@snapshot-labs/snapshot.js 0.4.109 → 0.4.110
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/snapshot.cjs.js +22 -21
- package/dist/snapshot.esm.js +22 -21
- package/dist/snapshot.min.js +3 -3
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/networks.json +6 -6
- package/src/utils.ts +15 -16
package/dist/utils.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare function getUrl(uri: any, gateway?: string): any;
|
|
|
28
28
|
export declare function getJSON(uri: any): Promise<any>;
|
|
29
29
|
export declare function ipfsGet(gateway: string, ipfsHash: string, protocolType?: string): Promise<any>;
|
|
30
30
|
export declare function sendTransaction(web3: any, contractAddress: string, abi: any[], action: string, params: any[], overrides?: {}): Promise<any>;
|
|
31
|
-
export declare function getScores(space: string, strategies: Strategy[], network: string, addresses: string[], snapshot?: number | string, scoreApiUrl?: string): Promise<any>;
|
|
31
|
+
export declare function getScores(space: string, strategies: Strategy[], network: string, addresses: string[], snapshot?: number | string, scoreApiUrl?: string, options?: any): Promise<any>;
|
|
32
32
|
export declare function getVp(address: string, network: string, strategies: Strategy[], snapshot: number | 'latest', space: string, delegation: boolean, options?: Options): Promise<any>;
|
|
33
33
|
export declare function validate(validation: string, author: string, space: string, network: string, snapshot: number | 'latest', params: any, options: any): Promise<any>;
|
|
34
34
|
export declare function validateSchema(schema: any, data: any): true | import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | null | undefined;
|
package/package.json
CHANGED
package/src/networks.json
CHANGED
|
@@ -1195,21 +1195,21 @@
|
|
|
1195
1195
|
},
|
|
1196
1196
|
"logo": "ipfs://QmVH3uyPQDcrPC1DMUWCb7HayMv1oMAiKehuWwP2C2fdgM"
|
|
1197
1197
|
},
|
|
1198
|
-
"
|
|
1199
|
-
"key": "
|
|
1198
|
+
"1072": {
|
|
1199
|
+
"key": "1072",
|
|
1200
1200
|
"name": "Shimmer EVM Testnet",
|
|
1201
1201
|
"shortName": "ShimmerEVM",
|
|
1202
|
-
"chainId":
|
|
1202
|
+
"chainId": 1072,
|
|
1203
1203
|
"network": "testnet",
|
|
1204
1204
|
"testnet": true,
|
|
1205
|
-
"multicall": "
|
|
1205
|
+
"multicall": "0x751d21047C116413895c259f3f305e38C10B7cF6",
|
|
1206
1206
|
"rpc": [
|
|
1207
|
-
"https://
|
|
1207
|
+
"https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"
|
|
1208
1208
|
],
|
|
1209
1209
|
"explorer": {
|
|
1210
1210
|
"url": "https://explorer.evm.testnet.shimmer.network/"
|
|
1211
1211
|
},
|
|
1212
|
-
"start":
|
|
1212
|
+
"start": 10614,
|
|
1213
1213
|
"logo": "ipfs://QmYGxmEhV6djksUk97pdE9TmL6DXm9KW8BP7pwUv8pqp8r"
|
|
1214
1214
|
},
|
|
1215
1215
|
"1088": {
|
package/src/utils.ts
CHANGED
|
@@ -28,10 +28,16 @@ interface Strategy {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export const SNAPSHOT_SUBGRAPH_URL = delegationSubgraphs;
|
|
31
|
-
|
|
32
31
|
const ENS_RESOLVER_ABI = [
|
|
33
32
|
'function text(bytes32 node, string calldata key) external view returns (string memory)'
|
|
34
33
|
];
|
|
34
|
+
const SCORE_API_KEY = process?.env?.KEYCARD_SECRET || '';
|
|
35
|
+
|
|
36
|
+
const scoreApiHeaders = {
|
|
37
|
+
Accept: 'application/json',
|
|
38
|
+
'Content-Type': 'application/json'
|
|
39
|
+
};
|
|
40
|
+
if (SCORE_API_KEY) scoreApiHeaders['X-API-KEY'] = SCORE_API_KEY;
|
|
35
41
|
|
|
36
42
|
const ajv = new Ajv({ allErrors: true, allowUnionTypes: true, $data: true });
|
|
37
43
|
// @ts-ignore
|
|
@@ -215,7 +221,8 @@ export async function getScores(
|
|
|
215
221
|
network: string,
|
|
216
222
|
addresses: string[],
|
|
217
223
|
snapshot: number | string = 'latest',
|
|
218
|
-
scoreApiUrl = 'https://score.snapshot.org/api/scores'
|
|
224
|
+
scoreApiUrl = 'https://score.snapshot.org/api/scores',
|
|
225
|
+
options: any = { returnValue: 'scores' }
|
|
219
226
|
) {
|
|
220
227
|
try {
|
|
221
228
|
const params = {
|
|
@@ -227,11 +234,11 @@ export async function getScores(
|
|
|
227
234
|
};
|
|
228
235
|
const res = await fetch(scoreApiUrl, {
|
|
229
236
|
method: 'POST',
|
|
230
|
-
headers:
|
|
237
|
+
headers: scoreApiHeaders,
|
|
231
238
|
body: JSON.stringify({ params })
|
|
232
239
|
});
|
|
233
240
|
const obj = await res.json();
|
|
234
|
-
return obj.result.
|
|
241
|
+
return options.returnValue ? obj.result[options.returnValue] : obj.result;
|
|
235
242
|
} catch (e) {
|
|
236
243
|
return Promise.reject(e);
|
|
237
244
|
}
|
|
@@ -250,10 +257,7 @@ export async function getVp(
|
|
|
250
257
|
if (!options.url) options.url = 'https://score.snapshot.org';
|
|
251
258
|
const init = {
|
|
252
259
|
method: 'POST',
|
|
253
|
-
headers:
|
|
254
|
-
Accept: 'application/json',
|
|
255
|
-
'Content-Type': 'application/json'
|
|
256
|
-
},
|
|
260
|
+
headers: scoreApiHeaders,
|
|
257
261
|
body: JSON.stringify({
|
|
258
262
|
jsonrpc: '2.0',
|
|
259
263
|
method: 'get_vp',
|
|
@@ -264,8 +268,7 @@ export async function getVp(
|
|
|
264
268
|
snapshot,
|
|
265
269
|
space,
|
|
266
270
|
delegation
|
|
267
|
-
}
|
|
268
|
-
id: null
|
|
271
|
+
}
|
|
269
272
|
})
|
|
270
273
|
};
|
|
271
274
|
const res = await fetch(options.url, init);
|
|
@@ -287,10 +290,7 @@ export async function validate(
|
|
|
287
290
|
if (!options.url) options.url = 'https://score.snapshot.org';
|
|
288
291
|
const init = {
|
|
289
292
|
method: 'POST',
|
|
290
|
-
headers:
|
|
291
|
-
Accept: 'application/json',
|
|
292
|
-
'Content-Type': 'application/json'
|
|
293
|
-
},
|
|
293
|
+
headers: scoreApiHeaders,
|
|
294
294
|
body: JSON.stringify({
|
|
295
295
|
jsonrpc: '2.0',
|
|
296
296
|
method: 'validate',
|
|
@@ -301,8 +301,7 @@ export async function validate(
|
|
|
301
301
|
network,
|
|
302
302
|
snapshot,
|
|
303
303
|
params
|
|
304
|
-
}
|
|
305
|
-
id: null
|
|
304
|
+
}
|
|
306
305
|
})
|
|
307
306
|
};
|
|
308
307
|
const res = await fetch(options.url, init);
|