Calculate Nonce from account number and sequence
This commit is contained in:
parent
ff57e8d2a7
commit
58634eb577
@ -19,7 +19,6 @@ import { assert } from "@iov/utils";
|
||||
import { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
import { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
import { signedTxJson, txId } from "./testdata.spec";
|
||||
import { nonceToSequence } from "./types";
|
||||
|
||||
const { fromBase64, toHex } = Encoding;
|
||||
|
||||
@ -317,9 +316,7 @@ describe("CosmWasmConnection", () => {
|
||||
expect(transaction.chainId).toEqual(unsigned.chainId);
|
||||
|
||||
expect(signatures.length).toEqual(1);
|
||||
// TODO: the nonce we recover in response doesn't have accountNumber, only sequence
|
||||
const signedSequence = nonceToSequence(signed.signatures[0].nonce);
|
||||
expect(signatures[0].nonce).toEqual(signedSequence);
|
||||
expect(signatures[0].nonce).toEqual(signed.signatures[0].nonce);
|
||||
expect(signatures[0].pubkey.algo).toEqual(signed.signatures[0].pubkey.algo);
|
||||
expect(toHex(signatures[0].pubkey.data)).toEqual(
|
||||
toHex(Secp256k1.compressPubkey(signed.signatures[0].pubkey.data)),
|
||||
|
||||
@ -372,9 +372,12 @@ export class CosmWasmConnection implements BlockchainConnection {
|
||||
|
||||
// tslint:disable-next-line: deprecation
|
||||
const accountForHeight = await this.restClient.authAccounts(senderAddress, response.height);
|
||||
// this is technically not the proper nonce. maybe this causes issues for sig validation?
|
||||
const accountNumber = accountForHeight.result.value.account_number;
|
||||
// this is technically not the proper sequence. maybe this causes issues for sig validation?
|
||||
// leaving for now unless it causes issues
|
||||
const sequence = (accountForHeight.result.value.sequence - 1) as Nonce;
|
||||
return parseTxsResponse(chainId, parseInt(response.height, 10), sequence, response, this.bankTokens);
|
||||
const sequence = accountForHeight.result.value.sequence - 1;
|
||||
const nonce = accountToNonce(accountNumber, sequence);
|
||||
|
||||
return parseTxsResponse(chainId, parseInt(response.height, 10), nonce, response, this.bankTokens);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user