-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:LiskHQ/lisk-token-claim into 115-im…
…plement-merkle-tree-builder
- Loading branch information
Showing
48 changed files
with
4,521 additions
and
3,878 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1 @@ | ||
docs/ | ||
lisk/ | ||
templates/ | ||
types/ | ||
examples/ | ||
**/*.d.ts | ||
jest.config.js | ||
coverage | ||
benchmark | ||
.eslintrc.js | ||
ecosystem.config.js | ||
**/dist/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,27 @@ | ||
/* eslint-env node */ | ||
module.exports = { | ||
root: true, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-type-checked', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
tsconfigRootDir: __dirname, | ||
project: [ | ||
'./tsconfig.eslint.json', | ||
'./packages/*/tsconfig.json', | ||
'./packages/*/test/tsconfig.json', | ||
], | ||
}, | ||
extends: ['lisk-base/ts'], | ||
plugins: ['@typescript-eslint'], | ||
root: true, | ||
rules: { | ||
'@typescript-eslint/member-ordering': 'off', | ||
'@typescript-eslint/no-unsafe-argument': ['warn'], | ||
'@typescript-eslint/require-await': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-return': 'off', | ||
"@typescript-eslint/no-unsafe-member-access": 'off', | ||
'@typescript-eslint/no-unsafe-call': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off' | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: 'type: bug' | ||
assignees: '' | ||
--- | ||
|
||
### Expected behavior | ||
|
||
### Actual behavior | ||
|
||
### Steps to reproduce | ||
|
||
### Which version(s) does this affect? (Environment, OS, etc...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Feature request | ||
about: Propose an idea for new improvements/features | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
### Description | ||
|
||
Please describe what functionality is needed | ||
|
||
### Motivation | ||
|
||
Please describe why it is needed | ||
|
||
### Additional Information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Feature specification | ||
about: Specification of new features/improvements | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
### Description | ||
|
||
Please describe the specification of new features/improvements | ||
|
||
### Acceptance Criteria | ||
|
||
Please describe the conditions which must be met for this issue to close | ||
|
||
### Additional Information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
### What was the problem? | ||
|
||
This PR resolves #INSERT_ISSUE_NUMBER | ||
|
||
### How was it solved? | ||
|
||
<!--- Please describe your technical implementation --> | ||
|
||
### How was it tested? | ||
|
||
<!--- Please describe how you tested your changes --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'PR' | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: self-hosted | ||
timeout-minutes: 15 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- name: Install yarn | ||
run: npm install --global yarn | ||
- name: Install dependencies | ||
shell: bash | ||
run: yarn --prefer-offline | ||
- name: Build | ||
shell: bash | ||
run: yarn build | ||
- run: yarn format | ||
- name: Check format | ||
run: | | ||
if [ -z "$(git status --untracked-files=no --porcelain)" ]; then | ||
echo "All files formatted" | ||
else | ||
echo "Running format is required" | ||
exit 1 | ||
fi | ||
- run: yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,80 @@ | ||
node_modules | ||
Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
|
||
# generate output | ||
dist | ||
.cache/ | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# Example Accounts and MerkleTree are not committed | ||
data/example/accounts.json | ||
data/example/merkle-root.json | ||
data/example/merkle-tree-result.json | ||
data/example/merkle-tree-result-detailed.json | ||
data/example/signatures.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Files | ||
LICENSE | ||
.gitkeep | ||
mocha.opts | ||
.DS_Store | ||
REVISION | ||
|
||
# rc files | ||
.*rc | ||
## ignore files | ||
.*ignore | ||
|
||
# Ignore extensions | ||
*.png | ||
*.sql | ||
*.sh | ||
*.html | ||
*.info | ||
*.xml | ||
*.log | ||
*.proto | ||
*.csv | ||
*.cmd | ||
*.tsbuildinfo | ||
*.blob | ||
*.lock | ||
|
||
## jest snapshot | ||
*.snap | ||
|
||
# project specific paths | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,11 @@ | ||
# Lisk Token Claim | ||
# lisk-token-claim | ||
This library is the monorepo for: | ||
|
||
This library builds Merkle Tree from a snapshot and computes Merkle Root. | ||
### Tree Builder | ||
Builds Merkle Tree from a snapshot and computes Merkle Root. | ||
|
||
## Setup and Installation | ||
|
||
``` | ||
$ git clone [email protected]:LiskHQ/lisk-token-claim.git && cd lisk-token-claim | ||
$ yarn | ||
``` | ||
|
||
## Run | ||
|
||
``` | ||
$ yarn generate-merkle-tree:mainnet # Using ./data/mainnet | ||
$ yarn generate-merkle-tree:testnet # Using ./data/testnet | ||
$ yarn generate-merkle-tree:example # Using ./data/example | ||
``` | ||
|
||
## Files | ||
|
||
| Name | Description | Generated By | | ||
|----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| --------------------------------------- | | ||
| `/data/<network>/accounts.json` | Stores addresses, balances, and multisig details(If any) per account after a snapshot is taken, addresses must be sorted in ascending order. Will be used for MerkleTree computation. | Snapshot | | ||
| `/data/<network>/merkle-tree-result-detailed.json` | Stores MerkleRoot, and leaves for each account. Will be used for examination by 3rd Party or public. | `$ yarn generate-merkle-tree:<network>` | | ||
| `/data/<network>/merkle-tree-result.json` | Stores MerkleRoot, and leaves for each account. Will be used for testing and simulation for Claim Contract. | `$ yarn generate-merkle-tree:<network>` | | ||
| `/data/<network>/merkle-root.json` | Stores MerkleRoot only. Will be used for deployment of Claim Contract. | `$ yarn generate-merkle-tree:<network>` | | ||
|
||
## Merkle Leaf | ||
|
||
Each leaf will be encoded as ABI-format, in the following order: | ||
|
||
``` | ||
LSK_ADDRESS_IN_HEX: bytes20 | ||
BALANCE_IN_BEDDOWS: uint64 | ||
NUMBER_OF_SIGNATURES: uint32 | ||
MANDATORY_KEYS: bytes32[] | ||
OPTIONAL_KEYS: bytes32[] | ||
P.S. If the address is not a multisig address, NUMBER_OF_SIGNATURES would be 0, MANDATORY_KEYS and OPTIONAL_KEYS be [] | ||
``` | ||
|
||
## Params | ||
|
||
``` | ||
accounts.json: | ||
{ | ||
lskAddress: string; | ||
balance: number; | ||
balanceBeddows: number; | ||
numberOfSignatures?: number; | ||
mandatoryKeys?: string[]; | ||
optionalKeys?: string[]; | ||
} | ||
merkle-tree-result-detailed.json: | ||
{ | ||
merkleRoot: string; | ||
leaves: { | ||
lskAddress: string; | ||
address: string; | ||
balance: number; | ||
balanceBeddows: number; | ||
numberOfSignatures: number; | ||
mandatoryKeys: string[]; | ||
optionalKeys: string[]; | ||
hash: string; | ||
proof: string[]; | ||
}[]; | ||
} | ||
merkle-tree-result.json: | ||
{ | ||
merkleRoot: string; | ||
leaves: { | ||
b32Address: string; | ||
balanceBeddows: number; | ||
mandatoryKeys: string[]; | ||
numberOfSignatures: number; | ||
optionalKeys: string[]; | ||
proof: string[]; | ||
}[]; | ||
} | ||
# `address` is a reserved in solidity, hence `b32Address` here | ||
``` | ||
|
||
### `merkle-tree-simple` | ||
|
||
Due to the constraint of vm.parseJson in Foundry, fields in `merkle-tree-result` such as decimal field will trigger error. | ||
|
||
`merkle-tree-simple.json` is a lightweight version of `merkle-tree-result-detailed.json`, which also has sufficient params for claiming. | ||
|
||
## _Testing Only_ | ||
|
||
### Generate accounts.json from `dev-validators.json` | ||
|
||
``` | ||
$ yarn create-accounts:example | ||
``` | ||
|
||
### (After running `generate-merkle-tree:example`) Sign all accounts and generates `signatures.json` | ||
|
||
``` | ||
$ yarn sign:example | ||
``` | ||
|
||
### Params (For testing purposes only) | ||
|
||
``` | ||
signatures.json: | ||
{ | ||
message: string; | ||
sigs: { | ||
pubKey: string | ||
r: string | ||
s: string | ||
}[]; | ||
}[]; | ||
``` | ||
$ yarn && yarn build | ||
``` |
Oops, something went wrong.