@snapshot-labs/snapshot.js 0.12.12 → 0.12.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.
@@ -1486,6 +1486,7 @@ var starknet = /*#__PURE__*/Object.freeze({
1486
1486
  'default': verify
1487
1487
  });
1488
1488
 
1489
+ const ERC6492_DETECTION_SUFFIX = '6492649264926492649264926492649264926492649264926492649264926492';
1489
1490
  function isEqual(a, b) {
1490
1491
  return a.toLowerCase() === b.toLowerCase();
1491
1492
  }
@@ -1504,6 +1505,28 @@ function verify$1(address_1, sig_1, data_1) {
1504
1505
  catch (e) { }
1505
1506
  const provider = getProvider(network, options);
1506
1507
  const hash = getHash$1(data);
1508
+ // Handle EIP-6492
1509
+ // https://eips.ethereum.org/EIPS/eip-6492
1510
+ //
1511
+ // We can actually replace verifyTypedData and verifyDefault with the following code,
1512
+ // but https://github.com/AmbireTech/signature-validator/blob/main/contracts/DeploylessUniversalSigValidator.sol
1513
+ // also can send an extra network request to the provider. (with verifyTypedData we don't send any extra request)
1514
+ //
1515
+ if (sig.endsWith(ERC6492_DETECTION_SUFFIX)) {
1516
+ try {
1517
+ return ('0x01' ===
1518
+ (yield provider.call({
1519
+ data: bytes.concat([
1520
+ '0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572',
1521
+ new abi.AbiCoder().encode(['address', 'bytes32', 'bytes'], [address, bytes.arrayify(hash), sig])
1522
+ ])
1523
+ })));
1524
+ }
1525
+ catch (error) {
1526
+ return false;
1527
+ }
1528
+ }
1529
+ // Handle EIP-1271
1507
1530
  if (yield verifyDefault(address, sig, hash, provider))
1508
1531
  return true;
1509
1532
  return yield verifyOldVersion(address, sig, hash, provider);
@@ -2480,6 +2503,21 @@ var networks = {
2480
2503
  },
2481
2504
  start: 4219343,
2482
2505
  logo: "ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"
2506
+ },
2507
+ "2192": {
2508
+ key: "2192",
2509
+ name: "SnaxChain",
2510
+ shortName: "mainnet",
2511
+ chainId: 2192,
2512
+ network: "mainnet",
2513
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2514
+ rpc: [
2515
+ ],
2516
+ explorer: {
2517
+ url: "https://explorer.snaxchain.io"
2518
+ },
2519
+ start: 1554893,
2520
+ logo: "ipfs://bafkreibzz757piho2llzkbiszpvalf5k5hpmxcwhvrmgp7vpz2vp4vj7ly"
2483
2521
  },
