quais 0.1.13 → 0.1.15

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/dist/quais.esm.js CHANGED
@@ -9647,10 +9647,6 @@ class TransactionOrderForkEvent extends ForkEvent {
9647
9647
  ///////////////////////////////
9648
9648
  // Exported Abstracts
9649
9649
  class Provider {
9650
- constructor() {
9651
- logger$d.checkAbstract(new.target, Provider);
9652
- defineReadOnly(this, "_isProvider", true);
9653
- }
9654
9650
  getFeeData() {
9655
9651
  return __awaiter$2(this, void 0, void 0, function* () {
9656
9652
  const { block, gasPrice, maxFeePerGas, maxPriorityFeePerGas } = yield resolveProperties({
@@ -9688,6 +9684,10 @@ class Provider {
9688
9684
  removeListener(eventName, listener) {
9689
9685
  return this.off(eventName, listener);
9690
9686
  }
9687
+ constructor() {
9688
+ logger$d.checkAbstract(new.target, Provider);
9689
+ defineReadOnly(this, "_isProvider", true);
9690
+ }
9691
9691
  static isProvider(value) {
9692
9692
  return !!(value && value._isProvider);
9693
9693
  }
@@ -9858,7 +9858,6 @@ class Signer {
9858
9858
  else {
9859
9859
  // We need to get fee data to determine things
9860
9860
  const feeData = yield this.getFeeData();
9861
- console.log("FEE DATA:", feeData);
9862
9861
  if (tx.type == null) {
9863
9862
  // We need to auto-detect the intended type of this transaction...
9864
9863
  if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) {
@@ -14056,6 +14055,7 @@ function _serialize(transaction, signature) {
14056
14055
  // If there is an explicit gasPrice, make sure it matches the
14057
14056
  // EIP-1559 fees; otherwise they may not understand what they
14058
14057
  // think they are setting in terms of fee.
14058
+ //console.log('Serializing tx: \n', JSON.stringify(transaction, null, 4));
14059
14059
  if (transaction.gasPrice != null) {
14060
14060
  const gasPrice = BigNumber.from(transaction.gasPrice);
14061
14061
  const maxFeePerGas = BigNumber.from(transaction.maxFeePerGas || 0);
@@ -14082,6 +14082,7 @@ function _serialize(transaction, signature) {
14082
14082
  fields.push(stripZeros(sig.r));
14083
14083
  fields.push(stripZeros(sig.s));
14084
14084
  }
14085
+ //console.log('Encoding tx: \n', JSON.stringify(fields, null, 4));
14085
14086
  return hexConcat(["0x00", encode$1(fields)]);
14086
14087
  }
14087
14088
  function _serializeStandardETx(transaction, signature) {
@@ -14173,9 +14174,9 @@ function _parse(payload) {
14173
14174
  }
14174
14175
  function _parseStandardETx(payload) {
14175
14176
  const transaction = decode$1(payload.slice(1));
14176
- if (transaction.length !== 8 && transaction.length !== 17) {
14177
- logger$h.throwArgumentError("invalid component count for transaction type: 1", "payload", hexlify(payload));
14178
- }
14177
+ // if (transaction.length !== 8 && transaction.length !== 17) {
14178
+ // logger.throwArgumentError("invalid component count for transaction type: 1", "payload", hexlify(payload));
14179
+ // }
14179
14180
  const maxPriorityFeePerGas = handleNumber(transaction[2]);
14180
14181
  const maxFeePerGas = handleNumber(transaction[3]);
14181
14182
  const tx = {
@@ -18633,41 +18634,44 @@ class Formatter {
18633
18634
  const address = this.address.bind(this);
18634
18635
  const bigNumber = this.bigNumber.bind(this);
18635
18636
  const bigNumberArray = this.bigNumberArray.bind(this);
18637
+ const numberArray = this.numberArray.bind(this);
18636
18638
  const blockTag = this.blockTag.bind(this);
18637
18639
  const data = this.data.bind(this);
18638
18640
  const hash = this.hash.bind(this);
18639
18641
  const hashArray = this.hashArray.bind(this);
18642
+ const hashArrayAnyLength = this.hashArrayAnyLength.bind(this);
18640
18643
  const hex = this.hex.bind(this);
18641
18644
  const number = this.number.bind(this);
18642
- const type = this.type.bind(this);
18645
+ const etxs = this.etxs.bind(this);
18643
18646
  const strictData = (v) => { return this.data(v, true); };
18644
18647
  formats.transaction = {
18645
18648
  hash: hash,
18646
- type: type,
18649
+ type: hex,
18647
18650
  accessList: Formatter.allowNull(this.accessList.bind(this), null),
18648
18651
  blockHash: Formatter.allowNull(hash, null),
18649
18652
  blockNumber: Formatter.allowNull(number, null),
18650
18653
  transactionIndex: Formatter.allowNull(number, null),
18651
- confirmations: Formatter.allowNull(number, null),
18652
18654
  from: address,
18653
18655
  // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas)
18654
18656
  // must be set
18655
18657
  gasPrice: Formatter.allowNull(bigNumber),
18656
18658
  maxPriorityFeePerGas: Formatter.allowNull(bigNumber),
18657
18659
  maxFeePerGas: Formatter.allowNull(bigNumber),
18658
- gasLimit: bigNumber,
18659
18660
  to: Formatter.allowNull(address, null),
18660
18661
  value: bigNumber,
18661
18662
  nonce: number,
18662
- data: data,
18663
- r: Formatter.allowNull(this.uint256),
18664
- s: Formatter.allowNull(this.uint256),
18665
- v: Formatter.allowNull(number),
18666
- creates: Formatter.allowNull(address, null),
18663
+ data: Formatter.allowNull(data),
18664
+ r: Formatter.allowNull(hex),
18665
+ s: Formatter.allowNull(hex),
18666
+ v: Formatter.allowNull(hex),
18667
18667
  raw: Formatter.allowNull(data),
18668
18668
  gas: Formatter.allowNull(bigNumber),
18669
- input: Formatter.allowNull(data),
18670
- sender: Formatter.allowNull(address),
18669
+ //EXT TRANSACTIONS
18670
+ etxGasLimit: Formatter.allowNull(bigNumber),
18671
+ etxGasPrice: Formatter.allowNull(bigNumber),
18672
+ etxGasTip: Formatter.allowNull(bigNumber),
18673
+ etxData: Formatter.allowNull(data),
18674
+ etxAccessList: Formatter.allowNull(this.accessList.bind(this), null),
18671
18675
  };
18672
18676
  formats.transactionRequest = {
18673
18677
  from: Formatter.allowNull(address),
@@ -18704,31 +18708,48 @@ class Formatter {
18704
18708
  // should be allowNull(hash), but broken-EIP-658 support is handled in receipt
18705
18709
  root: Formatter.allowNull(hex),
18706
18710
  gasUsed: bigNumber,
18707
- logsBloom: Formatter.allowNull(data),
18711
+ logsBloom: Formatter.allowNull(hex),
18708
18712
  blockHash: hash,
18709
18713
  transactionHash: hash,
18710
- exts: Formatter.allowNull(this.etx, null),
18714
+ etxs: Formatter.allowNull(etxs, null),
18711
18715
  logs: Formatter.arrayOf(this.receiptLog.bind(this)),
18712
18716
  blockNumber: number,
18713
18717
  confirmations: Formatter.allowNull(number, null),
18714
18718
  cumulativeGasUsed: bigNumber,
18715
18719
  effectiveGasPrice: Formatter.allowNull(bigNumber),
18716
- status: Formatter.allowNull(number),
18717
- type: type
18720
+ status: hex,
18721
+ type: hex,
18718
18722
  };
18719
18723
  formats.block = {
18720
18724
  hash: Formatter.allowNull(hash),
18721
18725
  parentHash: hashArray,
18722
- number: bigNumberArray,
18726
+ parentEntropy: bigNumberArray,
18727
+ number: numberArray,
18723
18728
  timestamp: number,
18724
18729
  nonce: Formatter.allowNull(hex),
18725
18730
  difficulty: bigNumber,
18726
18731
  gasLimit: bigNumber,
18727
18732
  gasUsed: bigNumber,
18733
+ baseFeePerGas: Formatter.allowNull(bigNumber),
18728
18734
  miner: Formatter.allowNull(address),
18729
18735
  extraData: data,
18730
18736
  transactions: Formatter.allowNull(Formatter.arrayOf(hash)),
18731
- baseFeePerGas: Formatter.allowNull(bigNumber)
18737
+ transactionsRoot: hash,
18738
+ extTransactions: Formatter.allowNull(Formatter.arrayOf(hash)),
18739
+ extRollupRoot: Formatter.allowNull(hash),
18740
+ extTransactionsRoot: Formatter.allowNull(hash),
18741
+ location: Formatter.allowNull(hex),
18742
+ manifestHash: hashArrayAnyLength,
18743
+ mixHash: hash,
18744
+ order: Number,
18745
+ parentDeltaS: bigNumberArray,
18746
+ receiptsRoot: hash,
18747
+ sha3Uncles: hash,
18748
+ size: bigNumber,
18749
+ stateRoot: hash,
18750
+ uncles: Formatter.allowNull(Formatter.arrayOf(hash)),
18751
+ subManifest: Formatter.allowNull(Formatter.arrayOf(hash)),
18752
+ totalEntropy: bigNumber,
18732
18753
  };
18733
18754
  formats.blockWithTransactions = shallowCopy(formats.block);
18734
18755
  formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this)));
@@ -18743,7 +18764,6 @@ class Formatter {
18743
18764
  blockNumber: Formatter.allowNull(number),
18744
18765
  blockHash: Formatter.allowNull(hash),
18745
18766
  transactionIndex: number,
18746
- removed: Formatter.allowNull(this.boolean.bind(this)),
18747
18767
  address: address,
18748
18768
  data: Formatter.allowFalsish(data, "0x"),
18749
18769
  topics: Formatter.arrayOf(hash),
@@ -18763,19 +18783,16 @@ class Formatter {
18763
18783
  }
18764
18784
  return BigNumber.from(number).toNumber();
18765
18785
  }
18766
- type(number) {
18767
- if (number === "0x" || number == null) {
18768
- return 0;
18769
- }
18770
- return BigNumber.from(number).toNumber();
18771
- }
18772
18786
  // Strict! Used on input.
18773
18787
  bigNumber(value) {
18774
18788
  return BigNumber.from(value);
18775
18789
  }
18790
+ numberArray(value) {
18791
+ return Array.from(value, item => (Number(item)));
18792
+ }
18776
18793
  // Strict! Used on input.
18777
18794
  bigNumberArray(value) {
18778
- return Array.from(value);
18795
+ return Array.from(value, item => (BigNumber.from(item)));
18779
18796
  }
18780
18797
  // Requires a boolean, "true" or "false"; returns a boolean
18781
18798
  boolean(value) {
@@ -18816,8 +18833,30 @@ class Formatter {
18816
18833
  address(value) {
18817
18834
  return getAddress(value);
18818
18835
  }
18819
- etx(value) {
18820
- return value;
18836
+ etxs(value) {
18837
+ if (!Array.isArray(value)) {
18838
+ throw new Error("Value must be an array.");
18839
+ }
18840
+ const formattedEtxs = [];
18841
+ for (let i = 0; i < value.length; i++) {
18842
+ const etx = value[i];
18843
+ formattedEtxs.push({
18844
+ type: etx.type,
18845
+ nonce: Number(etx.nonce),
18846
+ gasPrice: Formatter.allowNull(this.bigNumber, null)(etx.gasPrice),
18847
+ maxPriorityFeePerGas: this.bigNumber(etx.maxPriorityFeePerGas),
18848
+ maxFeePerGas: this.bigNumber(etx.maxFeePerGas),
18849
+ gas: this.bigNumber(etx.gas),
18850
+ value: this.bigNumber(etx.value),
18851
+ data: this.data(etx.input),
18852
+ to: this.address(etx.to),
18853
+ accessList: Formatter.allowNull(this.accessList, null)(etx.accessList),
18854
+ chainId: Number(etx.chainId),
18855
+ from: this.address(etx.sender),
18856
+ hash: this.hash(etx.hash)
18857
+ });
18858
+ }
18859
+ return formattedEtxs;
18821
18860
  }
18822
18861
  callAddress(value) {
18823
18862
  if (!isHexString(value, 32)) {
@@ -18873,6 +18912,17 @@ class Formatter {
18873
18912
  }
18874
18913
  return results;
18875
18914
  }
18915
+ hashArrayAnyLength(value, strict) {
18916
+ if (value.length != HIERARCHY_DEPTH) {
18917
+ return logger$s.throwArgumentError("invalid hash array", "value", value);
18918
+ }
18919
+ let results = [];
18920
+ for (const hash of value) {
18921
+ const result = this.hex(hash, strict);
18922
+ results.push(result);
18923
+ }
18924
+ return results;
18925
+ }
18876
18926
  // Returns the difficulty as a number, or if too large (i.e. PoA network) null
18877
18927
  difficulty(value) {
18878
18928
  if (value == null) {
@@ -18891,7 +18941,7 @@ class Formatter {
18891
18941
  }
18892
18942
  return hexZeroPad(value, 32);
18893
18943
  }
18894
- _block(value, format, context) {
18944
+ _block(value, format, context, simplify) {
18895
18945
  if (value.author != null && value.miner == null) {
18896
18946
  value.miner = value.author;
18897
18947
  }
@@ -18900,33 +18950,47 @@ class Formatter {
18900
18950
  const result = Formatter.check(format, value);
18901
18951
  result._difficulty = ((difficulty == null) ? null : difficulty);
18902
18952
  if (context) {
18903
- return this.contextBlock(result, context);
18953
+ return this.contextBlock(result, context, simplify);
18904
18954
  }
18905
18955
  return result;
18906
18956
  }
18907
- block(value, context) {
18908
- return this._block(value, this.formats.block, context);
18957
+ block(value, context, simplify) {
18958
+ return this._block(value, this.formats.block, context, simplify);
18909
18959
  }
18910
18960
  blockWithTransactions(value) {
18911
18961
  return this._block(value, this.formats.blockWithTransactions);
18912
18962
  }
18913
- contextBlock(value, context) {
18963
+ contextBlock(value, context, simplify = false) {
18914
18964
  let contextBlock = {
18915
- number: value.number[context],
18965
+ number: simplify ? value.number[2] : value.number,
18916
18966
  transactions: value.transactions,
18917
18967
  hash: value.hash,
18918
- parentHash: value.parentHash[context],
18968
+ parentHash: simplify ? value.parentHash[2] : value.parentHash,
18969
+ parentEntropy: simplify ? value.parentEntropy[2] : value.parentEntropy,
18970
+ extTransactions: value.extTransactions,
18919
18971
  timestamp: value.timestamp,
18920
18972
  nonce: value.nonce,
18921
18973
  difficulty: value.difficulty,
18922
- _difficulty: value._difficulty,
18923
18974
  gasLimit: value.gasLimit,
18924
18975
  gasUsed: value.gasUsed,
18925
18976
  miner: value.miner,
18926
- extraData: value.data,
18977
+ extraData: value.extraData,
18927
18978
  transactionsRoot: value.transactionsRoot,
18928
18979
  stateRoot: value.stateRoot,
18929
- receiptsRoot: value.receiptsRoot
18980
+ receiptsRoot: value.receiptsRoot,
18981
+ baseFeePerGas: value.baseFeePerGas,
18982
+ extRollupRoot: value.extRollupRoot,
18983
+ extTransactionsRoot: value.extTransactionsRoot,
18984
+ location: value.location,
18985
+ manifestHash: simplify ? value.manifestHash[2] : value.manifestHash,
18986
+ mixHash: value.mixHash,
18987
+ order: value.order,
18988
+ parentDeltaS: simplify ? value.parentDeltaS[2] : value.parentDeltaS,
18989
+ sha3Uncles: value.sha3Uncles,
18990
+ size: value.size,
18991
+ uncles: value.uncles,
18992
+ subManifest: value.subManifest,
18993
+ totalEntropy: value.totalEntropy,
18930
18994
  };
18931
18995
  return contextBlock;
18932
18996
  }
@@ -18937,7 +19001,7 @@ class Formatter {
18937
19001
  transactionResponse(transaction) {
18938
19002
  // Rename gas to gasLimit
18939
19003
  if (transaction.gas != null && transaction.gasLimit == null) {
18940
- transaction.gasLimit = transaction.gas;
19004
+ transaction.gas = transaction.gas;
18941
19005
  }
18942
19006
  // Some clients (TestRPC) do strange things like return 0x0 for the
18943
19007
  // 0 address; correct this to be a real address
@@ -18948,11 +19012,11 @@ class Formatter {
18948
19012
  if (transaction.input != null && transaction.data == null) {
18949
19013
  transaction.data = transaction.input;
18950
19014
  }
18951
- // If to and creates are empty, populate the creates from the transaction
18952
- if (transaction.to == null && transaction.creates == null) {
18953
- transaction.creates = this.contractAddress(transaction);
19015
+ if (transaction.type == '0x1') {
19016
+ transaction.from = transaction.sender;
19017
+ delete transaction.sender;
18954
19018
  }
18955
- if ((transaction.type === 1 || transaction.type === 2) && transaction.accessList == null) {
19019
+ if ((transaction.type === '0x1' || transaction.type === '0x2') && transaction.accessList == null) {
18956
19020
  transaction.accessList = [];
18957
19021
  }
18958
19022
  const result = Formatter.check(this.formats.transaction, transaction);
@@ -19020,9 +19084,6 @@ class Formatter {
19020
19084
  logger$s.throwArgumentError("invalid root hash", "value.root", result.root);
19021
19085
  }
19022
19086
  }
19023
- if (result.status != null) {
19024
- result.byzantium = true;
19025
- }
19026
19087
  return result;
19027
19088
  }
19028
19089
  topics(value) {
@@ -19742,7 +19803,7 @@ class BaseProvider extends Provider {
19742
19803
  this._maxInternalBlockNumber = -1024;
19743
19804
  this._lastBlockNumber = -2;
19744
19805
  this._maxFilterBlockRange = 10;
19745
- this._pollingInterval = 4000;
19806
+ this._pollingInterval = 40000;
19746
19807
  this._fastQueryDate = 0;
19747
19808
  }
19748
19809
  _ready() {
@@ -19903,9 +19964,9 @@ class BaseProvider extends Provider {
19903
19964
  });
19904
19965
  }
19905
19966
  poll() {
19906
- // Polling is now disabled
19907
- return;
19908
19967
  return __awaiter$9(this, void 0, void 0, function* () {
19968
+ // Polling is now disabled
19969
+ return;
19909
19970
  const pollId = nextPollId++;
19910
19971
  // Track all running promises, so we can trigger a post-poll once they are complete
19911
19972
  const runners = [];
@@ -20688,14 +20749,15 @@ class BaseProvider extends Provider {
20688
20749
  return address;
20689
20750
  });
20690
20751
  }
20691
- _getBlock(blockHashOrBlockTag, includeTransactions) {
20752
+ _getBlock(blockHashOrBlockTag, includeTransactions, simplify) {
20692
20753
  return __awaiter$9(this, void 0, void 0, function* () {
20693
20754
  yield this.getNetwork();
20694
20755
  blockHashOrBlockTag = yield blockHashOrBlockTag;
20695
20756
  // If blockTag is a number (not "latest", etc), this is the block number
20696
20757
  let blockNumber = -128;
20697
20758
  const params = {
20698
- includeTransactions: !!includeTransactions
20759
+ includeTransactions: !!includeTransactions,
20760
+ simplify: !!simplify
20699
20761
  };
20700
20762
  if (isHexString(blockHashOrBlockTag, 32)) {
20701
20763
  params.blockHash = blockHashOrBlockTag;
@@ -20725,7 +20787,7 @@ class BaseProvider extends Provider {
20725
20787
  }
20726
20788
  // For block tags, if we are asking for a future block, we return null
20727
20789
  if (params.blockTag != null) {
20728
- if (blockNumber > this._emitted.block) {
20790
+ if (blockNumber > Number(this._emitted.block)) {
20729
20791
  return null;
20730
20792
  }
20731
20793
  }
@@ -20756,15 +20818,15 @@ class BaseProvider extends Provider {
20756
20818
  blockWithTxs.transactions = blockWithTxs.transactions.map((tx) => this._wrapTransaction(tx));
20757
20819
  return blockWithTxs;
20758
20820
  }
20759
- return this.formatter.block(block, this._context);
20821
+ return this.formatter.block(block, this._context, simplify);
20760
20822
  }), { oncePoll: this });
20761
20823
  });
20762
20824
  }
20763
- getBlock(blockHashOrBlockTag) {
20764
- return (this._getBlock(blockHashOrBlockTag, false));
20825
+ getBlock(blockHashOrBlockTag, simplify = false) {
20826
+ return (this._getBlock(blockHashOrBlockTag, false, simplify));
20765
20827
  }
20766
- getBlockWithTransactions(blockHashOrBlockTag) {
20767
- return (this._getBlock(blockHashOrBlockTag, true));
20828
+ getBlockWithTransactions(blockHashOrBlockTag, simplify = false) {
20829
+ return (this._getBlock(blockHashOrBlockTag, true, simplify));
20768
20830
  }
20769
20831
  getTransaction(transactionHash) {
20770
20832
  return __awaiter$9(this, void 0, void 0, function* () {
@@ -21476,6 +21538,12 @@ const allowedTransactionKeys$2 = {
21476
21538
  externalGasLimit: true, externalGasPrice: true, externalGasTip: true, externalData: true, externalAccessList: true,
21477
21539
  };
21478
21540
  class JsonRpcProvider extends BaseProvider {
21541
+ get _cache() {
21542
+ if (this._eventLoopCache == null) {
21543
+ this._eventLoopCache = {};
21544
+ }
21545
+ return this._eventLoopCache;
21546
+ }
21479
21547
  constructor(url, network, context) {
21480
21548
  let networkOrReady = network;
21481
21549
  // The network is unknown, query the JSON-RPC for it
@@ -21514,12 +21582,6 @@ class JsonRpcProvider extends BaseProvider {
21514
21582
  }
21515
21583
  this._nextId = 42;
21516
21584
  }
21517
- get _cache() {
21518
- if (this._eventLoopCache == null) {
21519
- this._eventLoopCache = {};
21520
- }
21521
- return this._eventLoopCache;
21522
- }
21523
21585
  static defaultUrl() {
21524
21586
  return "http:/\/localhost:8545";
21525
21587
  }