diff --git a/README.md b/README.md index 5bf19264b..243a3fa49 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,4 @@ ## Docs - [Local environment setup](docs/local-env-setup.md) -- [Testing environment](docs/testing-env.md) \ No newline at end of file +- [Testing environment](docs/testing-env.md) diff --git a/docs/local-env-setup.md b/docs/local-env-setup.md index e2c42d836..8d4e7e696 100644 --- a/docs/local-env-setup.md +++ b/docs/local-env-setup.md @@ -1,8 +1,8 @@ -# Working with locally forked Arbitrum Sepolia chain +# Working with forked Arbitrum Sepolia chain ### In the dapp: -- Override `USE_LOCALHOST_FORK="true"` in `.env` file. +- Override `USE_ARBITRUM_FORK="true"` in `.env` file. - Run the dapp ### In the [extension](https://github.com/tahowallet/extension): @@ -28,12 +28,20 @@ Instruction based on [the system tests readme](https://github.com/tahowallet/con - `nvm use` - `yarn install` - Provide [`.envrc`](https://github.com/tahowallet/contracts/blob/main/system-tests/.envrc.SAMPLE) variables, make sure you have [Direnv](https://direnv.net/) installed + ```bash export FORKING_URL="https://sepolia-rollup.arbitrum.io/rpc" - export TAHO_DEPLOYER_PRIVATE_KEY="..." # mnemonic or first private key from `testertesting.eth` + + export TAHO_DEPLOYER_PRIVATE_KEY="..." # private key of testertesting.eth + export TAHO_TEST_WALLET_PRIVATE_KEY="..." # private key of testertesting.eth + export GUARDA_PRIVATE_KEY="..." # private key of testertesting.eth + export FORKING_BLOCK="..." # historical block; optional - setting this var enables cache and speeds up repatable read operations + export FORKING_CHAIN_ID="421614" # Arbitrum Sepolia chain id + export ARBITRUM_HTTPS_RPC_URL="http://127.0.0.1:8545/" ``` -- Open first terminal and run `yarn run test:fork` + +- Open terminal and run `yarn run test:fork` --- @@ -41,4 +49,53 @@ After all the steps above you should have: - the Taho token deployed on the Arbitrum Sepolia forked chain - the dapp should be able to interact with the token -- the extension should be able to display the token's balance \ No newline at end of file +- the extension should be able to display the token's balance + +--- + +### XP allocations deployment + +To be able to test XP allocations you need to: + +#### Prepare merkle tree file: + +1. In the contracts repository create a file with XP allocations in the format: + ```json + [ + { + "account": "0x...", + "amount": "4000" + }, + { + "account": "0x...", + "amount": "2000" + }, + { + "account": "0x...", + "amount": "3000" + } + ] + ``` +2. Run `yarn run merkle:generate .json .json`. This command will create an JSON file with a merkle tree of the XP allocations. +3. Copy the output file to the dapp's `src/data/xp/` directory. Name the file `xp__.json`. Drop index should start from `1` and be incremented by `1` for each new drop. + +#### Deploy XP allocations: + +1. In the contracts repository set correct environment variables based on where you want to publish the XP drop. + ```bash + export GUARDA_PRIVATE_KEY="..." # private key for account that will publish the drop, locally use testertesting.eth + export ARBITRUM_HTTPS_RPC_URL="http://127.0.0.1:8545/" # RPC url of the chain where you want to publish the drop + ``` +2. Then run: + ``` + yarn run merkle:allocate-xp + ``` + Where + ``` + - address of the realm where you want to publish the drop + - merkle root of the merkle tree, copy from the output file + - amount of XP to be distributed, copy from the output file + - url to the merkle tree file, can't be empty, doesn't matter locally, on public chain should be set to the actual url of the merkle tree json file + ``` +3. Drop should be accessible on the chain now and dapp should be able to fetch info about the drops and claim the XP. +4. Leaderboard data is just a sum of all drops for a given realm, script to generate leaderboard file is TODO diff --git a/src/data/xp/4/leaderboard.json b/src/data/xp/4/leaderboard.json new file mode 100644 index 000000000..18eb73844 --- /dev/null +++ b/src/data/xp/4/leaderboard.json @@ -0,0 +1,29 @@ +{ + "totalAmount": "0xbe8c", + "merkleRoot": "0xac7e1eeac7c8c79f4227ba21175f53d1b315d4ec0d3f63747caa806f8d4d5240", + "claims": { + "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { + "index": "0x0", + "amount": "0x5f46", + "proof": [ + "0x77d5949906c9d3f280b53e8f9ce4619cc3601e006a614e6e6b8efdb670851608" + ] + }, + "0x70997970c51812dc3a010c7d01b50e0d17dc79c8": { + "index": "0x1", + "amount": "0x3f84", + "proof": [ + "0x97d8034159ddd4aca63b7acfc7eee591e27cd83a6d690eac3ddb905ce99955b0", + "0xf955766c3e34d6d153fe72738c1b04f22d734532e735c48c7cbd61ea721b615a" + ] + }, + "0x6e80164ea60673d64d5d6228beb684a1274bb017": { + "index": "0x2", + "amount": "0x1fc2", + "proof": [ + "0x236261838f3f8aec57fe81caecc3216475c0a17841efddc10d879c609f7d430c", + "0xf955766c3e34d6d153fe72738c1b04f22d734532e735c48c7cbd61ea721b615a" + ] + } + } +} \ No newline at end of file diff --git a/src/data/xp/4/xp_4_1.json b/src/data/xp/4/xp_4_1.json new file mode 100644 index 000000000..18eb73844 --- /dev/null +++ b/src/data/xp/4/xp_4_1.json @@ -0,0 +1,29 @@ +{ + "totalAmount": "0xbe8c", + "merkleRoot": "0xac7e1eeac7c8c79f4227ba21175f53d1b315d4ec0d3f63747caa806f8d4d5240", + "claims": { + "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { + "index": "0x0", + "amount": "0x5f46", + "proof": [ + "0x77d5949906c9d3f280b53e8f9ce4619cc3601e006a614e6e6b8efdb670851608" + ] + }, + "0x70997970c51812dc3a010c7d01b50e0d17dc79c8": { + "index": "0x1", + "amount": "0x3f84", + "proof": [ + "0x97d8034159ddd4aca63b7acfc7eee591e27cd83a6d690eac3ddb905ce99955b0", + "0xf955766c3e34d6d153fe72738c1b04f22d734532e735c48c7cbd61ea721b615a" + ] + }, + "0x6e80164ea60673d64d5d6228beb684a1274bb017": { + "index": "0x2", + "amount": "0x1fc2", + "proof": [ + "0x236261838f3f8aec57fe81caecc3216475c0a17841efddc10d879c609f7d430c", + "0xf955766c3e34d6d153fe72738c1b04f22d734532e735c48c7cbd61ea721b615a" + ] + } + } +} \ No newline at end of file diff --git a/src/data/xp/9/leaderboard.json b/src/data/xp/9/leaderboard.json deleted file mode 100644 index cc09e7274..000000000 --- a/src/data/xp/9/leaderboard.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "totalAmount": "425", - "merkleRoot": "0x776cc1ec2e1e74ec24a074ff144e7b20f2f43d0997d0e2d08fc59dbb2cb36ad8", - "claims": { - "0x6e80164ea60673D64d5d6228beb684a1274Bb017": { - "index": 1, - "amount": "98", - "proof": [ - "0x24e1385387ca486e079e9435a84f0a78b299c3b9ce9cd52f8cf23ba009ccd002", - "0xdac00e214f93dbd7bd29e0cad8ad94d94a74d5d5ce2c8b6e5d1fde181ebe3740" - ] - }, - "0xad23ab2e2ec036a9ec319187e9659fcf8ddd6d38": { - "index": 2, - "amount": "147", - "proof": [ - "0xd268bbf69994cea70057deab58c962836c02f65a1474d718cf7b8ecb87aa5721" - ] - }, - "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { - "index": 0, - "amount": "180", - "proof": [ - "0x547b2845cc7b23ebb4ec1d0b0843f3e1f7f150da11542a41377ed869ac4f0700", - "0xdac00e214f93dbd7bd29e0cad8ad94d94a74d5d5ce2c8b6e5d1fde181ebe3740" - ] - } - } -} \ No newline at end of file diff --git a/src/redux-state/selectors/island.ts b/src/redux-state/selectors/island.ts index d82b834f2..d99e1a0ba 100644 --- a/src/redux-state/selectors/island.ts +++ b/src/redux-state/selectors/island.ts @@ -154,8 +154,7 @@ export const selectUnclaimedXpSumById = createSelector( [selectUnclaimedXpById], (unclaimedXp) => unclaimedXp?.reduce( - // TODO: not sue if final version will be hex or decimal - (acc, item) => acc + parseInt(item.claim.amount, 10), + (acc, item) => acc + parseInt(item.claim.amount, 16), 0 ) ?? 0 )