@snapshot-labs/snapshot.js 0.11.38 → 0.12.0-beta.1
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/LICENSE +0 -0
- package/dist/index.d.ts +2 -29
- package/dist/schemas/index.d.ts +2 -29
- package/dist/sign/types.d.ts +0 -3
- package/dist/snapshot.cjs.js +1549 -1906
- package/dist/snapshot.esm.js +1550 -1907
- package/dist/snapshot.js/src/index.d.ts +677 -0
- package/dist/snapshot.js/src/sign/index.d.ts +28 -0
- package/dist/snapshot.min.js +16 -5
- package/dist/src/index.d.ts +725 -0
- package/dist/src/schemas/index.d.ts +671 -0
- package/dist/src/sign/index.d.ts +29 -0
- package/dist/src/sign/types.d.ts +227 -0
- package/dist/src/utils/blockfinder.d.ts +1 -0
- package/dist/src/utils/delegation.d.ts +18 -0
- package/dist/src/utils/multicaller.d.ts +12 -0
- package/dist/src/utils/provider.d.ts +5 -0
- package/dist/src/utils/web3.d.ts +2 -0
- package/dist/src/utils.d.ts +91 -0
- package/dist/src/verify/evm.d.ts +4 -0
- package/dist/src/verify/evm.spec.d.ts +1 -0
- package/dist/src/verify/index.d.ts +11 -0
- package/dist/src/verify/index.spec.d.ts +1 -0
- package/dist/src/verify/starknet.d.ts +6 -0
- package/dist/src/verify/starknet.spec.d.ts +1 -0
- package/dist/src/voting/approval.d.ts +22 -0
- package/dist/src/voting/index.d.ts +14 -0
- package/dist/src/voting/quadratic.d.ts +20 -0
- package/dist/src/voting/rankedChoice.d.ts +18 -0
- package/dist/src/voting/singleChoice.d.ts +18 -0
- package/dist/src/voting/types.d.ts +35 -0
- package/dist/src/voting/weighted.d.ts +26 -0
- package/package.json +5 -3
- package/src/sign/hashedTypes.json +5 -1
- package/src/utils/dist/provider.js +47 -0
- package/src/utils/provider.ts +8 -2
- package/src/utils/web3.ts +1 -1
- package/src/utils.spec.js +36 -1
- package/src/utils.ts +44 -14
- package/src/verify/evm.spec.ts +32 -0
- package/src/verify/evm.ts +82 -0
- package/src/verify/index.spec.ts +84 -0
- package/src/verify/index.ts +41 -0
- package/src/verify/starknet.spec.ts +55 -0
- package/src/verify/starknet.ts +82 -0
- package/src/sign/eip1271.ts +0 -55
- package/src/sign/utils.ts +0 -27
package/src/sign/utils.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { verifyTypedData } from '@ethersproject/wallet';
|
|
2
|
-
import { _TypedDataEncoder } from '@ethersproject/hash';
|
|
3
|
-
import { verify as verifyEIP1271 } from './eip1271';
|
|
4
|
-
|
|
5
|
-
export function getHash(data) {
|
|
6
|
-
const { domain, types, message } = data;
|
|
7
|
-
return _TypedDataEncoder.hash(domain, types, message);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export async function verify(address, sig, data, network = '1', options = {}) {
|
|
11
|
-
const { domain, types, message } = data;
|
|
12
|
-
|
|
13
|
-
const hash = getHash(data);
|
|
14
|
-
// console.log('Hash', hash);
|
|
15
|
-
// console.log('Address', address);
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const recoverAddress = verifyTypedData(domain, types, message, sig);
|
|
19
|
-
// console.log('Recover address', recoverAddress);
|
|
20
|
-
if (address === recoverAddress) return true;
|
|
21
|
-
} catch (e) {
|
|
22
|
-
// console.log('Could not recoverAddress:' + e.message);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// console.log('Check EIP1271 signature');
|
|
26
|
-
return await verifyEIP1271(address, sig, hash, network, options);
|
|
27
|
-
}
|