stargate: Update for new OfflineSigner

This commit is contained in:
willclarktech 2020-10-21 16:27:54 +02:00
parent e3069e35a1
commit 716f318bd9
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 12 additions and 11 deletions

View File

@ -4,8 +4,8 @@ import { Coin, coins } from "@cosmjs/launchpad";
import {
DirectSecp256k1Wallet,
encodePubkey,
makeAuthInfo,
makeSignBytes,
makeAuthInfoBytes,
makeSignDoc,
Registry,
} from "@cosmjs/proto-signing";
import { assert, sleep } from "@cosmjs/utils";
@ -70,15 +70,15 @@ async function sendTokens(
},
];
const gasLimit = 200000;
const authInfoBytes = makeAuthInfo([pubkey], feeAmount, gasLimit, sequence);
const authInfoBytes = makeAuthInfoBytes([pubkey], feeAmount, gasLimit, sequence);
const chainId = await client.getChainId();
const signDocBytes = makeSignBytes(txBodyBytes, authInfoBytes, chainId, accountNumber);
const signature = await wallet.sign(walletAddress, signDocBytes);
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
const signResponse = await wallet.signDirect(walletAddress, signDoc);
const txRaw = TxRaw.create({
bodyBytes: txBodyBytes,
authInfoBytes: authInfoBytes,
signatures: [fromBase64(signature.signature)],
signatures: [fromBase64(signResponse.signature.signature)],
});
const txRawBytes = Uint8Array.from(TxRaw.encode(txRaw).finish());
const broadcastResponse = await client.broadcastTx(txRawBytes);

View File

@ -3,8 +3,9 @@ import { fromBase64, toBase64 } from "@cosmjs/encoding";
import {
DirectSecp256k1Wallet,
encodePubkey,
makeAuthInfo,
makeAuthInfoBytes,
makeSignBytes,
makeSignDoc,
Registry,
} from "@cosmjs/proto-signing";
import { assert, sleep } from "@cosmjs/utils";
@ -292,15 +293,15 @@ describe("StargateClient", () => {
},
];
const gasLimit = 200000;
const authInfoBytes = makeAuthInfo([pubkey], feeAmount, gasLimit, sequence);
const authInfoBytes = makeAuthInfoBytes([pubkey], feeAmount, gasLimit, sequence);
const chainId = await client.getChainId();
const signDocBytes = makeSignBytes(txBodyBytes, authInfoBytes, chainId, accountNumber);
const signature = await wallet.sign(address, signDocBytes);
const signDoc = makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
const signResponse = await wallet.signDirect(address, signDoc);
const txRaw = TxRaw.create({
bodyBytes: txBodyBytes,
authInfoBytes: authInfoBytes,
signatures: [fromBase64(signature.signature)],
signatures: [fromBase64(signResponse.signature.signature)],
});
const txRawBytes = Uint8Array.from(TxRaw.encode(txRaw).finish());
const txResult = await client.broadcastTx(txRawBytes);