Infinex Contracts
This repo contains the smart contracts used for Infinex. They are deployed and managed with Cannon.
Installation
Toolchain Image
The contracts toolchain is containerised. For now, you'll have to build the image yourself. (It takes at least a few minutes.)
podman build --tag localhost/evm-contracts-toolchain:latest .
Then tools can be run directly using the scripts/run
script, which runs a Docker/Podman container on the current directory. E.g.,
./scripts/run gitleaks detect -v
Gitleaks
Gitleaks is installed in the container image, but you can optionally install it locally from MacPorts:
sudo port install gitleaks
VScode plugins
TODO: document
Repository setup
./scripts/run pnpm install
Be aware that this command will remove any custom remapping setup from the file and could lead to issues when compiling
run the build
script from to generate the ABIs etc first
then run build
from
If you encounter a cannon error such as Error: could not download cannon package data...
follow the instructions from cannon, specifically the ipfs issues fix, by running an ipfs node locally.
Cannon File Usage
- Use a publishable cannonfile (e.g.
cannonfile.02.toml
) for the proper deployment configuration, for any additional testing configuration use cannonfile.toml.
If you are creating something new, and need to merge it to main, but it is not ready for testnet deployment, the contract can be deployed locally for testing using the cannonfile.toml
file.
Once you are ready to deploy, the contracts deployments should be added to a cannonfile as a publishable package, such as cannonfile.O2.toml
. Only the contract deployments go in this file, and a section in cannonfile.toml
is used to initialize and set any parameters via function calls. This section will be copied to the cannonfile in infinex-deployments, which is used by the council to deploy and initialize the contracts for production.
The publishable package cannonfile can be included in the test file ( cannonfile.toml
) with an include statement, and any setting and or contract name that is still in the test file, will override a contract or setting in the publishable package file. e.g. O2 has [setting.OWNER]
, which is overridden by [setting.OWNER]
in the test file
SDK
Readme here
Adding scripts
Adding scripts to package.json
need to be placed in alphabetical order.
For example:
scripts: {
"build": "forge build && pnpm build:cannon",
"build:cannon": "cannon build",
"build:cannon-N2O": "cannon build cannonfile.N2O.toml",
"build:cannon-O2": "cannon build cannonfile.O2.toml",
"build:hardhat": "hardhat cannon:build",
"build:sdk": "pnpm tsx ./sdk/build.ts",
"cannon:inspect": "cannon inspect infinex:1 -w ./deployments/local --sources",
}