Executing Signers #296
hayes-mysten
started this conversation in
Technical Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal for executing signers
Current state
Today transactions are primarily executed in 3 ways:
client.signAndExecuteTransaction
methodThese patterns have lead to some inconsistencies and incompatibilities in our SDKs.
Goals
Some things we would like future versions of our SDKs to be able to do:
Solution
To execute transactions, SDKs need both a
Signer
and aClient
. The signer produces the signature, and the client is used to build the transaction and executes it.Today, the
Client
is aSuiClient
, but is being replaced with a more limitedCoreClient
instead. TheCoreClient
and still be used to build and execute transactions, but will not have asignAndExecuteTransaction
method.We can instead add a
signAndExecuteTransaction
method the the baseSigner
class, which will take the transaction, and theCoreClient
as arguments. The baseSigner
will implement this by callingtransaction.build({ client })
to build the transaction, signing it with it's ownsignTransaction
method, and then executing it with theCoreClient
.This by itself does not change much, but if SDKs all use
signer.signAndExecuteTransaction
instead ofclient.signAndExecuteTransaction
, we can provide various executing signer implementations to customize the transaction execution process.WalletSigner
The most important of these will be a new
WalletSigner
exposed fromdapp-kit
that will enable signing/executing with the currently connected wallet/account. This signer would implement the normalsignTransaction
andsignPersonalMessage
methods using the corresponding wallet-standard features, but would also implement a customsignAndExecuteTransaction
method that uses thesignAndExecuteTransaction
wallet-standard feature.As long as SDKs are updated to use
signer.signAndExecuteTransaction
instead ofclient.signAndExecuteTransaction
, SDKs will automatically work with this new wallet signer, and transactions will be executed in the wallet instead of the dapp when using theWalletSigner
.SponsoredSigner
A sponsored signer could be implemented as:
This allows any signer to be used with a sponsorship flow, by wrapping it with a
SponsoredSigner
.Custom executors
Custom executors that parallelize execution, or cache transaction effects could work the same way, by wrapping another signer with custom execution logic.
Signers in dapp-kit
Dapp-kit methods like
signAndExecuteTransaction
could also acceptsigner
instances to customize execution, defaulting to theWalletSigner
if no signer is provided.Alternatively, we could omit methods like
signAndExecuteTransaction
from dapp-kit, and instead only expose theWalletSigner
from dapp-kit, so both dapps and SDKs always directly use theWalletSigner
instead.Problems to solve
Execution results
The biggest problem with this proposal is the return type of the
signAndExecuteTransaction
method. Today, SDKs are tied to the JSON RPC response ofsignAndExecuteTransaction
, which can accept a number of options to customize the returned data.I think the ideal answer would be to base this on the new
Core
executeTransaction
method. The downside of this is that aWalletSigner
would not currently get the same data from thesignAndExecuteTransaction
feature.We could query for the transaction in the
WalletSigner
after execution, but this would be less efficient.Does this belong in dapp-kit?
Should
WalletSigner
be part of dapp-kit, or should we just add a lower level implementation on top of the wallet standard that dapp-kit also consumes?Beta Was this translation helpful? Give feedback.
All reactions