@quantovainc/qcore 0.2.3 → 0.3.0
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/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/qcore_js_bg.wasm +0 -0
- package/pkg-node/package.json +1 -1
- package/pkg-node/qcore_js_bg.wasm +0 -0
- package/shared.js +5 -58
- package/shared.mjs +5 -58
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
|
+
"version": "0.3.0",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
package/pkg/qcore_js_bg.wasm
CHANGED
|
Binary file
|
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.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
Binary file
|
package/shared.js
CHANGED
|
@@ -8,14 +8,7 @@ function feeCeiling(maxFeeQuon) {
|
|
|
8
8
|
if (typeof maxFeeQuon === 'number') {
|
|
9
9
|
throw new Error('pass the maximum fee as a decimal string or a BigInt, never a JavaScript number, because a number silently rounds above 2^53 and could set the ceiling higher than you intended');
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
ceiling = BigInt(maxFeeQuon);
|
|
14
|
-
} catch {
|
|
15
|
-
throw new Error('the maximum fee must be an integer number of Quon');
|
|
16
|
-
}
|
|
17
|
-
if (ceiling < 0n) throw new Error('the maximum fee cannot be negative');
|
|
18
|
-
return ceiling;
|
|
11
|
+
return wholeNumber(maxFeeQuon, 'maximum fee', U128_MAX);
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
function checkAmount(amount) {
|
|
@@ -28,35 +21,11 @@ function checkAmount(amount) {
|
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
function accountIndex(index) {
|
|
31
|
-
|
|
32
|
-
throw new Error('the account index must be a whole number in the safe integer range, a number that large silently rounds and would sign with a different account key');
|
|
33
|
-
}
|
|
34
|
-
let i;
|
|
35
|
-
try {
|
|
36
|
-
i = BigInt(index);
|
|
37
|
-
} catch {
|
|
38
|
-
throw new Error('the account index must be a whole number');
|
|
39
|
-
}
|
|
40
|
-
if (i < 0n || i > 0xffffffffffffffffn) {
|
|
41
|
-
throw new Error('the account index must fit in an unsigned 64 bit integer');
|
|
42
|
-
}
|
|
43
|
-
return i;
|
|
24
|
+
return wholeNumber(index, 'account index', U64_MAX);
|
|
44
25
|
}
|
|
45
26
|
|
|
46
27
|
function accountNonce(nonce) {
|
|
47
|
-
|
|
48
|
-
throw new Error('the gateway reported a nonce outside the safe integer range, a number that large silently rounds and would sign a different nonce');
|
|
49
|
-
}
|
|
50
|
-
let n;
|
|
51
|
-
try {
|
|
52
|
-
n = BigInt(nonce);
|
|
53
|
-
} catch {
|
|
54
|
-
throw new Error('the gateway reported a nonce that is not a whole number');
|
|
55
|
-
}
|
|
56
|
-
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
57
|
-
throw new Error('the gateway reported a nonce outside the unsigned 64 bit range');
|
|
58
|
-
}
|
|
59
|
-
return n;
|
|
28
|
+
return wholeNumber(nonce, 'nonce', U64_MAX);
|
|
60
29
|
}
|
|
61
30
|
|
|
62
31
|
const VALIDITY_BLOCKS = 300n;
|
|
@@ -142,19 +111,7 @@ function isPublicChain(name) {
|
|
|
142
111
|
}
|
|
143
112
|
|
|
144
113
|
function meterLimitOf(meterLimit) {
|
|
145
|
-
|
|
146
|
-
throw new Error('the meter limit must be a whole number in the safe integer range');
|
|
147
|
-
}
|
|
148
|
-
let meter;
|
|
149
|
-
try {
|
|
150
|
-
meter = BigInt(meterLimit);
|
|
151
|
-
} catch {
|
|
152
|
-
throw new Error('the meter limit must be a whole number');
|
|
153
|
-
}
|
|
154
|
-
if (meter < 0n || meter > 0xffffffffffffffffn) {
|
|
155
|
-
throw new Error('the meter limit must fit in an unsigned 64 bit integer');
|
|
156
|
-
}
|
|
157
|
-
return meter;
|
|
114
|
+
return wholeNumber(meterLimit, 'meter limit', U64_MAX);
|
|
158
115
|
}
|
|
159
116
|
|
|
160
117
|
function validUntil(info) {
|
|
@@ -176,17 +133,7 @@ function validUntil(info) {
|
|
|
176
133
|
}
|
|
177
134
|
|
|
178
135
|
function gatewayFee(fee) {
|
|
179
|
-
|
|
180
|
-
throw new Error('the gateway reported a fee outside the safe integer range, a number that large silently rounds and would sign a different fee');
|
|
181
|
-
}
|
|
182
|
-
let f;
|
|
183
|
-
try {
|
|
184
|
-
f = BigInt(fee);
|
|
185
|
-
} catch {
|
|
186
|
-
throw new Error('the gateway reported a fee that is not a whole number');
|
|
187
|
-
}
|
|
188
|
-
if (f < 0n) throw new Error('the gateway reported a negative fee');
|
|
189
|
-
return f;
|
|
136
|
+
return wholeNumber(fee, 'fee', U128_MAX);
|
|
190
137
|
}
|
|
191
138
|
|
|
192
139
|
async function readBounded(res) {
|
package/shared.mjs
CHANGED
|
@@ -8,14 +8,7 @@ function feeCeiling(maxFeeQuon) {
|
|
|
8
8
|
if (typeof maxFeeQuon === 'number') {
|
|
9
9
|
throw new Error('pass the maximum fee as a decimal string or a BigInt, never a JavaScript number, because a number silently rounds above 2^53 and could set the ceiling higher than you intended');
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
try {
|
|
13
|
-
ceiling = BigInt(maxFeeQuon);
|
|
14
|
-
} catch {
|
|
15
|
-
throw new Error('the maximum fee must be an integer number of Quon');
|
|
16
|
-
}
|
|
17
|
-
if (ceiling < 0n) throw new Error('the maximum fee cannot be negative');
|
|
18
|
-
return ceiling;
|
|
11
|
+
return wholeNumber(maxFeeQuon, 'maximum fee', U128_MAX);
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
function checkAmount(amount) {
|
|
@@ -28,35 +21,11 @@ function checkAmount(amount) {
|
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
function accountIndex(index) {
|
|
31
|
-
|
|
32
|
-
throw new Error('the account index must be a whole number in the safe integer range, a number that large silently rounds and would sign with a different account key');
|
|
33
|
-
}
|
|
34
|
-
let i;
|
|
35
|
-
try {
|
|
36
|
-
i = BigInt(index);
|
|
37
|
-
} catch {
|
|
38
|
-
throw new Error('the account index must be a whole number');
|
|
39
|
-
}
|
|
40
|
-
if (i < 0n || i > 0xffffffffffffffffn) {
|
|
41
|
-
throw new Error('the account index must fit in an unsigned 64 bit integer');
|
|
42
|
-
}
|
|
43
|
-
return i;
|
|
24
|
+
return wholeNumber(index, 'account index', U64_MAX);
|
|
44
25
|
}
|
|
45
26
|
|
|
46
27
|
function accountNonce(nonce) {
|
|
47
|
-
|
|
48
|
-
throw new Error('the gateway reported a nonce outside the safe integer range, a number that large silently rounds and would sign a different nonce');
|
|
49
|
-
}
|
|
50
|
-
let n;
|
|
51
|
-
try {
|
|
52
|
-
n = BigInt(nonce);
|
|
53
|
-
} catch {
|
|
54
|
-
throw new Error('the gateway reported a nonce that is not a whole number');
|
|
55
|
-
}
|
|
56
|
-
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
57
|
-
throw new Error('the gateway reported a nonce outside the unsigned 64 bit range');
|
|
58
|
-
}
|
|
59
|
-
return n;
|
|
28
|
+
return wholeNumber(nonce, 'nonce', U64_MAX);
|
|
60
29
|
}
|
|
61
30
|
|
|
62
31
|
const VALIDITY_BLOCKS = 300n;
|
|
@@ -142,19 +111,7 @@ function isPublicChain(name) {
|
|
|
142
111
|
}
|
|
143
112
|
|
|
144
113
|
function meterLimitOf(meterLimit) {
|
|
145
|
-
|
|
146
|
-
throw new Error('the meter limit must be a whole number in the safe integer range');
|
|
147
|
-
}
|
|
148
|
-
let meter;
|
|
149
|
-
try {
|
|
150
|
-
meter = BigInt(meterLimit);
|
|
151
|
-
} catch {
|
|
152
|
-
throw new Error('the meter limit must be a whole number');
|
|
153
|
-
}
|
|
154
|
-
if (meter < 0n || meter > 0xffffffffffffffffn) {
|
|
155
|
-
throw new Error('the meter limit must fit in an unsigned 64 bit integer');
|
|
156
|
-
}
|
|
157
|
-
return meter;
|
|
114
|
+
return wholeNumber(meterLimit, 'meter limit', U64_MAX);
|
|
158
115
|
}
|
|
159
116
|
|
|
160
117
|
function validUntil(info) {
|
|
@@ -176,17 +133,7 @@ function validUntil(info) {
|
|
|
176
133
|
}
|
|
177
134
|
|
|
178
135
|
function gatewayFee(fee) {
|
|
179
|
-
|
|
180
|
-
throw new Error('the gateway reported a fee outside the safe integer range, a number that large silently rounds and would sign a different fee');
|
|
181
|
-
}
|
|
182
|
-
let f;
|
|
183
|
-
try {
|
|
184
|
-
f = BigInt(fee);
|
|
185
|
-
} catch {
|
|
186
|
-
throw new Error('the gateway reported a fee that is not a whole number');
|
|
187
|
-
}
|
|
188
|
-
if (f < 0n) throw new Error('the gateway reported a negative fee');
|
|
189
|
-
return f;
|
|
136
|
+
return wholeNumber(fee, 'fee', U128_MAX);
|
|
190
137
|
}
|
|
191
138
|
|
|
192
139
|
async function readBounded(res) {
|