@snapshot-labs/snapshot.js 0.14.5 → 0.14.6
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 +290 -232
- package/dist/snapshot.esm.js +281 -223
- package/dist/snapshot.min.js +23 -23
- package/dist/src/index.d.ts +1 -0
- package/dist/src/utils.d.ts +36 -0
- package/package.json +1 -1
- package/src/sign/index.ts +1 -1
- package/src/utils.ts +70 -2
package/dist/snapshot.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var crossFetch = require('cross-fetch');
|
|
4
4
|
var contracts = require('@ethersproject/contracts');
|
|
5
5
|
var address = require('@ethersproject/address');
|
|
6
6
|
var units = require('@ethersproject/units');
|
|
@@ -19,7 +19,7 @@ var set = require('lodash.set');
|
|
|
19
19
|
|
|
20
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var crossFetch__default = /*#__PURE__*/_interopDefaultLegacy(crossFetch);
|
|
23
23
|
var Ajv__default = /*#__PURE__*/_interopDefaultLegacy(Ajv);
|
|
24
24
|
var addFormats__default = /*#__PURE__*/_interopDefaultLegacy(addFormats);
|
|
25
25
|
var addErrors__default = /*#__PURE__*/_interopDefaultLegacy(addErrors);
|
|
@@ -62,227 +62,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const spaceTypes = {
|
|
66
|
-
Space: [
|
|
67
|
-
{ name: 'from', type: 'address' },
|
|
68
|
-
{ name: 'space', type: 'string' },
|
|
69
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
70
|
-
{ name: 'settings', type: 'string' }
|
|
71
|
-
]
|
|
72
|
-
};
|
|
73
|
-
const proposalTypes = {
|
|
74
|
-
Proposal: [
|
|
75
|
-
{ name: 'from', type: 'string' },
|
|
76
|
-
{ name: 'space', type: 'string' },
|
|
77
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
78
|
-
{ name: 'type', type: 'string' },
|
|
79
|
-
{ name: 'title', type: 'string' },
|
|
80
|
-
{ name: 'body', type: 'string' },
|
|
81
|
-
{ name: 'discussion', type: 'string' },
|
|
82
|
-
{ name: 'choices', type: 'string[]' },
|
|
83
|
-
{ name: 'labels', type: 'string[]' },
|
|
84
|
-
{ name: 'start', type: 'uint64' },
|
|
85
|
-
{ name: 'end', type: 'uint64' },
|
|
86
|
-
{ name: 'snapshot', type: 'uint64' },
|
|
87
|
-
{ name: 'plugins', type: 'string' },
|
|
88
|
-
{ name: 'privacy', type: 'string' },
|
|
89
|
-
{ name: 'app', type: 'string' }
|
|
90
|
-
]
|
|
91
|
-
};
|
|
92
|
-
const updateProposalTypes = {
|
|
93
|
-
UpdateProposal: [
|
|
94
|
-
{ name: 'proposal', type: 'string' },
|
|
95
|
-
{ name: 'from', type: 'string' },
|
|
96
|
-
{ name: 'space', type: 'string' },
|
|
97
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
98
|
-
{ name: 'type', type: 'string' },
|
|
99
|
-
{ name: 'title', type: 'string' },
|
|
100
|
-
{ name: 'body', type: 'string' },
|
|
101
|
-
{ name: 'discussion', type: 'string' },
|
|
102
|
-
{ name: 'choices', type: 'string[]' },
|
|
103
|
-
{ name: 'labels', type: 'string[]' },
|
|
104
|
-
{ name: 'plugins', type: 'string' },
|
|
105
|
-
{ name: 'privacy', type: 'string' }
|
|
106
|
-
]
|
|
107
|
-
};
|
|
108
|
-
const flagProposalTypes = {
|
|
109
|
-
FlagProposal: [
|
|
110
|
-
{ name: 'from', type: 'string' },
|
|
111
|
-
{ name: 'space', type: 'string' },
|
|
112
|
-
{ name: 'proposal', type: 'string' },
|
|
113
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
114
|
-
]
|
|
115
|
-
};
|
|
116
|
-
const cancelProposalTypes = {
|
|
117
|
-
CancelProposal: [
|
|
118
|
-
{ name: 'from', type: 'string' },
|
|
119
|
-
{ name: 'space', type: 'string' },
|
|
120
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
121
|
-
{ name: 'proposal', type: 'string' }
|
|
122
|
-
]
|
|
123
|
-
};
|
|
124
|
-
const cancelProposal2Types = {
|
|
125
|
-
CancelProposal: [
|
|
126
|
-
{ name: 'from', type: 'string' },
|
|
127
|
-
{ name: 'space', type: 'string' },
|
|
128
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
129
|
-
{ name: 'proposal', type: 'bytes32' }
|
|
130
|
-
]
|
|
131
|
-
};
|
|
132
|
-
const voteTypes = {
|
|
133
|
-
Vote: [
|
|
134
|
-
{ name: 'from', type: 'string' },
|
|
135
|
-
{ name: 'space', type: 'string' },
|
|
136
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
137
|
-
{ name: 'proposal', type: 'string' },
|
|
138
|
-
{ name: 'choice', type: 'uint32' },
|
|
139
|
-
{ name: 'reason', type: 'string' },
|
|
140
|
-
{ name: 'app', type: 'string' },
|
|
141
|
-
{ name: 'metadata', type: 'string' }
|
|
142
|
-
]
|
|
143
|
-
};
|
|
144
|
-
const voteArrayTypes = {
|
|
145
|
-
Vote: [
|
|
146
|
-
{ name: 'from', type: 'string' },
|
|
147
|
-
{ name: 'space', type: 'string' },
|
|
148
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
149
|
-
{ name: 'proposal', type: 'string' },
|
|
150
|
-
{ name: 'choice', type: 'uint32[]' },
|
|
151
|
-
{ name: 'reason', type: 'string' },
|
|
152
|
-
{ name: 'app', type: 'string' },
|
|
153
|
-
{ name: 'metadata', type: 'string' }
|
|
154
|
-
]
|
|
155
|
-
};
|
|
156
|
-
const voteStringTypes = {
|
|
157
|
-
Vote: [
|
|
158
|
-
{ name: 'from', type: 'string' },
|
|
159
|
-
{ name: 'space', type: 'string' },
|
|
160
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
161
|
-
{ name: 'proposal', type: 'string' },
|
|
162
|
-
{ name: 'choice', type: 'string' },
|
|
163
|
-
{ name: 'reason', type: 'string' },
|
|
164
|
-
{ name: 'app', type: 'string' },
|
|
165
|
-
{ name: 'metadata', type: 'string' }
|
|
166
|
-
]
|
|
167
|
-
};
|
|
168
|
-
const vote2Types = {
|
|
169
|
-
Vote: [
|
|
170
|
-
{ name: 'from', type: 'string' },
|
|
171
|
-
{ name: 'space', type: 'string' },
|
|
172
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
173
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
174
|
-
{ name: 'choice', type: 'uint32' },
|
|
175
|
-
{ name: 'reason', type: 'string' },
|
|
176
|
-
{ name: 'app', type: 'string' },
|
|
177
|
-
{ name: 'metadata', type: 'string' }
|
|
178
|
-
]
|
|
179
|
-
};
|
|
180
|
-
const voteArray2Types = {
|
|
181
|
-
Vote: [
|
|
182
|
-
{ name: 'from', type: 'string' },
|
|
183
|
-
{ name: 'space', type: 'string' },
|
|
184
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
185
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
186
|
-
{ name: 'choice', type: 'uint32[]' },
|
|
187
|
-
{ name: 'reason', type: 'string' },
|
|
188
|
-
{ name: 'app', type: 'string' },
|
|
189
|
-
{ name: 'metadata', type: 'string' }
|
|
190
|
-
]
|
|
191
|
-
};
|
|
192
|
-
const voteString2Types = {
|
|
193
|
-
Vote: [
|
|
194
|
-
{ name: 'from', type: 'string' },
|
|
195
|
-
{ name: 'space', type: 'string' },
|
|
196
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
197
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
198
|
-
{ name: 'choice', type: 'string' },
|
|
199
|
-
{ name: 'reason', type: 'string' },
|
|
200
|
-
{ name: 'app', type: 'string' },
|
|
201
|
-
{ name: 'metadata', type: 'string' }
|
|
202
|
-
]
|
|
203
|
-
};
|
|
204
|
-
const followTypes = {
|
|
205
|
-
Follow: [
|
|
206
|
-
{ name: 'from', type: 'address' },
|
|
207
|
-
{ name: 'network', type: 'string' },
|
|
208
|
-
{ name: 'space', type: 'string' },
|
|
209
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
210
|
-
]
|
|
211
|
-
};
|
|
212
|
-
const unfollowTypes = {
|
|
213
|
-
Unfollow: [
|
|
214
|
-
{ name: 'from', type: 'address' },
|
|
215
|
-
{ name: 'network', type: 'string' },
|
|
216
|
-
{ name: 'space', type: 'string' },
|
|
217
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
218
|
-
]
|
|
219
|
-
};
|
|
220
|
-
const subscribeTypes = {
|
|
221
|
-
Subscribe: [
|
|
222
|
-
{ name: 'from', type: 'address' },
|
|
223
|
-
{ name: 'space', type: 'string' },
|
|
224
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
225
|
-
]
|
|
226
|
-
};
|
|
227
|
-
const unsubscribeTypes = {
|
|
228
|
-
Unsubscribe: [
|
|
229
|
-
{ name: 'from', type: 'address' },
|
|
230
|
-
{ name: 'space', type: 'string' },
|
|
231
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
232
|
-
]
|
|
233
|
-
};
|
|
234
|
-
const profileTypes = {
|
|
235
|
-
Profile: [
|
|
236
|
-
{ name: 'from', type: 'address' },
|
|
237
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
238
|
-
{ name: 'profile', type: 'string' }
|
|
239
|
-
]
|
|
240
|
-
};
|
|
241
|
-
const statementTypes = {
|
|
242
|
-
Statement: [
|
|
243
|
-
{ name: 'from', type: 'address' },
|
|
244
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
245
|
-
{ name: 'space', type: 'string' },
|
|
246
|
-
{ name: 'about', type: 'string' },
|
|
247
|
-
{ name: 'statement', type: 'string' },
|
|
248
|
-
{ name: 'discourse', type: 'string' },
|
|
249
|
-
{ name: 'status', type: 'string' },
|
|
250
|
-
{ name: 'network', type: 'string' }
|
|
251
|
-
]
|
|
252
|
-
};
|
|
253
|
-
const aliasTypes = {
|
|
254
|
-
Alias: [
|
|
255
|
-
{ name: 'from', type: 'address' },
|
|
256
|
-
{ name: 'alias', type: 'address' },
|
|
257
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
258
|
-
]
|
|
259
|
-
};
|
|
260
|
-
const deleteSpaceType = {
|
|
261
|
-
DeleteSpace: [
|
|
262
|
-
{ name: 'from', type: 'address' },
|
|
263
|
-
{ name: 'space', type: 'string' },
|
|
264
|
-
{ name: 'timestamp', type: 'uint64' }
|
|
265
|
-
]
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
var mainnet = {
|
|
269
|
-
hub: "https://hub.snapshot.org",
|
|
270
|
-
sequencer: "https://seq.snapshot.org"
|
|
271
|
-
};
|
|
272
|
-
var testnet = {
|
|
273
|
-
hub: "https://testnet.hub.snapshot.org",
|
|
274
|
-
sequencer: "https://testnet.seq.snapshot.org"
|
|
275
|
-
};
|
|
276
|
-
var local = {
|
|
277
|
-
hub: "http://localhost:3000",
|
|
278
|
-
sequencer: "http://localhost:3001"
|
|
279
|
-
};
|
|
280
|
-
var constants = {
|
|
281
|
-
mainnet: mainnet,
|
|
282
|
-
testnet: testnet,
|
|
283
|
-
local: local
|
|
284
|
-
};
|
|
285
|
-
|
|
286
65
|
let cache = {};
|
|
287
66
|
let expirationTime = 0;
|
|
288
67
|
function getSnapshots(network_1, snapshot_1, provider_1, networks_1) {
|
|
@@ -3645,7 +3424,7 @@ function getDomainType(domain) {
|
|
|
3645
3424
|
function getDNSOwner(domain) {
|
|
3646
3425
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3647
3426
|
var _a;
|
|
3648
|
-
const response = yield
|
|
3427
|
+
const response = yield fetch(`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
3649
3428
|
headers: {
|
|
3650
3429
|
accept: 'application/dns-json'
|
|
3651
3430
|
}
|
|
@@ -3679,7 +3458,7 @@ function subgraphRequest(url_1, query_1) {
|
|
|
3679
3458
|
const body = { query: jsonToGraphqlQuery.jsonToGraphQLQuery({ query }) };
|
|
3680
3459
|
if (options.variables)
|
|
3681
3460
|
body.variables = options.variables;
|
|
3682
|
-
const res = yield
|
|
3461
|
+
const res = yield fetch(url, {
|
|
3683
3462
|
method: 'POST',
|
|
3684
3463
|
headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers),
|
|
3685
3464
|
body: JSON.stringify(body)
|
|
@@ -3714,16 +3493,73 @@ function getUrl(uri, gateway = gateways[0]) {
|
|
|
3714
3493
|
return uri.replace('ipns://', `${ipfsGateway}/ipns/`);
|
|
3715
3494
|
return uri;
|
|
3716
3495
|
}
|
|
3496
|
+
/**
|
|
3497
|
+
* Enhanced fetch with timeout support - drop-in replacement for native fetch
|
|
3498
|
+
*
|
|
3499
|
+
* @param url - The URL to fetch
|
|
3500
|
+
* @param options - Fetch options with optional timeout
|
|
3501
|
+
* @param options.timeout - Request timeout in milliseconds (default: 30000ms). Set to 0 to disable timeout.
|
|
3502
|
+
*
|
|
3503
|
+
* @returns Promise that resolves to the Response object
|
|
3504
|
+
*
|
|
3505
|
+
* @throws {Error} Throws timeout error if request exceeds the specified timeout duration
|
|
3506
|
+
*
|
|
3507
|
+
* @example
|
|
3508
|
+
* ```typescript
|
|
3509
|
+
* // Uses default 30s timeout
|
|
3510
|
+
* const response = await fetch('https://api.example.com/data');
|
|
3511
|
+
*
|
|
3512
|
+
* // Custom 5s timeout
|
|
3513
|
+
* const response = await fetch('https://api.example.com/data', { timeout: 5000 });
|
|
3514
|
+
*
|
|
3515
|
+
* // Disable timeout
|
|
3516
|
+
* const response = await fetch('https://api.example.com/data', { timeout: 0 });
|
|
3517
|
+
*
|
|
3518
|
+
* // With additional fetch options
|
|
3519
|
+
* const response = await fetch('https://api.example.com/data', {
|
|
3520
|
+
* timeout: 10000,
|
|
3521
|
+
* method: 'POST',
|
|
3522
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
3523
|
+
* body: JSON.stringify({ key: 'value' })
|
|
3524
|
+
* });
|
|
3525
|
+
* ```
|
|
3526
|
+
*/
|
|
3527
|
+
function fetch(url_1) {
|
|
3528
|
+
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
3529
|
+
const { timeout = 30000 } = options, fetchOptions = __rest(options, ["timeout"]);
|
|
3530
|
+
if (timeout > 0) {
|
|
3531
|
+
const controller = new AbortController();
|
|
3532
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
3533
|
+
try {
|
|
3534
|
+
const response = yield crossFetch__default['default'](url, Object.assign(Object.assign({}, fetchOptions), { signal: controller.signal }));
|
|
3535
|
+
return response;
|
|
3536
|
+
}
|
|
3537
|
+
catch (error) {
|
|
3538
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
3539
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
3540
|
+
}
|
|
3541
|
+
throw error;
|
|
3542
|
+
}
|
|
3543
|
+
finally {
|
|
3544
|
+
clearTimeout(timeoutId);
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3548
|
+
const cleanFetchOptions = __rest(fetchOptions, ["signal"]);
|
|
3549
|
+
return crossFetch__default['default'](url, cleanFetchOptions);
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3717
3552
|
function getJSON(uri_1) {
|
|
3718
3553
|
return __awaiter(this, arguments, void 0, function* (uri, options = {}) {
|
|
3719
3554
|
const url = getUrl(uri, options.gateways);
|
|
3720
|
-
|
|
3555
|
+
const response = yield fetch(url, options);
|
|
3556
|
+
return response.json();
|
|
3721
3557
|
});
|
|
3722
3558
|
}
|
|
3723
3559
|
function ipfsGet(gateway_1, ipfsHash_1) {
|
|
3724
3560
|
return __awaiter(this, arguments, void 0, function* (gateway, ipfsHash, protocolType = 'ipfs') {
|
|
3725
3561
|
const url = `https://${gateway}/${protocolType}/${ipfsHash}`;
|
|
3726
|
-
return
|
|
3562
|
+
return fetch(url).then((res) => res.json());
|
|
3727
3563
|
});
|
|
3728
3564
|
}
|
|
3729
3565
|
function sendTransaction(web3_1, contractAddress_1, abi_1, action_1, params_1) {
|
|
@@ -3770,7 +3606,7 @@ function getScores(space_1, strategies_1, network_1, addresses_1) {
|
|
|
3770
3606
|
strategies,
|
|
3771
3607
|
addresses
|
|
3772
3608
|
};
|
|
3773
|
-
const res = yield
|
|
3609
|
+
const res = yield fetch(url, {
|
|
3774
3610
|
method: 'POST',
|
|
3775
3611
|
headers,
|
|
3776
3612
|
body: JSON.stringify({ params })
|
|
@@ -3821,7 +3657,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
|
|
|
3821
3657
|
})
|
|
3822
3658
|
};
|
|
3823
3659
|
try {
|
|
3824
|
-
const res = yield
|
|
3660
|
+
const res = yield fetch(url, init);
|
|
3825
3661
|
const response = yield parseScoreAPIResponse(res);
|
|
3826
3662
|
return response.result;
|
|
3827
3663
|
}
|
|
@@ -3864,7 +3700,7 @@ function validate(validation, author, space, network, snapshot, params, options)
|
|
|
3864
3700
|
})
|
|
3865
3701
|
};
|
|
3866
3702
|
try {
|
|
3867
|
-
const res = yield
|
|
3703
|
+
const res = yield fetch(url, init);
|
|
3868
3704
|
const response = yield parseScoreAPIResponse(res);
|
|
3869
3705
|
return response.result;
|
|
3870
3706
|
}
|
|
@@ -3987,7 +3823,7 @@ function getShibariumNameOwner(id, network) {
|
|
|
3987
3823
|
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
3988
3824
|
return EMPTY_ADDRESS;
|
|
3989
3825
|
}
|
|
3990
|
-
const response = yield
|
|
3826
|
+
const response = yield fetch('https://stamp.fyi', {
|
|
3991
3827
|
method: 'POST',
|
|
3992
3828
|
headers: {
|
|
3993
3829
|
'Content-Type': 'application/json'
|
|
@@ -4092,6 +3928,7 @@ function inputError(message) {
|
|
|
4092
3928
|
var utils = {
|
|
4093
3929
|
call,
|
|
4094
3930
|
multicall: multicall$2,
|
|
3931
|
+
fetch,
|
|
4095
3932
|
subgraphRequest,
|
|
4096
3933
|
ipfsGet,
|
|
4097
3934
|
getUrl,
|
|
@@ -4123,6 +3960,227 @@ var utils = {
|
|
|
4123
3960
|
SNAPSHOT_SUBGRAPH_URL
|
|
4124
3961
|
};
|
|
4125
3962
|
|
|
3963
|
+
const spaceTypes = {
|
|
3964
|
+
Space: [
|
|
3965
|
+
{ name: 'from', type: 'address' },
|
|
3966
|
+
{ name: 'space', type: 'string' },
|
|
3967
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
3968
|
+
{ name: 'settings', type: 'string' }
|
|
3969
|
+
]
|
|
3970
|
+
};
|
|
3971
|
+
const proposalTypes = {
|
|
3972
|
+
Proposal: [
|
|
3973
|
+
{ name: 'from', type: 'string' },
|
|
3974
|
+
{ name: 'space', type: 'string' },
|
|
3975
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
3976
|
+
{ name: 'type', type: 'string' },
|
|
3977
|
+
{ name: 'title', type: 'string' },
|
|
3978
|
+
{ name: 'body', type: 'string' },
|
|
3979
|
+
{ name: 'discussion', type: 'string' },
|
|
3980
|
+
{ name: 'choices', type: 'string[]' },
|
|
3981
|
+
{ name: 'labels', type: 'string[]' },
|
|
3982
|
+
{ name: 'start', type: 'uint64' },
|
|
3983
|
+
{ name: 'end', type: 'uint64' },
|
|
3984
|
+
{ name: 'snapshot', type: 'uint64' },
|
|
3985
|
+
{ name: 'plugins', type: 'string' },
|
|
3986
|
+
{ name: 'privacy', type: 'string' },
|
|
3987
|
+
{ name: 'app', type: 'string' }
|
|
3988
|
+
]
|
|
3989
|
+
};
|
|
3990
|
+
const updateProposalTypes = {
|
|
3991
|
+
UpdateProposal: [
|
|
3992
|
+
{ name: 'proposal', type: 'string' },
|
|
3993
|
+
{ name: 'from', type: 'string' },
|
|
3994
|
+
{ name: 'space', type: 'string' },
|
|
3995
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
3996
|
+
{ name: 'type', type: 'string' },
|
|
3997
|
+
{ name: 'title', type: 'string' },
|
|
3998
|
+
{ name: 'body', type: 'string' },
|
|
3999
|
+
{ name: 'discussion', type: 'string' },
|
|
4000
|
+
{ name: 'choices', type: 'string[]' },
|
|
4001
|
+
{ name: 'labels', type: 'string[]' },
|
|
4002
|
+
{ name: 'plugins', type: 'string' },
|
|
4003
|
+
{ name: 'privacy', type: 'string' }
|
|
4004
|
+
]
|
|
4005
|
+
};
|
|
4006
|
+
const flagProposalTypes = {
|
|
4007
|
+
FlagProposal: [
|
|
4008
|
+
{ name: 'from', type: 'string' },
|
|
4009
|
+
{ name: 'space', type: 'string' },
|
|
4010
|
+
{ name: 'proposal', type: 'string' },
|
|
4011
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4012
|
+
]
|
|
4013
|
+
};
|
|
4014
|
+
const cancelProposalTypes = {
|
|
4015
|
+
CancelProposal: [
|
|
4016
|
+
{ name: 'from', type: 'string' },
|
|
4017
|
+
{ name: 'space', type: 'string' },
|
|
4018
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4019
|
+
{ name: 'proposal', type: 'string' }
|
|
4020
|
+
]
|
|
4021
|
+
};
|
|
4022
|
+
const cancelProposal2Types = {
|
|
4023
|
+
CancelProposal: [
|
|
4024
|
+
{ name: 'from', type: 'string' },
|
|
4025
|
+
{ name: 'space', type: 'string' },
|
|
4026
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4027
|
+
{ name: 'proposal', type: 'bytes32' }
|
|
4028
|
+
]
|
|
4029
|
+
};
|
|
4030
|
+
const voteTypes = {
|
|
4031
|
+
Vote: [
|
|
4032
|
+
{ name: 'from', type: 'string' },
|
|
4033
|
+
{ name: 'space', type: 'string' },
|
|
4034
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4035
|
+
{ name: 'proposal', type: 'string' },
|
|
4036
|
+
{ name: 'choice', type: 'uint32' },
|
|
4037
|
+
{ name: 'reason', type: 'string' },
|
|
4038
|
+
{ name: 'app', type: 'string' },
|
|
4039
|
+
{ name: 'metadata', type: 'string' }
|
|
4040
|
+
]
|
|
4041
|
+
};
|
|
4042
|
+
const voteArrayTypes = {
|
|
4043
|
+
Vote: [
|
|
4044
|
+
{ name: 'from', type: 'string' },
|
|
4045
|
+
{ name: 'space', type: 'string' },
|
|
4046
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4047
|
+
{ name: 'proposal', type: 'string' },
|
|
4048
|
+
{ name: 'choice', type: 'uint32[]' },
|
|
4049
|
+
{ name: 'reason', type: 'string' },
|
|
4050
|
+
{ name: 'app', type: 'string' },
|
|
4051
|
+
{ name: 'metadata', type: 'string' }
|
|
4052
|
+
]
|
|
4053
|
+
};
|
|
4054
|
+
const voteStringTypes = {
|
|
4055
|
+
Vote: [
|
|
4056
|
+
{ name: 'from', type: 'string' },
|
|
4057
|
+
{ name: 'space', type: 'string' },
|
|
4058
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4059
|
+
{ name: 'proposal', type: 'string' },
|
|
4060
|
+
{ name: 'choice', type: 'string' },
|
|
4061
|
+
{ name: 'reason', type: 'string' },
|
|
4062
|
+
{ name: 'app', type: 'string' },
|
|
4063
|
+
{ name: 'metadata', type: 'string' }
|
|
4064
|
+
]
|
|
4065
|
+
};
|
|
4066
|
+
const vote2Types = {
|
|
4067
|
+
Vote: [
|
|
4068
|
+
{ name: 'from', type: 'string' },
|
|
4069
|
+
{ name: 'space', type: 'string' },
|
|
4070
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4071
|
+
{ name: 'proposal', type: 'bytes32' },
|
|
4072
|
+
{ name: 'choice', type: 'uint32' },
|
|
4073
|
+
{ name: 'reason', type: 'string' },
|
|
4074
|
+
{ name: 'app', type: 'string' },
|
|
4075
|
+
{ name: 'metadata', type: 'string' }
|
|
4076
|
+
]
|
|
4077
|
+
};
|
|
4078
|
+
const voteArray2Types = {
|
|
4079
|
+
Vote: [
|
|
4080
|
+
{ name: 'from', type: 'string' },
|
|
4081
|
+
{ name: 'space', type: 'string' },
|
|
4082
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4083
|
+
{ name: 'proposal', type: 'bytes32' },
|
|
4084
|
+
{ name: 'choice', type: 'uint32[]' },
|
|
4085
|
+
{ name: 'reason', type: 'string' },
|
|
4086
|
+
{ name: 'app', type: 'string' },
|
|
4087
|
+
{ name: 'metadata', type: 'string' }
|
|
4088
|
+
]
|
|
4089
|
+
};
|
|
4090
|
+
const voteString2Types = {
|
|
4091
|
+
Vote: [
|
|
4092
|
+
{ name: 'from', type: 'string' },
|
|
4093
|
+
{ name: 'space', type: 'string' },
|
|
4094
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4095
|
+
{ name: 'proposal', type: 'bytes32' },
|
|
4096
|
+
{ name: 'choice', type: 'string' },
|
|
4097
|
+
{ name: 'reason', type: 'string' },
|
|
4098
|
+
{ name: 'app', type: 'string' },
|
|
4099
|
+
{ name: 'metadata', type: 'string' }
|
|
4100
|
+
]
|
|
4101
|
+
};
|
|
4102
|
+
const followTypes = {
|
|
4103
|
+
Follow: [
|
|
4104
|
+
{ name: 'from', type: 'address' },
|
|
4105
|
+
{ name: 'network', type: 'string' },
|
|
4106
|
+
{ name: 'space', type: 'string' },
|
|
4107
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4108
|
+
]
|
|
4109
|
+
};
|
|
4110
|
+
const unfollowTypes = {
|
|
4111
|
+
Unfollow: [
|
|
4112
|
+
{ name: 'from', type: 'address' },
|
|
4113
|
+
{ name: 'network', type: 'string' },
|
|
4114
|
+
{ name: 'space', type: 'string' },
|
|
4115
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4116
|
+
]
|
|
4117
|
+
};
|
|
4118
|
+
const subscribeTypes = {
|
|
4119
|
+
Subscribe: [
|
|
4120
|
+
{ name: 'from', type: 'address' },
|
|
4121
|
+
{ name: 'space', type: 'string' },
|
|
4122
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4123
|
+
]
|
|
4124
|
+
};
|
|
4125
|
+
const unsubscribeTypes = {
|
|
4126
|
+
Unsubscribe: [
|
|
4127
|
+
{ name: 'from', type: 'address' },
|
|
4128
|
+
{ name: 'space', type: 'string' },
|
|
4129
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4130
|
+
]
|
|
4131
|
+
};
|
|
4132
|
+
const profileTypes = {
|
|
4133
|
+
Profile: [
|
|
4134
|
+
{ name: 'from', type: 'address' },
|
|
4135
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4136
|
+
{ name: 'profile', type: 'string' }
|
|
4137
|
+
]
|
|
4138
|
+
};
|
|
4139
|
+
const statementTypes = {
|
|
4140
|
+
Statement: [
|
|
4141
|
+
{ name: 'from', type: 'address' },
|
|
4142
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4143
|
+
{ name: 'space', type: 'string' },
|
|
4144
|
+
{ name: 'about', type: 'string' },
|
|
4145
|
+
{ name: 'statement', type: 'string' },
|
|
4146
|
+
{ name: 'discourse', type: 'string' },
|
|
4147
|
+
{ name: 'status', type: 'string' },
|
|
4148
|
+
{ name: 'network', type: 'string' }
|
|
4149
|
+
]
|
|
4150
|
+
};
|
|
4151
|
+
const aliasTypes = {
|
|
4152
|
+
Alias: [
|
|
4153
|
+
{ name: 'from', type: 'address' },
|
|
4154
|
+
{ name: 'alias', type: 'address' },
|
|
4155
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4156
|
+
]
|
|
4157
|
+
};
|
|
4158
|
+
const deleteSpaceType = {
|
|
4159
|
+
DeleteSpace: [
|
|
4160
|
+
{ name: 'from', type: 'address' },
|
|
4161
|
+
{ name: 'space', type: 'string' },
|
|
4162
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4163
|
+
]
|
|
4164
|
+
};
|
|
4165
|
+
|
|
4166
|
+
var mainnet = {
|
|
4167
|
+
hub: "https://hub.snapshot.org",
|
|
4168
|
+
sequencer: "https://seq.snapshot.org"
|
|
4169
|
+
};
|
|
4170
|
+
var testnet = {
|
|
4171
|
+
hub: "https://testnet.hub.snapshot.org",
|
|
4172
|
+
sequencer: "https://testnet.seq.snapshot.org"
|
|
4173
|
+
};
|
|
4174
|
+
var local = {
|
|
4175
|
+
hub: "http://localhost:3000",
|
|
4176
|
+
sequencer: "http://localhost:3001"
|
|
4177
|
+
};
|
|
4178
|
+
var constants = {
|
|
4179
|
+
mainnet: mainnet,
|
|
4180
|
+
testnet: testnet,
|
|
4181
|
+
local: local
|
|
4182
|
+
};
|
|
4183
|
+
|
|
4126
4184
|
const NAME = 'snapshot';
|
|
4127
4185
|
const VERSION = '0.1.4';
|
|
4128
4186
|
const domain = {
|
|
@@ -4173,7 +4231,7 @@ class Client {
|
|
|
4173
4231
|
body: JSON.stringify(envelop)
|
|
4174
4232
|
};
|
|
4175
4233
|
return new Promise((resolve, reject) => {
|
|
4176
|
-
|
|
4234
|
+
fetch(address, init)
|
|
4177
4235
|
.then((res) => {
|
|
4178
4236
|
var _a;
|
|
4179
4237
|
if (res.ok)
|