Last active
February 13, 2024 11:28
-
-
Save ochaloup/017334068f830221e7c786a9576ddc42 to your computer and use it in GitHub Desktop.
fixture account change script
This file contains 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
# solana account -um vbMaRfmTCg92HWGzmd53APkMNpPnGVGZTUHwUJQkXAU --output json -o fixtures/solana-accounts/vbMaRfmTCg92HWGzmd53APkMNpPnGVGZTUHwUJQkXAU.json | |
function to_bash_arr() { | |
ARR="$@" | |
echo $ARR | sed 's/[,]/ /g' | sed 's/\[\|\]/ /g' | |
} | |
EXPECTED_LEN=260 | |
CONFIG_PUBKEY=`solana-keygen pubkey fixtures/config.keypair` | |
CONFIG_ARRAY=`frombase58.py $CONFIG_PUBKEY` | |
[ `arraylength.sh $CONFIG_ARRAY` -ne 32 ] && echo "ERROR: $CONFIG_ARRAY is not of length 32" | |
C=`to_bash_arr "$CONFIG_ARRAY"` | |
for I in fixtures/solana-accounts/migrate-cpme/*; do | |
BASE64=`cat "$I" | jq '.account.data[0]'` | |
ARRAY_DATA=`frombase64.py $BASE64` | |
DISCRIMINATOR=`arraybyindex.sh "$ARRAY_DATA" 0 8` | |
[ `arraylength.sh $DISCRIMINATOR` -ne 8 ] && echo "ERROR: $DISCRIMINATOR is not of length 8" && break | |
REST=`arraybyindex.sh "$ARRAY_DATA" 40` | |
[ `arraylength.sh $REST` -ne $((${EXPECTED_LEN}-8-32)) ] && echo "ERROR: $RESTis not of length 220" && break | |
echo $DISCRIMINATOR $CONFIG_ARRAY $REST | |
D=`to_bash_arr "$DISCRIMINATOR"` | |
R=`to_bash_arr "$REST"` | |
RES=`echo $D $C $R | sed 's/[ ]\+/,/g'` | |
[ `arraylength.sh $RES` -ne $EXPECTED_LEN ] && echo "ERROR: resulted data is not of length 260" && break | |
RES_BASE64=`tobase64.py "$RES"` | |
sed -i 's|"[^"]\+=",.*$|"'"$RES_BASE64"'",|' "$I" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment