#!/bin/bash
export SIGNATURES064=`node -e "console.log(Buffer.from('003fe8e05b0d3594bbf0ab1da0110dded88930a181ace6089a2442a8e58b293b23777331d928ab36c85de11e6f2874c1cc12c418fc4e0c1e344864a8b85fda042e0001791d7134fba47002376841fe688f7c478ba223580ec25ad5046a93db477d36fb4afa241ea95bf3c02b378a24220ff0f2ea035d088a0011bff9a4743d88f5c1b4010281940f26308012efd7a307960223638abde4fb55abcaac04a9fa97bf92e5518e5903396bf7e807eb0e97e3009f7e679c0dcece45cd659ab6cf45fed9add2d6a10103470cda5780ffb89118f152c449b4137f6c4f5413c4193d8a4169b31712d6c6583a90d34a31184cc5f3c8e8c987753a69ceadb2a46fcd31cd2db8fba4f918f5270004376beb1f765fe3222cc3fc0a891f731a7c9cdb762b5997e8bd9e32e473c2cf8b63db7fbb06156ec90990e6edd39cf3402054c2ca34bbec6fc2ab1cbfe49c9a860005058e4f1150dcdba98b8054f99dfe75fa2c2c8f0c9b23a858c9e5abff85e535f317627ddf5ec51b43182b382811f8a52c7832be5c7c630eb45d9213a96989c25c01','hex').toString('base64'))"`
export SIGNATURES164=`node -e "console.log(Buffer.from('0699f7fe9387cbc7c6528f7b7183042efb8d52f5e2811dc274c3e90141ff187fa21761f04e0d9b99f7bb40ad48709532c40b012de07d5253696aae4972ed1db2130107bfcf86e950316e431874dc755acafdbaf9c28d62b3731f76abe2f7299add68d0629fc5df238856ba6ad1c9ab6a5ed3f0c43a350250005274bdadbc2c697eb63b0108d69cae6a854c5468415c51747c9d7861ca5d5b164d100486c40477602a1c2e983da703866ffb2d3c9a642681e0c97c1ba8927d38b1d583c03a89d4f277a9a33900097e82cad360d4bb4f71e74e2ce0bdc067c38a97bd000fb397c99dbed63013179000b47e534028300a99ba5f722877164341ab859f8e7c21f815a77d54fd78aba2000ab009ea66dd2d7114952b3a667bd603110f08bd20ac03a79b672049e4a2f515b713527db7db0a3c13442ba8f2dad37cb255e4c660251cb96784ce7d385576eed5010b5ef9003237297028d98779f43041bd3141b4219ffa5965cf806d23188bb0538f0639aaadcda9d62a402df3a48da7cae5cc25e1a129ba30cf08cf5ff4da49bd0c00', 'hex').toString('base64'))"`

export SIGNATURES264=`node -e "console.log(Buffer.from('0cca7cd22e1514f0022666b35379f0685bfebbd5b80832d77eae6f57f52d351509093c433774d07ff6f3a4698331333a1dbb5478c4a51e20c15380d5dc68575f66000d525ac1524ec9d9ee623ef535a867e8f86d9b3f8e4c7b4234dbe7bb40dc8494327af2fa37c3db50064d6114f2e1441c4eee444b83636f11ce1f730f7b38490e28000e4528d8e7556ac14c74260f4ca5ed62c275324adec5a1146ac1abf6b41fcec88a24b4b797ed5370f648647904662e1fe2da2b4dea4327dfd2b94ca7080ed569f7010f5c84b1ef2ff5938ecdfd7048b2323b3e3568b2e0a62c8c513f60a4dfce8ee48e3fc7409caad8be1185be42c8a5e81d1fa4c4c98f6f53cdcddab6add2384dc5f20110cad08c66411cde321ce5b598ee4620e098e18a0427444c57923507064368912a3fab73a6b40dc050fbdaf340409583735a2528fde9b9b0322bd317f804b4767b0011c17a151c7d37376a3f7ea45030a18c4e3791dc5e376c350fe7838548506f64ee19e946fcb1b258394c6b6964608fc0a9d6a5ef682b3faded66b214637220dab300', 'hex').toString('base64'))"`

export SIGNATURES364=`node -e "console.log(Buffer.from('12af4f9015c9f11da3cb5457be96db960d49b37e59ec2bfce2b21dd2dfd28305f560e7977994a8380b7486361758a3eeace18aa1781bfcd79ad27995b41e504cd701','hex').toString('base64'))"`


