Created
October 14, 2020 10:25
-
-
Save zhaojun-sh/4d34773801cec3175e93b7262099f9b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # specify the sender | |
| SENDER_OPT="--sender 0x1111111111111111111111111111111111111111 --keystore ./keystore/UTC--0x1111111111111111111111111111111111111111.json --password ./password.txt" | |
| printUsage() { | |
| echo "Usage: $0 <chainName> <gateway> <rewardToken> <batchInterval> <input-files ...> [--sendtx]" | |
| echo "" | |
| echo "input files line format: address,value" | |
| echo "value is of unit wei" | |
| echo "batchInterval is sleep interval of milliseconds per sending 100 txs (ie. 13000 for Fusion block chain)" | |
| echo "if --sendtx is not specified, then do dry run and won't broadcast tx." | |
| echo "" | |
| echo "Example:" | |
| echo " $0 fusion /run/efsn/mainnet/efsn.ipc 0x0c74199D22f732039e843366a236Ff4F61986B32 13000 airdrop-input-file" | |
| exit | |
| } | |
| if (($# < 5)); then | |
| printUsage | |
| fi | |
| if [[ ! -f ./distribute ]]; then | |
| echo "'./distribute' file not found" | |
| echo "you can build it from 'https://github.com/anyswap/ANYToken-distribution.git'" | |
| exit | |
| fi | |
| chainName="$1" | |
| gateway="$2" | |
| rewardToken="$3" | |
| batchInterval="$4" | |
| shift 4 | |
| dryrun="true" | |
| DateStr=$(date +%Y%m%d) | |
| INPUT_OUTPUT_FILES="" | |
| for inputFile in "$@"; do | |
| if [[ "$inputFile" == "--sendtx" ]]; then | |
| dryrun="false" | |
| continue | |
| fi | |
| outputFile="$chainName-${inputFile%.csv}-$DateStr-result.csv" | |
| INPUT_OUTPUT_FILES="$INPUT_OUTPUT_FILES --input $inputFile --output $outputFile" | |
| done | |
| if [[ -z "$INPUT_OUTPUT_FILES" ]]; then | |
| printUsage | |
| fi | |
| if [[ "$dryrun" = "true" ]]; then | |
| DRYRUN_OPT="--dryrun" | |
| fi | |
| GATEWAY_OPT="--gateway $gateway" | |
| REWARD_OPT="--rewardToken $rewardToken --rewardType custom" | |
| BATCH_OPT="--batchInterval $batchInterval" | |
| echo | |
| CMD="./distribute sendrewards $GATEWAY_OPT $REWARD_OPT $SENDER_OPT $BATCH_OPT $INPUT_OUTPUT_FILES $DRYRUN_OPT" | |
| echo $CMD | |
| echo | |
| echo | |
| read -p "do you want to continue: [y/n]: " answer | |
| if [[ "$answer" = "y" || "$answer" = "Y" ]]; then | |
| echo "------------ execute command --------------" | |
| $CMD | tee $chainName-airdrop-$(date +%Y%m%d).log | |
| else | |
| echo "------------ stop execution ---------------" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment