Skip to content

Commit

Permalink
Xp claim adjustments (#352)
Browse files Browse the repository at this point in the history
Ref #330

Contracts PRs:

https://github.com/tahowallet/contracts/pull/413
https://github.com/tahowallet/contracts/pull/412

### What

Following the steps described in the README you should be able to deploy
XP drop and claim TAHO from a given account.

- fix parsing XP amount number
- describe the XP drop deployment process
  • Loading branch information
Karolina Kosiorowska authored Oct 23, 2023
2 parents 3ae240c + fd65d09 commit 8849b7d
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
## Docs

- [Local environment setup](docs/local-env-setup.md)
- [Testing environment](docs/testing-env.md)
- [Testing environment](docs/testing-env.md)
67 changes: 62 additions & 5 deletions docs/local-env-setup.md
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -28,17 +28,74 @@ 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`

---

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
- 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 <path-to-input-file>.json <path-to-output-file>.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/<realm-id>` directory. Name the file `xp_<realm-id>_<drop-index>.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 <realm-address> <merkle-root> <amount> <merkle-data-url>
```
Where
```
<realm-address> - address of the realm where you want to publish the drop
<merkle-root> - merkle root of the merkle tree, copy from the output file
<amount> - amount of XP to be distributed, copy from the output file
<merkle-data-url> - 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
29 changes: 29 additions & 0 deletions src/data/xp/4/leaderboard.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
29 changes: 29 additions & 0 deletions src/data/xp/4/xp_4_1.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
}
29 changes: 0 additions & 29 deletions src/data/xp/9/leaderboard.json

This file was deleted.

3 changes: 1 addition & 2 deletions src/redux-state/selectors/island.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 8849b7d

Please sign in to comment.