Rename to CosmWasmClient.getChainId
This commit is contained in:
parent
89fed439a0
commit
cbcf854a98
@ -94,7 +94,7 @@ export class CosmWasmConnection implements BlockchainConnection {
|
||||
}
|
||||
|
||||
private static async initialize(cosmWasmClient: CosmWasmClient): Promise<ChainId> {
|
||||
const rawChainId = await cosmWasmClient.chainId();
|
||||
const rawChainId = await cosmWasmClient.getChainId();
|
||||
return Caip5.encode(rawChainId);
|
||||
}
|
||||
|
||||
|
||||
@ -48,11 +48,11 @@ describe("CosmWasmClient", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("chainId", () => {
|
||||
describe("getChainId", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
expect(await client.chainId()).toEqual("testing");
|
||||
expect(await client.getChainId()).toEqual("testing");
|
||||
});
|
||||
});
|
||||
|
||||
@ -152,7 +152,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
// header
|
||||
expect(response.header.height).toBeGreaterThanOrEqual(1);
|
||||
expect(response.header.chainId).toEqual(await client.chainId());
|
||||
expect(response.header.chainId).toEqual(await client.getChainId());
|
||||
expect(new ReadonlyDate(response.header.time).getTime()).toBeLessThan(ReadonlyDate.now());
|
||||
expect(new ReadonlyDate(response.header.time).getTime()).toBeGreaterThanOrEqual(
|
||||
ReadonlyDate.now() - 5_000,
|
||||
@ -173,7 +173,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
// header
|
||||
expect(response.header.height).toEqual(height - 1);
|
||||
expect(response.header.chainId).toEqual(await client.chainId());
|
||||
expect(response.header.chainId).toEqual(await client.getChainId());
|
||||
expect(new ReadonlyDate(response.header.time).getTime()).toBeLessThan(ReadonlyDate.now());
|
||||
expect(new ReadonlyDate(response.header.time).getTime()).toBeGreaterThanOrEqual(
|
||||
ReadonlyDate.now() - 5_000,
|
||||
@ -223,7 +223,7 @@ describe("CosmWasmClient", () => {
|
||||
gas: "890000",
|
||||
};
|
||||
|
||||
const chainId = await client.chainId();
|
||||
const chainId = await client.getChainId();
|
||||
const { accountNumber, sequence } = await client.getNonce(faucet.address);
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await pen.sign(signBytes);
|
||||
|
||||
@ -153,7 +153,7 @@ export class CosmWasmClient {
|
||||
this.restClient = new RestClient(url, broadcastMode);
|
||||
}
|
||||
|
||||
public async chainId(): Promise<string> {
|
||||
public async getChainId(): Promise<string> {
|
||||
const response = await this.restClient.nodeInfo();
|
||||
return response.node_info.network;
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
};
|
||||
const fee = this.fees.upload;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const chainId = await this.chainId();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([storeCodeMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signCallback(signBytes);
|
||||
const signedTx = {
|
||||
@ -189,7 +189,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
};
|
||||
const fee = this.fees.init;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const chainId = await this.chainId();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([instantiateMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
|
||||
const signature = await this.signCallback(signBytes);
|
||||
@ -227,7 +227,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
};
|
||||
const fee = this.fees.exec;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const chainId = await this.chainId();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([executeMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signCallback(signBytes);
|
||||
const signedTx = {
|
||||
@ -261,7 +261,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
};
|
||||
const fee = this.fees.send;
|
||||
const { accountNumber, sequence } = await this.getNonce();
|
||||
const chainId = await this.chainId();
|
||||
const chainId = await this.getChainId();
|
||||
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
|
||||
const signature = await this.signCallback(signBytes);
|
||||
const signedTx = {
|
||||
|
||||
2
packages/sdk/types/cosmwasmclient.d.ts
vendored
2
packages/sdk/types/cosmwasmclient.d.ts
vendored
@ -113,7 +113,7 @@ export declare class CosmWasmClient {
|
||||
protected anyValidAddress: string | undefined;
|
||||
private readonly codesCache;
|
||||
constructor(url: string, broadcastMode?: BroadcastMode);
|
||||
chainId(): Promise<string>;
|
||||
getChainId(): Promise<string>;
|
||||
getHeight(): Promise<number>;
|
||||
/**
|
||||
* Returns a 32 byte upper-case hex transaction hash (typically used as the transaction ID)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user