export GK0='52A26Ce40F8CAa8D36155d37ef0D5D783fc614d2389A74E8FFa224aeAD0778c786163a7A2150768CB4459EA6482D4aE574305B239B4f2264239e7599072491bd66F63356090C11Aae8114F5372aBf12B51280eA1fd2B0A1c76Ae29a7d54dda68860A2bfFfa9Aa60CfF05e20E2CcAA784eE89A0A16C2057CB'

export GK1='e42d59F8FCd86a1c5c4bA351bD251A5c5B05DF6A4B07fF9D5cE1A6ed58b6e9e7d6974d1baBEc087ec8306B84235D7b0478c61783C50F990bfC44cFc0C8C1035110a13fe788259A4148F871b52bAbcb1B58A2508A20A7198E131503ce26bBE119aA8c62b28390820f04ddA22AFe03be1c3bb10f4ba6CF94A0'

export GK2='1FD6e97387C34a1F36DE0f8341E9D409E06ec45b255a41fC2792209CB998A8287204D40996df9E54bA663B12DD23fbF4FbAC618Be140727986B3BBd079040E577aC50486d0F6930e160A5C75FD1203C63580D2F00309A9A85efFAf02564Fc183C0183A963869795913D3B6dBF3B24a1C7654672c69A23c35'

export GK3='1c0Cc52D7673c52DE99785741344662F5b2308a0'

export GK064=`node -e "console.log(Buffer.from('$GK0',  'hex').toString('base64'))"`
export GK164=`node -e "console.log(Buffer.from('$GK1',  'hex').toString('base64'))"`
export GK264=`node -e "console.log(Buffer.from('$GK2',  'hex').toString('base64'))"`
export GK364=`node -e "console.log(Buffer.from('$GK3',  'hex').toString('base64'))"`

export VAABODY='0000000100000001000171f8dcb863d176e2c420ad6610cf687359612b6fb392e0642b0ca6b1f186aa3b00000000000000000012345678'
export VAABODY64=`node -e "console.log(Buffer.from('$VAABODY',  'hex').toString('base64'))"`
rm -f verify?.txn verify?.stxn verify?.dump

if [[ $1 == '' ]] 
then
	echo 'No appid specified'
	exit
fi
if [[ $STATELESS_ADDR == '' ]]
then
	echo 'No STATELESS_ADDR'
	exit
fi

goal app call --app-id $1 --from "$STATELESS_ADDR" --app-arg "str:verify" --app-arg "b64:$GK064" --app-arg "int:19" --noteb64 "$VAABODY64" -o verify0.txn
goal app call --app-id $1 --from "$STATELESS_ADDR" --app-arg "str:verify" --app-arg "b64:$GK164" --app-arg "int:19" --noteb64 "$VAABODY64" -o verify1.txn
goal app call --app-id $1 --from "$STATELESS_ADDR" --app-arg "str:verify" --app-arg "b64:$GK264" --app-arg "int:19" --noteb64 "$VAABODY64" -o verify2.txn
goal app call --app-id $1 --from "$STATELESS_ADDR" --app-arg "str:verify" --app-arg "b64:$GK364" --app-arg "int:19" --noteb64 "$VAABODY64" -o verify3.txn
cat verify0.txn verify1.txn verify2.txn verify3.txn > verifycc.txn
goal clerk group -i verifycc.txn -o group.txn
goal clerk split -i group.txn -o verify-signed
goal clerk sign --program vaa-verify.teal --argb64 "$SIGNATURES064" --infile verify-signed-0 --outfile verify-signed-0
goal clerk sign --program vaa-verify.teal --argb64 "$SIGNATURES164" --infile verify-signed-1 --outfile verify-signed-1
goal clerk sign --program vaa-verify.teal --argb64 "$SIGNATURES264" --infile verify-signed-2 --outfile verify-signed-2
goal clerk sign --program vaa-verify.teal --argb64 "$SIGNATURES364" --infile verify-signed-3 --outfile verify-signed-3
cat verify-signed-0 verify-signed-1 verify-signed-2 verify-signed-3 > verifygroup.stxn
goal clerk dryrun -t verifygroup.stxn --dryrun-dump --outfile verifygroup.dump
goal clerk dryrun-remote -D verifygroup.dump --verbose


