@snapshot-labs/snapshot.js 0.14.12 → 0.14.14

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.
@@ -12,7 +12,6 @@ var addErrors = require('ajv-errors');
12
12
  var providers = require('@ethersproject/providers');
13
13
  var starknet$1 = require('starknet');
14
14
  var bytes = require('@ethersproject/bytes');
15
- var bignumber = require('@ethersproject/bignumber');
16
15
  var wallet = require('@ethersproject/wallet');
17
16
  var abi = require('@ethersproject/abi');
18
17
  var set = require('lodash.set');
@@ -1476,7 +1475,7 @@ var networks = {
1476
1475
  url: "https://basescan.org"
1477
1476
  },
1478
1477
  start: 5022,
1479
- logo: "ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"
1478
+ logo: "ipfs://bafkreid4ek4gnj6ccxl3yubwj2wr3d5t6dqelvvh4hv5wo5eldkqs725ri"
1480
1479
  },
1481
1480
  "9001": {
1482
1481
  key: "9001",
@@ -1929,7 +1928,38 @@ var networks = {
1929
1928
  url: "https://base-sepolia.blockscout.com"
1930
1929
  },
1931
1930
  start: 1059647,
1932
- logo: "ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",
1931
+ logo: "ipfs://bafkreid4ek4gnj6ccxl3yubwj2wr3d5t6dqelvvh4hv5wo5eldkqs725ri",
1932
+ testnet: true
1933
+ },
1934
+ "88811": {
1935
+ key: "88811",
1936
+ name: "Unit Zero",
1937
+ shortName: "mainnet",
1938
+ chainId: 88811,
1939
+ network: "mainnet",
1940
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
1941
+ rpc: [
1942
+ ],
1943
+ explorer: {
1944
+ url: "https://explorer.unit0.dev"
1945
+ },
1946
+ start: 9727,
1947
+ logo: "ipfs://bafkreihbmy3rqlammea35nniemipxrwcgitzkiahs6nlrfjunnvgfnakp4"
1948
+ },
1949
+ "88817": {
1950
+ key: "88817",
1951
+ name: "Unit Zero testnet",
1952
+ shortName: "testnet",
1953
+ chainId: 88817,
1954
+ network: "testnet",
1955
+ multicall: "0x017181efb3bDB325C17800799b33Ae80B395024c",
1956
+ rpc: [
1957
+ ],
1958
+ explorer: {
1959
+ url: "https://explorer-testnet.unit0.dev"
1960
+ },
1961
+ start: 3973744,
1962
+ logo: "ipfs://bafkreihbmy3rqlammea35nniemipxrwcgitzkiahs6nlrfjunnvgfnakp4",
1933
1963
  testnet: true
1934
1964
  },
