@snapshot-labs/snapshot.js 0.3.79 → 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;
@@ -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",
@@ -1957,6 +2012,23 @@ var networks = {
1957
2012
  explorer: "https://explorer.testnet.nahmii.io",
1958
2013
  start: 53370,
1959
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"
1960
2032
  },
1961
2033
  "7341": {
1962
2034
  key: "7341",
@@ -2823,7 +2895,7 @@ var voting = {
2823
2895
  };
2824
2896
 
2825
2897
  var SNAPSHOT_SUBGRAPH_URL = {
2826
- '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/subgraphs/id/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn',
2898
+ '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmWtK3SiKTomQC24G9jWUpFQhfG1hdHo2Yh4nYABZ21cLq',
2827
2899
  '4': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby',
2828
2900
  '42': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan',
2829
2901
  '97': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain',
@@ -3162,6 +3234,7 @@ var utils = {
3162
3234
  signMessage: signMessage,
3163
3235
  getBlockNumber: getBlockNumber,
3164
3236
  Multicaller: Multicaller,
3237
+ getSnapshots: getSnapshots,
3165
3238
  validations: validations,
3166
3239
  getHash: getHash,
3167
3240
  verify: verify$1,
@@ -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",
@@ -1948,6 +2003,23 @@ var networks = {
1948
2003
  explorer: "https://explorer.testnet.nahmii.io",
1949
2004
  start: 53370,
1950
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"
1951
2023
  },
1952
2024
  "7341": {
1953
2025
  key: "7341",
@@ -2814,7 +2886,7 @@ var voting = {
2814
2886
  };
2815
2887
 
2816
2888
  var SNAPSHOT_SUBGRAPH_URL = {
2817
- '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/subgraphs/id/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn',
2889
+ '1': 'https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmWtK3SiKTomQC24G9jWUpFQhfG1hdHo2Yh4nYABZ21cLq',
2818
2890
  '4': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby',
2819
2891
  '42': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan',
2820
2892
  '97': 'https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain',
@@ -3153,6 +3225,7 @@ var utils = {
3153
3225
  signMessage: signMessage,
3154
3226
  getBlockNumber: getBlockNumber,
3155
3227
  Multicaller: Multicaller,
3228
+ getSnapshots: getSnapshots,
3156
3229
  validations: validations,
3157
3230
  getHash: getHash,
3158
3231
  verify: verify$1,