@bitpay-labs/crypto-wallet-core 11.8.1 → 11.10.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.
Files changed (58) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +7 -7
  3. package/src/constants/chains.ts +6 -2
  4. package/src/constants/units.ts +11 -0
  5. package/src/derivation/index.ts +1 -0
  6. package/src/derivation/paths.ts +3 -0
  7. package/src/transactions/index.ts +2 -0
  8. package/src/transactions/spl/index.ts +2 -2
  9. package/src/utils/index.ts +69 -1
  10. package/src/validation/arc/index.ts +8 -0
  11. package/src/validation/index.ts +2 -0
  12. package/test/address.test.ts +12 -0
  13. package/test/transactions.test.ts +54 -1
  14. package/test/utils.test.ts +196 -10
  15. package/test/validation.test.ts +21 -0
  16. package/ts_build/src/constants/chains.d.ts +5 -2
  17. package/ts_build/src/constants/chains.d.ts.map +1 -1
  18. package/ts_build/src/constants/chains.js +5 -2
  19. package/ts_build/src/constants/chains.js.map +1 -1
  20. package/ts_build/src/constants/index.d.ts +14 -1
  21. package/ts_build/src/constants/index.d.ts.map +1 -1
  22. package/ts_build/src/constants/units.d.ts +11 -0
  23. package/ts_build/src/constants/units.d.ts.map +1 -1
  24. package/ts_build/src/constants/units.js +11 -0
  25. package/ts_build/src/constants/units.js.map +1 -1
  26. package/ts_build/src/derivation/index.d.ts.map +1 -1
  27. package/ts_build/src/derivation/index.js +1 -0
  28. package/ts_build/src/derivation/index.js.map +1 -1
  29. package/ts_build/src/derivation/paths.d.ts +3 -0
  30. package/ts_build/src/derivation/paths.d.ts.map +1 -1
  31. package/ts_build/src/derivation/paths.js +3 -0
  32. package/ts_build/src/derivation/paths.js.map +1 -1
  33. package/ts_build/src/transactions/index.d.ts.map +1 -1
  34. package/ts_build/src/transactions/index.js +2 -0
  35. package/ts_build/src/transactions/index.js.map +1 -1
  36. package/ts_build/src/transactions/spl/index.d.ts +1 -1
  37. package/ts_build/src/transactions/spl/index.d.ts.map +1 -1
  38. package/ts_build/src/transactions/spl/index.js +1 -1
  39. package/ts_build/src/transactions/spl/index.js.map +1 -1
  40. package/ts_build/src/utils/index.d.ts +2 -0
  41. package/ts_build/src/utils/index.d.ts.map +1 -1
  42. package/ts_build/src/utils/index.js +73 -1
  43. package/ts_build/src/utils/index.js.map +1 -1
  44. package/ts_build/src/validation/arc/index.d.ts +5 -0
  45. package/ts_build/src/validation/arc/index.d.ts.map +1 -0
  46. package/ts_build/src/validation/arc/index.js +12 -0
  47. package/ts_build/src/validation/arc/index.js.map +1 -0
  48. package/ts_build/src/validation/index.d.ts.map +1 -1
  49. package/ts_build/src/validation/index.js +2 -0
  50. package/ts_build/src/validation/index.js.map +1 -1
  51. package/ts_build/test/address.test.js +8 -0
  52. package/ts_build/test/address.test.js.map +1 -1
  53. package/ts_build/test/transactions.test.js +46 -0
  54. package/ts_build/test/transactions.test.js.map +1 -1
  55. package/ts_build/test/utils.test.js +165 -10
  56. package/ts_build/test/utils.test.js.map +1 -1
  57. package/ts_build/test/validation.test.js +17 -0
  58. package/ts_build/test/validation.test.js.map +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 BitPay, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitpay-labs/crypto-wallet-core",
3
- "version": "11.8.1",
3
+ "version": "11.10.0",
4
4
  "description": "A multi-currency support library for address derivation, private key creation, and transaction creation",
5
5
  "main": "./ts_build/src/index.js",
6
6
  "types": "./ts_build/src/index.d.ts",
@@ -17,8 +17,8 @@
17
17
  "fix:errors": "eslint --fix --quiet .",
18
18
  "fix:all": "eslint --fix .",
19
19
  "fix": "npm run fix:errors",
20
- "test": "npm run compile && mocha 'ts_build/test/**/*.test.js'",
21
- "coverage": "npm run compile && nyc mocha 'ts_build/test/**/*.test.js'",
20
+ "test": "npm run compile && mocha -n enable-source-maps 'ts_build/test/**/*.test.js'",
21
+ "coverage": "npm run compile && nyc mocha -n enable-source-maps 'ts_build/test/**/*.test.js'",
22
22
  "pub": "npm run compile && npm publish"
