From cee00d48bf73d4b7f7d1b1716f2aaa0d0c8c37c3 Mon Sep 17 00:00:00 2001 From: Geoff Lee <11830048+Vritra4@users.noreply.github.com> Date: Tue, 5 Jul 2022 11:21:38 +0900 Subject: [PATCH 1/2] fix wasm api to query code info --- src/client/lcd/api/WasmAPI.spec.ts | 26 ++++++++++++++++++++++++++ src/client/lcd/api/WasmAPI.ts | 8 ++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/client/lcd/api/WasmAPI.spec.ts b/src/client/lcd/api/WasmAPI.spec.ts index a112be6d8..ed59a47af 100644 --- a/src/client/lcd/api/WasmAPI.spec.ts +++ b/src/client/lcd/api/WasmAPI.spec.ts @@ -18,4 +18,30 @@ describe('WasmAPI', () => { }); } }); + + it('code_info', async () => { + // only classic network has param query + await expect(wasm.codeInfo(1)).resolves.toMatchObject({ + code_id: 1, + creator: 'terra1zpglp37eg85mtwa54ymgj0nzqe37awhsv42yxj', + code_hash: + '325A94095F5D98B816AB5192C7771B43D9E45800846B5F2CC96B92E5F3492D45', + instantiate_permission: { + permission: 3, + address: '', + }, + }); + }); + + /* access denied + it('all_codes', async () => { + // only classic network has param query + const [codes, _] = await wasm.allCodes(); + codes.forEach(code => { + expect(code.code_id).toBeDefined(); + expect(code.code_hash).toBeDefined(); + expect(code.creator).toBeDefined(); + }); + }); + */ }); diff --git a/src/client/lcd/api/WasmAPI.ts b/src/client/lcd/api/WasmAPI.ts index 4bb96bffe..769302cd4 100644 --- a/src/client/lcd/api/WasmAPI.ts +++ b/src/client/lcd/api/WasmAPI.ts @@ -8,7 +8,7 @@ import { AccessConfig } from '../../../core/wasm'; export interface CodeInfo { code_id: number; - code_hash: string; + code_hash: string; // TODO: rename it to data_hash when bumping to v4 creator: AccAddress; instantiate_config?: AccessConfig; } @@ -21,7 +21,7 @@ export namespace CodeInfo { } export interface DataV2 { code_id: string; - code_hash: string; + data_hash: string; creator: AccAddress; instantiate_permission?: AccessConfig.Data; } @@ -127,7 +127,7 @@ export class WasmAPI extends BaseAPI { .get<{ code_info: CodeInfo.DataV2 }>(endpoint, params) .then(({ code_info: d }) => ({ code_id: +d.code_id, - code_hash: d.code_hash, + code_hash: d.data_hash, creator: d.creator, instantiate_permission: d.instantiate_permission ? AccessConfig.fromData(d.instantiate_permission) @@ -320,7 +320,7 @@ export class WasmAPI extends BaseAPI { d.codeInfos.map(codeInfo => { return { code_id: +codeInfo.code_id, - code_hash: codeInfo.code_hash, + code_hash: codeInfo.data_hash, creator: codeInfo.creator, instantiate_permission: codeInfo.instantiate_permission ? AccessConfig.fromData(codeInfo.instantiate_permission) From 112e7fda5f91159c1b1bccfc839293aeac7622c3 Mon Sep 17 00:00:00 2001 From: Geoff Lee <11830048+Vritra4@users.noreply.github.com> Date: Mon, 11 Jul 2022 15:28:49 +0900 Subject: [PATCH 2/2] add wasm proposals to index --- src/core/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/index.ts b/src/core/index.ts index c5a4bfe80..8abb673ca 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -70,7 +70,9 @@ export * from './staking/Validator'; export * from './treasury/PolicyConstraints'; // WASM +export * from './wasm'; export * from './wasm/msgs'; +export * from './wasm/proposals'; // IBC export * from './ibc/msgs/channel';