Skip to content

Commit

Permalink
feat: add abi script and files
Browse files Browse the repository at this point in the history
  • Loading branch information
tansawit committed Aug 5, 2024
1 parent e945903 commit 8915f78
Show file tree
Hide file tree
Showing 24 changed files with 3,804 additions and 0 deletions.
21 changes: 21 additions & 0 deletions abi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Create the ABIs directory if it doesn't exist
mkdir -p abis

# Iterate over all JSON files in the out directory and its subdirectories
find out -name '*.json' | while read -r file; do
# Extract the contract name from the file path
contract_name=$(basename "$file" .json)

# Check if the ABI is not empty using jq
if jq -e '.abi | length > 0' "$file" > /dev/null; then
# Extract the ABI and save it to the ABIs directory
jq '.abi' "$file" > "abis/${contract_name}.abi.json"
echo "Extracted ABI for $contract_name"
else
echo "Skipped $contract_name as its ABI is empty"
fi
done

echo "All non-empty ABIs have been extracted to the ABIs directory."
35 changes: 35 additions & 0 deletions abis/Counter.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"type": "function",
"name": "increment",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "number",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "setNumber",
"inputs": [
{
"name": "newNumber",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [],
"stateMutability": "nonpayable"
}
]
21 changes: 21 additions & 0 deletions abis/ERC165.abi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"type": "function",
"name": "supportsInterface",
"inputs": [
{
"name": "interfaceId",
"type": "bytes4",
"internalType": "bytes4"
}
],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
}
]
Loading

0 comments on commit 8915f78

Please sign in to comment.