sdk38: Rename getNonce -> getSequence
This commit is contained in:
parent
d86dd3ed7c
commit
7159896d88
@ -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);
|
||||
|
||||
@ -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 = {
|
||||
|
||||
@ -231,7 +231,7 @@ 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<GetNonceResult> {
|
||||
const account = await this.getAccount(address);
|
||||
if (!account) {
|
||||
throw new Error(
|
||||
|
||||
@ -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<GetNonceResult> {
|
||||
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);
|
||||
|
||||
2
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
2
packages/cosmwasm/types/cosmwasmclient.d.ts
vendored
@ -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<GetNonceResult>;
|
||||
getAccount(address: string): Promise<Account | undefined>;
|
||||
/**
|
||||
* Gets block header and meta
|
||||
|
||||
@ -104,7 +104,7 @@ export declare class SigningCosmWasmClient extends CosmWasmClient {
|
||||
customFees?: Partial<FeeTable>,
|
||||
broadcastMode?: BroadcastMode,
|
||||
);
|
||||
getNonce(address?: string): Promise<GetNonceResult>;
|
||||
getSequence(address?: string): Promise<GetNonceResult>;
|
||||
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 = {
|
||||
|
||||
@ -196,7 +196,7 @@ 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<GetNonceResult> {
|
||||
const account = await this.getAccount(address);
|
||||
if (!account) {
|
||||
throw new Error(
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<GetNonceResult> {
|
||||
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);
|
||||
|
||||
2
packages/sdk38/types/cosmosclient.d.ts
vendored
2
packages/sdk38/types/cosmosclient.d.ts
vendored
@ -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<GetNonceResult>;
|
||||
getAccount(address: string): Promise<Account | undefined>;
|
||||
/**
|
||||
* Gets block header and meta
|
||||
|
||||
@ -32,7 +32,7 @@ export declare class SigningCosmosClient extends CosmosClient {
|
||||
customFees?: Partial<FeeTable>,
|
||||
broadcastMode?: BroadcastMode,
|
||||
);
|
||||
getNonce(address?: string): Promise<GetNonceResult>;
|
||||
getSequence(address?: string): Promise<GetNonceResult>;
|
||||
getAccount(address?: string): Promise<Account | undefined>;
|
||||
sendTokens(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<PostTxResult>;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user