@leofcoin/chain 1.7.49 → 1.7.52
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/README.md +5 -0
- package/exports/browser/{browser-DQJ6xf_F-C6-szetT.js → browser-DQJ6xf_F-BegK2uLt.js} +2 -2
- package/exports/browser/chain.js +4253 -36
- package/exports/browser/{client-Depp28gl-B4Mz_hP5.js → client-Depp28gl-CXOVR2or.js} +4 -4
- package/exports/browser/{index-BeqbCwUk-k7nFljXa.js → index-BeqbCwUk-DFZB5z7Q.js} +2 -2
- package/exports/browser/{index-DqPlTtAJ-BCTqnABp.js → index-DqPlTtAJ-1o5kJ_mi.js} +2 -2
- package/exports/browser/{workers/worker-Botf--mj-BUK2CMT9.js → index-jJAWNcIz.js} +68 -4224
- package/exports/browser/{messages-RYLqPGkg-Jd6OizO7.js → messages-RYLqPGkg-007SVYHA.js} +2 -2
- package/exports/browser/{node-browser-lePEPRA6.js → node-browser-CuHuGNar.js} +4 -4
- package/exports/browser/node-browser.js +2 -2
- package/exports/chain.d.ts +5 -7
- package/exports/chain.js +43 -28
- package/exports/flags.d.ts +2 -0
- package/exports/machine.d.ts +9 -10
- package/exports/transaction.d.ts +1 -1
- package/package.json +12 -12
- package/exports/browser/index-XTbRdu6H.js +0 -12611
- package/exports/browser/workers/block-worker.js +0 -33
- package/exports/browser/workers/machine-worker.js +0 -505
- package/exports/workers/block-worker.js +0 -33
- package/exports/workers/machine-worker.js +0 -505
- package/exports/workers/worker-Botf--mj-BUK2CMT9.js +0 -12565
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormatInterface$3, C as ContractMessage, T as TransactionMessage,
|
|
1
|
+
import { F as FormatInterface$3, C as ContractMessage, T as TransactionMessage, B as BlockMessage, a as BWMessage, b as BWRequestMessage, V as ValidatorMessage } from './index-jJAWNcIz.js';
|
|
2
2
|
|
|
3
3
|
var proto = {
|
|
4
4
|
lastblock: Object(),
|
|
@@ -16678,7 +16678,7 @@ class Identity {
|
|
|
16678
16678
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
16679
16679
|
}
|
|
16680
16680
|
else {
|
|
16681
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-BeqbCwUk-
|
|
16681
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-BeqbCwUk-DFZB5z7Q.js');
|
|
16682
16682
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
16683
16683
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
16684
16684
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -29434,7 +29434,7 @@ class Peernet {
|
|
|
29434
29434
|
this.root = options.root;
|
|
29435
29435
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
29436
29436
|
// FolderMessageResponse
|
|
29437
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-RYLqPGkg-
|
|
29437
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-RYLqPGkg-007SVYHA.js');
|
|
29438
29438
|
/**
|
|
29439
29439
|
* proto Object containing protos
|
|
29440
29440
|
* @type {Object}
|
|
@@ -29528,7 +29528,7 @@ class Peernet {
|
|
|
29528
29528
|
if (this.#starting || this.#started)
|
|
29529
29529
|
return;
|
|
29530
29530
|
this.#starting = true;
|
|
29531
|
-
const importee = await import('./client-Depp28gl-
|
|
29531
|
+
const importee = await import('./client-Depp28gl-CXOVR2or.js');
|
|
29532
29532
|
/**
|
|
29533
29533
|
* @access public
|
|
29534
29534
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
2
|
-
import './index-
|
|
1
|
+
export { N as default } from './node-browser-CuHuGNar.js';
|
|
2
|
+
import './index-jJAWNcIz.js';
|
package/exports/chain.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import '@vandeurenglenn/debug';
|
|
2
|
-
import { BigNumber } from '@leofcoin/utils';
|
|
3
|
-
import { BigNumberish } from '@ethersproject/bignumber';
|
|
4
2
|
import { Address } from './types.js';
|
|
5
3
|
import { VersionControl } from './version-control.js';
|
|
6
4
|
export default class Chain extends VersionControl {
|
|
@@ -21,14 +19,14 @@ export default class Chain extends VersionControl {
|
|
|
21
19
|
sendTransaction(transaction: any): Promise<{
|
|
22
20
|
hash: any;
|
|
23
21
|
data: any;
|
|
24
|
-
fee: string | 0 | BigNumber;
|
|
22
|
+
fee: string | 0 | import("@ethersproject/bignumber").BigNumber;
|
|
25
23
|
wait: Promise<unknown>;
|
|
26
24
|
message: any;
|
|
27
25
|
}>;
|
|
28
26
|
addContract(transaction: any, contractMessage: any): Promise<{
|
|
29
27
|
hash: any;
|
|
30
28
|
data: any;
|
|
31
|
-
fee: string | 0 | BigNumber;
|
|
29
|
+
fee: string | 0 | import("@ethersproject/bignumber").BigNumber;
|
|
32
30
|
wait: Promise<unknown>;
|
|
33
31
|
message: any;
|
|
34
32
|
}>;
|
|
@@ -50,10 +48,10 @@ export default class Chain extends VersionControl {
|
|
|
50
48
|
*/
|
|
51
49
|
call(contract: Address, method: string, parameters?: any[]): Promise<any>;
|
|
52
50
|
staticCall(contract: Address, method: string, parameters?: any[]): Promise<any>;
|
|
53
|
-
mint(to: Address, amount:
|
|
54
|
-
transfer(from: Address, to: Address, amount:
|
|
51
|
+
mint(to: Address, amount: bigint): Promise<any>;
|
|
52
|
+
transfer(from: Address, to: Address, amount: bigint): Promise<any>;
|
|
55
53
|
get balances(): Promise<{
|
|
56
|
-
[index: string]:
|
|
54
|
+
[index: string]: bigint;
|
|
57
55
|
}>;
|
|
58
56
|
get contracts(): Promise<any>;
|
|
59
57
|
deleteAll(): Promise<any[]>;
|
package/exports/chain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@vandeurenglenn/debug';
|
|
2
|
-
import { formatBytes,
|
|
2
|
+
import { formatBytes, formatUnits, parseUnits } from '@leofcoin/utils';
|
|
3
3
|
import { TransactionMessage, BlockMessage, ContractMessage, 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';
|
|
@@ -7,6 +7,7 @@ import semver from 'semver';
|
|
|
7
7
|
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
|
+
import { warn } from 'console';
|
|
10
11
|
|
|
11
12
|
const limit = 1800;
|
|
12
13
|
const transactionLimit = 1000;
|
|
@@ -284,15 +285,15 @@ class Machine {
|
|
|
284
285
|
},
|
|
285
286
|
accounts: {},
|
|
286
287
|
info: {
|
|
287
|
-
nativeCalls:
|
|
288
|
-
nativeMints:
|
|
289
|
-
nativeBurns:
|
|
290
|
-
nativeTransfers:
|
|
291
|
-
totalBurnAmount:
|
|
292
|
-
totalMintAmount:
|
|
293
|
-
totalTransferAmount:
|
|
294
|
-
totalTransactions:
|
|
295
|
-
totalBlocks:
|
|
288
|
+
nativeCalls: BigInt(0),
|
|
289
|
+
nativeMints: BigInt(0),
|
|
290
|
+
nativeBurns: BigInt(0),
|
|
291
|
+
nativeTransfers: BigInt(0),
|
|
292
|
+
totalBurnAmount: BigInt(0),
|
|
293
|
+
totalMintAmount: BigInt(0),
|
|
294
|
+
totalTransferAmount: BigInt(0),
|
|
295
|
+
totalTransactions: BigInt(0),
|
|
296
|
+
totalBlocks: BigInt(0)
|
|
296
297
|
}
|
|
297
298
|
};
|
|
298
299
|
this.wantList = [];
|
|
@@ -364,6 +365,12 @@ class Machine {
|
|
|
364
365
|
this.wantList.push(data.input);
|
|
365
366
|
}
|
|
366
367
|
}
|
|
368
|
+
else if (data.question === 'peers') {
|
|
369
|
+
this.worker.postMessage({ id: data.id, input: peernet.peers });
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
this.worker.postMessage({ id: data.id, input: data.input });
|
|
373
|
+
}
|
|
367
374
|
}
|
|
368
375
|
}
|
|
369
376
|
}
|
|
@@ -476,7 +483,7 @@ class Machine {
|
|
|
476
483
|
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')));
|
|
477
484
|
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')));
|
|
478
485
|
for (const key in info) {
|
|
479
|
-
info[key] =
|
|
486
|
+
info[key] = BigInt(info[key]);
|
|
480
487
|
}
|
|
481
488
|
this.states.info = info;
|
|
482
489
|
}
|
|
@@ -485,15 +492,15 @@ class Machine {
|
|
|
485
492
|
this.states.accounts = {};
|
|
486
493
|
// todo try fetching info from fully synced peer
|
|
487
494
|
this.states.info = {
|
|
488
|
-
nativeCalls:
|
|
489
|
-
nativeMints:
|
|
490
|
-
nativeBurns:
|
|
491
|
-
nativeTransfers:
|
|
492
|
-
totalBurnAmount:
|
|
493
|
-
totalMintAmount:
|
|
494
|
-
totalTransferAmount:
|
|
495
|
-
totalTransactions:
|
|
496
|
-
totalBlocks:
|
|
495
|
+
nativeCalls: BigInt(0),
|
|
496
|
+
nativeMints: BigInt(0),
|
|
497
|
+
nativeBurns: BigInt(0),
|
|
498
|
+
nativeTransfers: BigInt(0),
|
|
499
|
+
totalBurnAmount: BigInt(0),
|
|
500
|
+
totalMintAmount: BigInt(0),
|
|
501
|
+
totalTransferAmount: BigInt(0),
|
|
502
|
+
totalTransactions: BigInt(0),
|
|
503
|
+
totalBlocks: BigInt(0)
|
|
497
504
|
};
|
|
498
505
|
}
|
|
499
506
|
}
|
|
@@ -1353,7 +1360,8 @@ class VersionControl extends State {
|
|
|
1353
1360
|
constructor(config) {
|
|
1354
1361
|
super(config);
|
|
1355
1362
|
}
|
|
1356
|
-
#currentVersion = '1.
|
|
1363
|
+
#currentVersion = '0.1.0';
|
|
1364
|
+
#reachedOneZeroZero = false;
|
|
1357
1365
|
async #setCurrentVersion() {
|
|
1358
1366
|
this.version = this.#currentVersion;
|
|
1359
1367
|
await globalThis.chainStore.put('version', this.version);
|
|
@@ -1366,13 +1374,21 @@ class VersionControl extends State {
|
|
|
1366
1374
|
console.log(this.version, this.#currentVersion);
|
|
1367
1375
|
/**
|
|
1368
1376
|
* protocol version control!
|
|
1369
|
-
* Note that before
|
|
1370
|
-
*
|
|
1377
|
+
* Note that before v1.2.2 everything gets deleted because of big changes,
|
|
1378
|
+
* This will be removed in the future by setting the #reachedOneZeroZero flag to true
|
|
1379
|
+
*
|
|
1380
|
+
* This is because we are still in development and the protocol is still changing a lot.
|
|
1381
|
+
*
|
|
1382
|
+
* # this is not what we want in the future.
|
|
1371
1383
|
* In the future we want newer nodes to handle the new changes and still confirm old version transactions
|
|
1372
1384
|
* Unless there is a security issue!
|
|
1373
|
-
* But for now the protocoll isn't finished enough and still has to much breaking changes.
|
|
1374
1385
|
*/
|
|
1375
|
-
if
|
|
1386
|
+
// check if we are above v1.0.0 and if we still not reached v1.0.0
|
|
1387
|
+
// if so, clear all data
|
|
1388
|
+
// once v1.0.0 is reached this will not run and we can remove this check once every node is above v1.0.0
|
|
1389
|
+
warn('the reachedZeroZero flag is set to false, this will clear all data on every start if above v1.0.0');
|
|
1390
|
+
if (semver.compare(this.version, '1.0.0') === 1 && !this.#reachedOneZeroZero) {
|
|
1391
|
+
warn('clearing all data because we are below v1.0.0');
|
|
1376
1392
|
await this.clearAll();
|
|
1377
1393
|
}
|
|
1378
1394
|
if (semver.compare(this.#currentVersion, this.version) === 1) {
|
|
@@ -1388,7 +1404,6 @@ class VersionControl extends State {
|
|
|
1388
1404
|
}
|
|
1389
1405
|
}
|
|
1390
1406
|
|
|
1391
|
-
globalThis.BigNumber = BigNumber;
|
|
1392
1407
|
const debug = globalThis.createDebugger('leofcoin/chain');
|
|
1393
1408
|
// check if browser or local
|
|
1394
1409
|
class Chain extends VersionControl {
|
|
@@ -1489,7 +1504,7 @@ class Chain extends VersionControl {
|
|
|
1489
1504
|
const initialized = await globalThis.contractStore.has(addresses.contractFactory);
|
|
1490
1505
|
if (!initialized)
|
|
1491
1506
|
await this.#setup();
|
|
1492
|
-
this.utils = {
|
|
1507
|
+
this.utils = { formatUnits, parseUnits };
|
|
1493
1508
|
// this.#state = new State()
|
|
1494
1509
|
// todo some functions rely on state
|
|
1495
1510
|
await super.init();
|
|
@@ -1746,7 +1761,7 @@ class Chain extends VersionControl {
|
|
|
1746
1761
|
let block = {
|
|
1747
1762
|
transactions: [],
|
|
1748
1763
|
validators: [],
|
|
1749
|
-
fees:
|
|
1764
|
+
fees: BigInt(0),
|
|
1750
1765
|
timestamp,
|
|
1751
1766
|
previousHash: '',
|
|
1752
1767
|
reward: parseUnits('150'),
|
package/exports/machine.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import EasyWorker from '@vandeurenglenn/easy-worker';
|
|
2
|
-
import { BigNumber } from '@leofcoin/utils';
|
|
3
2
|
export default class Machine {
|
|
4
3
|
#private;
|
|
5
4
|
worker: EasyWorker;
|
|
@@ -11,15 +10,15 @@ export default class Machine {
|
|
|
11
10
|
};
|
|
12
11
|
accounts: {};
|
|
13
12
|
info: {
|
|
14
|
-
nativeCalls:
|
|
15
|
-
nativeMints:
|
|
16
|
-
nativeBurns:
|
|
17
|
-
nativeTransfers:
|
|
18
|
-
totalBurnAmount:
|
|
19
|
-
totalMintAmount:
|
|
20
|
-
totalTransferAmount:
|
|
21
|
-
totalTransactions:
|
|
22
|
-
totalBlocks:
|
|
13
|
+
nativeCalls: bigint;
|
|
14
|
+
nativeMints: bigint;
|
|
15
|
+
nativeBurns: bigint;
|
|
16
|
+
nativeTransfers: bigint;
|
|
17
|
+
totalBurnAmount: bigint;
|
|
18
|
+
totalMintAmount: bigint;
|
|
19
|
+
totalTransferAmount: bigint;
|
|
20
|
+
totalTransactions: bigint;
|
|
21
|
+
totalBlocks: bigint;
|
|
23
22
|
};
|
|
24
23
|
};
|
|
25
24
|
wantList: string[];
|
package/exports/transaction.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export default class Transaction extends Protocol {
|
|
|
34
34
|
sendTransaction(message: any): Promise<{
|
|
35
35
|
hash: any;
|
|
36
36
|
data: any;
|
|
37
|
-
fee: string | 0 | import("@
|
|
37
|
+
fee: string | 0 | import("@ethersproject/bignumber").BigNumber;
|
|
38
38
|
wait: Promise<unknown>;
|
|
39
39
|
message: any;
|
|
40
40
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.52",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -55,24 +55,24 @@
|
|
|
55
55
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
56
56
|
"@types/semver": "^7.5.8",
|
|
57
57
|
"@vandeurenglenn/debug": "^1.2.5",
|
|
58
|
-
"rollup": "^4.
|
|
58
|
+
"rollup": "^4.22.2",
|
|
59
59
|
"rollup-plugin-modify": "^3.0.0",
|
|
60
|
-
"tape": "^5.
|
|
60
|
+
"tape": "^5.9.0",
|
|
61
61
|
"tslib": "^2.7.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@leofcoin/addresses": "^1.0.
|
|
65
|
-
"@leofcoin/contracts": "^0.1.
|
|
66
|
-
"@leofcoin/crypto": "^0.2.
|
|
67
|
-
"@leofcoin/errors": "^1.0.
|
|
68
|
-
"@leofcoin/lib": "^1.2.
|
|
69
|
-
"@leofcoin/messages": "^1.4.
|
|
64
|
+
"@leofcoin/addresses": "^1.0.38",
|
|
65
|
+
"@leofcoin/contracts": "^0.1.13",
|
|
66
|
+
"@leofcoin/crypto": "^0.2.24",
|
|
67
|
+
"@leofcoin/errors": "^1.0.19",
|
|
68
|
+
"@leofcoin/lib": "^1.2.63",
|
|
69
|
+
"@leofcoin/messages": "^1.4.33",
|
|
70
70
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
71
|
-
"@leofcoin/networks": "^1.1.
|
|
71
|
+
"@leofcoin/networks": "^1.1.18",
|
|
72
72
|
"@leofcoin/peernet": "^1.1.80",
|
|
73
73
|
"@leofcoin/storage": "^3.5.32",
|
|
74
|
-
"@leofcoin/utils": "^1.1.
|
|
75
|
-
"@leofcoin/workers": "^1.5.
|
|
74
|
+
"@leofcoin/utils": "^1.1.30",
|
|
75
|
+
"@leofcoin/workers": "^1.5.14",
|
|
76
76
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
77
77
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
78
78
|
"semver": "^7.6.3"
|