Skip to content

Commit 5675fcf

Browse files
feat(precompiles): sync ABIs with Sei Chain v6.6.1 (#330)
* feat(precompiles): sync ABIs with Sei Chain v6.6.1 (PLT-996) Expose the full live precompile surface, including P256 and missing staking/query APIs, while pinning ABI parity to the frozen v6.6 snapshot. * docs(precompiles): clarify ABI release support Distinguish frozen chain snapshots from the current surface and link the live-chain reasons for excluding Oracle and IBC. * fix(precompiles): harden v6.6 ABI verification Compare against independently vendored chain fixtures and document P256 packing and failure semantics so consumers cannot mistake invalid signatures for success. * Remove viem ABI aliases and adjust exports Remove the viem-specific VIEM_* ABI aliases and related viem/*Precompile files; export raw as-const ABIs from the package root (and viem entrypoint) instead. Add `satisfies Abi` typing to raw ABI exports, update the public examples/templates to use BANK_PRECOMPILE_ABI, adjust tests and the export barrel (root now re-exports viem/chain), and update scripts and README. Breaking: VIEM_* ABI aliases were removed — import the raw *_PRECOMPILE_ABI constants (they work directly with Viem).
1 parent 39c277f commit 5675fcf

52 files changed

Lines changed: 1038 additions & 233 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.changeset/remove-ibc-oracle-precompiles.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
'@sei-js/precompiles': major
33
---
44

5-
**Breaking:** remove the IBC and Oracle precompiles. `IBC_PRECOMPILE_ADDRESS`, `IBC_PRECOMPILE_ABI`, `ETHERS_IBC_PRECOMPILE_ABI`, `getIbcPrecompileEthersV6Contract`, `VIEM_IBC_PRECOMPILE_ABI`, `ORACLE_PRECOMPILE_ADDRESS`, `ORACLE_PRECOMPILE_ABI`, `ETHERS_ORACLE_PRECOMPILE_ABI`, `getOraclePrecompileEthersV6Contract`, and `VIEM_ORACLE_PRECOMPILE_ABI` are no longer exported.
5+
**Breaking:** remove the unsupported IBC and Oracle precompile addresses, ABIs, and Ethers factories.
66

77
Neither precompile is supported on Sei any more, so calls to them fail on-chain regardless of where the address and ABI come from. There is no drop-in replacement: re-declaring them locally will not restore working calls, and code still depending on them needs to move off these precompiles.
8+
9+
Also remove the redundant Viem-specific ABI aliases. Import the raw `*_PRECOMPILE_ABI` constants instead; they work directly with Viem and preserve literal types for contract inference. The `viem` subpath re-exports these raw constants alongside the Sei chain definitions.

‎.changeset/sync-v66-precompiles.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@sei-js/precompiles': minor
3+
---
4+
5+
Sync the exported precompile ABIs with Sei Chain v6.6.1.
6+
7+
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.

‎biome.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"!**/bun.lock",
1616
"!packages/create-sei/templates",
1717
"!packages/create-sei/extensions",
18+
"!packages/precompiles/src/__tests__/fixtures/v66",
1819
"!packages/registry/chain-registry",
1920
"!packages/registry/community-assetlist"
2021
]

‎packages/create-sei/extensions/precompiles/src/components/default/index.tsx‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import { CodeHighlight } from '@mantine/code-highlight';
44
import { ActionIcon, Badge, Button, Card, Collapse, Container, Flex, Group, Paper, Stack, Text, ThemeIcon, Title } from '@mantine/core';
55
import { notifications } from '@mantine/notifications';
6-
import { BANK_PRECOMPILE_ADDRESS, VIEM_BANK_PRECOMPILE_ABI } from '@sei-js/precompiles';
6+
import { BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS } from '@sei-js/precompiles';
77
import { IconBulb, IconChevronDown, IconChevronUp, IconCopy, IconDatabase } from '@tabler/icons-react';
88
import { useState } from 'react';
9-
import type { ReadContractParameters } from 'viem';
109
import { usePublicClient } from 'wagmi';
1110

