@leofcoin/chain 1.6.11 → 1.6.13
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-Ei0BXMlu-9eQR3AGp.js → browser-Ei0BXMlu-_DPyExz0.js} +2 -2
- package/exports/browser/chain.js +736 -683
- package/exports/browser/{client-A009z8av-DavUUkay.js → client-A009z8av-Dw6NYFQr.js} +4 -4
- package/exports/browser/{index-Bz6K16zr.js → index--C9N9ZXK.js} +42 -52
- package/exports/browser/{index-G74WLzL7-d1Vs_wqe.js → index-G74WLzL7-BZ6_sy39.js} +2 -2
- package/exports/browser/{index-YQrIDBUQ-CbL47K_x.js → index-YQrIDBUQ-CqYDmtzG.js} +2 -2
- package/exports/browser/{messages-lWRTai7t-Cs3eU5Cb.js → messages-lWRTai7t-3F-6Qszg.js} +2 -2
- package/exports/browser/{node-browser-CC3grAN3.js → node-browser-DRoVQRWp.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 +66 -28
- package/exports/browser/workers/{worker-CFrwP8cD.js → worker-Cqj1ERFr.js} +38 -48
- package/exports/chain.js +62 -26
- package/exports/machine.d.ts +11 -0
- package/exports/workers/block-worker.js +1 -1
- package/exports/workers/machine-worker.js +66 -28
- package/exports/workers/{worker-CFrwP8cD.js → worker-Cqj1ERFr.js} +38 -48
- package/package.json +13 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
import { L as LittlePubSub } from './node-browser-DRoVQRWp.js';
|
|
2
|
+
import './index--C9N9ZXK.js';
|
|
3
3
|
|
|
4
4
|
class Api {
|
|
5
5
|
_pubsub;
|
|
@@ -206,7 +206,7 @@ class SocketRequestClient {
|
|
|
206
206
|
const init = async () => {
|
|
207
207
|
// @ts-ignore
|
|
208
208
|
if (!globalThis.WebSocket)
|
|
209
|
-
globalThis.WebSocket = (await import('./browser-Ei0BXMlu-
|
|
209
|
+
globalThis.WebSocket = (await import('./browser-Ei0BXMlu-_DPyExz0.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
210
210
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
211
211
|
client.onmessage = this.onmessage;
|
|
212
212
|
client.onerror = this.onerror;
|
|
@@ -280,7 +280,7 @@ const iceServers = [
|
|
|
280
280
|
credential: 'openrelayproject'
|
|
281
281
|
}
|
|
282
282
|
];
|
|
283
|
-
const SimplePeer = (await import('./index-YQrIDBUQ-
|
|
283
|
+
const SimplePeer = (await import('./index-YQrIDBUQ-CqYDmtzG.js').then(function (n) { return n.i; })).default;
|
|
284
284
|
class Peer extends SimplePeer {
|
|
285
285
|
peerId;
|
|
286
286
|
channelName;
|
|
@@ -12458,37 +12458,6 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
|
12458
12458
|
const FormatInterface = FormatInterface$1;
|
|
12459
12459
|
|
|
12460
12460
|
var proto$6 = {
|
|
12461
|
-
timestamp: Number(),
|
|
12462
|
-
from: String(),
|
|
12463
|
-
to: String(),
|
|
12464
|
-
method: String(),
|
|
12465
|
-
params: Array(),
|
|
12466
|
-
signature: String(),
|
|
12467
|
-
'nonce?': Number(),
|
|
12468
|
-
'dependsOn?': Array(),
|
|
12469
|
-
'priority?': Boolean()
|
|
12470
|
-
};
|
|
12471
|
-
|
|
12472
|
-
class TransactionMessage extends FormatInterface {
|
|
12473
|
-
get messageName() {
|
|
12474
|
-
return 'TransactionMessage';
|
|
12475
|
-
}
|
|
12476
|
-
constructor(buffer) {
|
|
12477
|
-
if (buffer instanceof TransactionMessage)
|
|
12478
|
-
return buffer;
|
|
12479
|
-
const name = 'transaction-message';
|
|
12480
|
-
super(buffer, proto$6, { name });
|
|
12481
|
-
}
|
|
12482
|
-
beforeHashing(decoded) {
|
|
12483
|
-
decoded = super.beforeHashing(decoded);
|
|
12484
|
-
delete decoded.signature;
|
|
12485
|
-
delete decoded.priority;
|
|
12486
|
-
delete decoded.dependsOn;
|
|
12487
|
-
return decoded;
|
|
12488
|
-
}
|
|
12489
|
-
}
|
|
12490
|
-
|
|
12491
|
-
var proto$5 = {
|
|
12492
12461
|
address: String(),
|
|
12493
12462
|
reward: BigNumber.from(0)
|
|
12494
12463
|
};
|
|
@@ -12501,17 +12470,17 @@ class ValidatorMessage extends FormatInterface {
|
|
|
12501
12470
|
if (buffer instanceof ValidatorMessage)
|
|
12502
12471
|
return buffer;
|
|
12503
12472
|
const name = 'validator-message';
|
|
12504
|
-
super(buffer, proto$
|
|
12473
|
+
super(buffer, proto$6, { name });
|
|
12505
12474
|
}
|
|
12506
12475
|
}
|
|
12507
12476
|
|
|
12508
|
-
var proto$
|
|
12477
|
+
var proto$5 = {
|
|
12509
12478
|
index: Number(),
|
|
12510
12479
|
previousHash: String(),
|
|
12511
12480
|
timestamp: Number(),
|
|
12512
12481
|
reward: BigNumber.from(0),
|
|
12513
12482
|
fees: BigNumber.from(0),
|
|
12514
|
-
transactions:
|
|
12483
|
+
transactions: Array(),
|
|
12515
12484
|
validators: new Uint8Array()
|
|
12516
12485
|
};
|
|
12517
12486
|
|
|
@@ -12523,42 +12492,32 @@ class BlockMessage extends FormatInterface {
|
|
|
12523
12492
|
if (buffer instanceof BlockMessage)
|
|
12524
12493
|
return buffer;
|
|
12525
12494
|
const name = 'block-message';
|
|
12526
|
-
super(buffer, proto$
|
|
12495
|
+
super(buffer, proto$5, { name });
|
|
12527
12496
|
}
|
|
12528
12497
|
encode(decoded) {
|
|
12529
12498
|
decoded = decoded || this.decoded;
|
|
12530
12499
|
const validators = [];
|
|
12531
|
-
const transactions = [];
|
|
12532
12500
|
for (const validator of decoded.validators) {
|
|
12533
12501
|
if (validator instanceof ValidatorMessage)
|
|
12534
12502
|
validators.push(validator.encode());
|
|
12535
12503
|
else
|
|
12536
12504
|
validators.push(new ValidatorMessage(validator).encode());
|
|
12537
12505
|
}
|
|
12538
|
-
for (const transaction of decoded.transactions) {
|
|
12539
|
-
if (transaction instanceof TransactionMessage)
|
|
12540
|
-
transactions.push(transaction.encode());
|
|
12541
|
-
else
|
|
12542
|
-
transactions.push(new TransactionMessage(transaction).encode());
|
|
12543
|
-
}
|
|
12544
12506
|
return super.encode({
|
|
12545
12507
|
...decoded,
|
|
12546
|
-
validators: index$5(validators)
|
|
12547
|
-
transactions: index$5(transactions)
|
|
12508
|
+
validators: index$5(validators)
|
|
12548
12509
|
});
|
|
12549
12510
|
}
|
|
12550
12511
|
decode(encoded) {
|
|
12551
12512
|
encoded = encoded || this.encoded;
|
|
12552
12513
|
super.decode(encoded);
|
|
12553
12514
|
// @ts-ignore
|
|
12554
|
-
this.decoded.transactions = index$4(this.decoded.transactions).map((transaction) => new TransactionMessage(transaction).decoded);
|
|
12555
|
-
// @ts-ignore
|
|
12556
12515
|
this.decoded.validators = index$4(this.decoded.validators).map((validator) => new ValidatorMessage(validator).decoded);
|
|
12557
12516
|
return this.decoded;
|
|
12558
12517
|
}
|
|
12559
12518
|
}
|
|
12560
12519
|
|
|
12561
|
-
var proto$
|
|
12520
|
+
var proto$4 = {
|
|
12562
12521
|
up: Number(),
|
|
12563
12522
|
down: Number()
|
|
12564
12523
|
};
|
|
@@ -12571,11 +12530,11 @@ class BWMessage extends FormatInterface {
|
|
|
12571
12530
|
if (buffer instanceof BWMessage)
|
|
12572
12531
|
return buffer;
|
|
12573
12532
|
const name = 'bw-message';
|
|
12574
|
-
super(buffer, proto$
|
|
12533
|
+
super(buffer, proto$4, { name });
|
|
12575
12534
|
}
|
|
12576
12535
|
}
|
|
12577
12536
|
|
|
12578
|
-
var proto$
|
|
12537
|
+
var proto$3 = {};
|
|
12579
12538
|
|
|
12580
12539
|
class BWRequestMessage extends FormatInterface {
|
|
12581
12540
|
get messageName() {
|
|
@@ -12585,11 +12544,11 @@ class BWRequestMessage extends FormatInterface {
|
|
|
12585
12544
|
if (buffer instanceof BWRequestMessage)
|
|
12586
12545
|
return buffer;
|
|
12587
12546
|
const name = 'bw-request-message';
|
|
12588
|
-
super(buffer, proto$
|
|
12547
|
+
super(buffer, proto$3, { name });
|
|
12589
12548
|
}
|
|
12590
12549
|
}
|
|
12591
12550
|
|
|
12592
|
-
var proto$
|
|
12551
|
+
var proto$2 = {
|
|
12593
12552
|
creator: String(),
|
|
12594
12553
|
contract: new Uint8Array(),
|
|
12595
12554
|
constructorParameters: Array()
|
|
@@ -12602,7 +12561,38 @@ class ContractMessage extends FormatInterface {
|
|
|
12602
12561
|
constructor(buffer) {
|
|
12603
12562
|
if (buffer instanceof ContractMessage)
|
|
12604
12563
|
return buffer;
|
|
12605
|
-
super(buffer, proto$
|
|
12564
|
+
super(buffer, proto$2, { name: 'contract-message' });
|
|
12565
|
+
}
|
|
12566
|
+
}
|
|
12567
|
+
|
|
12568
|
+
var proto$1 = {
|
|
12569
|
+
timestamp: Number(),
|
|
12570
|
+
from: String(),
|
|
12571
|
+
to: String(),
|
|
12572
|
+
method: String(),
|
|
12573
|
+
params: Array(),
|
|
12574
|
+
signature: String(),
|
|
12575
|
+
'nonce?': Number(),
|
|
12576
|
+
'dependsOn?': Array(),
|
|
12577
|
+
'priority?': Boolean()
|
|
12578
|
+
};
|
|
12579
|
+
|
|
12580
|
+
class TransactionMessage extends FormatInterface {
|
|
12581
|
+
get messageName() {
|
|
12582
|
+
return 'TransactionMessage';
|
|
12583
|
+
}
|
|
12584
|
+
constructor(buffer) {
|
|
12585
|
+
if (buffer instanceof TransactionMessage)
|
|
12586
|
+
return buffer;
|
|
12587
|
+
const name = 'transaction-message';
|
|
12588
|
+
super(buffer, proto$1, { name });
|
|
12589
|
+
}
|
|
12590
|
+
beforeHashing(decoded) {
|
|
12591
|
+
decoded = super.beforeHashing(decoded);
|
|
12592
|
+
delete decoded.signature;
|
|
12593
|
+
delete decoded.priority;
|
|
12594
|
+
delete decoded.dependsOn;
|
|
12595
|
+
return decoded;
|
|
12606
12596
|
}
|
|
12607
12597
|
}
|
|
12608
12598
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-DRoVQRWp.js';
|
|
2
|
+
import './index--C9N9ZXK.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @params {String} network
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-
|
|
2
|
-
import './index
|
|
1
|
+
import { i as inherits_browserExports, c as commonjsGlobal, g as getDefaultExportFromCjs, r as require$$3 } from './node-browser-DRoVQRWp.js';
|
|
2
|
+
import './index--C9N9ZXK.js';
|
|
3
3
|
|
|
4
4
|
var browser$2 = {exports: {}};
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FormatInterface$3, C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index
|
|
1
|
+
import { F as FormatInterface$3, C as ContractMessage, T as TransactionMessage, c as BlockMessage, d as BWMessage, e as BWRequestMessage, V as ValidatorMessage } from './index--C9N9ZXK.js';
|
|
2
2
|
|
|
3
3
|
var proto = {
|
|
4
4
|
lastblock: Object(),
|
|
@@ -27217,7 +27217,7 @@ class Identity {
|
|
|
27217
27217
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
27218
27218
|
}
|
|
27219
27219
|
else {
|
|
27220
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-G74WLzL7-
|
|
27220
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-G74WLzL7-BZ6_sy39.js');
|
|
27221
27221
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
27222
27222
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
27223
27223
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -27409,7 +27409,7 @@ class Peernet {
|
|
|
27409
27409
|
this.root = options.root;
|
|
27410
27410
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
27411
27411
|
// FolderMessageResponse
|
|
27412
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-lWRTai7t-
|
|
27412
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-lWRTai7t-3F-6Qszg.js');
|
|
27413
27413
|
/**
|
|
27414
27414
|
* proto Object containing protos
|
|
27415
27415
|
* @type {Object}
|
|
@@ -27503,7 +27503,7 @@ class Peernet {
|
|
|
27503
27503
|
if (this.#starting || this.#started)
|
|
27504
27504
|
return;
|
|
27505
27505
|
this.#starting = true;
|
|
27506
|
-
const importee = await import('./client-A009z8av-
|
|
27506
|
+
const importee = await import('./client-A009z8av-Dw6NYFQr.js');
|
|
27507
27507
|
/**
|
|
27508
27508
|
* @access public
|
|
27509
27509
|
* @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-DRoVQRWp.js';
|
|
2
|
+
import './index--C9N9ZXK.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, C as ContractMessage, T as TransactionMessage } from './worker-Cqj1ERFr.js';
|
|
2
2
|
|
|
3
3
|
const byteFormats = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
4
4
|
const formatBytes = (bytes, decimals = 2) => {
|
|
@@ -117,6 +117,10 @@ let nativeMints = 0;
|
|
|
117
117
|
let nativeTransfers = 0;
|
|
118
118
|
let totalTransactions = 0;
|
|
119
119
|
|
|
120
|
+
let totalBurnAmount = 0;
|
|
121
|
+
let totalMintAmount = 0;
|
|
122
|
+
let totalTransferAmount = 0;
|
|
123
|
+
|
|
120
124
|
let blocks = [];
|
|
121
125
|
let contracts = {};
|
|
122
126
|
const _ = {};
|
|
@@ -146,7 +150,9 @@ const get = ({ contract, method, params }) => {
|
|
|
146
150
|
return result
|
|
147
151
|
};
|
|
148
152
|
|
|
149
|
-
const resolveContract = (
|
|
153
|
+
const resolveContract = (hash) => askFor('contract', hash);
|
|
154
|
+
|
|
155
|
+
const resolveTransaction = (hash) => askFor('transaction', hash);
|
|
150
156
|
|
|
151
157
|
const respond = (id, value) => {
|
|
152
158
|
worker.postMessage({
|
|
@@ -223,9 +229,18 @@ const _executeTransaction = async (transaction) => {
|
|
|
223
229
|
await _.execute({ contract: to, method, params });
|
|
224
230
|
if (to === nativeToken$2) {
|
|
225
231
|
nativeCalls += 1;
|
|
226
|
-
if (method === 'burn')
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
if (method === 'burn') {
|
|
233
|
+
nativeBurns += 1;
|
|
234
|
+
totalBurnAmount += params[0];
|
|
235
|
+
}
|
|
236
|
+
if (method === 'mint') {
|
|
237
|
+
nativeMints += 1;
|
|
238
|
+
totalMintAmount += params[0];
|
|
239
|
+
}
|
|
240
|
+
if (method === 'transfer') {
|
|
241
|
+
nativeTransfers += 1;
|
|
242
|
+
totalTransferAmount += params[0];
|
|
243
|
+
}
|
|
229
244
|
}
|
|
230
245
|
totalTransactions += 1;
|
|
231
246
|
|
|
@@ -241,10 +256,19 @@ const _executeTransaction = async (transaction) => {
|
|
|
241
256
|
};
|
|
242
257
|
|
|
243
258
|
_.init = async (message) => {
|
|
244
|
-
let { peerid, fromState, state } = message;
|
|
259
|
+
let { peerid, fromState, state, info } = message;
|
|
245
260
|
globalThis.peerid = peerid;
|
|
246
261
|
console.log({ fromState });
|
|
247
262
|
if (fromState) {
|
|
263
|
+
nativeCalls = info.nativeCalls;
|
|
264
|
+
nativeBurns = info.nativeBurns;
|
|
265
|
+
nativeMints = info.nativeMints;
|
|
266
|
+
nativeTransfers = info.nativeTransfers;
|
|
267
|
+
totalTransactions = info.totalTransactions;
|
|
268
|
+
totalBurnAmount = info.totalBurnAmount;
|
|
269
|
+
totalMintAmount = info.totalMintAmount;
|
|
270
|
+
totalTransferAmount = info.totalTransferAmount;
|
|
271
|
+
|
|
248
272
|
lastBlock = message.lastBlock;
|
|
249
273
|
const setState = async (address, state) => {
|
|
250
274
|
const contractBytes = await resolveContract(address);
|
|
@@ -284,23 +308,23 @@ _.init = async (message) => {
|
|
|
284
308
|
);
|
|
285
309
|
console.log({ blocks: message.blocks });
|
|
286
310
|
if (message.blocks?.length > 0) {
|
|
287
|
-
let pre
|
|
288
|
-
|
|
289
|
-
try {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
} catch {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
311
|
+
// let pre
|
|
312
|
+
|
|
313
|
+
// try {
|
|
314
|
+
// const importee = await import('url')
|
|
315
|
+
// const url = importee.default
|
|
316
|
+
// if (url) pre = url.fileURLToPath(new URL('.', import.meta.url))
|
|
317
|
+
// } catch {
|
|
318
|
+
// // browser env
|
|
319
|
+
// pre = './'
|
|
320
|
+
// }
|
|
297
321
|
|
|
298
|
-
let _worker = await new EasyWorker(pre + './block-worker.js', {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
})
|
|
302
|
-
blocks = await _worker.once(message.blocks)
|
|
303
|
-
_worker = null
|
|
322
|
+
// let _worker = await new EasyWorker(pre + './block-worker.js', {
|
|
323
|
+
// serialization: 'advanced',
|
|
324
|
+
// type: 'module'
|
|
325
|
+
// })
|
|
326
|
+
// blocks = await _worker.once(message.blocks)
|
|
327
|
+
// _worker = null
|
|
304
328
|
// blocks = unique(globalThis.blocks ? globalThis : [], blocks)
|
|
305
329
|
// for (let i = 0; i < blocks.length; i++) {
|
|
306
330
|
|
|
@@ -311,20 +335,25 @@ _.init = async (message) => {
|
|
|
311
335
|
// this means contracts will be restored from this state
|
|
312
336
|
// this also means devs NEED to make sure the state can be restored
|
|
313
337
|
// on contract deploy an error will be thrown if state wasn't recoverable
|
|
314
|
-
if (block.index
|
|
338
|
+
if (block.index >= blocks.length - 24) {
|
|
315
339
|
const transactionCount = blocks[block.index - 1].transactions.length;
|
|
316
340
|
latestTransactions.splice(-(transactionCount - 1), latestTransactions.length);
|
|
317
341
|
}
|
|
318
342
|
|
|
319
343
|
if (!block.loaded && !fromState) {
|
|
320
|
-
const
|
|
344
|
+
const transactions = await Promise.all(
|
|
345
|
+
block.transactions.map(async (transaction) =>
|
|
346
|
+
new TransactionMessage(await resolveTransaction(transaction)).decode()
|
|
347
|
+
)
|
|
348
|
+
);
|
|
349
|
+
const priority = transactions.filter((transaction) => transaction.priority)?.sort((a, b) => a.nonce - b.nonce);
|
|
321
350
|
if (priority.length > 0)
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
351
|
+
for (const transaction of priority) {
|
|
352
|
+
await _executeTransaction(transaction);
|
|
353
|
+
}
|
|
325
354
|
|
|
326
355
|
await Promise.all(
|
|
327
|
-
|
|
356
|
+
transactions
|
|
328
357
|
.filter((transaction) => !transaction.priority)
|
|
329
358
|
.map(async (transaction) => _executeTransaction(transaction))
|
|
330
359
|
);
|
|
@@ -418,6 +447,15 @@ worker.onmessage(({ id, type, input }) => {
|
|
|
418
447
|
case 'nativeTransfers':
|
|
419
448
|
respond(id, nativeTransfers);
|
|
420
449
|
break
|
|
450
|
+
case 'totalBurnAmount':
|
|
451
|
+
respond(id, totalBurnAmount);
|
|
452
|
+
break
|
|
453
|
+
case 'totalMintAmount':
|
|
454
|
+
respond(id, totalMintAmount);
|
|
455
|
+
break
|
|
456
|
+
case 'totalTransferAmount':
|
|
457
|
+
respond(id, totalTransferAmount);
|
|
458
|
+
break
|
|
421
459
|
case 'totalTransfers':
|
|
422
460
|
respond(id, totalTransfers);
|
|
423
461
|
break
|
|
@@ -12379,37 +12379,6 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
|
|
|
12379
12379
|
const FormatInterface = FormatInterface$1;
|
|
12380
12380
|
|
|
12381
12381
|
var proto$3 = {
|
|
12382
|
-
timestamp: Number(),
|
|
12383
|
-
from: String(),
|
|
12384
|
-
to: String(),
|
|
12385
|
-
method: String(),
|
|
12386
|
-
params: Array(),
|
|
12387
|
-
signature: String(),
|
|
12388
|
-
'nonce?': Number(),
|
|
12389
|
-
'dependsOn?': Array(),
|
|
12390
|
-
'priority?': Boolean()
|
|
12391
|
-
};
|
|
12392
|
-
|
|
12393
|
-
class TransactionMessage extends FormatInterface {
|
|
12394
|
-
get messageName() {
|
|
12395
|
-
return 'TransactionMessage';
|
|
12396
|
-
}
|
|
12397
|
-
constructor(buffer) {
|
|
12398
|
-
if (buffer instanceof TransactionMessage)
|
|
12399
|
-
return buffer;
|
|
12400
|
-
const name = 'transaction-message';
|
|
12401
|
-
super(buffer, proto$3, { name });
|
|
12402
|
-
}
|
|
12403
|
-
beforeHashing(decoded) {
|
|
12404
|
-
decoded = super.beforeHashing(decoded);
|
|
12405
|
-
delete decoded.signature;
|
|
12406
|
-
delete decoded.priority;
|
|
12407
|
-
delete decoded.dependsOn;
|
|
12408
|
-
return decoded;
|
|
12409
|
-
}
|
|
12410
|
-
}
|
|
12411
|
-
|
|
12412
|
-
var proto$2 = {
|
|
12413
12382
|
address: String(),
|
|
12414
12383
|
reward: BigNumber.from(0)
|
|
12415
12384
|
};
|
|
@@ -12422,17 +12391,17 @@ class ValidatorMessage extends FormatInterface {
|
|
|
12422
12391
|
if (buffer instanceof ValidatorMessage)
|
|
12423
12392
|
return buffer;
|
|
12424
12393
|
const name = 'validator-message';
|
|
12425
|
-
super(buffer, proto$
|
|
12394
|
+
super(buffer, proto$3, { name });
|
|
12426
12395
|
}
|
|
12427
12396
|
}
|
|
12428
12397
|
|
|
12429
|
-
var proto$
|
|
12398
|
+
var proto$2 = {
|
|
12430
12399
|
index: Number(),
|
|
12431
12400
|
previousHash: String(),
|
|
12432
12401
|
timestamp: Number(),
|
|
12433
12402
|
reward: BigNumber.from(0),
|
|
12434
12403
|
fees: BigNumber.from(0),
|
|
12435
|
-
transactions:
|
|
12404
|
+
transactions: Array(),
|
|
12436
12405
|
validators: new Uint8Array()
|
|
12437
12406
|
};
|
|
12438
12407
|
|
|
@@ -12444,42 +12413,32 @@ class BlockMessage extends FormatInterface {
|
|
|
12444
12413
|
if (buffer instanceof BlockMessage)
|
|
12445
12414
|
return buffer;
|
|
12446
12415
|
const name = 'block-message';
|
|
12447
|
-
super(buffer, proto$
|
|
12416
|
+
super(buffer, proto$2, { name });
|
|
12448
12417
|
}
|
|
12449
12418
|
encode(decoded) {
|
|
12450
12419
|
decoded = decoded || this.decoded;
|
|
12451
12420
|
const validators = [];
|
|
12452
|
-
const transactions = [];
|
|
12453
12421
|
for (const validator of decoded.validators) {
|
|
12454
12422
|
if (validator instanceof ValidatorMessage)
|
|
12455
12423
|
validators.push(validator.encode());
|
|
12456
12424
|
else
|
|
12457
12425
|
validators.push(new ValidatorMessage(validator).encode());
|
|
12458
12426
|
}
|
|
12459
|
-
for (const transaction of decoded.transactions) {
|
|
12460
|
-
if (transaction instanceof TransactionMessage)
|
|
12461
|
-
transactions.push(transaction.encode());
|
|
12462
|
-
else
|
|
12463
|
-
transactions.push(new TransactionMessage(transaction).encode());
|
|
12464
|
-
}
|
|
12465
12427
|
return super.encode({
|
|
12466
12428
|
...decoded,
|
|
12467
|
-
validators: index$5(validators)
|
|
12468
|
-
transactions: index$5(transactions)
|
|
12429
|
+
validators: index$5(validators)
|
|
12469
12430
|
});
|
|
12470
12431
|
}
|
|
12471
12432
|
decode(encoded) {
|
|
12472
12433
|
encoded = encoded || this.encoded;
|
|
12473
12434
|
super.decode(encoded);
|
|
12474
12435
|
// @ts-ignore
|
|
12475
|
-
this.decoded.transactions = index$4(this.decoded.transactions).map((transaction) => new TransactionMessage(transaction).decoded);
|
|
12476
|
-
// @ts-ignore
|
|
12477
12436
|
this.decoded.validators = index$4(this.decoded.validators).map((validator) => new ValidatorMessage(validator).decoded);
|
|
12478
12437
|
return this.decoded;
|
|
12479
12438
|
}
|
|
12480
12439
|
}
|
|
12481
12440
|
|
|
12482
|
-
var proto = {
|
|
12441
|
+
var proto$1 = {
|
|
12483
12442
|
creator: String(),
|
|
12484
12443
|
contract: new Uint8Array(),
|
|
12485
12444
|
constructorParameters: Array()
|
|
@@ -12492,7 +12451,38 @@ class ContractMessage extends FormatInterface {
|
|
|
12492
12451
|
constructor(buffer) {
|
|
12493
12452
|
if (buffer instanceof ContractMessage)
|
|
12494
12453
|
return buffer;
|
|
12495
|
-
super(buffer, proto, { name: 'contract-message' });
|
|
12454
|
+
super(buffer, proto$1, { name: 'contract-message' });
|
|
12455
|
+
}
|
|
12456
|
+
}
|
|
12457
|
+
|
|
12458
|
+
var proto = {
|
|
12459
|
+
timestamp: Number(),
|
|
12460
|
+
from: String(),
|
|
12461
|
+
to: String(),
|
|
12462
|
+
method: String(),
|
|
12463
|
+
params: Array(),
|
|
12464
|
+
signature: String(),
|
|
12465
|
+
'nonce?': Number(),
|
|
12466
|
+
'dependsOn?': Array(),
|
|
12467
|
+
'priority?': Boolean()
|
|
12468
|
+
};
|
|
12469
|
+
|
|
12470
|
+
class TransactionMessage extends FormatInterface {
|
|
12471
|
+
get messageName() {
|
|
12472
|
+
return 'TransactionMessage';
|
|
12473
|
+
}
|
|
12474
|
+
constructor(buffer) {
|
|
12475
|
+
if (buffer instanceof TransactionMessage)
|
|
12476
|
+
return buffer;
|
|
12477
|
+
const name = 'transaction-message';
|
|
12478
|
+
super(buffer, proto, { name });
|
|
12479
|
+
}
|
|
12480
|
+
beforeHashing(decoded) {
|
|
12481
|
+
decoded = super.beforeHashing(decoded);
|
|
12482
|
+
delete decoded.signature;
|
|
12483
|
+
delete decoded.priority;
|
|
12484
|
+
delete decoded.dependsOn;
|
|
12485
|
+
return decoded;
|
|
12496
12486
|
}
|
|
12497
12487
|
}
|
|
12498
12488
|
|