Skip to content

Commit 2eb1207

Browse files
committed
lint
1 parent 34f1ee5 commit 2eb1207

File tree

6 files changed

+67
-63
lines changed

6 files changed

+67
-63
lines changed

tests/evm-tools-compatibility/foundry/.env

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
FOUNDRY_DISABLE_NIGHTLY_WARNING=true
77

88
# chain id
9-
CHAIN_ID="4221"
9+
CHAIN_ID=4221
1010
# endpoint of custom chain
11-
CUSTOM_RPC="http://127.0.0.1:8545"
11+
CUSTOM_RPC=http://127.0.0.1:8545
1212
# private key for tx broadcast (PUBLIC TEST KEY - NOT A SECRET)
1313
# Split to avoid false positive secret detection
1414
PRIVATE_KEY_PART1=0x8a36c69d940a92fcea94b36d0f2928c7a0ee19a90
1515
PRIVATE_KEY_PART2=073eda769693298dfa9603b
1616
PRIVATE_KEY=${PRIVATE_KEY_PART1}${PRIVATE_KEY_PART2}
1717

1818
# erc20 contract address
19-
CONTRACT="0xA3D934000542D6A51BD3B4D18B04418aFfB52672"
19+
CONTRACT=0xA3D934000542D6A51BD3B4D18B04418aFfB52672
2020

2121
# accounts
22-
ACCOUNT_1="0x498B5AeC5D439b733dC2F58AB489783A23FB26dA"
23-
ACCOUNT_2="0x40a0cb1C63e026A81B55EE1308586E21eec1eFa9"
24-
22+
ACCOUNT_1=0x498B5AeC5D439b733dC2F58AB489783A23FB26dA
23+
ACCOUNT_2=0x40a0cb1C63e026A81B55EE1308586E21eec1eFa9

tests/evm-tools-compatibility/foundry/shellscripts/get-network-info.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -euo pipefail
44
# Usage: ./query_network_info.sh [RPC_URL]
55
# If RPC_URL is not provided as the first argument, falls back to $CUSTOM_RPC or http://127.0.0.1:8545
66