1935
1965
  "314159": {
@@ -2286,34 +2316,6 @@ const RPC_URLS = {
2286
2316
  SN_MAIN: (_b = (_a = networks[starknet$1.constants.StarknetChainId.SN_MAIN]) === null || _a === void 0 ? void 0 : _a.rpc) === null || _b === void 0 ? void 0 : _b[0],
2287
2317
  SN_SEPOLIA: (_d = (_c = networks[starknet$1.constants.StarknetChainId.SN_SEPOLIA]) === null || _c === void 0 ? void 0 : _c.rpc) === null || _d === void 0 ? void 0 : _d[0]
2288
2318
  };
2289
- const ABI = [
2290
- {
2291
- name: 'argent::common::account::IAccount',
2292
- type: 'interface',
2293
- items: [
2294
- {
2295
- name: 'is_valid_signature',
2296
- type: 'function',
2297
- inputs: [
2298
- {
2299
- name: 'hash',
2300
- type: 'core::felt252'
2301
- },
2302
- {
2303
- name: 'signature',
2304
- type: 'core::array::Array::<core::felt252>'
2305
- }
2306
- ],
2307
- outputs: [
2308
- {
2309
- type: 'core::felt252'
2310
- }
2311
- ],
2312
- state_mutability: 'view'
2313
- }
2314
- ]
2315
- }
2316
- ];
2317
2319
  function getProvider$1(network, options) {
2318
2320
  var _a;
2319
2321
  if (!RPC_URLS[network])
@@ -2329,40 +2331,14 @@ function getHash(data, address) {
2329
2331
  const { domain, types, primaryType, message } = data;
2330
2332
  return starknet$1.typedData.getMessageHash({ types, primaryType, domain, message }, address);
2331
2333
  }
2332
- /**
2333
- * Processes a StarkNet signature array and returns the appropriate signature format
2334
- * for contract verification.
2335
- * Returns the r ands values for each signature in the array.
2336
- *
2337
- * Handles the following cases:
2338
- * - 2-item array: Standard signature, returns as-is.
2339
- * - 3-item array: Some wallets (e.g., Braavos) may return a 3-item array; returns the last two items.
2340
- * - Multi-signer array: For multisig accounts, the array may contain multiple signatures;
2341
- * this function extracts the relevant signature pairs.
2342
- *
2343
- * @param {string[]} sig - The signature array to process. Must have at least 2 items.
2344
- * @returns {string[]} The processed signature array suitable for contract verification.
2345
- * @throws {Error} If the signature array has fewer than 2 items.
2346
- */
2347
- function getSignatureArray(sig) {
2348
- if (sig.length < 2) {
2349
- throw new Error('Invalid signature format');
2350
- }
2351
- if (sig.length <= 3) {
2352
- return sig.slice(-2);
2353
- }
2354
- const results = [];
2355
- for (let i = 1; i < sig.length; i += 4) {
2356
- results.push(sig[i + 2], sig[i + 3]);
2357
- }
2358
- return results;
2359
- }
2360
2334
  function verify(address_1, sig_1, data_1) {
2361
2335
  return __awaiter(this, arguments, void 0, function* (address, sig, data, network = 'SN_MAIN', options = {}) {
2362
2336
  try {
2363
- const contractAccount = new starknet$1.Contract(ABI, address, getProvider$1(network, options));
2364
- const result = yield contractAccount.is_valid_signature(getHash(data, address), getSignatureArray(sig));
2365
- return bignumber.BigNumber.from(result).eq(bignumber.BigNumber.from('370462705988'));
2337
+ const provider = getProvider$1(network, options);
2338
+ // Check if the contract is deployed
2339
+ // Will throw on non-deployed contract
2340
+ yield provider.getClassAt(address);
2341
+ return provider.verifyMessageInStarknet(data, sig, address);
2366
2342
  }
2367
2343
  catch (e) {
2368
2344
  if (e.message.includes('Contract not found')) {
@@ -1,5 +1,5 @@
1
1
  import crossFetch from 'cross-fetch';
2
- import { Contract as Contract$1 } from '@ethersproject/contracts';
2
+ import { Contract } from '@ethersproject/contracts';
3
3
  import { isAddress, getAddress } from '@ethersproject/address';
4
4
  import { parseUnits } from '@ethersproject/units';
5
5
  import { _TypedDataEncoder, namehash, ensNormalize } from '@ethersproject/hash';
@@ -8,9 +8,8 @@ import Ajv from 'ajv';
8
8
  import addFormats from 'ajv-formats';
9
9
  import addErrors from 'ajv-errors';
10
10
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
11
- import { RpcProvider, constants as constants$1, Contract, typedData, transaction, uint256, shortString, num, validateAndParseAddress } from 'starknet';
11
+ import { RpcProvider, constants as constants$1, typedData, transaction, uint256, shortString, num, validateAndParseAddress } from 'starknet';
12
12
  import { hexlify, concat, arrayify } from '@ethersproject/bytes';
13
- import { BigNumber } from '@ethersproject/bignumber';
14
13
  import { verifyTypedData } from '@ethersproject/wallet';
15
14
  import { AbiCoder, Interface } from '@ethersproject/abi';
16
15
  import set from 'lodash.set';
@@ -1466,7 +1465,7 @@ var networks = {
1466
1465
  url: "https://basescan.org"
1467
1466
  },
1468
1467
  start: 5022,
1469
- logo: "ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"
1468
+ logo: "ipfs://bafkreid4ek4gnj6ccxl3yubwj2wr3d5t6dqelvvh4hv5wo5eldkqs725ri"
1470
1469
  },
1471
1470
  "9001": {
1472
1471
  key: "9001",
@@ -1919,7 +1918,38 @@ var networks = {
1919
1918
  url: "https://base-sepolia.blockscout.com"
1920
1919
  },
1921
1920
  start: 1059647,
1922
- logo: "ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",
1921
+ logo: "ipfs://bafkreid4ek4gnj6ccxl3yubwj2wr3d5t6dqelvvh4hv5wo5eldkqs725ri",
1922
+ testnet: true
1923
+ },
1924
+ "88811": {
1925
+ key: "88811",
1926
+ name: "Unit Zero",
1927
+ shortName: "mainnet",
1928
+ chainId: 88811,
1929
+ network: "mainnet",
1930
+ multicall: "0xcA11bde05977b3631167028862bE2a173976CA11",
1931
+ rpc: [
1932
+ ],
1933
+ explorer: {
1934
+ url: "https://explorer.unit0.dev"
1935
+ },
1936
+ start: 9727,
1937
+ logo: "ipfs://bafkreihbmy3rqlammea35nniemipxrwcgitzkiahs6nlrfjunnvgfnakp4"
1938
+ },
1939
+ "88817": {
1940
+ key: "88817",
1941
+ name: "Unit Zero testnet",
1942
+ shortName: "testnet",
1943
+ chainId: 88817,
1944
+ network: "testnet",
1945
+ multicall: "0x017181efb3bDB325C17800799b33Ae80B395024c",
1946
+ rpc: [
1947
+ ],
1948
+ explorer: {
1949
+ url: "https://explorer-testnet.unit0.dev"
1950
+ },
1951
+ start: 3973744,
1952
+ logo: "ipfs://bafkreihbmy3rqlammea35nniemipxrwcgitzkiahs6nlrfjunnvgfnakp4",
1923
1953
  testnet: true
1924
1954
  },
1925
1955
  "314159": {
@@ -2276,34 +2306,6 @@ const RPC_URLS = {
2276
2306
  SN_MAIN: (_b = (_a = networks[constants$1.StarknetChainId.SN_MAIN]) === null || _a === void 0 ? void 0 : _a.rpc) === null || _b === void 0 ? void 0 : _b[0],
2277
2307
  SN_SEPOLIA: (_d = (_c = networks[constants$1.StarknetChainId.SN_SEPOLIA]) === null || _c === void 0 ? void 0 : _c.rpc) === null || _d === void 0 ? void 0 : _d[0]
2278
2308
  };
2279
- const ABI = [
2280
- {
2281
- name: 'argent::common::account::IAccount',
2282
- type: 'interface',
2283
- items: [
2284
- {
2285
- name: 'is_valid_signature',
2286
- type: 'function',
2287
- inputs: [
2288
- {
2289
- name: 'hash',
2290
- type: 'core::felt252'
2291
- },
2292
- {
2293
- name: 'signature',
2294
- type: 'core::array::Array::<core::felt252>'
2295
- }
2296
- ],
2297
- outputs: [
2298
- {
2299
- type: 'core::felt252'
2300
- }
2301
- ],
2302
- state_mutability: 'view'
2303
- }
2304
- ]
2305
- }
2306
- ];
2307
2309
  function getProvider$1(network, options) {
2308
2310
  var _a;
2309
2311
  if (!RPC_URLS[network])
@@ -2319,40 +2321,14 @@ function getHash(data, address) {
2319
2321
  const { domain, types, primaryType, message } = data;
2320
2322
  return typedData.getMessageHash({ types, primaryType, domain, message }, address);
2321
2323
  }
2322
- /**
2323
- * Processes a StarkNet signature array and returns the appropriate signature format
2324
- * for contract verification.
2325
- * Returns the r ands values for each signature in the array.
2326
- *
2327
- * Handles the following cases:
2328
- * - 2-item array: Standard signature, returns as-is.
2329
- * - 3-item array: Some wallets (e.g., Braavos) may return a 3-item array; returns the last two items.
2330
- * - Multi-signer array: For multisig accounts, the array may contain multiple signatures;
2331
- * this function extracts the relevant signature pairs.
2332
- *
2333
- * @param {string[]} sig - The signature array to process. Must have at least 2 items.
2334
- * @returns {string[]} The processed signature array suitable for contract verification.
2335
- * @throws {Error} If the signature array has fewer than 2 items.
2336
- */
2337
- function getSignatureArray(sig) {
2338
- if (sig.length < 2) {
2339
- throw new Error('Invalid signature format');
2340
- }
2341
- if (sig.length <= 3) {
2342
- return sig.slice(-2);
2343
- }
2344
- const results = [];
2345
- for (let i = 1; i < sig.length; i += 4) {
2346
- results.push(sig[i + 2], sig[i + 3]);
2347
- }
2348
- return results;
2349
- }
2350
2324
  function verify(address_1, sig_1, data_1) {
2351
2325
  return __awaiter(this, arguments, void 0, function* (address, sig, data, network = 'SN_MAIN', options = {}) {
2352
2326
  try {
2353
- const contractAccount = new Contract(ABI, address, getProvider$1(network, options));
2354
- const result = yield contractAccount.is_valid_signature(getHash(data, address), getSignatureArray(sig));
2355
- return BigNumber.from(result).eq(BigNumber.from('370462705988'));
2327
+ const provider = getProvider$1(network, options);
2328
+ // Check if the contract is deployed
2329
+ // Will throw on non-deployed contract
2330
+ yield provider.getClassAt(address);
2331
+ return provider.verifyMessageInStarknet(data, sig, address);
2356
2332
  }
2357
2333
  catch (e) {
2358
2334
  if (e.message.includes('Contract not found')) {
@@ -3154,7 +3130,7 @@ const multicallAbi = [
3154
3130
  ];
3155
3131
  function multicall(address_1, provider_1, abi_1, calls_1, limit_1) {
3156
3132
  return __awaiter(this, arguments, void 0, function* (address, provider, abi, calls, limit, options = {}) {
3157
- const multi = new Contract$1(address, multicallAbi, provider);
3133
+ const multi = new Contract(address, multicallAbi, provider);
3158
3134
  const itf = new Interface(abi);
3159
3135
  try {
3160
3136
  const pages = Math.ceil(calls.length / limit);
@@ -3571,7 +3547,7 @@ function getDNSOwner(domain) {
3571
3547
  }
3572
3548
  function call(provider, abi, call, options) {
3573
3549
  return __awaiter(this, void 0, void 0, function* () {
3574
- const contract = new Contract$1(call[0], abi, provider);
3550
+ const contract = new Contract(call[0], abi, provider);
3575
3551
  try {
3576
3552
  const params = call[2] || [];
3577
3553
  return yield contract[call[1]](...params, options || {});
@@ -3693,7 +3669,7 @@ function ipfsGet(gateway_1, ipfsHash_1) {
3693
3669
  function sendTransaction(web3_1, contractAddress_1, abi_1, action_1, params_1) {
3694
3670
  return __awaiter(this, arguments, void 0, function* (web3, contractAddress, abi, action, params, overrides = {}) {
3695
3671
  const signer = web3.getSigner();
3696
- const contract = new Contract$1(contractAddress, abi, web3);
3672
+ const contract = new Contract(contractAddress, abi, web3);
3697
3673
  const contractWithSigner = contract.connect(signer);
3698
3674
  // overrides.gasLimit = 12e6;
3699
3675
  return yield contractWithSigner[action](...params, overrides);
@@ -3893,7 +3869,7 @@ function getEnsOwner(ens_1) {
3893
3869
  }
3894
3870
  const domainType = getDomainType(ens);
3895
3871
  const provider = getProvider(network, options);
3896
- const ensRegistry = new Contract$1(ENS_REGISTRY, ['function owner(bytes32) view returns (address)'], provider);
3872
+ const ensRegistry = new Contract(ENS_REGISTRY, ['function owner(bytes32) view returns (address)'], provider);
3897
3873
  let ensHash;
3898
3874
  try {
3899
3875
  ensHash = namehash(ensNormalize(ens));
@@ -3905,7 +3881,7 @@ function getEnsOwner(ens_1) {
3905
3881
  let owner = yield ensRegistry.owner(ensHash);
3906
3882
  // If owner is the ENSNameWrapper contract, resolve the owner of the name
3907
3883
  if (owner === ensNameWrapper) {
3908
- const ensNameWrapperContract = new Contract$1(ensNameWrapper, ['function ownerOf(uint256) view returns (address)'], provider);
3884
+ const ensNameWrapperContract = new Contract(ensNameWrapper, ['function ownerOf(uint256) view returns (address)'], provider);
3909
3885
  owner = yield ensNameWrapperContract.ownerOf(ensHash);
3910
3886
  }
3911
3887
  if (owner === EMPTY_ADDRESS && domainType === 'other-tld') {