feat(timeout-height): use bigint instead long
This commit is contained in:
parent
d7bf870e6c
commit
efeb501b69
@ -62,7 +62,7 @@ export function makeSignDoc(
|
||||
memo: string | undefined,
|
||||
accountNumber: number | string,
|
||||
sequence: number | string,
|
||||
timeout_height?: string,
|
||||
timeout_height?: bigint,
|
||||
): StdSignDoc {
|
||||
return {
|
||||
chain_id: chainId,
|
||||
@ -71,7 +71,7 @@ export function makeSignDoc(
|
||||
fee: fee,
|
||||
msgs: msgs,
|
||||
memo: memo || "",
|
||||
...(timeout_height && { timeout_height }),
|
||||
...(timeout_height && { timeout_height: timeout_height.toString() }),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1214,14 +1214,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
};
|
||||
const memo = "Use your power wisely";
|
||||
const height = await client.getHeight();
|
||||
const signed = await client.sign(
|
||||
alice.address0,
|
||||
[msgAny],
|
||||
fee,
|
||||
memo,
|
||||
undefined,
|
||||
Long.fromNumber(height + 1),
|
||||
);
|
||||
const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height + 3));
|
||||
|
||||
// ensure signature is valid
|
||||
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
|
||||
@ -1468,14 +1461,7 @@ describe("SigningCosmWasmClient", () => {
|
||||
};
|
||||
const memo = "Use your tokens wisely";
|
||||
const height = await client.getHeight();
|
||||
const signed = await client.sign(
|
||||
alice.address0,
|
||||
[msgAny],
|
||||
fee,
|
||||
memo,
|
||||
undefined,
|
||||
Long.fromNumber(height + 1),
|
||||
);
|
||||
const signed = await client.sign(alice.address0, [msgAny], fee, memo, undefined, BigInt(height + 3));
|
||||
|
||||
// ensure signature is valid
|
||||
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
|
||||
|
||||
@ -643,7 +643,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
fee: StdFee,
|
||||
memo: string,
|
||||
explicitSignerData?: SignerData,
|
||||
timeoutHeight?: Long,
|
||||
timeoutHeight?: bigint,
|
||||
): Promise<TxRaw> {
|
||||
let signerData: SignerData;
|
||||
if (explicitSignerData) {
|
||||
@ -669,7 +669,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
fee: StdFee,
|
||||
memo: string,
|
||||
{ accountNumber, sequence, chainId }: SignerData,
|
||||
timeoutHeight?: Long,
|
||||
timeoutHeight?: bigint,
|
||||
): Promise<TxRaw> {
|
||||
assert(!isOfflineDirectSigner(this.signer));
|
||||
const accountFromSigner = (await this.signer.getAccounts()).find(
|
||||
@ -681,15 +681,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
const pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
||||
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
||||
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
||||
const signDoc = makeSignDocAmino(
|
||||
msgs,
|
||||
fee,
|
||||
chainId,
|
||||
memo,
|
||||
accountNumber,
|
||||
sequence,
|
||||
timeoutHeight?.toString(),
|
||||
);
|
||||
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight);
|
||||
const { signature, signed } = await this.signer.signAmino(signerAddress, signDoc);
|
||||
const signedTxBody: TxBodyEncodeObject = {
|
||||
typeUrl: "/cosmos.tx.v1beta1.TxBody",
|
||||
@ -723,7 +715,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
fee: StdFee,
|
||||
memo: string,
|
||||
{ accountNumber, sequence, chainId }: SignerData,
|
||||
timeoutHeight?: Long,
|
||||
timeoutHeight?: bigint,
|
||||
): Promise<TxRaw> {
|
||||
assert(isOfflineDirectSigner(this.signer));
|
||||
const accountFromSigner = (await this.signer.getAccounts()).find(
|
||||
|
||||
@ -936,14 +936,7 @@ describe("SigningStargateClient", () => {
|
||||
};
|
||||
const memo = "Use your power wisely";
|
||||
const height = await client.getHeight();
|
||||
const signed = await client.sign(
|
||||
faucet.address0,
|
||||
[msgAny],
|
||||
fee,
|
||||
memo,
|
||||
undefined,
|
||||
Long.fromNumber(height + 1),
|
||||
);
|
||||
const signed = await client.sign(faucet.address0, [msgAny], fee, memo, undefined, BigInt(height + 3));
|
||||
|
||||
// ensure signature is valid
|
||||
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
|
||||
@ -1184,14 +1177,7 @@ describe("SigningStargateClient", () => {
|
||||
};
|
||||
const memo = "Use your tokens wisely";
|
||||
const height = await client.getHeight();
|
||||
const signed = await client.sign(
|
||||
faucet.address0,
|
||||
[msgAny],
|
||||
fee,
|
||||
memo,
|
||||
undefined,
|
||||
Long.fromNumber(height + 1),
|
||||
);
|
||||
const signed = await client.sign(faucet.address0, [msgAny], fee, memo, undefined, BigInt(height + 3));
|
||||
|
||||
// ensure signature is valid
|
||||
const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish()));
|
||||
|
||||
@ -371,7 +371,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
fee: StdFee,
|
||||
memo: string,
|
||||
explicitSignerData?: SignerData,
|
||||
timeoutHeight?: Long,
|
||||
timeoutHeight?: bigint,
|
||||
): Promise<TxRaw> {
|
||||
let signerData: SignerData;
|
||||
if (explicitSignerData) {
|
||||
@ -397,7 +397,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
fee: StdFee,
|
||||
memo: string,
|
||||
{ accountNumber, sequence, chainId }: SignerData,
|
||||
timeoutHeight?: Long,
|
||||
timeoutHeight?: bigint,
|
||||
): Promise<TxRaw> {
|
||||
assert(!isOfflineDirectSigner(this.signer));
|
||||
const accountFromSigner = (await this.signer.getAccounts()).find(
|
||||
@ -409,15 +409,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
const pubkey = encodePubkey(encodeSecp256k1Pubkey(accountFromSigner.pubkey));
|
||||
const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
|
||||
const msgs = messages.map((msg) => this.aminoTypes.toAmino(msg));
|
||||
const signDoc = makeSignDocAmino(
|
||||
msgs,
|
||||
fee,
|
||||
chainId,
|
||||
memo,
|
||||
accountNumber,
|
||||
sequence,
|
||||
timeoutHeight?.toString(),
|
||||
);
|
||||
const signDoc = makeSignDocAmino(msgs, fee, chainId, memo, accountNumber, sequence, timeoutHeight);
|
||||
const { signature, signed } = await this.signer.signAmino(signerAddress, signDoc);
|
||||
const signedTxBody = {
|
||||
messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
|
||||
@ -452,7 +444,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
fee: StdFee,
|
||||
memo: string,
|
||||
{ accountNumber, sequence, chainId }: SignerData,
|
||||
timeoutHeight?: Long,
|
||||
timeoutHeight?: bigint,
|
||||
): Promise<TxRaw> {
|
||||
assert(isOfflineDirectSigner(this.signer));
|
||||
const accountFromSigner = (await this.signer.getAccounts()).find(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user