@frequency-chain/ethereum-utils 1.17.0-rc7 → 1.17.0

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.
@@ -3626,6 +3626,8 @@ function stringToU8a(value) {
3626
3626
  * @summary Creates a Uint8Array value from a Uint8Array, Buffer, string or hex input.
3627
3627
  * @description
3628
3628
  * `null` or `undefined` inputs returns a `[]` result, Uint8Array values returns the value, hex strings returns a Uint8Array representation.
3629
+ * If `strict` is true, `null` or `undefined` will throw an error instead of returning an empty array.
3630
+ * Supports input types: Uint8Array, Buffer, hex string, string, or number array.
3629
3631
  * @example
3630
3632
  * <BR>
3631
3633
  *
@@ -3636,7 +3638,10 @@ function stringToU8a(value) {
3636
3638
  * u8aToU8a(0x1234); // => Uint8Array([0x12, 0x34])
3637
3639
  * ```
3638
3640
  */
3639
- function u8aToU8a(value) {
3641
+ function u8aToU8a(value, strict = false) {
3642
+ if (strict && (value === null || value === undefined)) {
3643
+ throw new Error('u8aToU8a: Expected non-null, non-undefined value');
3644
+ }
3640
3645
  return isU8a(value)
3641
3646
  // NOTE isBuffer needs to go here since it actually extends
3642
3647
  // Uint8Array on Node.js environments, so all Buffer are Uint8Array,
@@ -10515,7 +10520,7 @@ function ethereumEncode(addressOrPublic) {
10515
10520
  /**
10516
10521
  * The current version of Ethers.
10517
10522
  */
10518
- const version = "6.14.4";/**
10523
+ const version = "6.15.0";/**
10519
10524
  * Property helper functions.
10520
10525
  *
10521
10526
  * @_subsection api/utils:Properties [about-properties]
@@ -14694,12 +14699,28 @@ class Signature {
14694
14699
  /**
14695
14700
  * The ``s`` value for a signature.
14696
14701
  */
14697
- get s() { return this.#s; }
14702
+ get s() {
14703
+ assertArgument(parseInt(this.#s.substring(0, 3)) < 8, "non-canonical s; use ._s", "s", this.#s);
14704
+ return this.#s;
14705
+ }
14698
14706
  set s(_value) {
14699
14707
  assertArgument(dataLength(_value) === 32, "invalid s", "value", _value);
14700
- const value = hexlify(_value);
14701
- assertArgument(parseInt(value.substring(0, 3)) < 8, "non-canonical s", "value", value);
14702
- this.#s = value;
14708
+ this.#s = hexlify(_value);
14709
+ }
14710
+ /**
14711
+ * Return the s value, unchecked for EIP-2 compliance.
14712
+ *
14713
+ * This should generally not be used and is for situations where
14714
+ * a non-canonical S value might be relevant, such as Frontier blocks
14715
+ * that were mined prior to EIP-2 or invalid Authorization List
14716
+ * signatures.
14717
+ */
14718
+ get _s() { return this.#s; }
14719
+ /**
14720
+ * Returns true if the Signature is valid for [[link-eip-2]] signatures.
14721
+ */
14722
+ isValid() {
14723
+ return (parseInt(this.#s.substring(0, 3)) < 8);
14703
14724
  }
14704
14725
  /**
14705
14726
  * The ``v`` value for a signature.
@@ -14776,13 +14797,13 @@ class Signature {
14776
14797
  this.#networkV = null;
14777
14798
  }
14778
14799
  [Symbol.for('nodejs.util.inspect.custom')]() {
14779
- return `Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`;
14800
+ return `Signature { r: "${this.r}", s: "${this._s}"${this.isValid() ? "" : ', valid: "false"'}, yParity: ${this.yParity}, networkV: ${this.networkV} }`;
14780
14801
  }
14781
14802
  /**
14782
14803
  * Returns a new identical [[Signature]].
14783
14804
  */
14784
14805
  clone() {
14785
- const clone = new Signature(_guard$2, this.r, this.s, this.v);
14806
+ const clone = new Signature(_guard$2, this.r, this._s, this.v);
14786
14807
  if (this.networkV) {
14787
14808
  clone.#networkV = this.networkV;
14788
14809
  }
@@ -14796,7 +14817,7 @@ class Signature {
14796
14817
  return {
14797
14818
  _type: "signature",
14798
14819
  networkV: ((networkV != null) ? networkV.toString() : null),
14799
- r: this.r, s: this.s, v: this.v,
14820
+ r: this.r, s: this._s, v: this.v,
14800
14821
  };
14801
14822
  }
14802
14823
  /**
@@ -14895,10 +14916,9 @@ class Signature {
14895
14916
  }
14896
14917
  if (bytes.length === 65) {
14897
14918
  const r = hexlify(bytes.slice(0, 32));
14898
- const s = bytes.slice(32, 64);
14899
- assertError((s[0] & 0x80) === 0, "non-canonical s");
14919
+ const s = hexlify(bytes.slice(32, 64));
14900
14920
  const v = Signature.getNormalizedV(bytes[64]);
14901
- return new Signature(_guard$2, r, hexlify(s), v);
14921
+ return new Signature(_guard$2, r, s, v);
14902
14922
  }
14903
14923
  assertError(false, "invalid raw signature length");
14904
14924
  }
@@ -14922,7 +14942,6 @@ class Signature {
14922
14942
  }
14923
14943
  assertError(false, "missing s");
14924
14944
  })(sig.s, sig.yParityAndS);
14925
- assertError((getBytes(s)[0] & 0x80) == 0, "non-canonical s");
14926
14945
  // Get v; by any means necessary (we check consistency below)
14927
14946
  const { networkV, v } = (function (_v, yParityAndS, yParity) {
14928
14947
  if (_v != null) {
@@ -3626,6 +3626,8 @@ function stringToU8a(value) {
3626
3626
  * @summary Creates a Uint8Array value from a Uint8Array, Buffer, string or hex input.
3627
3627
  * @description
3628
3628
  * `null` or `undefined` inputs returns a `[]` result, Uint8Array values returns the value, hex strings returns a Uint8Array representation.
3629
+ * If `strict` is true, `null` or `undefined` will throw an error instead of returning an empty array.
3630
+ * Supports input types: Uint8Array, Buffer, hex string, string, or number array.
3629
3631
  * @example
3630
3632
  * <BR>
3631
3633
  *
@@ -3636,7 +3638,10 @@ function stringToU8a(value) {
3636
3638
  * u8aToU8a(0x1234); // => Uint8Array([0x12, 0x34])
3637
3639
  * ```
3638
3640
  */
3639
- function u8aToU8a(value) {
3641
+ function u8aToU8a(value, strict = false) {
3642
+ if (strict && (value === null || value === undefined)) {
3643
+ throw new Error('u8aToU8a: Expected non-null, non-undefined value');
3644
+ }
3640
3645
  return isU8a(value)
3641
3646
  // NOTE isBuffer needs to go here since it actually extends
3642
3647
  // Uint8Array on Node.js environments, so all Buffer are Uint8Array,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frequency-chain/ethereum-utils",
3
- "version": "1.17.0-rc7",
3
+ "version": "1.17.0",
4
4
  "bugs": {
5
5
  "url": "https://github.com/frequency-chain/frequency/issues"
6
6
  },
@@ -15,9 +15,9 @@
15
15
  "author": "frequency-chain",
16
16
  "license": "Apache-2.0",
17
17
  "dependencies": {
18
- "@polkadot/api": "^16.2.2",
19
- "@polkadot/util": "13.5.2",
20
- "ethers": "^6.14.4"
18
+ "@polkadot/api": "^16.3.1",
19
+ "@polkadot/util": "13.5.3",
20
+ "ethers": "^6.15.0"
21
21
  },
22
22
  "optionalDependencies": {
23
23
  "@rollup/rollup-linux-x64-gnu": "^4.44.1"