23
23
  },
24
24
  "keywords": [
@@ -45,10 +45,10 @@
45
45
  "author": "Micah Riggan",
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@bitpay-labs/bitcore-lib": "^11.8.1",
49
- "@bitpay-labs/bitcore-lib-cash": "^11.8.1",
48
+ "@bitpay-labs/bitcore-lib": "^11.9.0",
49
+ "@bitpay-labs/bitcore-lib-cash": "^11.9.0",
50
50
  "@bitpay-labs/bitcore-lib-doge": "^11.8.1",
51
- "@bitpay-labs/bitcore-lib-ltc": "^11.8.1",
51
+ "@bitpay-labs/bitcore-lib-ltc": "^11.9.0",
52
52
  "@solana-program/compute-budget": "0.7.0",
53
53
  "@solana-program/memo": "0.7.0",
54
54
  "@solana-program/system": "0.7.0",
@@ -70,5 +70,5 @@
70
70
  "nyc": "^17.1.0",
71
71
  "typescript": "5.7.3"
72
72
  },
73
- "gitHead": "e091d99915d099863ad3e78dbe867aa7780191e4"
73
+ "gitHead": "cccc9de4342d56cfcfc14d8b563d7542e4b08b6a"
74
74
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  export const UTXO_CHAINS = ['btc', 'bch', 'doge', 'ltc'];
3
- export const EVM_CHAINS = ['eth', 'matic', 'arb', 'base', 'op'];
3
+ export const EVM_CHAINS = ['eth', 'matic', 'arb', 'base', 'op', 'arc'];
4
4
  export const SVM_CHAINS = ['sol'];
5
5
  export const RIPPLE_CHAINS = ['xrp'];
6
6
  export const CHAINS = [...UTXO_CHAINS, ...EVM_CHAINS, ...SVM_CHAINS, ...RIPPLE_CHAINS];
@@ -12,7 +12,8 @@ export const EVM_CHAIN_DEFAULT_TESTNET = {
12
12
  MATIC: 'amoy',
13
13
  ARB: 'sepolia',
14
14
  BASE: 'sepolia',
15
- OP: 'sepolia'
15
+ OP: 'sepolia',
16
+ ARC: 'testnet'
16
17
  };
17
18
 
