From 1a3af0f5fb784ce37a8c6dd8e1ccb29dcadd315d Mon Sep 17 00:00:00 2001 From: Dmitryii Osipov Date: Thu, 15 Feb 2024 19:46:56 +0400 Subject: [PATCH] fix(api): add `gr_env_vars` stub (#1487) --- api/CHANGELOG.md | 8 ++++++++ api/package.json | 2 +- api/src/wasm/importObj.ts | 31 ++++++++++++++++--------------- api/src/wasm/reply.ts | 20 +++++++++++--------- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 333fd18b30..42bf96c00f 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.36.6 + +_02/15/2024_ + +### Changes +https://github.com/gear-tech/gear-js/pull/1487 +- Add add `gr_env_vars` stub + ## 0.36.5 _02/12/2024_ diff --git a/api/package.json b/api/package.json index 67ef8dcd93..dbffdd6535 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "@gear-js/api", - "version": "0.36.5", + "version": "0.36.6", "description": "A JavaScript library that provides functionality to connect GEAR Component APIs.", "main": "cjs/index.js", "module": "index.js", diff --git a/api/src/wasm/importObj.ts b/api/src/wasm/importObj.ts index 057faa3741..62ac65ab5d 100644 --- a/api/src/wasm/importObj.ts +++ b/api/src/wasm/importObj.ts @@ -29,6 +29,7 @@ export default ( }, free: () => {}, free_range: () => {}, + gr_env_vars: () => {}, gr_block_height: () => block_height, gr_block_timestamp: () => timestamp, gr_create_program_wgas: () => {}, @@ -50,16 +51,17 @@ export default ( new TypeRegistry().createType('String', new Uint8Array(memory.buffer.slice(error, error + len))).toHuman(), ); }, - gr_exit: () => {}, - gr_gas_available: () => {}, - gr_leave: () => {}, - gr_message_id: () => {}, - gr_oom_panic: () => {}, gr_origin: () => {}, - gr_panic: () => {}, gr_pay_program_rent: () => {}, + gr_status_code: () => {}, + gr_panic: () => {}, + gr_oom_panic: () => {}, gr_reply_code: () => {}, gr_signal_code: () => {}, + gr_exit: () => {}, + gr_gas_available: () => {}, + gr_leave: () => {}, + gr_message_id: () => {}, gr_program_id: () => {}, gr_random: () => {}, gr_read: (at: number, len: number, buffer: number) => { @@ -69,10 +71,13 @@ export default ( gr_reply_commit_wgas: () => {}, gr_reply_commit: () => {}, gr_reply_push: () => {}, + gr_reply_push_input: () => {}, gr_reply_to: () => {}, gr_signal_from: () => {}, + gr_reply_input_wgas: () => {}, gr_reply_wgas: () => {}, gr_reply: replyFn, + gr_reply_input: () => {}, gr_reservation_reply_commit: () => {}, gr_reservation_reply: () => {}, gr_reservation_send_commit: () => {}, @@ -82,8 +87,11 @@ export default ( gr_send_commit: () => {}, gr_send_init: () => {}, gr_send_push: () => {}, + gr_send_push_input: () => {}, + gr_send_input_wgas: () => {}, gr_send_wgas: () => {}, gr_send: () => {}, + gr_send_input: () => {}, gr_size: (size_ptr: number) => { assert.notStrictEqual(inputValue, undefined, 'Input value not found'); const len = new TypeRegistry().createType('u32', inputValue.byteLength).toU8a(); @@ -92,20 +100,13 @@ export default ( } }, gr_source: () => {}, - gr_status_code: () => {}, gr_system_reserve_gas: () => {}, gr_unreserve_gas: () => {}, gr_value_available: () => {}, gr_value: () => {}, - gr_wait: () => {}, - gr_wait_up_to: () => {}, gr_wait_for: () => {}, + gr_wait_up_to: () => {}, + gr_wait: () => {}, gr_wake: () => {}, - gr_reply_push_input: () => {}, - gr_reply_input_wgas: () => {}, - gr_reply_input: () => {}, - gr_send_push_input: () => {}, - gr_send_input_wgas: () => {}, - gr_send_input: () => {}, }, }); diff --git a/api/src/wasm/reply.ts b/api/src/wasm/reply.ts index 274b1cdd41..30082338a3 100644 --- a/api/src/wasm/reply.ts +++ b/api/src/wasm/reply.ts @@ -13,14 +13,16 @@ export function getGrReply(wasm: HexString | Buffer | ArrayBuffer | Uint8Array, importObj(memory, false, undefined, undefined, undefined, (payload: number, len: number) => resolve(new Uint8Array(memory.buffer.slice(payload, payload + len))), ), - ).then(({ instance: { exports } }) => { - if (!(fn in exports)) { - reject(`${fn} function not found in exports`); - } else if (typeof exports[fn] !== 'function') { - reject(`${fn} is not a function`); - } else { - (exports[fn] as () => void)(); - } - }); + ) + .then(({ instance: { exports } }) => { + if (!(fn in exports)) { + reject(`${fn} function not found in exports`); + } else if (typeof exports[fn] !== 'function') { + reject(`${fn} is not a function`); + } else { + (exports[fn] as () => void)(); + } + }) + .catch((error) => reject(error)); }); }