@snapshot-labs/snapshot.js 0.3.77 → 0.3.80

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.
package/dist/index.d.ts CHANGED
@@ -365,6 +365,7 @@ declare const _default: {
365
365
  signMessage: typeof import("./utils/web3").signMessage;
366
366
  getBlockNumber: typeof import("./utils/web3").getBlockNumber;
367
367
  Multicaller: typeof import("./utils/multicaller").default;
368
+ getSnapshots: typeof import("./utils/blockfinder").getSnapshots;
368
369
  validations: {
369
370
  basic: typeof import("./validations/basic").default;
370
371
  aave: typeof import("./validations/aave").default;
@@ -893,7 +893,7 @@ var definitions$1 = {
893
893
  type: "array",
894
894
  title: "choices",
895
895
  minItems: 1,
896
- maxItems: 140
896
+ maxItems: 160
897
897
  },
898
898
  type: {
899
899
  type: "string",
@@ -1065,6 +1065,46 @@ var Multicaller = /** @class */ (function () {
1065
1065
  return Multicaller;
1066
1066
  }());
1067
1067
 
1068
+ function getSnapshots(network, snapshot, provider, networks) {
1069
+ return __awaiter(this, void 0, void 0, function () {
1070
+ var snapshots, networkIn, block, query, url, data;
1071
+ return __generator(this, function (_a) {
1072
+ switch (_a.label) {
1073
+ case 0:
1074
+ snapshots = {};
1075
+ networks.forEach(function (n) { return (snapshots[n] = 'latest'); });
1076
+ if (snapshot === 'latest')
1077
+ return [2 /*return*/, snapshots];
1078
+ snapshots[network] = snapshot;
1079
+ networkIn = Object.keys(snapshots).filter(function (s) { return network !== s; });
1080
+ if (networkIn.length === 0)
1081
+ return [2 /*return*/, snapshots];
1082
+ return [4 /*yield*/, provider.getBlock(snapshot)];
1083
+ case 1:
1084
+ block = _a.sent();
1085
+ query = {
1086
+ blocks: {
1087
+ __args: {
1088
+ where: {
1089
+ ts: block.timestamp,
1090
+ network_in: networkIn
1091
+ }
1092
+ },
1093
+ network: true,
1094
+ number: true
1095
+ }
1096
+ };
1097
+ url = 'https://blockfinder.snapshot.org/graphql';
1098
+ return [4 /*yield*/, subgraphRequest(url, query)];
1099
+ case 2:
1100
+ data = _a.sent();
1101
+ data.blocks.forEach(function (block) { return (snapshots[block.network] = block.number); });
1102
+ return [2 /*return*/, snapshots];
1103
+ }
1104
+ });
1105
+ });
1106
+ }
1107
+
1068
1108
  var networks = {
1069
1109
  "1": {
1070
1110
  key: "1",
@@ -1332,6 +1372,21 @@ var networks = {
1332
1372
  explorer: "https://bscscan.com",
1333
1373
  start: 461230,
1334
1374
  imageIPFS: "QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"
1375
+ },
1376
+ "58": {
1377
+ key: "58",
1378
+ name: "Ontology Mainnet",
1379
+ chainId: 58,
1380
+ network: "mainnet",
1381
+ multicall: "0xce6292279bf688173B269Df080E14407470A9E60",
1382
+ rpc: [
1383
+ "https://dappnode1.ont.io:10339",
1384
+ "https://dappnode2.ont.io:10339",
1385
+ "https://dappnode3.ont.io:10339",
1386
+ "https://dappnode4.ont.io:10339"
1387
+ ],
1388
+ explorer: "https://explorer.ont.io/",
1389
+ imageIPFS: "Qme21sVqfwvrjkZHaeKaBH1F8AKPjbAV7vF7rH6akaLkU1"
1335
1390
  },
1336
1391
  "61": {
1337
1392
  key: "61",
@@ -1770,8 +1825,8 @@ var networks = {
1770
1825
  network: "mainnet",
1771
1826
  multicall: "0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",
1772
1827
  rpc: [
1773
- "https://rpc.astar.network:8545",
1774
- "https://astar.api.onfinality.io/public"
1828
+ "https://astar.api.onfinality.io/public",
1829
+ "https://rpc.astar.network:8545"
1775
1830
  ],
1776
1831
  explorer: "https://blockscout.com/astar",
1777
1832
  start: 366482,
@@ -1826,6 +1881,22 @@ var networks = {
1826
1881
  explorer: "https://scan.v2b.testnet.pulsechain.com",
1827
1882
  start: 14473847,
1828
1883
  imageIPFS: "QmYqkn8pJUaV9KcEPYEvRPwgbfeozLEvcQ9aEwKNRUL3cR"
1884
+ },
1885
+ "1001": {
1886
+ key: "1001",
1887
+ name: "Klaytn Baobab Testnet",
1888
+ shortName: "Boabab",
1889
+ chainId: 1001,
1890
+ network: "testnet",
1891
+ multicall: "0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",
1892
+ rpc: [
1893
+ "https://baobab.fandom.finance/archive"
1894
+ ],
1895
+ ws: [
1896
+ "wss://baobab.fandom.finance/archive/ws"
1897
+ ],
1898
+ explorer: "https://baobab.scope.klaytn.com/",
1899
+ imageIPFS: "QmYACyZcidcFtMo4Uf9H6ZKUxTP2TQPjGzNjcUjqYa64dt"
1829
1900
  },
1830
1901
  "1088": {
1831
1902
  key: "1088",
@@ -1941,6 +2012,23 @@ var networks = {
1941
2012
  explorer: "https://explorer.testnet.nahmii.io",
1942
2013
  start: 53370,
1943
2014
  imageIPFS: "QmPXPCBho3kGLt5rhG9JGkKmzdtLvqZmJqGzzijVCuggWY"
2015
+ },
2016
+ "5851": {
2017
+ key: "5851",
2018
+ name: "Ontology Testnet",
2019
+ chainId: 5851,
2020
+ network: "testnet",
2021
+ multicall: "0x381445710b5e73d34aF196c53A3D5cDa58EDBf7A",
2022
+ rpc: [
2023
+ "https://polaris1.ont.io:10339",
2024
+ "https://polaris2.ont.io:10339",
2025
+ "https://polaris3.ont.io:10339",
2026
+ "https://polaris4.ont.io:10339",
2027
+ "https://polaris4.ont.io:10339",
2028
+ "https://polaris5.ont.io:10339"
2029
+ ],
2030
+ explorer: "https://explorer.ont.io/testnet",
2031
+ imageIPFS: "Qme21sVqfwvrjkZHaeKaBH1F8AKPjbAV7vF7rH6akaLkU1"
1944
2032
  },
1945
2033
  "7341": {
1946
2034
  key: "7341",
@@ -2086,6 +2174,62 @@ var networks = {
2086
2174
  explorer: "https://scan.rei.network/",
2087
2175
  start: 1715902,
2088
2176
  imageIPFS: "QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"
2177
+ },
2178
+ "60001": {
2179
+ key: "60001",
2180
+ name: "Thinkium Testnet Chain 1",
2181
+ shortName: "ThinkiumTest1",
2182
+ chainId: 60001,
2183
+ network: "thinkiumtest1",
2184
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2185
+ rpc: [
2186
+ "https://test1.thinkiumrpc.net"
2187
+ ],
2188
+ explorer: "https://test1.thinkiumscan.net/",
2189
+ start: 323327,
2190
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2191
+ },
2192
+ "70001": {
2193
+ key: "70001",
2194
+ name: "Thinkium Mainnet Chain 1",
2195
+ shortName: "Thinkium1",
2196
+ chainId: 70001,
2197
+ network: "thinkium1",
2198
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2199
+ rpc: [
2200
+ "https://proxy1.thinkiumrpc.net"
2201
+ ],
2202
+ explorer: "https://chain1.thinkiumscan.net/",
2203
+ start: 26677364,
2204
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2205
+ },
2206
+ "70002": {
2207
+ key: "70002",
2208
+ name: "Thinkium Mainnet Chain 2",
2209
+ shortName: "Thinkium2",
2210
+ chainId: 70002,
2211
+ network: "thinkium2",
2212
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2213
+ rpc: [
2214
+ "https://proxy2.thinkiumrpc.net"
2215
+ ],
2216
+ explorer: "https://chain2.thinkiumscan.net/",
2217
+ start: 22124397,
2218
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2219
+ },
2220
+ "70103": {
2221
+ key: "70103",
2222
+ name: "Thinkium Mainnet Chain 103",
2223
+ shortName: "Thinkium103",
2224
+ chainId: 70103,
2225
+ network: "thinkium103",
2226
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2227
+ rpc: [
2228
+ "https://proxy103.thinkiumrpc.net"
2229
+ ],
2230
+ explorer: "https://chain103.thinkiumscan.net/",
2231
+ start: 22090160,
2232
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2089
2233
  },
2090
2234
  "80001": {
2091
2235
  key: "80001",
@@ -2751,7 +2895,7 @@ var voting = {
2751
2895
  };
2752
2896
 
2753
2897
  var SNAPSHOT_SUBGRAPH_URL = {
2754
- '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/subgraphs/id/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn',
2898
+ '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmWtK3SiKTomQC24G9jWUpFQhfG1hdHo2Yh4nYABZ21cLq',
2755
2899
  '4': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby',
2756
2900
  '42': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan',
2757
2901
  '97': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain',
@@ -3090,6 +3234,7 @@ var utils = {
3090
3234
  signMessage: signMessage,
3091
3235
  getBlockNumber: getBlockNumber,
3092
3236
  Multicaller: Multicaller,
3237
+ getSnapshots: getSnapshots,
3093
3238
  validations: validations,
3094
3239
  getHash: getHash,
3095
3240
  verify: verify$1,
@@ -884,7 +884,7 @@ var definitions$1 = {
884
884
  type: "array",
885
885
  title: "choices",
886
886
  minItems: 1,
887
- maxItems: 140
887
+ maxItems: 160
888
888
  },
889
889
  type: {
890
890
  type: "string",
@@ -1056,6 +1056,46 @@ var Multicaller = /** @class */ (function () {
1056
1056
  return Multicaller;
1057
1057
  }());
1058
1058
 
1059
+ function getSnapshots(network, snapshot, provider, networks) {
1060
+ return __awaiter(this, void 0, void 0, function () {
1061
+ var snapshots, networkIn, block, query, url, data;
1062
+ return __generator(this, function (_a) {
1063
+ switch (_a.label) {
1064
+ case 0:
1065
+ snapshots = {};
1066
+ networks.forEach(function (n) { return (snapshots[n] = 'latest'); });
1067
+ if (snapshot === 'latest')
1068
+ return [2 /*return*/, snapshots];
1069
+ snapshots[network] = snapshot;
1070
+ networkIn = Object.keys(snapshots).filter(function (s) { return network !== s; });
1071
+ if (networkIn.length === 0)
1072
+ return [2 /*return*/, snapshots];
1073
+ return [4 /*yield*/, provider.getBlock(snapshot)];
1074
+ case 1:
1075
+ block = _a.sent();
1076
+ query = {
1077
+ blocks: {
1078
+ __args: {
1079
+ where: {
1080
+ ts: block.timestamp,
1081
+ network_in: networkIn
1082
+ }
1083
+ },
1084
+ network: true,
1085
+ number: true
1086
+ }
1087
+ };
1088
+ url = 'https://blockfinder.snapshot.org/graphql';
1089
+ return [4 /*yield*/, subgraphRequest(url, query)];
1090
+ case 2:
1091
+ data = _a.sent();
1092
+ data.blocks.forEach(function (block) { return (snapshots[block.network] = block.number); });
1093
+ return [2 /*return*/, snapshots];
1094
+ }
1095
+ });
1096
+ });
1097
+ }
1098
+
1059
1099
  var networks = {
1060
1100
  "1": {
1061
1101
  key: "1",
@@ -1323,6 +1363,21 @@ var networks = {
1323
1363
  explorer: "https://bscscan.com",
1324
1364
  start: 461230,
1325
1365
  imageIPFS: "QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"
1366
+ },
1367
+ "58": {
1368
+ key: "58",
1369
+ name: "Ontology Mainnet",
1370
+ chainId: 58,
1371
+ network: "mainnet",
1372
+ multicall: "0xce6292279bf688173B269Df080E14407470A9E60",
1373
+ rpc: [
1374
+ "https://dappnode1.ont.io:10339",
1375
+ "https://dappnode2.ont.io:10339",
1376
+ "https://dappnode3.ont.io:10339",
1377
+ "https://dappnode4.ont.io:10339"
1378
+ ],
1379
+ explorer: "https://explorer.ont.io/",
1380
+ imageIPFS: "Qme21sVqfwvrjkZHaeKaBH1F8AKPjbAV7vF7rH6akaLkU1"
1326
1381
  },
1327
1382
  "61": {
1328
1383
  key: "61",
@@ -1761,8 +1816,8 @@ var networks = {
1761
1816
  network: "mainnet",
1762
1817
  multicall: "0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",
1763
1818
  rpc: [
1764
- "https://rpc.astar.network:8545",
1765
- "https://astar.api.onfinality.io/public"
1819
+ "https://astar.api.onfinality.io/public",
1820
+ "https://rpc.astar.network:8545"
1766
1821
  ],
1767
1822
  explorer: "https://blockscout.com/astar",
1768
1823
  start: 366482,
@@ -1817,6 +1872,22 @@ var networks = {
1817
1872
  explorer: "https://scan.v2b.testnet.pulsechain.com",
1818
1873
  start: 14473847,
1819
1874
  imageIPFS: "QmYqkn8pJUaV9KcEPYEvRPwgbfeozLEvcQ9aEwKNRUL3cR"
1875
+ },
1876
+ "1001": {
1877
+ key: "1001",
1878
+ name: "Klaytn Baobab Testnet",
1879
+ shortName: "Boabab",
1880
+ chainId: 1001,
1881
+ network: "testnet",
1882
+ multicall: "0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",
1883
+ rpc: [
1884
+ "https://baobab.fandom.finance/archive"
1885
+ ],
1886
+ ws: [
1887
+ "wss://baobab.fandom.finance/archive/ws"
1888
+ ],
1889
+ explorer: "https://baobab.scope.klaytn.com/",
1890
+ imageIPFS: "QmYACyZcidcFtMo4Uf9H6ZKUxTP2TQPjGzNjcUjqYa64dt"
1820
1891
  },
1821
1892
  "1088": {
1822
1893
  key: "1088",
@@ -1932,6 +2003,23 @@ var networks = {
1932
2003
  explorer: "https://explorer.testnet.nahmii.io",
1933
2004
  start: 53370,
1934
2005
  imageIPFS: "QmPXPCBho3kGLt5rhG9JGkKmzdtLvqZmJqGzzijVCuggWY"
2006
+ },
2007
+ "5851": {
2008
+ key: "5851",
2009
+ name: "Ontology Testnet",
2010
+ chainId: 5851,
2011
+ network: "testnet",
2012
+ multicall: "0x381445710b5e73d34aF196c53A3D5cDa58EDBf7A",
2013
+ rpc: [
2014
+ "https://polaris1.ont.io:10339",
2015
+ "https://polaris2.ont.io:10339",
2016
+ "https://polaris3.ont.io:10339",
2017
+ "https://polaris4.ont.io:10339",
2018
+ "https://polaris4.ont.io:10339",
2019
+ "https://polaris5.ont.io:10339"
2020
+ ],
2021
+ explorer: "https://explorer.ont.io/testnet",
2022
+ imageIPFS: "Qme21sVqfwvrjkZHaeKaBH1F8AKPjbAV7vF7rH6akaLkU1"
1935
2023
  },
1936
2024
  "7341": {
1937
2025
  key: "7341",
@@ -2077,6 +2165,62 @@ var networks = {
2077
2165
  explorer: "https://scan.rei.network/",
2078
2166
  start: 1715902,
2079
2167
  imageIPFS: "QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"
2168
+ },
2169
+ "60001": {
2170
+ key: "60001",
2171
+ name: "Thinkium Testnet Chain 1",
2172
+ shortName: "ThinkiumTest1",
2173
+ chainId: 60001,
2174
+ network: "thinkiumtest1",
2175
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2176
+ rpc: [
2177
+ "https://test1.thinkiumrpc.net"
2178
+ ],
2179
+ explorer: "https://test1.thinkiumscan.net/",
2180
+ start: 323327,
2181
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2182
+ },
2183
+ "70001": {
2184
+ key: "70001",
2185
+ name: "Thinkium Mainnet Chain 1",
2186
+ shortName: "Thinkium1",
2187
+ chainId: 70001,
2188
+ network: "thinkium1",
2189
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2190
+ rpc: [
2191
+ "https://proxy1.thinkiumrpc.net"
2192
+ ],
2193
+ explorer: "https://chain1.thinkiumscan.net/",
2194
+ start: 26677364,
2195
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2196
+ },
2197
+ "70002": {
2198
+ key: "70002",
2199
+ name: "Thinkium Mainnet Chain 2",
2200
+ shortName: "Thinkium2",
2201
+ chainId: 70002,
2202
+ network: "thinkium2",
2203
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2204
+ rpc: [
2205
+ "https://proxy2.thinkiumrpc.net"
2206
+ ],
2207
+ explorer: "https://chain2.thinkiumscan.net/",
2208
+ start: 22124397,
2209
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2210
+ },
2211
+ "70103": {
2212
+ key: "70103",
2213
+ name: "Thinkium Mainnet Chain 103",
2214
+ shortName: "Thinkium103",
2215
+ chainId: 70103,
2216
+ network: "thinkium103",
2217
+ multicall: "0xc49bc485d4f943b287edadbce45eb1a1220ffdfe",
2218
+ rpc: [
2219
+ "https://proxy103.thinkiumrpc.net"
2220
+ ],
2221
+ explorer: "https://chain103.thinkiumscan.net/",
2222
+ start: 22090160,
2223
+ imageIPFS: "QmRfiNT4tDhyxfpYcjNde4BMPPWEAygYNPdAaS9bra6aFC"
2080
2224
  },
2081
2225
  "80001": {
2082
2226
  key: "80001",
@@ -2742,7 +2886,7 @@ var voting = {
2742
2886
  };
2743
2887
 
2744
2888
  var SNAPSHOT_SUBGRAPH_URL = {
2745
- '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/subgraphs/id/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn',
2889
+ '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmWtK3SiKTomQC24G9jWUpFQhfG1hdHo2Yh4nYABZ21cLq',
2746
2890
  '4': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby',
2747
2891
  '42': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan',
2748
2892
  '97': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain',
@@ -3081,6 +3225,7 @@ var utils = {
3081
3225
  signMessage: signMessage,
3082
3226
  getBlockNumber: getBlockNumber,
3083
3227
  Multicaller: Multicaller,
3228
+ getSnapshots: getSnapshots,
3084
3229
  validations: validations,
3085
3230
  getHash: getHash,
3086
3231
  verify: verify$1,