@infinex/infinex-sdk
Advanced tools
Comparing version 1.1.3 to 1.1.4
{ | ||
"name": "@infinex/infinex-sdk", | ||
"version": "1.1.3", | ||
"private": false, | ||
"main": "./sdk/index.ts", | ||
"files": [ | ||
"./sdk/contracts", | ||
"./sdk/abis", | ||
"./sdk/utils", | ||
"./sdk/chains", | ||
"./sdk/build.ts", | ||
"./sdk/config.ts", | ||
"./sdk/env.ts", | ||
"./sdk/types.ts", | ||
"./sdk/schema.ts" | ||
], | ||
"dependencies": { | ||
"abitype": "^1.0.2", | ||
"viem": "^2.12.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@nomicfoundation/hardhat-foundry": "1.1.1", | ||
"@pythnetwork/entropy-sdk-solidity": "^1.3.0", | ||
"@solana/spl-token": "^0.4.6", | ||
"@solana/web3.js": "^1.90.0", | ||
"@synthetixio/core-contracts": "^3.3.6", | ||
"@synthetixio/perps-market": "^3.3.6", | ||
"@types/node": "^20.12.12", | ||
"@typescript-eslint/eslint-plugin": "^6.14.0", | ||
"@usecannon/cli": "2.15.1", | ||
"@wormhole-foundation/wormhole-query-sdk": "0.0.6", | ||
"axios": "1.6.0", | ||
"commander": "^12.1.0", | ||
"dotenv": "10.0.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-json": "^3.1.0", | ||
"eslint-plugin-markdown": "^3.0.1", | ||
"hardhat": "2.22.2", | ||
"hardhat-cannon": "2.14.2", | ||
"hardhat-contract-sizer": "^2.10.0", | ||
"node-fetch": "3.3.2", | ||
"prettier": "^3.2.5", | ||
"solhint": "^4.5.4", | ||
"ts-node": "^10.9.2", | ||
"tsx": "^4.15.2", | ||
"typedoc": "^0.25.13", | ||
"vite": "^5.2.11", | ||
"vitest": "^1.6.0", | ||
"wormhole-solidity-sdk": "github:wormhole-foundation/wormhole-solidity-sdk" | ||
"@tsconfig/recommended": "^1.0.6", | ||
"typescript": "^5.5.2" | ||
}, | ||
"main": "index.ts", | ||
"name": "@infinex/infinex-sdk", | ||
"version": "1.1.4", | ||
"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", | ||
"cannon:verify": "cannon verify infinex:0.0.1@main -c CHAIN -a ETHERSCAN_KEY", | ||
"clean": "rm -rf dist cache artifacts typechain deployments/test && pnpm cannon clean", | ||
"codecheck": "pnpm format && pnpm lint && pnpm slither && pnpm gitleaks", | ||
"debug": "cannon test cannonfile.toml --wipe -- --force -vvvv --no-match-contract OLD_* --match-test ", | ||
"dev": "forge build && pnpm cannon build --keep-alive --port 13370", | ||
"fetch:addresses": "pnpm tsx ./sdk/scripts/getPublishedContracts.ts", | ||
"forge:build": "forge build", | ||
"forge:clean": " forge clean", | ||
"format": "pnpm format:common && pnpm format:sol", | ||
"format:check": "prettier . --check && ./scripts/run forge fmt --check", | ||
"format:common": "prettier . --write", | ||
"format:sol": "forge fmt", | ||
"gitleaks": "./scripts/run gitleaks detect --no-git --config ./.gitleaks.toml --verbose", | ||
"lint": "pnpm lint:eslint && pnpm lint:sol", | ||
"lint:eslint": "eslint --no-error-on-unmatched-pattern --max-warnings=0 .", | ||
"lint:sol": "solhint --max-warnings=0 'src/**/*.sol' 'test/**/*.sol' 'script/**/*.sol'", | ||
"postinstall": "# forge install", | ||
"preinstall": "# ./scripts/pnpm-checks.sh", | ||
"slither": "./scripts/run slither .", | ||
"start": "CANNON_PROVIDER_URL=RPC_URL ./scripts/run cannon infinex:0.1.0@main -c CHAIN", | ||
"start:non-interactive": "cannon infinex:1 --non-interactive --host 0.0.0.0", | ||
"test": "cannon test cannonfile.toml --wipe -- --force --no-match-contract OLD_*", | ||
"test:cannon-fast": "cannon test cannonfile.toml --", | ||
"test:forge": "forge test --no-match-contract OLD_*", | ||
"test:hardhat": "hardhat test", | ||
"test:hardhat-debug": "DEBUG=cannon:cli:rpc pnpm test:hardhat", | ||
"test:healthcheck": "vitest run --config ./vitest.config.ts healthcheck", | ||
"test:sdk": "vitest run --config ./vitest.config.ts", | ||
"test:upgrade": "cannon test cannonfile.upgrade.toml --wipe -- --force", | ||
"tet": "cannon test cannonfile.toml --wipe -- --force --no-match-contract OLD_*" | ||
"build": "tsx build", | ||
"check:types": "tsc --noEmit" | ||
} | ||
} |
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` types and to `/schema` 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 */` | ||
```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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 2 instances in 1 package
2
55
11417
96
0
240074
3
1
+ Addedabitype@^1.0.2
+ Addedviem@^2.12.0
+ Addedzod@^3.23.8
+ Added@adraffy/ens-normalize@1.11.0(transitive)
+ Added@noble/curves@1.8.1(transitive)
+ Added@noble/hashes@1.7.1(transitive)
+ Added@scure/base@1.2.4(transitive)
+ Added@scure/bip32@1.6.2(transitive)
+ Added@scure/bip39@1.5.4(transitive)
+ Addedabitype@1.0.8(transitive)
+ Addedeventemitter3@5.0.1(transitive)
+ Addedisows@1.0.6(transitive)
+ Addedox@0.6.7(transitive)
+ Addedviem@2.23.4(transitive)
+ Addedws@8.18.0(transitive)
+ Addedzod@3.24.2(transitive)