Expose instance labels of contracts
This commit is contained in:
parent
d1c069d9a7
commit
7e7c0ff896
@ -435,16 +435,19 @@ describe("CosmWasmClient", () => {
|
||||
address: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
codeId: 1,
|
||||
creator: faucet.address,
|
||||
label: "HASH",
|
||||
});
|
||||
expect(isa).toEqual({
|
||||
address: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
codeId: 1,
|
||||
creator: faucet.address,
|
||||
label: "ISA",
|
||||
});
|
||||
expect(jade).toEqual({
|
||||
address: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
|
||||
codeId: 1,
|
||||
creator: faucet.address,
|
||||
label: "JADE",
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -458,6 +461,7 @@ describe("CosmWasmClient", () => {
|
||||
address: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
codeId: 1,
|
||||
creator: faucet.address,
|
||||
label: "HASH",
|
||||
initMsg: {
|
||||
decimals: 5,
|
||||
name: "Hash token",
|
||||
|
||||
@ -68,6 +68,7 @@ export interface Contract {
|
||||
readonly codeId: number;
|
||||
/** Bech32 account address */
|
||||
readonly creator: string;
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
export interface ContractDetails extends Contract {
|
||||
@ -220,6 +221,7 @@ export class CosmWasmClient {
|
||||
address: entry.address,
|
||||
codeId: entry.code_id,
|
||||
creator: entry.creator,
|
||||
label: entry.label,
|
||||
}),
|
||||
);
|
||||
}
|
||||
@ -234,6 +236,7 @@ export class CosmWasmClient {
|
||||
address: result.address,
|
||||
codeId: result.code_id,
|
||||
creator: result.creator,
|
||||
label: result.label,
|
||||
initMsg: result.init_msg,
|
||||
};
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import { PostTxsResponse, RestClient, TxsResponse } from "./restclient";
|
||||
import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import cosmoshub from "./testdata/cosmoshub.json";
|
||||
import {
|
||||
bech32AddressMatcher,
|
||||
getRandomizedHackatom,
|
||||
makeRandomAddress,
|
||||
pendingWithoutWasmd,
|
||||
@ -670,7 +671,12 @@ describe("RestClient", () => {
|
||||
|
||||
// create new instance and compare before and after
|
||||
const existingContractsByCode = await client.listContractsByCodeId(codeId);
|
||||
existingContractsByCode.forEach(ctc => expect(ctc.code_id).toEqual(codeId));
|
||||
for (const contract of existingContractsByCode) {
|
||||
expect(contract.address).toMatch(bech32AddressMatcher);
|
||||
expect(contract.code_id).toEqual(codeId);
|
||||
expect(contract.creator).toMatch(bech32AddressMatcher);
|
||||
expect(contract.label).toMatch(/^.+$/);
|
||||
}
|
||||
|
||||
const result = await instantiateContract(client, pen, codeId, beneficiaryAddress, transferAmount);
|
||||
expect(result.code).toBeFalsy();
|
||||
@ -679,8 +685,15 @@ describe("RestClient", () => {
|
||||
const myAddress = contractAddressAttr.value;
|
||||
|
||||
const newContractsByCode = await client.listContractsByCodeId(codeId);
|
||||
newContractsByCode.forEach(ctc => expect(ctc.code_id).toEqual(codeId));
|
||||
expect(newContractsByCode.length).toEqual(existingContractsByCode.length + 1);
|
||||
const newContract = newContractsByCode[newContractsByCode.length - 1];
|
||||
expect(newContract).toEqual(
|
||||
jasmine.objectContaining({
|
||||
code_id: codeId,
|
||||
creator: faucet.address,
|
||||
label: "my escrow",
|
||||
}),
|
||||
);
|
||||
|
||||
// check out info
|
||||
const myInfo = await client.getContractInfo(myAddress);
|
||||
|
||||
@ -139,6 +139,7 @@ export interface ContractInfo {
|
||||
readonly code_id: number;
|
||||
/** Bech32 account address */
|
||||
readonly creator: string;
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
export interface ContractDetails extends ContractInfo {
|
||||
|
||||
@ -60,6 +60,9 @@ export const tendermintIdMatcher = /^[0-9A-F]{64}$/;
|
||||
export const tendermintOptionalIdMatcher = /^([0-9A-F]{64}|)$/;
|
||||
export const tendermintAddressMatcher = /^[0-9A-F]{40}$/;
|
||||
|
||||
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
|
||||
export const bech32AddressMatcher = /^[\x21-\x7e]{1,83}1[02-9ac-hj-np-z]{38}$/;
|
||||
|
||||
export function wasmdEnabled(): boolean {
|
||||
return !!process.env.WASMD_ENABLED;
|
||||
}
|
||||
|
||||
1
packages/sdk/types/cosmwasmclient.d.ts
vendored
1
packages/sdk/types/cosmwasmclient.d.ts
vendored
@ -43,6 +43,7 @@ export interface Contract {
|
||||
readonly codeId: number;
|
||||
/** Bech32 account address */
|
||||
readonly creator: string;
|
||||
readonly label: string;
|
||||
}
|
||||
export interface ContractDetails extends Contract {
|
||||
/** Argument passed on initialization of the contract */
|
||||
|
||||
1
packages/sdk/types/restclient.d.ts
vendored
1
packages/sdk/types/restclient.d.ts
vendored
@ -106,6 +106,7 @@ export interface ContractInfo {
|
||||
readonly code_id: number;
|
||||
/** Bech32 account address */
|
||||
readonly creator: string;
|
||||
readonly label: string;
|
||||
}
|
||||
export interface ContractDetails extends ContractInfo {
|
||||
/** Argument passed on initialization of the contract */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user