diff --git a/packages/cli/examples/delegate.ts b/packages/cli/examples/delegate.ts index 51892dee..d4399628 100644 --- a/packages/cli/examples/delegate.ts +++ b/packages/cli/examples/delegate.ts @@ -27,8 +27,8 @@ console.log("Connected to chain:", chainId); const { accountNumber, sequence } = await client.getSequence(senderAddress); console.log("Account/sequence:", accountNumber, sequence); -const signBytes = makeSignBytes([msg], fee, chainId, memo, accountNumber, sequence); -const signature = await wallet.sign(senderAddress, signBytes); +const signDoc = makeStdSignDoc([msg], fee, chainId, memo, accountNumber, sequence); +const { signature } = await wallet.sign(senderAddress, signDoc); const signedTx: StdTx = { msg: [msg], fee: fee, diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index b338bce1..6db25cda 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -99,6 +99,7 @@ export async function main(originalArgs: readonly string[]): Promise { "logs", "makeCosmoshubPath", "makeSignBytes", + "makeStdSignDoc", "IndexedTx", "BroadcastTxResult", "Coin", @@ -115,6 +116,7 @@ export async function main(originalArgs: readonly string[]): Promise { "Secp256k1Wallet", "SigningCosmosClient", "StdFee", + "StdSignDoc", "StdTx", ], ], @@ -161,7 +163,13 @@ export async function main(originalArgs: readonly string[]): Promise { const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic, makeCosmoshubPath(0)); const [{ address }] = await wallet.getAccounts(); const data = toAscii("foo bar"); - const signature = await wallet.sign(address, data); + const fee: StdFee = { + amount: coins(5000000, "ucosm"), + gas: "89000000", + }; + const signDoc = makeStdSignDoc([], fee, "chain-xyz", "hello, world", 1, 2); + const { signed, signature } = await wallet.sign(address, signDoc); + assert(signed.memo === "hello, world"); const bechPubkey = "coralvalconspub1zcjduepqvxg72ccnl9r65fv0wn3amlk4sfzqfe2k36l073kjx2qyaf6sk23qw7j8wq"; assert(encodeBech32Pubkey(decodeBech32Pubkey(bechPubkey), "coralvalconspub") == bechPubkey);