@snapshot-labs/snapshot.js 0.14.5 → 0.14.7
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 +306 -233
- package/dist/snapshot.esm.js +297 -224
- 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/networks.json +14 -0
- package/src/sign/index.ts +1 -1
- package/src/utils.ts +70 -2
- package/src/voting/rankedChoice.ts +1 -1
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) {
|
|
@@ -743,6 +522,21 @@ var networks = {
|
|
|
743
522
|
},
|
|
744
523
|
start: 1290,
|
|
745
524
|
logo: "ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"
|
|
525
|
+
},
|
|
526
|
+
"151": {
|
|
527
|
+
key: "151",
|
|
528
|
+
name: "Redbelly",
|
|
529
|
+
shortName: "mainnet",
|
|
530
|
+
chainId: 151,
|
|
531
|
+
network: "mainnet",
|
|
532
|
+
multicall: "0xEe43BBcC6340038130681F98d855E416F7F728e9",
|
|
533
|
+
rpc: [
|
|
534
|
+
],
|
|
535
|
+
explorer: {
|
|
536
|
+
url: "https://redbelly.routescan.io"
|
|
537
|
+
},
|
|
538
|
+
start: 1908395,
|
|
539
|
+
logo: "ipfs://bafkreie5mdk5shaebcec6zs5dc4722u2tn7oxvkksjy62kkjdzgnvmad7q"
|
|
746
540
|
},
|
|
747
541
|
"157": {
|
|
748
542
|
key: "157",
|
|
@@ -2911,7 +2705,7 @@ class RankedChoiceVoting {
|
|
|
2911
2705
|
return this.proposal.choices.map((choice, i) => this.strategies.map((strategy, sI) => {
|
|
2912
2706
|
return finalRound
|
|
2913
2707
|
.filter((res) => Number(res[0]) === i + 1)
|
|
2914
|
-
.reduce((a, b) => a + b[1][1][sI], 0);
|
|
2708
|
+
.reduce((a, b) => a + b[1][1][sI] || 0, 0);
|
|
2915
2709
|
}));
|
|
2916
2710
|
}
|
|
2917
2711
|
getScoresTotal() {
|
|
@@ -3645,7 +3439,7 @@ function getDomainType(domain) {
|
|
|
3645
3439
|
function getDNSOwner(domain) {
|
|
3646
3440
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3647
3441
|
var _a;
|
|
3648
|
-
const response = yield
|
|
3442
|
+
const response = yield fetch(`https://cloudflare-dns.com/dns-query?name=${domain}&type=TXT`, {
|
|
3649
3443
|
headers: {
|
|
3650
3444
|
accept: 'application/dns-json'
|
|
3651
3445
|
}
|
|
@@ -3679,7 +3473,7 @@ function subgraphRequest(url_1, query_1) {
|
|
|
3679
3473
|
const body = { query: jsonToGraphqlQuery.jsonToGraphQLQuery({ query }) };
|
|
3680
3474
|
if (options.variables)
|
|
3681
3475
|
body.variables = options.variables;
|
|
3682
|
-
const res = yield
|
|
3476
|
+
const res = yield fetch(url, {
|
|
3683
3477
|
method: 'POST',
|
|
3684
3478
|
headers: Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers),
|
|
3685
3479
|
body: JSON.stringify(body)
|
|
@@ -3714,16 +3508,73 @@ function getUrl(uri, gateway = gateways[0]) {
|
|
|
3714
3508
|
return uri.replace('ipns://', `${ipfsGateway}/ipns/`);
|
|
3715
3509
|
return uri;
|
|
3716
3510
|
}
|
|
3511
|
+
/**
|
|
3512
|
+
* Enhanced fetch with timeout support - drop-in replacement for native fetch
|
|
3513
|
+
*
|
|
3514
|
+
* @param url - The URL to fetch
|
|
3515
|
+
* @param options - Fetch options with optional timeout
|
|
3516
|
+
* @param options.timeout - Request timeout in milliseconds (default: 30000ms). Set to 0 to disable timeout.
|
|
3517
|
+
*
|
|
3518
|
+
* @returns Promise that resolves to the Response object
|
|
3519
|
+
*
|
|
3520
|
+
* @throws {Error} Throws timeout error if request exceeds the specified timeout duration
|
|
3521
|
+
*
|
|
3522
|
+
* @example
|
|
3523
|
+
* ```typescript
|
|
3524
|
+
* // Uses default 30s timeout
|
|
3525
|
+
* const response = await fetch('https://api.example.com/data');
|
|
3526
|
+
*
|
|
3527
|
+
* // Custom 5s timeout
|
|
3528
|
+
* const response = await fetch('https://api.example.com/data', { timeout: 5000 });
|
|
3529
|
+
*
|
|
3530
|
+
* // Disable timeout
|
|
3531
|
+
* const response = await fetch('https://api.example.com/data', { timeout: 0 });
|
|
3532
|
+
*
|
|
3533
|
+
* // With additional fetch options
|
|
3534
|
+
* const response = await fetch('https://api.example.com/data', {
|
|
3535
|
+
* timeout: 10000,
|
|
3536
|
+
* method: 'POST',
|
|
3537
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
3538
|
+
* body: JSON.stringify({ key: 'value' })
|
|
3539
|
+
* });
|
|
3540
|
+
* ```
|
|
3541
|
+
*/
|
|
3542
|
+
function fetch(url_1) {
|
|
3543
|
+
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
3544
|
+
const { timeout = 30000 } = options, fetchOptions = __rest(options, ["timeout"]);
|
|
3545
|
+
if (timeout > 0) {
|
|
3546
|
+
const controller = new AbortController();
|
|
3547
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
3548
|
+
try {
|
|
3549
|
+
const response = yield crossFetch__default['default'](url, Object.assign(Object.assign({}, fetchOptions), { signal: controller.signal }));
|
|
3550
|
+
return response;
|
|
3551
|
+
}
|
|
3552
|
+
catch (error) {
|
|
3553
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
3554
|
+
throw new Error(`Request timeout after ${timeout}ms`);
|
|
3555
|
+
}
|
|
3556
|
+
throw error;
|
|
3557
|
+
}
|
|
3558
|
+
finally {
|
|
3559
|
+
clearTimeout(timeoutId);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3563
|
+
const cleanFetchOptions = __rest(fetchOptions, ["signal"]);
|
|
3564
|
+
return crossFetch__default['default'](url, cleanFetchOptions);
|
|
3565
|
+
});
|
|
3566
|
+
}
|
|
3717
3567
|
function getJSON(uri_1) {
|
|
3718
3568
|
return __awaiter(this, arguments, void 0, function* (uri, options = {}) {
|
|
3719
3569
|
const url = getUrl(uri, options.gateways);
|
|
3720
|
-
|
|
3570
|
+
const response = yield fetch(url, options);
|
|
3571
|
+
return response.json();
|
|
3721
3572
|
});
|
|
3722
3573
|
}
|
|
3723
3574
|
function ipfsGet(gateway_1, ipfsHash_1) {
|
|
3724
3575
|
return __awaiter(this, arguments, void 0, function* (gateway, ipfsHash, protocolType = 'ipfs') {
|
|
3725
3576
|
const url = `https://${gateway}/${protocolType}/${ipfsHash}`;
|
|
3726
|
-
return
|
|
3577
|
+
return fetch(url).then((res) => res.json());
|
|
3727
3578
|
});
|
|
3728
3579
|
}
|
|
3729
3580
|
function sendTransaction(web3_1, contractAddress_1, abi_1, action_1, params_1) {
|
|
@@ -3770,7 +3621,7 @@ function getScores(space_1, strategies_1, network_1, addresses_1) {
|
|
|
3770
3621
|
strategies,
|
|
3771
3622
|
addresses
|
|
3772
3623
|
};
|
|
3773
|
-
const res = yield
|
|
3624
|
+
const res = yield fetch(url, {
|
|
3774
3625
|
method: 'POST',
|
|
3775
3626
|
headers,
|
|
3776
3627
|
body: JSON.stringify({ params })
|
|
@@ -3821,7 +3672,7 @@ function getVp(address, network, strategies, snapshot, space, delegation, option
|
|
|
3821
3672
|
})
|
|
3822
3673
|
};
|
|
3823
3674
|
try {
|
|
3824
|
-
const res = yield
|
|
3675
|
+
const res = yield fetch(url, init);
|
|
3825
3676
|
const response = yield parseScoreAPIResponse(res);
|
|
3826
3677
|
return response.result;
|
|
3827
3678
|
}
|
|
@@ -3864,7 +3715,7 @@ function validate(validation, author, space, network, snapshot, params, options)
|
|
|
3864
3715
|
})
|
|
3865
3716
|
};
|
|
3866
3717
|
try {
|
|
3867
|
-
const res = yield
|
|
3718
|
+
const res = yield fetch(url, init);
|
|
3868
3719
|
const response = yield parseScoreAPIResponse(res);
|
|
3869
3720
|
return response.result;
|
|
3870
3721
|
}
|
|
@@ -3987,7 +3838,7 @@ function getShibariumNameOwner(id, network) {
|
|
|
3987
3838
|
if (!id.endsWith(SHIBARIUM_TLD)) {
|
|
3988
3839
|
return EMPTY_ADDRESS;
|
|
3989
3840
|
}
|
|
3990
|
-
const response = yield
|
|
3841
|
+
const response = yield fetch('https://stamp.fyi', {
|
|
3991
3842
|
method: 'POST',
|
|
3992
3843
|
headers: {
|
|
3993
3844
|
'Content-Type': 'application/json'
|
|
@@ -4092,6 +3943,7 @@ function inputError(message) {
|
|
|
4092
3943
|
var utils = {
|
|
4093
3944
|
call,
|
|
4094
3945
|
multicall: multicall$2,
|
|
3946
|
+
fetch,
|
|
4095
3947
|
subgraphRequest,
|
|
4096
3948
|
ipfsGet,
|
|
4097
3949
|
getUrl,
|
|
@@ -4123,6 +3975,227 @@ var utils = {
|
|
|
4123
3975
|
SNAPSHOT_SUBGRAPH_URL
|
|
4124
3976
|
};
|
|
4125
3977
|
|
|
3978
|
+
const spaceTypes = {
|
|
3979
|
+
Space: [
|
|
3980
|
+
{ name: 'from', type: 'address' },
|
|
3981
|
+
{ name: 'space', type: 'string' },
|
|
3982
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
3983
|
+
{ name: 'settings', type: 'string' }
|
|
3984
|
+
]
|
|
3985
|
+
};
|
|
3986
|
+
const proposalTypes = {
|
|
3987
|
+
Proposal: [
|
|
3988
|
+
{ name: 'from', type: 'string' },
|
|
3989
|
+
{ name: 'space', type: 'string' },
|
|
3990
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
3991
|
+
{ name: 'type', type: 'string' },
|
|
3992
|
+
{ name: 'title', type: 'string' },
|
|
3993
|
+
{ name: 'body', type: 'string' },
|
|
3994
|
+
{ name: 'discussion', type: 'string' },
|
|
3995
|
+
{ name: 'choices', type: 'string[]' },
|
|
3996
|
+
{ name: 'labels', type: 'string[]' },
|
|
3997
|
+
{ name: 'start', type: 'uint64' },
|
|
3998
|
+
{ name: 'end', type: 'uint64' },
|
|
3999
|
+
{ name: 'snapshot', type: 'uint64' },
|
|
4000
|
+
{ name: 'plugins', type: 'string' },
|
|
4001
|
+
{ name: 'privacy', type: 'string' },
|
|
4002
|
+
{ name: 'app', type: 'string' }
|
|
4003
|
+
]
|
|
4004
|
+
};
|
|
4005
|
+
const updateProposalTypes = {
|
|
4006
|
+
UpdateProposal: [
|
|
4007
|
+
{ name: 'proposal', type: 'string' },
|
|
4008
|
+
{ name: 'from', type: 'string' },
|
|
4009
|
+
{ name: 'space', type: 'string' },
|
|
4010
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4011
|
+
{ name: 'type', type: 'string' },
|
|
4012
|
+
{ name: 'title', type: 'string' },
|
|
4013
|
+
{ name: 'body', type: 'string' },
|
|
4014
|
+
{ name: 'discussion', type: 'string' },
|
|
4015
|
+
{ name: 'choices', type: 'string[]' },
|
|
4016
|
+
{ name: 'labels', type: 'string[]' },
|
|
4017
|
+
{ name: 'plugins', type: 'string' },
|
|
4018
|
+
{ name: 'privacy', type: 'string' }
|
|
4019
|
+
]
|
|
4020
|
+
};
|
|
4021
|
+
const flagProposalTypes = {
|
|
4022
|
+
FlagProposal: [
|
|
4023
|
+
{ name: 'from', type: 'string' },
|
|
4024
|
+
{ name: 'space', type: 'string' },
|
|
4025
|
+
{ name: 'proposal', type: 'string' },
|
|
4026
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4027
|
+
]
|
|
4028
|
+
};
|
|
4029
|
+
const cancelProposalTypes = {
|
|
4030
|
+
CancelProposal: [
|
|
4031
|
+
{ name: 'from', type: 'string' },
|
|
4032
|
+
{ name: 'space', type: 'string' },
|
|
4033
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4034
|
+
{ name: 'proposal', type: 'string' }
|
|
4035
|
+
]
|
|
4036
|
+
};
|
|
4037
|
+
const cancelProposal2Types = {
|
|
4038
|
+
CancelProposal: [
|
|
4039
|
+
{ name: 'from', type: 'string' },
|
|
4040
|
+
{ name: 'space', type: 'string' },
|
|
4041
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4042
|
+
{ name: 'proposal', type: 'bytes32' }
|
|
4043
|
+
]
|
|
4044
|
+
};
|
|
4045
|
+
const voteTypes = {
|
|
4046
|
+
Vote: [
|
|
4047
|
+
{ name: 'from', type: 'string' },
|
|
4048
|
+
{ name: 'space', type: 'string' },
|
|
4049
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4050
|
+
{ name: 'proposal', type: 'string' },
|
|
4051
|
+
{ name: 'choice', type: 'uint32' },
|
|
4052
|
+
{ name: 'reason', type: 'string' },
|
|
4053
|
+
{ name: 'app', type: 'string' },
|
|
4054
|
+
{ name: 'metadata', type: 'string' }
|
|
4055
|
+
]
|
|
4056
|
+
};
|
|
4057
|
+
const voteArrayTypes = {
|
|
4058
|
+
Vote: [
|
|
4059
|
+
{ name: 'from', type: 'string' },
|
|
4060
|
+
{ name: 'space', type: 'string' },
|
|
4061
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4062
|
+
{ name: 'proposal', type: 'string' },
|
|
4063
|
+
{ name: 'choice', type: 'uint32[]' },
|
|
4064
|
+
{ name: 'reason', type: 'string' },
|
|
4065
|
+
{ name: 'app', type: 'string' },
|
|
4066
|
+
{ name: 'metadata', type: 'string' }
|
|
4067
|
+
]
|
|
4068
|
+
};
|
|
4069
|
+
const voteStringTypes = {
|
|
4070
|
+
Vote: [
|
|
4071
|
+
{ name: 'from', type: 'string' },
|
|
4072
|
+
{ name: 'space', type: 'string' },
|
|
4073
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4074
|
+
{ name: 'proposal', type: 'string' },
|
|
4075
|
+
{ name: 'choice', type: 'string' },
|
|
4076
|
+
{ name: 'reason', type: 'string' },
|
|
4077
|
+
{ name: 'app', type: 'string' },
|
|
4078
|
+
{ name: 'metadata', type: 'string' }
|
|
4079
|
+
]
|
|
4080
|
+
};
|
|
4081
|
+
const vote2Types = {
|
|
4082
|
+
Vote: [
|
|
4083
|
+
{ name: 'from', type: 'string' },
|
|
4084
|
+
{ name: 'space', type: 'string' },
|
|
4085
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4086
|
+
{ name: 'proposal', type: 'bytes32' },
|
|
4087
|
+
{ name: 'choice', type: 'uint32' },
|
|
4088
|
+
{ name: 'reason', type: 'string' },
|
|
4089
|
+
{ name: 'app', type: 'string' },
|
|
4090
|
+
{ name: 'metadata', type: 'string' }
|
|
4091
|
+
]
|
|
4092
|
+
};
|
|
4093
|
+
const voteArray2Types = {
|
|
4094
|
+
Vote: [
|
|
4095
|
+
{ name: 'from', type: 'string' },
|
|
4096
|
+
{ name: 'space', type: 'string' },
|
|
4097
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4098
|
+
{ name: 'proposal', type: 'bytes32' },
|
|
4099
|
+
{ name: 'choice', type: 'uint32[]' },
|
|
4100
|
+
{ name: 'reason', type: 'string' },
|
|
4101
|
+
{ name: 'app', type: 'string' },
|
|
4102
|
+
{ name: 'metadata', type: 'string' }
|
|
4103
|
+
]
|
|
4104
|
+
};
|
|
4105
|
+
const voteString2Types = {
|
|
4106
|
+
Vote: [
|
|
4107
|
+
{ name: 'from', type: 'string' },
|
|
4108
|
+
{ name: 'space', type: 'string' },
|
|
4109
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4110
|
+
{ name: 'proposal', type: 'bytes32' },
|
|
4111
|
+
{ name: 'choice', type: 'string' },
|
|
4112
|
+
{ name: 'reason', type: 'string' },
|
|
4113
|
+
{ name: 'app', type: 'string' },
|
|
4114
|
+
{ name: 'metadata', type: 'string' }
|
|
4115
|
+
]
|
|
4116
|
+
};
|
|
4117
|
+
const followTypes = {
|
|
4118
|
+
Follow: [
|
|
4119
|
+
{ name: 'from', type: 'address' },
|
|
4120
|
+
{ name: 'network', type: 'string' },
|
|
4121
|
+
{ name: 'space', type: 'string' },
|
|
4122
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4123
|
+
]
|
|
4124
|
+
};
|
|
4125
|
+
const unfollowTypes = {
|
|
4126
|
+
Unfollow: [
|
|
4127
|
+
{ name: 'from', type: 'address' },
|
|
4128
|
+
{ name: 'network', type: 'string' },
|
|
4129
|
+
{ name: 'space', type: 'string' },
|
|
4130
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4131
|
+
]
|
|
4132
|
+
};
|
|
4133
|
+
const subscribeTypes = {
|
|
4134
|
+
Subscribe: [
|
|
4135
|
+
{ name: 'from', type: 'address' },
|
|
4136
|
+
{ name: 'space', type: 'string' },
|
|
4137
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4138
|
+
]
|
|
4139
|
+
};
|
|
4140
|
+
const unsubscribeTypes = {
|
|
4141
|
+
Unsubscribe: [
|
|
4142
|
+
{ name: 'from', type: 'address' },
|
|
4143
|
+
{ name: 'space', type: 'string' },
|
|
4144
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4145
|
+
]
|
|
4146
|
+
};
|
|
4147
|
+
const profileTypes = {
|
|
4148
|
+
Profile: [
|
|
4149
|
+
{ name: 'from', type: 'address' },
|
|
4150
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4151
|
+
{ name: 'profile', type: 'string' }
|
|
4152
|
+
]
|
|
4153
|
+
};
|
|
4154
|
+
const statementTypes = {
|
|
4155
|
+
Statement: [
|
|
4156
|
+
{ name: 'from', type: 'address' },
|
|
4157
|
+
{ name: 'timestamp', type: 'uint64' },
|
|
4158
|
+
{ name: 'space', type: 'string' },
|
|
4159
|
+
{ name: 'about', type: 'string' },
|
|
4160
|
+
{ name: 'statement', type: 'string' },
|
|
4161
|
+
{ name: 'discourse', type: 'string' },
|
|
4162
|
+
{ name: 'status', type: 'string' },
|
|
4163
|
+
{ name: 'network', type: 'string' }
|
|
4164
|
+
]
|
|
4165
|
+
};
|
|
4166
|
+
const aliasTypes = {
|
|
4167
|
+
Alias: [
|
|
4168
|
+
{ name: 'from', type: 'address' },
|
|
4169
|
+
{ name: 'alias', type: 'address' },
|
|
4170
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4171
|
+
]
|
|
4172
|
+
};
|
|
4173
|
+
const deleteSpaceType = {
|
|
4174
|
+
DeleteSpace: [
|
|
4175
|
+
{ name: 'from', type: 'address' },
|
|
4176
|
+
{ name: 'space', type: 'string' },
|
|
4177
|
+
{ name: 'timestamp', type: 'uint64' }
|
|
4178
|
+
]
|
|
4179
|
+
};
|
|
4180
|
+
|
|
4181
|
+
var mainnet = {
|
|
4182
|
+
hub: "https://hub.snapshot.org",
|
|
4183
|
+
sequencer: "https://seq.snapshot.org"
|
|
4184
|
+
};
|
|
4185
|
+
var testnet = {
|
|
4186
|
+
hub: "https://testnet.hub.snapshot.org",
|
|
4187
|
+
sequencer: "https://testnet.seq.snapshot.org"
|
|
4188
|
+
};
|
|
4189
|
+
var local = {
|
|
4190
|
+
hub: "http://localhost:3000",
|
|
4191
|
+
sequencer: "http://localhost:3001"
|
|
4192
|
+
};
|
|
4193
|
+
var constants = {
|
|
4194
|
+
mainnet: mainnet,
|
|
4195
|
+
testnet: testnet,
|
|
4196
|
+
local: local
|
|
4197
|
+
};
|
|
4198
|
+
|
|
4126
4199
|
const NAME = 'snapshot';
|
|
4127
4200
|
const VERSION = '0.1.4';
|
|
4128
4201
|
const domain = {
|
|
@@ -4173,7 +4246,7 @@ class Client {
|
|
|
4173
4246
|
body: JSON.stringify(envelop)
|
|
4174
4247
|
};
|
|
4175
4248
|
return new Promise((resolve, reject) => {
|
|
4176
|
-
|
|
4249
|
+
fetch(address, init)
|
|
4177
4250
|
.then((res) => {
|
|
4178
4251
|
var _a;
|
|
4179
4252
|
if (res.ok)
|