mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Add getAccount to CosmWasmClient
This commit is contained in:
parent
d4f5d1b801
commit
b39a54211b
@ -73,6 +73,25 @@ describe("CosmWasmClient", () => {
|
||||
sequence: 0,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe("getAccount", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutCosmos();
|
||||
const client = CosmWasmClient.makeReadOnly(httpUrl);
|
||||
expect(await client.getAccount(unusedAccount.address)).toEqual({
|
||||
address: unusedAccount.address,
|
||||
account_number: 5,
|
||||
sequence: 0,
|
||||
public_key: "",
|
||||
coins: [
|
||||
{denom: 'ucosm', amount: '1000000000'},
|
||||
{denom: 'ustake', amount: '1000000000'},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("getBlock", () => {
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
MsgStoreCode,
|
||||
StdFee,
|
||||
StdSignature,
|
||||
CosmosSdkAccount,
|
||||
} from "./types";
|
||||
|
||||
const defaultUploadFee: StdFee = {
|
||||
@ -150,13 +151,18 @@ 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> {
|
||||
const account = (await this.restClient.authAccounts(address || this.senderAddress)).result.value;
|
||||
const account = await this.getAccount(address);
|
||||
return {
|
||||
accountNumber: account.account_number,
|
||||
sequence: account.sequence,
|
||||
};
|
||||
}
|
||||
|
||||
public async getAccount(address?: string): Promise<CosmosSdkAccount> {
|
||||
const account = await this.restClient.authAccounts(address || this.senderAddress);
|
||||
return account.result.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets block header and meta
|
||||
*
|
||||
|
3
packages/sdk/types/cosmwasmclient.d.ts
vendored
3
packages/sdk/types/cosmwasmclient.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
import { Log } from "./logs";
|
||||
import { BlockResponse, TxsResponse } from "./restclient";
|
||||
import { Coin, CosmosSdkTx, StdSignature } from "./types";
|
||||
import { Coin, CosmosSdkTx, StdSignature, CosmosSdkAccount } from "./types";
|
||||
export interface SigningCallback {
|
||||
(signBytes: Uint8Array): Promise<StdSignature>;
|
||||
}
|
||||
@ -46,6 +46,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>;
|
||||
getAccount(address?: string): Promise<CosmosSdkAccount>;
|
||||
/**
|
||||
* Gets block header and meta
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user