diff --git a/.changeset/export-solo-precompile-ethers.md b/.changeset/export-solo-precompile-ethers.md new file mode 100644 index 000000000..e972d76bd --- /dev/null +++ b/.changeset/export-solo-precompile-ethers.md @@ -0,0 +1,7 @@ +--- +'@sei-js/precompiles': minor +--- + +Export the Solo precompile from the `ethers` entrypoint. `ETHERS_SOLO_PRECOMPILE_ABI` and `getSoloPrecompileEthersV6Contract` were implemented but never re-exported from `src/ethers/index.ts`, so they were unreachable from the `@sei-js/precompiles` package root. + +The `@sei-js/precompiles/ethers` subpath shown in the doc examples remains unresolvable and is unchanged here — the package still publishes no `exports` map. That is tracked separately. diff --git a/packages/precompiles/src/__tests__/barrelParity.spec.ts b/packages/precompiles/src/__tests__/barrelParity.spec.ts new file mode 100644 index 000000000..3060fe5d3 --- /dev/null +++ b/packages/precompiles/src/__tests__/barrelParity.spec.ts @@ -0,0 +1,41 @@ +import * as ethersBarrel from '../ethers'; +import * as precompilesBarrel from '../precompiles'; +import * as viemBarrel from '../viem'; + +const precompileNamesFrom = (barrel: Record, prefix: '' | 'ETHERS_' | 'VIEM_'): string[] => { + const pattern = new RegExp(`^${prefix}([A-Z0-9]+)_PRECOMPILE_ABI$`); + + return Object.keys(barrel) + .map((key) => pattern.exec(key)?.[1]) + .filter((name): name is string => name !== undefined) + .sort(); +}; + +describe('Precompile barrel parity', () => { + const precompileNames = precompileNamesFrom(precompilesBarrel, ''); + const ethersNames = precompileNamesFrom(ethersBarrel, 'ETHERS_'); + const viemNames = precompileNamesFrom(viemBarrel, 'VIEM_'); + + // 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. + it('discovers precompiles in the base barrel', () => { + expect(precompileNames.length).toBeGreaterThan(0); + }); + + it('exposes the same precompiles from the ethers barrel as the base barrel', () => { + expect(ethersNames).toEqual(precompileNames); + }); + + it('exposes the same precompiles from the viem barrel as the base barrel', () => { + expect(viemNames).toEqual(precompileNames); + }); + + it('exposes an ethers contract factory for each precompile', () => { + const factories = Object.keys(ethersBarrel) + .map((key) => /^get([A-Za-z0-9]+)PrecompileEthersV6Contract$/.exec(key)?.[1]?.toUpperCase()) + .filter((name): name is string => name !== undefined) + .sort(); + + expect(factories).toEqual(precompileNames); + }); +}); diff --git a/packages/precompiles/src/ethers/__tests__/ethersPrecompiles.spec.ts b/packages/precompiles/src/ethers/__tests__/ethersPrecompiles.spec.ts index b0f55d49c..4fd7aaea0 100644 --- a/packages/precompiles/src/ethers/__tests__/ethersPrecompiles.spec.ts +++ b/packages/precompiles/src/ethers/__tests__/ethersPrecompiles.spec.ts @@ -10,6 +10,7 @@ import { ETHERS_ORACLE_PRECOMPILE_ABI, ETHERS_POINTERVIEW_PRECOMPILE_ABI, ETHERS_POINTER_PRECOMPILE_ABI, + ETHERS_SOLO_PRECOMPILE_ABI, ETHERS_STAKING_PRECOMPILE_ABI, ETHERS_WASM_PRECOMPILE_ABI, getAddressPrecompileEthersV6Contract, @@ -21,6 +22,7 @@ import { getOraclePrecompileEthersV6Contract, getPointerPrecompileEthersV6Contract, getPointerviewPrecompileEthersV6Contract, + getSoloPrecompileEthersV6Contract, getStakingPrecompileEthersV6Contract, getWasmPrecompileEthersV6Contract } from '../'; @@ -51,7 +53,6 @@ import { WASM_PRECOMPILE_ABI, WASM_PRECOMPILE_ADDRESS } from '../../precompiles'; -import { ETHERS_SOLO_PRECOMPILE_ABI, getSoloPrecompileEthersV6Contract } from '../soloPrecompile'; const FACTORIES: [string, string, InterfaceAbi, unknown, (runner: ContractRunner) => Contract][] = [ ['ADDRESS', ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI, ETHERS_ADDRESS_PRECOMPILE_ABI, getAddressPrecompileEthersV6Contract], diff --git a/packages/precompiles/src/ethers/index.ts b/packages/precompiles/src/ethers/index.ts index fea8ea58e..bda78cf27 100644 --- a/packages/precompiles/src/ethers/index.ts +++ b/packages/precompiles/src/ethers/index.ts @@ -7,5 +7,6 @@ export * from './jsonPrecompile'; export * from './oraclePrecompile'; export * from './pointerPrecompile'; export * from './pointerviewPrecompile'; +export * from './soloPrecompile'; export * from './stakingPrecompile'; export * from './wasmPrecompile'; diff --git a/packages/precompiles/src/ethers/soloPrecompile.ts b/packages/precompiles/src/ethers/soloPrecompile.ts index 2f1495db5..f074460b3 100644 --- a/packages/precompiles/src/ethers/soloPrecompile.ts +++ b/packages/precompiles/src/ethers/soloPrecompile.ts @@ -26,7 +26,7 @@ export const ETHERS_SOLO_PRECOMPILE_ABI = SOLO_PRECOMPILE_ABI as InterfaceAbi; * ``` * * @param runner A [Provider](https://docs.ethers.org/v6/api/providers/) (read-only) or ethers.Signer to use with the contract. - * @returns The typed contract instance for interacting with the Oracle precompile contract. + * @returns The typed contract instance for interacting with the Solo precompile contract. * @category Contract Factory */ export const getSoloPrecompileEthersV6Contract = (runner: ContractRunner) => {