@leofcoin/chain 1.7.55 → 1.7.66
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/exports/browser/{browser-DQJ6xf_F-BqXoTvHj.js → browser-DQJ6xf_F-D0onvbt2.js} +2 -2
- package/exports/browser/chain.js +2560 -6094
- package/exports/browser/{client-Depp28gl-CAZHe8Gn.js → client-Depp28gl-DItJEEYa.js} +4 -4
- package/exports/browser/{index-BeqbCwUk-CO_3tWk0.js → index-BeqbCwUk-DfNb2uRP.js} +2 -2
- package/exports/browser/{index-jJAWNcIz.js → index-CM4QYC3g.js} +217 -192
- package/exports/browser/{index-DqPlTtAJ-C6Al_ebv.js → index-DqPlTtAJ-Bczd-x6k.js} +2 -2
- package/exports/browser/{messages-RYLqPGkg-B8phafAq.js → messages-RYLqPGkg-Da9CI_ow.js} +2 -2
- package/exports/browser/{node-browser-CDiT4wAl.js → node-browser-DewO13hB.js} +4 -4
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +1 -1
- package/exports/browser/workers/machine-worker.js +73 -10
- package/exports/browser/workers/{worker-2Vk145X_-2Vk145X_.js → worker-4K8uC3xq-4K8uC3xq.js} +217 -192
- package/exports/chain.js +24 -16
- package/exports/helpers/contract.d.ts +4 -0
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +73 -10
- package/exports/workers/{worker-2Vk145X_-2Vk145X_.js → worker-4K8uC3xq-4K8uC3xq.js} +217 -192
- package/package.json +14 -14
|
@@ -1,4 +1,61 @@
|
|
|
1
|
-
import { E as EasyWorker, C as ContractMessage, T as TransactionMessage } from './worker-
|
|
1
|
+
import { E as EasyWorker, C as ContractMessage, T as TransactionMessage } from './worker-4K8uC3xq-4K8uC3xq.js';
|
|
2
|
+
|
|
3
|
+
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
|
|
4
|
+
/**
|
|
5
|
+
* The current version of Ethers.
|
|
6
|
+
*/
|
|
7
|
+
["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
|
8
|
+
try {
|
|
9
|
+
// General test for normalize
|
|
10
|
+
/* c8 ignore start */
|
|
11
|
+
if ("test".normalize(form) !== "test") {
|
|
12
|
+
throw new Error("bad");
|
|
13
|
+
}
|
|
14
|
+
;
|
|
15
|
+
/* c8 ignore stop */
|
|
16
|
+
if (form === "NFD") {
|
|
17
|
+
const check = String.fromCharCode(0xe9).normalize("NFD");
|
|
18
|
+
const expected = String.fromCharCode(0x65, 0x0301);
|
|
19
|
+
/* c8 ignore start */
|
|
20
|
+
if (check !== expected) {
|
|
21
|
+
throw new Error("broken");
|
|
22
|
+
}
|
|
23
|
+
/* c8 ignore stop */
|
|
24
|
+
}
|
|
25
|
+
accum.push(form);
|
|
26
|
+
}
|
|
27
|
+
catch (error) { }
|
|
28
|
+
return accum;
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Some mathematic operations.
|
|
33
|
+
*
|
|
34
|
+
* @_subsection: api/utils:Math Helpers [about-maths]
|
|
35
|
+
*/
|
|
36
|
+
BigInt(0);
|
|
37
|
+
BigInt(1);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The **FixedNumber** class permits using values with decimal places,
|
|
41
|
+
* using fixed-pont math.
|
|
42
|
+
*
|
|
43
|
+
* Fixed-point math is still based on integers under-the-hood, but uses an
|
|
44
|
+
* internal offset to store fractional components below, and each operation
|
|
45
|
+
* corrects for this after each operation.
|
|
46
|
+
*
|
|
47
|
+
* @_section: api/utils/fixed-point-math:Fixed-Point Maths [about-fixed-point-math]
|
|
48
|
+
*/
|
|
49
|
+
BigInt(-1);
|
|
50
|
+
BigInt(0);
|
|
51
|
+
BigInt(1);
|
|
52
|
+
BigInt(5);
|
|
53
|
+
// Constant to pull zeros from for multipliers
|
|
54
|
+
let Zeros = "0000";
|
|
55
|
+
while (Zeros.length < 80) {
|
|
56
|
+
Zeros += Zeros;
|
|
57
|
+
}
|
|
58
|
+
const jsonParseBigInt = (key, value) => typeof value === 'object' && value.$bigint ? BigInt(value.$bigint) : value;
|
|
2
59
|
|
|
3
60
|
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
4
61
|
const formatBytes = (bytes, decimals = 2) => {
|
|
@@ -263,22 +320,22 @@ const _ = {
|
|
|
263
320
|
nativeCalls += 1n;
|
|
264
321
|
if (method === 'burn') {
|
|
265
322
|
nativeBurns = nativeBurns += 1n;
|
|
266
|
-
totalBurnAmount
|
|
323
|
+
totalBurnAmount += BigInt(params[1]);
|
|
267
324
|
}
|
|
268
325
|
if (method === 'mint') {
|
|
269
326
|
nativeMints = nativeMints += 1n;
|
|
270
|
-
totalMintAmount
|
|
327
|
+
totalMintAmount += BigInt(params[1]);
|
|
271
328
|
}
|
|
272
329
|
if (method === 'transfer') {
|
|
273
330
|
nativeTransfers = nativeTransfers += 1n;
|
|
274
|
-
totalTransferAmount
|
|
275
|
-
}
|
|
276
|
-
if (method === 'transferFrom') {
|
|
277
|
-
nativeTransfers = nativeTransfers += 1n;
|
|
278
|
-
totalTransferAmount = totalTransferAmount += params[1];
|
|
331
|
+
totalTransferAmount += BigInt(params[2]);
|
|
279
332
|
}
|
|
333
|
+
// if (method === 'transferFrom') {
|
|
334
|
+
// nativeTransfers = nativeTransfers += 1n
|
|
335
|
+
// totalTransferAmount += params[1]
|
|
336
|
+
// }
|
|
280
337
|
}
|
|
281
|
-
totalTransactions
|
|
338
|
+
totalTransactions += 1n;
|
|
282
339
|
// state.put(result)
|
|
283
340
|
return result;
|
|
284
341
|
}
|
|
@@ -293,6 +350,10 @@ const _ = {
|
|
|
293
350
|
},
|
|
294
351
|
init: async (message) => {
|
|
295
352
|
let { peerid, fromState, state, info } = message;
|
|
353
|
+
if (info)
|
|
354
|
+
info = JSON.parse(info, jsonParseBigInt);
|
|
355
|
+
if (state)
|
|
356
|
+
state = JSON.parse(state, jsonParseBigInt);
|
|
296
357
|
globalThis.peerid = peerid;
|
|
297
358
|
console.log({ fromState, info });
|
|
298
359
|
nativeCalls = BigInt(info?.nativeCalls ?? 0);
|
|
@@ -305,7 +366,9 @@ const _ = {
|
|
|
305
366
|
totalTransferAmount = BigInt(info?.totalTransferAmount ?? 0);
|
|
306
367
|
totalBlocks = BigInt(info?.totalBlocks ?? 0);
|
|
307
368
|
if (fromState) {
|
|
308
|
-
|
|
369
|
+
if (message.lastBlock) {
|
|
370
|
+
lastBlock = JSON.parse(message.lastBlock, jsonParseBigInt);
|
|
371
|
+
}
|
|
309
372
|
const setState = async (address, state) => {
|
|
310
373
|
const contractBytes = await resolveContract(address);
|
|
311
374
|
if (contractBytes === address) {
|
|
@@ -7458,6 +7458,9 @@ var pako = {
|
|
|
7458
7458
|
constants: constants_1
|
|
7459
7459
|
};
|
|
7460
7460
|
|
|
7461
|
+
const jsonStringifyBigInt$1 = (key, value) => (typeof value === 'bigint' ? { $bigint: value.toString() } : value);
|
|
7462
|
+
const jsonParseBigInt$1 = (key, value) => typeof value === 'object' && value.$bigint ? BigInt(value.$bigint) : value;
|
|
7463
|
+
|
|
7461
7464
|
const { fromString, toString } = index$1;
|
|
7462
7465
|
const isJson = (type) => type === 'object' || 'array';
|
|
7463
7466
|
const isString = (type) => type === 'string';
|
|
@@ -7493,7 +7496,7 @@ const toType = (data) => {
|
|
|
7493
7496
|
return new TextEncoder().encode(data);
|
|
7494
7497
|
// returns the object as UintArray
|
|
7495
7498
|
if (typeof data === 'object')
|
|
7496
|
-
return new TextEncoder().encode(JSON.stringify(data));
|
|
7499
|
+
return new TextEncoder().encode(JSON.stringify(data, jsonStringifyBigInt$1));
|
|
7497
7500
|
// returns the number as UintArray
|
|
7498
7501
|
if (typeof data === 'number' || typeof data === 'boolean')
|
|
7499
7502
|
return new TextEncoder().encode(data.toString());
|
|
@@ -7539,7 +7542,7 @@ const decode = (proto, uint8Array, compressed) => {
|
|
|
7539
7542
|
else if (isBigInt(token.type))
|
|
7540
7543
|
output[token.key] = BigInt(new TextDecoder().decode(deconcated[i]));
|
|
7541
7544
|
else if (isJson(token.type))
|
|
7542
|
-
output[token.key] = JSON.parse(new TextDecoder().decode(deconcated[i]));
|
|
7545
|
+
output[token.key] = JSON.parse(new TextDecoder().decode(deconcated[i]), jsonParseBigInt$1);
|
|
7543
7546
|
if (token.optional) {
|
|
7544
7547
|
if (!output[token.key] || output[token.key].length === 0)
|
|
7545
7548
|
delete output[token.key];
|
|
@@ -7554,6 +7557,8 @@ var index = {
|
|
|
7554
7557
|
decode
|
|
7555
7558
|
};
|
|
7556
7559
|
|
|
7560
|
+
const jsonStringifyBigInt = (key, value) => typeof value === 'bigint' ? { $bigint: value.toString() } : value;
|
|
7561
|
+
const jsonParseBigInt = (key, value) => typeof value === 'object' && value.$bigint ? BigInt(value.$bigint) : value;
|
|
7557
7562
|
class BasicInterface {
|
|
7558
7563
|
#encoded;
|
|
7559
7564
|
#decoded;
|
|
@@ -7670,195 +7675,209 @@ class BasicInterface {
|
|
|
7670
7675
|
}
|
|
7671
7676
|
}
|
|
7672
7677
|
|
|
7673
|
-
const blockchainCodecs = [
|
|
7674
|
-
{
|
|
7675
|
-
name: 'leofcoin-block',
|
|
7676
|
-
codec: '0x6c62',
|
|
7677
|
-
hashAlg: 'dbl-keccak-512',
|
|
7678
|
-
},
|
|
7679
|
-
{
|
|
7680
|
-
name: 'leofcoin-tx',
|
|
7681
|
-
codec: '0x6c74',
|
|
7682
|
-
hashAlg: 'dbl-keccak-512',
|
|
7683
|
-
},
|
|
7684
|
-
{
|
|
7685
|
-
name: 'leofcoin-itx',
|
|
7686
|
-
codec: '0x6c69',
|
|
7687
|
-
hashAlg: 'keccak-512',
|
|
7688
|
-
},
|
|
7689
|
-
{
|
|
7690
|
-
name: 'leofcoin-pr',
|
|
7691
|
-
codec: '0x6c70',
|
|
7692
|
-
hashAlg: 'keccak-256',
|
|
7693
|
-
},
|
|
7694
|
-
{
|
|
7695
|
-
name: 'contract-message',
|
|
7696
|
-
codec: '0x63636d',
|
|
7697
|
-
hashAlg: 'keccak-256'
|
|
7698
|
-
},
|
|
7699
|
-
{
|
|
7700
|
-
name: 'transaction-message',
|
|
7701
|
-
codec: '0x746d',
|
|
7702
|
-
hashAlg: 'keccak-256'
|
|
7703
|
-
},
|
|
7704
|
-
{
|
|
7705
|
-
name: 'raw-transaction-message',
|
|
7706
|
-
codec: '0x772746d',
|
|
7707
|
-
hashAlg: 'keccak-256'
|
|
7708
|
-
},
|
|
7709
|
-
{
|
|
7710
|
-
name: 'block-message',
|
|
7711
|
-
codec: '0x626d',
|
|
7712
|
-
hashAlg: 'keccak-256'
|
|
7713
|
-
},
|
|
7714
|
-
{
|
|
7715
|
-
name: 'bw-message',
|
|
7716
|
-
codec: '0x62776d',
|
|
7717
|
-
hashAlg: 'keccak-256'
|
|
7718
|
-
},
|
|
7719
|
-
{
|
|
7720
|
-
name: 'bw-request-message',
|
|
7721
|
-
codec: '0x6277726d',
|
|
7722
|
-
hashAlg: 'keccak-256'
|
|
7723
|
-
},
|
|
7724
|
-
{
|
|
7725
|
-
name: 'validator-message',
|
|
7726
|
-
codec: '0x766d',
|
|
7727
|
-
hashAlg: 'keccak-256'
|
|
7728
|
-
}
|
|
7678
|
+
const blockchainCodecs = [
|
|
7679
|
+
{
|
|
7680
|
+
name: 'leofcoin-block',
|
|
7681
|
+
codec: '0x6c62',
|
|
7682
|
+
hashAlg: 'dbl-keccak-512',
|
|
7683
|
+
},
|
|
7684
|
+
{
|
|
7685
|
+
name: 'leofcoin-tx',
|
|
7686
|
+
codec: '0x6c74',
|
|
7687
|
+
hashAlg: 'dbl-keccak-512',
|
|
7688
|
+
},
|
|
7689
|
+
{
|
|
7690
|
+
name: 'leofcoin-itx',
|
|
7691
|
+
codec: '0x6c69',
|
|
7692
|
+
hashAlg: 'keccak-512',
|
|
7693
|
+
},
|
|
7694
|
+
{
|
|
7695
|
+
name: 'leofcoin-pr',
|
|
7696
|
+
codec: '0x6c70',
|
|
7697
|
+
hashAlg: 'keccak-256',
|
|
7698
|
+
},
|
|
7699
|
+
{
|
|
7700
|
+
name: 'contract-message',
|
|
7701
|
+
codec: '0x63636d',
|
|
7702
|
+
hashAlg: 'keccak-256'
|
|
7703
|
+
},
|
|
7704
|
+
{
|
|
7705
|
+
name: 'transaction-message',
|
|
7706
|
+
codec: '0x746d',
|
|
7707
|
+
hashAlg: 'keccak-256'
|
|
7708
|
+
},
|
|
7709
|
+
{
|
|
7710
|
+
name: 'raw-transaction-message',
|
|
7711
|
+
codec: '0x772746d',
|
|
7712
|
+
hashAlg: 'keccak-256'
|
|
7713
|
+
},
|
|
7714
|
+
{
|
|
7715
|
+
name: 'block-message',
|
|
7716
|
+
codec: '0x626d',
|
|
7717
|
+
hashAlg: 'keccak-256'
|
|
7718
|
+
},
|
|
7719
|
+
{
|
|
7720
|
+
name: 'bw-message',
|
|
7721
|
+
codec: '0x62776d',
|
|
7722
|
+
hashAlg: 'keccak-256'
|
|
7723
|
+
},
|
|
7724
|
+
{
|
|
7725
|
+
name: 'bw-request-message',
|
|
7726
|
+
codec: '0x6277726d',
|
|
7727
|
+
hashAlg: 'keccak-256'
|
|
7728
|
+
},
|
|
7729
|
+
{
|
|
7730
|
+
name: 'validator-message',
|
|
7731
|
+
codec: '0x766d',
|
|
7732
|
+
hashAlg: 'keccak-256'
|
|
7733
|
+
}
|
|
7729
7734
|
];
|
|
7730
7735
|
|
|
7731
|
-
const internalCodecs = [
|
|
7732
|
-
{
|
|
7733
|
-
name: '
|
|
7734
|
-
codec: '
|
|
7735
|
-
hashAlg: '
|
|
7736
|
-
},
|
|
7737
|
-
{
|
|
7738
|
-
name: '
|
|
7739
|
-
codec: '
|
|
7740
|
-
hashAlg: 'keccak-256'
|
|
7741
|
-
}
|
|
7742
|
-
{
|
|
7743
|
-
name: 'peernet-peer',
|
|
7744
|
-
codec: '0x7070',
|
|
7745
|
-
hashAlg: 'keccak-256',
|
|
7746
|
-
},
|
|
7747
|
-
{
|
|
7748
|
-
name: 'peernet-dht',
|
|
7749
|
-
codec: '0x706468',
|
|
7750
|
-
hashAlg: 'keccak-256',
|
|
7751
|
-
},
|
|
7752
|
-
{
|
|
7753
|
-
name: 'peernet-dht-response',
|
|
7754
|
-
codec: '0x706472',
|
|
7755
|
-
hashAlg: 'keccak-256',
|
|
7756
|
-
},
|
|
7757
|
-
{
|
|
7758
|
-
name: 'peernet-data',
|
|
7759
|
-
codec: '0x706461',
|
|
7760
|
-
hashAlg: 'keccak-256',
|
|
7761
|
-
},
|
|
7762
|
-
{
|
|
7763
|
-
name: 'peernet-data-response',
|
|
7764
|
-
codec: '0x70646172',
|
|
7765
|
-
hashAlg: 'keccak-256',
|
|
7766
|
-
},
|
|
7767
|
-
{
|
|
7768
|
-
name: 'peernet-message',
|
|
7769
|
-
codec: '0x706d65',
|
|
7770
|
-
hashAlg: 'keccak-256',
|
|
7771
|
-
},
|
|
7772
|
-
{
|
|
7773
|
-
name: 'peernet-ps',
|
|
7774
|
-
codec: '707073',
|
|
7775
|
-
hashAlg: 'keccak-256',
|
|
7776
|
-
},
|
|
7777
|
-
{
|
|
7778
|
-
name: 'peernet-response',
|
|
7779
|
-
codec: '0x7072',
|
|
7780
|
-
hashAlg: 'keccak-256',
|
|
7781
|
-
},
|
|
7782
|
-
{
|
|
7783
|
-
name: 'peernet-request',
|
|
7784
|
-
codec: '0x707271',
|
|
7785
|
-
hashAlg: 'keccak-256',
|
|
7786
|
-
},
|
|
7787
|
-
{
|
|
7788
|
-
name: 'peernet-file',
|
|
7789
|
-
codec: '0x7066',
|
|
7790
|
-
hashAlg: 'keccak-256',
|
|
7791
|
-
},
|
|
7792
|
-
{
|
|
7793
|
-
name: 'peernet-file-response',
|
|
7794
|
-
codec: '0x706672',
|
|
7795
|
-
hashAlg: 'keccak-256',
|
|
7796
|
-
}
|
|
7736
|
+
const internalCodecs = [
|
|
7737
|
+
{
|
|
7738
|
+
name: 'pubsub-request',
|
|
7739
|
+
codec: '0x70737271',
|
|
7740
|
+
hashAlg: 'keccak-256'
|
|
7741
|
+
},
|
|
7742
|
+
{
|
|
7743
|
+
name: 'pubsub-response',
|
|
7744
|
+
codec: '0x707372',
|
|
7745
|
+
hashAlg: 'keccak-256'
|
|
7746
|
+
}
|
|
7797
7747
|
];
|
|
7798
7748
|
|
|
7799
|
-
var social = [{
|
|
7800
|
-
name: 'chat-message',
|
|
7801
|
-
codec: '0x70636d',
|
|
7802
|
-
hashAlg: 'dbl-keccak-256',
|
|
7749
|
+
var social = [{
|
|
7750
|
+
name: 'chat-message',
|
|
7751
|
+
codec: '0x70636d',
|
|
7752
|
+
hashAlg: 'dbl-keccak-256',
|
|
7803
7753
|
}];
|
|
7804
7754
|
|
|
7805
|
-
const
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7755
|
+
const peernetCodecs = [
|
|
7756
|
+
{
|
|
7757
|
+
name: 'disco-hash',
|
|
7758
|
+
codec: '0x30',
|
|
7759
|
+
hashAlg: 'dbl-keccak-256',
|
|
7760
|
+
},
|
|
7761
|
+
{
|
|
7762
|
+
name: 'peernet-peer-response',
|
|
7763
|
+
codec: '0x707072',
|
|
7764
|
+
hashAlg: 'keccak-256',
|
|
7765
|
+
},
|
|
7766
|
+
{
|
|
7767
|
+
name: 'peernet-peer',
|
|
7768
|
+
codec: '0x7070',
|
|
7769
|
+
hashAlg: 'keccak-256',
|
|
7770
|
+
},
|
|
7771
|
+
{
|
|
7772
|
+
name: 'peernet-dht',
|
|
7773
|
+
codec: '0x706468',
|
|
7774
|
+
hashAlg: 'keccak-256',
|
|
7775
|
+
},
|
|
7776
|
+
{
|
|
7777
|
+
name: 'peernet-dht-response',
|
|
7778
|
+
codec: '0x706472',
|
|
7779
|
+
hashAlg: 'keccak-256',
|
|
7780
|
+
},
|
|
7781
|
+
{
|
|
7782
|
+
name: 'peernet-data',
|
|
7783
|
+
codec: '0x706461',
|
|
7784
|
+
hashAlg: 'keccak-256',
|
|
7785
|
+
},
|
|
7786
|
+
{
|
|
7787
|
+
name: 'peernet-data-response',
|
|
7788
|
+
codec: '0x70646172',
|
|
7789
|
+
hashAlg: 'keccak-256',
|
|
7790
|
+
},
|
|
7791
|
+
{
|
|
7792
|
+
name: 'peernet-message',
|
|
7793
|
+
codec: '0x706d65',
|
|
7794
|
+
hashAlg: 'keccak-256',
|
|
7795
|
+
},
|
|
7796
|
+
{
|
|
7797
|
+
name: 'peernet-ps',
|
|
7798
|
+
codec: '707073',
|
|
7799
|
+
hashAlg: 'keccak-256',
|
|
7800
|
+
},
|
|
7801
|
+
{
|
|
7802
|
+
name: 'peernet-response',
|
|
7803
|
+
codec: '0x7072',
|
|
7804
|
+
hashAlg: 'keccak-256',
|
|
7805
|
+
},
|
|
7806
|
+
{
|
|
7807
|
+
name: 'peernet-request',
|
|
7808
|
+
codec: '0x707271',
|
|
7809
|
+
hashAlg: 'keccak-256',
|
|
7810
|
+
},
|
|
7811
|
+
{
|
|
7812
|
+
name: 'peernet-file',
|
|
7813
|
+
codec: '0x7066',
|
|
7814
|
+
hashAlg: 'keccak-256',
|
|
7815
|
+
},
|
|
7816
|
+
{
|
|
7817
|
+
name: 'peernet-file-response',
|
|
7818
|
+
codec: '0x706672',
|
|
7819
|
+
hashAlg: 'keccak-256',
|
|
7820
|
+
}
|
|
7809
7821
|
];
|
|
7810
7822
|
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
if (
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
const
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
const
|
|
7846
|
-
if (
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7823
|
+
const codecs$1 = [
|
|
7824
|
+
...internalCodecs,
|
|
7825
|
+
...blockchainCodecs,
|
|
7826
|
+
...social,
|
|
7827
|
+
...peernetCodecs
|
|
7828
|
+
];
|
|
7829
|
+
|
|
7830
|
+
const codecs = {};
|
|
7831
|
+
const addCodec = (codecInput) => {
|
|
7832
|
+
let { hashAlg, codec, name } = codecInput;
|
|
7833
|
+
if (!codecs[name])
|
|
7834
|
+
codecs[name] = {
|
|
7835
|
+
hashAlg,
|
|
7836
|
+
codec: typeof codec === 'string' ? parseInt(codec, 16) : codec
|
|
7837
|
+
};
|
|
7838
|
+
};
|
|
7839
|
+
for (const codec of codecs$1) {
|
|
7840
|
+
addCodec(codec);
|
|
7841
|
+
}
|
|
7842
|
+
const getCodec = (name) => {
|
|
7843
|
+
if (typeof name === 'number')
|
|
7844
|
+
return name;
|
|
7845
|
+
return getCodecByName(name).codec;
|
|
7846
|
+
};
|
|
7847
|
+
const getCodecName = (codec) => {
|
|
7848
|
+
return Object.keys(codecs).reduce((p, c) => {
|
|
7849
|
+
const item = codecs[c];
|
|
7850
|
+
if (item.codec === codec)
|
|
7851
|
+
return c;
|
|
7852
|
+
else
|
|
7853
|
+
return p;
|
|
7854
|
+
}, undefined);
|
|
7855
|
+
};
|
|
7856
|
+
const getCodecByName = (name) => codecs[name];
|
|
7857
|
+
const getHashAlg = (name) => {
|
|
7858
|
+
if (typeof name === 'number')
|
|
7859
|
+
return getCodecByName(getCodecName(name)).hashAlg;
|
|
7860
|
+
return getCodecByName(name).hashAlg;
|
|
7861
|
+
};
|
|
7862
|
+
const isCodec = (codec) => {
|
|
7863
|
+
if (codec.codec !== undefined && codec.hashAlg)
|
|
7864
|
+
return true;
|
|
7865
|
+
return false;
|
|
7866
|
+
};
|
|
7867
|
+
const validateCodec = (codec) => {
|
|
7868
|
+
if (codec.codec === undefined ||
|
|
7869
|
+
codec.hashAlg === undefined ||
|
|
7870
|
+
codec.name === undefined)
|
|
7871
|
+
throw new Error(`invalid codecInput: ${codec}`);
|
|
7872
|
+
};
|
|
7873
|
+
var utils = {
|
|
7874
|
+
isCodec,
|
|
7875
|
+
addCodec,
|
|
7876
|
+
getCodec,
|
|
7877
|
+
getHashAlg,
|
|
7878
|
+
getCodecName,
|
|
7879
|
+
validateCodec,
|
|
7880
|
+
codecs: codecs
|
|
7862
7881
|
};
|
|
7863
7882
|
|
|
7864
7883
|
class Codec extends BasicInterface {
|
|
@@ -7965,20 +7984,21 @@ class Codec extends BasicInterface {
|
|
|
7965
7984
|
class CodecHash extends BasicInterface {
|
|
7966
7985
|
codec;
|
|
7967
7986
|
discoCodec;
|
|
7968
|
-
|
|
7987
|
+
size;
|
|
7988
|
+
constructor(buffer, options) {
|
|
7969
7989
|
super();
|
|
7970
|
-
if (options
|
|
7990
|
+
if (options?.name)
|
|
7971
7991
|
this.name = options.name;
|
|
7972
7992
|
else
|
|
7973
7993
|
this.name = 'disco-hash';
|
|
7974
|
-
if (options
|
|
7994
|
+
if (options?.codecs)
|
|
7975
7995
|
this.codecs = options.codecs;
|
|
7976
7996
|
return this.init(buffer);
|
|
7977
7997
|
}
|
|
7978
7998
|
async init(uint8Array) {
|
|
7979
7999
|
if (uint8Array) {
|
|
7980
8000
|
if (uint8Array instanceof Uint8Array) {
|
|
7981
|
-
this.discoCodec = new Codec(uint8Array
|
|
8001
|
+
this.discoCodec = new Codec(uint8Array);
|
|
7982
8002
|
const name = this.discoCodec.name;
|
|
7983
8003
|
if (name) {
|
|
7984
8004
|
this.name = name;
|
|
@@ -8020,7 +8040,7 @@ class CodecHash extends BasicInterface {
|
|
|
8020
8040
|
return this.encoded;
|
|
8021
8041
|
}
|
|
8022
8042
|
fromJSON(json) {
|
|
8023
|
-
return this.encode(new TextEncoder().encode(JSON.stringify(json)));
|
|
8043
|
+
return this.encode(new TextEncoder().encode(JSON.stringify(json, jsonStringifyBigInt)));
|
|
8024
8044
|
}
|
|
8025
8045
|
async encode(buffer, name) {
|
|
8026
8046
|
if (!this.name && name)
|
|
@@ -8094,7 +8114,7 @@ class CodecHash extends BasicInterface {
|
|
|
8094
8114
|
name: this.name,
|
|
8095
8115
|
size: this.size,
|
|
8096
8116
|
length: this.length,
|
|
8097
|
-
digest: this.digest
|
|
8117
|
+
digest: this.digest
|
|
8098
8118
|
};
|
|
8099
8119
|
}
|
|
8100
8120
|
}
|
|
@@ -8218,13 +8238,13 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
|
8218
8238
|
this.encoded = buffer;
|
|
8219
8239
|
return this.hasCodec()
|
|
8220
8240
|
? this.decode()
|
|
8221
|
-
: this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
8241
|
+
: this.create(JSON.parse(new TextDecoder().decode(this.encoded), jsonParseBigInt));
|
|
8222
8242
|
}
|
|
8223
8243
|
fromArrayBuffer(buffer) {
|
|
8224
8244
|
this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength);
|
|
8225
8245
|
return this.hasCodec()
|
|
8226
8246
|
? this.decode()
|
|
8227
|
-
: this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
|
|
8247
|
+
: this.create(JSON.parse(new TextDecoder().decode(this.encoded), jsonParseBigInt));
|
|
8228
8248
|
}
|
|
8229
8249
|
/**
|
|
8230
8250
|
* @param {Object} data
|
|
@@ -8264,7 +8284,7 @@ class ValidatorMessage extends FormatInterface {
|
|
|
8264
8284
|
}
|
|
8265
8285
|
|
|
8266
8286
|
var proto$2 = {
|
|
8267
|
-
index:
|
|
8287
|
+
index: BigInt(0),
|
|
8268
8288
|
previousHash: String(),
|
|
8269
8289
|
timestamp: Number(),
|
|
8270
8290
|
reward: BigInt(0),
|
|
@@ -8323,6 +8343,11 @@ class ContractMessage extends FormatInterface {
|
|
|
8323
8343
|
}
|
|
8324
8344
|
}
|
|
8325
8345
|
|
|
8346
|
+
({
|
|
8347
|
+
hash: String(),
|
|
8348
|
+
index: BigInt(0)
|
|
8349
|
+
});
|
|
8350
|
+
|
|
8326
8351
|
var proto = {
|
|
8327
8352
|
timestamp: Number(),
|
|
8328
8353
|
from: String(),
|