@leofcoin/chain 1.7.54 → 1.7.55
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-BegK2uLt.js → browser-DQJ6xf_F-BqXoTvHj.js} +1 -1
- package/exports/browser/chain.js +243 -15
- package/exports/browser/{client-Depp28gl-CXOVR2or.js → client-Depp28gl-CAZHe8Gn.js} +3 -3
- package/exports/browser/{index-BeqbCwUk-DFZB5z7Q.js → index-BeqbCwUk-CO_3tWk0.js} +1 -1
- package/exports/browser/{index-DqPlTtAJ-1o5kJ_mi.js → index-DqPlTtAJ-C6Al_ebv.js} +1 -1
- package/exports/browser/{messages-RYLqPGkg-007SVYHA.js → messages-RYLqPGkg-B8phafAq.js} +1 -1
- package/exports/browser/{node-browser-CuHuGNar.js → node-browser-CDiT4wAl.js} +4 -4
- package/exports/browser/node-browser.js +1 -1
- package/exports/browser/workers/machine-worker.js +31 -30
- package/exports/chain.d.ts +2 -2
- package/exports/chain.js +14 -14
- package/exports/contract.d.ts +2 -2
- package/exports/node.js +1 -1
- package/exports/transaction.d.ts +1 -1
- package/exports/workers/machine-worker.js +31 -30
- package/package.json +9 -9
package/exports/browser/chain.js
CHANGED
|
@@ -35,6 +35,232 @@ if (!globalThis.debug) {
|
|
|
35
35
|
globalThis.createDebugger = createDebugger;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/* Do NOT modify this file; see /src.ts/_admin/update-version.ts */
|
|
39
|
+
/**
|
|
40
|
+
* The current version of Ethers.
|
|
41
|
+
*/
|
|
42
|
+
const version$4 = "6.13.2";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Property helper functions.
|
|
46
|
+
*
|
|
47
|
+
* @_subsection api/utils:Properties [about-properties]
|
|
48
|
+
*/
|
|
49
|
+
/**
|
|
50
|
+
* Assigns the %%values%% to %%target%% as read-only values.
|
|
51
|
+
*
|
|
52
|
+
* It %%types%% is specified, the values are checked.
|
|
53
|
+
*/
|
|
54
|
+
function defineProperties(target, values, types) {
|
|
55
|
+
for (let key in values) {
|
|
56
|
+
let value = values[key];
|
|
57
|
+
Object.defineProperty(target, key, { enumerable: true, value, writable: false });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* All errors in ethers include properties to ensure they are both
|
|
63
|
+
* human-readable (i.e. ``.message``) and machine-readable (i.e. ``.code``).
|
|
64
|
+
*
|
|
65
|
+
* The [[isError]] function can be used to check the error ``code`` and
|
|
66
|
+
* provide a type guard for the properties present on that error interface.
|
|
67
|
+
*
|
|
68
|
+
* @_section: api/utils/errors:Errors [about-errors]
|
|
69
|
+
*/
|
|
70
|
+
function stringify(value) {
|
|
71
|
+
if (value == null) {
|
|
72
|
+
return "null";
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
return "[ " + (value.map(stringify)).join(", ") + " ]";
|
|
76
|
+
}
|
|
77
|
+
if (value instanceof Uint8Array) {
|
|
78
|
+
const HEX = "0123456789abcdef";
|
|
79
|
+
let result = "0x";
|
|
80
|
+
for (let i = 0; i < value.length; i++) {
|
|
81
|
+
result += HEX[value[i] >> 4];
|
|
82
|
+
result += HEX[value[i] & 0xf];
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
if (typeof (value) === "object" && typeof (value.toJSON) === "function") {
|
|
87
|
+
return stringify(value.toJSON());
|
|
88
|
+
}
|
|
89
|
+
switch (typeof (value)) {
|
|
90
|
+
case "boolean":
|
|
91
|
+
case "symbol":
|
|
92
|
+
return value.toString();
|
|
93
|
+
case "bigint":
|
|
94
|
+
return BigInt(value).toString();
|
|
95
|
+
case "number":
|
|
96
|
+
return (value).toString();
|
|
97
|
+
case "string":
|
|
98
|
+
return JSON.stringify(value);
|
|
99
|
+
case "object": {
|
|
100
|
+
const keys = Object.keys(value);
|
|
101
|
+
keys.sort();
|
|
102
|
+
return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return `[ COULD NOT SERIALIZE ]`;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns a new Error configured to the format ethers emits errors, with
|
|
109
|
+
* the %%message%%, [[api:ErrorCode]] %%code%% and additional properties
|
|
110
|
+
* for the corresponding EthersError.
|
|
111
|
+
*
|
|
112
|
+
* Each error in ethers includes the version of ethers, a
|
|
113
|
+
* machine-readable [[ErrorCode]], and depending on %%code%%, additional
|
|
114
|
+
* required properties. The error message will also include the %%message%%,
|
|
115
|
+
* ethers version, %%code%% and all additional properties, serialized.
|
|
116
|
+
*/
|
|
117
|
+
function makeError(message, code, info) {
|
|
118
|
+
let shortMessage = message;
|
|
119
|
+
{
|
|
120
|
+
const details = [];
|
|
121
|
+
if (info) {
|
|
122
|
+
if ("message" in info || "code" in info || "name" in info) {
|
|
123
|
+
throw new Error(`value will overwrite populated values: ${stringify(info)}`);
|
|
124
|
+
}
|
|
125
|
+
for (const key in info) {
|
|
126
|
+
if (key === "shortMessage") {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const value = (info[key]);
|
|
130
|
+
// try {
|
|
131
|
+
details.push(key + "=" + stringify(value));
|
|
132
|
+
// } catch (error: any) {
|
|
133
|
+
// console.log("MMM", error.message);
|
|
134
|
+
// details.push(key + "=[could not serialize object]");
|
|
135
|
+
// }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
details.push(`code=${code}`);
|
|
139
|
+
details.push(`version=${version$4}`);
|
|
140
|
+
if (details.length) {
|
|
141
|
+
message += " (" + details.join(", ") + ")";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
let error;
|
|
145
|
+
switch (code) {
|
|
146
|
+
case "INVALID_ARGUMENT":
|
|
147
|
+
error = new TypeError(message);
|
|
148
|
+
break;
|
|
149
|
+
case "NUMERIC_FAULT":
|
|
150
|
+
case "BUFFER_OVERRUN":
|
|
151
|
+
error = new RangeError(message);
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
error = new Error(message);
|
|
155
|
+
}
|
|
156
|
+
defineProperties(error, { code });
|
|
157
|
+
if (info) {
|
|
158
|
+
Object.assign(error, info);
|
|
159
|
+
}
|
|
160
|
+
if (error.shortMessage == null) {
|
|
161
|
+
defineProperties(error, { shortMessage });
|
|
162
|
+
}
|
|
163
|
+
return error;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Throws an EthersError with %%message%%, %%code%% and additional error
|
|
167
|
+
* %%info%% when %%check%% is falsish..
|
|
168
|
+
*
|
|
169
|
+
* @see [[api:makeError]]
|
|
170
|
+
*/
|
|
171
|
+
function assert(check, message, code, info) {
|
|
172
|
+
if (!check) {
|
|
173
|
+
throw makeError(message, code, info);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A simple helper to simply ensuring provided arguments match expected
|
|
178
|
+
* constraints, throwing if not.
|
|
179
|
+
*
|
|
180
|
+
* In TypeScript environments, the %%check%% has been asserted true, so
|
|
181
|
+
* any further code does not need additional compile-time checks.
|
|
182
|
+
*/
|
|
183
|
+
function assertArgument(check, message, name, value) {
|
|
184
|
+
assert(check, message, "INVALID_ARGUMENT", { argument: name, value: value });
|
|
185
|
+
}
|
|
186
|
+
["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
|
187
|
+
try {
|
|
188
|
+
// General test for normalize
|
|
189
|
+
/* c8 ignore start */
|
|
190
|
+
if ("test".normalize(form) !== "test") {
|
|
191
|
+
throw new Error("bad");
|
|
192
|
+
}
|
|
193
|
+
;
|
|
194
|
+
/* c8 ignore stop */
|
|
195
|
+
if (form === "NFD") {
|
|
196
|
+
const check = String.fromCharCode(0xe9).normalize("NFD");
|
|
197
|
+
const expected = String.fromCharCode(0x65, 0x0301);
|
|
198
|
+
/* c8 ignore start */
|
|
199
|
+
if (check !== expected) {
|
|
200
|
+
throw new Error("broken");
|
|
201
|
+
}
|
|
202
|
+
/* c8 ignore stop */
|
|
203
|
+
}
|
|
204
|
+
accum.push(form);
|
|
205
|
+
}
|
|
206
|
+
catch (error) { }
|
|
207
|
+
return accum;
|
|
208
|
+
}, []);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Some mathematic operations.
|
|
212
|
+
*
|
|
213
|
+
* @_subsection: api/utils:Math Helpers [about-maths]
|
|
214
|
+
*/
|
|
215
|
+
BigInt(0);
|
|
216
|
+
BigInt(1);
|
|
217
|
+
//const BN_Max256 = (BN_1 << BigInt(256)) - BN_1;
|
|
218
|
+
// IEEE 754 support 53-bits of mantissa
|
|
219
|
+
const maxValue = 0x1fffffffffffff;
|
|
220
|
+
/**
|
|
221
|
+
* Gets a BigInt from %%value%%. If it is an invalid value for
|
|
222
|
+
* a BigInt, then an ArgumentError will be thrown for %%name%%.
|
|
223
|
+
*/
|
|
224
|
+
function getBigInt(value, name) {
|
|
225
|
+
switch (typeof (value)) {
|
|
226
|
+
case "bigint": return value;
|
|
227
|
+
case "number":
|
|
228
|
+
assertArgument(Number.isInteger(value), "underflow", "value", value);
|
|
229
|
+
assertArgument(value >= -maxValue && value <= maxValue, "overflow", "value", value);
|
|
230
|
+
return BigInt(value);
|
|
231
|
+
case "string":
|
|
232
|
+
try {
|
|
233
|
+
if (value === "") {
|
|
234
|
+
throw new Error("empty string");
|
|
235
|
+
}
|
|
236
|
+
if (value[0] === "-" && value[1] !== "-") {
|
|
237
|
+
return -BigInt(value.substring(1));
|
|
238
|
+
}
|
|
239
|
+
return BigInt(value);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
assertArgument(false, `invalid BigNumberish string: ${e.message}`, "value", value);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
assertArgument(false, "invalid BigNumberish value", "value", value);
|
|
246
|
+
}
|
|
247
|
+
const Nibbles = "0123456789abcdef";
|
|
248
|
+
/*
|
|
249
|
+
* Converts %%value%% to a BigInt. If %%value%% is a Uint8Array, it
|
|
250
|
+
* is treated as Big Endian data.
|
|
251
|
+
*/
|
|
252
|
+
function toBigInt(value) {
|
|
253
|
+
if (value instanceof Uint8Array) {
|
|
254
|
+
let result = "0x0";
|
|
255
|
+
for (const v of value) {
|
|
256
|
+
result += Nibbles[v >> 4];
|
|
257
|
+
result += Nibbles[v & 0x0f];
|
|
258
|
+
}
|
|
259
|
+
return BigInt(result);
|
|
260
|
+
}
|
|
261
|
+
return getBigInt(value);
|
|
262
|
+
}
|
|
263
|
+
|
|
38
264
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
39
265
|
|
|
40
266
|
function getDefaultExportFromCjs (x) {
|
|
@@ -4635,6 +4861,8 @@ const formatBytes = (bytes, decimals = 2) => {
|
|
|
4635
4861
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
4636
4862
|
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(decimals))} ${byteFormats[i]}`;
|
|
4637
4863
|
};
|
|
4864
|
+
const jsonStringifyBigInt = (key, value) => (typeof value === 'bigint' ? { $bigint: value.toString() } : value);
|
|
4865
|
+
const jsonParseBigInt = (key, value) => typeof value === 'object' && value.$bigint ? BigInt(value.$bigint) : value;
|
|
4638
4866
|
|
|
4639
4867
|
var contractFactory$1 = "IHNY2GQHUE4PTLSDCQFK44M4V56IYCLPHBC73NATR7ZM2J7HVM7XAZLTZAT";
|
|
4640
4868
|
var nativeToken$1 = "IHNY2GQH2YS5GXF7JWKY7MKGO6MKNZ3CFWZQLE5CE5HOIEIFQXK3ZJMD2OD";
|
|
@@ -4685,9 +4913,9 @@ const calculateFee = async (transaction, format = false) => {
|
|
|
4685
4913
|
if (transaction.to === validators$2)
|
|
4686
4914
|
return 0;
|
|
4687
4915
|
transaction = await new TransactionMessage(transaction);
|
|
4688
|
-
let fee =
|
|
4916
|
+
let fee = toBigInt(String(transaction.encoded.length));
|
|
4689
4917
|
// fee per gb
|
|
4690
|
-
fee
|
|
4918
|
+
fee /= 1073741824n;
|
|
4691
4919
|
// fee = fee.div(1000000)
|
|
4692
4920
|
return format ? formatUnits(fee.toString()) : fee;
|
|
4693
4921
|
};
|
|
@@ -7467,7 +7695,7 @@ class Machine {
|
|
|
7467
7695
|
}
|
|
7468
7696
|
}
|
|
7469
7697
|
else if (data.question === 'peers') {
|
|
7470
|
-
this.worker.postMessage({ id: data.id, input: peernet.peers });
|
|
7698
|
+
this.worker.postMessage({ id: data.id, input: peernet.connections ? peernet.peers : [] });
|
|
7471
7699
|
}
|
|
7472
7700
|
else {
|
|
7473
7701
|
this.worker.postMessage({ id: data.id, input: data.input });
|
|
@@ -7531,8 +7759,8 @@ class Machine {
|
|
|
7531
7759
|
}
|
|
7532
7760
|
const tasks = [
|
|
7533
7761
|
stateStore.put('lastBlock', JSON.stringify(await this.lastBlock)),
|
|
7534
|
-
stateStore.put('states', JSON.stringify(state)),
|
|
7535
|
-
stateStore.put('accounts', JSON.stringify(accounts)),
|
|
7762
|
+
stateStore.put('states', JSON.stringify(state, jsonStringifyBigInt)),
|
|
7763
|
+
stateStore.put('accounts', JSON.stringify(accounts, jsonStringifyBigInt)),
|
|
7536
7764
|
stateStore.put('info', JSON.stringify({
|
|
7537
7765
|
nativeCalls: await this.nativeCalls,
|
|
7538
7766
|
nativeMints: await this.nativeMints,
|
|
@@ -7543,7 +7771,7 @@ class Machine {
|
|
|
7543
7771
|
totalMintAmount: await this.totalMintAmount,
|
|
7544
7772
|
totalTransferAmount: await this.totalTransferAmount,
|
|
7545
7773
|
totalBlocks: await blockStore.length
|
|
7546
|
-
}))
|
|
7774
|
+
}, jsonStringifyBigInt))
|
|
7547
7775
|
// accountsStore.clear()
|
|
7548
7776
|
];
|
|
7549
7777
|
await Promise.all(tasks);
|
|
@@ -7579,13 +7807,13 @@ class Machine {
|
|
|
7579
7807
|
this.worker.onmessage(this.#onmessage.bind(this));
|
|
7580
7808
|
if (await stateStore.has('lastBlock')) {
|
|
7581
7809
|
this.states.lastBlock = JSON.parse(new TextDecoder().decode(await stateStore.get('lastBlock')));
|
|
7582
|
-
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')));
|
|
7810
|
+
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')), jsonParseBigInt);
|
|
7583
7811
|
try {
|
|
7584
|
-
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')));
|
|
7585
|
-
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')));
|
|
7586
|
-
for (const key in info) {
|
|
7587
|
-
|
|
7588
|
-
}
|
|
7812
|
+
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')), jsonParseBigInt);
|
|
7813
|
+
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')), jsonParseBigInt);
|
|
7814
|
+
// for (const key in info) {
|
|
7815
|
+
// info[key] = BigInt(info[key])
|
|
7816
|
+
// }
|
|
7589
7817
|
this.states.info = info;
|
|
7590
7818
|
}
|
|
7591
7819
|
catch (error) {
|
|
@@ -8833,7 +9061,7 @@ class Chain extends VersionControl {
|
|
|
8833
9061
|
const result = await this.#executeTransaction({ ...transaction.decoded, hash });
|
|
8834
9062
|
if (block) {
|
|
8835
9063
|
block.transactions.push(hash);
|
|
8836
|
-
block.fees = block.fees
|
|
9064
|
+
block.fees = block.fees += await calculateFee(transaction.decoded);
|
|
8837
9065
|
}
|
|
8838
9066
|
await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
|
|
8839
9067
|
await transactionStore.put(hash, await transaction.encode());
|
|
@@ -8921,8 +9149,8 @@ class Chain extends VersionControl {
|
|
|
8921
9149
|
}
|
|
8922
9150
|
block.validators = block.validators.map((validator) => {
|
|
8923
9151
|
validator.reward = block.fees;
|
|
8924
|
-
validator.reward
|
|
8925
|
-
validator.reward
|
|
9152
|
+
validator.reward += block.reward;
|
|
9153
|
+
validator.reward /= block.validators.length;
|
|
8926
9154
|
delete validator.bw;
|
|
8927
9155
|
return validator;
|
|
8928
9156
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './node-browser-
|
|
1
|
+
import { L as LittlePubSub } from './node-browser-CDiT4wAl.js';
|
|
2
2
|
import './index-jJAWNcIz.js';
|
|
3
3
|
|
|
4
4
|
class Api {
|
|
@@ -209,7 +209,7 @@ class SocketRequestClient {
|
|
|
209
209
|
const init = async () => {
|
|
210
210
|
// @ts-ignore
|
|
211
211
|
if (!globalThis.WebSocket && !this.#experimentalWebsocket)
|
|
212
|
-
globalThis.WebSocket = (await import('./browser-DQJ6xf_F-
|
|
212
|
+
globalThis.WebSocket = (await import('./browser-DQJ6xf_F-BqXoTvHj.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
213
213
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
214
214
|
if (this.#experimentalWebsocket) {
|
|
215
215
|
client.addEventListener('error', this.onerror);
|
|
@@ -313,7 +313,7 @@ const iceServers = [
|
|
|
313
313
|
credential: 'openrelayproject'
|
|
314
314
|
}
|
|
315
315
|
];
|
|
316
|
-
const SimplePeer = (await import('./index-DqPlTtAJ-
|
|
316
|
+
const SimplePeer = (await import('./index-DqPlTtAJ-C6Al_ebv.js').then(function (n) { return n.i; })).default;
|
|
317
317
|
class Peer extends SimplePeer {
|
|
318
318
|
peerId;
|
|
319
319
|
channelName;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-
|
|
1
|
+
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-CDiT4wAl.js';
|
|
2
2
|
import './index-jJAWNcIz.js';
|
|
3
3
|
|
|
4
4
|
var browser$2 = {exports: {}};
|
|
@@ -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-CO_3tWk0.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-B8phafAq.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-CAZHe8Gn.js');
|
|
29532
29532
|
/**
|
|
29533
29533
|
* @access public
|
|
29534
29534
|
* @type {PeernetClient}
|
|
@@ -30050,7 +30050,7 @@ class Node {
|
|
|
30050
30050
|
async _init(config = {
|
|
30051
30051
|
network: 'leofcoin:peach',
|
|
30052
30052
|
networkVersion: 'peach',
|
|
30053
|
-
version: '1.
|
|
30053
|
+
version: '0.1.0',
|
|
30054
30054
|
stars: networks.leofcoin.peach.stars
|
|
30055
30055
|
}, password) {
|
|
30056
30056
|
config = { ...DEFAULT_NODE_OPTIONS, ...config };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as default } from './node-browser-
|
|
1
|
+
export { N as default } from './node-browser-CDiT4wAl.js';
|
|
2
2
|
import './index-jJAWNcIz.js';
|
|
@@ -378,6 +378,7 @@ const _ = {
|
|
|
378
378
|
latestTransactions.splice(-transactionCount, latestTransactions.length);
|
|
379
379
|
}
|
|
380
380
|
if (!block.loaded && !fromState) {
|
|
381
|
+
totalBlocks += 1n;
|
|
381
382
|
try {
|
|
382
383
|
const transactions = await Promise.all(block.transactions.map(async (transaction) => {
|
|
383
384
|
const message = new TransactionMessage(await resolveTransaction(transaction)).decode();
|
|
@@ -449,36 +450,9 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
449
450
|
case 'addLoadedBlock':
|
|
450
451
|
runTask(id, 'addLoadedBlock', input);
|
|
451
452
|
break;
|
|
452
|
-
case 'nativeCalls':
|
|
453
|
-
respond(id, nativeCalls);
|
|
454
|
-
break;
|
|
455
453
|
case 'contracts':
|
|
456
454
|
respond(id, contracts);
|
|
457
455
|
break;
|
|
458
|
-
case 'totalContracts':
|
|
459
|
-
respond(id, Object.keys(contracts).length);
|
|
460
|
-
break;
|
|
461
|
-
case 'nativeMints':
|
|
462
|
-
respond(id, nativeMints);
|
|
463
|
-
break;
|
|
464
|
-
case 'nativeBurns':
|
|
465
|
-
respond(id, nativeBurns);
|
|
466
|
-
break;
|
|
467
|
-
case 'nativeTransfers':
|
|
468
|
-
respond(id, nativeTransfers);
|
|
469
|
-
break;
|
|
470
|
-
case 'totalBurnAmount':
|
|
471
|
-
respond(id, totalBurnAmount);
|
|
472
|
-
break;
|
|
473
|
-
case 'totalMintAmount':
|
|
474
|
-
respond(id, totalMintAmount);
|
|
475
|
-
break;
|
|
476
|
-
case 'totalTransferAmount':
|
|
477
|
-
respond(id, totalTransferAmount);
|
|
478
|
-
break;
|
|
479
|
-
case 'totalBlocks':
|
|
480
|
-
respond(id, totalBlocks);
|
|
481
|
-
break;
|
|
482
456
|
case 'blocks':
|
|
483
457
|
respond(id, input ? blocks.slice(input.from, input.to) : blocks);
|
|
484
458
|
break;
|
|
@@ -494,15 +468,42 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
494
468
|
case 'latestTransactions':
|
|
495
469
|
respond(id, latestTransactions);
|
|
496
470
|
break;
|
|
497
|
-
case 'totalTransactions':
|
|
498
|
-
respond(id, totalTransactions);
|
|
499
|
-
break;
|
|
500
471
|
case 'has':
|
|
501
472
|
respond(id, has(input.address));
|
|
502
473
|
break;
|
|
503
474
|
case 'get':
|
|
504
475
|
respond(id, get(input));
|
|
505
476
|
break;
|
|
477
|
+
case 'totalContracts':
|
|
478
|
+
respond(id, Object.keys(contracts).length);
|
|
479
|
+
break;
|
|
480
|
+
case 'nativeCalls':
|
|
481
|
+
respond(id, nativeCalls.toString());
|
|
482
|
+
break;
|
|
483
|
+
case 'nativeMints':
|
|
484
|
+
respond(id, nativeMints.toString());
|
|
485
|
+
break;
|
|
486
|
+
case 'nativeBurns':
|
|
487
|
+
respond(id, nativeBurns.toString());
|
|
488
|
+
break;
|
|
489
|
+
case 'nativeTransfers':
|
|
490
|
+
respond(id, nativeTransfers.toString());
|
|
491
|
+
break;
|
|
492
|
+
case 'totalBurnAmount':
|
|
493
|
+
respond(id, totalBurnAmount.toString());
|
|
494
|
+
break;
|
|
495
|
+
case 'totalMintAmount':
|
|
496
|
+
respond(id, totalMintAmount.toString());
|
|
497
|
+
break;
|
|
498
|
+
case 'totalTransferAmount':
|
|
499
|
+
respond(id, totalTransferAmount.toString());
|
|
500
|
+
break;
|
|
501
|
+
case 'totalBlocks':
|
|
502
|
+
respond(id, totalBlocks.toString());
|
|
503
|
+
break;
|
|
504
|
+
case 'totalTransactions':
|
|
505
|
+
respond(id, totalTransactions.toString());
|
|
506
|
+
break;
|
|
506
507
|
default:
|
|
507
508
|
console.log(`machine-worker: unsupported taskType: ${type}`);
|
|
508
509
|
break;
|
package/exports/chain.d.ts
CHANGED
|
@@ -19,14 +19,14 @@ export default class Chain extends VersionControl {
|
|
|
19
19
|
sendTransaction(transaction: any): Promise<{
|
|
20
20
|
hash: any;
|
|
21
21
|
data: any;
|
|
22
|
-
fee: string |
|
|
22
|
+
fee: string | bigint | 0;
|
|
23
23
|
wait: Promise<unknown>;
|
|
24
24
|
message: any;
|
|
25
25
|
}>;
|
|
26
26
|
addContract(transaction: any, contractMessage: any): Promise<{
|
|
27
27
|
hash: any;
|
|
28
28
|
data: any;
|
|
29
|
-
fee: string |
|
|
29
|
+
fee: string | bigint | 0;
|
|
30
30
|
wait: Promise<unknown>;
|
|
31
31
|
message: any;
|
|
32
32
|
}>;
|
package/exports/chain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@vandeurenglenn/debug';
|
|
2
|
-
import { formatBytes, formatUnits, parseUnits } from '@leofcoin/utils';
|
|
2
|
+
import { formatBytes, jsonStringifyBigInt, jsonParseBigInt, 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';
|
|
@@ -366,7 +366,7 @@ class Machine {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
else if (data.question === 'peers') {
|
|
369
|
-
this.worker.postMessage({ id: data.id, input: peernet.peers });
|
|
369
|
+
this.worker.postMessage({ id: data.id, input: peernet.connections ? peernet.peers : [] });
|
|
370
370
|
}
|
|
371
371
|
else {
|
|
372
372
|
this.worker.postMessage({ id: data.id, input: data.input });
|
|
@@ -430,8 +430,8 @@ class Machine {
|
|
|
430
430
|
}
|
|
431
431
|
const tasks = [
|
|
432
432
|
stateStore.put('lastBlock', JSON.stringify(await this.lastBlock)),
|
|
433
|
-
stateStore.put('states', JSON.stringify(state)),
|
|
434
|
-
stateStore.put('accounts', JSON.stringify(accounts)),
|
|
433
|
+
stateStore.put('states', JSON.stringify(state, jsonStringifyBigInt)),
|
|
434
|
+
stateStore.put('accounts', JSON.stringify(accounts, jsonStringifyBigInt)),
|
|
435
435
|
stateStore.put('info', JSON.stringify({
|
|
436
436
|
nativeCalls: await this.nativeCalls,
|
|
437
437
|
nativeMints: await this.nativeMints,
|
|
@@ -442,7 +442,7 @@ class Machine {
|
|
|
442
442
|
totalMintAmount: await this.totalMintAmount,
|
|
443
443
|
totalTransferAmount: await this.totalTransferAmount,
|
|
444
444
|
totalBlocks: await blockStore.length
|
|
445
|
-
}))
|
|
445
|
+
}, jsonStringifyBigInt))
|
|
446
446
|
// accountsStore.clear()
|
|
447
447
|
];
|
|
448
448
|
await Promise.all(tasks);
|
|
@@ -478,13 +478,13 @@ class Machine {
|
|
|
478
478
|
this.worker.onmessage(this.#onmessage.bind(this));
|
|
479
479
|
if (await stateStore.has('lastBlock')) {
|
|
480
480
|
this.states.lastBlock = JSON.parse(new TextDecoder().decode(await stateStore.get('lastBlock')));
|
|
481
|
-
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')));
|
|
481
|
+
this.states.states = JSON.parse(new TextDecoder().decode(await stateStore.get('states')), jsonParseBigInt);
|
|
482
482
|
try {
|
|
483
|
-
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')));
|
|
484
|
-
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')));
|
|
485
|
-
for (const key in info) {
|
|
486
|
-
|
|
487
|
-
}
|
|
483
|
+
this.states.accounts = JSON.parse(new TextDecoder().decode(await stateStore.get('accounts')), jsonParseBigInt);
|
|
484
|
+
const info = JSON.parse(new TextDecoder().decode(await stateStore.get('info')), jsonParseBigInt);
|
|
485
|
+
// for (const key in info) {
|
|
486
|
+
// info[key] = BigInt(info[key])
|
|
487
|
+
// }
|
|
488
488
|
this.states.info = info;
|
|
489
489
|
}
|
|
490
490
|
catch (error) {
|
|
@@ -1732,7 +1732,7 @@ class Chain extends VersionControl {
|
|
|
1732
1732
|
const result = await this.#executeTransaction({ ...transaction.decoded, hash });
|
|
1733
1733
|
if (block) {
|
|
1734
1734
|
block.transactions.push(hash);
|
|
1735
|
-
block.fees = block.fees
|
|
1735
|
+
block.fees = block.fees += await calculateFee(transaction.decoded);
|
|
1736
1736
|
}
|
|
1737
1737
|
await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
|
|
1738
1738
|
await transactionStore.put(hash, await transaction.encode());
|
|
@@ -1820,8 +1820,8 @@ class Chain extends VersionControl {
|
|
|
1820
1820
|
}
|
|
1821
1821
|
block.validators = block.validators.map((validator) => {
|
|
1822
1822
|
validator.reward = block.fees;
|
|
1823
|
-
validator.reward
|
|
1824
|
-
validator.reward
|
|
1823
|
+
validator.reward += block.reward;
|
|
1824
|
+
validator.reward /= block.validators.length;
|
|
1825
1825
|
delete validator.bw;
|
|
1826
1826
|
return validator;
|
|
1827
1827
|
});
|
package/exports/contract.d.ts
CHANGED
|
@@ -31,14 +31,14 @@ export default class Contract extends Transaction {
|
|
|
31
31
|
deployContract(signer: MultiWallet, contract: any, constructorParameters?: any[]): Promise<{
|
|
32
32
|
hash: any;
|
|
33
33
|
data: any;
|
|
34
|
-
fee: string |
|
|
34
|
+
fee: string | bigint | 0;
|
|
35
35
|
wait: Promise<unknown>;
|
|
36
36
|
message: any;
|
|
37
37
|
}>;
|
|
38
38
|
deployContractMessage(signer: any, message: any): Promise<{
|
|
39
39
|
hash: any;
|
|
40
40
|
data: any;
|
|
41
|
-
fee: string |
|
|
41
|
+
fee: string | bigint | 0;
|
|
42
42
|
wait: Promise<unknown>;
|
|
43
43
|
message: any;
|
|
44
44
|
}>;
|
package/exports/node.js
CHANGED
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 |
|
|
37
|
+
fee: string | bigint | 0;
|
|
38
38
|
wait: Promise<unknown>;
|
|
39
39
|
message: any;
|
|
40
40
|
}>;
|
|
@@ -378,6 +378,7 @@ const _ = {
|
|
|
378
378
|
latestTransactions.splice(-transactionCount, latestTransactions.length);
|
|
379
379
|
}
|
|
380
380
|
if (!block.loaded && !fromState) {
|
|
381
|
+
totalBlocks += 1n;
|
|
381
382
|
try {
|
|
382
383
|
const transactions = await Promise.all(block.transactions.map(async (transaction) => {
|
|
383
384
|
const message = new TransactionMessage(await resolveTransaction(transaction)).decode();
|
|
@@ -449,36 +450,9 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
449
450
|
case 'addLoadedBlock':
|
|
450
451
|
runTask(id, 'addLoadedBlock', input);
|
|
451
452
|
break;
|
|
452
|
-
case 'nativeCalls':
|
|
453
|
-
respond(id, nativeCalls);
|
|
454
|
-
break;
|
|
455
453
|
case 'contracts':
|
|
456
454
|
respond(id, contracts);
|
|
457
455
|
break;
|
|
458
|
-
case 'totalContracts':
|
|
459
|
-
respond(id, Object.keys(contracts).length);
|
|
460
|
-
break;
|
|
461
|
-
case 'nativeMints':
|
|
462
|
-
respond(id, nativeMints);
|
|
463
|
-
break;
|
|
464
|
-
case 'nativeBurns':
|
|
465
|
-
respond(id, nativeBurns);
|
|
466
|
-
break;
|
|
467
|
-
case 'nativeTransfers':
|
|
468
|
-
respond(id, nativeTransfers);
|
|
469
|
-
break;
|
|
470
|
-
case 'totalBurnAmount':
|
|
471
|
-
respond(id, totalBurnAmount);
|
|
472
|
-
break;
|
|
473
|
-
case 'totalMintAmount':
|
|
474
|
-
respond(id, totalMintAmount);
|
|
475
|
-
break;
|
|
476
|
-
case 'totalTransferAmount':
|
|
477
|
-
respond(id, totalTransferAmount);
|
|
478
|
-
break;
|
|
479
|
-
case 'totalBlocks':
|
|
480
|
-
respond(id, totalBlocks);
|
|
481
|
-
break;
|
|
482
456
|
case 'blocks':
|
|
483
457
|
respond(id, input ? blocks.slice(input.from, input.to) : blocks);
|
|
484
458
|
break;
|
|
@@ -494,15 +468,42 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
494
468
|
case 'latestTransactions':
|
|
495
469
|
respond(id, latestTransactions);
|
|
496
470
|
break;
|
|
497
|
-
case 'totalTransactions':
|
|
498
|
-
respond(id, totalTransactions);
|
|
499
|
-
break;
|
|
500
471
|
case 'has':
|
|
501
472
|
respond(id, has(input.address));
|
|
502
473
|
break;
|
|
503
474
|
case 'get':
|
|
504
475
|
respond(id, get(input));
|
|
505
476
|
break;
|
|
477
|
+
case 'totalContracts':
|
|
478
|
+
respond(id, Object.keys(contracts).length);
|
|
479
|
+
break;
|
|
480
|
+
case 'nativeCalls':
|
|
481
|
+
respond(id, nativeCalls.toString());
|
|
482
|
+
break;
|
|
483
|
+
case 'nativeMints':
|
|
484
|
+
respond(id, nativeMints.toString());
|
|
485
|
+
break;
|
|
486
|
+
case 'nativeBurns':
|
|
487
|
+
respond(id, nativeBurns.toString());
|
|
488
|
+
break;
|
|
489
|
+
case 'nativeTransfers':
|
|
490
|
+
respond(id, nativeTransfers.toString());
|
|
491
|
+
break;
|
|
492
|
+
case 'totalBurnAmount':
|
|
493
|
+
respond(id, totalBurnAmount.toString());
|
|
494
|
+
break;
|
|
495
|
+
case 'totalMintAmount':
|
|
496
|
+
respond(id, totalMintAmount.toString());
|
|
497
|
+
break;
|
|
498
|
+
case 'totalTransferAmount':
|
|
499
|
+
respond(id, totalTransferAmount.toString());
|
|
500
|
+
break;
|
|
501
|
+
case 'totalBlocks':
|
|
502
|
+
respond(id, totalBlocks.toString());
|
|
503
|
+
break;
|
|
504
|
+
case 'totalTransactions':
|
|
505
|
+
respond(id, totalTransactions.toString());
|
|
506
|
+
break;
|
|
506
507
|
default:
|
|
507
508
|
console.log(`machine-worker: unsupported taskType: ${type}`);
|
|
508
509
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.55",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -61,18 +61,18 @@
|
|
|
61
61
|
"tslib": "^2.7.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@leofcoin/addresses": "^1.0.
|
|
64
|
+
"@leofcoin/addresses": "^1.0.43",
|
|
65
65
|
"@leofcoin/contracts": "^0.1.13",
|
|
66
|
-
"@leofcoin/crypto": "^0.2.
|
|
67
|
-
"@leofcoin/errors": "^1.0.
|
|
68
|
-
"@leofcoin/lib": "^1.2.
|
|
69
|
-
"@leofcoin/messages": "^1.4.
|
|
66
|
+
"@leofcoin/crypto": "^0.2.27",
|
|
67
|
+
"@leofcoin/errors": "^1.0.22",
|
|
68
|
+
"@leofcoin/lib": "^1.2.66",
|
|
69
|
+
"@leofcoin/messages": "^1.4.36",
|
|
70
70
|
"@leofcoin/multi-wallet": "^3.1.8",
|
|
71
|
-
"@leofcoin/networks": "^1.1.
|
|
71
|
+
"@leofcoin/networks": "^1.1.21",
|
|
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.33",
|
|
75
|
+
"@leofcoin/workers": "^1.5.18",
|
|
76
76
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
77
77
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
78
78
|
"semver": "^7.6.3"
|