Merge pull request #308 from CosmWasm/299-rename-getnonce-getsequence
Rename getNonce -> getSequence
This commit is contained in:
commit
0e20be743c
@ -24,7 +24,7 @@ const memo = "Use your power wisely";
|
||||
const chainId = await client.getChainId();
|
||||
console.log("Connected to chain:", chainId);
|
||||
|
||||
const { accountNumber, sequence } = await client.getNonce(senderAddress);
|
||||
const { accountNumber, sequence } = await client.getSequence(senderAddress);
|
||||
console.log("Account/sequence:", accountNumber, sequence);
|
||||
|
||||
const signBytes = makeSignBytes([msg], fee, chainId, memo, accountNumber, sequence);
|
||||
|
||||
@ -41,7 +41,7 @@ export function main(originalArgs: readonly string[]): void {
|
||||
"Contract",
|
||||
"ContractDetails",
|
||||
"CosmWasmClient",
|
||||
"GetNonceResult",
|
||||
"GetSequenceResult",
|
||||
"PostTxResult",
|
||||
"SearchByHeightQuery",
|
||||
"SearchByIdQuery",
|
||||
|
||||
@ -100,7 +100,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "80000", // 80k
|
||||
};
|
||||
const { accountNumber, sequence } = await client.getNonce();
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const chainId = await client.getChainId();
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await wallet.sign(alice.address0, signBytes);
|
||||
|
||||
@ -105,11 +105,11 @@ describe("CosmWasmClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getNonce", () => {
|
||||
describe("getSequence", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
expect(await client.getNonce(unused.address)).toEqual({
|
||||
expect(await client.getSequence(unused.address)).toEqual({
|
||||
accountNumber: unused.accountNumber,
|
||||
sequence: unused.sequence,
|
||||
});
|
||||
@ -119,7 +119,7 @@ describe("CosmWasmClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const missing = makeRandomAddress();
|
||||
await client.getNonce(missing).then(
|
||||
await client.getSequence(missing).then(
|
||||
() => fail("this must not succeed"),
|
||||
(error) => expect(error).toMatch(/account does not exist on chain/i),
|
||||
);
|
||||
@ -233,7 +233,7 @@ describe("CosmWasmClient", () => {
|
||||
};
|
||||
|
||||
const chainId = await client.getChainId();
|
||||
const { accountNumber, sequence } = await client.getNonce(alice.address0);
|
||||
const { accountNumber, sequence } = await client.getSequence(alice.address0);
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await wallet.sign(alice.address0, signBytes);
|
||||
const signedTx = {
|
||||
|
||||
@ -18,7 +18,7 @@ import { setupWasmExtension, WasmExtension } from "./lcdapi/wasm";
|
||||
import { Log, parseLogs } from "./logs";
|
||||
import { JsonObject } from "./types";
|
||||
|
||||
export interface GetNonceResult {
|
||||
export interface GetSequenceResult {
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
}
|
||||
@ -231,11 +231,11 @@ export class CosmWasmClient {
|
||||
*
|
||||
* @param address returns data for this address. When unset, the client's sender adddress is used.
|
||||
*/
|
||||
public async getNonce(address: string): Promise<GetNonceResult> {
|
||||
public async getSequence(address: string): Promise<GetSequenceResult> {
|
||||
const account = await this.getAccount(address);
|
||||
if (!account) {
|
||||
throw new Error(
|
||||
"Account does not exist on chain. Send some tokens there before trying to query nonces.",
|
||||
"Account does not exist on chain. Send some tokens there before trying to query sequence.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
|
||||
@ -11,7 +11,7 @@ export {
|
||||
Contract,
|
||||
ContractDetails,
|
||||
CosmWasmClient,
|
||||
GetNonceResult,
|
||||
GetSequenceResult,
|
||||
PostTxResult,
|
||||
SearchByHeightQuery,
|
||||
SearchByIdQuery,
|
||||
|
||||
@ -19,7 +19,7 @@ import { isValidBuilder } from "./builder";
|
||||
import {
|
||||
Account,
|
||||
CosmWasmClient,
|
||||
GetNonceResult,
|
||||
GetSequenceResult,
|
||||
isPostTxFailure,
|
||||
PostTxFailure,
|
||||
PostTxResult,
|
||||
@ -196,8 +196,8 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
this.fees = { ...defaultFees, ...(customFees || {}) };
|
||||
}
|
||||
|
||||
public async getNonce(address?: string): Promise<GetNonceResult> {
|
||||
return super.getNonce(address || this.senderAddress);
|
||||
public async getSequence(address?: string): Promise<GetSequenceResult> {
|
||||
return super.getSequence(address || this.senderAddress);
|
||||
}
|
||||
|
||||
public async getAccount(address?: string): Promise<Account | undefined> {
|
||||
@ -220,7 +220,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.upload;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([storeCodeMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
@ -266,7 +266,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
};
|
||||
const memo = options.memo || "";
|
||||
const fee = this.fees.init;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([instantiateMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
|
||||
@ -300,7 +300,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.changeAdmin;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([updateAdminMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
@ -330,7 +330,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.changeAdmin;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([clearAdminMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
@ -367,7 +367,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.migrate;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([msg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
@ -404,7 +404,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.exec;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([executeMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
@ -439,7 +439,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.send;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
|
||||
4
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
4
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
@ -11,7 +11,7 @@ import {
|
||||
import { WasmExtension } from "./lcdapi/wasm";
|
||||
import { Log } from "./logs";
|
||||
import { JsonObject } from "./types";
|
||||
export interface GetNonceResult {
|
||||
export interface GetSequenceResult {
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
}
|
||||
@ -154,7 +154,7 @@ export declare class CosmWasmClient {
|
||||
*
|
||||
* @param address returns data for this address. When unset, the client's sender adddress is used.
|
||||
*/
|
||||
getNonce(address: string): Promise<GetNonceResult>;
|
||||
getSequence(address: string): Promise<GetSequenceResult>;
|
||||
getAccount(address: string): Promise<Account | undefined>;
|
||||
/**
|
||||
* Gets block header and meta
|
||||
|
||||
2
packages/cosmwasm/types/index.d.ts
vendored
2
packages/cosmwasm/types/index.d.ts
vendored
@ -10,7 +10,7 @@ export {
|
||||
Contract,
|
||||
ContractDetails,
|
||||
CosmWasmClient,
|
||||
GetNonceResult,
|
||||
GetSequenceResult,
|
||||
PostTxResult,
|
||||
SearchByHeightQuery,
|
||||
SearchByIdQuery,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { BroadcastMode, Coin, OfflineSigner, StdFee, StdSignature } from "@cosmjs/sdk38";
|
||||
import { Account, CosmWasmClient, GetNonceResult, PostTxResult } from "./cosmwasmclient";
|
||||
import { Account, CosmWasmClient, GetSequenceResult, PostTxResult } from "./cosmwasmclient";
|
||||
import { Log } from "./logs";
|
||||
export interface SigningCallback {
|
||||
(signBytes: Uint8Array): Promise<StdSignature>;
|
||||
@ -104,7 +104,7 @@ export declare class SigningCosmWasmClient extends CosmWasmClient {
|
||||
customFees?: Partial<FeeTable>,
|
||||
broadcastMode?: BroadcastMode,
|
||||
);
|
||||
getNonce(address?: string): Promise<GetNonceResult>;
|
||||
getSequence(address?: string): Promise<GetSequenceResult>;
|
||||
getAccount(address?: string): Promise<Account | undefined>;
|
||||
/** Uploads code and returns a receipt, including the code ID */
|
||||
upload(wasmCode: Uint8Array, meta?: UploadMeta, memo?: string): Promise<UploadResult>;
|
||||
|
||||
@ -53,7 +53,7 @@ describe("CosmosClient.searchTx", () => {
|
||||
amount: coins(2000, "ucosm"),
|
||||
gas: "80000", // 80k
|
||||
};
|
||||
const { accountNumber, sequence } = await client.getNonce();
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const chainId = await client.getChainId();
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await wallet.sign(walletAddress, signBytes);
|
||||
|
||||
@ -94,11 +94,11 @@ describe("CosmosClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getNonce", () => {
|
||||
describe("getSequence", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmosClient(wasmd.endpoint);
|
||||
expect(await client.getNonce(unused.address)).toEqual({
|
||||
expect(await client.getSequence(unused.address)).toEqual({
|
||||
accountNumber: unused.accountNumber,
|
||||
sequence: unused.sequence,
|
||||
});
|
||||
@ -108,7 +108,7 @@ describe("CosmosClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmosClient(wasmd.endpoint);
|
||||
const missing = makeRandomAddress();
|
||||
await client.getNonce(missing).then(
|
||||
await client.getSequence(missing).then(
|
||||
() => fail("this must not succeed"),
|
||||
(error) => expect(error).toMatch(/account does not exist on chain/i),
|
||||
);
|
||||
@ -224,7 +224,7 @@ describe("CosmosClient", () => {
|
||||
};
|
||||
|
||||
const chainId = await client.getChainId();
|
||||
const { accountNumber, sequence } = await client.getNonce(faucet.address);
|
||||
const { accountNumber, sequence } = await client.getSequence(faucet.address);
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await wallet.sign(walletAddress, signBytes);
|
||||
const signedTx = {
|
||||
|
||||
@ -8,7 +8,7 @@ import { Log, parseLogs } from "./logs";
|
||||
import { decodeBech32Pubkey } from "./pubkey";
|
||||
import { CosmosSdkTx, PubKey, StdTx } from "./types";
|
||||
|
||||
export interface GetNonceResult {
|
||||
export interface GetSequenceResult {
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
}
|
||||
@ -196,11 +196,11 @@ export class CosmosClient {
|
||||
*
|
||||
* @param address returns data for this address. When unset, the client's sender adddress is used.
|
||||
*/
|
||||
public async getNonce(address: string): Promise<GetNonceResult> {
|
||||
public async getSequence(address: string): Promise<GetSequenceResult> {
|
||||
const account = await this.getAccount(address);
|
||||
if (!account) {
|
||||
throw new Error(
|
||||
"Account does not exist on chain. Send some tokens there before trying to query nonces.",
|
||||
"Account does not exist on chain. Send some tokens there before trying to query sequence.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
|
||||
@ -9,7 +9,7 @@ export {
|
||||
Block,
|
||||
BlockHeader,
|
||||
CosmosClient,
|
||||
GetNonceResult,
|
||||
GetSequenceResult,
|
||||
IndexedTx,
|
||||
PostTxResult,
|
||||
SearchByHeightQuery,
|
||||
|
||||
@ -45,7 +45,7 @@ describe("DistributionExtension", () => {
|
||||
},
|
||||
};
|
||||
const memo = "Test delegation for wasmd";
|
||||
const { accountNumber, sequence } = await client.getNonce();
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const signBytes = makeSignBytes([msg], defaultFee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await wallet.sign(faucet.address, signBytes);
|
||||
const tx = {
|
||||
|
||||
@ -49,7 +49,7 @@ describe("GovExtension", () => {
|
||||
},
|
||||
};
|
||||
const proposalMemo = "Test proposal for wasmd";
|
||||
const { accountNumber: proposalAccountNumber, sequence: proposalSequence } = await client.getNonce();
|
||||
const { accountNumber: proposalAccountNumber, sequence: proposalSequence } = await client.getSequence();
|
||||
const proposalSignBytes = makeSignBytes(
|
||||
[proposalMsg],
|
||||
defaultFee,
|
||||
@ -81,7 +81,7 @@ describe("GovExtension", () => {
|
||||
},
|
||||
};
|
||||
const voteMemo = "Test vote for wasmd";
|
||||
const { accountNumber: voteAccountNumber, sequence: voteSequence } = await client.getNonce();
|
||||
const { accountNumber: voteAccountNumber, sequence: voteSequence } = await client.getSequence();
|
||||
const voteSignBytes = makeSignBytes(
|
||||
[voteMsg],
|
||||
defaultFee,
|
||||
|
||||
@ -261,7 +261,7 @@ describe("LcdClient", () => {
|
||||
],
|
||||
gas: "80000", // 80k
|
||||
};
|
||||
const { accountNumber, sequence } = await client.getNonce();
|
||||
const { accountNumber, sequence } = await client.getSequence();
|
||||
const chainId = await client.getChainId();
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await wallet.sign(walletAddress, signBytes);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Coin, coins } from "./coins";
|
||||
import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient";
|
||||
import { Account, CosmosClient, GetSequenceResult, PostTxResult } from "./cosmosclient";
|
||||
import { makeSignBytes } from "./encoding";
|
||||
import { BroadcastMode } from "./lcdapi";
|
||||
import { MsgSend } from "./msgs";
|
||||
@ -66,8 +66,8 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
this.fees = { ...defaultFees, ...(customFees || {}) };
|
||||
}
|
||||
|
||||
public async getNonce(address?: string): Promise<GetNonceResult> {
|
||||
return super.getNonce(address || this.senderAddress);
|
||||
public async getSequence(address?: string): Promise<GetSequenceResult> {
|
||||
return super.getSequence(address || this.senderAddress);
|
||||
}
|
||||
|
||||
public async getAccount(address?: string): Promise<Account | undefined> {
|
||||
@ -88,7 +88,7 @@ export class SigningCosmosClient extends CosmosClient {
|
||||
},
|
||||
};
|
||||
const fee = this.fees.send;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const { accountNumber, sequence } = await this.getSequence();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signer.sign(this.senderAddress, signBytes);
|
||||
|
||||
4
packages/sdk38/types/cosmosclient.d.ts
vendored
4
packages/sdk38/types/cosmosclient.d.ts
vendored
@ -2,7 +2,7 @@ import { Coin } from "./coins";
|
||||
import { AuthExtension, BroadcastMode, LcdClient } from "./lcdapi";
|
||||
import { Log } from "./logs";
|
||||
import { CosmosSdkTx, PubKey, StdTx } from "./types";
|
||||
export interface GetNonceResult {
|
||||
export interface GetSequenceResult {
|
||||
readonly accountNumber: number;
|
||||
readonly sequence: number;
|
||||
}
|
||||
@ -124,7 +124,7 @@ export declare class CosmosClient {
|
||||
*
|
||||
* @param address returns data for this address. When unset, the client's sender adddress is used.
|
||||
*/
|
||||
getNonce(address: string): Promise<GetNonceResult>;
|
||||
getSequence(address: string): Promise<GetSequenceResult>;
|
||||
getAccount(address: string): Promise<Account | undefined>;
|
||||
/**
|
||||
* Gets block header and meta
|
||||
|
||||
2
packages/sdk38/types/index.d.ts
vendored
2
packages/sdk38/types/index.d.ts
vendored
@ -7,7 +7,7 @@ export {
|
||||
Block,
|
||||
BlockHeader,
|
||||
CosmosClient,
|
||||
GetNonceResult,
|
||||
GetSequenceResult,
|
||||
IndexedTx,
|
||||
PostTxResult,
|
||||
SearchByHeightQuery,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Coin } from "./coins";
|
||||
import { Account, CosmosClient, GetNonceResult, PostTxResult } from "./cosmosclient";
|
||||
import { Account, CosmosClient, GetSequenceResult, PostTxResult } from "./cosmosclient";
|
||||
import { BroadcastMode } from "./lcdapi";
|
||||
import { StdFee } from "./types";
|
||||
import { OfflineSigner } from "./wallet";
|
||||
@ -32,7 +32,7 @@ export declare class SigningCosmosClient extends CosmosClient {
|
||||
customFees?: Partial<FeeTable>,
|
||||
broadcastMode?: BroadcastMode,
|
||||
);
|
||||
getNonce(address?: string): Promise<GetNonceResult>;
|
||||
getSequence(address?: string): Promise<GetSequenceResult>;
|
||||
getAccount(address?: string): Promise<Account | undefined>;
|
||||
sendTokens(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<PostTxResult>;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ You should get output matching the following:
|
||||
Pubkey 2: A6e9ElvKaM0DKWh1bIdK3bgB14dyEDgIXYMA0Lbs1GoQ<br>
|
||||
Pubkey 3: AkAK5PQaucieWMb0+tTRY01feYI+upRnoNK556eD0Ibb<br>
|
||||
Pubkey 4: A5HMVEAJsupdQWItbZv5Z1xZifDixQi6tjU/hJpZY1bF
|
||||
4. **Unused**: for testing account state; this account never changes balances or nonces<br>
|
||||
4. **Unused**: for testing account state; this account never changes balances or sequences<br>
|
||||
oyster design unusual machine spread century engine gravity focus cave carry slot<br>
|
||||
ArkCaFUJ/IH+vKBmNRCdUVl3mCAhbopk9jjW4Ko4OfRQ<br>
|
||||
cosmos1cjsxept9rkggzxztslae9ndgpdyt2408lk850u
|
||||
|
||||
Loading…
Reference in New Issue
Block a user