7+
# shellcheck source=../.env
78
source ../.env
89
RPC_URL=${1:-${CUSTOM_RPC:-http://127.0.0.1:8545}}
910

@@ -38,4 +39,4 @@ echo
3839
echo "⚙️ Protocol Version:"
3940
echo "$ cast rpc --rpc-url \"$RPC_URL\" eth_protocolVersion"
4041
cast rpc --rpc-url "$RPC_URL" eth_protocolVersion
41-
echo
42+
echo

tests/evm-tools-compatibility/foundry/shellscripts/get-tx.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# Usage: ./get-tx.sh <TX_HASH> [RPC_URL]
44
# Example: ./get-tx.sh 0x1234... http://127.0.0.1:8545
55

6+
# shellcheck source=../.env
67
source ../.env
78
TX_HASH=$1
89
RPC_URL=${2:-http://127.0.0.1:8545}
910

1011
if [ -z "$TX_HASH" ]; then
11-
echo "Usage: $0 <TX_HASH> [RPC_URL]"
12-
exit 1
12+
echo "Usage: $0 <TX_HASH> [RPC_URL]"
13+
exit 1
1314
fi
1415

1516
# get transaction by hash
@@ -27,7 +28,7 @@ echo "📡 Getting transaction by hash:"
2728
echo "$ curl -s -X POST -H \"Content-Type: application/json\" --data '$PAYLOAD' \"$RPC_URL\" | jq"
2829
echo
2930
curl -s -X POST \
30-
-H "Content-Type: application/json" \
31-
--data "$PAYLOAD" \
32-
"$RPC_URL" \
33-
| jq
31+
-H "Content-Type: application/json" \
32+
--data "$PAYLOAD" \
33+
"$RPC_URL" |
34+
jq

tests/evm-tools-compatibility/foundry/shellscripts/read_state.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,48 @@ set -euo pipefail
44
# Usage: ./read_state.sh <CONTRACT_ADDRESS>
55
# .env에 CUSTOM_RPC, ALICE_ADDRESS 를 정의해 두세요.
66

7+
# shellcheck source=../.env
78
source ../.env
89
RPC_URL=${CUSTOM_RPC:-http://127.0.0.1:8545}
910
CONTRACT=$1
1011
ALICE=${ALICE_ADDRESS:-0x0000000000000000000000000000000000000001}
1112

1213
if [ -z "$CONTRACT" ]; then
13-
echo "Usage: $0 <CONTRACT_ADDRESS>"
14-
exit 1
14+
echo "Usage: $0 <CONTRACT_ADDRESS>"
15+
exit 1
1516
fi
1617

1718
# 1) Chain ID
1819
echo "⛓ Chain ID:"
1920
echo "$ cast chain-id --rpc-url \"$RPC_URL\""
20-
echo "$(cast chain-id --rpc-url "$RPC_URL")"
21+
cast chain-id --rpc-url "$RPC_URL"
2122
echo
2223

2324
# 2) totalSupply()
2425
echo "🔢 totalSupply:"
2526
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'totalSupply()(uint256)'"
26-
echo "$(cast call --rpc-url "$RPC_URL" "$CONTRACT" 'totalSupply()(uint256)')"
27+
cast call --rpc-url "$RPC_URL" "$CONTRACT" 'totalSupply()(uint256)'
2728
echo
2829

2930
# 3) balanceOf(alice)
3031
echo "👤 balanceOf(alice=$ALICE):"
3132
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'balanceOf(address)(uint256)' \"$ALICE\""
32-
echo "$(cast call --rpc-url "$RPC_URL" "$CONTRACT" 'balanceOf(address)(uint256)' "$ALICE")"
33+
cast call --rpc-url "$RPC_URL" "$CONTRACT" 'balanceOf(address)(uint256)' "$ALICE"
3334
echo
3435

3536
# 4) name()
3637
echo "📛 name:"
3738
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'name()(string)'"
38-
echo "$(cast call --rpc-url "$RPC_URL" "$CONTRACT" 'name()(string)')"
39+
cast call --rpc-url "$RPC_URL" "$CONTRACT" 'name()(string)'
3940
echo
4041

4142
# 5) symbol()
4243
echo "🔣 symbol:"
4344
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'symbol()(string)'"
44-
echo "$(cast call --rpc-url "$RPC_URL" "$CONTRACT" 'symbol()(string)')"
45+
cast call --rpc-url "$RPC_URL" "$CONTRACT" 'symbol()(string)'
4546
echo
4647

4748
# 6) decimals()
4849
echo "🔢 decimals:"
4950
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'decimals()(uint8)'"
50-
echo "$(cast call --rpc-url "$RPC_URL" "$CONTRACT" 'decimals()(uint8)')"
51+
cast call --rpc-url "$RPC_URL" "$CONTRACT" 'decimals()(uint8)'

tests/evm-tools-compatibility/foundry/shellscripts/transfer.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ set -euo pipefail
55
# Requires: .env with CUSTOM_RPC and PRIVATE_KEY
66

77
if [ $# -ne 3 ]; then
8-
echo "Usage: $0 <CONTRACT_ADDR> <TO_ADDR> <AMOUNT>"
9-
exit 1
8+
echo "Usage: $0 <CONTRACT_ADDR> <TO_ADDR> <AMOUNT>"
9+
exit 1
1010
fi
1111

12+
# shellcheck source=../.env
1213
source ../.env
1314
CONTRACT=$1
1415
TO=$2
15-
AMOUNT=$3 # e.g. 100000000000000000000 for 100 tokens (18 decimals)
16+
AMOUNT=$3 # e.g. 100000000000000000000 for 100 tokens (18 decimals)
1617
RPC_URL=${CUSTOM_RPC:-http://127.0.0.1:8545}
1718
PRIVATE_KEY=${PRIVATE_KEY:?}
1819
CHAIN_ID=${CHAIN_ID:-262144}
@@ -24,12 +25,12 @@ echo "📦 Sending transfer($TO, $AMOUNT) to $CONTRACT"
2425
echo "💸 Sending transfer transaction:"
2526
echo "$ cast send \"$CONTRACT\" 'transfer(address,uint256)' \"$TO\" \"$AMOUNT\" --rpc-url \"$RPC_URL\" --private-key \"[HIDDEN]\" --chain-id \"$CHAIN_ID\" --json"
2627
RESPONSE=$(cast send \
27-
"$CONTRACT" \
28-
'transfer(address,uint256)' "$TO" "$AMOUNT" \
29-
--rpc-url "$RPC_URL" \
30-
--private-key "$PRIVATE_KEY" \
31-
--chain-id "$CHAIN_ID" \
32-
--json)
28+
"$CONTRACT" \
29+
'transfer(address,uint256)' "$TO" "$AMOUNT" \
30+
--rpc-url "$RPC_URL" \
31+
--private-key "$PRIVATE_KEY" \
32+
--chain-id "$CHAIN_ID" \
33+
--json)
3334

3435
TXHASH=$(echo "$RESPONSE" | jq -r '.hash // .transactionHash')
3536
echo "✅ Transaction sent: $TXHASH"
@@ -51,17 +52,17 @@ echo
5152
echo "💰 Checking balances:"
5253
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'balanceOf(address)(uint256)' \"$SENDER\""
5354
SENDER_BALANCE=$(cast call \
54-
--rpc-url "$RPC_URL" \
55-
"$CONTRACT" \
56-
'balanceOf(address)(uint256)' \
57-
"$SENDER")
55+
--rpc-url "$RPC_URL" \
56+
"$CONTRACT" \
57+
'balanceOf(address)(uint256)' \
58+
"$SENDER")
5859

5960
echo "$ cast call --rpc-url \"$RPC_URL\" \"$CONTRACT\" 'balanceOf(address)(uint256)' \"$TO\""
6061
RECEIVER_BALANCE=$(cast call \
61-
--rpc-url "$RPC_URL" \
62-
"$CONTRACT" \
63-
'balanceOf(address)(uint256)' \
64-
"$TO")
62+
--rpc-url "$RPC_URL" \
63+
"$CONTRACT" \
64+
'balanceOf(address)(uint256)' \
65+
"$TO")
6566

6667
echo "👤 Sender ($SENDER) balance: $SENDER_BALANCE"
67-
echo "👤 Receiver ($TO) balance: $RECEIVER_BALANCE"
68+
echo "👤 Receiver ($TO) balance: $RECEIVER_BALANCE"

tests/evm-tools-compatibility/foundry/shellscripts/transfer_error.sh

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -euo pipefail
33

44
# Usage: ./error_edge_case.sh
55
# Requires in .env: CUSTOM_RPC, PRIVATE_KEY, ACCOUNT_2 (recipient), CONTRACT
6+
# shellcheck source=../.env
67
source ../.env
78
export FOUNDRY_DISABLE_NIGHTLY_WARNING=1
89

@@ -13,8 +14,8 @@ CHAIN_ID=${CHAIN_ID:-262144}
1314

1415
# Ensure CONTRACT is set
1516
if [ -z "${CONTRACT:-}" ]; then
16-
echo "Error: CONTRACT environment variable not set."
17-
exit 1
17+
echo "Error: CONTRACT environment variable not set."
18+
exit 1
1819
fi
1920

2021
# Amount exceeding typical balance (2000 tokens)
@@ -26,36 +27,36 @@ echo "🔄 Sending transfer exceeding balance..."
2627
echo "❌ Attempting transfer that should fail:"
2728
echo "$ cast send \"$CONTRACT\" 'transfer(address,uint256)' \"$RECIPIENT\" \"$AMOUNT\" --rpc-url \"$RPC_URL\" --private-key \"[HIDDEN]\" --chain-id \"$CHAIN_ID\" --json"
2829
OUTPUT=$(cast send \
29-
"$CONTRACT" \
30-
'transfer(address,uint256)' "$RECIPIENT" "$AMOUNT" \
31-
--rpc-url "$RPC_URL" \
32-
--private-key "$PK" \
33-
--chain-id "$CHAIN_ID" \
34-
--json 2>&1 || true)
30+
"$CONTRACT" \
31+
'transfer(address,uint256)' "$RECIPIENT" "$AMOUNT" \
32+
--rpc-url "$RPC_URL" \
33+
--private-key "$PK" \
34+
--chain-id "$CHAIN_ID" \
35+
--json 2>&1 || true)
3536

3637
# 2) Try parse JSON
3738
JSON=$(echo "$OUTPUT" | sed -n 's/.*\({.*\)/\1/p')
3839

3940
if [ -n "$JSON" ]; then
40-
# 3a) JSON returned -> parse error field
41-
echo "$JSON" | jq -r '
41+
# 3a) JSON returned -> parse error field
42+
echo "$JSON" | jq -r '
4243
if has("error") then
4344
"✅ Transaction reverted as expected:\n " + .error.message
4445
else
4546
"❌ Expected a revert, but transaction succeeded:\n" + (.|tojson)
4647
end'
4748
else
48-
# 3b) No JSON -> fallback to raw text check
49-
if echo "$OUTPUT" | grep -q -e 'execution reverted' -e 'ERC20InsufficientBalance'; then
50-
echo "✅ Transaction reverted as expected"
51-
echo
52-
echo "Revert detail:"
53-
# Newline before 'Error:'
54-
echo "$OUTPUT" | sed -n 's/.*\(Error:.*\)/\1/p'
55-
else
56-
echo "❌ Unexpected response (no JSON, no revert message):"
57-
echo
58-
echo "$OUTPUT"
59-
exit 1
60-
fi
61-
fi
49+
# 3b) No JSON -> fallback to raw text check
50+
if echo "$OUTPUT" | grep -q -e 'execution reverted' -e 'ERC20InsufficientBalance'; then
51+
echo "✅ Transaction reverted as expected"
52+
echo
53+
echo "Revert detail:"
54+
# Newline before 'Error:'
55+
echo "$OUTPUT" | sed -n 's/.*\(Error:.*\)/\1/p'
56+
else
57+
echo "❌ Unexpected response (no JSON, no revert message):"
58+
echo
59+
echo "$OUTPUT"
60+
exit 1
61+
fi
62+
fi

0 commit comments

Comments
 (0)