// PREVIOUS CODE EXAMPLE
//it is recommended to fetch ledger offset before preparing your command
const offsetLatest = (await sdk.userLedger?.ledgerEnd())?.offset ?? 0
const transferCommandId =
// prepareSignAndExecuteTransaction & prepareSign now returns the commandId
await sdk.userLedger?.prepareSignAndExecuteTransaction(
[{ ExerciseCommand: transferCommand }],
keyPairSender.privateKey,
v4(),
disclosedContracts2
)
//new command that scans the ledger to ensure the command have completed
const completion = await sdk.userLedger?.waitForCompletion(
offsetLatest, //where to start from
5000, //optional timeout in ms
transferCommandId! //the command to look for
)
// NEW VARIATION
const completion =
await sdk.userLedger?.prepareSignExecuteAndWaitFor(
transferCommand,
keyPairSender.privateKey,
v4(),
disclosedContracts,
10000 // 10 second timeout, if no value is provided here a default of 15 seconds is used
)
// VARIATION FOR `ExecuteSubmission`
const completion =
await onlineSDK.userLedger?.executeSubmissionAndWaitFor(
transferCommand,
signedHash,
keyPairSender.publicKey,
v4()
)