Skip to content

Conversation

@mkaczanowski
Copy link
Contributor

@mkaczanowski mkaczanowski commented Mar 10, 2025

TL;DR

The sign method does a few other things (like wallet creation etc) prior calling the signer. If SDK user wants to skip the signer, he/she would have to replicate some of the logic which ain't great.

This PR splits the sign method into:

  1. prepareSigningData - prepare the final transaction
  2. prepareSignerTx - turns signed TxCell into a SignedTx structure

Example without signer abstraction:

const staker = TonPoolStaker(...)
const externalCustomSigner = signer({ ... })
const { signerAddress, signerPublicKey } = signer({...})

const signingData = await this.prepareSigningData({
  signerAddress,
  signerPublicKey,
  tx: await staker.buildStakeTx(...)
})

// sign transaction via custom signer or call some method that returns signed cell
const signedTxCell = await externalCustomSigner.sign(signingData.txCell)

const signedTx = await this.prepareSignedTx({
  signerAddress,
  signedTxCell,
  stateInit: signingData.txArgs.stateInit
})

staker.broadcast({ signedTx })

Test Plan

https://testnet.tonviewer.com/transaction/58a1db257f9309c587063f9439cbfef8738b6b52fcc2dafa2592e220d7f30996

Copy link
Collaborator

@welldan97 welldan97 left a comment

Choose a reason for hiding this comment

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

Looking great, we support multistep signing now

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

Successfully merging this pull request may close these issues.

2 participants