Connect admin field in the CosmWasmClient API

This commit is contained in:
Simon Warta
2020-06-30 15:11:04 +02:00
parent 61ac418465
commit c95f42225e
6 changed files with 135 additions and 96 deletions
+18 -1
View File
@@ -313,25 +313,28 @@ describe("CosmWasmClient", () => {
address: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
codeId: 1,
creator: alice.address0,
admin: undefined,
label: "HASH",
});
expect(isa).toEqual({
address: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
codeId: 1,
creator: alice.address0,
admin: undefined,
label: "ISA",
});
expect(jade).toEqual({
address: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
codeId: 1,
creator: alice.address0,
admin: alice.address1,
label: "JADE",
});
});
});
describe("getContract", () => {
it("works for HASH instance", async () => {
it("works for instance without admin", async () => {
pendingWithoutWasmd();
const client = new CosmWasmClient(wasmd.endpoint);
const hash = await client.getContract("cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5");
@@ -340,6 +343,7 @@ describe("CosmWasmClient", () => {
codeId: 1,
creator: alice.address0,
label: "HASH",
admin: undefined,
initMsg: {
decimals: 5,
name: "Hash token",
@@ -361,6 +365,19 @@ describe("CosmWasmClient", () => {
},
});
});
it("works for instance with admin", async () => {
pendingWithoutWasmd();
const client = new CosmWasmClient(wasmd.endpoint);
const jade = await client.getContract("cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c");
expect(jade).toEqual(
jasmine.objectContaining({
address: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
label: "JADE",
admin: alice.address1,
}),
);
});
});
describe("queryContractRaw", () => {
+4
View File
@@ -118,6 +118,8 @@ export interface Contract {
readonly codeId: number;
/** Bech32 account address */
readonly creator: string;
/** Bech32-encoded admin address */
readonly admin: string | undefined;
readonly label: string;
}
@@ -380,6 +382,7 @@ export class CosmWasmClient {
address: entry.address,
codeId: entry.code_id,
creator: entry.creator,
admin: entry.admin,
label: entry.label,
}),
);
@@ -395,6 +398,7 @@ export class CosmWasmClient {
address: result.address,
codeId: result.code_id,
creator: result.creator,
admin: result.admin,
label: result.label,
initMsg: result.init_msg,
};
+2
View File
@@ -193,6 +193,7 @@ describe("RestClient", () => {
init_msg: jasmine.objectContaining({ symbol: "JADE" }),
label: "JADE",
sender: alice.address0,
admin: alice.address1,
});
});
@@ -248,6 +249,7 @@ describe("RestClient", () => {
init_msg: jasmine.objectContaining({ symbol: "JADE" }),
label: "JADE",
sender: alice.address0,
admin: alice.address1,
});
}
});
+4
View File
@@ -53,6 +53,10 @@ export const alice = {
value: "A9cXhWb8ZpqCzkA8dQCPV29KdeRLV3rUYxrkHudLbQtS",
},
address0: "cosmos14qemq0vw6y3gc3u3e0aty2e764u4gs5le3hada",
address1: "cosmos1hhg2rlu9jscacku2wwckws7932qqqu8x3gfgw0",
address2: "cosmos1xv9tklw7d82sezh9haa573wufgy59vmwe6xxe5",
address3: "cosmos17yg9mssjenmc3jkqth6ulcwj9cxujrxxzezwta",
address4: "cosmos1f7j7ryulwjfe9ljplvhtcaxa6wqgula3etktce",
};
/** Unused account */
+2
View File
@@ -76,6 +76,8 @@ export interface Contract {
readonly codeId: number;
/** Bech32 account address */
readonly creator: string;
/** Bech32-encoded admin address */
readonly admin: string | undefined;
readonly label: string;
}
export interface ContractDetails extends Contract {