Skip to content

Commit bcf6953

Browse files
committed
refactor: enhance TypeScript configuration for precompiles
1 parent 304d073 commit bcf6953

File tree

8 files changed

+657
-108
lines changed

8 files changed

+657
-108
lines changed

contracts/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cosmos-evm-contracts
22

33
A collection of smart contracts for the Cosmos EVM blockchain.
4-
The published package includes precompile interface sources (`.sol`) and ABIs (`.json`).
4+
The published package includes precompile interface sources (`.sol`) and ABIs as typed TypeScript (`.ts`).
55

66
## Installation
77

@@ -23,21 +23,12 @@ After installation, use the following paths:
2323
| Path | Description |
2424
|------|-------------|
2525
| `cosmos-evm-contracts/precompiles/` | Solidity sources (`.sol`) |
26-
| `cosmos-evm-contracts/abi/precompiles/` | ABI as JSON (`.json`) or typed ESM (`.js` + `.d.ts`) |
26+
| `cosmos-evm-contracts/abi/precompiles/` | ABI as typed ESM (`.ts`) |
2727

2828
Included precompiles: `bank`, `bech32`, `callbacks`, `common`, `distribution`, `erc20`, `gov`, `ics02`, `ics20`, `slashing`, `staking`, `werc20` (testdata and testutil excluded).
2929

3030
## Usage
3131

32-
### Loading ABI (ethers / viem / web3, etc.)
33-
34-
```javascript
35-
import IBankAbi from "cosmos-evm-contracts/abi/precompiles/bank/IBank.json" assert { type: "json" };
36-
37-
// or Node
38-
const IBankAbi = require("cosmos-evm-contracts/abi/precompiles/bank/IBank.json");
39-
```
40-
4132
### Loading ABI with TypeScript / viem (typed)
4233

4334
Import the named ABI constant so that `functionName`, `args`, and return types are inferred:
@@ -81,6 +72,6 @@ import "cosmos-evm-contracts/bank/IBank.sol";
8172

8273
### Path reference
8374

84-
- Interface ABI: `cosmos-evm-contracts/abi/precompiles/{module}/{Interface}.json`
85-
e.g. `abi/precompiles/staking/StakingI.json`
75+
- Interface ABI: `cosmos-evm-contracts/abi/precompiles/{module}/{Interface}` (`.ts`)
76+
e.g. `abi/precompiles/staking/StakingI`
8677
- Common types: `cosmos-evm-contracts/precompiles/common/Types.sol` (structs only, no ABI)

contracts/package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "cosmos-evm-contracts",
33
"packageManager": "pnpm@9.15.0",
4-
"version": "0.0.8",
4+
"version": "0.0.9",
55
"description": "A collection of smart contracts used in the development of the Cosmos EVM blockchain.",
66
"devDependencies": {
77
"@openzeppelin/contracts": "^5.4.0",
8+
"@types/node": "^22.0.0",
9+
"@wagmi/cli": "^2.2.0",
810
"hardhat": "^3.1.10",
911
"typescript": "^5.0.0"
1012
},
1113
"scripts": {
12-
"build:precompiles": "node scripts/build-precompiles.js && pnpm exec tsc -p tsconfig.json",
13-
"compile": "hardhat compile",
14+
"build:precompiles": "node scripts/build-precompiles.js && wagmi generate",
1415
"prepublishOnly": "pnpm run build:precompiles"
1516
},
1617
"files": [
@@ -19,11 +20,7 @@
1920
],
2021
"exports": {
2122
"./*.sol": "./dist/*.sol",
22-
"./*": {
23-
"types": "./dist/*.d.ts",
24-
"import": "./dist/*.js",
25-
"default": "./dist/*.js"
26-
}
23+
"./*": "./dist/*.ts"
2724
},
2825
"repository": {
2926
"type": "git",

0 commit comments

Comments
 (0)