@quantovainc/qcore 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -197,6 +197,7 @@ export interface QCore {
197
197
  ): string;
198
198
  storageBody(contract: string): string;
199
199
  storageValue(response: string, slot_key_hex: string): string;
200
+ storageValueReported(response: string, slot_key_hex: string): string | undefined;
200
201
  submit_body(tx_hex: string): string;
201
202
  testnetChainId(): bigint;
202
203
  transaction_body(tx_id: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quantovainc/qcore",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Quantova's post quantum client core for JavaScript. Signs with ML-DSA-65 and builds Q1 addresses.",
5
5
  "scripts": {
6
6
  "build": "bash scripts/build.sh",
package/pkg/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "qcore-js",
3
3
  "type": "module",
4
4
  "description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
5
- "version": "0.5.3",
5
+ "version": "0.5.5",
6
6
  "license": "Apache-2.0 OR MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/pkg/qcore_js.d.ts CHANGED
@@ -96,6 +96,8 @@ export function storageBody(contract: string): string;
96
96
 
97
97
  export function storageValue(response: string, slot_key_hex: string): string;
98
98
 
99
+ export function storageValueReported(response: string, slot_key_hex: string): string | undefined;
100
+
99
101
  export function submit_body(tx_hex: string): string;
100
102
 
101
103
  export function testnetChainId(): bigint;
package/pkg/qcore_js.js CHANGED
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./qcore_js_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- SigningSession, account_body, address, assetBalanceBody, assetSupplyBody, block_by_height_body, boundedValidUntil, buildSignedOrderCall, buildTypedOrderCall, chainIdFromName, checkGatewayJson, checkOrderExpiry, checkValidUntil, contractAddress, decodeEvent, eventsBody, genesisSecs, headCeiling, localChainId, lookalikeOf, mainnetChainId, mapAddrWordKey, mapSlotKey, mnemonicFromSeed, mnemonicFromSeedText, nameKey, nonceSlotKey, orderLayoutHash, orderSigner, packSymbol, parseEvents, sameAddress, scalarSlotKey, seedFromMnemonic, seedFromMnemonicBytes, signAssetCall, signPayableCall, signRegister, sign_call, sign_transfer, storageBody, storageValue, submit_body, testnetChainId, testnetChainName, testnetRpcUrl, tokenDecimalsSlot, tokenSymbolSlot, transaction_body, unpackSymbol, valid_address, validityBlocks, verifyEvent, verifyFinality, vmCallFee, vmDeployAddress
8
+ SigningSession, account_body, address, assetBalanceBody, assetSupplyBody, block_by_height_body, boundedValidUntil, buildSignedOrderCall, buildTypedOrderCall, chainIdFromName, checkGatewayJson, checkOrderExpiry, checkValidUntil, contractAddress, decodeEvent, eventsBody, genesisSecs, headCeiling, localChainId, lookalikeOf, mainnetChainId, mapAddrWordKey, mapSlotKey, mnemonicFromSeed, mnemonicFromSeedText, nameKey, nonceSlotKey, orderLayoutHash, orderSigner, packSymbol, parseEvents, sameAddress, scalarSlotKey, seedFromMnemonic, seedFromMnemonicBytes, signAssetCall, signPayableCall, signRegister, sign_call, sign_transfer, storageBody, storageValue, storageValueReported, submit_body, testnetChainId, testnetChainName, testnetRpcUrl, tokenDecimalsSlot, tokenSymbolSlot, transaction_body, unpackSymbol, valid_address, validityBlocks, verifyEvent, verifyFinality, vmCallFee, vmDeployAddress
9
9
  } from "./qcore_js_bg.js";
@@ -323,7 +323,10 @@ export function chainIdFromName(name) {
323
323
  const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
324
324
  const len0 = WASM_VECTOR_LEN;
325
325
  const ret = wasm.chainIdFromName(ptr0, len0);
326
- return BigInt.asUintN(64, ret);
326
+ if (ret[2]) {
327
+ throw takeFromExternrefTable0(ret[1]);
328
+ }
329
+ return BigInt.asUintN(64, ret[0]);
327
330
  }
328
331
 
329
332
  /**
@@ -1009,6 +1012,28 @@ export function storageValue(response, slot_key_hex) {
1009
1012
  }
1010
1013
  }
1011
1014
 
1015
+ /**
1016
+ * @param {string} response
1017
+ * @param {string} slot_key_hex
1018
+ * @returns {string | undefined}
1019
+ */
1020
+ export function storageValueReported(response, slot_key_hex) {
1021
+ const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1022
+ const len0 = WASM_VECTOR_LEN;
1023
+ const ptr1 = passStringToWasm0(slot_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1024
+ const len1 = WASM_VECTOR_LEN;
1025
+ const ret = wasm.storageValueReported(ptr0, len0, ptr1, len1);
1026
+ if (ret[3]) {
1027
+ throw takeFromExternrefTable0(ret[2]);
1028
+ }
1029
+ let v3;
1030
+ if (ret[0] !== 0) {
1031
+ v3 = getStringFromWasm0(ret[0], ret[1]).slice();
1032
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1033
+ }
1034
+ return v3;
1035
+ }
1036
+
1012
1037
  /**
1013
1038
  * @param {string} tx_hex
1014
1039
  * @returns {string}
Binary file
@@ -10,7 +10,7 @@ export const block_by_height_body: (a: bigint) => [number, number];
10
10
  export const boundedValidUntil: (a: number, b: number, c: bigint, d: bigint, e: number, f: bigint, g: bigint) => [bigint, number, number];
11
11
  export const buildSignedOrderCall: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: bigint, k: number, l: number, m: number, n: number, o: bigint, p: number, q: number, r: bigint, s: bigint, t: bigint) => [number, number, number, number];
12
12
  export const buildTypedOrderCall: (a: bigint, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: bigint, j: bigint, k: bigint, l: number, m: number, n: number, o: number, p: bigint, q: bigint, r: bigint) => [number, number, number, number];
13
- export const chainIdFromName: (a: number, b: number) => bigint;
13
+ export const chainIdFromName: (a: number, b: number) => [bigint, number, number];
14
14
  export const checkGatewayJson: (a: number, b: number) => [number, number];
15
15
  export const checkOrderExpiry: (a: bigint, b: bigint) => [number, number];
16
16
  export const checkValidUntil: (a: bigint, b: bigint) => [number, number];
@@ -51,6 +51,7 @@ export const signingsession_signed: (a: number, b: number, c: number, d: bigint)
51
51
  export const signingsession_slot: (a: number, b: number, c: number, d: bigint, e: number, f: bigint, g: number) => [bigint, number, number];
52
52
  export const storageBody: (a: number, b: number) => [number, number];
53
53
  export const storageValue: (a: number, b: number, c: number, d: number) => [number, number, number, number];
54
+ export const storageValueReported: (a: number, b: number, c: number, d: number) => [number, number, number, number];
54
55
  export const submit_body: (a: number, b: number) => [number, number, number, number];
55
56
  export const testnetChainId: () => bigint;
56
57
  export const testnetChainName: () => [number, number];
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qcore-js",
3
3
  "description": "The JavaScript binding for the Quantova client core, generated over QCore with wasm-bindgen. The core does the key derivation, the post quantum signing, and the wire, the page does the fetch.",
4
- "version": "0.5.3",
4
+ "version": "0.5.5",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -96,6 +96,8 @@ export function storageBody(contract: string): string;
96
96
 
97
97
  export function storageValue(response: string, slot_key_hex: string): string;
98
98
 
99
+ export function storageValueReported(response: string, slot_key_hex: string): string | undefined;
100
+
99
101
  export function submit_body(tx_hex: string): string;
100
102
 
101
103
  export function testnetChainId(): bigint;
@@ -334,7 +334,10 @@ function chainIdFromName(name) {
334
334
  const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
335
335
  const len0 = WASM_VECTOR_LEN;
336
336
  const ret = wasm.chainIdFromName(ptr0, len0);
337
- return BigInt.asUintN(64, ret);
337
+ if (ret[2]) {
338
+ throw takeFromExternrefTable0(ret[1]);
339
+ }
340
+ return BigInt.asUintN(64, ret[0]);
338
341
  }
339
342
  exports.chainIdFromName = chainIdFromName;
340
343
 
@@ -1053,6 +1056,29 @@ function storageValue(response, slot_key_hex) {
1053
1056
  }
1054
1057
  exports.storageValue = storageValue;
1055
1058
 
1059
+ /**
1060
+ * @param {string} response
1061
+ * @param {string} slot_key_hex
1062
+ * @returns {string | undefined}
1063
+ */
1064
+ function storageValueReported(response, slot_key_hex) {
1065
+ const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1066
+ const len0 = WASM_VECTOR_LEN;
1067
+ const ptr1 = passStringToWasm0(slot_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1068
+ const len1 = WASM_VECTOR_LEN;
1069
+ const ret = wasm.storageValueReported(ptr0, len0, ptr1, len1);
1070
+ if (ret[3]) {
1071
+ throw takeFromExternrefTable0(ret[2]);
1072
+ }
1073
+ let v3;
1074
+ if (ret[0] !== 0) {
1075
+ v3 = getStringFromWasm0(ret[0], ret[1]).slice();
1076
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1077
+ }
1078
+ return v3;
1079
+ }
1080
+ exports.storageValueReported = storageValueReported;
1081
+
1056
1082
  /**
1057
1083
  * @param {string} tx_hex
1058
1084
  * @returns {string}
Binary file
package/shared.js CHANGED
@@ -100,6 +100,7 @@ const CORE_ARGS = {
100
100
  buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['text', 'layout hash'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'expiry offset'], ['u64', 'region offset'], ['text', 'fields'], ['seed', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce'], ['u64', 'order expiry']],
101
101
  orderLayoutHash: [['text', 'selector'], ['text', 'order layout']],
102
102
  checkOrderExpiry: [['u64', 'order expiry'], ['u64', 'wall clock seconds']],
103
+ storageValueReported: [['text', 'storage response'], ['text', 'slot key']],
103
104
  verifyFinality: [['u64', 'chain id'], ['text', 'header'], ['text', 'certificate'], ['text', 'validator roster']],
104
105
  verifyEvent: [['text', 'event root'], ['text', 'event leaf'], ['text', 'proof steps']],
105
106
  decodeEvent: [['text', 'event leaf']],
@@ -610,11 +611,9 @@ function makeClient(core) {
610
611
 
611
612
  async _slotValue(contract, key) {
612
613
  const resp = await this._call('get_storage_at', JSON.stringify({ address: contract, keys: [key] }), true);
613
- const slots = resp && Array.isArray(resp.slots) ? resp.slots : [];
614
- if (!slots.some((s) => s && typeof s.slot === 'string' && s.slot.toLowerCase() === String(key).toLowerCase())) {
615
- throw new Error('the gateway did not report the requested storage slot');
616
- }
617
- return BigInt(core.storageValue(JSON.stringify(resp), key));
614
+ const value = core.storageValueReported(JSON.stringify(resp), key);
615
+ if (value == null) throw new Error('the gateway did not report the requested storage slot');
616
+ return BigInt(value);
618
617
  }
619
618
 
620
619
  async contractNonce(contract, signerHex) {
package/shared.mjs CHANGED
@@ -100,6 +100,7 @@ const CORE_ARGS = {
100
100
  buildTypedOrderCall: [['u64', 'chain id'], ['text', 'contract'], ['text', 'selector'], ['text', 'layout hash'], ['u64', 'scheme offset'], ['u64', 'pointer offset'], ['u64', 'expiry offset'], ['u64', 'region offset'], ['text', 'fields'], ['seed', 'owner seed'], ['u64', 'owner index'], ['u64', 'order nonce'], ['u64', 'order expiry']],
101
101
  orderLayoutHash: [['text', 'selector'], ['text', 'order layout']],
102
102
  checkOrderExpiry: [['u64', 'order expiry'], ['u64', 'wall clock seconds']],
103
+ storageValueReported: [['text', 'storage response'], ['text', 'slot key']],
103
104
  verifyFinality: [['u64', 'chain id'], ['text', 'header'], ['text', 'certificate'], ['text', 'validator roster']],
104
105
  verifyEvent: [['text', 'event root'], ['text', 'event leaf'], ['text', 'proof steps']],
105
106
  decodeEvent: [['text', 'event leaf']],
@@ -610,11 +611,9 @@ function makeClient(core) {
610
611
 
611
612
  async _slotValue(contract, key) {
612
613
  const resp = await this._call('get_storage_at', JSON.stringify({ address: contract, keys: [key] }), true);
613
- const slots = resp && Array.isArray(resp.slots) ? resp.slots : [];
614
- if (!slots.some((s) => s && typeof s.slot === 'string' && s.slot.toLowerCase() === String(key).toLowerCase())) {
615
- throw new Error('the gateway did not report the requested storage slot');
616
- }
617
- return BigInt(core.storageValue(JSON.stringify(resp), key));
614
+ const value = core.storageValueReported(JSON.stringify(resp), key);
615
+ if (value == null) throw new Error('the gateway did not report the requested storage slot');
616
+ return BigInt(value);
618
617
  }
619
618
 
620
619
  async contractNonce(contract, signerHex) {