-
Notifications
You must be signed in to change notification settings - Fork 50
feat(precompiles): sync ABIs with Sei Chain v6.6.1 #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d34a7aa
035a4b6
2dc7985
27806ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@sei-js/precompiles': minor | ||
| --- | ||
|
|
||
| Sync the exported precompile ABIs with Sei Chain v6.6.1. | ||
|
|
||
| This adds the P256 precompile address, ABI, and Ethers factory. It also adds the missing staking queries and events, governance proposal methods, distribution events and validator commission withdrawal, JSON array extraction, and CW1155 pointer methods. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,23 +7,59 @@ | |
| [](https://www.typescriptlang.org/) | ||
| [](https://sei.io) | ||
|
|
||
| **TypeScript utilities for interacting with Sei's precompile contracts** | ||
| TypeScript ABIs, addresses, and Ethers/Viem helpers for Sei precompiles. | ||
|
|
||
| [GitHub](https://github.com/sei-protocol/sei-js) • [NPM](https://www.npmjs.com/package/@sei-js/precompiles) • [Telegram](https://t.me/+LPW_1djQwRQwMzlk) | ||
|
|
||
| </div> | ||
|
|
||
| ## 🚀 Quick Start | ||
| ## Install | ||
|
|
||
| ```bash | ||
| npm install @sei-js/precompiles | ||
| ``` | ||
|
|
||
| Works seamlessly with your favorite Ethereum development tools: | ||
| - **Viem** - Type-safe contract interactions | ||
| - **Ethers.js** - Contract factories and utilities | ||
| - **Wagmi** - React hooks for precompile contracts | ||
| - **Hardhat/Foundry** - Testing and deployment | ||
| ## Sei Chain compatibility | ||
|
|
||
| The exported ABIs match [Sei Chain v6.6.1](https://github.com/sei-protocol/sei-chain/tree/v6.6.1/precompiles). The `legacy/v66` directory is a frozen historical snapshot for that release, not a moving view of the current chain surface. Chain and package versions are independent; adopting a later Sei Chain minor snapshot is treated as at least a minor release of `@sei-js/precompiles`. | ||
|
|
||
| This package exports: | ||
|
|
||
| - Bank at `0x0000000000000000000000000000000000001001` | ||
| - CosmWasm at `0x0000000000000000000000000000000000001002` | ||
| - JSON at `0x0000000000000000000000000000000000001003` | ||
| - Address association at `0x0000000000000000000000000000000000001004` | ||
| - Staking at `0x0000000000000000000000000000000000001005` | ||
| - Governance at `0x0000000000000000000000000000000000001006` | ||
| - Distribution at `0x0000000000000000000000000000000000001007` | ||
| - Pointer view at `0x000000000000000000000000000000000000100A` | ||
| - Pointer registration at `0x000000000000000000000000000000000000100B` | ||
| - Solo migration at `0x000000000000000000000000000000000000100C` | ||
| - P256 verification at `0x0000000000000000000000000000000000001011` | ||
|
|
||
| Oracle and IBC are intentionally excluded: the [v6.6.1 Oracle implementation returns a retired error for every query](https://github.com/sei-protocol/sei-chain/blob/v6.6.1/precompiles/oracle/oracle.go#L85-L104), and [SIP-03 disabled IBC in both directions](https://docs.sei.io/learn/sip-03-migration#ibc-is-disabled). Calls to either cannot succeed on live Sei. Some ABI methods can also be disabled by chain governance. Check the [Sei precompile docs](https://docs.sei.io/evm/precompiles/example-usage) before using a deprecated module or method. | ||
|
|
||
| ## Usage | ||
|
|
||
| Addresses and raw `as const` ABIs are available from the package root and the `precompiles` and `viem` entrypoints. They work directly with Viem and preserve full type inference. Ethers factories are available from the `ethers` entrypoint. | ||
|
|
||
| ```ts | ||
| import { STAKING_PRECOMPILE_ABI, STAKING_PRECOMPILE_ADDRESS } from '@sei-js/precompiles'; | ||
| import { getStakingPrecompileEthersV6Contract } from '@sei-js/precompiles/ethers'; | ||
| ``` | ||
|
|
||
| With a configured Viem public client, the v6.6 staking query methods can be called directly: | ||
|
|
||
| ```ts | ||
| const result = await publicClient.readContract({ | ||
| address: STAKING_PRECOMPILE_ADDRESS, | ||
| abi: STAKING_PRECOMPILE_ABI, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] Minor inconsistency between the two snippets: the import block above advertises A short parenthetical ("use the |
||
| functionName: 'validators', | ||
| args: ['BOND_STATUS_BONDED', '0x'] | ||
| }); | ||
|
|
||
| console.log(result.validators, result.nextKey); | ||
| ``` | ||
|
|
||
| ## Sei chain definitions | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import * as ethersBarrel from '../ethers'; | |
| import * as precompilesBarrel from '../precompiles'; | ||
| import * as viemBarrel from '../viem'; | ||
|
|
||
| const precompileNamesFrom = (barrel: Record<string, unknown>, prefix: '' | 'ETHERS_' | 'VIEM_'): string[] => { | ||
| const precompileNamesFrom = (barrel: Record<string, unknown>, prefix: '' | 'ETHERS_'): string[] => { | ||
| const pattern = new RegExp(`^${prefix}([A-Z0-9]+)_PRECOMPILE_ABI$`); | ||
|
|
||
| return Object.keys(barrel) | ||
|
|
@@ -14,7 +14,7 @@ const precompileNamesFrom = (barrel: Record<string, unknown>, prefix: '' | 'ETHE | |
| describe('Precompile barrel parity', () => { | ||
| const precompileNames = precompileNamesFrom(precompilesBarrel, ''); | ||
| const ethersNames = precompileNamesFrom(ethersBarrel, 'ETHERS_'); | ||
| const viemNames = precompileNamesFrom(viemBarrel, 'VIEM_'); | ||
| const viemNames = precompileNamesFrom(viemBarrel, ''); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] This assertion is now tautological. Since That isn't wrong — the invariant is structurally guaranteed now rather than checked — but the comment on line 19 still describes this as a real guard. Either drop the viem case and note that the re-export makes it unnecessary, or move the check to something that can actually drift (e.g. assert |
||
|
|
||
| // Without this the three comparisons below would pass on three empty sets if the | ||
| // ABI naming convention ever changes out from under the pattern above. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Sei Chain v6.6 ABI fixtures | ||
|
|
||
| The JSON files in this directory are verbatim copies of `precompiles/*/legacy/v66/abi.json` from the [`v6.6.1`](https://github.com/sei-protocol/sei-chain/tree/v6.6.1/precompiles) tag of `sei-chain`. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion] Question rather than a defect — I couldn't reach the network to settle it, so flagging per the repo guideline on hand-maintained ABIs. The fixtures are sourced from If |
||
|
|
||
| The parity test compares the package's TypeScript ABI constants with these independently vendored fixtures. IBC and Oracle are retained here to document the complete frozen snapshot, but they are intentionally not exported by `@sei-js/precompiles`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"inputs":[{"internalType":"string","name":"v","type":"string"},{"internalType":"string","name":"r","type":"string"},{"internalType":"string","name":"s","type":"string"},{"internalType":"string","name":"customMessage","type":"string"}],"name":"associate","outputs":[{"internalType":"string","name":"seiAddr","type":"string"},{"internalType":"address","name":"evmAddr","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"pubKeyHex","type":"string"}],"name":"associatePubKey","outputs":[{"internalType":"string","name":"seiAddr","type":"string"},{"internalType":"address","name":"evmAddr","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getSeiAddr","outputs":[{"internalType":"string","name":"response","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"addr","type":"string"}],"name":"getEvmAddr","outputs":[{"internalType":"address","name":"response","type":"address"}],"stateMutability":"view","type":"function"}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"inputs":[{"internalType":"address","name":"acc","type":"address"}],"name":"all_balances","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"denom","type":"string"}],"internalType":"struct IBank.Coin[]","name":"response","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"acc","type":"address"},{"internalType":"string","name":"denom","type":"string"}],"name":"balance","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"denom","type":"string"}],"name":"decimals","outputs":[{"internalType":"uint8","name":"response","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"denom","type":"string"}],"name":"name","outputs":[{"internalType":"string","name":"response","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"fromAddress","type":"address"},{"internalType":"address","name":"toAddress","type":"address"},{"internalType":"string","name":"denom","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"send","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"toNativeAddress","type":"string"}],"name":"sendNative","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"denom","type":"string"}],"name":"supply","outputs":[{"internalType":"uint256","name":"response","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"denom","type":"string"}],"name":"symbol","outputs":[{"internalType":"string","name":"response","type":"string"}],"stateMutability":"view","type":"function"}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"string","name":"validator","type":"string"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DelegationRewardsWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"string[]","name":"validators","type":"string[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"MultipleDelegationRewardsWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"validator","type":"string"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ValidatorCommissionWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"address","name":"withdrawAddr","type":"address"}],"name":"WithdrawAddressSet","type":"event"},{"inputs":[{"internalType":"address","name":"delegatorAddress","type":"address"}],"name":"rewards","outputs":[{"components":[{"components":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"string","name":"denom","type":"string"}],"internalType":"struct IDistr.Coin[]","name":"coins","type":"tuple[]"},{"internalType":"string","name":"validator_address","type":"string"}],"internalType":"struct IDistr.Reward[]","name":"rewards","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"},{"internalType":"string","name":"denom","type":"string"}],"internalType":"struct IDistr.Coin[]","name":"total","type":"tuple[]"}],"internalType":"struct IDistr.Rewards","name":"rewards","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"withdrawAddr","type":"address"}],"name":"setWithdrawAddress","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"validator","type":"string"}],"name":"withdrawDelegationRewards","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"validators","type":"string[]"}],"name":"withdrawMultipleDelegationRewards","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawValidatorCommission","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"inputs":[{"internalType":"string","name":"proposalJSON","type":"string"}],"name":"submitProposal","outputs":[{"internalType":"uint64","name":"proposalID","type":"uint64"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint64","name":"proposalID","type":"uint64"}],"name":"deposit","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint64","name":"proposalID","type":"uint64"},{"internalType":"int32","name":"option","type":"int32"}],"name":"vote","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"proposalID","type":"uint64"},{"components":[{"internalType":"int32","name":"option","type":"int32"},{"internalType":"string","name":"weight","type":"string"}],"internalType":"struct WeightedVoteOption[]","name":"options","type":"tuple[]"}],"name":"voteWeighted","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"inputs":[{"internalType":"string","name":"toAddress","type":"string"},{"internalType":"string","name":"port","type":"string"},{"internalType":"string","name":"channel","type":"string"},{"internalType":"string","name":"denom","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint64","name":"revisionNumber","type":"uint64"},{"internalType":"uint64","name":"revisionHeight","type":"uint64"},{"internalType":"uint64","name":"timeoutTimestamp","type":"uint64"},{"internalType":"string","name":"memo","type":"string"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"toAddress","type":"string"},{"internalType":"string","name":"port","type":"string"},{"internalType":"string","name":"channel","type":"string"},{"internalType":"string","name":"denom","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"memo","type":"string"}],"name":"transferWithDefaultTimeout","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"string","name":"key","type":"string"}],"name":"extractAsBytes","outputs":[{"internalType":"bytes","name":"response","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"string","name":"key","type":"string"}],"name":"extractAsBytesList","outputs":[{"internalType":"bytes[]","name":"response","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"string","name":"key","type":"string"}],"name":"extractAsUint256","outputs":[{"internalType":"uint256","name":"response","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"input","type":"bytes"},{"internalType":"uint16","name":"arrayIndex","type":"uint16"}],"name":"extractAsBytesFromArray","outputs":[{"internalType":"bytes","name":"response","type":"bytes"}],"stateMutability":"view","type":"function"}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] Rewriting this line dropped the explicit list of removed export names. The previous text named every symbol (
IBC_PRECOMPILE_ADDRESS,ETHERS_IBC_PRECOMPILE_ABI,VIEM_ORACLE_PRECOMPILE_ABI, …), which is exactly what a consumer greps for when their build breaks after a major bump.The new prose ("addresses, ABIs, and Ethers factories") plus the Viem paragraph describes the shape of the change but leaves the reader to reconstruct the ten
VIEM_*_PRECOMPILE_ABInames and the IBC/Oracle symbols themselves. Since this is the release note for a breaking change, suggest keeping the summary sentence and restoring the enumeration below it.