@leofcoin/chain 1.8.15 → 1.8.17
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/chain.js +26 -11
- package/exports/chain.js +26 -11
- package/package.json +1 -1
- package/exports/browser/constants-C0USBuxC.js +0 -8919
package/exports/browser/chain.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, L as LastBlockMessage, P as PROTOCOL_VERSION, a as REACHED_ONE_ZERO_ZERO,
|
|
1
|
+
import { t as toBase58, T as TransactionMessage, C as ContractMessage, R as RawTransactionMessage, B as BlockMessage, u as utils, L as LastBlockMessage, P as PROTOCOL_VERSION, a as REACHED_ONE_ZERO_ZERO, b as BWMessage, c as BWRequestMessage } from './constants-BKKQytjd.js';
|
|
2
2
|
import { log } from 'console';
|
|
3
3
|
import { log as log$1 } from 'node:console';
|
|
4
4
|
|
|
@@ -963,7 +963,7 @@ function parseUnits(value, unit) {
|
|
|
963
963
|
return FixedNumber.fromString(value, { decimals, width: 512 }).value;
|
|
964
964
|
}
|
|
965
965
|
|
|
966
|
-
const jsonStringifyBigInt = (key, value) => (typeof value === 'bigint' ? { $bigint: value.toString() } : value);
|
|
966
|
+
const jsonStringifyBigInt$1 = (key, value) => (typeof value === 'bigint' ? { $bigint: value.toString() } : value);
|
|
967
967
|
const jsonParseBigInt = (key, value) => typeof value === 'object' && value.$bigint ? BigInt(value.$bigint) : value;
|
|
968
968
|
|
|
969
969
|
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
@@ -4631,9 +4631,9 @@ class Machine {
|
|
|
4631
4631
|
await Promise.all(promises);
|
|
4632
4632
|
}
|
|
4633
4633
|
const tasks = [
|
|
4634
|
-
stateStore.put('lastBlock', JSON.stringify(await this.lastBlock, jsonStringifyBigInt)),
|
|
4635
|
-
stateStore.put('states', JSON.stringify(state, jsonStringifyBigInt)),
|
|
4636
|
-
stateStore.put('accounts', JSON.stringify(accounts, jsonStringifyBigInt)),
|
|
4634
|
+
stateStore.put('lastBlock', JSON.stringify(await this.lastBlock, jsonStringifyBigInt$1)),
|
|
4635
|
+
stateStore.put('states', JSON.stringify(state, jsonStringifyBigInt$1)),
|
|
4636
|
+
stateStore.put('accounts', JSON.stringify(accounts, jsonStringifyBigInt$1)),
|
|
4637
4637
|
stateStore.put('info', JSON.stringify({
|
|
4638
4638
|
nativeCalls: await this.nativeCalls,
|
|
4639
4639
|
nativeMints: await this.nativeMints,
|
|
@@ -4644,7 +4644,7 @@ class Machine {
|
|
|
4644
4644
|
totalMintAmount: await this.totalMintAmount,
|
|
4645
4645
|
totalTransferAmount: await this.totalTransferAmount,
|
|
4646
4646
|
totalBlocks: await blockStore.length
|
|
4647
|
-
}, jsonStringifyBigInt))
|
|
4647
|
+
}, jsonStringifyBigInt$1))
|
|
4648
4648
|
// accountsStore.clear()
|
|
4649
4649
|
];
|
|
4650
4650
|
await Promise.all(tasks);
|
|
@@ -4710,7 +4710,7 @@ class Machine {
|
|
|
4710
4710
|
totalTransactions: BigInt(0),
|
|
4711
4711
|
totalBlocks: BigInt(0)
|
|
4712
4712
|
};
|
|
4713
|
-
rawInfo = JSON.stringify(this.states.info, jsonStringifyBigInt);
|
|
4713
|
+
rawInfo = JSON.stringify(this.states.info, jsonStringifyBigInt$1);
|
|
4714
4714
|
await stateStore.put('info', new TextEncoder().encode(rawInfo));
|
|
4715
4715
|
}
|
|
4716
4716
|
}
|
|
@@ -4945,7 +4945,7 @@ class Machine {
|
|
|
4945
4945
|
debug$2(`adding loaded block: ${block.index}@${block.hash}`);
|
|
4946
4946
|
if (block.decoded)
|
|
4947
4947
|
block = { ...block.decoded, hash: await block.hash() };
|
|
4948
|
-
return this.#askWorker('addLoadedBlock', JSON.stringify(block, jsonStringifyBigInt));
|
|
4948
|
+
return this.#askWorker('addLoadedBlock', JSON.stringify(block, jsonStringifyBigInt$1));
|
|
4949
4949
|
}
|
|
4950
4950
|
async latestTransactions() {
|
|
4951
4951
|
return this.#askWorker('latestTransactions');
|
|
@@ -4994,6 +4994,16 @@ class Jobber {
|
|
|
4994
4994
|
}
|
|
4995
4995
|
}
|
|
4996
4996
|
|
|
4997
|
+
utils.addCodec({
|
|
4998
|
+
name: 'last-block-message',
|
|
4999
|
+
codec: 0x6c626d,
|
|
5000
|
+
hashAlg: 'keccak-256'
|
|
5001
|
+
});
|
|
5002
|
+
const jsonStringifyBigInt = (key, value) => {
|
|
5003
|
+
if (typeof value === 'bigint')
|
|
5004
|
+
return value.toString();
|
|
5005
|
+
return value;
|
|
5006
|
+
};
|
|
4997
5007
|
const debug$1 = createDebugger('leofcoin/state');
|
|
4998
5008
|
class State extends Contract {
|
|
4999
5009
|
#resolveErrored;
|
|
@@ -5107,7 +5117,7 @@ class State extends Contract {
|
|
|
5107
5117
|
};
|
|
5108
5118
|
this.#lastBlockHandler = async () => {
|
|
5109
5119
|
return new globalThis.peernet.protos['peernet-response']({
|
|
5110
|
-
response:
|
|
5120
|
+
response: JSON.stringify(new LastBlockMessage(await this.lastBlock).decoded, jsonStringifyBigInt)
|
|
5111
5121
|
});
|
|
5112
5122
|
};
|
|
5113
5123
|
this.#knownBlocksHandler = async () => {
|
|
@@ -6307,7 +6317,12 @@ class Chain extends VersionControl {
|
|
|
6307
6317
|
try {
|
|
6308
6318
|
let response = await peer.request(node.encoded);
|
|
6309
6319
|
response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)));
|
|
6310
|
-
|
|
6320
|
+
let decoded = response.decoded.response;
|
|
6321
|
+
try {
|
|
6322
|
+
decoded = JSON.parse(decoded);
|
|
6323
|
+
}
|
|
6324
|
+
catch { }
|
|
6325
|
+
return decoded;
|
|
6311
6326
|
}
|
|
6312
6327
|
catch (error) {
|
|
6313
6328
|
const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
|
|
@@ -6354,7 +6369,7 @@ class Chain extends VersionControl {
|
|
|
6354
6369
|
}
|
|
6355
6370
|
let lastBlock;
|
|
6356
6371
|
try {
|
|
6357
|
-
lastBlock = new LastBlockMessage(await this.#makeRequest(peer, 'lastBlock')).
|
|
6372
|
+
lastBlock = new LastBlockMessage(await this.#makeRequest(peer, 'lastBlock')).encoded;
|
|
6358
6373
|
}
|
|
6359
6374
|
catch (error) {
|
|
6360
6375
|
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || 'unknown';
|
package/exports/chain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDebugger } from '@vandeurenglenn/debug';
|
|
2
|
-
import { formatBytes, jsonStringifyBigInt, jsonParseBigInt, parseUnits, formatUnits } from '@leofcoin/utils';
|
|
2
|
+
import { formatBytes, jsonStringifyBigInt as jsonStringifyBigInt$1, jsonParseBigInt, parseUnits, formatUnits } from '@leofcoin/utils';
|
|
3
3
|
import { TransactionMessage, BlockMessage, ContractMessage, LastBlockMessage, BWMessage, BWRequestMessage } from '@leofcoin/messages';
|
|
4
4
|
import addresses, { contractFactory } from '@leofcoin/addresses';
|
|
5
5
|
import { calculateFee, createContractMessage, signTransaction, contractFactoryMessage, nativeTokenMessage, validatorsMessage, nameServiceMessage } from '@leofcoin/lib';
|
|
@@ -8,9 +8,9 @@ import { randombytes } from '@leofcoin/crypto';
|
|
|
8
8
|
import EasyWorker from '@vandeurenglenn/easy-worker';
|
|
9
9
|
import { ContractDeploymentError, ExecutionError, isResolveError, ResolveError, isExecutionError } from '@leofcoin/errors';
|
|
10
10
|
import { log } from 'console';
|
|
11
|
+
import codecs from '@leofcoin/codecs/utils';
|
|
11
12
|
import { P as PROTOCOL_VERSION, R as REACHED_ONE_ZERO_ZERO } from './constants-eo0U5-D_.js';
|
|
12
13
|
import { log as log$1 } from 'node:console';
|
|
13
|
-
import codecs from '@leofcoin/codecs/utils';
|
|
14
14
|
import '@leofcoin/networks';
|
|
15
15
|
|
|
16
16
|
const limit = 1800;
|
|
@@ -772,9 +772,9 @@ class Machine {
|
|
|
772
772
|
await Promise.all(promises);
|
|
773
773
|
}
|
|
774
774
|
const tasks = [
|
|
775
|
-
stateStore.put('lastBlock', JSON.stringify(await this.lastBlock, jsonStringifyBigInt)),
|
|
776
|
-
stateStore.put('states', JSON.stringify(state, jsonStringifyBigInt)),
|
|
777
|
-
stateStore.put('accounts', JSON.stringify(accounts, jsonStringifyBigInt)),
|
|
775
|
+
stateStore.put('lastBlock', JSON.stringify(await this.lastBlock, jsonStringifyBigInt$1)),
|
|
776
|
+
stateStore.put('states', JSON.stringify(state, jsonStringifyBigInt$1)),
|
|
777
|
+
stateStore.put('accounts', JSON.stringify(accounts, jsonStringifyBigInt$1)),
|
|
778
778
|
stateStore.put('info', JSON.stringify({
|
|
779
779
|
nativeCalls: await this.nativeCalls,
|
|
780
780
|
nativeMints: await this.nativeMints,
|
|
@@ -785,7 +785,7 @@ class Machine {
|
|
|
785
785
|
totalMintAmount: await this.totalMintAmount,
|
|
786
786
|
totalTransferAmount: await this.totalTransferAmount,
|
|
787
787
|
totalBlocks: await blockStore.length
|
|
788
|
-
}, jsonStringifyBigInt))
|
|
788
|
+
}, jsonStringifyBigInt$1))
|
|
789
789
|
// accountsStore.clear()
|
|
790
790
|
];
|
|
791
791
|
await Promise.all(tasks);
|
|
@@ -851,7 +851,7 @@ class Machine {
|
|
|
851
851
|
totalTransactions: BigInt(0),
|
|
852
852
|
totalBlocks: BigInt(0)
|
|
853
853
|
};
|
|
854
|
-
rawInfo = JSON.stringify(this.states.info, jsonStringifyBigInt);
|
|
854
|
+
rawInfo = JSON.stringify(this.states.info, jsonStringifyBigInt$1);
|
|
855
855
|
await stateStore.put('info', new TextEncoder().encode(rawInfo));
|
|
856
856
|
}
|
|
857
857
|
}
|
|
@@ -1086,7 +1086,7 @@ class Machine {
|
|
|
1086
1086
|
debug$2(`adding loaded block: ${block.index}@${block.hash}`);
|
|
1087
1087
|
if (block.decoded)
|
|
1088
1088
|
block = { ...block.decoded, hash: await block.hash() };
|
|
1089
|
-
return this.#askWorker('addLoadedBlock', JSON.stringify(block, jsonStringifyBigInt));
|
|
1089
|
+
return this.#askWorker('addLoadedBlock', JSON.stringify(block, jsonStringifyBigInt$1));
|
|
1090
1090
|
}
|
|
1091
1091
|
async latestTransactions() {
|
|
1092
1092
|
return this.#askWorker('latestTransactions');
|
|
@@ -1135,6 +1135,16 @@ class Jobber {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
|
+
codecs.addCodec({
|
|
1139
|
+
name: 'last-block-message',
|
|
1140
|
+
codec: 0x6c626d,
|
|
1141
|
+
hashAlg: 'keccak-256'
|
|
1142
|
+
});
|
|
1143
|
+
const jsonStringifyBigInt = (key, value) => {
|
|
1144
|
+
if (typeof value === 'bigint')
|
|
1145
|
+
return value.toString();
|
|
1146
|
+
return value;
|
|
1147
|
+
};
|
|
1138
1148
|
const debug$1 = createDebugger('leofcoin/state');
|
|
1139
1149
|
class State extends Contract {
|
|
1140
1150
|
#resolveErrored;
|
|
@@ -1248,7 +1258,7 @@ class State extends Contract {
|
|
|
1248
1258
|
};
|
|
1249
1259
|
this.#lastBlockHandler = async () => {
|
|
1250
1260
|
return new globalThis.peernet.protos['peernet-response']({
|
|
1251
|
-
response:
|
|
1261
|
+
response: JSON.stringify(new LastBlockMessage(await this.lastBlock).decoded, jsonStringifyBigInt)
|
|
1252
1262
|
});
|
|
1253
1263
|
};
|
|
1254
1264
|
this.#knownBlocksHandler = async () => {
|
|
@@ -2448,7 +2458,12 @@ class Chain extends VersionControl {
|
|
|
2448
2458
|
try {
|
|
2449
2459
|
let response = await peer.request(node.encoded);
|
|
2450
2460
|
response = await new globalThis.peernet.protos['peernet-response'](new Uint8Array(Object.values(response)));
|
|
2451
|
-
|
|
2461
|
+
let decoded = response.decoded.response;
|
|
2462
|
+
try {
|
|
2463
|
+
decoded = JSON.parse(decoded);
|
|
2464
|
+
}
|
|
2465
|
+
catch { }
|
|
2466
|
+
return decoded;
|
|
2452
2467
|
}
|
|
2453
2468
|
catch (error) {
|
|
2454
2469
|
const peerId = peer?.peerId || peer?.id || peer?.address || 'unknown';
|
|
@@ -2495,7 +2510,7 @@ class Chain extends VersionControl {
|
|
|
2495
2510
|
}
|
|
2496
2511
|
let lastBlock;
|
|
2497
2512
|
try {
|
|
2498
|
-
lastBlock = new LastBlockMessage(await this.#makeRequest(peer, 'lastBlock')).
|
|
2513
|
+
lastBlock = new LastBlockMessage(await this.#makeRequest(peer, 'lastBlock')).encoded;
|
|
2499
2514
|
}
|
|
2500
2515
|
catch (error) {
|
|
2501
2516
|
const peerName = peer?.peerId || peer?.id || peer?.address || peerId || 'unknown';
|