From 47f85813385af86fd8ab170e7151b139339e11a7 Mon Sep 17 00:00:00 2001 From: Jagoda Berry Rybacka Date: Thu, 12 Oct 2023 11:57:56 +0200 Subject: [PATCH 1/3] Fix parsing XP allocation amount --- src/redux-state/selectors/island.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/redux-state/selectors/island.ts b/src/redux-state/selectors/island.ts index 22ccb92b1..e7536ba64 100644 --- a/src/redux-state/selectors/island.ts +++ b/src/redux-state/selectors/island.ts @@ -144,8 +144,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 ) From 047bb169a44f64b011637c55fc98d1e1b5a4abbc Mon Sep 17 00:00:00 2001 From: Jagoda Berry Rybacka Date: Thu, 12 Oct 2023 11:58:27 +0200 Subject: [PATCH 2/3] Update readme to describe XP allocations deployment --- README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index be33e0973..179ed3d23 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,16 @@ Instruction based on [the system tests readme](https://github.com/tahowallet/con - 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` --- @@ -60,3 +66,52 @@ 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 + +--- + +### 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 \ No newline at end of file From a0d114308f6b3cb176dda430e972fa3cd437a918 Mon Sep 17 00:00:00 2001 From: Jagoda Berry Rybacka Date: Thu, 12 Oct 2023 11:58:46 +0200 Subject: [PATCH 3/3] Update mocked XP files --- src/data/xp/4/leaderboard.json | 29 +++++++++++++++++++++++++++++ src/data/xp/4/xp_4_1.json | 29 +++++++++++++++++++++++++++++ src/data/xp/9/leaderboard.json | 32 -------------------------------- src/data/xp/9/xp_9_1.json | 32 -------------------------------- 4 files changed, 58 insertions(+), 64 deletions(-) create mode 100644 src/data/xp/4/leaderboard.json create mode 100644 src/data/xp/4/xp_4_1.json delete mode 100644 src/data/xp/9/leaderboard.json delete mode 100644 src/data/xp/9/xp_9_1.json 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 d62d0e9da..000000000 --- a/src/data/xp/9/leaderboard.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "totalAmount": "425", - "merkleRoot": "0x776cc1ec2e1e74ec24a074ff144e7b20f2f43d0997d0e2d08fc59dbb2cb36ad8", - "claims": { - "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266": { - "index": 1, - "beneficiary": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", - "amount": "98", - "proof": [ - "0x24e1385387ca486e079e9435a84f0a78b299c3b9ce9cd52f8cf23ba009ccd002", - "0xdac00e214f93dbd7bd29e0cad8ad94d94a74d5d5ce2c8b6e5d1fde181ebe3740" - ] - }, - "0x70997970c51812dc3a010c7d01b50e0d17dc79c8": { - "index": 2, - "beneficiary": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", - "amount": "147", - "proof": [ - "0xd268bbf69994cea70057deab58c962836c02f65a1474d718cf7b8ecb87aa5721" - ] - }, - "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { - "index": 0, - "beneficiary": "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc", - "amount": "180", - "proof": [ - "0x547b2845cc7b23ebb4ec1d0b0843f3e1f7f150da11542a41377ed869ac4f0700", - "0xdac00e214f93dbd7bd29e0cad8ad94d94a74d5d5ce2c8b6e5d1fde181ebe3740" - ] - } - } -} \ No newline at end of file diff --git a/src/data/xp/9/xp_9_1.json b/src/data/xp/9/xp_9_1.json deleted file mode 100644 index 57028c6a4..000000000 --- a/src/data/xp/9/xp_9_1.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "totalAmount": "48780", - "merkleRoot": "0x95382c8d5c5293d5227a0e30788ffe1c0c86b2c3fe0abc0a56bf6816b9460613", - "claims": { - "0x6e80164ea60673d64d5d6228beb684a1274bb017": { - "index": 2, - "beneficiary": "0x6e80164ea60673d64d5d6228beb684a1274bb017", - "amount": "8130", - "proof": [ - "0x8ec0c0c52a46e5bc13c0e6d7923ce3b01155600b870d988692de29e538390103" - ] - }, - "0x70997970c51812dc3a010c7d01b50e0d17dc79c8": { - "index": 1, - "beneficiary": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", - "amount": "16260", - "proof": [ - "0x1364421c30895d0949d8f03614ad49766d67b19169eea8ec69551b7559a1539c", - "0xfd2c839ccc5047b31b14f224870dee095e8a72154a87fcc72c578122fb223323" - ] - }, - "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc": { - "index": 0, - "beneficiary": "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc", - "amount": "24390", - "proof": [ - "0x274996539fafc4b0887fdcfbe1c73bc1147c223b1ebedc6e4e8462a80707d2c7", - "0xfd2c839ccc5047b31b14f224870dee095e8a72154a87fcc72c578122fb223323" - ] - } - } -} \ No newline at end of file