@snapshot-labs/snapshot.js 0.14.11 → 0.14.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.
@@ -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');
@@ -2286,34 +2285,6 @@ const RPC_URLS = {
2286
2285
  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
2286
  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
2287
  };
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
2288
  function getProvider$1(network, options) {
2318
2289
  var _a;
2319
2290
  if (!RPC_URLS[network])
@@ -2332,12 +2303,11 @@ function getHash(data, address) {
2332
2303
  function verify(address_1, sig_1, data_1) {
2333
2304
  return __awaiter(this, arguments, void 0, function* (address, sig, data, network = 'SN_MAIN', options = {}) {
2334
2305
  try {
2335
- const contractAccount = new starknet$1.Contract(ABI, address, getProvider$1(network, options));
2336
- if (sig.length < 2) {
2337
- throw new Error('Invalid signature format');
2338
- }
2339
- const result = yield contractAccount.is_valid_signature(getHash(data, address), sig.slice(-2));
2340
- return bignumber.BigNumber.from(result).eq(bignumber.BigNumber.from('370462705988'));
2306
+ const provider = getProvider$1(network, options);
2307
+ // Check if the contract is deployed
2308
+ // Will throw on non-deployed contract
2309
+ yield provider.getClassAt(address);
2310
+ return provider.verifyMessageInStarknet(data, sig, address);
2341
2311
  }
2342
2312
  catch (e) {
2343
2313
  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';
@@ -2276,34 +2275,6 @@ const RPC_URLS = {
2276
2275
  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
2276
  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
2277
  };
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
2278
  function getProvider$1(network, options) {
2308
2279
  var _a;
2309
2280
  if (!RPC_URLS[network])
@@ -2322,12 +2293,11 @@ function getHash(data, address) {
2322
2293
  function verify(address_1, sig_1, data_1) {
2323
2294
  return __awaiter(this, arguments, void 0, function* (address, sig, data, network = 'SN_MAIN', options = {}) {
2324
2295
  try {
2325
- const contractAccount = new Contract(ABI, address, getProvider$1(network, options));
2326
- if (sig.length < 2) {
2327
- throw new Error('Invalid signature format');
2328
- }
2329
- const result = yield contractAccount.is_valid_signature(getHash(data, address), sig.slice(-2));
2330
- return BigNumber.from(result).eq(BigNumber.from('370462705988'));
2296
+ const provider = getProvider$1(network, options);
2297
+ // Check if the contract is deployed
2298
+ // Will throw on non-deployed contract
2299
+ yield provider.getClassAt(address);
2300
+ return provider.verifyMessageInStarknet(data, sig, address);
2331
2301
  }
2332
2302
  catch (e) {
2333
2303
  if (e.message.includes('Contract not found')) {
@@ -3129,7 +3099,7 @@ const multicallAbi = [
3129
3099
  ];
3130
3100
  function multicall(address_1, provider_1, abi_1, calls_1, limit_1) {
3131
3101
  return __awaiter(this, arguments, void 0, function* (address, provider, abi, calls, limit, options = {}) {
3132
- const multi = new Contract$1(address, multicallAbi, provider);
3102
+ const multi = new Contract(address, multicallAbi, provider);
3133
3103
  const itf = new Interface(abi);
3134
3104
  try {
3135
3105
  const pages = Math.ceil(calls.length / limit);
@@ -3546,7 +3516,7 @@ function getDNSOwner(domain) {
3546
3516
  }
3547
3517
  function call(provider, abi, call, options) {
3548
3518
  return __awaiter(this, void 0, void 0, function* () {
3549
- const contract = new Contract$1(call[0], abi, provider);
3519
+ const contract = new Contract(call[0], abi, provider);
3550
3520
  try {
3551
3521
  const params = call[2] || [];
3552
3522
  return yield contract[call[1]](...params, options || {});
@@ -3668,7 +3638,7 @@ function ipfsGet(gateway_1, ipfsHash_1) {
3668
3638
  function sendTransaction(web3_1, contractAddress_1, abi_1, action_1, params_1) {
3669
3639
  return __awaiter(this, arguments, void 0, function* (web3, contractAddress, abi, action, params, overrides = {}) {
3670
3640
  const signer = web3.getSigner();
3671
- const contract = new Contract$1(contractAddress, abi, web3);
3641
+ const contract = new Contract(contractAddress, abi, web3);
3672
3642
  const contractWithSigner = contract.connect(signer);
3673
3643
  // overrides.gasLimit = 12e6;
3674
3644
  return yield contractWithSigner[action](...params, overrides);
@@ -3868,7 +3838,7 @@ function getEnsOwner(ens_1) {
3868
3838
  }
3869
3839
  const domainType = getDomainType(ens);
3870
3840
  const provider = getProvider(network, options);
3871
- const ensRegistry = new Contract$1(ENS_REGISTRY, ['function owner(bytes32) view returns (address)'], provider);
3841
+ const ensRegistry = new Contract(ENS_REGISTRY, ['function owner(bytes32) view returns (address)'], provider);
3872
3842
  let ensHash;
3873
3843
  try {
3874
3844
  ensHash = namehash(ensNormalize(ens));
@@ -3880,7 +3850,7 @@ function getEnsOwner(ens_1) {
3880
3850
  let owner = yield ensRegistry.owner(ensHash);
3881
3851
  // If owner is the ENSNameWrapper contract, resolve the owner of the name
3882
3852
  if (owner === ensNameWrapper) {
3883
- const ensNameWrapperContract = new Contract$1(ensNameWrapper, ['function ownerOf(uint256) view returns (address)'], provider);
3853
+ const ensNameWrapperContract = new Contract(ensNameWrapper, ['function ownerOf(uint256) view returns (address)'], provider);
3884
3854
  owner = yield ensNameWrapperContract.ownerOf(ensHash);
3885
3855
  }
3886
3856
  if (owner === EMPTY_ADDRESS && domainType === 'other-tld') {