Skip to content

Commit

Permalink
better abi exporter todo using forge inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Dec 23, 2024
1 parent 4808f41 commit 9e640f4
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 43 deletions.
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// solidity
"solidity.packageDefaultDependenciesContractsDirectory": "src",
"solidity.packageDefaultDependenciesDirectory": "lib",
"editor.formatOnSave": true,
Expand All @@ -7,5 +8,8 @@
},
"solidity.formatter": "forge",
"solidity.compileUsingRemoteVersion": "v0.8.26",
"solidity.defaultCompiler": "localFile"
"solidity.defaultCompiler": "localFile",
"material-icon-theme.files.associations": {
".gas-snapshot": "bench-ts"
}
}
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ forge script ./script/Deploy.s.sol:Deploy<CONTRACT_NAME> \
--broadcast
```

You can see deployed contract addresses under the `deployment/<chainid>.json`
You can see deployed contract addresses under the [`deployments/<chainid>.json`](./deployments/)

You can verify the contract during deployment by adding the verification arguments as well:

Expand Down Expand Up @@ -150,18 +150,32 @@ Note that the `--verifier-url` value should be the target explorer's homepage UR
>
> The `--verifier` can accept any of the following: `etherscan`, `blockscout`, `sourcify`, `oklink`. We are using Blockscout most of the time.
### Generate ABIs
After deployment, we need to take care of two things:

To interact with the contracts, you need the contract ABIs. We store the ABIs under the [`abis`](./abis/) folder, and these can be generated using the following script:
- **ABIs**: to interact with the contracts
- **Artifacts**: required if we need to upgrade in future

We have a post-deployment script that outputs these files under the [`deployments/abis`](./deployments/abis/) folder:

```sh
./export-abis.sh
# requires NodeJS
./post-deploy.sh
```

### Upgrade Contract

Upgrading an existing contract is done as per the instructions in [openzeppelin-foundry-upgrades](https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades) repository.
The `--sender <ADDRESS>` field is required when deploying a contract,

To upgrade, you must

> [!NOTE]
>
> The `--sender <ADDRESS>` field is mandatory when deploying a contract, it can be obtained with:
>
> ```sh
> # will prompt for password
> cast wallet address --account <WALLET_NAME>
> ```
## Testing & Diagnostics
Expand Down Expand Up @@ -225,7 +239,7 @@ forge fmt ./src/**/*.sol ./script/**/*.sol
If you have solhint installed, you can lint all contracts with:

```sh
solhint 'contracts/**/*.sol'
solhint 'src/**/*.sol'
```

## Documentation
Expand Down
24 changes: 0 additions & 24 deletions abis/parseAbi.cjs

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions deployments/abis/LLMOracleCoordinator.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,4 @@
}
]
}
]
]
1 change: 1 addition & 0 deletions deployments/abis/LLMOracleRegistry.json

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions export-abis.sh

This file was deleted.

2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ force = true
# fs permissions for deployment (false by default)
fs_permissions = [
{ access = "read", path = "out" },
{ access = "read-write", path = "deployment" },
{ access = "read-write", path = "deployments" },
]
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
10 changes: 10 additions & 0 deletions post-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Exporting deployment files & ABIs"

cp ./out/LLMOracleCoordinator.sol/LLMOracleCoordinator.json ./deployments/abis/LLMOracleCoordinator.json
node ./deployments/abis/parseAbi.cjs ./deployments/abis/LLMOracleCoordinator.json

cp ./out/LLMOracleRegistry.sol/LLMOracleRegistry.json ./deployments/abis/LLMOracleRegistry.json
node ./deployments/abis/parseAbi.cjs ./deployments/abis/LLMOracleRegistry.json

4 changes: 2 additions & 2 deletions script/Helper.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract Helper is Script {
/// @dev You are expect to use JSON-related commands with the returned string,
/// see https://book.getfoundry.sh/cheatcodes/external for more.
function getDeploymentsJson() external view returns (string memory) {
string memory dir = "deployment/";
string memory dir = "deployments/";
string memory fileName = Strings.toString(block.chainid);
string memory path = string.concat(dir, fileName, ".json");

Expand All @@ -22,7 +22,7 @@ contract Helper is Script {

function writeProxyAddresses(string memory name, address _proxy, address _impl) external {
// create a deployment file if not exist
string memory dir = "deployment/";
string memory dir = "deployments/";
string memory fileName = Strings.toString(block.chainid);
string memory path = string.concat(dir, fileName, ".json");

Expand Down

0 comments on commit 9e640f4

Please sign in to comment.