@snapshot-labs/snapshot.js 0.14.16 → 0.14.18
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 +7 -59
- package/dist/snapshot.esm.js +8 -60
- package/dist/snapshot.min.js +1 -1
- package/dist/src/sign/types.d.ts +0 -18
- package/dist/src/verify/starknet.d.ts +1 -2
- package/package.json +1 -1
- package/src/networks.json +2 -6
- package/src/sign/index.ts +4 -8
- package/src/sign/types.ts +1 -40
- package/src/verify/starknet.spec.ts +28 -8
- package/src/verify/starknet.ts +3 -18
package/dist/snapshot.cjs.js
CHANGED
|
@@ -2197,7 +2197,6 @@ var networks = {
|
|
|
2197
2197
|
url: "https://starkscan.co"
|
|
2198
2198
|
},
|
|
2199
2199
|
rpc: [
|
|
2200
|
-
"https://starknet-mainnet.public.blastapi.io"
|
|
2201
2200
|
],
|
|
2202
2201
|
start: 8446,
|
|
2203
2202
|
logo: "ipfs://bafkreihbjafyh7eud7r6e5743esaamifcttsvbspfwcrfoc5ykodjdi67m"
|
|
@@ -2216,7 +2215,6 @@ var networks = {
|
|
|
2216
2215
|
url: "https://sepolia.starkscan.co"
|
|
2217
2216
|
},
|
|
2218
2217
|
rpc: [
|
|
2219
|
-
"https://starknet-sepolia.public.blastapi.io"
|
|
2220
2218
|
],
|
|
2221
2219
|
start: 7,
|
|
2222
2220
|
logo: "ipfs://bafkreihbjafyh7eud7r6e5743esaamifcttsvbspfwcrfoc5ykodjdi67m"
|
|
@@ -2296,19 +2294,6 @@ function getBlockNumber(provider) {
|
|
|
2296
2294
|
});
|
|
2297
2295
|
}
|
|
2298
2296
|
|
|
2299
|
-
var _a, _b, _c, _d;
|
|
2300
|
-
const RPC_URLS = {
|
|
2301
|
-
SN_MAIN: (_b = (_a = networks[starknet$1.constants.StarknetChainId.SN_MAIN]) === null || _a === void 0 ? void 0 : _a.rpc) === null || _b === void 0 ? void 0 : _b[0],
|
|
2302
|
-
SN_SEPOLIA: (_d = (_c = networks[starknet$1.constants.StarknetChainId.SN_SEPOLIA]) === null || _c === void 0 ? void 0 : _c.rpc) === null || _d === void 0 ? void 0 : _d[0]
|
|
2303
|
-
};
|
|
2304
|
-
function getProvider$1(network, options) {
|
|
2305
|
-
var _a;
|
|
2306
|
-
if (!RPC_URLS[network])
|
|
2307
|
-
throw new Error('Invalid network');
|
|
2308
|
-
return new starknet$1.RpcProvider({
|
|
2309
|
-
nodeUrl: (_a = options === null || options === void 0 ? void 0 : options.broviderUrl) !== null && _a !== void 0 ? _a : RPC_URLS[network]
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
2297
|
function isStarknetMessage(data) {
|
|
2313
2298
|
return !!data.primaryType && !!data.types.StarkNetDomain;
|
|
2314
2299
|
}
|
|
@@ -2317,9 +2302,9 @@ function getHash(data, address) {
|
|
|
2317
2302
|
return starknet$1.typedData.getMessageHash({ types, primaryType, domain, message }, address);
|
|
2318
2303
|
}
|
|
2319
2304
|
function verify(address_1, sig_1, data_1) {
|
|
2320
|
-
return __awaiter(this, arguments, void 0, function* (address, sig, data, network = '
|
|
2305
|
+
return __awaiter(this, arguments, void 0, function* (address, sig, data, network = '0x534e5f4d41494e', options = {}) {
|
|
2321
2306
|
try {
|
|
2322
|
-
const provider = getProvider
|
|
2307
|
+
const provider = getProvider(network, options);
|
|
2323
2308
|
// Check if the contract is deployed
|
|
2324
2309
|
// Will throw on non-deployed contract
|
|
2325
2310
|
yield provider.getClassAt(address);
|
|
@@ -4123,7 +4108,7 @@ const cancelProposal2Types = {
|
|
|
4123
4108
|
{ name: 'from', type: 'string' },
|
|
4124
4109
|
{ name: 'space', type: 'string' },
|
|
4125
4110
|
{ name: 'timestamp', type: 'uint64' },
|
|
4126
|
-
{ name: 'proposal', type: '
|
|
4111
|
+
{ name: 'proposal', type: 'string' }
|
|
4127
4112
|
]
|
|
4128
4113
|
};
|
|
4129
4114
|
const voteTypes = {
|
|
@@ -4162,42 +4147,6 @@ const voteStringTypes = {
|
|
|
4162
4147
|
{ name: 'metadata', type: 'string' }
|
|
4163
4148
|
]
|
|
4164
4149
|
};
|
|
4165
|
-
const vote2Types = {
|
|
4166
|
-
Vote: [
|
|
4167
|
-
{ name: 'from', type: 'string' },
|
|
4168
|
-
{ name: 'space', type: 'string' },
|
|
4169
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
4170
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
4171
|
-
{ name: 'choice', type: 'uint32' },
|
|
4172
|
-
{ name: 'reason', type: 'string' },
|
|
4173
|
-
{ name: 'app', type: 'string' },
|
|
4174
|
-
{ name: 'metadata', type: 'string' }
|
|
4175
|
-
]
|
|
4176
|
-
};
|
|
4177
|
-
const voteArray2Types = {
|
|
4178
|
-
Vote: [
|
|
4179
|
-
{ name: 'from', type: 'string' },
|
|
4180
|
-
{ name: 'space', type: 'string' },
|
|
4181
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
4182
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
4183
|
-
{ name: 'choice', type: 'uint32[]' },
|
|
4184
|
-
{ name: 'reason', type: 'string' },
|
|
4185
|
-
{ name: 'app', type: 'string' },
|
|
4186
|
-
{ name: 'metadata', type: 'string' }
|
|
4187
|
-
]
|
|
4188
|
-
};
|
|
4189
|
-
const voteString2Types = {
|
|
4190
|
-
Vote: [
|
|
4191
|
-
{ name: 'from', type: 'string' },
|
|
4192
|
-
{ name: 'space', type: 'string' },
|
|
4193
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
4194
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
4195
|
-
{ name: 'choice', type: 'string' },
|
|
4196
|
-
{ name: 'reason', type: 'string' },
|
|
4197
|
-
{ name: 'app', type: 'string' },
|
|
4198
|
-
{ name: 'metadata', type: 'string' }
|
|
4199
|
-
]
|
|
4200
|
-
};
|
|
4201
4150
|
const followTypes = {
|
|
4202
4151
|
Follow: [
|
|
4203
4152
|
{ name: 'from', type: 'address' },
|
|
@@ -4388,16 +4337,15 @@ class Client {
|
|
|
4388
4337
|
message.app = '';
|
|
4389
4338
|
if (!message.metadata)
|
|
4390
4339
|
message.metadata = '{}';
|
|
4391
|
-
|
|
4392
|
-
let type = type2 ? vote2Types : voteTypes;
|
|
4340
|
+
let type = voteTypes;
|
|
4393
4341
|
if (['approval', 'ranked-choice'].includes(message.type))
|
|
4394
|
-
type =
|
|
4342
|
+
type = voteArrayTypes;
|
|
4395
4343
|
if (!isShutter && ['quadratic', 'weighted'].includes(message.type)) {
|
|
4396
|
-
type =
|
|
4344
|
+
type = voteStringTypes;
|
|
4397
4345
|
message.choice = JSON.stringify(message.choice);
|
|
4398
4346
|
}
|
|
4399
4347
|
if (isShutter)
|
|
4400
|
-
type =
|
|
4348
|
+
type = voteStringTypes;
|
|
4401
4349
|
delete message.privacy;
|
|
4402
4350
|
// @ts-ignore
|
|
4403
4351
|
delete message.type;
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import Ajv from 'ajv';
|
|
|
8
8
|
import addFormats from 'ajv-formats';
|
|
9
9
|
import addErrors from 'ajv-errors';
|
|
10
10
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
11
|
-
import { RpcProvider,
|
|
11
|
+
import { RpcProvider, typedData, transaction, uint256, shortString, num, validateAndParseAddress } from 'starknet';
|
|
12
12
|
import { hexlify, concat, arrayify } from '@ethersproject/bytes';
|
|
13
13
|
import { verifyTypedData } from '@ethersproject/wallet';
|
|
14
14
|
import { AbiCoder, Interface } from '@ethersproject/abi';
|
|
@@ -2187,7 +2187,6 @@ var networks = {
|
|
|
2187
2187
|
url: "https://starkscan.co"
|
|
2188
2188
|
},
|
|
2189
2189
|
rpc: [
|
|
2190
|
-
"https://starknet-mainnet.public.blastapi.io"
|
|
2191
2190
|
],
|
|
2192
2191
|
start: 8446,
|
|
2193
2192
|
logo: "ipfs://bafkreihbjafyh7eud7r6e5743esaamifcttsvbspfwcrfoc5ykodjdi67m"
|
|
@@ -2206,7 +2205,6 @@ var networks = {
|
|
|
2206
2205
|
url: "https://sepolia.starkscan.co"
|
|
2207
2206
|
},
|
|
2208
2207
|
rpc: [
|
|
2209
|
-
"https://starknet-sepolia.public.blastapi.io"
|
|
2210
2208
|
],
|
|
2211
2209
|
start: 7,
|
|
2212
2210
|
logo: "ipfs://bafkreihbjafyh7eud7r6e5743esaamifcttsvbspfwcrfoc5ykodjdi67m"
|
|
@@ -2286,19 +2284,6 @@ function getBlockNumber(provider) {
|
|
|
2286
2284
|
});
|
|
2287
2285
|
}
|
|
2288
2286
|
|
|
2289
|
-
var _a, _b, _c, _d;
|
|
2290
|
-
const RPC_URLS = {
|
|
2291
|
-
SN_MAIN: (_b = (_a = networks[constants$1.StarknetChainId.SN_MAIN]) === null || _a === void 0 ? void 0 : _a.rpc) === null || _b === void 0 ? void 0 : _b[0],
|
|
2292
|
-
SN_SEPOLIA: (_d = (_c = networks[constants$1.StarknetChainId.SN_SEPOLIA]) === null || _c === void 0 ? void 0 : _c.rpc) === null || _d === void 0 ? void 0 : _d[0]
|
|
2293
|
-
};
|
|
2294
|
-
function getProvider$1(network, options) {
|
|
2295
|
-
var _a;
|
|
2296
|
-
if (!RPC_URLS[network])
|
|
2297
|
-
throw new Error('Invalid network');
|
|
2298
|
-
return new RpcProvider({
|
|
2299
|
-
nodeUrl: (_a = options === null || options === void 0 ? void 0 : options.broviderUrl) !== null && _a !== void 0 ? _a : RPC_URLS[network]
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
2287
|
function isStarknetMessage(data) {
|
|
2303
2288
|
return !!data.primaryType && !!data.types.StarkNetDomain;
|
|
2304
2289
|
}
|
|
@@ -2307,9 +2292,9 @@ function getHash(data, address) {
|
|
|
2307
2292
|
return typedData.getMessageHash({ types, primaryType, domain, message }, address);
|
|
2308
2293
|
}
|
|
2309
2294
|
function verify(address_1, sig_1, data_1) {
|
|
2310
|
-
return __awaiter(this, arguments, void 0, function* (address, sig, data, network = '
|
|
2295
|
+
return __awaiter(this, arguments, void 0, function* (address, sig, data, network = '0x534e5f4d41494e', options = {}) {
|
|
2311
2296
|
try {
|
|
2312
|
-
const provider = getProvider
|
|
2297
|
+
const provider = getProvider(network, options);
|
|
2313
2298
|
// Check if the contract is deployed
|
|
2314
2299
|
// Will throw on non-deployed contract
|
|
2315
2300
|
yield provider.getClassAt(address);
|
|
@@ -4113,7 +4098,7 @@ const cancelProposal2Types = {
|
|
|
4113
4098
|
{ name: 'from', type: 'string' },
|
|
4114
4099
|
{ name: 'space', type: 'string' },
|
|
4115
4100
|
{ name: 'timestamp', type: 'uint64' },
|
|
4116
|
-
{ name: 'proposal', type: '
|
|
4101
|
+
{ name: 'proposal', type: 'string' }
|
|
4117
4102
|
]
|
|
4118
4103
|
};
|
|
4119
4104
|
const voteTypes = {
|
|
@@ -4152,42 +4137,6 @@ const voteStringTypes = {
|
|
|
4152
4137
|
{ name: 'metadata', type: 'string' }
|
|
4153
4138
|
]
|
|
4154
4139
|
};
|
|
4155
|
-
const vote2Types = {
|
|
4156
|
-
Vote: [
|
|
4157
|
-
{ name: 'from', type: 'string' },
|
|
4158
|
-
{ name: 'space', type: 'string' },
|
|
4159
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
4160
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
4161
|
-
{ name: 'choice', type: 'uint32' },
|
|
4162
|
-
{ name: 'reason', type: 'string' },
|
|
4163
|
-
{ name: 'app', type: 'string' },
|
|
4164
|
-
{ name: 'metadata', type: 'string' }
|
|
4165
|
-
]
|
|
4166
|
-
};
|
|
4167
|
-
const voteArray2Types = {
|
|
4168
|
-
Vote: [
|
|
4169
|
-
{ name: 'from', type: 'string' },
|
|
4170
|
-
{ name: 'space', type: 'string' },
|
|
4171
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
4172
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
4173
|
-
{ name: 'choice', type: 'uint32[]' },
|
|
4174
|
-
{ name: 'reason', type: 'string' },
|
|
4175
|
-
{ name: 'app', type: 'string' },
|
|
4176
|
-
{ name: 'metadata', type: 'string' }
|
|
4177
|
-
]
|
|
4178
|
-
};
|
|
4179
|
-
const voteString2Types = {
|
|
4180
|
-
Vote: [
|
|
4181
|
-
{ name: 'from', type: 'string' },
|
|
4182
|
-
{ name: 'space', type: 'string' },
|
|
4183
|
-
{ name: 'timestamp', type: 'uint64' },
|
|
4184
|
-
{ name: 'proposal', type: 'bytes32' },
|
|
4185
|
-
{ name: 'choice', type: 'string' },
|
|
4186
|
-
{ name: 'reason', type: 'string' },
|
|
4187
|
-
{ name: 'app', type: 'string' },
|
|
4188
|
-
{ name: 'metadata', type: 'string' }
|
|
4189
|
-
]
|
|
4190
|
-
};
|
|
4191
4140
|
const followTypes = {
|
|
4192
4141
|
Follow: [
|
|
4193
4142
|
{ name: 'from', type: 'address' },
|
|
@@ -4378,16 +4327,15 @@ class Client {
|
|
|
4378
4327
|
message.app = '';
|
|
4379
4328
|
if (!message.metadata)
|
|
4380
4329
|
message.metadata = '{}';
|
|
4381
|
-
|
|
4382
|
-
let type = type2 ? vote2Types : voteTypes;
|
|
4330
|
+
let type = voteTypes;
|
|
4383
4331
|
if (['approval', 'ranked-choice'].includes(message.type))
|
|
4384
|
-
type =
|
|
4332
|
+
type = voteArrayTypes;
|
|
4385
4333
|
if (!isShutter && ['quadratic', 'weighted'].includes(message.type)) {
|
|
4386
|
-
type =
|
|
4334
|
+
type = voteStringTypes;
|
|
4387
4335
|
message.choice = JSON.stringify(message.choice);
|
|
4388
4336
|
}
|
|
4389
4337
|
if (isShutter)
|
|
4390
|
-
type =
|
|
4338
|
+
type = voteStringTypes;
|
|
4391
4339
|
delete message.privacy;
|
|
4392
4340
|
// @ts-ignore
|
|
4393
4341
|
delete message.type;
|