Skip to content

Conversation

@elizabethengelman
Copy link
Collaborator

@elizabethengelman elizabethengelman commented Sep 13, 2024

This branch is based on #1590.

Companion Lab PR: stellar/laboratory#987 (merged)

old pr: #1579

What

Closes #1428

This PR adds the ability to sign a tx via lab, by opening lab in the browser with the xdr prefilled in the Lab UI.

To test, on this branch, run:

  • you can generate your tx xdr, but this example uses xdr created from deploying the test_hello_world contract.
    (stellar contract deploy --wasm target/wasm32-unknown-unknown/test-wasms/test_hello_world.wasm --build-only --network testnet --source testnet-alice)
  • run the following from the root dir of this project, on this branch:
echo AAAAAgAAAADcOHnq5sGLOngOCEMyLqqn5CvFV2HGbOSjJAIzhqBdkAAAAGQAEb7UAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAYAAAAAQAAAAAAAAAAAAAAANw4eermwYs6eA4IQzIuqqfkK8VXYcZs5KMkAjOGoF2Q04SY/PMseMCgfbEFkX5gTr9qD/d0mvD9H3acFOz/X5oAAAAALtGgcgsAibk5q8VOLY2R1G1NdGX7fLzlz7iBFBy64JIAAAAAAAAAAAAAAAA= \
| cargo run tx sign --network testnet \
--sign-with-lab \
--lab-url http://laboratory-pr987.previews.kube001.services.stellar-ops.com/transaction/sign

Why

This will allow for another way for users to sign their tx.

Known limitations

  • Based on discussions during our weekly check-in, this PR is the first step in implementing this feature. For now, when the user adds the --sign-with-lab flag, the CLI will send the transaction's xdr to lab via a query param, and then will print out the xdr to the stdout.

    In future iterations, we may want to send the signed tx xdr back to the command line, but for now the intention is to have the user either:
    a. send the transaction from lab
    b. manually copy the signed xdr from Lab, and paste it back in the command line to use with the cli

  • Instead of having the flag be --sign-with-lab, what if we change it to --sign-externally? This would open us up to allow a user to pass in any URL that accepts xdr and networkPasshrase as query params. 🤔

willemneal and others added 16 commits September 10, 2024 15:25
The new `sign` subcommand allows for signing a passed transaction envelope. And can choose a different source_account than the signing key's corresponding public key.

Additionally, `signer::{Transaction, TransactionHash, Blob}` traits which simplifies the interface. Using blanket implementations, any type that implements `Blob`, will implement, `TransactionHash` and any type that implements `TransactionHash` implements `Transaction`, which uses the hash. This will allow for types to opt in to how they want to sign the transaction.
willemneal and others added 2 commits September 16, 2024 09:36
Co-authored-by: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com>
@leighmcculloch leighmcculloch changed the title Feat/sign with lab feat: tx sign --sign-with-lab Sep 24, 2024
Base automatically changed from feat/tx_sign to main September 24, 2024 02:37
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I merged main into this PR to update it.

Some comments below.

@leighmcculloch leighmcculloch enabled auto-merge (squash) September 25, 2024 02:12
@leighmcculloch leighmcculloch enabled auto-merge (squash) September 25, 2024 02:51
@leighmcculloch leighmcculloch merged commit 3c5cc83 into main Sep 25, 2024
@leighmcculloch leighmcculloch deleted the feat/sign_with_lab branch September 25, 2024 02:54
printer.globeln(format!("Opening lab to sign transaction: {url}"));
open::that(url)?;

Err(Error::ReturningSignatureFromLab)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future it'd be good to add a TODO with a task number in the code

@willemneal willemneal linked an issue Oct 2, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add a tx sign command Enable the CLI to generate links or files compatible with the Stellar Lab

5 participants