@quantovainc/qcore 0.5.2 → 0.5.4
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 +1 -0
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/qcore_js.d.ts +2 -0
- package/pkg/qcore_js.js +1 -1
- package/pkg/qcore_js_bg.js +22 -0
- package/pkg/qcore_js_bg.wasm +0 -0
- package/pkg/qcore_js_bg.wasm.d.ts +1 -0
- package/pkg-node/package.json +1 -1
- package/pkg-node/qcore_js.d.ts +2 -0
- package/pkg-node/qcore_js.js +23 -0
- package/pkg-node/qcore_js_bg.wasm +0 -0
- package/shared.js +5 -6
- package/shared.mjs +5 -6
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
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.
|
|
5
|
+
"version": "0.5.4",
|
|
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";
|
package/pkg/qcore_js_bg.js
CHANGED
|
@@ -1009,6 +1009,28 @@ export function storageValue(response, slot_key_hex) {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
|
+
/**
|
|
1013
|
+
* @param {string} response
|
|
1014
|
+
* @param {string} slot_key_hex
|
|
1015
|
+
* @returns {string | undefined}
|
|
1016
|
+
*/
|
|
1017
|
+
export function storageValueReported(response, slot_key_hex) {
|
|
1018
|
+
const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1019
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1020
|
+
const ptr1 = passStringToWasm0(slot_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1021
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1022
|
+
const ret = wasm.storageValueReported(ptr0, len0, ptr1, len1);
|
|
1023
|
+
if (ret[3]) {
|
|
1024
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1025
|
+
}
|
|
1026
|
+
let v3;
|
|
1027
|
+
if (ret[0] !== 0) {
|
|
1028
|
+
v3 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1029
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1030
|
+
}
|
|
1031
|
+
return v3;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1012
1034
|
/**
|
|
1013
1035
|
* @param {string} tx_hex
|
|
1014
1036
|
* @returns {string}
|
package/pkg/qcore_js_bg.wasm
CHANGED
|
Binary file
|
|
@@ -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];
|
package/pkg-node/package.json
CHANGED
|
@@ -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.
|
|
4
|
+
"version": "0.5.4",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
package/pkg-node/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-node/qcore_js.js
CHANGED
|
@@ -1053,6 +1053,29 @@ function storageValue(response, slot_key_hex) {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
exports.storageValue = storageValue;
|
|
1055
1055
|
|
|
1056
|
+
/**
|
|
1057
|
+
* @param {string} response
|
|
1058
|
+
* @param {string} slot_key_hex
|
|
1059
|
+
* @returns {string | undefined}
|
|
1060
|
+
*/
|
|
1061
|
+
function storageValueReported(response, slot_key_hex) {
|
|
1062
|
+
const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1063
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1064
|
+
const ptr1 = passStringToWasm0(slot_key_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1065
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1066
|
+
const ret = wasm.storageValueReported(ptr0, len0, ptr1, len1);
|
|
1067
|
+
if (ret[3]) {
|
|
1068
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1069
|
+
}
|
|
1070
|
+
let v3;
|
|
1071
|
+
if (ret[0] !== 0) {
|
|
1072
|
+
v3 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
1073
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1074
|
+
}
|
|
1075
|
+
return v3;
|
|
1076
|
+
}
|
|
1077
|
+
exports.storageValueReported = storageValueReported;
|
|
1078
|
+
|
|
1056
1079
|
/**
|
|
1057
1080
|
* @param {string} tx_hex
|
|
1058
1081
|
* @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']],
|
|
@@ -419,7 +420,7 @@ function makeClient(core) {
|
|
|
419
420
|
redirect: 'error',
|
|
420
421
|
});
|
|
421
422
|
const text = await readBounded(res);
|
|
422
|
-
if (
|
|
423
|
+
if (res.status === 200) core.checkGatewayJson(text);
|
|
423
424
|
let data;
|
|
424
425
|
try { data = JSON.parse(text); } catch { throw new Error('the node returned a non JSON response'); }
|
|
425
426
|
if (res.status !== 200) {
|
|
@@ -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
|
|
614
|
-
if (
|
|
615
|
-
|
|
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']],
|
|
@@ -419,7 +420,7 @@ function makeClient(core) {
|
|
|
419
420
|
redirect: 'error',
|
|
420
421
|
});
|
|
421
422
|
const text = await readBounded(res);
|
|
422
|
-
if (
|
|
423
|
+
if (res.status === 200) core.checkGatewayJson(text);
|
|
423
424
|
let data;
|
|
424
425
|
try { data = JSON.parse(text); } catch { throw new Error('the node returned a non JSON response'); }
|
|
425
426
|
if (res.status !== 200) {
|
|
@@ -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
|
|
614
|
-
if (
|
|
615
|
-
|
|
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) {
|