Update precompiles#57
Conversation
…istribution contracts - Implemented `bank.ts` with hooks for reading balances, supply, and total supply from the Bank precompile. - Created `bech32.ts` for Bech32 precompile configuration. - Added `distribution.ts` for Distribution precompile configuration. - Updated `wagmi.config.ts` to include ABI and address for multiple precompiles including Bank, Bech32, Distribution, Governance, IBC, ICS20, Slashing, Staking, and Wasm.
…ile hooks - Implemented hooks for governance precompile including read, write, simulate, and watch functionalities. - Added ibc precompile hooks for transfer operations. - Introduced ics20 precompile hooks for denom and denomHash functionalities. - Created slashing precompile hooks for reading signing info and unjailing validators. - Developed staking precompile hooks for delegation, redelegation, and validator management. - Added wasm precompile hooks for querying and executing smart contracts. - Updated index file to export all new hooks for easier access.
WalkthroughThis PR adds nine new ABI artifact JSON files for precompiles (bank, bech32, distribution, governance, ibc, ics20, slashing, staking, wasmd), updates many TypeScript precompile modules to tighten address constant types and expand/restructure ABI metadata, and removes the Evidence precompile exports. It introduces a Wagmi CLI config and numerous Wagmi hook modules (read/write/simulate/watch) wired to the new ABIs, bumps the evm package version and dependencies (wagmi, @wagmi/cli), and adjusts build scripts in several packages to use && chaining. Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧬 Code graph analysis (1)packages/evm/src/wagmi/bech32.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR updates precompile contracts by refreshing ABIs and addresses, adds Wagmi integration for React hooks, and fixes build script issues. The changes enable developers to interact with blockchain precompiles through type-safe React hooks while ensuring builds execute correctly across platforms.
- Updated precompile ABIs and addresses to latest contract definitions
- Added Wagmi configuration and generated React hooks for all precompiles
- Fixed build scripts to use cross-platform command chaining (
&&instead of;)
Reviewed Changes
Copilot reviewed 40 out of 42 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rwa/package.json | Fixed build script command chaining for cross-platform compatibility |
| packages/proto/package.json | Fixed build script command chaining for cross-platform compatibility |
| packages/lcd/package.json | Fixed build script command chaining for cross-platform compatibility |
| packages/evm/wagmi.config.ts | Added Wagmi CLI configuration for generating precompile hooks |
| packages/evm/src/wagmi/*.ts | Added generated React hooks for interacting with precompile contracts |
| packages/evm/src/precompiles/*.ts | Updated precompile ABIs with new event definitions and type improvements |
| packages/evm/src/viem/index.ts | Removed evidence precompile export |
| packages/evm/src/ethers/index.ts | Removed evidence precompile export |
| packages/evm/src/index.ts | Added wagmi exports |
| packages/evm/package.json | Added Wagmi dependencies and generate script |
| packages/evm/abis/precompiles/*.json | Added/updated ABI JSON files for precompile contracts |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 10
🧹 Nitpick comments (6)
packages/evm/src/wagmi/bech32.ts (2)
10-13: Nice: central precompile config.Good pattern. Consider exporting similar CONFIG objects for other precompile wagmi modules for uniformity.
18-41: Prefer simulate for conversions; consider dropping write wrappers.bech32ToHex/hexToBech32 are nonpayable and stateless; simulate returns the value, while write only yields a tx hash. Keeping write hooks can mislead consumers. Either remove them or add JSDoc: “Prefer simulate over write.”
packages/evm/src/wagmi/ibc.ts (1)
11-14: Optional: export a CONFIG constant like Bech32.Add IBC_PRECOMPILE_CONFIG = { address, abi } for parity and future codegen.
packages/evm/src/wagmi/wasm.ts (1)
12-15: Optional: add a CONFIG constant for consistency.Export WASM_PRECOMPILE_CONFIG = { address, abi } similar to Bech32.
packages/evm/src/wagmi/slashing.ts (1)
15-18: Optional: export SLASHING_PRECOMPILE_CONFIG for parity.Mirror Bech32’s CONFIG pattern.
packages/evm/src/wagmi/ics20.ts (1)
16-105: DRY the hooks by spreading ICS20_PRECOMPILE_CONFIG.
Avoid repeating abi/address in every hook to reduce drift and ease future updates.Apply pattern:
-export const useReadIcs20Precompile = /*#__PURE__*/ createUseReadContract({ - abi: ICS20_PRECOMPILE_ABI, - address: ICS20_PRECOMPILE_ADDRESS, -}); +export const useReadIcs20Precompile = /*#__PURE__*/ createUseReadContract( + ICS20_PRECOMPILE_CONFIG +); -export const useReadIcs20PrecompileDenom = /*#__PURE__*/ createUseReadContract({ - abi: ICS20_PRECOMPILE_ABI, - address: ICS20_PRECOMPILE_ADDRESS, - functionName: 'denom', -}); +export const useReadIcs20PrecompileDenom = /*#__PURE__*/ createUseReadContract({ + ...ICS20_PRECOMPILE_CONFIG, + functionName: 'denom', +}); # Repeat for denomHash/denoms, write/simulate/transfer, and watch/IbcTransfer: - { abi: ICS20_PRECOMPILE_ABI, address: ICS20_PRECOMPILE_ADDRESS, ... } + { ...ICS20_PRECOMPILE_CONFIG, ... }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
.yarn/install-state.gzis excluded by!**/.yarn/**,!**/*.gzyarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (40)
packages/evm/abis/precompiles/bank.json(1 hunks)packages/evm/abis/precompiles/bech32.json(1 hunks)packages/evm/abis/precompiles/distribution.json(1 hunks)packages/evm/abis/precompiles/governance.json(1 hunks)packages/evm/abis/precompiles/ibc.json(1 hunks)packages/evm/abis/precompiles/ics20.json(1 hunks)packages/evm/abis/precompiles/slashing.json(1 hunks)packages/evm/abis/precompiles/staking.json(1 hunks)packages/evm/abis/precompiles/wasmd.json(1 hunks)packages/evm/package.json(2 hunks)packages/evm/src/ethers/evidencePrecompile.ts(0 hunks)packages/evm/src/ethers/index.ts(0 hunks)packages/evm/src/index.ts(1 hunks)packages/evm/src/precompiles/bank.ts(1 hunks)packages/evm/src/precompiles/bech32.ts(1 hunks)packages/evm/src/precompiles/distribution.ts(1 hunks)packages/evm/src/precompiles/evidence.ts(0 hunks)packages/evm/src/precompiles/governance.ts(1 hunks)packages/evm/src/precompiles/ibc.ts(1 hunks)packages/evm/src/precompiles/ics20.ts(1 hunks)packages/evm/src/precompiles/index.ts(0 hunks)packages/evm/src/precompiles/slashing.ts(1 hunks)packages/evm/src/precompiles/staking.ts(1 hunks)packages/evm/src/precompiles/wasm.ts(1 hunks)packages/evm/src/viem/evidencePrecompile.ts(0 hunks)packages/evm/src/viem/index.ts(0 hunks)packages/evm/src/wagmi/bank.ts(1 hunks)packages/evm/src/wagmi/bech32.ts(1 hunks)packages/evm/src/wagmi/distribution.ts(1 hunks)packages/evm/src/wagmi/governance.ts(1 hunks)packages/evm/src/wagmi/ibc.ts(1 hunks)packages/evm/src/wagmi/ics20.ts(1 hunks)packages/evm/src/wagmi/index.ts(1 hunks)packages/evm/src/wagmi/slashing.ts(1 hunks)packages/evm/src/wagmi/staking.ts(1 hunks)packages/evm/src/wagmi/wasm.ts(1 hunks)packages/evm/wagmi.config.ts(1 hunks)packages/lcd/package.json(1 hunks)packages/proto/package.json(1 hunks)packages/rwa/package.json(1 hunks)
💤 Files with no reviewable changes (6)
- packages/evm/src/ethers/index.ts
- packages/evm/src/viem/evidencePrecompile.ts
- packages/evm/src/precompiles/index.ts
- packages/evm/src/ethers/evidencePrecompile.ts
- packages/evm/src/precompiles/evidence.ts
- packages/evm/src/viem/index.ts
🧰 Additional context used
🧬 Code graph analysis (9)
packages/evm/src/wagmi/ics20.ts (1)
packages/evm/src/precompiles/ics20.ts (2)
ICS20_PRECOMPILE_ADDRESS(5-6)ICS20_PRECOMPILE_ABI(12-156)
packages/evm/src/wagmi/bech32.ts (1)
packages/evm/src/precompiles/bech32.ts (2)
BECH32_PRECOMPILE_ADDRESS(1-2)BECH32_PRECOMPILE_ABI(4-24)
packages/evm/src/wagmi/slashing.ts (1)
packages/evm/src/precompiles/slashing.ts (2)
SLASHING_PRECOMPILE_ABI(12-155)SLASHING_PRECOMPILE_ADDRESS(5-6)
packages/evm/src/wagmi/wasm.ts (1)
packages/evm/src/precompiles/wasm.ts (2)
WASM_PRECOMPILE_ABI(12-114)WASM_PRECOMPILE_ADDRESS(5-6)
packages/evm/src/wagmi/bank.ts (1)
packages/evm/src/precompiles/bank.ts (2)
BANK_PRECOMPILE_ABI(8-54)BANK_PRECOMPILE_ADDRESS(5-6)
packages/evm/src/wagmi/distribution.ts (1)
packages/evm/src/precompiles/distribution.ts (2)
DISTRIBUTION_PRECOMPILE_ABI(4-456)DISTRIBUTION_PRECOMPILE_ADDRESS(1-2)
packages/evm/src/wagmi/ibc.ts (1)
packages/evm/src/precompiles/ibc.ts (2)
IBC_PRECOMPILE_ABI(12-96)IBC_PRECOMPILE_ADDRESS(5-6)
packages/evm/src/wagmi/staking.ts (1)
packages/evm/src/precompiles/staking.ts (2)
STAKING_PRECOMPILE_ABI(4-598)STAKING_PRECOMPILE_ADDRESS(1-2)
packages/evm/src/wagmi/governance.ts (1)
packages/evm/src/precompiles/governance.ts (2)
GOVERNANCE_PRECOMPILE_ABI(4-581)GOVERNANCE_PRECOMPILE_ADDRESS(1-2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: analyze
🔇 Additional comments (30)
packages/proto/package.json (1)
38-39: Build scripts correctly use && chaining with consistent npx prefixes.The use of && ensures each step only runs if the prior step succeeds, providing proper error handling. All tsc invocations correctly use npx for portability across different environments.
packages/evm/abis/precompiles/bank.json (1)
1-86: LGTM!The Bank precompile ABI artifact is well-structured with clear function signatures and properly defined tuple components for the Balance struct. Empty bytecode fields are expected for interface-only contracts.
packages/evm/abis/precompiles/governance.json (1)
1-1116: LGTM!The Governance precompile ABI artifact provides a comprehensive interface for governance operations including proposal management, voting, and parameter queries. The nested struct definitions are properly structured with appropriate field types.
packages/evm/abis/precompiles/staking.json (1)
1-1016: LGTM!The Staking precompile ABI artifact is comprehensive and well-organized, covering all essential staking operations including validator management, delegation, redelegation, and unbonding. The complex nested structures are properly typed.
packages/evm/abis/precompiles/wasmd.json (1)
5-207: LGTM!The Wasmd precompile ABI is well-structured with appropriate events and functions for CosmWasm contract interactions. The
Coinstruct usage is consistent with other precompile artifacts.packages/evm/src/precompiles/ibc.ts (2)
5-6: LGTM!The address constant is properly typed with
as constfor literal type inference, which is consistent with modern TypeScript best practices and aligns with similar updates across other precompile definitions.
12-96: LGTM!The IBC precompile ABI has been properly enhanced with:
- A
Transferevent with appropriately indexed fields- Two transfer function variants with explicit output types
- Consistent field naming and typing throughout
The structure aligns with the corresponding ABI artifact pattern used in other precompiles.
packages/evm/abis/precompiles/distribution.json (1)
1-764: LGTM!The Distribution precompile ABI artifact provides a complete interface for reward distribution, community pool management, and validator commission operations. The nested struct definitions (DecCoin, Coin, PageRequest, PageResponse, etc.) are properly structured with appropriate precision and type information.
packages/evm/src/wagmi/index.ts (1)
1-9: LGTM!This barrel export file provides a clean, centralized entry point for all Wagmi-based precompile wrappers. The module organization is logical and follows a consistent naming pattern.
packages/evm/src/index.ts (1)
4-4: LGTM!The export of Wagmi functionality is straightforward and follows the existing pattern of re-exporting module contents.
packages/evm/abis/precompiles/ics20.json (1)
1-280: LGTM!The ICS20 precompile ABI artifact is well-structured with proper event definitions, function signatures, and nested type definitions. Empty bytecode fields are expected for precompiles since they're implemented natively in the chain.
packages/evm/src/wagmi/bank.ts (1)
1-44: LGTM!The Wagmi hooks for the bank precompile are correctly implemented:
- Proper use of
createUseReadContractwith ABI and address bindings- Function-specific hooks appropriately configured with
functionName- JSDoc comments and pure annotations present
packages/evm/abis/precompiles/ibc.json (1)
1-181: LGTM!The IBC precompile ABI is well-defined with:
- Properly indexed Transfer event for efficient filtering
- Two transfer functions with appropriate state mutability (
nonpayablefor state-changing operations)transferWithDefaultTimeoutas a convenient wrapperpackages/evm/abis/precompiles/slashing.json (1)
1-265: LGTM!The slashing precompile ABI is correctly structured with:
- Appropriate state mutability (
viewfor reads,nonpayablefor unjail)- Properly defined nested structures (Params, SigningInfo, Dec, PageRequest, PageResponse)
- ValidatorUnjailed event for tracking state changes
packages/evm/src/precompiles/bech32.ts (1)
1-24: LGTM!The updates improve type safety and ABI structure:
as constassertion on the address creates a literal type for better type checking- Explicit
type: 'function'fields align with standard ABI format- Property ordering changes improve consistency
packages/evm/wagmi.config.ts (1)
15-65: All precompile addresses verified and consistent—no issues found.Verification confirms that all 9 precompile addresses in wagmi.config.ts match exactly with their corresponding constants in packages/evm/src/precompiles/:
Precompile Address Bank 0x0000000000000000000000000000000000000804 Bech32 0x0000000000000000000000000000000000000400 Distribution 0x0000000000000000000000000000000000000801 Governance 0x0000000000000000000000000000000000000805 IBC 0x0000000000000000000000000000000000001002 ICS20 0x0000000000000000000000000000000000000802 Slashing 0x0000000000000000000000000000000000000806 Staking 0x0000000000000000000000000000000000000800 Wasm 0x0000000000000000000000000000000000001001 The configuration is correct and requires no changes.
packages/evm/src/wagmi/ibc.ts (1)
11-14: Hooks match ABI surface; looks good.Function and event names align with IBC_PRECOMPILE_ABI.
Also applies to: 19-34, 39-41, 46-61, 66-70, 75-80
packages/evm/src/wagmi/wasm.ts (1)
12-15: WASM wrappers align with ABI; solid.Names and mutability match the ABI; event watchers OK.
Also applies to: 20-35, 40-63, 68-92, 97-121
packages/evm/src/wagmi/slashing.ts (1)
15-18: Slashing hooks match ABI; good coverage.Functions/events aligned; no issues spotted.
Also applies to: 23-48, 53-66, 71-85, 90-104
packages/evm/src/precompiles/distribution.ts (2)
1-2: Address literal with const-assertion: good.Literal typing works well with viem Address template type.
118-123: Validator address indexed as string in one event; ensure all related items match.WithdrawValidatorCommission uses string and indexed: true. Confirm other events/functions follow the same convention after normalization.
packages/evm/src/precompiles/staking.ts (2)
1-2: Address literal tightened to const — good.
Literal address with const assertion is correct and consistent with other precompiles.
140-144: completionTime type disparity (events: uint256, functions: int64).
Different widths/sign across events and returns is surprising and can lead to inconsistent app handling. Align or document the rationale.Also applies to: 171-175, 289-289, 510-510
packages/evm/src/precompiles/bank.ts (1)
5-6: LGTM on Bank precompile ABI/address.
Address literal and tuple component shapes look consistent and consumer‑friendly.Also applies to: 10-22, 27-36, 38-53
packages/evm/src/wagmi/ics20.ts (1)
9-12: Config object export — nice.
Providing ICS20_PRECOMPILE_CONFIG is useful for consistency across hooks.packages/evm/src/precompiles/governance.ts (1)
1-581: LGTM! Well-structured precompile ABI modernization.The governance precompile has been comprehensively updated with:
- Type-safe address constant using
as const- Expanded ABI with explicit event and function definitions
- Detailed parameter structures with nested components for complex types
The changes follow Ethereum ABI standards and provide excellent type safety for TypeScript consumers.
packages/evm/src/precompiles/ics20.ts (1)
1-156: LGTM! Consistent ICS20 precompile update.The ICS20 precompile follows the same modernization pattern as governance, with explicit ABI types and
as constassertions. The IBCTransfer event and transfer-related functions are properly structured for IBC functionality.packages/evm/src/wagmi/governance.ts (1)
1-285: LGTM! Comprehensive Wagmi integration for governance precompile.This file provides a complete set of typed React hooks for interacting with the governance precompile:
- Read hooks for all view functions
- Write hooks for state mutations
- Simulate hooks for transaction dry-runs
- Event watchers for monitoring contract events
The consistent pattern and
/*#__PURE__*/annotations enable optimal tree-shaking. Great addition to the SDK!packages/evm/src/wagmi/staking.ts (1)
1-284: LGTM! Complete staking precompile integration.The staking hooks provide full coverage of delegation operations:
- Querying delegation/validator state
- Managing delegations (delegate, undelegate, redelegate)
- Validator management (create, edit)
- Event monitoring for all operations
Consistent with the governance pattern and well-structured.
packages/evm/src/wagmi/distribution.ts (1)
1-316: LGTM! Distribution precompile hooks complete the set.This file rounds out the Wagmi integration with hooks for:
- Querying rewards and commission
- Managing reward distribution and withdrawals
- Community pool operations
- Event monitoring
The entire precompile integration (governance, staking, distribution, ICS20) follows a consistent, well-designed pattern that provides excellent DX for SDK consumers.
Description
Type of change
Please delete options that are not relevant.