Skip to content

Commit

Permalink
feat: add importing claim records (#298)
Browse files Browse the repository at this point in the history
* Add importing claim records

* Finish claim record scripts

* Add changelog

* Remove installation from dockerfile

* Add final csv's
  • Loading branch information
toshiSat authored Dec 8, 2024
1 parent b8dda2a commit b1c4e94
Show file tree
Hide file tree
Showing 7 changed files with 726,769 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Contains all the PRs that improved the code without changing the behaviors.
# v1.0.1-Prerelease

## Added
- Add claim record scripts
- Thorchain Claims Proto Updates
- Documentation of Testnet Setup using local build and Cosmovisor
- Documentation update and addition of validator setup documentation
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.localnet
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ FROM ubuntu:lunar
# hadolint ignore=DL3008,DL4006
RUN apt-get update -y && \
apt-get upgrade -y && \
apt-get install -y bc && \
apt-get install -y --no-install-recommends \
jq curl htop vim ca-certificates && \
apt-get clean && \
Expand Down
46 changes: 46 additions & 0 deletions scripts/add-claim-records.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# Input files and genesis file
CHAIN1_CSV="./data/arkeo_airdrop.csv"
CHAIN2_CSV="./data/eth_airdrop.csv"
GENESIS_FILE="~/.arkeo/config/genesis.json"
TEMP_FILE="/tmp/genesis_temp.json"

# Check if CSV files and genesis.json exist
if [ ! -f "$CHAIN1_CSV" ] || [ ! -f "$CHAIN2_CSV" ]; then
echo "CSV file for one of the chains not found!"
exit 1
fi

# Function to process a CSV file and add entries to the genesis file
add_claim_records() {
local csv_file="$1"
local chain_name="$2"

# Start building the new claim records JSON array
records="["

# Loop through each line in the CSV file (skip the header)
while IFS=, read -r address amount; do
amount_claim=$(echo "scale=0; $amount * 100000000 / 3" | bc)
amount_vote=$(echo "scale=0; $amount * 100000000 / 3" | bc)
amount_delegate=$(echo "scale=0; $amount * 100000000 / 3" | bc)

# Append the new record to the JSON array
records+=$(jq -n --arg chain "$chain_name" --arg address "$address" --arg amount_claim "$amount_claim" --arg amount_vote "$amount_vote" --arg amount_delegate "$amount_delegate" \
'{chain: $chain, address: $address, amount_claim: {denom: "uarkeo", amount: $amount_claim}, amount_vote: {denom: "uarkeo", amount: $amount_vote}, amount_delegate: {denom: "uarkeo", amount: $amount_delegate}, is_transferable: true}')
records+=","
done < <(tail -n +2 "$csv_file")

records="${records%,}]"

echo "Final JSON Records Array: $records"

jq --argjson new_records "$records" '.app_state.claimarkeo.claim_records += $new_records' <~/.arkeo/config/genesis.json >/tmp/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
}

add_claim_records "$CHAIN1_CSV" "ARKEO"
add_claim_records "$CHAIN2_CSV" "ETHEREUM"

echo "Updated genesis.json with new claim records for arkeo and ethereum."
681,711 changes: 681,711 additions & 0 deletions scripts/data/arkeo_airdrop.csv

Large diffs are not rendered by default.

44,996 changes: 44,996 additions & 0 deletions scripts/data/eth_airdrop.csv

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions scripts/genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ add_claim_records() {
}

set_fee_pool() {
local denom="$1"
local amount="$2"
local denom="$1"
local amount="$2"

jq --arg DENOM "$denom" --arg AMOUNT "$amount" '.app_state.distribution.fee_pool.community_pool = [{
jq --arg DENOM "$denom" --arg AMOUNT "$amount" '.app_state.distribution.fee_pool.community_pool = [{
"denom": $DENOM,
"amount": $AMOUNT
}]' <~/.arkeo/config/genesis.json >/tmp/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
}

disable_mint_params() {
jq '.app_state.mint.minter.inflation = "0.000000000000000000" |
jq '.app_state.mint.minter.inflation = "0.000000000000000000" |
.app_state.mint.minter.annual_provisions = "0.000000000000000000" |
.app_state.mint.params.inflation_rate_change = "0.000000000000000000" |
.app_state.mint.params.inflation_max = "0.000000000000000000" |
.app_state.mint.params.inflation_min = "0.000000000000000000"' \
<~/.arkeo/config/genesis.json >/tmp/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
<~/.arkeo/config/genesis.json >/tmp/genesis.json
mv /tmp/genesis.json ~/.arkeo/config/genesis.json
}

if [ ! -f ~/.arkeo/config/priv_validator_key.json ]; then
Expand All @@ -104,22 +104,18 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then
disable_mint_params

if [ "$NET" = "mocknet" ] || [ "$NET" = "testnet" ]; then
add_module tarkeo1d0m97ywk2y4vq58ud6q5e0r3q9khj9e3unfe4t $TOKEN 2420000000000000 'arkeo-reserve'
add_module tarkeo1d0m97ywk2y4vq58ud6q5e0r3q9khj9e3unfe4t $TOKEN 2420000000000000 'arkeo-reserve'
add_module tarkeo14tmx70mvve3u7hfmd45vle49kvylk6s2wllxny $TOKEN 3025000000000000 'claimarkeo'
add_module tarkeo1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8t6gr9e $TOKEN 4840000000000000 'distribution'
# this is to handle the balance set to distribution as a community pool
# this is to handle the balance set to distribution as a community pool
set_fee_pool $TOKEN 4840000000000000



# Add Foundational Accounts
# Add Foundational Accounts
# FoundationDevAccount = "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q"
add_account "tarkeo1x978nttd8vgcgnv9wxut4dh7809lr0n2fhuh0q" $TOKEN 1210000000000000
# FoundationGrantsAccount = "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj"
add_account "tarkeo1a307z4a82mcyv9njdj9ajnd9xpp90kmeqwntxj" $TOKEN 605000000000000




# Thorchain derived test addresses
add_account "tarkeo1dllfyp57l4xj5umqfcqy6c2l3xfk0qk6zpc3t7" $TOKEN 1000000000000000 # bob, 10m
add_claim_records "ARKEO" "tarkeo1dllfyp57l4xj5umqfcqy6c2l3xfk0qk6zpc3t7" 1000 1000 1000 true
Expand All @@ -135,6 +131,8 @@ if [ ! -f ~/.arkeo/config/genesis.json ]; then
# enable CORs on testnet/localnet
sed -i 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' ~/.arkeo/config/app.toml
sed -i 's/cors_allowed_origins = \[\]/cors_allowed_origins = \["*"\]/g' ~/.arkeo/config/config.toml
else
source ./add-claim-records.sh
fi

sed -i 's/"stake"/"uarkeo"/g' ~/.arkeo/config/genesis.json
Expand Down
2 changes: 1 addition & 1 deletion x/claim/keeper/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func (k Keeper) SetClaimRecord(ctx sdk.Context, claimRecord types.ClaimRecord) error {
// validate address if valid based on chain
if !types.IsValidAddress(claimRecord.Address, claimRecord.Chain) {
return sdkerror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address for chain %s", claimRecord.Chain.String())
return sdkerror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid address %s for chain %s", claimRecord.Address, claimRecord.Chain.String())
}

store := ctx.KVStore(k.storeKey)
Expand Down

0 comments on commit b1c4e94

Please sign in to comment.