18
19
  export const EVM_CHAIN_NETWORK_TO_CHAIN_ID = {
@@ -22,6 +23,7 @@ export const EVM_CHAIN_NETWORK_TO_CHAIN_ID = {
22
23
  ARB_mainnet: 42161,
23
24
  BASE_mainnet: 8453,
24
25
  OP_mainnet: 10,
26
+ ARC_mainnet: 'unsupported',
25
27
  // ETH testnets
26
28
  ETH_holesky: 17000,
27
29
  ETH_sepolia: 11155111,
@@ -41,6 +43,8 @@ export const EVM_CHAIN_NETWORK_TO_CHAIN_ID = {
41
43
  // OP testnets
42
44
  OP_sepolia: 11155420,
43
45
  OP_goerli: 28528,
46
+ // ARC testnets
47
+ ARC_testnet: 5042002,
44
48
  // Regtests
45
49
  ETH_regtest: 1337,
46
50
  MATIC_regtest: 13375,
@@ -87,6 +87,17 @@ export const UNITS = {
87
87
  minDecimals: 2
88
88
  }
89
89
  },
90
+ arc: {
91
+ toSatoshis: 1e18,
92
+ full: {
93
+ maxDecimals: 6,
94
+ minDecimals: 6
95
+ },
96
+ short: {
97
+ maxDecimals: 6,
98
+ minDecimals: 2
99
+ }
100
+ },
90
101
  xrp: {
91
102
  toSatoshis: 1e6,
92
103
  full: {
@@ -23,6 +23,7 @@ const derivers: { [chain: string]: IDeriver } = {
23
23
  ARB: new ArbDeriver(),
24
24
  BASE: new BaseDeriver(),
25
25
  OP: new OpDeriver(),
26
+ ARC: new EthDeriver(),
26
27
  SOL: new SolDeriver()
27
28
  };
28
29
 
@@ -33,6 +33,9 @@ export const Paths = {
33
33
  BASE: {
34
34
  default: "m/44'/60'/",
35
35
  },
36
+ ARC: {
37
+ default: "m/44'/60'/",
38
+ },
36
39
  SOL: {
37
40
  default: "m/44'/501'/",
38
41
  },
@@ -41,6 +41,8 @@ const providers = {
41
41
  BASEERC20: new BASEERC20TxProvider(),
42
42
  OP: new OPTxProvider(),
43
43
  OPERC20: new OPERC20TxProvider(),
44
+ ARC: new ETHTxProvider('ARC'),
45
+ ARCERC20: new ERC20TxProvider('ARC'),
44
46
  SOL: new SOLTxProvider(),
45
47
  SOLSPL: new SPLTxProvider(),
46
48
  };
@@ -28,7 +28,7 @@ export class SPLTxProvider extends SOLTxProvider {
28
28
  mint: SolKit.address(tokenAddress),
29
29
  destination: SolKit.address(recipientAddress), // ATA address
30
30
  amount: BigInt(recipientAmount),
31
- decimals
31
+ decimals: Number(decimals)
32
32
  }));
33
33
  }
34
34
  }
@@ -164,7 +164,7 @@ interface CreateParams {
164
164
  // SPL token transfer fields (required for token transfers)
165
165
  tokenAddress: string; // mint address
166
166
  fromAta?: string;
167
- decimals?: number;
167
+ decimals?: number | string;
168
168
  }
169
169
 
170
170
  interface CreateRecoverNestedAssociatedTokenParams {
@@ -63,7 +63,10 @@ export function isHexString(str: string): boolean {
63
63
  if (typeof str !== 'string' || str === '') {
64
64
  return false;
65
65
  }
66
- const normalizedStr = str.toLowerCase().slice(0, 2) === '0x' ? str.toLowerCase().slice(2) : str.toLowerCase();
66
+ let normalizedStr = str.toLowerCase().slice(0, 2) === '0x' ? str.toLowerCase().slice(2) : str.toLowerCase();
67
+ if (normalizedStr.length % 2) {
68
+ normalizedStr = '0' + normalizedStr; // add leading zero if odd length
69
+ }
67
70
  return Buffer.from(normalizedStr, 'hex').toString('hex') === normalizedStr;
68
71
  }
69
72
 
@@ -91,4 +94,69 @@ export function toHex(input: number | string | bigint): string {
91
94
  }
92
95
  }
93
96
 
97
+ /**
98
+ * Returns the elements that are in arr1 but not in arr2.
99
+ * Note, this does a primitive comparison of elements.
100
+ * @returns An array containing the elements that are in arr1 but not in arr2
101
+ *
102
+ * @example difference([1,2,3], [2,3,4]) => [1]
103
+ * @example difference([{a:1}], [{a:1}]) => [{a:1}]
104
+ * @example const obj = {a:1};
105
+ * difference([obj], [obj]) => []
106
+ */
107
+ export function difference<T>(arr1: T[], arr2: T[]): T[] {
108
+ arr1 = arr1 || [];
109
+ arr2 = arr2 || [];
110
+ const arr2Set = new Set(arr2);
111
+ return arr1.filter(x => !arr2Set.has(x));
112
+ }
113
+
114
+ /**
115
+ * Deeply compares two objects for equality, handling circular references.
116
+ * @returns True if the objects are deeply equal, false otherwise
117
+ */
118
+ export function isEqual(obj1: object, obj2: object): boolean {
119
+ if (obj1 === obj2) return true;
120
+ if (obj1 == null || obj2 == null) return false;
121
+ if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
122
+ const stack = [obj1, obj2];
123
+ // Use a WeakSet to track already compared objects to handle circular references
124
+ const weakRefs = new WeakSet();
125
+ const isWeak = (val) => val !== null && (typeof val === 'object' || typeof val === 'function');
94
126
 
127
+ while (stack.length) {
128
+ const a = stack.pop();
129
+ const b = stack.pop();
130
+ if (a === b) continue;
131
+ if (a == null || b == null) return false;
132
+ if (typeof a !== 'object' || typeof b !== 'object') return false;
133
+ if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
134
+ if (a instanceof Date) {
135
+ if (!(b instanceof Date) || a.getTime() !== b.getTime()) return false;
136
+ continue;
137
+ }
138
+ if (a instanceof RegExp) {
139
+ if (!(b instanceof RegExp) || a.source !== b.source || a.flags !== b.flags) return false;
140
+ continue;
141
+ }
142
+ for (const key of Object.keys(a)) {
143
+ if (!(key in b)) return false;
144
+ if (isWeak(a[key])) {
145
+ if (weakRefs.has(a[key])) continue;
146
+ try { weakRefs.add(a[key]); } catch { /* ignore TypeError if a[key] is not a valid WeakSet key */ }
147
+ }
148
+
149
+ stack.push(a[key], b[key]);
150
+ }
151
+ const addtlBKeys = difference(Object.keys(b), Object.keys(a));
152
+ for (const key of addtlBKeys) {
153
+ if (!(key in a)) return false;
154
+ if (isWeak(b[key])) {
155
+ if (weakRefs.has(b[key])) continue;
156
+ try { weakRefs.add(b[key]); } catch { /* ignore TypeError if b[key] is not a valid WeakSet key */ }
157
+ }
158
+ stack.push(a[key], b[key]);
159
+ }
160
+ }
161
+ return true;
162
+ }
@@ -0,0 +1,8 @@
1
+ import { EthValidation } from '../eth';
2
+
3
+ export class ArcValidation extends EthValidation {
4
+ constructor() {
5
+ super();
6
+ this.regex = /arc/i;
7
+ }
8
+ }
@@ -1,4 +1,5 @@
1
1
  import { ArbValidation } from './arb';
2
+ import { ArcValidation } from './arc';
2
3
  import { BaseValidation } from './base';
3
4
  import { BchValidation } from './bch';
4
5
  import { BtcValidation } from './btc';
@@ -22,6 +23,7 @@ const validation: { [chain: string]: IValidation } = {
22
23
  ARB: new ArbValidation(),
23
24
  BASE: new BaseValidation(),
24
25
  OP: new OpValidation(),
26
+ ARC: new ArcValidation(),
25
27
  SOL: new SolValidation(),
26
28
  };
27
29
 
@@ -88,6 +88,18 @@ describe('Address Derivation', () => {
88
88
  expect(address).to.equal(expectedAddress);
89
89
  });
90
90
 
91
+ it('should be able to generate a valid ARC address', () => {
92
+ const xPub = 'xpub6D8rChqkgFuaZULuq2n6VrS4zB5Cmv24gcRc889dFRRgYAH1CGQmQZ9kcPfMAfWGPnyMd1X5foBYFmJ5ZPfvwhm6tXjaY13ao1rQHRtkKDv';
93
+ // 'select scout crash enforce riot rival spring whale hollow radar rule sentence';
94
+
95
+ const path = Deriver.pathFor('ARC', 'testnet');
96
+ expect(path).to.equal("m/44'/60'/0'");
97
+
98
+ const address = Deriver.deriveAddress('ARC', 'testnet', xPub, 0, false);
99
+ const expectedAddress = '0x9dbfE221A6EEa27a0e2f52961B339e95426931F9';
100
+ expect(address).to.equal(expectedAddress);
101
+ });
102
+
91
103
  it('should be able to generate a valid ETH address, privKey, pubKey', () => {
92
104
  const privKey = 'xprv9ypBjKErGMqCdzd44hfSdy1Vk6PGtU3si8ogZcow7rA23HTxMi9XfT99EKmiNdLMr9BAZ9S8ZKCYfN1eCmzYSmXYHje1jnYQseV1VJDDfdS';
93
105
 
@@ -4,7 +4,7 @@ import bitcoreLib from '@bitpay-labs/bitcore-lib';
4
4
  import bitcoreLibCash from '@bitpay-labs/bitcore-lib-cash';
5
5
  import bitcoreLibDoge from '@bitpay-labs/bitcore-lib-doge';
6
6
  import bitcoreLibLtc from '@bitpay-labs/bitcore-lib-ltc';
7
- import { Transactions } from '../src';
7
+ import { Constants, Transactions } from '../src';
8
8
 
9
9
  describe('Transaction', function() {
10
10
  describe('create', () => {
@@ -1751,6 +1751,59 @@ describe('Transaction', function() {
1751
1751
  });
1752
1752
  });
1753
1753
 
1754
+ describe('ARC EVM support', () => {
1755
+ it('should get the correct testnet chainId', () => {
1756
+ const testnetId = Transactions.get({ chain: 'ARC' }).getChainId('testnet');
1757
+ expect(testnetId).to.equal(5042002);
1758
+ });
1759
+
1760
+ it('should create an ARC native transaction using 18-decimal base units', () => {
1761
+ const tx = Transactions.create({
1762
+ chain: 'ARC',
1763
+ recipients: [{ address: '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A', amount: '1000000000000000000' }],
1764
+ nonce: 0,
1765
+ gasPrice: 1,
1766
+ gasLimit: 21000,
1767
+ network: 'testnet',
1768
+ data: '0x'
1769
+ });
1770
+ const parsed = ethers.Transaction.from(tx);
1771
+ expect(parsed.chainId).to.equal(5042002n);
1772
+ expect(parsed.value).to.equal(1000000000000000000n);
1773
+ });
1774
+
1775
+ it('should create an ARC ERC20 transaction using ARC testnet chainId', () => {
1776
+ const tokenAddress = '0x3600000000000000000000000000000000000000';
1777
+ const recipient = '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A';
1778
+ const amount = '1000000';
1779
+ const tx = Transactions.create({
1780
+ chain: 'ARCERC20',
1781
+ recipients: [{ address: recipient, amount }],
1782
+ nonce: 0,
1783
+ gasPrice: 1,
1784
+ gasLimit: 200000,
1785
+ network: 'testnet',
1786
+ tokenAddress
1787
+ });
1788
+ const parsed = ethers.Transaction.from(tx);
1789
+
1790
+ expect(parsed.chainId).to.equal(5042002n);
1791
+ expect(parsed.to).to.equal(ethers.getAddress(tokenAddress));
1792
+ expect(parsed.value).to.equal(0n);
1793
+ expect(parsed.data).to.equal(
1794
+ '0xa9059cbb' +
1795
+ '00000000000000000000000037d7b3bbd88efde6a93cf74d2f5b0385d3e3b08a' +
1796
+ '00000000000000000000000000000000000000000000000000000000000f4240'
1797
+ );
1798
+ });
1799
+
1800
+ it('should define ARC native units as 18 decimals', () => {
1801
+ expect(Constants.UNITS.arc.toSatoshis).to.equal(1e18);
1802
+ expect(Constants.UNITS.arc.full.maxDecimals).to.equal(6);
1803
+ expect(Constants.UNITS.arc.full.minDecimals).to.equal(6);
1804
+ });
1805
+ });
1806
+
1754
1807
  describe('ETH _toHex', function() {
1755
1808
  it('should convert number to hex string', function() {
1756
1809
  const ETHTxProvider = Transactions.get({ chain: 'ETH' });
@@ -6,53 +6,59 @@ describe('Utils', function() {
6
6
  it('should return true for valid prefixed hex string', function() {
7
7
  const str = '0xabcdef123456';
8
8
  const result = utils.isHexString(str);
9
- expect(result).to.be.true;
9
+ expect(result).to.equal(true);
10
10
  });
11
11
 
12
12
  it('should return true for valid non-prefixed hex string', function() {
13
13
  const str = 'abcdef123456';
14
14
  const result = utils.isHexString(str);
15
+ expect(result).to.equal(true);
16
+ });
17
+
18
+ it('should return true for valid odd-length hex string', function() {
19
+ const str = 'abcdef12345';
20
+ const result = utils.isHexString(str);
15
21
  expect(result).to.be.true;
16
22
  });
17
23
 
18
24
  it('should return false for invalid prefixed hex string', function() {
19
25
  const str = '0xabc123g';
20
26
  const result = utils.isHexString(str);
21
- expect(result).to.be.false;
27
+ expect(result).to.equal(false);
22
28
  });
23
29
 
24
30
  it('should return false for string with 0x somewhere in the middle', function() {
25
31
  const str = 'abc0x123';
26
32
  const result = utils.isHexString(str);
27
- expect(result).to.be.false;
33
+ expect(result).to.equal(false);
28
34
  });
29
35
 
30
36
  it('should return false for invalid non-prefixed hex string', function() {
31
37
  const str = 'abc123g';
32
38
  const result = utils.isHexString(str);
33
- expect(result).to.be.false;
39
+ expect(result).to.equal(false);
34
40
  });
35
41
 
36
42
  it('should return false for empty string', function() {
37
43
  const str = '';
38
44
  const result = utils.isHexString(str);
39
- expect(result).to.be.false;
45
+ expect(result).to.equal(false);
40
46
  });
41
47
 
42
48
  it('should return false for null/undefined input', function() {
43
- expect(utils.isHexString(null)).to.be.false;
44
- expect(utils.isHexString(undefined as any)).to.be.false;
49
+ expect(utils.isHexString(null)).to.equal(false);
50
+ expect(utils.isHexString(undefined as any)).to.equal(false);
45
51
  });
46
52
 
47
53
  it('should return false for non-string input', function() {
48
- expect(utils.isHexString(123 as any)).to.be.false;
49
- expect(utils.isHexString({} as any)).to.be.false;
54
+ expect(utils.isHexString(123 as any)).to.equal(false);
55
+ expect(utils.isHexString({} as any)).to.equal(false);
50
56
  });
51
57
 
52
58
  it('should return false for octal string', function() {
53
59
  const str = '0o01234567';
54
60
  const result = utils.isHexString(str);
55
- expect(result).to.be.false;
61
+ expect(result).to.equal(false);
56
62
  });
57
63
  });
58
64
 
@@ -118,4 +124,184 @@ describe('Utils', function() {
118
124
  expect(() => utils.toHex(input)).to.throw('Invalid input for toHex: NaN');
119
125
  });
120
126
  });
127
+
128
+ describe('difference', function() {
129
+ it('should return items from first array that are not in second array', function() {
130
+ const arr1 = [1, 2, 3, 4];
131
+ const arr2 = [2, 4, 6];
132
+ const result = utils.difference(arr1, arr2);
133
+ expect(result).to.deep.equal([1, 3]);
134
+ });
135
+
136
+ it('should consider different pointer references as a difference', function() {
137
+ const arr1 = [1, 2, 3, {}];
138
+ const arr2 = [1, 2, 3, {}];
139
+ const result = utils.difference(arr1, arr2);
140
+ expect(result).to.deep.equal([{}]);
141
+ });
142
+
143
+ it('should consider same pointer references as no difference', function() {
144
+ const obj = {};
145
+ const arr1 = [1, 2, 3, obj];
146
+ const arr2 = [1, 2, 3, obj];
147
+ const result = utils.difference(arr1, arr2);
148
+ expect(result).to.deep.equal([]);
149
+ });
150
+
151
+ it('should remove all matching duplicates from first array', function() {
152
+ const arr1 = ['a', 'b', 'b', 'c'];
153
+ const arr2 = ['b'];
154
+ const result = utils.difference(arr1, arr2);
155
+ expect(result).to.deep.equal(['a', 'c']);
156
+ });
157
+
158
+ it('should return empty array when first array is null/undefined', function() {
159
+ expect(utils.difference(null as any, [1, 2])).to.deep.equal([]);
160
+ expect(utils.difference(undefined as any, [1, 2])).to.deep.equal([]);
161
+ });
162
+
163
+ it('should return first array unchanged when second array is null/undefined', function() {
164
+ expect(utils.difference([1, 2, 3], null as any)).to.deep.equal([1, 2, 3]);
165
+ expect(utils.difference([1, 2, 3], undefined as any)).to.deep.equal([1, 2, 3]);
166
+ });
167
+
168
+ it('should not mutate input arrays', function() {
169
+ const arr1 = [1, 2, 3];
170
+ const arr2 = [2];
171
+ const arr1Copy = [...arr1];
172
+ const arr2Copy = [...arr2];
173
+
174
+ utils.difference(arr1, arr2);
175
+
176
+ expect(arr1).to.deep.equal(arr1Copy);
177
+ expect(arr2).to.deep.equal(arr2Copy);
178
+ });
179
+ });
180
+
181
+ describe('isEqual', function() {
182
+ it('should return true for the same object reference', function() {
183
+ const obj = { a: 1, b: { c: 2 } };
184
+ expect(utils.isEqual(obj, obj)).to.equal(true);
185
+ });
186
+
187
+ it('should return false when one object is null', function() {
188
+ expect(utils.isEqual(null as any, { a: 1 })).to.equal(false);
189
+ expect(utils.isEqual({ a: 1 }, null as any)).to.equal(false);
190
+ });
191
+
192
+ it('should return false for different primitive values', function() {
193
+ const obj1 = { a: 1, b: 'hello' };
194
+ const obj2 = { a: 2, b: 'hello' };
195
+ expect(utils.isEqual(obj1, obj2)).to.equal(false);
196
+ });
197
+
198
+ it('should return false when one object has additional keys', function() {
199
+ const obj1 = { a: 1 };
200
+ const obj2 = { a: 1, b: 2 };
201
+ expect(utils.isEqual(obj1, obj2)).to.equal(false);
202
+ expect(utils.isEqual(obj2, obj1)).to.equal(false);
203
+ });
204
+
205
+ it('should return false for different nested object values', function() {
206
+ const obj1 = { a: { b: 1 } };
207
+ const obj2 = { a: { b: 2 } };
208
+ expect(utils.isEqual(obj1, obj2)).to.equal(false);
209
+ });
210
+
211
+ it('should handle implicit vs explicit undefined values', function() {
212
+ const obj1 = {}; // obj1.a is implicitly undefined
213
+ const obj2 = { a: undefined }; // obj2.a is explicitly undefined
214
+ expect(utils.isEqual(obj1, obj2)).to.equal(false);
215
+ expect(utils.isEqual(obj2, obj1)).to.equal(false);
216
+
217
+ const obj3 = { a: undefined };
218
+ expect(utils.isEqual(obj2, obj3)).to.equal(true);
219
+ });
220
+
221
+ it('should handle null vs undefined values correctly', function() {
222
+ const obj1 = { a: null };
223
+ const obj2 = { a: undefined };
224
+ expect(utils.isEqual(obj1, obj2)).to.equal(false);
225
+ });
226
+
227
+ it('should prevent infinite recursion on circular references', function() {
228
+ const obj1: any = { a: 1 };
229
+ obj1.self = obj1;
230
+
231
+ const obj2: any = { a: 1 };
232
+ obj2.self = obj2;
233
+
234
+ expect(utils.isEqual(obj1, obj2)).to.equal(true);
235
+
236
+ obj2.extra = 'value';
237
+ expect(utils.isEqual(obj1, obj2)).to.equal(false);
238
+ });
239
+
240
+ it('should handle large complex objects (stress test)', function() {
241
+ const buildLargeObject = () => {
242
+ const root: any = {
243
+ meta: {
244
+ chain: 'eth',
245
+ network: 'mainnet',
246
+ createdAt: '2026-05-06T00:00:00.000Z'
247
+ },
248
+ buckets: [],
249
+ matrix: [],
250
+ lookup: {}
251
+ };
252
+
253
+ for (let i = 0; i < 120; i++) {
254
+ const bucket = {
255
+ id: i,
256
+ name: `bucket-${i}`,
257
+ flags: {
258
+ active: i % 2 === 0,
259
+ archived: i % 5 === 0
260
+ },
261
+ balances: [],
262
+ tokens: []
263
+ } as any;
264
+
265
+ for (let j = 0; j < 20; j++) {
266
+ bucket.balances.push({
267
+ height: j,
268
+ satoshis: i * 100000 + j,
269
+ confirmations: (i + j) % 18
270
+ });
271
+ bucket.tokens.push({
272
+ symbol: `T${j}`,
273
+ amount: `${i * j}`,
274
+ decimals: 18,
275
+ tags: [`g${i % 4}`, `t${j % 7}`]
276
+ });
277
+ }
278
+
279
+ root.buckets.push(bucket);
280
+ root.lookup[`k-${i}`] = {
281
+ index: i,
282
+ ref: `bucket-${i}`,
283
+ checksums: [i * 3, i * 7, i * 11]
284
+ };
285
+ }
286
+
287
+ for (let r = 0; r < 40; r++) {
288
+ const row: number[] = [];
289
+ for (let c = 0; c < 40; c++) {
290
+ row.push(r * 40 + c);
291
+ }
292
+ root.matrix.push(row);
293
+ }
294
+
295
+ return root;
296
+ };
297
+
298
+ const left = buildLargeObject();
299
+ const right = buildLargeObject();
300
+
301
+ expect(utils.isEqual(left, right)).to.equal(true);
302
+
303
+ right.buckets[119].tokens[19].tags[1] = 'mutated-tag';
304
+ expect(utils.isEqual(left, right)).to.equal(false);
305
+ });
306
+ });
121
307
  });
@@ -239,6 +239,27 @@ describe('Address Validation', () => {
239
239
  expect(inValidMaticPrefix).to.equal(false);
240
240
  });
241
241
 
242
+ it('should validate ARC addresses', async () => {
243
+ const address = '37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A';
244
+ const prefixedAddress = `0x${address}`;
245
+
246
+ expect(await Validation.validateAddress('ARC', 'testnet', address)).to.equal(true);
247
+ expect(await Validation.validateAddress('ARC', 'testnet', prefixedAddress)).to.equal(true);
248
+ expect(await Validation.validateAddress('ARC', 'testnet', address.slice(1))).to.equal(false);
249
+ });
250
+
251
+ it('should validate ARC URIs', async () => {
252
+ const address = '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A';
253
+ const uri = `arc:${address}`;
254
+ const uriParams = `${uri}?value=123&gasPrice=123&gas=123&gasLimit=123`;
255
+
256
+ expect(await Validation.validateUri('ARC', uri)).to.equal(true);
257
+ expect(await Validation.validateUri('ARC', uriParams)).to.equal(true);
258
+ expect(await Validation.validateUri('ARC', `${uri}?value=123`)).to.equal(true);
259
+ expect(await Validation.validateUri('ARC', address)).to.equal(false);
260
+ expect(await Validation.validateUri('ARC', `${uri}?value=invalid&gasLimit=123&gas=123`)).to.equal(false);
261
+ });
262
+
242
263
  it('should be able to validate a SOL address', async () => {
243
264
  const isValidAddress = await Validation.validateAddress('SOL', 'mainnet', solAddress);
244
265
  expect(isValidAddress).to.equal(true);
@@ -10,6 +10,7 @@ export declare const EVM_CHAIN_DEFAULT_TESTNET: {
10
10
  ARB: string;
11
11
  BASE: string;
12
12
  OP: string;
13
+ ARC: string;
13
14
  };
14
15
  export declare const EVM_CHAIN_NETWORK_TO_CHAIN_ID: {
15
16
  ETH_mainnet: number;
@@ -17,6 +18,7 @@ export declare const EVM_CHAIN_NETWORK_TO_CHAIN_ID: {
17
18
  ARB_mainnet: number;
18
19
  BASE_mainnet: number;
19
20
  OP_mainnet: number;
21
+ ARC_mainnet: string;
20
22
  ETH_holesky: number;
21
23
  ETH_sepolia: number;
22
24
  ETH_goerli: number;
@@ -31,12 +33,13 @@ export declare const EVM_CHAIN_NETWORK_TO_CHAIN_ID: {
31
33
  BASE_goerli: number;
32
34
  OP_sepolia: number;
33
35
  OP_goerli: number;
36
+ ARC_testnet: number;
34
37
  ETH_regtest: number;
35
38
  MATIC_regtest: number;
36
39
  ARB_regtest: number;
37
40
  BASE_regtest: number;
38
41
  OP_regtest: number;
39
42
  };
40
- export declare const EVM_CHAIN_ID_TO_CHAIN_NETWORK: Record<number, "ETH_mainnet" | "MATIC_mainnet" | "ARB_mainnet" | "BASE_mainnet" | "OP_mainnet" | "ETH_holesky" | "ETH_sepolia" | "ETH_goerli" | "ETH_kovan" | "ETH_ropsten" | "ETH_rinkeby" | "MATIC_mumbai" | "MATIC_amoy" | "ARB_sepolia" | "ARB_goerli" | "BASE_sepolia" | "BASE_goerli" | "OP_sepolia" | "OP_goerli" | "ETH_regtest" | "MATIC_regtest" | "ARB_regtest" | "BASE_regtest" | "OP_regtest">;
41
- export declare const EVM_CHAIN_ID_TO_CHAIN: Record<number, "ETH_mainnet" | "MATIC_mainnet" | "ARB_mainnet" | "BASE_mainnet" | "OP_mainnet" | "ETH_holesky" | "ETH_sepolia" | "ETH_goerli" | "ETH_kovan" | "ETH_ropsten" | "ETH_rinkeby" | "MATIC_mumbai" | "MATIC_amoy" | "ARB_sepolia" | "ARB_goerli" | "BASE_sepolia" | "BASE_goerli" | "OP_sepolia" | "OP_goerli" | "ETH_regtest" | "MATIC_regtest" | "ARB_regtest" | "BASE_regtest" | "OP_regtest">;
43
+ export declare const EVM_CHAIN_ID_TO_CHAIN_NETWORK: Record<string | number, "ETH_mainnet" | "MATIC_mainnet" | "ARB_mainnet" | "BASE_mainnet" | "OP_mainnet" | "ARC_mainnet" | "ETH_holesky" | "ETH_sepolia" | "ETH_goerli" | "ETH_kovan" | "ETH_ropsten" | "ETH_rinkeby" | "MATIC_mumbai" | "MATIC_amoy" | "ARB_sepolia" | "ARB_goerli" | "BASE_sepolia" | "BASE_goerli" | "OP_sepolia" | "OP_goerli" | "ARC_testnet" | "ETH_regtest" | "MATIC_regtest" | "ARB_regtest" | "BASE_regtest" | "OP_regtest">;
44
+ export declare const EVM_CHAIN_ID_TO_CHAIN: Record<string | number, "ETH_mainnet" | "MATIC_mainnet" | "ARB_mainnet" | "BASE_mainnet" | "OP_mainnet" | "ARC_mainnet" | "ETH_holesky" | "ETH_sepolia" | "ETH_goerli" | "ETH_kovan" | "ETH_ropsten" | "ETH_rinkeby" | "MATIC_mumbai" | "MATIC_amoy" | "ARB_sepolia" | "ARB_goerli" | "BASE_sepolia" | "BASE_goerli" | "OP_sepolia" | "OP_goerli" | "ARC_testnet" | "ETH_regtest" | "MATIC_regtest" | "ARB_regtest" | "BASE_regtest" | "OP_regtest">;
42
45
  //# sourceMappingURL=chains.d.ts.map