@infinex/infinex-sdk
Advanced tools
Comparing version 1.0.0-viem to 1.0.1-viem
{ | ||
"name": "@infinex/infinex-sdk", | ||
"version": "1.0.0-viem", | ||
"version": "1.0.1-viem", | ||
"main": "./sdk/index.ts", | ||
@@ -5,0 +5,0 @@ "files": [ |
108
README.md
@@ -1,77 +0,95 @@ | ||
# Infinex Contracts | ||
# Infinex SDK | ||
This repo contains the smart contracts used for Infinex. They are deployed and managed with [Cannon](https://usecannon.com). | ||
The Infinex SDK provides a comprehensive toolkit for interacting with the Infinex multichain ecosystem. It supports a wide range of blockchain networks and allows for seamless integration with Infinex contracts. This README provides an overview of the SDK's capabilities, installation instructions, usage examples, and configuration options. | ||
## Installation | ||
### Toolchain Image | ||
To install dependencies | ||
The contracts toolchain is containerised. For now, you'll have to build the image yourself. (It takes at least a few minutes.) | ||
`pnpm i` | ||
``` | ||
podman build --tag localhost/evm-contracts-toolchain:latest . | ||
``` | ||
To fetch the latest address from cannon | ||
Then tools can be run directly using the `scripts/run` script, which runs a Docker/Podman container on the current directory. E.g., | ||
`pnpm run fetch:addresses` | ||
``` | ||
./scripts/run gitleaks detect -v | ||
``` | ||
To process abis from `/out` | ||
### Gitleaks | ||
`pnpm run sdk:build` | ||
Gitleaks is installed in the container image, but you can optionally install it locally from MacPorts: | ||
## Overview | ||
``` | ||
sudo port install gitleaks | ||
``` | ||
### `.env.*` | ||
### VScode plugins | ||
- For now we have mapped enviroments to our deployed enviroments. Which are: | ||
- dev | ||
- test | ||
- staging | ||
- prod | ||
- Each enviroment will hold the addresses for the deployed contracts. | ||
TODO: document | ||
#### `/chains` | ||
### Repository setup | ||
- A list of chains that are configured with a set of enviroment variables. These will eventually be in side the deployments repo and injected in. At the moment you will need to have all the .env vars `pnpm run fetch:address` will give you all the evm address needed to start. | ||
``` | ||
./scripts/run pnpm install | ||
``` | ||
- Chains are configured with most of the default contracts and account you will need per chain. Theres no ambguity about which address are needed and which are not. | ||
Be aware that this command will remove any custom remapping setup from the file and could lead to issues when compiling | ||
- As the contracts are worked on the sdk will add the necessary address to keep up to date with the interfaces and contracts | ||
run the `build` script from [](/packages/contracts/package.json) to generate the ABIs etc first | ||
#### `/contracts` | ||
then run `build` from [](/package.json) | ||
- The contracts folder are a list of preconfigured viem contracts [https://viem.sh/docs/contract/getContract](https://viem.sh/docs/contract/getContract) | ||
If you encounter a cannon error such as `Error: could not download cannon package data...` follow the instructions from [cannon](https://usecannon.com/learn/guides/get-started), specifically the ipfs issues fix, by running an ipfs node locally. | ||
- These contracts can take in the chain configuration, and also are overridable. | ||
## Cannon File Usage | ||
#### `/utils` | ||
- Use a publishable cannonfile (e.g. `cannonfile.02.toml`) for the proper deployment configuration, for any additional testing configuration use cannonfile.toml. | ||
- Utility functions to help testing and running functions against the contracts. | ||
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. | ||
- `initEvmChains()` | ||
- `selectChains(['arbitrum'])` | ||
- `createForwardRequest({ from, to, data, signer })` | ||
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. | ||
#### Adding contracts | ||
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 | ||
To add new contracts, follow these steps: | ||
## SDK | ||
1. Add the contract to the `.env.*.template` if theres multiple contracts please update each enviroment. | ||
1. Prefix the ADDRESS with the chain its on ie: `base` = `BASE` | ||
2. Add the contract in the contracts folder. Copy an exsisting contract in that folder. | ||
3. Add that contract name prefixed with the chain to the `/env.ts` types and to `/schema.ts` to catch missing contract addresses. | ||
4. Add the `/out` contract name for example `AccountFactory` to the the config contract list. | ||
5. Run the `pnpm run build:sdk` build to copy and format the abi | ||
Readme [here](./sdk/README.md) | ||
#### Building the addresses | ||
## Adding scripts | ||
Under the hood we currently use cannon to do deployments and we depoly, `local` / `testnet` / `mainnet` / `forked-mainnet` each env will have different addresses therefore we need to build and fetch the addresses for any enviroment. | ||
Adding scripts to `package.json` need to be placed in alphabetical order. | ||
The addresses are stored in a cache _if not published to usecannon.com_. In order to fetch the addresses, we want we should update the src code as followed: | ||
For example: | ||
`./scripts/getPublishedContracts.ts */` | ||
```bash | ||
pnpm run fetch:addresses --package-scope="infinex-multichain" --package-version="latest" --include-chains="arbitrum, ethereum, base" | ||
``` | ||
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", | ||
} | ||
Fetching all chains | ||
```bash | ||
pnpm run fetch:addresses --package-scope="infinex-multichain" --package-version="latest" | ||
``` | ||
All the addrsses will be here | ||
`./deployments/addresse.txt` | ||
```toml | ||
# Scope: infinex-multichain | ||
## Version: latest | ||
### Chain: arbitrum-sepolia | ||
ARBITRUM_FORWARDER_ADDRESS='0x5c593fdE5a2C8d9C6A2C7785490dd879E01e1a74' | ||
ARBITRUM_ACCOUNT_FACTORY_ADDRESS='0x628cF9F21731E56E63768Ce993cBAF70A7C52cA4' | ||
ARBITRUM_INFINEX_PROTOCOL_CONFIG_BEACON_ADDRESS='0x2b8587b08bB3DB1fA969792A255b2dC6385266A9' | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
157035
96
0