Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contract client: add sign method, in addition to signAndSend #979

Closed
chadoh opened this issue May 31, 2024 · 1 comment
Closed

contract client: add sign method, in addition to signAndSend #979

chadoh opened this issue May 31, 2024 · 1 comment

Comments

@chadoh
Copy link
Contributor

chadoh commented May 31, 2024

Is your feature request related to a problem? Please describe.

Right now, using a contract client, there is no way to sign a transaction without also sending. There's some nice functionality around signing that's trapped inside the private send method of the `SentTransaction class.

Describe the solution you'd like

Let's move that logic to AssembledTransaction.sign, which will set this.signed on AssembledTransaction rather than SentTransaction. Then AssembledTransaction#signAndSend will call this, before calling SentTransaction.init, and SentTransaction.init will check that this.assembled.signed exists.

In addition to AssembledTransaction#sign, we will need an AssembledTransaction.send. It will need to check that this.signed is present. And, probably, signAndSend can check if this.signed is present, and avoid re-signing if so, making it equivalent to send in that case.

Describe alternatives you've considered

When first creating contract client, I really wanted an interface like

await assembledTx.sign().send()

But you can't do that, it ends up like

await (await assembledTx.sign()).send()

...or something equivalently ugly. It gets even worse if you wanted to require people to also include simulate in the chain:

await (await (await assembledTx.simulate()).sign()).send() 

OK, we COULD do the "bundled-await" approach, and I almost did, but @willemneal talked me out of it because it would lead to a large number of foot-guns and quite complex code.

After hemming and hawing and being annoyed at JS for a long time, we opted to bundle signAndSend(), since we guessed that people would want that 95+% of the time.

@kalepail would now like to be able to sign without sending, so it makes sense to add sign and send, in addition to the combined signAndSend.

@chadoh
Copy link
Contributor Author

chadoh commented Jun 7, 2024

@Shaptic I can't assign people to issues in this repo. Could you give me permission? @BlaineHeffron is going to work on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants