@@ -6,8 +6,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
66
77# Non-verification tempo checks: local tests, fork tests, cast commands, DEX operations
88
9- # Hardfork version, defaults to T3 (latest features)
10- HARDFORK=" ${TEMPO_HARDFORK:- T3 } "
9+ # Hardfork version, defaults to T5.
10+ HARDFORK=" ${TEMPO_HARDFORK:- T5 } "
1111
1212# Fee token address, defaults to native fee token
1313FEE_TOKEN=" ${TEMPO_FEE_TOKEN:- 0x20c0000000000000000000000000000000000000} "
@@ -48,6 +48,12 @@ fund_and_wait() {
4848 done
4949}
5050
51+ wallet_json_field () {
52+ local wallet_json=" $1 "
53+ local field=" $2 "
54+ jq -r --arg field " $field " ' (.data // .)[0][$field]' <<< " $wallet_json"
55+ }
56+
5157echo -e " \n=== INIT TEMPO PROJECT ==="
5258tmp_dir=$( mktemp -d)
5359cd " $tmp_dir "
@@ -76,8 +82,8 @@ forge script ${FEE_TOKEN_ARG[@]+"${FEE_TOKEN_ARG[@]}"} script/Mail.s.sol --sig "
7682
7783echo -e " \n=== CREATE AND FUND ADDRESS ==="
7884wallet_json=" $( cast wallet new --json) "
79- ADDR=" $( jq -r ' .[0].address ' <<< " $wallet_json" ) "
80- PK=" $( jq -r ' .[0].private_key ' <<< " $wallet_json" ) "
85+ ADDR=" $( wallet_json_field " $wallet_json " address ) "
86+ PK=" $( wallet_json_field " $wallet_json " private_key ) "
8187printf " address: %s\nprivate_key: %s\n" " $ADDR " " $PK "
8288fund_and_wait " $ADDR "
8389
@@ -158,8 +164,8 @@ cast send ${FEE_TOKEN_ARG[@]+"${FEE_TOKEN_ARG[@]}"} --rpc-url "$ETH_RPC_URL" 0x8
158164echo -e " \n=== SETUP ACCESS KEY ==="
159165# Create an access key for testing
160166access_wallet_json=" $( cast wallet new --json) "
161- ACCESS_KEY=" $( jq -r ' .[0].private_key ' <<< " $access_wallet_json" ) "
162- ACCESS_KEY_ADDR=" $( jq -r ' .[0].address ' <<< " $access_wallet_json" ) "
167+ ACCESS_KEY=" $( wallet_json_field " $access_wallet_json " private_key ) "
168+ ACCESS_KEY_ADDR=" $( wallet_json_field " $access_wallet_json " address ) "
163169printf " Access key address: %s\n" " $ACCESS_KEY_ADDR "
164170
165171# Authorize the access key on-chain first (required for gas estimation)
@@ -198,8 +204,8 @@ cast send ${FEE_TOKEN_ARG[@]+"${FEE_TOKEN_ARG[@]}"} --rpc-url "$ETH_RPC_URL" 0x8
198204
199205echo -e " \n=== CAST KEYCHAIN: AUTHORIZE ==="
200206kc_wallet_json=" $( cast wallet new --json) "
201- KC_KEY_PK=" $( jq -r ' .[0].private_key ' <<< " $kc_wallet_json" ) "
202- KC_KEY_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_wallet_json" ) "
207+ KC_KEY_PK=" $( wallet_json_field " $kc_wallet_json " private_key ) "
208+ KC_KEY_ADDR=" $( wallet_json_field " $kc_wallet_json " address ) "
203209printf " Keychain key address: %s\n" " $KC_KEY_ADDR "
204210
205211cast keychain auth " $KC_KEY_ADDR " secp256k1 1893456000 \
@@ -212,11 +218,11 @@ echo "$KC_INFO" | grep -q "secp256k1"
212218
213219echo -e " \n=== CAST KEYCHAIN: KEY-INFO --json ==="
214220KC_INFO_JSON=$( cast keychain info " $ADDR " " $KC_KEY_ADDR " --rpc-url " $ETH_RPC_URL " --json)
215- echo " $KC_INFO_JSON " | jq -e ' .signatureType == "secp256k1"'
221+ echo " $KC_INFO_JSON " | jq -e ' .data. signatureType == "secp256k1"'
216222
217223echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH LIMIT ==="
218224kc_limited_json=" $( cast wallet new --json) "
219- KC_LIMITED_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_limited_json" ) "
225+ KC_LIMITED_ADDR=" $( wallet_json_field " $kc_limited_json " address ) "
220226cast keychain auth " $KC_LIMITED_ADDR " secp256k1 1893456000 \
221227 --limit " $FEE_TOKEN :1000000000" \
222228 --rpc-url " $ETH_RPC_URL " --private-key " $PK " ${FEE_TOKEN_ARG[@]+" ${FEE_TOKEN_ARG[@]} " }
@@ -272,8 +278,8 @@ echo "OK: duplicate authorize correctly rejected"
272278if [[ " $HARDFORK " == " T3" ]]; then
273279 echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH --scope (ADDRESS ONLY, UNRESTRICTED) ==="
274280 kc_scoped_json=" $( cast wallet new --json) "
275- KC_SCOPED_PK=" $( jq -r ' .[0].private_key ' <<< " $kc_scoped_json" ) "
276- KC_SCOPED_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_scoped_json" ) "
281+ KC_SCOPED_PK=" $( wallet_json_field " $kc_scoped_json " private_key ) "
282+ KC_SCOPED_ADDR=" $( wallet_json_field " $kc_scoped_json " address ) "
277283 cast keychain auth " $KC_SCOPED_ADDR " secp256k1 1893456000 \
278284 --scope 0x86A2EE8FAf9A840F7a2c64CA3d51209F9A02081D \
279285 --rpc-url " $ETH_RPC_URL " --private-key " $PK " ${FEE_TOKEN_ARG[@]+" ${FEE_TOKEN_ARG[@]} " }
@@ -296,8 +302,8 @@ if [[ "$HARDFORK" == "T3" ]]; then
296302
297303 echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH --scope + SELECTORS ==="
298304 kc_sel_json=" $( cast wallet new --json) "
299- KC_SEL_PK=" $( jq -r ' .[0].private_key ' <<< " $kc_sel_json" ) "
300- KC_SEL_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_sel_json" ) "
305+ KC_SEL_PK=" $( wallet_json_field " $kc_sel_json " private_key ) "
306+ KC_SEL_ADDR=" $( wallet_json_field " $kc_sel_json " address ) "
301307 cast keychain auth " $KC_SEL_ADDR " secp256k1 1893456000 \
302308 --scope " $FEE_TOKEN :transfer,approve" \
303309 --rpc-url " $ETH_RPC_URL " --private-key " $PK " ${FEE_TOKEN_ARG[@]+" ${FEE_TOKEN_ARG[@]} " }
@@ -313,15 +319,15 @@ if [[ "$HARDFORK" == "T3" ]]; then
313319
314320 echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH --scopes JSON ==="
315321 kc_json_json=" $( cast wallet new --json) "
316- KC_JSON_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_json_json" ) "
322+ KC_JSON_ADDR=" $( wallet_json_field " $kc_json_json " address ) "
317323 cast keychain auth " $KC_JSON_ADDR " secp256k1 1893456000 \
318324 --scopes " [{\" target\" :\" $FEE_TOKEN \" ,\" selectors\" :[\" transfer\" ]},{\" target\" :\" 0x86A2EE8FAf9A840F7a2c64CA3d51209F9A02081D\" }]" \
319325 --rpc-url " $ETH_RPC_URL " --private-key " $PK " ${FEE_TOKEN_ARG[@]+" ${FEE_TOKEN_ARG[@]} " }
320326 echo " OK: authorized key with --scopes JSON"
321327
322328 echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH MULTIPLE LIMITS ==="
323329 kc_multi_json=" $( cast wallet new --json) "
324- KC_MULTI_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_multi_json" ) "
330+ KC_MULTI_ADDR=" $( wallet_json_field " $kc_multi_json " address ) "
325331 cast keychain auth " $KC_MULTI_ADDR " secp256k1 1893456000 \
326332 --limit " $FEE_TOKEN :1000000" \
327333 --limit " 0x20C0000000000000000000000000000000000001:2000000" \
@@ -336,8 +342,8 @@ if [[ "$HARDFORK" == "T3" ]]; then
336342
337343 echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH RAW HEX SELECTOR ==="
338344 kc_hex_json=" $( cast wallet new --json) "
339- KC_HEX_PK=" $( jq -r ' .[0].private_key ' <<< " $kc_hex_json" ) "
340- KC_HEX_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_hex_json" ) "
345+ KC_HEX_PK=" $( wallet_json_field " $kc_hex_json " private_key ) "
346+ KC_HEX_ADDR=" $( wallet_json_field " $kc_hex_json " address ) "
341347 # increment() selector = 0xd09de08a
342348 cast keychain auth " $KC_HEX_ADDR " secp256k1 1893456000 \
343349 --scope " 0x86A2EE8FAf9A840F7a2c64CA3d51209F9A02081D:0xd09de08a" \
@@ -354,8 +360,8 @@ if [[ "$HARDFORK" == "T3" ]]; then
354360 echo -e " \n=== CAST KEYCHAIN: SET-SCOPE ==="
355361 # Create a new unrestricted key, then add scope restrictions via set-scope
356362 kc_ss_json=" $( cast wallet new --json) "
357- KC_SS_PK=" $( jq -r ' .[0].private_key ' <<< " $kc_ss_json" ) "
358- KC_SS_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_ss_json" ) "
363+ KC_SS_PK=" $( wallet_json_field " $kc_ss_json " private_key ) "
364+ KC_SS_ADDR=" $( wallet_json_field " $kc_ss_json " address ) "
359365 cast keychain auth " $KC_SS_ADDR " secp256k1 1893456000 \
360366 --rpc-url " $ETH_RPC_URL " --private-key " $PK " ${FEE_TOKEN_ARG[@]+" ${FEE_TOKEN_ARG[@]} " }
361367
@@ -403,8 +409,8 @@ if [[ "$HARDFORK" == "T3" ]]; then
403409
404410 echo -e " \n=== CAST KEYCHAIN: AUTHORIZE WITH RECIPIENT RESTRICTION ==="
405411 kc_recip_json=" $( cast wallet new --json) "
406- KC_RECIP_PK=" $( jq -r ' .[0].private_key ' <<< " $kc_recip_json" ) "
407- KC_RECIP_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_recip_json" ) "
412+ KC_RECIP_PK=" $( wallet_json_field " $kc_recip_json " private_key ) "
413+ KC_RECIP_ADDR=" $( wallet_json_field " $kc_recip_json " address ) "
408414 # Only allow transfer to a specific recipient
409415 ALLOWED_RECIPIENT=" 0x4ef5DFf69C1514f4Dbf85aA4F9D95F804F64275F"
410416 cast keychain auth " $KC_RECIP_ADDR " secp256k1 1893456000 \
@@ -422,7 +428,7 @@ if [[ "$HARDFORK" == "T3" ]]; then
422428
423429 echo -e " \n=== CAST KEYCHAIN: --scopes JSON WITH RECIPIENTS ==="
424430 kc_jsonr_json=" $( cast wallet new --json) "
425- KC_JSONR_ADDR=" $( jq -r ' .[0].address ' <<< " $kc_jsonr_json" ) "
431+ KC_JSONR_ADDR=" $( wallet_json_field " $kc_jsonr_json " address ) "
426432 cast keychain auth " $KC_JSONR_ADDR " secp256k1 1893456000 \
427433 --scopes " [{\" target\" :\" $FEE_TOKEN \" ,\" selectors\" :[{\" selector\" :\" transfer\" ,\" recipients\" :[\" $ALLOWED_RECIPIENT \" ]}]},{\" target\" :\" 0x86A2EE8FAf9A840F7a2c64CA3d51209F9A02081D\" }]" \
428434 --rpc-url " $ETH_RPC_URL " --private-key " $PK " ${FEE_TOKEN_ARG[@]+" ${FEE_TOKEN_ARG[@]} " }
@@ -434,8 +440,8 @@ fi # end T3-only scope tests
434440echo -e " \n=== SETUP SPONSOR ==="
435441# Create a sponsor wallet for testing sponsored (gasless) transactions
436442sponsor_wallet_json=" $( cast wallet new --json) "
437- SPONSOR_PK=" $( jq -r ' .[0].private_key ' <<< " $sponsor_wallet_json" ) "
438- SPONSOR_ADDR=" $( jq -r ' .[0].address ' <<< " $sponsor_wallet_json" ) "
443+ SPONSOR_PK=" $( wallet_json_field " $sponsor_wallet_json " private_key ) "
444+ SPONSOR_ADDR=" $( wallet_json_field " $sponsor_wallet_json " address ) "
439445printf " Sponsor address: %s\n" " $SPONSOR_ADDR "
440446
441447# Fund the sponsor address (sponsor pays gas)
@@ -802,8 +808,8 @@ echo -e "\n=== ANVIL FORK TESTS ==="
802808# Use a fresh wallet for fork tests to avoid fee token exhaustion from prior devnet tests
803809echo -e " \n=== ANVIL FORK: CREATE AND FUND FRESH WALLET ==="
804810fork_wallet_json=" $( cast wallet new --json) "
805- FORK_ADDR=" $( jq -r ' .[0].address ' <<< " $fork_wallet_json" ) "
806- FORK_PK=" $( jq -r ' .[0].private_key ' <<< " $fork_wallet_json" ) "
811+ FORK_ADDR=" $( wallet_json_field " $fork_wallet_json " address ) "
812+ FORK_PK=" $( wallet_json_field " $fork_wallet_json " private_key ) "
807813printf " Fork test address: %s\n" " $FORK_ADDR "
808814fund_and_wait " $FORK_ADDR "
809815
0 commit comments