2484
2522
  "2221": {
2485
2523
  key: "2221",
@@ -3156,7 +3194,7 @@ var networks = {
3156
3194
  "0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"
3157
3195
  ],
3158
3196
  ensNameWrapper: "0x0635513f179D50A207757E05759CbD106d7dFcE8",
3159
- ensSubgraph: "https://api.studio.thegraph.com/proxy/49574/enssepolia/version/latest",
3197
+ ensSubgraph: "https://subgrapher.snapshot.org/subgraph/arbitrum/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV",
3160
3198
  explorer: {
3161
3199
  url: "https://sepolia.etherscan.io",
3162
3200
  apiUrl: "https://api-sepolia.etherscan.io"
@@ -1,6 +1,6 @@
1
1
  import fetch from 'cross-fetch';
2
2
  import { getAddress, isAddress } from '@ethersproject/address';
3
- import { Interface } from '@ethersproject/abi';
3
+ import { AbiCoder, Interface } from '@ethersproject/abi';
4
4
  import { Contract as Contract$1 } from '@ethersproject/contracts';
5
5
  import { parseUnits } from '@ethersproject/units';
6
6
  import { _TypedDataEncoder, namehash, ensNormalize } from '@ethersproject/hash';
@@ -10,7 +10,7 @@ import addFormats from 'ajv-formats';
10
10
  import addErrors from 'ajv-errors';
11
11
  import set from 'lodash.set';
12
12
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
13
- import { hexlify, arrayify } from '@ethersproject/bytes';
13
+ import { hexlify, concat, arrayify } from '@ethersproject/bytes';
14
14
  import { Contract, RpcProvider, typedData, validateAndParseAddress } from 'starknet';
15
15
  import { BigNumber } from '@ethersproject/bignumber';
16
16
  import { verifyTypedData } from '@ethersproject/wallet';
@@ -1476,6 +1476,7 @@ var starknet = /*#__PURE__*/Object.freeze({
1476
1476
  'default': verify
1477
1477
  });
1478
1478
 
1479
+ const ERC6492_DETECTION_SUFFIX = '6492649264926492649264926492649264926492649264926492649264926492';
1479
1480
  function isEqual(a, b) {
1480
1481
  return a.toLowerCase() === b.toLowerCase();
1481
1482
  }
@@ -1494,6 +1495,28 @@ function verify$1(address_1, sig_1, data_1) {
1494
1495
  catch (e) { }
1495
1496
  const provider = getProvider(network, options);
1496
1497
  const hash = getHash$1(data);
1498
+ // Handle EIP-6492
1499
+ // https://eips.ethereum.org/EIPS/eip-6492
1500
+ //
1501
+ // We can actually replace verifyTypedData and verifyDefault with the following code,
1502
+ // but https://github.com/AmbireTech/signature-validator/blob/main/contracts/DeploylessUniversalSigValidator.sol
1503
+ // also can send an extra network request to the provider. (with verifyTypedData we don't send any extra request)
1504
+ //
1505
+ if (sig.endsWith(ERC6492_DETECTION_SUFFIX)) {
1506
+ try {
1507
+ return ('0x01' ===
1508
+ (yield provider.call({
1509
+ data: concat([
1510
+ '0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572',
1511
+ new AbiCoder().encode(['address', 'bytes32', 'bytes'], [address, arrayify(hash), sig])
1512
+ ])
1513
+ })));
1514
+ }
1515
+ catch (error) {
1516
+ return false;
1517
+ }
1518
+ }
1519
+ // Handle EIP-1271
1497
1520
  if (yield verifyDefault(address, sig, hash, provider))
1498
1521
  return true;
1499
1522
  return yield verifyOldVersion(address, sig, hash, provider);
@@ -2470,6 +2493,21 @@ var networks = {
2470
2493
  },
2471
2494
  start: 4219343,
2472
2495
  logo: "ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"
2496
+ },
2497
+ "2192": {
2498
+ key: "2192",
2499
+ name: "SnaxChain",
2500
+ shortName: "mainnet",
2501
+ chainId: 2192,
2502
+ network: "mainnet",
2503
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
2504
+ rpc: [
2505
+ ],
2506
+ explorer: {
2507
+ url: "https://explorer.snaxchain.io"
2508
+ },
2509
+ start: 1554893,
2510
+ logo: "ipfs://bafkreibzz757piho2llzkbiszpvalf5k5hpmxcwhvrmgp7vpz2vp4vj7ly"
2473
2511
  },
2474
2512
  "2221": {
2475
2513
  key: "2221",
@@ -3146,7 +3184,7 @@ var networks = {
3146
3184
  "0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"
3147
3185
  ],
3148
3186
  ensNameWrapper: "0x0635513f179D50A207757E05759CbD106d7dFcE8",
3149
- ensSubgraph: "https://api.studio.thegraph.com/proxy/49574/enssepolia/version/latest",
3187
+ ensSubgraph: "https://subgrapher.snapshot.org/subgraph/arbitrum/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV",
3150
3188
  explorer: {
3151
3189
  url: "https://sepolia.etherscan.io",
3152
3190
  apiUrl: "https://api-sepolia.etherscan.io"