-
Notifications
You must be signed in to change notification settings - Fork 62
feat: add evm precompiles (bank, exchange, staking) Go bindings #310
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
Conversation
WalkthroughThis change introduces new Go bindings for several Ethereum smart contracts related to banking, exchange, and staking modules. The generated files provide struct definitions, deployment helpers, method wrappers, event handling, and session management for seamless contract interaction from Go applications. Each file encapsulates the ABI and contract logic for its respective module. Changes
Sequence Diagram(s)sequenceDiagram
participant GoApp
participant ContractBinding
participant EthereumNode
GoApp->>ContractBinding: Create binding (New* function)
GoApp->>ContractBinding: Call contract method (e.g., Transfer, Mint, Delegate)
ContractBinding->>EthereumNode: Send call/transaction via ABI
EthereumNode-->>ContractBinding: Return result (data or tx receipt)
ContractBinding-->>GoApp: Return result or event
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1)
197-925: Empty event filterer stubs
TheExchangeModuleFilterertype exists but no event subscriptions or iterators are generated. This indicates the ABI had noeventdefinitions. If the module emits events (e.g., orders created/cancelled), update the ABI JSON to include them so that abigen can generate watchers and filters.chain/evm/precompiles/bank/i_bank_module.abigen.go (1)
41-360: Event filterer stub without watchers
BankModuleFiltererexists, but no event filter or watch methods are generated because there are no events in the ABI. If the bank module contract emits events (e.g., ERC-20Transfer), add those definitions in the ABI so that abigen can produce the corresponding event iterators.chain/evm/precompiles/staking/i_staking_module.abigen.go (1)
32-36: Consider unifying theCosmosCointype across modules.Right now each abigen binding generates its own
CosmosCoinstruct. Extracting it into a shared precompile package could reduce duplication and improve consistency.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go(1 hunks)chain/evm/precompiles/bank/i_bank_module.abigen.go(1 hunks)chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go(1 hunks)chain/evm/precompiles/exchange/i_exchange_module.abigen.go(1 hunks)chain/evm/precompiles/staking/i_staking_module.abigen.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
chain/evm/precompiles/bank/i_bank_module.abigen.go (1)
ethereum/util/contract.go (2)
BoundContract(27-35)Contract(15-23)
chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go (1)
ethereum/util/contract.go (2)
BoundContract(27-35)Contract(15-23)
chain/evm/precompiles/staking/i_staking_module.abigen.go (2)
ethereum/util/contract.go (2)
BoundContract(27-35)Contract(15-23)chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1)
CosmosCoin(33-36)
chain/evm/precompiles/exchange/i_exchange_module.abigen.go (3)
client/chain/orderhash.go (1)
OrderHashes(48-51)ethereum/util/contract.go (2)
BoundContract(27-35)Contract(15-23)chain/evm/precompiles/staking/i_staking_module.abigen.go (1)
CosmosCoin(33-36)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: run-tests
- GitHub Check: lint
🔇 Additional comments (44)
chain/evm/precompiles/exchange/i_exchange_module.abigen.go (16)
6-17: Imports grouping follows Go conventions
The imports are well-structured: standard library first, a blank line, then external packages. The alias forethereumis used in the suppression block below.
19-30: Reference imports correctly suppress unused errors
The_ = ...statements prevent unused-import errors for packages only referenced in some bindings. This aligns with abigen’s typical pattern.
32-36: CosmosCoin struct definition is consistent
Matches thei_staking_module.abigen.godefinition and correctly uses*big.Intfor numeric fields.
38-73: Batch request/response structs mirror contract tuples
TheIExchangeModuleBatchCreate…andIExchangeModuleBatchUpdate…types correctly reflect the contract’s tuple definitions and use Go slices where needed.
75-195: Custom tuple types are accurately mapped
All user-defined struct types (IExchangeModuleDerivativeOrder,IExchangeModuleOrderData,IExchangeModuleSubaccountDepositData, etc.) use the proper Go types (e.g.,string,*big.Int,bool) matching the ABI.
197-205: Metadata constant and deprecated alias
ExchangeModuleMetaDataholds the raw ABI for parsing, andExchangeModuleABIremains as a deprecated alias for backward compatibility.
206-264: Core binding types and constructors
The definitions forExchangeModule,Caller,Transactor,Filterer, session types, raw bindings, and theNewExchangeModule*functions correctly initialize the underlyingbind.BoundContract.
301-308:bindExchangeModulewrapper is correct
Parses the ABI once (viaGetAbi) and reuses the parsed object for all subsequent calls, minimizing redundant work.
309-346: Raw call/transfer/transact helpers
Provides the low-level entry points to invoke any method or send plain transactions. This block follows the standard abigen template.
348-361:AllowanceCall and Session wrappers
The read-only binding correctly retrievesboolusingabi.ConvertTypeand returns a defaultfalseon error.
379-402:SubaccountDepositmapping logic
Maps the returnedavailableBalanceandtotalBalanceinto a Go struct, handling the pointer-of-pointer conversion. Error handling returns the zero struct if the call fails.
424-453:SubaccountDepositsslice conversion
Converts the anonymous tuple array into a Go slice ofIExchangeModuleSubaccountDepositDataand returns a nil slice on error.
455-484:SubaccountPositionsslice conversion
Similar to deposits, this correctly handles the array ofIExchangeModuleDerivativePosition.
786-793: ReviewDerivativeOrdersByHashesbinding
This method is generated as a paid mutator (Transact) but semantically it may be a read-only view. Please confirm that the ABI’sstateMutabilityforderivativeOrdersByHashesis intentionallynonpayable. If it’s meant to be a view, you should regenerate bindings to produce aCallwrapper instead ofTransact.
868-876: ReviewSpotOrdersByHashesbinding
Like its derivative counterpart,SpotOrdersByHashesis generated as a mutator. Verify whether it should be a view call and adjust the ABI/bindings accordingly.
843-862:Revokesignature check
TheRevokemethod omits asenderparameter (unlike most other mutators). Double-check the contract signature: ifrevokerequires a sender address in Solidity, you may need to include it in the Go binding.chain/evm/precompiles/bank/i_bank_module.abigen.go (10)
6-17: Imports grouping and suppression follow abigen template
Standard library imports, blank line, then external packages._ = ...references prevent unused imports.
32-40: Metadata constant and deprecated alias
BankModuleMetaDataembeds the contract’s ABI, andBankModuleABIremains as a deprecated alias.
41-61: Binding types (Caller, Transactor, Filterer) and sessions
The core types (BankModule,BankModuleCaller, etc.) and their session/raw counterparts follow the standard abigen pattern.
100-143: Constructor functions andbindBankModule
NewBankModule*helpers and the underlyingbindBankModulecorrectly parse the ABI and bind the contract.
149-182: Raw call/transaction wrappers
Low-level methods for generic calls and fund transfers are implemented as expected.
183-198:BalanceOfconversion logic
Converts the returneduint256into a*big.Int, returningnilon error along with the error. This matches abigen’s typical pattern.
214-231:Metadatacall wrapper
Handles multiple return values (string,string,uint8) viaabi.ConvertType. The default zero values are returned on error.
247-262:TotalSupplyconversion logic
Same pattern asBalanceOf, yielding a*big.Int.
278-322: Payable mutator methods (burn,mint,setMetadata)
All three methods and their session variants correctly invoke the respective contract function viaTransact.
341-360:transfertransaction wrapper
Thetransfermethod and its session variants correctly map arguments (from,to,amount) in the right order.chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go (3)
46-61: Deployment function follows go-ethereum best practices.The deployment function properly validates the ABI, handles errors appropriately, and returns the expected contract artifacts. The constructor parameters are appropriate for a fixed-supply ERC20 token.
205-452: Complete ERC20 method implementation.All standard ERC20 methods are properly bound with appropriate Go types, error handling, and multiple access patterns (caller, session, caller session). The implementation follows go-ethereum conventions for contract method bindings.
454-760: Comprehensive event handling implementation.The event handling code properly implements iterator patterns, filtering, watching, and parsing for both Approval and Transfer events. The channel-based subscription handling and error management follow go-ethereum best practices.
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (3)
422-588: Proper implementation of mint/burn and ownership functionality.The extended methods correctly implement mintable/burnable token functionality with appropriate ownership controls. The method bindings follow the same high-quality patterns as the standard ERC20 methods.
744-895: Complete ownership event handling.The OwnershipTransferred event implementation properly follows the established patterns and provides full functionality for tracking ownership changes. This is essential for applications managing mintable tokens with ownership controls.
1-1050:Details
❓ Verification inconclusive
Well-structured binding with comprehensive functionality.
This binding successfully combines standard ERC20 functionality with mint/burn capabilities and ownership management. The implementation is thorough and follows go-ethereum best practices throughout.
Given that these are manually copied bindings that need automation, please verify that the source contracts in the injective-core repository match these generated bindings to ensure consistency.
🏁 Script executed:
#!/bin/bash # Description: Check if there are any existing automation scripts or CI workflows for syncing these bindings # Search for any existing automation or scripts related to binding generation rg -i "abigen|binding|precompile" --type yaml --type sh --type md -A 3 -B 3 # Look for any references to the source repository path mentioned in PR description rg "injective-core.*precompile.*binding" -A 3 -B 3Length of output: 130
Automation Check Required
We didn’t find any existing CI workflows or scripts for regenerating these Go bindings. Please manually verify that the generated bindings in
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.goexactly match your source contracts in the injective-core repository, and consider adding an automated sync step to your CI.• No
abigen- or binding-generation scripts detected in YAML, shell, or Markdown files.
• Manually confirm the ABI/bytecode in this file aligns with the source Solidity contracts.
• Recommend adding a CI task (e.g.,abigen) to keep these bindings in sync going forward.chain/evm/precompiles/staking/i_staking_module.abigen.go (12)
1-5: Approved: Generated file header and package declaration look correct.The standard “DO NOT EDIT” notice and
package stakingdeclaration align with abigen conventions.
6-17: Approved: Import grouping is clear and complete.Standard library imports are separated from external packages, and all necessary go-ethereum packages are included.
19-30: Approved: Suppression of unused imports is correct.The
_ =assignments ensure none of the imports trigger “unused” errors in the generated code.
38-46: Approved: Contract metadata and deprecated ABI constant.Embedding the JSON ABI in
StakingModuleMetaDataand deprecating the standaloneStakingModuleABIfollows abigen’s recommended pattern.
47-67: Approved: Core contract binding types.The
StakingModule,StakingModuleCaller,StakingModuleTransactor, andStakingModuleFiltererstructs are correctly defined and mirror the pattern in other precompile modules.
69-105: Approved: Session and raw binding type definitions.Session and raw variants provide flexible call/transact configurations and low-level access. Definitions are consistent with go-ethereum’s bind package.
106-141: Approved: Constructor helper functions.The
NewStakingModule*functions correctly wire up caller, transactor, and filterer roles. Error handling is straightforward.
142-149: Approved: Internal binding helper.
bindStakingModuleproperly parses the ABI and constructs thebind.BoundContract. Error paths are handled.
151-168: Approved: Raw method wrappers.The
Call,Transfer, andTransactmethods on the raw binding expose the low-level API as expected.
189-232: Approved: Delegation view methods.The typed
Delegationcall implementation (Caller, Session, CallerSession) correctly decodes shares and balance into the generated struct.
234-295: Approved: Mutator transaction methods.
Delegate,Redelegate, andUndelegatevariants follow the correct ABI signatures and offer both direct and session-based invocations.
297-316: Approved: WithdrawDelegatorRewards transaction methods.The wrappers for
withdrawDelegatorRewardscorrectly map the single-argument transaction to all binding types.
| // Code generated - DO NOT EDIT. | ||
| // This file is a generated binding and any manual changes will be lost. | ||
|
|
||
| package bank | ||
|
|
||
| import ( | ||
| "errors" | ||
| "math/big" | ||
| "strings" | ||
|
|
||
| ethereum "github.com/ethereum/go-ethereum" | ||
| "github.com/ethereum/go-ethereum/accounts/abi" | ||
| "github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/core/types" | ||
| "github.com/ethereum/go-ethereum/event" | ||
| ) | ||
|
|
||
| // Reference imports to suppress errors if they are not otherwise used. | ||
| var ( | ||
| _ = errors.New | ||
| _ = big.NewInt | ||
| _ = strings.NewReader | ||
| _ = ethereum.NotFound | ||
| _ = bind.Bind | ||
| _ = common.Big1 | ||
| _ = types.BloomLookup | ||
| _ = event.NewSubscription | ||
| _ = abi.ConvertType | ||
| ) | ||
|
|
||
| // FixedSupplyBankERC20MetaData contains all meta data concerning the FixedSupplyBankERC20 contract. | ||
| var FixedSupplyBankERC20MetaData = &bind.MetaData{ | ||
| ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"},{\"internalType\":\"uint8\",\"name\":\"decimals_\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"initial_supply_\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"allowance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientAllowance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSpender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", | ||
| Bin: "0x6080604052606460055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034801562000051575f80fd5b5060405162001f4c38038062001f4c8339818101604052810190620000779190620006d7565b83838360405180602001604052805f81525060405180602001604052805f8152508160039081620000a99190620009b2565b508060049081620000bb9190620009b2565b50505060055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166337d2c2f48484846040518463ffffffff1660e01b81526004016200011e9392919062000af7565b6020604051808303815f875af11580156200013b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000161919062000b7a565b505050505f81111562000181576200018033826200018b60201b60201c565b5b5050505062000c9a565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603620001fe575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401620001f5919062000bed565b60405180910390fd5b620002115f83836200021560201b60201c565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603620002f15760055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401620002a792919062000c19565b6020604051808303815f875af1158015620002c4573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620002ea919062000b7a565b5062000473565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603620003cd5760055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639dc29fac84836040518363ffffffff1660e01b81526004016200038392919062000c19565b6020604051808303815f875af1158015620003a0573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190620003c6919062000b7a565b5062000472565b60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663beabacc88484846040518463ffffffff1660e01b81526004016200042d9392919062000c44565b6020604051808303815f875af11580156200044a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019062000470919062000b7a565b505b5b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051620004d2919062000c7f565b60405180910390a3505050565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6200054082620004f8565b810181811067ffffffffffffffff8211171562000562576200056162000508565b5b80604052505050565b5f62000576620004df565b905062000584828262000535565b919050565b5f67ffffffffffffffff821115620005a657620005a562000508565b5b620005b182620004f8565b9050602081019050919050565b5f5b83811015620005dd578082015181840152602081019050620005c0565b5f8484015250505050565b5f620005fe620005f88462000589565b6200056b565b9050828152602081018484840111156200061d576200061c620004f4565b5b6200062a848285620005be565b509392505050565b5f82601f830112620006495762000648620004f0565b5b81516200065b848260208601620005e8565b91505092915050565b5f60ff82169050919050565b6200067b8162000664565b811462000686575f80fd5b50565b5f81519050620006998162000670565b92915050565b5f819050919050565b620006b3816200069f565b8114620006be575f80fd5b50565b5f81519050620006d181620006a8565b92915050565b5f805f8060808587031215620006f257620006f1620004e8565b5b5f85015167ffffffffffffffff811115620007125762000711620004ec565b5b620007208782880162000632565b945050602085015167ffffffffffffffff811115620007445762000743620004ec565b5b620007528782880162000632565b9350506040620007658782880162000689565b92505060606200077887828801620006c1565b91505092959194509250565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680620007d357607f821691505b602082108103620007e957620007e86200078e565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026200084d7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000810565b62000859868362000810565b95508019841693508086168417925050509392505050565b5f819050919050565b5f6200089a620008946200088e846200069f565b62000871565b6200069f565b9050919050565b5f819050919050565b620008b5836200087a565b620008cd620008c482620008a1565b8484546200081c565b825550505050565b5f90565b620008e3620008d5565b620008f0818484620008aa565b505050565b5b8181101562000917576200090b5f82620008d9565b600181019050620008f6565b5050565b601f82111562000966576200093081620007ef565b6200093b8462000801565b810160208510156200094b578190505b620009636200095a8562000801565b830182620008f5565b50505b505050565b5f82821c905092915050565b5f620009885f19846008026200096b565b1980831691505092915050565b5f620009a2838362000977565b9150826002028217905092915050565b620009bd8262000784565b67ffffffffffffffff811115620009d957620009d862000508565b5b620009e58254620007bb565b620009f28282856200091b565b5f60209050601f83116001811462000a28575f841562000a13578287015190505b62000a1f858262000995565b86555062000a8e565b601f19841662000a3886620007ef565b5f5b8281101562000a615784890151825560018201915060208501945060208101905062000a3a565b8683101562000a81578489015162000a7d601f89168262000977565b8355505b6001600288020188555050505b505050505050565b5f82825260208201905092915050565b5f62000ab28262000784565b62000abe818562000a96565b935062000ad0818560208601620005be565b62000adb81620004f8565b840191505092915050565b62000af18162000664565b82525050565b5f6060820190508181035f83015262000b11818662000aa6565b9050818103602083015262000b27818562000aa6565b905062000b38604083018462000ae6565b949350505050565b5f8115159050919050565b62000b568162000b40565b811462000b61575f80fd5b50565b5f8151905062000b748162000b4b565b92915050565b5f6020828403121562000b925762000b91620004e8565b5b5f62000ba18482850162000b64565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f62000bd58262000baa565b9050919050565b62000be78162000bc9565b82525050565b5f60208201905062000c025f83018462000bdc565b92915050565b62000c13816200069f565b82525050565b5f60408201905062000c2e5f83018562000bdc565b62000c3d602083018462000c08565b9392505050565b5f60608201905062000c595f83018662000bdc565b62000c68602083018562000bdc565b62000c77604083018462000c08565b949350505050565b5f60208201905062000c945f83018462000c08565b92915050565b6112a48062000ca85f395ff3fe608060405234801561000f575f80fd5b5060043610610091575f3560e01c8063313ce56711610064578063313ce5671461013157806370a082311461014f57806395d89b411461017f578063a9059cbb1461019d578063dd62ed3e146101cd57610091565b806306fdde0314610095578063095ea7b3146100b357806318160ddd146100e357806323b872dd14610101575b5f80fd5b61009d6101fd565b6040516100aa9190610ce6565b60405180910390f35b6100cd60048036038101906100c89190610da4565b6102aa565b6040516100da9190610dfc565b60405180910390f35b6100eb6102cc565b6040516100f89190610e24565b60405180910390f35b61011b60048036038101906101169190610e3d565b61036b565b6040516101289190610dfc565b60405180910390f35b610139610399565b6040516101469190610ea8565b60405180910390f35b61016960048036038101906101649190610ec1565b610447565b6040516101769190610e24565b60405180910390f35b6101876104ea565b6040516101949190610ce6565b60405180910390f35b6101b760048036038101906101b29190610da4565b610598565b6040516101c49190610dfc565b60405180910390f35b6101e760048036038101906101e29190610eec565b6105ba565b6040516101f49190610e24565b60405180910390f35b60608060055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632ba21572306040518263ffffffff1660e01b815260040161025a9190610f39565b5f60405180830381865afa158015610274573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f8201168201806040525081019061029c919061109a565b905050809150508091505090565b5f806102b461063c565b90506102c1818585610643565b600191505092915050565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663e4dc2aa4306040518263ffffffff1660e01b81526004016103279190610f39565b602060405180830381865afa158015610342573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906103669190611136565b905090565b5f8061037561063c565b9050610382858285610655565b61038d8585856106e8565b60019150509392505050565b5f8060055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632ba21572306040518263ffffffff1660e01b81526004016103f59190610f39565b5f60405180830381865afa15801561040f573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610437919061109a565b9091509050809150508091505090565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f7888aec30846040518363ffffffff1660e01b81526004016104a4929190611161565b602060405180830381865afa1580156104bf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104e39190611136565b9050919050565b60608060055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16632ba21572306040518263ffffffff1660e01b81526004016105479190610f39565b5f60405180830381865afa158015610561573d5f803e3d5ffd5b505050506040513d5f823e3d601f19601f82011682018060405250810190610589919061109a565b90915050809150508091505090565b5f806105a261063c565b90506105af8185856106e8565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b5f33905090565b61065083838360016107d8565b505050565b5f61066084846105ba565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8110156106e257818110156106d3578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016106ca93929190611188565b60405180910390fd5b6106e184848484035f6107d8565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610758575f6040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260040161074f9190610f39565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036107c8575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016107bf9190610f39565b60405180910390fd5b6107d38383836109a7565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610848575f6040517fe602df0500000000000000000000000000000000000000000000000000000000815260040161083f9190610f39565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108b8575f6040517f94280d620000000000000000000000000000000000000000000000000000000081526004016108af9190610f39565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208190555080156109a1578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516109989190610e24565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610a7c5760055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340c10f1983836040518363ffffffff1660e01b8152600401610a369291906111bd565b6020604051808303815f875af1158015610a52573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a76919061120e565b50610bf2565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610b515760055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639dc29fac84836040518363ffffffff1660e01b8152600401610b0b9291906111bd565b6020604051808303815f875af1158015610b27573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b4b919061120e565b50610bf1565b60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663beabacc88484846040518463ffffffff1660e01b8152600401610baf93929190611239565b6020604051808303815f875af1158015610bcb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bef919061120e565b505b5b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610c4f9190610e24565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015610c93578082015181840152602081019050610c78565b5f8484015250505050565b5f601f19601f8301169050919050565b5f610cb882610c5c565b610cc28185610c66565b9350610cd2818560208601610c76565b610cdb81610c9e565b840191505092915050565b5f6020820190508181035f830152610cfe8184610cae565b905092915050565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610d4082610d17565b9050919050565b610d5081610d36565b8114610d5a575f80fd5b50565b5f81359050610d6b81610d47565b92915050565b5f819050919050565b610d8381610d71565b8114610d8d575f80fd5b50565b5f81359050610d9e81610d7a565b92915050565b5f8060408385031215610dba57610db9610d0f565b5b5f610dc785828601610d5d565b9250506020610dd885828601610d90565b9150509250929050565b5f8115159050919050565b610df681610de2565b82525050565b5f602082019050610e0f5f830184610ded565b92915050565b610e1e81610d71565b82525050565b5f602082019050610e375f830184610e15565b92915050565b5f805f60608486031215610e5457610e53610d0f565b5b5f610e6186828701610d5d565b9350506020610e7286828701610d5d565b9250506040610e8386828701610d90565b9150509250925092565b5f60ff82169050919050565b610ea281610e8d565b82525050565b5f602082019050610ebb5f830184610e99565b92915050565b5f60208284031215610ed657610ed5610d0f565b5b5f610ee384828501610d5d565b91505092915050565b5f8060408385031215610f0257610f01610d0f565b5b5f610f0f85828601610d5d565b9250506020610f2085828601610d5d565b9150509250929050565b610f3381610d36565b82525050565b5f602082019050610f4c5f830184610f2a565b92915050565b5f80fd5b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610f9082610c9e565b810181811067ffffffffffffffff82111715610faf57610fae610f5a565b5b80604052505050565b5f610fc1610d06565b9050610fcd8282610f87565b919050565b5f67ffffffffffffffff821115610fec57610feb610f5a565b5b610ff582610c9e565b9050602081019050919050565b5f61101461100f84610fd2565b610fb8565b9050828152602081018484840111156110305761102f610f56565b5b61103b848285610c76565b509392505050565b5f82601f83011261105757611056610f52565b5b8151611067848260208601611002565b91505092915050565b61107981610e8d565b8114611083575f80fd5b50565b5f8151905061109481611070565b92915050565b5f805f606084860312156110b1576110b0610d0f565b5b5f84015167ffffffffffffffff8111156110ce576110cd610d13565b5b6110da86828701611043565b935050602084015167ffffffffffffffff8111156110fb576110fa610d13565b5b61110786828701611043565b925050604061111886828701611086565b9150509250925092565b5f8151905061113081610d7a565b92915050565b5f6020828403121561114b5761114a610d0f565b5b5f61115884828501611122565b91505092915050565b5f6040820190506111745f830185610f2a565b6111816020830184610f2a565b9392505050565b5f60608201905061119b5f830186610f2a565b6111a86020830185610e15565b6111b56040830184610e15565b949350505050565b5f6040820190506111d05f830185610f2a565b6111dd6020830184610e15565b9392505050565b6111ed81610de2565b81146111f7575f80fd5b50565b5f81519050611208816111e4565b92915050565b5f6020828403121561122357611222610d0f565b5b5f611230848285016111fa565b91505092915050565b5f60608201905061124c5f830186610f2a565b6112596020830185610f2a565b6112666040830184610e15565b94935050505056fea2646970667358221220e082168350992ad9e3420d61e59401edc6a5d5fd0f8d6596268a64c76e430a5064736f6c63430008180033", | ||
| } | ||
|
|
||
| // FixedSupplyBankERC20ABI is the input ABI used to generate the binding from. | ||
| // Deprecated: Use FixedSupplyBankERC20MetaData.ABI instead. | ||
| var FixedSupplyBankERC20ABI = FixedSupplyBankERC20MetaData.ABI | ||
|
|
||
| // FixedSupplyBankERC20Bin is the compiled bytecode used for deploying new contracts. | ||
| // Deprecated: Use FixedSupplyBankERC20MetaData.Bin instead. | ||
| var FixedSupplyBankERC20Bin = FixedSupplyBankERC20MetaData.Bin |
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.
🛠️ Refactor suggestion
Generated binding file structure looks correct.
This auto-generated Go binding follows standard go-ethereum patterns and includes all necessary components for contract interaction. As noted in the PR description, these bindings should be automated rather than manually copied from the injective-core repository to prevent inconsistencies and reduce maintenance overhead.
Consider implementing automated CI/CD workflows to sync these bindings from the source repository at InjectiveLabs/injective-core/injective-chain/modules/evm/precompiles/bindings/cosmos/precompile.
🤖 Prompt for AI Agents
In chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go lines 1 to 44,
the generated Go binding file is structurally correct but should not be manually
copied from the injective-core repository. To fix this, implement an automated
CI/CD workflow that syncs these bindings directly from the source repository
InjectiveLabs/injective-core/injective-chain/modules/evm/precompiles/bindings/cosmos/precompile
to ensure consistency and reduce maintenance overhead.
|
Updated to newer generated bindings (constructors for ERC20 payable, etc) |
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.
Actionable comments posted: 0
♻️ Duplicate comments (1)
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (1)
1-4: Add an explicitgo:generateline for painless regenerationStamping the file as generated is good, but without a
//go:generatedirective developers still need to remember the fullabigen(or copy) command.
Including it makes re-generation a one-liner and eliminates drift with the source ABI.Example:
//go:generate abigen --abi ../../../../injective-core/modules/evm/precompiles/bindings/cosmos/precompile/MintBurnBankERC20.abi \ // --pkg bank --out mint_burn_bank_erc20.abigen.go
🧹 Nitpick comments (8)
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (2)
32-36: LargeBinconstant inflates binary size – considerembedor build-tag-gatingKeeping ~50 KB of hex byte-code in a global string increases compile time and every consumer’s binary, even when deployment helpers are unused.
Options:
- Move the byte-code to a separate
*.binfile andembedit on demand.- Wrap the constant in a build tag (e.g.
//go:build dev || tools) so it’s stripped from production builds.Either approach trims the SDK’s runtime footprint.
46-60: Redundantparsed == nilcheck afterGetAbi()
MetaData.GetAbi()already returns an error if decoding fails, so thenilcase is unreachable. The extra branch adds noise.- if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - }chain/evm/precompiles/exchange/i_exchange_module.abigen.go (6)
1-4: Add a//go:generate(or build) directive to document the generator commandThe header only states “Code generated – DO NOT EDIT”.
Including the exactabigeninvocation (or a//go:generate …line) makes the generation process reproducible for other contributors and CI.
6-17: Remove unused std-lib references via build‐tag or generation flagThe dummy assignments (
_ = strings.NewReader,_ = errors.New, …) keepgo vetquiet but still bloat the byte-code.
If possible, instructabigento emit//go:build !codeanalysiswrapper (or use//lint:file-ignore U1000) instead of run-time dead code.
198-205: Consider externalising the giant ABI string
ExchangeModuleMetaData.ABIembeds ~30 KB of text directly in the binary.
Moving the raw ABI to a separate*.jsonfile and using//go:embed(Go 1.16+) keeps the compiled binary smaller and improves diff ergonomics when the contract changes.-var ExchangeModuleMetaData = &bind.MetaData{ - ABI: "<huge-inline-string>", -} +//go:embed i_exchange_module.abi.json +var exchangeModuleABI string + +var ExchangeModuleMetaData = &bind.MetaData{ + ABI: exchangeModuleABI, +}
302-308:GetAbi()is parsed on every bind – cache the parsed value
bindExchangeModuleparses the ABI each time a binding is instantiated.
If the application spins up many bindings, consider caching the parsed ABI in async.Onceto avoid repeated parsing costs.
348-367: Return value initialisation is redundantPatterns like:
if err != nil { return *new(bool), err }allocate a new zero value unnecessarily. Returning
false, erris clearer and cheaper.
906-925: Minor: group identical session wrappers via helper to reduce code sizeMost
Session/TransactorSessionwrappers are boilerplate.
Generating a small helper (e.g.callSession(method string, args ...interface{})) could cut ~2 000 lines, improving compile time.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go(1 hunks)chain/evm/precompiles/bank/i_bank_module.abigen.go(1 hunks)chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go(1 hunks)chain/evm/precompiles/exchange/i_exchange_module.abigen.go(1 hunks)chain/evm/precompiles/staking/i_staking_module.abigen.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- chain/evm/precompiles/bank/i_bank_module.abigen.go
- chain/evm/precompiles/staking/i_staking_module.abigen.go
- chain/evm/precompiles/bank/fixed_supply_bank_erc20.abigen.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (1)
ethereum/util/contract.go (2)
BoundContract(27-35)Contract(15-23)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: run-tests
- GitHub Check: lint
🔇 Additional comments (2)
chain/evm/precompiles/bank/mint_burn_bank_erc20.abigen.go (1)
206-218: Nil pointer returned on error can trip careless callersWhen
contract.Callfails, the getter returns(*big.Int)(nil)together with the error.
Any caller that forgets to inspect the error will dereference a nil pointer and panic.Generated code can’t easily change, but consider wrapping these bindings in higher-level helpers that enforce error handling or return a zero value instead.
chain/evm/precompiles/exchange/i_exchange_module.abigen.go (1)
32-196: Structs lack JSON / protobuf tags – confirm they are never marshalledBindings for on-chain calls rarely need JSON tags, but the SDK sometimes serialises these structs (e.g. REST helpers).
Double-check downstream code; if marshaling occurs, missing tags will break clients.
|
This has already been added in |
We need to auto-copy these from chain somehow.
It's located in https://github.com/InjectiveLabs/injective-core/tree/master/injective-chain/modules/evm/precompiles/bindings/cosmos/precompile
cc @aarmoa
P.S. for now there is a tag
v1.58.0-evm-precompiles-comet1-rc1until this is merged or done elsewere.Summary by CodeRabbit