Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Token Pools Calldata Generator

A tool to generate calldata for TokenPool contract interactions, including token and pool deployment, and chain updates. Supports both raw calldata and Safe Transaction Builder JSON formats.
A tool to generate calldata for TokenPool contract interactions, including token and pool deployment, and chain updates. Supports both raw calldata and Safe Transaction Builder JSON formats with multi-destination-chain support.

## Features

- **Multi Destination Chain Support**: Supports EVM --> EVM and EVM --> SVM chains. Move VM is TODO.
- **Cross-Chain Token Pools**: Configure token pools across different blockchain architectures
- **Multiple Output Formats**: Raw calldata or Safe Transaction Builder JSON

## Prerequisites

Expand Down Expand Up @@ -160,12 +166,14 @@ Create a JSON file with the chain update parameters (e.g., `examples/chain-updat

```json
[
[], // Array of chain selectors to remove
[],
[
// Array of chain updates to add
{
"remoteChainSelector": "12532609583862916517",
"remotePoolAddresses": ["0x779877A7B0D9E8603169DdbD7836e478b4624789"],
"remotePoolAddresses": [
"0x779877A7B0D9E8603169DdbD7836e478b4624789",
"0x1234567890123456789012345678901234567890"
],
"remoteTokenAddress": "0xFd57b4ddBf88a4e07fF4e34C487b99af2Fe82a05",
"outboundRateLimiterConfig": {
"isEnabled": true,
Expand All @@ -176,12 +184,31 @@ Create a JSON file with the chain update parameters (e.g., `examples/chain-updat
"isEnabled": true,
"capacity": "1000000",
"rate": "100000"
}
},
"remoteChainType": "evm" // could be "svm" etc.
}
]
]
```

##### Chain Update Fields

Each chain update object requires:

- `remoteChainSelector`: Unique identifier for the remote chain.
- `remotePoolAddresses`: Array of pool addresses on the remote chain.
- `remoteTokenAddress`: Token address on the remote chain.
- `outboundRateLimiterConfig`: Rate limiter for outbound transfers.
- `inboundRateLimiterConfig`: Rate limiter for inbound transfers.
- `remoteChainType`: Chain type: `"evm"` or `"svm"`. As per one of the enum set out in `/src/types/chainUpdate.ts`.

##### Address Formats by Chain Type

- **EVM**: Standard Ethereum addresses (20 bytes, hex format).
- Example: `"0x779877A7B0D9E8603169DdbD7836e478b4624789"`
- **SVM**: Solana public keys (32 bytes, base58 format).
- Example: `"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"`

#### Generate Chain Update Transaction

```bash
Expand Down Expand Up @@ -302,10 +329,10 @@ pnpm typechain

## Error Handling

The tool validates input JSON against a schema and provides detailed error messages for:
The tool validates input JSON and provides detailed error messages for:

- Invalid JSON format
- Invalid Ethereum addresses
- Invalid EVM or SVM addresses (for EVM chains)
- Invalid rate limiter configurations
- Missing required fields
- Missing required parameters for Safe Transaction Builder JSON
Expand Down
3 changes: 2 additions & 1 deletion examples/chain-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"isEnabled": true,
"capacity": "1000000",
"rate": "100000"
}
},
"remoteChainType": "evm"
},
{
"remoteChainSelector": "3478487238524512106",
Expand Down
12 changes: 12 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>/src'],
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)+(spec|test).ts'],
transform: {
'^.+\\.ts$': 'ts-jest',
},
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts', '!src/test/**'],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'html'],
};
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,34 @@
"prepare": "husky",
"postinstall": "pnpm typechain",
"start": "ts-node src/cli.ts",
"check:deps": "pnpm outdated"
"check:deps": "pnpm outdated",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@typechain/ethers-v6": "^0.5.1",
"@types/jest": "^30.0.0",
"@types/node": "^22.13.5",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"jest": "^30.0.5",
"lint-staged": "^15.2.2",
"ts-jest": "^29.4.0",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.3.3"
},
"dependencies": {
"@safe-global/types-kit": "^1.0.4",
"@solana/web3.js": "^1.98.2",
"commander": "^13.1.0",
"ethers": "^6.11.1",
"prettier": "^3.5.2",
Expand Down
Loading
Loading