Skip to content

Commit

Permalink
Merge branch 'master' into pass-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Jul 8, 2023
2 parents 6960681 + 70c7df8 commit 63fe7c3
Show file tree
Hide file tree
Showing 49 changed files with 1,833 additions and 2,718 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ jobs:
strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2.3.4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build and run tests
run: |
yarn install --frozen-lockfile
yarn build
yarn test:once
yarn lint
- uses: actions/checkout@v2.3.4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build and run tests
run: |
yarn install --frozen-lockfile
yarn build
yarn test:once --coverage
yarn lint
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
node_modules
dist
coverage

# Remove some common IDE working directories
.idea
Expand Down
32 changes: 29 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,57 @@

[![npm](https://img.shields.io/npm/v/@snapshot-labs/snapshot.js?label=npm)](https://www.npmjs.com/package/@snapshot-labs/snapshot.js)

### Install
## Install

Snapshot.js was designed to work both in the browser and in Node.js.

#### Node.js
### In Node Applications

To install Snapshot.js on Node.js, open your terminal and run:
```

```bash
npm i @snapshot-labs/snapshot.js
```

#### Browser

You can create an index.html file and include Snapshot.js with:

```html
<script src="https://cdn.jsdelivr.net/npm/@snapshot-labs/snapshot.js"></script>
```

### Development

#### Install dependencies

```bash
yarn
```

#### Build package

```bash
yarn build
```

#### Test cases

```bash
yarn test
# or
yarn test:once
```

#### Other useful scripts

```bash
# Format ABI
ts-node scripts/abi.ts
# Generate hash for types
ts-node scripts/generateHashWithTypes.ts
```

### License

[MIT](LICENSE).
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snapshot-labs/snapshot.js",
"version": "0.4.50",
"version": "0.4.103",
"repository": "snapshot-labs/snapshot.js",
"license": "MIT",
"main": "dist/snapshot.cjs.js",
Expand All @@ -15,10 +15,11 @@
"@ethersproject/contracts": "^5.6.2",
"@ethersproject/hash": "^5.6.1",
"@ethersproject/providers": "^5.6.8",
"@ethersproject/units": "^5.7.0",
"@ethersproject/wallet": "^5.6.2",
"ajv": "^8.11.0",
"ajv-formats": "^2.1.1",
"cross-fetch": "^3.1.5",
"cross-fetch": "^3.1.6",
"json-to-graphql-query": "^2.2.4",
"lodash.set": "^4.3.2"
},
Expand All @@ -28,6 +29,7 @@
"@types/node": "^13.9.5",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.33.0",
"@vitest/coverage-v8": "^0.32.2",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
Expand All @@ -42,7 +44,7 @@
"rollup-plugin-terser": "^7.0.0",
"rollup-plugin-typescript2": "^0.27.0",
"typescript": "^3.8.3",
"vitest": "^0.22.1"
"vitest": "^0.32.1"
},
"scripts": {
"build": "rollup -c",
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions scripts/generateHashWithTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { createHash } = require('crypto');

const types = {
Statement: [
{ name: 'from', type: 'address' },
{ name: 'timestamp', type: 'uint64' },
{ name: 'space', type: 'string' },
{ name: 'about', type: 'string' },
{ name: 'statement', type: 'string' }
]
};
function sha256(str) {
return createHash('sha256').update(str).digest('hex');
}
const hash = sha256(JSON.stringify(types));
console.log(hash);
136 changes: 0 additions & 136 deletions src/client.ts

This file was deleted.

13 changes: 12 additions & 1 deletion src/constants.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{
"version": "0.1.3"
"livenet": {
"hub": "https://hub.snapshot.org",
"sequencer": "https://seq.snapshot.org"
},
"testnet": {
"hub": "https://testnet.snapshot.org",
"sequencer": "https://testnet.seq.snapshot.org"
},
"local": {
"hub": "http://localhost:3000",
"sequencer": "http://localhost:3001"
}
}
18 changes: 8 additions & 10 deletions src/delegationSubgraphs.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"1": "https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmXZiV6S13ha6QXq4dmaM3TB4CHcDxBMvGexSNu9Kc28EH",
"4": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby",
"5": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-goerli",
"10": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-optimism",
"42": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan",
"56": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain",
"100": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-gnosis-chain",
"137": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-polygon",
"250": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-fantom",
"42161": "https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-arbitrum"
"1": "https://subgrapher.snapshot.org/gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/deployments/id/QmXZiV6S13ha6QXq4dmaM3TB4CHcDxBMvGexSNu9Kc28EH",
"5": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-goerli",
"10": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-optimism",
"56": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain",
"100": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-gnosis-chain",
"137": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-polygon",
"250": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-fantom",
"42161": "https://subgrapher.snapshot.org/api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-arbitrum"
}
4 changes: 0 additions & 4 deletions src/hubs.json

This file was deleted.

3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Client712 from './sign';
import Client from './client';
import schemas from './schemas';
import utils from './utils';

export default {
Client,
Client: Client712,
Client712,
schemas,
utils
Expand Down
Loading

0 comments on commit 63fe7c3

Please sign in to comment.