Skip to content

Commit

Permalink
Add importing claim records
Browse files Browse the repository at this point in the history
  • Loading branch information
toshiSat committed Nov 3, 2024
1 parent deb1b73 commit b943c54
Show file tree
Hide file tree
Showing 8 changed files with 1,090,578 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM scratch

RUN apt-get update && apt-get install -y bc

COPY ./arkeod /usr/bin/arkeod

WORKDIR /root/.arkeo
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM alpine:3.18

RUN apt-get update && apt-get install -y bc

COPY ./arkeod /usr/bin/arkeod

WORKDIR /root/.arkeo
Expand Down
1 change: 1 addition & 0 deletions 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
52 changes: 52 additions & 0 deletions scripts/add-claim-records.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Input files and genesis file
CHAIN1_CSV="./data/arkeo_airdrop_bech32.csv" # Replace with the actual filename for the first chain
CHAIN2_CSV="./data/combined_eth_airdrop.csv" # Replace with the actual filename for the second chain
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

# if [ ! -f "$GENESIS_FILE" ]; then
# echo "Genesis file 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)
tail -n +2 "$csv_file" | while IFS=, read -r address amount; do
# Multiply the amount by 10^9
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

# Remove the trailing comma and close the JSON array
records="${records%,}]"

# Add the batch of records to the genesis.json in one operation
jq --argjson new_records "$records" '.app_state.claimarkeo.claim_records += $new_records' "$GENESIS_FILE" >"$TEMP_FILE" && mv "$TEMP_FILE" "$GENESIS_FILE"
}

# Process CSV files for each chain
add_claim_records "$CHAIN1_CSV" "ARKEO"
add_claim_records "$CHAIN2_CSV" "ETHEREUM"

echo "Updated genesis.json with new claim records for both chains."
Loading

0 comments on commit b943c54

Please sign in to comment.