-
Notifications
You must be signed in to change notification settings - Fork 195
feat: pnpm migration, contracts precompiles build & npm publish #1021
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
Open
nowooj
wants to merge
15
commits into
cosmos:main
Choose a base branch
from
nowooj:feat/contracts-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0f99252
refactor: update access control and token transfer methods in ERC20 c…
nowooj a8f3701
chore: make contracts-all
nowooj c9bf955
fix: for use same abi format
nowooj 68d810c
chore: make contracts-all
nowooj addfd7e
refactor: use pnpm
nowooj 2e19452
feat: add build script for precompiles and update package structure
nowooj f7e2dbb
chore: remove unused package-lock.json
nowooj 9f28548
feat: generate TypeScript ABI files for improved type inference
nowooj 7011dbb
fix: solidity path
nowooj 39c8260
fix: ci setup order
nowooj 45652fd
fix: update build script for precompiles to use hardhat compile
nowooj 2f193be
chore: update build process to include clean step for wagmi staging a…
nowooj 6cdc60f
refactor: re-arrange .sol file
nowooj f2719c5
fix: fixed ERC20 contract reference in tests
nowooj d8d837e
chore: refine README for ESM/CJS module exports
nowooj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ yarn.lock | |
|
|
||
| # Node.js | ||
| **/node_modules | ||
| .pnpm-store | ||
|
|
||
| # OpenZeppelin contracts | ||
| contracts/@openzeppelin/* | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # cosmos-evm-contracts | ||
|
|
||
| A collection of smart contracts for the Cosmos EVM blockchain. | ||
| The published package includes precompile interface sources (`.sol`) and ABIs as typed ESM/CJS modules. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```bash | ||
| # pnpm | ||
| pnpm add cosmos-evm-contracts | ||
|
|
||
| # npm | ||
| npm install cosmos-evm-contracts | ||
|
|
||
| # yarn | ||
| yarn add cosmos-evm-contracts | ||
| ``` | ||
|
|
||
| ## Package structure | ||
|
|
||
| After installation, use the following paths: | ||
|
|
||
| | Path | Description | | ||
| |------|-------------| | ||
| | `cosmos-evm-contracts/precompiles/{module}/{Interface}.sol` | Solidity sources (`.sol`) | | ||
| | `cosmos-evm-contracts/precompiles/{module}/{Interface}` | ABI as typed ESM/CJS modules | | ||
|
|
||
| Included precompiles: `bank`, `bech32`, `callbacks`, `common`, `distribution`, `erc20`, `gov`, `ics02`, `ics20`, `slashing`, `staking`, `werc20` (testdata and testutil excluded). | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Loading ABI with TypeScript / viem (typed) | ||
|
|
||
| Import the named ABI constant so that `functionName`, `args`, and return types are inferred: | ||
|
|
||
| ```typescript | ||
| import { createPublicClient, http } from "viem"; | ||
| import { iBankAbi } from "cosmos-evm-contracts/precompiles/bank/IBank"; | ||
|
|
||
| const client = createPublicClient({ transport: http() }); | ||
|
|
||
| // functionName and args are type-checked and autocompleted | ||
| const balances = await client.readContract({ | ||
| address: "0x0000000000000000000000000000000000000804", | ||
| abi: iBankAbi, | ||
| functionName: "balances", | ||
| args: ["0x..."], | ||
| }); | ||
| ``` | ||
|
|
||
| Use the same pattern for other precompiles, e.g. `distributionIAbi` from `precompiles/distribution/DistributionI`, `stakingIAbi` from `precompiles/staking/StakingI`, etc. | ||
|
|
||
| ### Using interfaces in Hardhat | ||
|
|
||
| Import by package path in your contract: | ||
|
|
||
| ```solidity | ||
| import "cosmos-evm-contracts/precompiles/bank/IBank.sol"; | ||
| ``` | ||
|
|
||
| ### Using interfaces in Foundry | ||
|
|
||
| Add the following to `remappings.txt` for shorter import paths: | ||
|
|
||
| ``` | ||
| cosmos-evm-contracts/=node_modules/cosmos-evm-contracts/precompiles/ | ||
| ``` | ||
|
|
||
| ```solidity | ||
| import "cosmos-evm-contracts/bank/IBank.sol"; | ||
| ``` | ||
|
|
||
| ### Path reference | ||
|
|
||
| - Interface ABI: `cosmos-evm-contracts/precompiles/{module}/{Interface}` (typed ESM/CJS module) | ||
| e.g. `precompiles/staking/StakingI` | ||
| - Common types: `cosmos-evm-contracts/precompiles/common/Types.sol` (structs only, no ABI) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
actions/setup-node@v4withcache: 'pnpm'requires pnpm to already be installed so it can locate the cache store path. With the current order, pnpm is not available yet whensetup-noderuns, so the pnpm cache is silently skipped on every CI run. The same ordering bug exists in all three compatibility workflows (tests-compatibility-hardhat.yml,tests-compatibility-viem.yml,tests-compatibility-web3js.yml).Swap the steps: run
pnpm/action-setup@v4first, thenactions/setup-node@v4.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.
5553613