Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dankostiuk authored Jun 27, 2022
2 parents 65fb4cf + 524fb67 commit bcadd6d
Show file tree
Hide file tree
Showing 28 changed files with 18,009 additions and 3,090 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
22 changes: 10 additions & 12 deletions package.json
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/snapshot.js",
"version": "0.3.97",
"version": "0.4.2",
"repository": "snapshot-labs/snapshot.js",
"license": "MIT",
"main": "dist/snapshot.cjs.js",
Expand All @@ -10,9 +10,9 @@
"dependencies": {
"@ensdomains/eth-ens-namehash": "^2.0.15",
"@ethersproject/abi": "^5.0.4",
"@ethersproject/bytes": "^5.0.8",
"@ethersproject/bytes": "^5.6.1",
"@ethersproject/contracts": "^5.0.3",
"@ethersproject/hash": "^5.0.9",
"@ethersproject/hash": "^5.6.1",
"@ethersproject/providers": "^5.3.1",
"@ethersproject/wallet": "^5.4.0",
"ajv": "^8.6.0",
Expand All @@ -22,18 +22,16 @@
"lodash.set": "^4.3.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-commonjs": "^18.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@types/jest": "^26.0.23",
"@types/node": "^13.9.5",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-prettier": "^3.4.0",
"jest": "^26.6.3",
"prettier": "2.2.0",
"prettier": "2.7.1",
"rollup": "^2.35.1",
"rollup-plugin-filesize": "^9.1.0",
"rollup-plugin-json": "^4.0.0",
Expand All @@ -42,16 +40,16 @@
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.0",
"typescript": "^3.8.3"
"typescript": "^3.8.3",
"vitest": "^0.15.1"
},
"scripts": {
"build": "rollup -c",
"build:cjs": "rollup -c rollup.cjs.config.js",
"test": "vitest",
"dev": "rollup -c -w",
"test:validation": "npm run build:cjs && jest test/validation.spec.ts --runInBand",
"pretest": "npm run build:cjs",
"lint": "eslint . --ext .ts --fix",
"prepublishOnly": "npm run build"
"prepublishOnly": "yarn build"
},
"engines": {
"node": ">=14"
Expand Down
20 changes: 17 additions & 3 deletions src/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@
"network": "mainnet",
"multicall": "0x1ee38d535d541c55c9dae27b12edf090c608e6fb",
"rpc": [
"https://rpc.ankr.com/bsc",
"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive",
"https://rpc.ankr.com/bsc",
"https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7",
"https://bsc-private-dataseed1.nariox.org",
"https://bsc-dataseed1.ninicoin.io",
Expand Down Expand Up @@ -770,6 +770,20 @@
"start": 366482,
"logo": "ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"
},
"595": {
"key": "595",
"name": "Acala Mandala Testnet",
"chainId": 595,
"network": "testnet",
"testnet": true,
"multicall": "0x8ce86f733024c1ccae2224f05c11fd50713d6f81",
"rpc": [
"https://tc7-eth.aca-dev.network"
],
"explorer": "https://blockscout.mandala.acala.network",
"start": 1335512,
"logo": "ipfs://QmY1ZYBUzb46Mto7G1GitQWfaqq6n8Q4WArxFBzhNdLqvg"
},
"888": {
"key": "888",
"name": "Wanchain",
Expand Down Expand Up @@ -1206,8 +1220,8 @@
"testnet": true,
"multicall": "0x08411ADd0b5AA8ee47563b146743C13b3556c9Cc",
"rpc": [
"https://rpc-mumbai.matic.today",
"https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mumbai/archive"
"https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive",
"https://rpc-mumbai.matic.today"
],
"ws": [
"wss://ws-mumbai.matic.today"
Expand Down
42 changes: 40 additions & 2 deletions src/schemas/space.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@
"type": "object",
"properties": {
"delay": {
"type": "number",
"type": "integer",
"minimum": 0
},
"period": {
"type": "number",
"type": "integer",
"minimum": 0
},
"type": {
Expand All @@ -205,6 +205,13 @@
},
"hideAbstain": {
"type": "boolean"
},
"privacy": {
"type": "string",
"enum": [
"",
"shutter"
]
}
},
"additionalProperties": false
Expand All @@ -226,6 +233,37 @@
]
}
},
"treasuries": {
"type": "array",
"maxItems": 10,
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "Name",
"examples": ["e.g. Balancer DAO 1"],
"minLength": 1,
"maxLength": 64
},
"address": {
"type": "string",
"title": "Contract address",
"examples": ["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],
"pattern": "^0x[a-fA-F0-9]{40}$",
"minLength": 42,
"maxLength": 42
},
"network": {
"type": "string",
"title": "Network",
"maxLength": 12
}
},
"required": ["name", "address", "network"],
"additionalProperties": false
}
},
"parent": {
"type": "string",
"title": "parent"
Expand Down
2 changes: 1 addition & 1 deletion src/sign/eip1271.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function verifyOldVersion(
}

export async function verify(address, sig, hash, network = '1') {
const provider = getProvider(network);
const provider = getProvider(network, 'brovider');
if (await verifyDefault(address, sig, hash, provider)) return true;
return await verifyOldVersion(address, sig, hash, provider);
}
4 changes: 3 additions & 1 deletion src/sign/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ export default class Client {
type = type2 ? voteString2Types : voteStringTypes;
message.choice = JSON.stringify(message.choice);
}
// @ts-ignore
if (message?.privacy === 'shutter')
type = type2 ? voteString2Types : voteStringTypes;
delete message.privacy;
delete message.type;
return await this.sign(web3, address, message, type);
}
Expand Down
1 change: 1 addition & 0 deletions src/sign/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface Vote {
proposal: string;
type: string;
choice: number | number[] | string;
privacy?: string;
}

export interface Follow {
Expand Down
4 changes: 2 additions & 2 deletions src/sign/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function getHash(data) {
return _TypedDataEncoder.hash(domain, types, message);
}

export async function verify(address, sig, data) {
export async function verify(address, sig, data, network = '1') {
const { domain, types, message } = data;

const hash = getHash(data);
Expand All @@ -23,5 +23,5 @@ export async function verify(address, sig, data) {
}

console.log('Check EIP1271 signature');
return await verifyEIP1271(address, sig, hash);
return await verifyEIP1271(address, sig, hash, network);
}
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export function validateSchema(schema, data) {
export function getEnsTextRecord(ens: string, record: string, network = '1') {
const address = networks[network].ensResolver || networks['1'].ensResolver;
const ensHash = hash(normalize(ens));
const provider = getProvider(network);
const provider = getProvider(network, 'brovider');
return call(provider, ENS_RESOLVER_ABI, [address, 'text', [ensHash, record]]);
}

Expand Down
Loading

0 comments on commit bcadd6d

Please sign in to comment.