1211
function Examples() {
@@ -49,16 +48,14 @@ function Examples() {
4948
return undefined;
5049
}
5150

52-
const readContractParams: ReadContractParameters = {
53-
abi: VIEM_BANK_PRECOMPILE_ABI,
54-
address: BANK_PRECOMPILE_ADDRESS,
55-
functionName: 'supply',
56-
args: ['usei']
57-
};
58-
5951
try {
60-
const result = await publicClient.readContract(readContractParams);
61-
setSupply((result as bigint).toString());
52+
const result = await publicClient.readContract({
53+
abi: BANK_PRECOMPILE_ABI,
54+
address: BANK_PRECOMPILE_ADDRESS,
55+
functionName: 'supply',
56+
args: ['usei']
57+
});
58+
setSupply(result.toString());
6259
} catch (error) {
6360
console.error('Error fetching supply:', error);
6461
notifications.show({
@@ -70,21 +67,19 @@ function Examples() {
7067
};
7168

7269
const codeExample = `// Sei Precompile Example - Bank Precompile
73-
import { BANK_PRECOMPILE_ADDRESS, VIEM_BANK_PRECOMPILE_ABI } from '@sei-js/precompiles';
70+
import { BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS } from '@sei-js/precompiles';
7471
import { usePublicClient } from 'wagmi';
7572
7673
const publicClient = usePublicClient();
7774
7875
const getSeiSupply = async () => {
79-
const readContractParams = {
80-
abi: VIEM_BANK_PRECOMPILE_ABI,
76+
const result = await publicClient?.readContract({
77+
abi: BANK_PRECOMPILE_ABI,
8178
address: BANK_PRECOMPILE_ADDRESS,
8279
functionName: 'supply',
8380
args: ['usei'],
84-
};
85-
86-
const result = await publicClient?.readContract(readContractParams);
87-
return (result as bigint).toString();
81+
});
82+
return result?.toString();
8883
};`;
8984

9085
return (

‎packages/create-sei/templates/next-template/src/components/default/examples.ts‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,19 @@ const weiBalance = await publicClient.getBalance({ address });
2626
const seiBalance = formatEther(weiBalance);`;
2727

2828
export const precompileCodeExample = `// Import Sei precompiles
29-
import { VIEM_BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS } from '@sei-js/precompiles';
29+
import { BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS } from '@sei-js/precompiles';
3030
import { usePublicClient } from 'wagmi';
31-
import { type ReadContractParameters } from 'viem';
3231
3332
// Use the hook
3433
const publicClient = usePublicClient();
3534
3635
// Call precompile
37-
const readContractParams: ReadContractParameters = {
38-
abi: VIEM_BANK_PRECOMPILE_ABI,
36+
const result = await publicClient.readContract({
37+
abi: BANK_PRECOMPILE_ABI,
3938
address: BANK_PRECOMPILE_ADDRESS,
4039
functionName: 'supply',
4140
args: ['usei']
42-
};
43-
44-
const result = await publicClient.readContract(readContractParams);`;
41+
});`;
4542

4643
export const transactionCodeExample = `// Import transaction hooks
4744
import { useSendTransaction, useWaitForTransactionReceipt } from 'wagmi';

‎packages/precompiles/README.md‎

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,59 @@
77
[![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
88
[![Sei Network](https://img.shields.io/badge/Sei-Network-red)](https://sei.io)
99

10-
**TypeScript utilities for interacting with Sei's precompile contracts**
10+
TypeScript ABIs, addresses, and Ethers/Viem helpers for Sei precompiles.
1111

1212
[GitHub](https://github.com/sei-protocol/sei-js) • [NPM](https://www.npmjs.com/package/@sei-js/precompiles) • [Telegram](https://t.me/+LPW_1djQwRQwMzlk)
1313

1414
</div>
1515

16-
## 🚀 Quick Start
16+
## Install
1717

1818
```bash
1919
npm install @sei-js/precompiles
2020
```
2121

22-
Works seamlessly with your favorite Ethereum development tools:
23-
- **Viem** - Type-safe contract interactions
24-
- **Ethers.js** - Contract factories and utilities
25-
- **Wagmi** - React hooks for precompile contracts
26-
- **Hardhat/Foundry** - Testing and deployment
22+
## Sei Chain compatibility
23+
24+
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`.
25+
26+
This package exports:
27+
28+
- Bank at `0x0000000000000000000000000000000000001001`
29+
- CosmWasm at `0x0000000000000000000000000000000000001002`
30+
- JSON at `0x0000000000000000000000000000000000001003`
31+
- Address association at `0x0000000000000000000000000000000000001004`
32+
- Staking at `0x0000000000000000000000000000000000001005`
33+
- Governance at `0x0000000000000000000000000000000000001006`
34+
- Distribution at `0x0000000000000000000000000000000000001007`
35+
- Pointer view at `0x000000000000000000000000000000000000100A`
36+
- Pointer registration at `0x000000000000000000000000000000000000100B`
37+
- Solo migration at `0x000000000000000000000000000000000000100C`
38+
- P256 verification at `0x0000000000000000000000000000000000001011`
39+
40+
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.
41+
42+
## Usage
43+
44+
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.
45+
46+
```ts
47+
import { STAKING_PRECOMPILE_ABI, STAKING_PRECOMPILE_ADDRESS } from '@sei-js/precompiles';
48+
import { getStakingPrecompileEthersV6Contract } from '@sei-js/precompiles/ethers';
49+
```
50+
51+
With a configured Viem public client, the v6.6 staking query methods can be called directly:
52+
53+
```ts
54+
const result = await publicClient.readContract({
55+
address: STAKING_PRECOMPILE_ADDRESS,
56+
abi: STAKING_PRECOMPILE_ABI,
57+
functionName: 'validators',
58+
args: ['BOND_STATUS_BONDED', '0x']
59+
});
60+
61+
console.log(result.validators, result.nextKey);
62+
```
2763

2864
## Sei chain definitions
2965

‎packages/precompiles/src/__tests__/barrelParity.spec.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as ethersBarrel from '../ethers';
22
import * as precompilesBarrel from '../precompiles';
33
import * as viemBarrel from '../viem';
44

5-
const precompileNamesFrom = (barrel: Record<string, unknown>, prefix: '' | 'ETHERS_' | 'VIEM_'): string[] => {
5+
const precompileNamesFrom = (barrel: Record<string, unknown>, prefix: '' | 'ETHERS_'): string[] => {
66
const pattern = new RegExp(`^${prefix}([A-Z0-9]+)_PRECOMPILE_ABI$`);
77

88
return Object.keys(barrel)
@@ -14,7 +14,7 @@ const precompileNamesFrom = (barrel: Record<string, unknown>, prefix: '' | 'ETHE
1414
describe('Precompile barrel parity', () => {
1515
const precompileNames = precompileNamesFrom(precompilesBarrel, '');
1616
const ethersNames = precompileNamesFrom(ethersBarrel, 'ETHERS_');
17-
const viemNames = precompileNamesFrom(viemBarrel, 'VIEM_');
17+
const viemNames = precompileNamesFrom(viemBarrel, '');
1818

1919
// Without this the three comparisons below would pass on three empty sets if the
2020
// ABI naming convention ever changes out from under the pattern above.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Sei Chain v6.6 ABI fixtures
2+
3+
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`.
4+
5+
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`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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"}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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"}]

0 commit comments

Comments
 (0)