Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 [QA] Update release environment #691

Merged
merged 8 commits into from
Nov 14, 2023
Merged
10 changes: 5 additions & 5 deletions .github/workflows/test-list/release-test-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ environment 🚀**
6. Population
- [ ] shows on each realm
- [ ] shows on the bottom bar
- [ ] is updated approriately if a new account stakes
- [ ] is updated appropriately if a new account stakes

7. Quests/Questline
- [ ] shows on each realm as expected
Expand All @@ -70,11 +70,11 @@ environment 🚀**
9. Connect Wallet
- [ ] with Taho installed and default wallet
- [ ] with Taho installed and not default
- [ ] with Taho not installed and no other
- [ ] with Taho not installed and MM installed
- [ ] with Taho not installed and no other - should be directed to the Chrome store to download Taho & given a message in the dapp to do so
- [ ] with Taho not installed and MM installed - should be directed to the Chrome store to download Taho & given a message in the dapp to do so

10. XP
- [ ] an account with XP to claim sees that under Claimable Rewards on the Realm modal
- [ ] account can claim XP and sees the wallet balance of VETAHO change accordingly
- [ ] an account with XP to claim sees that under Claimable Rewards on the Realm modal (in pre-prod we can see this on stage-live but might be easiest to only test this when we're testing XP drops)
- [ ] account can claim XP and sees the wallet balance of VETAHO change accordingly (requires that the account earned XP and hasn't claimed it yet so this could be hard to test on each release but when we're testing XP drops, we should do this)
- [ ] leaderboard shows the top 10 earners in the realm - the connected account is shown at the top with their place on the board shown

84 changes: 20 additions & 64 deletions docs/local-env-setup.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# Working with forked Arbitrum Sepolia chain
# Working with Subscape locally

### In the dapp:

- Override `USE_ARBITRUM_FORK="true"` in `.env` file.
- Run the dapp
Either connect to
- the real Arbitrum Sepolia chain - override `USE_ARBITRUM_SEPOLIA="true"` in `.env` file
- to local fork - override `USE_LOCALHOST_FORK="true"` in `.env` file
- to Tenderly fork - `USE_TENDERLY_FORK="true"` in `.env` file
- Install dapp `yarn install`
- Run the dapp with `yarn start`

### In the [extension](https://github.com/tahowallet/extension):

- Install extension due to readme
If you want to use the real Arbitrum Sepolia blockchain:
- just use production version of the Taho wallet

If you want to use local or Tenderly fork:
- Install extension due to the readme
- Change `.env` variables
```bash
# Forking Arbitrum Sepolia
USE_MAINNET_FORK=true
MAINNET_FORK_CHAIN_ID="421614"
CHAIN_API_URL="https://sepolia-rollup.arbitrum.io/rpc"
CHAIN_API_URL="<tenderly-url-or-local-hardhat-url>"
```
- Restart extension's process
- Install extension as usual in the browser
- In the wallet let's import the account from the private key of the `testertesting.eth`
- Based on the Taho token's contract address (see `deployment-info.json` in the dapp or contracts repository) add the Taho asset to the wallet

### In the [contracts](https://github.com/tahowallet/contracts):

Follow to setup **local hardhat fork** of Arbitrum Sepolia network. The fork will contain the same set of contracts that is already deployed on the blockchain. In case of using Tenderly fork ignore this section.

Instruction based on [the system tests readme](https://github.com/tahowallet/contracts/blob/main/system-tests/README.md)

- Install contracts
Expand All @@ -30,15 +38,11 @@ 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="..." # 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_URL="https://sepolia-rollup.arbitrum.io/rpc" # any Arbitrum Sepolia RPC url
export TAHO_DEPLOYER_PRIVATE_KEY="..." # account that will get funds on the Hardhat chain fork

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 terminal and run `yarn run test:fork`
Expand All @@ -47,55 +51,7 @@ Instruction based on [the system tests readme](https://github.com/tahowallet/con

After all the steps above you should have:

- the Taho token deployed on the Arbitrum Sepolia forked chain
- (optional) 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 <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
- the wallet extension should be able to display the token's balance
- the wallet should be able to sign transactions
18 changes: 18 additions & 0 deletions docs/xp-distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

Allocation is done using the script from the [contracts](https://github.com/tahowallet/contracts) repository, please use [documentation](https://github.com/tahowallet/contracts/blob/main/merkle/README.adoc) written for the script there. This documentation assumes you've already generated all the files and the drop already happened. The only thing left to do is to provide the dapp source merkle tree data for given allocation.

#### Prepare merkle tree source file:

In the contracts repository create a file with XP allocations in the format:
```
[
{
"account": "0x...", // account address, normalized - lower case letters
"amount": "0x" // XP amount, 18 decimal places
},
]
```

#### Generate merkle trees and allocate XP

Generate merkle trees and do the allocations. There are 2 scripts that can be used:
1. Do the allocation on a single realm using `merkle:allocate-xp`
2. Do the allocation on multiple realms using `merkle:multi-allocate-xp`

### Providing XP data in the dapp

1. In the `src/assets/xp-data.json` find out where is the folder for the realm that you did the XP drop on. Should be `assets/xp/<realm-name>/`
Expand Down
6 changes: 4 additions & 2 deletions src/shared/components/TokenAmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default function TokenAmountInput({
<div>
{label && (
<div className="label">{`${label} ${bigIntToDisplayUserAmount(
balance
balance,
18,
5
)} ${symbol}`}</div>
)}
<SharedInput
Expand All @@ -88,7 +90,7 @@ export default function TokenAmountInput({
isDisabled={disabled}
onMouseDown={(event) => {
event.preventDefault()
onChange(bigIntToUserAmount(balance))
onChange(bigIntToUserAmount(balance, 18, 18))
}}
>
Max
Expand Down
14 changes: 10 additions & 4 deletions src/shared/utils/numbers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import { FixedPointNumber } from "shared/types/stake"
const FLOATING_POINT_REGEX = /^[^0-9]*([0-9,]+)(?:\.([0-9]*))?$/

export const separateThousandsByComma = (
value: number | bigint | string
value: number | bigint | string,
decimals = 2
): string => {
const adjustedValue = typeof value === "string" ? +value : value
return adjustedValue.toLocaleString("en-US", { maximumFractionDigits: 2 })
return adjustedValue.toLocaleString("en-US", {
// @ts-expect-error - `maximumFractionDigits` wants to get number less than 21,
// but as the tokens have 18 decimals have, we can safely pass a parameter
maximumFractionDigits: decimals < 21 ? decimals : 2,
})
}

function parseToFixedPointNumber(
Expand Down Expand Up @@ -81,7 +86,7 @@ export function bigIntToUserAmount(
desiredDecimals = 2
): string {
const desiredDecimalsAmount =
amount / 10n ** BigInt(Math.max(1, decimals - desiredDecimals))
amount / 10n ** BigInt(Math.max(0, decimals - desiredDecimals))

return (
Number(desiredDecimalsAmount) /
Expand All @@ -98,6 +103,7 @@ export function bigIntToDisplayUserAmount(
const amountBigInt = typeof amount === "string" ? BigInt(amount) : amount

return separateThousandsByComma(
bigIntToUserAmount(amountBigInt, decimals, desiredDecimals)
bigIntToUserAmount(amountBigInt, decimals, desiredDecimals),
desiredDecimals
)
}
Loading