@leofcoin/chain 1.4.79 → 1.4.81

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.
@@ -1,64 +1,73 @@
1
- // import base32 from '@vandeurenglenn/base32'
2
- // import base58 from '@vandeurenglenn/base58'
3
-
4
- // export const encodings = {
5
- // base58,
6
- // base32
7
- // }
8
-
9
- const encode$1 = (string, encoding = 'utf-8') => {
10
- if (typeof string === 'string') {
11
- let encoded;
12
-
13
- // if (encodings[encoding]) encoded = encodings[encoding].encode(encoded)
14
- encoded = new TextEncoder().encode(string);
15
- return encoded
16
- }
17
- throw Error(`expected typeof String instead got ${string}`)
1
+ const encode = (string) => {
2
+ if (typeof string === 'string')
3
+ return new TextEncoder().encode(string);
4
+ throw Error(`expected typeof String instead got ${string}`);
18
5
  };
19
-
20
- const decode$1 = (uint8Array, encoding) => {
21
- if (uint8Array instanceof Uint8Array) {
22
- let decoded;
23
- // if (encodings[encoding]) decoded = encodings[encoding].decode(decoded)
24
- decoded = new TextDecoder().decode(uint8Array);
25
-
26
- return decoded
27
- }
28
- throw Error(`expected typeof uint8Array instead got ${uint8Array}`)
6
+ const decode = (uint8Array) => {
7
+ if (uint8Array instanceof Uint8Array)
8
+ return new TextDecoder().decode(uint8Array);
9
+ throw Error(`expected typeof uint8Array instead got ${uint8Array}`);
29
10
  };
30
11
 
31
- class KeyValue {
32
-
33
- /**
34
- * @param {string | Uint8Array} input
35
- */
36
- constructor(input) {
37
- if (typeof input === 'string') {
38
- this.uint8Array = encode$1(input);
39
- } else if (input instanceof Uint8Array) {
40
- this.uint8Array = input;
41
- } else if (input instanceof KeyValue) {
42
- this.uint8Array = input.uint8Array;
43
- } else {
44
- throw new Error('Invalid KeyValue, should be a String, Uint8Array or KeyValue')
12
+ const pathSepS = '/';
13
+ class KeyPath {
14
+ uint8Array;
15
+ constructor(input) {
16
+ if (typeof input === 'string') {
17
+ this.uint8Array = encode(input);
18
+ }
19
+ else if (input instanceof Uint8Array) {
20
+ this.uint8Array = input;
21
+ }
22
+ else if (input instanceof KeyPath) {
23
+ this.uint8Array = input.uint8Array;
24
+ }
25
+ else {
26
+ throw new Error('Invalid keyPath, should be a String, Uint8Array or KeyPath');
27
+ }
45
28
  }
46
- }
47
-
48
- isKeyValue() {
49
- return true
50
- }
51
-
52
- /**
53
- * Convert to the string representation
54
- *
55
- * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.
56
- * @returns {string}
57
- */
58
- toString(encoding = 'utf8') {
59
- return decode$1(this.uint8Array)
60
- }
29
+ isKeyPath() {
30
+ return true;
31
+ }
32
+ toString() {
33
+ return decode(this.uint8Array);
34
+ }
35
+ /**
36
+ * Returns the `list` representation of this path.
37
+ *
38
+ * @example
39
+ * ```js
40
+ * new Key('/Comedy/MontyPython/Actor:JohnCleese').list()
41
+ * // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']
42
+ * ```
43
+ */
44
+ list() {
45
+ return this.toString().split(pathSepS).slice(1);
46
+ }
47
+ }
61
48
 
49
+ class KeyValue {
50
+ uint8Array;
51
+ constructor(input) {
52
+ if (typeof input === 'string') {
53
+ this.uint8Array = encode(input);
54
+ }
55
+ else if (input instanceof Uint8Array) {
56
+ this.uint8Array = input;
57
+ }
58
+ else if (input instanceof KeyValue) {
59
+ this.uint8Array = input.uint8Array;
60
+ }
61
+ else {
62
+ throw new Error('Invalid KeyValue, should be a String, Uint8Array or KeyValue');
63
+ }
64
+ }
65
+ isKeyValue() {
66
+ return true;
67
+ }
68
+ toString() {
69
+ return decode(this.uint8Array);
70
+ }
62
71
  }
63
72
 
64
73
  const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);
@@ -376,149 +385,66 @@ replaceTraps((oldTraps) => ({
376
385
  },
377
386
  }));
378
387
 
379
- // import base32 from '@vandeurenglenn/base32'
380
- // import base58 from '@vandeurenglenn/base58'
381
-
382
- // export const encodings = {
383
- // base58,
384
- // base32
385
- // }
386
-
387
- const encode = (string, encoding = 'utf-8') => {
388
- if (typeof string === 'string') {
389
- let encoded;
390
-
391
- // if (encodings[encoding]) encoded = encodings[encoding].encode(encoded)
392
- encoded = new TextEncoder().encode(string);
393
- return encoded
394
- }
395
- throw Error(`expected typeof String instead got ${string}`)
396
- };
397
-
398
- const decode = (uint8Array, encoding) => {
399
- if (uint8Array instanceof Uint8Array) {
400
- let decoded;
401
- // if (encodings[encoding]) decoded = encodings[encoding].decode(decoded)
402
- decoded = new TextDecoder().decode(uint8Array);
403
-
404
- return decoded
405
- }
406
- throw Error(`expected typeof uint8Array instead got ${uint8Array}`)
407
- };
408
-
409
- const pathSepS = '/';
410
- class KeyPath {
411
-
412
- /**
413
- * @param {string | Uint8Array} input
414
- */
415
- constructor(input) {
416
- if (typeof input === 'string') {
417
- this.uint8Array = encode(input);
418
- } else if (input instanceof Uint8Array) {
419
- this.uint8Array = input;
420
- } else if (input instanceof KeyPath) {
421
- this.uint8Array = input.uint8Array;
422
- } else {
423
- throw new Error('Invalid keyPath, should be a String, Uint8Array or KeyPath')
424
- }
425
- }
426
-
427
- isKeyPath() {
428
- return true
429
- }
430
-
431
- /**
432
- * Convert to the string representation
433
- *
434
- * @param {import('uint8arrays/to-string').SupportedEncodings} [encoding='utf8'] - The encoding to use.
435
- * @returns {string}
436
- */
437
- toString(encoding = 'hex') {
438
- return decode(this.uint8Array)
439
- }
440
-
441
- /**
442
- * Returns the `list` representation of this path.
443
- *
444
- * @returns string[]
445
- *
446
- * @example
447
- * ```js
448
- * new Key('/Comedy/MontyPython/Actor:JohnCleese').list()
449
- * // => ['Comedy', 'MontyPythong', 'Actor:JohnCleese']
450
- * ```
451
- */
452
- list() {
453
- return this.toString().split(pathSepS).slice(1)
454
- }
455
-
456
- }
457
-
458
388
  class BrowerStore {
459
- constructor(name = 'storage', root = '.leofcoin', version = 1) {
460
- this.version = version;
461
- this.name = name;
462
- this.root = root;
463
- this.db = openDB(`${root}/${name}`, version, {
464
- upgrade(db) {
465
- db.createObjectStore(name);
466
- }
467
- });
468
- }
469
-
470
- toKeyPath(key) {
471
- if (!key.isKeyPath()) key = new KeyPath(key);
472
- return key.toString('base32')
473
- }
474
-
475
- toKeyValue(value) {
476
- if (!value.isKeyValue()) value = new KeyValue(value);
477
- return value.uint8Array
478
- }
479
-
480
- async get(key) {
481
- return (await this.db).get(this.name, this.toKeyPath(key))
482
- }
483
-
484
- async put(key, value) {
485
- return (await this.db).put(this.name, this.toKeyValue(value), this.toKeyPath(key))
486
- }
487
-
488
- async delete(key) {
489
- return (await this.db).delete(this.name, this.toKeyPath(key))
490
- }
491
-
492
- async clear() {
493
- return (await this.db).clear(this.name)
494
- }
495
-
496
- async values(limit = -1) {
497
- const values = [];
498
- const tx = (await this.db).transaction(this.name);
499
-
500
- for await (const cursor of tx.store) {
501
- values.push(cursor.value);
502
- if (limit && values.length === limit) return values
389
+ db;
390
+ name;
391
+ root;
392
+ version;
393
+ constructor(name = 'storage', root = '.leofcoin', version = '1') {
394
+ this.version = version;
395
+ this.name = name;
396
+ this.root = root;
397
+ this.db = openDB(`${root}/${name}`, Number(version), {
398
+ upgrade(db) {
399
+ db.createObjectStore(name);
400
+ }
401
+ });
503
402
  }
504
- return values
505
- }
506
-
507
- async keys(limit = -1) {
508
- const keys = [];
509
- const tx = (await this.db).transaction(this.name);
510
-
511
- for await (const cursor of tx.store) {
512
- keys.push(cursor.key);
513
- if (limit && keys.length === limit) return keys
403
+ toKeyPath(key) {
404
+ if (!key.isKeyPath())
405
+ key = new KeyPath(key);
406
+ return key.toString('base32');
407
+ }
408
+ toKeyValue(value) {
409
+ if (!value.isKeyValue())
410
+ value = new KeyValue(value);
411
+ return value.uint8Array;
412
+ }
413
+ async get(key) {
414
+ return (await this.db).get(this.name, this.toKeyPath(key));
415
+ }
416
+ async put(key, value) {
417
+ return (await this.db).put(this.name, this.toKeyValue(value), this.toKeyPath(key));
418
+ }
419
+ async delete(key) {
420
+ return (await this.db).delete(this.name, this.toKeyPath(key));
421
+ }
422
+ async clear() {
423
+ return (await this.db).clear(this.name);
424
+ }
425
+ async values(limit = -1) {
426
+ const values = [];
427
+ const tx = (await this.db).transaction(this.name);
428
+ for await (const cursor of tx.store) {
429
+ values.push(cursor.value);
430
+ if (limit && values.length === limit)
431
+ return values;
432
+ }
433
+ return values;
434
+ }
435
+ async keys(limit = -1) {
436
+ const keys = [];
437
+ const tx = (await this.db).transaction(this.name);
438
+ for await (const cursor of tx.store) {
439
+ keys.push(cursor.key);
440
+ if (limit && keys.length === limit)
441
+ return keys;
442
+ }
443
+ return keys;
444
+ }
445
+ async iterate() {
446
+ return (await this.db).transaction(this.name).store;
514
447
  }
515
- return keys
516
- }
517
-
518
- async iterate() {
519
- return (await this.db).transaction(this.name).store
520
- }
521
-
522
448
  }
523
449
 
524
450
  export { BrowerStore as default };
@@ -1302,11 +1302,11 @@ _PQueue_carryoverConcurrencyCount = new WeakMap(), _PQueue_isIntervalIgnored = n
1302
1302
 
1303
1303
  const limit = 1800;
1304
1304
  const transactionLimit = 1800;
1305
- const requestTimeout = 30_000;
1306
- const syncTimeout = 30_000;
1305
+ const requestTimeout = 30000;
1306
+ const syncTimeout = 30000;
1307
1307
  class Protocol {
1308
1308
  version;
1309
- resolveTimeout = 30_000;
1309
+ resolveTimeout = 30000;
1310
1310
  get limit() {
1311
1311
  return limit;
1312
1312
  }
@@ -1377,7 +1377,7 @@ class Transaction extends Protocol {
1377
1377
  transactions = transactions.filter(tx => tx.decoded.from === address);
1378
1378
  transactions = await this.promiseTransactionsContent(transactions);
1379
1379
  if (this.lastBlock?.hash && transactions.length === 0 && this.lastBlock.hash !== '0x0') {
1380
- let block = await peernet.get(this.lastBlock.hash);
1380
+ let block = await peernet.get(this.lastBlock.hash, 'block');
1381
1381
  block = await new BlockMessage(block);
1382
1382
  // for (let tx of block.decoded?.transactions) {
1383
1383
  // tx = await peernet.get(tx, 'transaction')
@@ -1457,22 +1457,28 @@ class Transaction extends Protocol {
1457
1457
  throw new Error(`transaction not signed`);
1458
1458
  if (message.decoded.nonce === undefined)
1459
1459
  throw new Error(`nonce required`);
1460
+ await this.validateNonce(message.decoded.from, message.decoded.nonce);
1461
+ // todo check if signature is valid
1462
+ const hash = await message.hash();
1460
1463
  try {
1461
- await this.validateNonce(message.decoded.from, message.decoded.nonce);
1462
- // todo check if signature is valid
1463
- const hash = await message.hash();
1464
1464
  let data;
1465
1465
  const wait = new Promise(async (resolve, reject) => {
1466
1466
  if (pubsub.subscribers[`transaction.completed.${hash}`]) {
1467
1467
  const result = pubsub.subscribers[`transaction.completed.${hash}`].value;
1468
+ if (result.status !== 'fulfilled') {
1469
+ await transactionPoolStore.delete(hash);
1470
+ }
1468
1471
  result.status === 'fulfilled' ? resolve(result.hash) : reject({ hash: result.hash, error: result.error });
1469
1472
  }
1470
1473
  else {
1471
1474
  const completed = async (result) => {
1475
+ if (result.status !== 'fulfilled') {
1476
+ await transactionPoolStore.delete(hash);
1477
+ }
1472
1478
  result.status === 'fulfilled' ? resolve(result.hash) : reject({ hash: result.hash, error: result.error });
1473
1479
  setTimeout(async () => {
1474
1480
  pubsub.unsubscribe(`transaction.completed.${hash}`, completed);
1475
- }, 10_000);
1481
+ }, 10000);
1476
1482
  };
1477
1483
  pubsub.subscribe(`transaction.completed.${hash}`, completed);
1478
1484
  }
@@ -1483,6 +1489,8 @@ class Transaction extends Protocol {
1483
1489
  return { hash, data, fee: await calculateFee(message.decoded), wait, message };
1484
1490
  }
1485
1491
  catch (error) {
1492
+ console.log('remo');
1493
+ await transactionPoolStore.delete(hash);
1486
1494
  throw error;
1487
1495
  }
1488
1496
  }
@@ -1922,7 +1930,7 @@ class State extends Contract {
1922
1930
  super();
1923
1931
  }
1924
1932
  async init() {
1925
- this.jobber = new Jobber(30_000);
1933
+ this.jobber = new Jobber(30000);
1926
1934
  if (super.init)
1927
1935
  await super.init();
1928
1936
  await globalThis.peernet.addRequestHandler('lastBlock', this.#lastBlockHandler.bind(this));
@@ -1951,9 +1959,17 @@ class State extends Contract {
1951
1959
  }
1952
1960
  catch (error) {
1953
1961
  console.log({ e: error });
1962
+ console.log({ e: error });
1954
1963
  }
1955
1964
  globalThis.pubsub.publish('lastBlock', this.lastBlock);
1956
1965
  // load local blocks
1966
+ try {
1967
+ this.knownBlocks = await blockStore.keys();
1968
+ }
1969
+ catch (error) {
1970
+ console.error(error);
1971
+ throw error;
1972
+ }
1957
1973
  await this.resolveBlocks();
1958
1974
  this.#machine = await new Machine(this.#blocks);
1959
1975
  await this.#loadBlocks(this.#blocks);
@@ -2199,6 +2215,8 @@ class State extends Contract {
2199
2215
  this.#totalTransactions += 1;
2200
2216
  }
2201
2217
  catch (error) {
2218
+ await globalThis.transactionPoolStore.delete(transaction.hash);
2219
+ console.log('removing invalid transaction');
2202
2220
  console.log(error);
2203
2221
  return false;
2204
2222
  }
@@ -2252,6 +2270,7 @@ class State extends Contract {
2252
2270
  }
2253
2271
 
2254
2272
  globalThis.BigNumber = BigNumber;
2273
+ const ignorelist = ['BA5XUACBBBAT653LT3GHP2Z5SUHVCA42BP6IBFBJACHOZIHHR4DUPG2XMB'];
2255
2274
  // check if browser or local
2256
2275
  class Chain extends State {
2257
2276
  #state;
@@ -2286,7 +2305,7 @@ class Chain extends State {
2286
2305
  console.log('epoch');
2287
2306
  const validators = await this.staticCall(addresses.validators, 'validators');
2288
2307
  console.log({ validators });
2289
- if (!validators[globalThis.globalThis.peernet.selectedAccount]?.active)
2308
+ if (!validators[peernet.selectedAccount]?.active)
2290
2309
  return;
2291
2310
  const start = Date.now();
2292
2311
  try {
@@ -2294,6 +2313,7 @@ class Chain extends State {
2294
2313
  }
2295
2314
  catch (error) {
2296
2315
  console.error(error);
2316
+ console.log('ttttt');
2297
2317
  }
2298
2318
  const end = Date.now();
2299
2319
  console.log(((end - start) / 1000) + ' s');
@@ -2324,7 +2344,7 @@ class Chain extends State {
2324
2344
  console.log('handle native contracts');
2325
2345
  // handle native contracts
2326
2346
  }
2327
- async #clearPool() {
2347
+ async clearPool() {
2328
2348
  await globalThis.transactionPoolStore.clear();
2329
2349
  }
2330
2350
  async #init() {
@@ -2368,11 +2388,12 @@ class Chain extends State {
2368
2388
  globalThis.peernet.subscribe('add-block', this.#addBlock.bind(this));
2369
2389
  globalThis.peernet.subscribe('invalid-transaction', this.#invalidTransaction.bind(this));
2370
2390
  globalThis.peernet.subscribe('send-transaction', this.#sendTransaction.bind(this));
2391
+ globalThis.peernet.subscribe('add-transaction', this.#addTransaction.bind(this));
2371
2392
  globalThis.peernet.subscribe('validator:timeout', this.#validatorTimeout.bind(this));
2372
2393
  globalThis.pubsub.subscribe('peer:connected', this.#peerConnected.bind(this));
2373
2394
  // todo some functions rely on state
2374
2395
  await super.init();
2375
- globalThis.globalThis.pubsub.publish('chain:ready', true);
2396
+ globalThis.pubsub.publish('chain:ready', true);
2376
2397
  return this;
2377
2398
  }
2378
2399
  async #invalidTransaction(hash) {
@@ -2385,6 +2406,9 @@ class Chain extends State {
2385
2406
  }, validatorInfo.timeout);
2386
2407
  this.#jail.push(validatorInfo.address);
2387
2408
  }
2409
+ #addTransaction(message) {
2410
+ console.log(message);
2411
+ }
2388
2412
  async #prepareRequest(request) {
2389
2413
  let node = await new globalThis.peernet.protos['peernet-request']({ request });
2390
2414
  return globalThis.peernet.prepareMessage(node);
@@ -2399,13 +2423,27 @@ class Chain extends State {
2399
2423
  if (!peer.version || peer.version !== this.version)
2400
2424
  return;
2401
2425
  const lastBlock = await this.#makeRequest(peer, 'lastBlock');
2426
+ let transactionsInPool = await this.#makeRequest(peer, 'transactionPool');
2427
+ const transactions = await globalThis.transactionPoolStore.keys();
2428
+ console.log({ transactionsInPool });
2429
+ const transactionsToGet = [];
2430
+ for (const key of transactionsInPool) {
2431
+ if (!transactions.includes(key))
2432
+ transactionsToGet.push(transactionPoolStore.put(key, (await peernet.get(key, 'transaction'))));
2433
+ }
2434
+ console.log(await transactionPoolStore.keys());
2435
+ await Promise.all(transactionsToGet);
2402
2436
  if (Object.keys(lastBlock).length > 0) {
2403
2437
  if (!this.lastBlock || !this.blocks[this.blocks.length - 1]?.loaded || lastBlock && lastBlock.index > this.lastBlock?.index || !this.loaded && !this.resolving) {
2404
2438
  this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
2405
2439
  await this.syncChain(lastBlock);
2406
2440
  // if (await this.hasTransactionToHandle() && this.#participating) this.#runEpoch()
2407
2441
  }
2442
+ else if (!this.knownBlocks)
2443
+ this.knownBlocks = await this.#makeRequest(peer, 'knownBlocks');
2408
2444
  }
2445
+ if (this.#participating)
2446
+ this.#runEpoch();
2409
2447
  }
2410
2448
  #epochTimeout;
2411
2449
  async #transactionPoolHandler() {
@@ -2423,7 +2461,7 @@ class Chain extends State {
2423
2461
  return result || 'no state change';
2424
2462
  }
2425
2463
  catch (error) {
2426
- console.log({ error });
2464
+ await transactionPoolStore.delete(hash);
2427
2465
  globalThis.peernet.publish('invalid-transaction', hash);
2428
2466
  globalThis.pubsub.publish(`transaction.completed.${hash}`, { status: 'fail', hash, error: error });
2429
2467
  throw { error, hash, from, to, params, nonce };
@@ -2465,6 +2503,9 @@ class Chain extends State {
2465
2503
  globalThis.pubsub.publish('block-processed', blockMessage.decoded);
2466
2504
  }
2467
2505
  catch (error) {
2506
+ console.log(error.hash);
2507
+ console.log('errrrr');
2508
+ await transactionPoolStore.delete(error.hash);
2468
2509
  console.log({ e: error });
2469
2510
  }
2470
2511
  }
@@ -2497,6 +2538,10 @@ class Chain extends State {
2497
2538
  if (await globalThis.transactionPoolStore.size() === 0)
2498
2539
  return;
2499
2540
  let transactions = await globalThis.transactionPoolStore.values(this.transactionLimit);
2541
+ for (const hash of await globalThis.transactionPoolStore.keys()) {
2542
+ if (ignorelist.includes(hash))
2543
+ await globalThis.transactionPoolStore.delete(hash);
2544
+ }
2500
2545
  if (Object.keys(transactions)?.length === 0)
2501
2546
  return;
2502
2547
  const timestamp = Date.now();
@@ -2512,6 +2557,7 @@ class Chain extends State {
2512
2557
  // exclude failing tx
2513
2558
  transactions = await this.promiseTransactions(transactions);
2514
2559
  transactions = transactions.sort((a, b) => a.nonce - b.nonce);
2560
+ console.log({ transactions });
2515
2561
  for (let transaction of transactions) {
2516
2562
  const hash = await transaction.hash();
2517
2563
  const doubleTransactions = [];
@@ -2525,21 +2571,25 @@ class Chain extends State {
2525
2571
  if (doubleTransactions.length > 0) {
2526
2572
  await globalThis.transactionPoolStore.delete(hash);
2527
2573
  await globalThis.peernet.publish('invalid-transaction', hash);
2574
+ return;
2528
2575
  }
2529
- else {
2530
- // if (timestamp + this.#slotTime > Date.now()) {
2531
- try {
2532
- const result = await this.#executeTransaction({ ...transaction.decoded, hash });
2533
- block.transactions.push(transaction);
2534
- block.fees = block.fees.add(await calculateFee(transaction.decoded));
2535
- await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
2536
- }
2537
- catch (e) {
2538
- console.log({ e });
2539
- console.log(hash);
2540
- await globalThis.transactionPoolStore.delete(hash);
2541
- }
2542
- // }
2576
+ // if (timestamp + this.#slotTime > Date.now()) {
2577
+ try {
2578
+ const result = await this.#executeTransaction({ ...transaction.decoded, hash });
2579
+ console.log({ result });
2580
+ block.transactions.push(transaction);
2581
+ block.fees = block.fees.add(await calculateFee(transaction.decoded));
2582
+ await globalThis.accountsStore.put(transaction.decoded.from, new TextEncoder().encode(String(transaction.decoded.nonce)));
2583
+ }
2584
+ catch (e) {
2585
+ console.log('vvvvvv');
2586
+ console.log({ e });
2587
+ console.log(hash);
2588
+ peernet.publish('invalid-transaction', hash);
2589
+ console.log(await globalThis.transactionPoolStore.keys());
2590
+ console.log(await globalThis.transactionPoolStore.has(e.hash));
2591
+ await globalThis.transactionPoolStore.delete(e.hash);
2592
+ console.log(await globalThis.transactionPoolStore.has(e.hash));
2543
2593
  }
2544
2594
  }
2545
2595
  // don't add empty block
@@ -2613,6 +2663,7 @@ class Chain extends State {
2613
2663
  }
2614
2664
  catch (error) {
2615
2665
  console.log(error);
2666
+ console.log('eeeee');
2616
2667
  throw new Error(`invalid block ${block}`);
2617
2668
  }
2618
2669
  // data = await this.machine.execute(to, method, params)
@@ -2631,6 +2682,7 @@ class Chain extends State {
2631
2682
  }
2632
2683
  catch (e) {
2633
2684
  console.log(e);
2685
+ console.log('rrrrr');
2634
2686
  globalThis.peernet.publish('invalid-transaction', hash);
2635
2687
  throw new Error('invalid transaction');
2636
2688
  }
@@ -2660,7 +2712,7 @@ class Chain extends State {
2660
2712
  * @param {Address} sender
2661
2713
  * @returns {globalMessage}
2662
2714
  */
2663
- #createMessage(sender = globalThis.globalThis.peernet.selectedAccount) {
2715
+ #createMessage(sender = globalThis.peernet.selectedAccount) {
2664
2716
  return {
2665
2717
  sender,
2666
2718
  call: this.call,
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-44a01a16.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './node-browser-3cbee72b.js';
2
2
  import './index-c3f4012c.js';
3
3
 
4
4
  /**