Add label to SigningCosmWasmClient.instantiate

This commit is contained in:
Ethan Frey 2020-02-27 17:39:08 +01:00
parent 36d557a4ef
commit 365c1a0e66
7 changed files with 29 additions and 11 deletions

View File

@ -538,7 +538,7 @@ describe("CosmWasmClient", () => {
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
const { codeId } = await client.upload(getRandomizedHackatom());
const initMsg = { verifier: makeRandomAddress(), beneficiary: makeRandomAddress() };
const contractAddress = await client.instantiate(codeId, initMsg);
const contractAddress = await client.instantiate(codeId, initMsg, "random hackatom");
contract = { initMsg: initMsg, address: contractAddress };
}
});
@ -589,7 +589,7 @@ describe("CosmWasmClient", () => {
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
const { codeId } = await client.upload(getRandomizedHackatom());
const initMsg = { verifier: makeRandomAddress(), beneficiary: makeRandomAddress() };
const contractAddress = await client.instantiate(codeId, initMsg);
const contractAddress = await client.instantiate(codeId, initMsg, "a different hackatom");
contract = { initMsg: initMsg, address: contractAddress };
}
});

View File

@ -108,6 +108,7 @@ async function instantiateContract(
value: {
sender: faucet.address,
code_id: codeId.toString(),
label: "my escrow",
init_msg: {
verifier: faucet.address,
beneficiary: beneficiaryAddress,

View File

@ -76,7 +76,8 @@ describe("SigningCosmWasmClient", () => {
verifier: faucet.address,
beneficiary: beneficiaryAddress,
},
"Let's see",
"My cool label",
"Let's see if the memo is used",
transferAmount,
);
@ -91,14 +92,22 @@ describe("SigningCosmWasmClient", () => {
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
const { codeId } = await client.upload(getRandomizedHackatom());
const contractAddress1 = await client.instantiate(codeId, {
verifier: faucet.address,
beneficiary: makeRandomAddress(),
});
const contractAddress2 = await client.instantiate(codeId, {
verifier: faucet.address,
beneficiary: makeRandomAddress(),
});
const contractAddress1 = await client.instantiate(
codeId,
{
verifier: faucet.address,
beneficiary: makeRandomAddress(),
},
"contract 1",
);
const contractAddress2 = await client.instantiate(
codeId,
{
verifier: faucet.address,
beneficiary: makeRandomAddress(),
},
"contract 2",
);
expect(contractAddress1).not.toEqual(contractAddress2);
});
});
@ -128,6 +137,7 @@ describe("SigningCosmWasmClient", () => {
verifier: faucet.address,
beneficiary: beneficiaryAddress,
},
"amazing random contract",
undefined,
transferAmount,
);

View File

@ -134,6 +134,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
public async instantiate(
codeId: number,
initMsg: object,
label: string,
memo = "",
transferAmount?: readonly Coin[],
): Promise<string> {
@ -143,6 +144,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
sender: this.senderAddress,
// eslint-disable-next-line @typescript-eslint/camelcase
code_id: codeId.toString(),
label: label,
// eslint-disable-next-line @typescript-eslint/camelcase
init_msg: initMsg,
// eslint-disable-next-line @typescript-eslint/camelcase

View File

@ -70,6 +70,8 @@ export interface MsgInstantiateContract extends MsgTemplate {
readonly sender: string;
/** ID of the Wasm code that was uploaded before */
readonly code_id: string;
/** Human-readable label for this contract */
readonly label: string;
/** Init message as JavaScript object */
readonly init_msg: object;
readonly init_funds: ReadonlyArray<Coin>;

View File

@ -44,6 +44,7 @@ export declare class SigningCosmWasmClient extends CosmWasmClient {
instantiate(
codeId: number,
initMsg: object,
label: string,
memo?: string,
transferAmount?: readonly Coin[],
): Promise<string>;

View File

@ -55,6 +55,8 @@ export interface MsgInstantiateContract extends MsgTemplate {
readonly sender: string;
/** ID of the Wasm code that was uploaded before */
readonly code_id: string;
/** Human-readable label for this contract */
readonly label: string;
/** Init message as JavaScript object */
readonly init_msg: object;
readonly init_funds: ReadonlyArray<Coin>;