Skip to content

Commit 49740c7

Browse files
authored
Merge pull request #26 from Terran-One/feat/AddLabel
Add label to contract instantiation.
2 parents ea39149 + d442dc1 commit 49740c7

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terran-one/cw-simulate",
3-
"version": "2.7.4",
3+
"version": "2.7.5",
44
"description": "Mock blockchain environment for simulating CosmWasm interactions",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/modules/wasm.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class WasmModule {
234234
}
235235

236236
// TODO: add admin, label, etc.
237-
registerContractInstance(sender: string, codeId: number): string {
237+
registerContractInstance(sender: string, codeId: number, label:string): string {
238238
return this.store.tx(setter => {
239239
const contractAddressHash = WasmModule.buildContractAddress(
240240
codeId,
@@ -250,7 +250,7 @@ export class WasmModule {
250250
codeId,
251251
creator: sender,
252252
admin: null,
253-
label: '',
253+
label,
254254
created: this.chain.height,
255255
};
256256

@@ -291,13 +291,14 @@ export class WasmModule {
291291
funds: Coin[],
292292
codeId: number,
293293
instantiateMsg: any,
294+
label:string,
294295
trace: TraceLog[] = []
295296
): Promise<Result<AppResponse, string>> {
296297
return await this.chain.pushBlock(async () => {
297298
const snapshot = this.store.db.data;
298299

299300
// first register the contract instance
300-
const contractAddress = this.registerContractInstance(sender, codeId);
301+
const contractAddress = this.registerContractInstance(sender, codeId, label);
301302
let logs = [] as DebugLog[];
302303

303304
const send = this.chain.bank.send(sender, contractAddress, funds);
@@ -780,12 +781,13 @@ export class WasmModule {
780781
);
781782
}
782783
else if ('instantiate' in wasm) {
783-
let { code_id, funds, msg } = wasm.instantiate;
784+
let { code_id, funds, msg, label} = wasm.instantiate;
784785
return await this.instantiateContract(
785786
sender,
786787
funds,
787788
code_id,
788789
fromBinary(msg),
790+
label,
789791
trace,
790792
);
791793
}

testing/wasm-util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ export class TestContract {
161161
opts.sender ?? this.creator,
162162
opts.funds ?? [],
163163
codeId,
164-
{}
164+
{},
165+
"Test Contract"
165166
);
166167

167168
const addr = res.unwrap().events[0].attributes[0].value;

0 commit comments

Comments
 (0)