diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 00ac7e92..9bfbae9b 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -63,12 +63,13 @@ import ( "github.com/spf13/cast" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/crosschain" + stakingprecompile "github.com/functionx/fx-core/v8/precompiles/staking" fxtypes "github.com/functionx/fx-core/v8/types" arbitrumtypes "github.com/functionx/fx-core/v8/x/arbitrum/types" avalanchetypes "github.com/functionx/fx-core/v8/x/avalanche/types" bsctypes "github.com/functionx/fx-core/v8/x/bsc/types" crosschainkeeper "github.com/functionx/fx-core/v8/x/crosschain/keeper" - crosschainprecompile "github.com/functionx/fx-core/v8/x/crosschain/precompile" erc20keeper "github.com/functionx/fx-core/v8/x/erc20/keeper" erc20types "github.com/functionx/fx-core/v8/x/erc20/types" ethtypes "github.com/functionx/fx-core/v8/x/eth/types" @@ -83,7 +84,6 @@ import ( optimismtypes "github.com/functionx/fx-core/v8/x/optimism/types" polygontypes "github.com/functionx/fx-core/v8/x/polygon/types" fxstakingkeeper "github.com/functionx/fx-core/v8/x/staking/keeper" - stakingprecompile "github.com/functionx/fx-core/v8/x/staking/precompile" trontypes "github.com/functionx/fx-core/v8/x/tron/types" ) @@ -350,7 +350,7 @@ func NewAppKeeper( ) // crosschain precompile - crosschainPrecompileRouter := crosschainprecompile.NewRouter() + crosschainPrecompileRouter := crosschain.NewRouter() evmKeeper := evmkeeper.NewKeeper( appCodec, appKeepers.keys[evmtypes.StoreKey], @@ -364,7 +364,7 @@ func NewAppKeeper( appKeepers.GetSubspace(evmtypes.ModuleName), []evmkeeper.CustomContractFn{ func(_ sdk.Context, _ ethparams.Rules) vm.PrecompiledContract { - return crosschainprecompile.NewPrecompiledContract( + return crosschain.NewPrecompiledContract( appKeepers.BankKeeper, appKeepers.GovKeeper, crosschainPrecompileRouter) }, func(_ sdk.Context, _ ethparams.Rules) vm.PrecompiledContract { diff --git a/x/crosschain/precompile/bridge_call.go b/precompiles/crosschain/bridge_call.go similarity index 99% rename from x/crosschain/precompile/bridge_call.go rename to precompiles/crosschain/bridge_call.go index e7fb4b00..9b89ef74 100644 --- a/x/crosschain/precompile/bridge_call.go +++ b/precompiles/crosschain/bridge_call.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "errors" diff --git a/x/crosschain/precompile/bridge_call_test.go b/precompiles/crosschain/bridge_call_test.go similarity index 94% rename from x/crosschain/precompile/bridge_call_test.go rename to precompiles/crosschain/bridge_call_test.go index 63ba767e..a0c1027f 100644 --- a/x/crosschain/precompile/bridge_call_test.go +++ b/precompiles/crosschain/bridge_call_test.go @@ -1,4 +1,4 @@ -package precompile_test +package crosschain_test import ( "encoding/hex" @@ -10,19 +10,19 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/crosschain" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/crosschain/precompile" ) func TestBridgeCallABI(t *testing.T) { - bridgeCallABI := precompile.NewBridgeCallABI() + bridgeCallABI := crosschain.NewBridgeCallABI() require.Len(t, bridgeCallABI.Method.Inputs, 8) require.Len(t, bridgeCallABI.Method.Outputs, 1) } func TestContract_BridgeCall_Input(t *testing.T) { - bridgeCallABI := precompile.NewBridgeCallABI() + bridgeCallABI := crosschain.NewBridgeCallABI() assert.Equal(t, `bridgeCall(string,address,address[],uint256[],address,bytes,uint256,bytes)`, bridgeCallABI.Method.Sig) assert.Equal(t, "payable", bridgeCallABI.Method.StateMutability) @@ -78,7 +78,7 @@ func TestContract_BridgeCall_Input(t *testing.T) { } func TestContract_BridgeCall_Output(t *testing.T) { - bridgeCallABI := precompile.NewBridgeCallABI() + bridgeCallABI := crosschain.NewBridgeCallABI() assert.Len(t, bridgeCallABI.Method.Outputs, 1) outputs := bridgeCallABI.Method.Outputs @@ -95,7 +95,7 @@ func TestContract_BridgeCall_Output(t *testing.T) { } func TestContract_BridgeCall_Event(t *testing.T) { - bridgeCallABI := precompile.NewBridgeCallABI() + bridgeCallABI := crosschain.NewBridgeCallABI() assert.Equal(t, `BridgeCallEvent(address,address,address,address,uint256,string,address[],uint256[],bytes,uint256,bytes)`, bridgeCallABI.Event.Sig) assert.Equal(t, "0x96da1d63da4d424eb5848fc98c0361f8e970b1934ddc9c5529ba684171283a53", bridgeCallABI.Event.ID.String()) @@ -144,7 +144,7 @@ func TestContract_BridgeCall_Event(t *testing.T) { } func TestContract_BridgeCall_NewBridgeCallEvent(t *testing.T) { - bridgeCallABI := precompile.NewBridgeCallABI() + bridgeCallABI := crosschain.NewBridgeCallABI() sender := common.BytesToAddress([]byte{0x1}) origin := common.BytesToAddress([]byte{0x2}) diff --git a/x/crosschain/precompile/bridge_coin_amount.go b/precompiles/crosschain/bridge_coin_amount.go similarity index 99% rename from x/crosschain/precompile/bridge_coin_amount.go rename to precompiles/crosschain/bridge_coin_amount.go index d9e4c365..93612b6e 100644 --- a/x/crosschain/precompile/bridge_coin_amount.go +++ b/precompiles/crosschain/bridge_coin_amount.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "errors" diff --git a/x/crosschain/precompile/bridge_coin_amount_test.go b/precompiles/crosschain/bridge_coin_amount_test.go similarity index 59% rename from x/crosschain/precompile/bridge_coin_amount_test.go rename to precompiles/crosschain/bridge_coin_amount_test.go index 4bb67c9b..dfd6cf0b 100644 --- a/x/crosschain/precompile/bridge_coin_amount_test.go +++ b/precompiles/crosschain/bridge_coin_amount_test.go @@ -1,15 +1,15 @@ -package precompile_test +package crosschain_test import ( "testing" "github.com/stretchr/testify/assert" - "github.com/functionx/fx-core/v8/x/crosschain/precompile" + "github.com/functionx/fx-core/v8/precompiles/crosschain" ) func TestBridgeCoinAmountMethod_ABI(t *testing.T) { - bridgeCoinAmountABI := precompile.NewBridgeCoinAmountABI() + bridgeCoinAmountABI := crosschain.NewBridgeCoinAmountABI() assert.Len(t, bridgeCoinAmountABI.Inputs, 2) assert.Len(t, bridgeCoinAmountABI.Outputs, 1) } diff --git a/x/crosschain/precompile/contract.go b/precompiles/crosschain/contract.go similarity index 92% rename from x/crosschain/precompile/contract.go rename to precompiles/crosschain/contract.go index 2454e8c9..00297747 100644 --- a/x/crosschain/precompile/contract.go +++ b/precompiles/crosschain/contract.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "bytes" @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/types" evmtypes "github.com/functionx/fx-core/v8/x/evm/types" ) @@ -18,12 +19,12 @@ var ( type Contract struct { methods []contract.PrecompileMethod - govKeeper GovKeeper + govKeeper types.GovKeeper } func NewPrecompiledContract( - bankKeeper BankKeeper, - govKeeper GovKeeper, + bankKeeper types.BankKeeper, + govKeeper types.GovKeeper, router *Router, ) *Contract { keeper := &Keeper{ diff --git a/x/crosschain/precompile/contract_test.go b/precompiles/crosschain/contract_test.go similarity index 99% rename from x/crosschain/precompile/contract_test.go rename to precompiles/crosschain/contract_test.go index bd0f517b..3b253881 100644 --- a/x/crosschain/precompile/contract_test.go +++ b/precompiles/crosschain/contract_test.go @@ -1,4 +1,4 @@ -package precompile_test +package crosschain_test import ( "testing" diff --git a/x/crosschain/precompile/crosschain.go b/precompiles/crosschain/crosschain.go similarity index 75% rename from x/crosschain/precompile/crosschain.go rename to precompiles/crosschain/crosschain.go index 59a189f1..7f7cd99d 100644 --- a/x/crosschain/precompile/crosschain.go +++ b/precompiles/crosschain/crosschain.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "errors" @@ -17,32 +17,32 @@ import ( ) // Deprecated: After the upgrade to v8 -type CrosschainMethod struct { +type LegacyCrosschainMethod struct { *Keeper - CrosschainABI + LegacyCrosschainABI } // Deprecated: After the upgrade to v8 -func NewCrosschainMethod(keeper *Keeper) *CrosschainMethod { - return &CrosschainMethod{ - Keeper: keeper, - CrosschainABI: NewCrosschainABI(), +func NewCrosschainMethod(keeper *Keeper) *LegacyCrosschainMethod { + return &LegacyCrosschainMethod{ + Keeper: keeper, + LegacyCrosschainABI: NewCrosschainABI(), } } -func (m *CrosschainMethod) IsReadonly() bool { +func (m *LegacyCrosschainMethod) IsReadonly() bool { return false } -func (m *CrosschainMethod) GetMethodId() []byte { +func (m *LegacyCrosschainMethod) GetMethodId() []byte { return m.Method.ID } -func (m *CrosschainMethod) RequiredGas() uint64 { +func (m *LegacyCrosschainMethod) RequiredGas() uint64 { return 40_000 } -func (m *CrosschainMethod) Run(evm *vm.EVM, contract *vm.Contract) ([]byte, error) { +func (m *LegacyCrosschainMethod) Run(evm *vm.EVM, contract *vm.Contract) ([]byte, error) { args, err := m.UnpackInput(contract.Input) if err != nil { return nil, err @@ -110,24 +110,24 @@ func (m *CrosschainMethod) Run(evm *vm.EVM, contract *vm.Contract) ([]byte, erro } // Deprecated: After the upgrade to v8 -type CrosschainABI struct { +type LegacyCrosschainABI struct { abi.Method abi.Event } // Deprecated: After the upgrade to v8 -func NewCrosschainABI() CrosschainABI { - return CrosschainABI{ +func NewCrosschainABI() LegacyCrosschainABI { + return LegacyCrosschainABI{ Method: crosschainABI.Methods["crossChain"], Event: crosschainABI.Events["CrossChain"], } } -func (m CrosschainABI) NewCrosschainEvent(sender, token common.Address, denom, receipt string, amount, fee *big.Int, target [32]byte, memo string) (data []byte, topic []common.Hash, err error) { +func (m LegacyCrosschainABI) NewCrosschainEvent(sender, token common.Address, denom, receipt string, amount, fee *big.Int, target [32]byte, memo string) (data []byte, topic []common.Hash, err error) { return evmtypes.PackTopicData(m.Event, []common.Hash{sender.Hash(), token.Hash()}, denom, receipt, amount, fee, target, memo) } -func (m CrosschainABI) UnpackInput(data []byte) (*fxcontract.CrosschainArgs, error) { +func (m LegacyCrosschainABI) UnpackInput(data []byte) (*fxcontract.CrosschainArgs, error) { args := new(fxcontract.CrosschainArgs) if err := evmtypes.ParseMethodArgs(m.Method, args, data[4:]); err != nil { return nil, err @@ -135,7 +135,7 @@ func (m CrosschainABI) UnpackInput(data []byte) (*fxcontract.CrosschainArgs, err return args, nil } -func (m CrosschainABI) PackInput(args fxcontract.CrosschainArgs) ([]byte, error) { +func (m LegacyCrosschainABI) PackInput(args fxcontract.CrosschainArgs) ([]byte, error) { data, err := m.Method.Inputs.Pack(args.Token, args.Receipt, args.Amount, args.Fee, args.Target, args.Memo) if err != nil { return nil, err @@ -143,6 +143,6 @@ func (m CrosschainABI) PackInput(args fxcontract.CrosschainArgs) ([]byte, error) return append(m.Method.ID, data...), nil } -func (m CrosschainABI) PackOutput(success bool) ([]byte, error) { +func (m LegacyCrosschainABI) PackOutput(success bool) ([]byte, error) { return m.Method.Outputs.Pack(success) } diff --git a/x/crosschain/precompile/crosschain_test.go b/precompiles/crosschain/crosschain_test.go similarity index 65% rename from x/crosschain/precompile/crosschain_test.go rename to precompiles/crosschain/crosschain_test.go index 9da7e49a..1368348b 100644 --- a/x/crosschain/precompile/crosschain_test.go +++ b/precompiles/crosschain/crosschain_test.go @@ -1,15 +1,15 @@ -package precompile_test +package crosschain_test import ( "testing" "github.com/stretchr/testify/require" - "github.com/functionx/fx-core/v8/x/crosschain/precompile" + "github.com/functionx/fx-core/v8/precompiles/crosschain" ) func TestCrosschainABI(t *testing.T) { - crosschainABI := precompile.NewCrosschainABI() + crosschainABI := crosschain.NewCrosschainABI() require.Len(t, crosschainABI.Method.Inputs, 6) require.Len(t, crosschainABI.Method.Outputs, 1) diff --git a/x/crosschain/precompile/execute_claim.go b/precompiles/crosschain/execute_claim.go similarity index 99% rename from x/crosschain/precompile/execute_claim.go rename to precompiles/crosschain/execute_claim.go index 0fd4de67..0d3e8cdf 100644 --- a/x/crosschain/precompile/execute_claim.go +++ b/precompiles/crosschain/execute_claim.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "errors" diff --git a/x/crosschain/precompile/execute_claim_test.go b/precompiles/crosschain/execute_claim_test.go similarity index 86% rename from x/crosschain/precompile/execute_claim_test.go rename to precompiles/crosschain/execute_claim_test.go index 66128f7b..b0c0a2ba 100644 --- a/x/crosschain/precompile/execute_claim_test.go +++ b/precompiles/crosschain/execute_claim_test.go @@ -1,4 +1,4 @@ -package precompile_test +package crosschain_test import ( "encoding/hex" @@ -9,12 +9,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" - "github.com/functionx/fx-core/v8/x/crosschain/precompile" + "github.com/functionx/fx-core/v8/precompiles/crosschain" ethtypes "github.com/functionx/fx-core/v8/x/eth/types" ) func TestExecuteClaimMethod_ABI(t *testing.T) { - executeClaimABI := precompile.NewExecuteClaimABI() + executeClaimABI := crosschain.NewExecuteClaimABI() methodStr := `function executeClaim(string _chain, uint256 _eventNonce) returns(bool _result)` assert.Equal(t, methodStr, executeClaimABI.Method.String()) @@ -24,7 +24,7 @@ func TestExecuteClaimMethod_ABI(t *testing.T) { } func TestExecuteClaimMethod_PackInput(t *testing.T) { - executeClaimABI := precompile.NewExecuteClaimABI() + executeClaimABI := crosschain.NewExecuteClaimABI() input, err := executeClaimABI.PackInput(contract.ExecuteClaimArgs{ Chain: ethtypes.ModuleName, EventNonce: big.NewInt(1), diff --git a/x/crosschain/precompile/has_oracle.go b/precompiles/crosschain/has_oracle.go similarity index 99% rename from x/crosschain/precompile/has_oracle.go rename to precompiles/crosschain/has_oracle.go index 61ee9590..0545a0ca 100644 --- a/x/crosschain/precompile/has_oracle.go +++ b/precompiles/crosschain/has_oracle.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "fmt" diff --git a/x/crosschain/precompile/has_oracle_test.go b/precompiles/crosschain/has_oracle_test.go similarity index 93% rename from x/crosschain/precompile/has_oracle_test.go rename to precompiles/crosschain/has_oracle_test.go index 10bc825d..8b67ea4a 100644 --- a/x/crosschain/precompile/has_oracle_test.go +++ b/precompiles/crosschain/has_oracle_test.go @@ -1,4 +1,4 @@ -package precompile_test +package crosschain_test import ( "fmt" @@ -7,14 +7,14 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/crosschain" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/crosschain/precompile" "github.com/functionx/fx-core/v8/x/crosschain/types" ethtypes "github.com/functionx/fx-core/v8/x/eth/types" ) func TestCrosschainHasOracleABI(t *testing.T) { - hasOracleABI := precompile.NewHasOracleABI() + hasOracleABI := crosschain.NewHasOracleABI() require.Len(t, hasOracleABI.Method.Inputs, 2) require.Len(t, hasOracleABI.Method.Outputs, 1) } diff --git a/x/crosschain/precompile/is_oracle_online.go b/precompiles/crosschain/is_oracle_online.go similarity index 99% rename from x/crosschain/precompile/is_oracle_online.go rename to precompiles/crosschain/is_oracle_online.go index 2bd80d4b..f3eba1cd 100644 --- a/x/crosschain/precompile/is_oracle_online.go +++ b/precompiles/crosschain/is_oracle_online.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "fmt" diff --git a/x/crosschain/precompile/is_oracle_online_test.go b/precompiles/crosschain/is_oracle_online_test.go similarity index 93% rename from x/crosschain/precompile/is_oracle_online_test.go rename to precompiles/crosschain/is_oracle_online_test.go index 93458ce9..69d645a8 100644 --- a/x/crosschain/precompile/is_oracle_online_test.go +++ b/precompiles/crosschain/is_oracle_online_test.go @@ -1,4 +1,4 @@ -package precompile_test +package crosschain_test import ( "fmt" @@ -7,14 +7,14 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/crosschain" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/crosschain/precompile" "github.com/functionx/fx-core/v8/x/crosschain/types" ethtypes "github.com/functionx/fx-core/v8/x/eth/types" ) func TestCrosschainIsOracleOnlineABI(t *testing.T) { - isOracleOnlineABI := precompile.NewIsOracleOnlineABI() + isOracleOnlineABI := crosschain.NewIsOracleOnlineABI() require.Len(t, isOracleOnlineABI.Method.Inputs, 2) require.Len(t, isOracleOnlineABI.Method.Outputs, 1) } diff --git a/x/crosschain/precompile/keeper.go b/precompiles/crosschain/keeper.go similarity index 88% rename from x/crosschain/precompile/keeper.go rename to precompiles/crosschain/keeper.go index be0f0c2f..51625e51 100644 --- a/x/crosschain/precompile/keeper.go +++ b/precompiles/crosschain/keeper.go @@ -1,4 +1,4 @@ -package precompile +package crosschain import ( "fmt" @@ -11,16 +11,17 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/functionx/fx-core/v8/contract" + types2 "github.com/functionx/fx-core/v8/precompiles/types" fxtypes "github.com/functionx/fx-core/v8/types" erc20types "github.com/functionx/fx-core/v8/x/erc20/types" ) type Keeper struct { router *Router - bankKeeper BankKeeper + bankKeeper types2.BankKeeper } -func (c *Keeper) EvmTokenToBaseCoin(ctx sdk.Context, evm *vm.EVM, crosschainKeeper CrosschainKeeper, holder, tokenAddr common.Address, amount *big.Int) (sdk.Coin, error) { +func (c *Keeper) EvmTokenToBaseCoin(ctx sdk.Context, evm *vm.EVM, crosschainKeeper types2.CrosschainKeeper, holder, tokenAddr common.Address, amount *big.Int) (sdk.Coin, error) { erc20Token, err := crosschainKeeper.GetBaseDenomByErc20(ctx, tokenAddr) if err != nil { return sdk.Coin{}, err diff --git a/x/crosschain/precompile/router.go b/precompiles/crosschain/router.go similarity index 88% rename from x/crosschain/precompile/router.go rename to precompiles/crosschain/router.go index 5161cd50..2f3558ac 100644 --- a/x/crosschain/precompile/router.go +++ b/precompiles/crosschain/router.go @@ -1,10 +1,11 @@ -package precompile +package crosschain import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/functionx/fx-core/v8/precompiles/types" crosschainkeeper "github.com/functionx/fx-core/v8/x/crosschain/keeper" ) @@ -47,7 +48,7 @@ func (rtr *Router) AddRoute(module string, hook crosschainkeeper.Keeper) *Router return rtr } -func (rtr *Router) GetRoute(module string) (CrosschainKeeper, bool) { +func (rtr *Router) GetRoute(module string) (types.CrosschainKeeper, bool) { hook, found := rtr.routes[module] return hook, found } diff --git a/x/staking/precompile/allowance_shares.go b/precompiles/staking/allowance_shares.go similarity index 99% rename from x/staking/precompile/allowance_shares.go rename to precompiles/staking/allowance_shares.go index 00b5f1e5..2cda26b8 100644 --- a/x/staking/precompile/allowance_shares.go +++ b/precompiles/staking/allowance_shares.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "math/big" diff --git a/x/staking/precompile/allowance_shares_test.go b/precompiles/staking/allowance_shares_test.go similarity index 94% rename from x/staking/precompile/allowance_shares_test.go rename to precompiles/staking/allowance_shares_test.go index 146026bb..6677392b 100644 --- a/x/staking/precompile/allowance_shares_test.go +++ b/precompiles/staking/allowance_shares_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -8,12 +8,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestStakingAllowanceSharesABI(t *testing.T) { - allowanceSharesABI := precompile.NewAllowanceSharesABI() + allowanceSharesABI := staking.NewAllowanceSharesABI() require.Len(t, allowanceSharesABI.Method.Inputs, 3) require.Len(t, allowanceSharesABI.Method.Outputs, 1) diff --git a/x/staking/precompile/approve_shares.go b/precompiles/staking/approve_shares.go similarity index 99% rename from x/staking/precompile/approve_shares.go rename to precompiles/staking/approve_shares.go index 71c56905..d20e55eb 100644 --- a/x/staking/precompile/approve_shares.go +++ b/precompiles/staking/approve_shares.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/approve_shares_test.go b/precompiles/staking/approve_shares_test.go similarity index 94% rename from x/staking/precompile/approve_shares_test.go rename to precompiles/staking/approve_shares_test.go index 87dccb48..d7ec1037 100644 --- a/x/staking/precompile/approve_shares_test.go +++ b/precompiles/staking/approve_shares_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -10,12 +10,12 @@ import ( "github.com/stretchr/testify/require" fxcontract "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestStakingApproveSharesABI(t *testing.T) { - approveSharesABI := precompile.NewApproveSharesABI() + approveSharesABI := staking.NewApproveSharesABI() require.Len(t, approveSharesABI.Method.Inputs, 3) require.Len(t, approveSharesABI.Method.Outputs, 1) @@ -88,7 +88,7 @@ func (suite *StakingPrecompileTestSuite) TestApproveShares() { } existLog := false - approveSharesABI := precompile.NewApproveSharesABI() + approveSharesABI := staking.NewApproveSharesABI() for _, log := range res.Logs { if log.Topics[0] == approveSharesABI.Event.ID.String() { suite.Require().Equal(fxcontract.StakingAddress, log.Address) diff --git a/x/staking/precompile/contract.go b/precompiles/staking/contract.go similarity index 93% rename from x/staking/precompile/contract.go rename to precompiles/staking/contract.go index 7d513c6b..ca991c50 100644 --- a/x/staking/precompile/contract.go +++ b/precompiles/staking/contract.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "bytes" @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/types" evmtypes "github.com/functionx/fx-core/v8/x/evm/types" fxstakingkeeper "github.com/functionx/fx-core/v8/x/staking/keeper" ) @@ -21,16 +22,16 @@ var ( type Contract struct { methods []contract.PrecompileMethod - govKeeper GovKeeper + govKeeper types.GovKeeper } func NewPrecompiledContract( - bankKeeper BankKeeper, + bankKeeper types.BankKeeper, stakingKeeper *fxstakingkeeper.Keeper, distrKeeper distrkeeper.Keeper, stakingDenom string, - govKeeper GovKeeper, - slashingKeeper SlashingKeeper, + govKeeper types.GovKeeper, + slashingKeeper types.SlashingKeeper, ) *Contract { keeper := &Keeper{ bankKeeper: bankKeeper, diff --git a/x/staking/precompile/contract_test.go b/precompiles/staking/contract_test.go similarity index 99% rename from x/staking/precompile/contract_test.go rename to precompiles/staking/contract_test.go index ac93037a..f9f9186f 100644 --- a/x/staking/precompile/contract_test.go +++ b/precompiles/staking/contract_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "math/big" diff --git a/x/staking/precompile/delegate.go b/precompiles/staking/delegate.go similarity index 99% rename from x/staking/precompile/delegate.go rename to precompiles/staking/delegate.go index 1df746e5..3aec20ee 100644 --- a/x/staking/precompile/delegate.go +++ b/precompiles/staking/delegate.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/delegate_test.go b/precompiles/staking/delegate_test.go similarity index 97% rename from x/staking/precompile/delegate_test.go rename to precompiles/staking/delegate_test.go index 9b99ede3..b7dfeb73 100644 --- a/x/staking/precompile/delegate_test.go +++ b/precompiles/staking/delegate_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "errors" @@ -15,9 +15,9 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" fxtypes "github.com/functionx/fx-core/v8/types" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func (suite *StakingPrecompileTestSuite) TestDelegateCompare() { @@ -58,7 +58,7 @@ func (suite *StakingPrecompileTestSuite) TestDelegateCompare() { } func TestStakingDelegateV2ABI(t *testing.T) { - delegateV2ABI := precompile.NewDelegateV2ABI() + delegateV2ABI := staking.NewDelegateV2ABI() require.Len(t, delegateV2ABI.Method.Inputs, 2) require.Len(t, delegateV2ABI.Method.Outputs, 1) @@ -152,7 +152,7 @@ func (suite *StakingPrecompileTestSuite) TestDelegateV2() { } func (suite *StakingPrecompileTestSuite) CheckDelegateLogs(logs []*evmtypes.Log, delAddr common.Address, valAddr string, amount *big.Int) { - delegateV2ABI := precompile.NewDelegateV2ABI() + delegateV2ABI := staking.NewDelegateV2ABI() existLog := false for _, log := range logs { if log.Topics[0] == delegateV2ABI.Event.ID.String() { diff --git a/x/staking/precompile/delegation.go b/precompiles/staking/delegation.go similarity index 99% rename from x/staking/precompile/delegation.go rename to precompiles/staking/delegation.go index e4b1a60d..67159169 100644 --- a/x/staking/precompile/delegation.go +++ b/precompiles/staking/delegation.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/delegation_rewards.go b/precompiles/staking/delegation_rewards.go similarity index 99% rename from x/staking/precompile/delegation_rewards.go rename to precompiles/staking/delegation_rewards.go index ccc771c3..6b858c72 100644 --- a/x/staking/precompile/delegation_rewards.go +++ b/precompiles/staking/delegation_rewards.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/delegation_rewards_test.go b/precompiles/staking/delegation_rewards_test.go similarity index 94% rename from x/staking/precompile/delegation_rewards_test.go rename to precompiles/staking/delegation_rewards_test.go index 5f5fca8d..539e4d8b 100644 --- a/x/staking/precompile/delegation_rewards_test.go +++ b/precompiles/staking/delegation_rewards_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -10,12 +10,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestStakingDelegationRewardsABI(t *testing.T) { - delegationRewardsABI := precompile.NewDelegationRewardsABI() + delegationRewardsABI := staking.NewDelegationRewardsABI() require.Len(t, delegationRewardsABI.Method.Inputs, 2) require.Len(t, delegationRewardsABI.Method.Outputs, 1) diff --git a/x/staking/precompile/delegation_test.go b/precompiles/staking/delegation_test.go similarity index 95% rename from x/staking/precompile/delegation_test.go rename to precompiles/staking/delegation_test.go index 156fa9a4..88712825 100644 --- a/x/staking/precompile/delegation_test.go +++ b/precompiles/staking/delegation_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -9,12 +9,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestStakingDelegationABI(t *testing.T) { - delegationABI := precompile.NewDelegationABI() + delegationABI := staking.NewDelegationABI() require.Len(t, delegationABI.Method.Inputs, 2) require.Len(t, delegationABI.Method.Outputs, 2) diff --git a/x/staking/precompile/keeper.go b/precompiles/staking/keeper.go similarity index 97% rename from x/staking/precompile/keeper.go rename to precompiles/staking/keeper.go index 28f85b7e..d62c1e29 100644 --- a/x/staking/precompile/keeper.go +++ b/precompiles/staking/keeper.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" fxcontract "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/types" ) type Validator struct { @@ -22,12 +23,12 @@ type Validator struct { } type Keeper struct { - bankKeeper BankKeeper - distrKeeper DistrKeeper + bankKeeper types.BankKeeper + distrKeeper types.DistrKeeper distrMsgServer distrtypes.MsgServer - stakingKeeper StakingKeeper + stakingKeeper types.StakingKeeper stakingMsgServer stakingtypes.MsgServer - slashingKeeper SlashingKeeper + slashingKeeper types.SlashingKeeper stakingDenom string } diff --git a/x/staking/precompile/redelegate.go b/precompiles/staking/redelegate.go similarity index 99% rename from x/staking/precompile/redelegate.go rename to precompiles/staking/redelegate.go index 07b6ca0c..c21e2fc2 100644 --- a/x/staking/precompile/redelegate.go +++ b/precompiles/staking/redelegate.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/redelegate_test.go b/precompiles/staking/redelegate_test.go similarity index 97% rename from x/staking/precompile/redelegate_test.go rename to precompiles/staking/redelegate_test.go index 9e6f5dc0..b64a3336 100644 --- a/x/staking/precompile/redelegate_test.go +++ b/precompiles/staking/redelegate_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -13,9 +13,9 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" fxtypes "github.com/functionx/fx-core/v8/types" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func (suite *StakingPrecompileTestSuite) TestRedelegate() { @@ -99,7 +99,7 @@ func (suite *StakingPrecompileTestSuite) TestRedelegate() { } func (suite *StakingPrecompileTestSuite) CheckRedelegateLogs(logs []*evmtypes.Log, delAddr common.Address, valSrc, valDst string, shares, amount *big.Int, completionTime int64) { - redelegateV2ABI := precompile.NewRedelegateV2ABI() + redelegateV2ABI := staking.NewRedelegateV2ABI() existLog := false for _, log := range logs { if log.Topics[0] == redelegateV2ABI.Event.ID.String() { diff --git a/x/staking/precompile/slashing_info.go b/precompiles/staking/slashing_info.go similarity index 99% rename from x/staking/precompile/slashing_info.go rename to precompiles/staking/slashing_info.go index db638aee..1875ca39 100644 --- a/x/staking/precompile/slashing_info.go +++ b/precompiles/staking/slashing_info.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "math/big" diff --git a/x/staking/precompile/slashing_info_test.go b/precompiles/staking/slashing_info_test.go similarity index 93% rename from x/staking/precompile/slashing_info_test.go rename to precompiles/staking/slashing_info_test.go index 2f5b6f3c..68999e66 100644 --- a/x/staking/precompile/slashing_info_test.go +++ b/precompiles/staking/slashing_info_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -8,12 +8,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestSlashingInfoABI(t *testing.T) { - slashingInfoABI := precompile.NewSlashingInfoABI() + slashingInfoABI := staking.NewSlashingInfoABI() require.Len(t, slashingInfoABI.Method.Inputs, 1) require.Len(t, slashingInfoABI.Method.Outputs, 2) diff --git a/x/staking/precompile/transfer_shares.go b/precompiles/staking/transfer_shares.go similarity index 99% rename from x/staking/precompile/transfer_shares.go rename to precompiles/staking/transfer_shares.go index d27561c6..7d4fb865 100644 --- a/x/staking/precompile/transfer_shares.go +++ b/precompiles/staking/transfer_shares.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/transfer_shares_test.go b/precompiles/staking/transfer_shares_test.go similarity index 99% rename from x/staking/precompile/transfer_shares_test.go rename to precompiles/staking/transfer_shares_test.go index 4513a3cb..012c9436 100644 --- a/x/staking/precompile/transfer_shares_test.go +++ b/precompiles/staking/transfer_shares_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "errors" @@ -17,13 +17,13 @@ import ( "github.com/stretchr/testify/require" fxcontract "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" fxtypes "github.com/functionx/fx-core/v8/types" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestStakingTransferSharesABI(t *testing.T) { - transferSharesABI := precompile.NewTransferSharesABI() + transferSharesABI := staking.NewTransferSharesABI() require.Len(t, transferSharesABI.Method.Inputs, 3) require.Len(t, transferSharesABI.Method.Outputs, 2) @@ -238,7 +238,7 @@ func (suite *StakingPrecompileTestSuite) TestTransferShares() { existLog := false for _, log := range res.Logs { - transferSharesABI := precompile.NewTransferSharesABI() + transferSharesABI := staking.NewTransferSharesABI() if log.Topics[0] == transferSharesABI.Event.ID.String() { suite.Require().Len(log.Topics, 3) event, err := transferSharesABI.UnpackEvent(log.ToEthereum()) @@ -278,7 +278,7 @@ func (suite *StakingPrecompileTestSuite) packTransferAll(val sdk.ValAddress, to } func TestStakingTransferFromSharesABI(t *testing.T) { - transferFromSharesABI := precompile.NewTransferFromSharesABI() + transferFromSharesABI := staking.NewTransferFromSharesABI() require.Len(t, transferFromSharesABI.Method.Inputs, 4) require.Len(t, transferFromSharesABI.Method.Outputs, 2) @@ -507,7 +507,7 @@ func (suite *StakingPrecompileTestSuite) TestTransferFromShares() { existLog := false for _, log := range res.Logs { - transferFromSharesABI := precompile.NewTransferFromSharesABI() + transferFromSharesABI := staking.NewTransferFromSharesABI() if log.Topics[0] == transferFromSharesABI.Event.ID.String() { suite.Require().Len(log.Topics, 3) event, err := transferFromSharesABI.UnpackEvent(log.ToEthereum()) diff --git a/x/staking/precompile/undelegate.go b/precompiles/staking/undelegate.go similarity index 99% rename from x/staking/precompile/undelegate.go rename to precompiles/staking/undelegate.go index 0dd4013e..25ab77ce 100644 --- a/x/staking/precompile/undelegate.go +++ b/precompiles/staking/undelegate.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/undelegate_test.go b/precompiles/staking/undelegate_test.go similarity index 97% rename from x/staking/precompile/undelegate_test.go rename to precompiles/staking/undelegate_test.go index c4853243..92514c1a 100644 --- a/x/staking/precompile/undelegate_test.go +++ b/precompiles/staking/undelegate_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -13,9 +13,9 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" fxtypes "github.com/functionx/fx-core/v8/types" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func (suite *StakingPrecompileTestSuite) TestUndelegate() { @@ -93,7 +93,7 @@ func (suite *StakingPrecompileTestSuite) TestUndelegate() { } func (suite *StakingPrecompileTestSuite) CheckUndelegateLogs(logs []*evmtypes.Log, delAddr common.Address, valAddr string, shares, amount *big.Int, completionTime time.Time) { - undelegateV2ABI := precompile.NewUndelegateV2ABI() + undelegateV2ABI := staking.NewUndelegateV2ABI() existLog := false for _, log := range logs { if log.Topics[0] == undelegateV2ABI.Event.ID.String() { diff --git a/x/staking/precompile/validator_list.go b/precompiles/staking/validator_list.go similarity index 99% rename from x/staking/precompile/validator_list.go rename to precompiles/staking/validator_list.go index 041221b5..7d8c43cc 100644 --- a/x/staking/precompile/validator_list.go +++ b/precompiles/staking/validator_list.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "github.com/ethereum/go-ethereum/accounts/abi" diff --git a/x/staking/precompile/validator_list_test.go b/precompiles/staking/validator_list_test.go similarity index 90% rename from x/staking/precompile/validator_list_test.go rename to precompiles/staking/validator_list_test.go index e9e58df8..692a0387 100644 --- a/x/staking/precompile/validator_list_test.go +++ b/precompiles/staking/validator_list_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -8,12 +8,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - precompile2 "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestValidatorListABI(t *testing.T) { - validatorListABI := precompile2.NewValidatorListABI() + validatorListABI := staking.NewValidatorListABI() require.Len(t, validatorListABI.Method.Inputs, 1) require.Len(t, validatorListABI.Method.Outputs, 1) @@ -76,13 +76,13 @@ func (suite *StakingPrecompileTestSuite) TestValidatorList() { } } if args.GetSortBy() == contract.ValidatorSortByMissed { - valList := make([]precompile2.Validator, 0, len(valsByPower)) + valList := make([]staking.Validator, 0, len(valsByPower)) for _, validator := range valsByPower { consAddr, err := validator.GetConsAddr() suite.Require().NoError(err) info, err := suite.App.SlashingKeeper.GetValidatorSigningInfo(suite.Ctx, consAddr) suite.Require().NoError(err) - valList = append(valList, precompile2.Validator{ + valList = append(valList, staking.Validator{ ValAddr: validator.OperatorAddress, MissedBlocks: info.MissedBlocksCounter, }) diff --git a/x/staking/precompile/withdraw.go b/precompiles/staking/withdraw.go similarity index 99% rename from x/staking/precompile/withdraw.go rename to precompiles/staking/withdraw.go index 8678b712..f0129d66 100644 --- a/x/staking/precompile/withdraw.go +++ b/precompiles/staking/withdraw.go @@ -1,4 +1,4 @@ -package precompile +package staking import ( "errors" diff --git a/x/staking/precompile/withdraw_test.go b/precompiles/staking/withdraw_test.go similarity index 96% rename from x/staking/precompile/withdraw_test.go rename to precompiles/staking/withdraw_test.go index c02f3edd..925c1c67 100644 --- a/x/staking/precompile/withdraw_test.go +++ b/precompiles/staking/withdraw_test.go @@ -1,4 +1,4 @@ -package precompile_test +package staking_test import ( "fmt" @@ -11,12 +11,12 @@ import ( "github.com/stretchr/testify/require" "github.com/functionx/fx-core/v8/contract" + "github.com/functionx/fx-core/v8/precompiles/staking" fxtypes "github.com/functionx/fx-core/v8/types" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) func TestStakingWithdrawABI(t *testing.T) { - withdrawABI := precompile.NewWithdrawABI() + withdrawABI := staking.NewWithdrawABI() require.Len(t, withdrawABI.Method.Inputs, 1) require.Len(t, withdrawABI.Method.Outputs, 1) @@ -94,7 +94,7 @@ func (suite *StakingPrecompileTestSuite) TestWithdraw() { suite.Require().NoError(err) suite.Require().Equal(totalAfter, totalBefore) - withdrawABI := precompile.NewWithdrawABI() + withdrawABI := staking.NewWithdrawABI() reward, err := withdrawABI.UnpackOutput(res.Ret) suite.Require().NoError(err) diff --git a/x/staking/precompile/interfaces.go b/precompiles/types/expected_keepers.go similarity index 75% rename from x/staking/precompile/interfaces.go rename to precompiles/types/expected_keepers.go index a012775f..ee92092a 100644 --- a/x/staking/precompile/interfaces.go +++ b/precompiles/types/expected_keepers.go @@ -1,4 +1,4 @@ -package precompile +package types import ( "context" @@ -12,15 +12,36 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" + + crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types" + erc20types "github.com/functionx/fx-core/v8/x/erc20/types" ) type BankKeeper interface { + MintCoins(ctx context.Context, moduleName string, amounts sdk.Coins) error + SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx context.Context, recipientAddr sdk.AccAddress, senderModule string, amt sdk.Coins) error + SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin } +type CrosschainKeeper interface { + ExecuteClaim(ctx sdk.Context, eventNonce uint64) error + BridgeCoinSupply(ctx context.Context, token, target string) (sdk.Coin, error) + CrosschainBaseCoin(ctx sdk.Context, from sdk.AccAddress, receipt string, amount, fee sdk.Coin, fxTarget *crosschaintypes.FxTarget, memo string, originToken bool) error + BridgeCallBaseCoin(ctx sdk.Context, from, refund, to common.Address, coins sdk.Coins, data, memo []byte, quoteId *big.Int, fxTarget *crosschaintypes.FxTarget, originTokenAmount sdkmath.Int) (uint64, error) + GetBaseDenomByErc20(ctx sdk.Context, erc20Addr common.Address) (erc20types.ERC20Token, error) + + HasOracleAddrByExternalAddr(ctx sdk.Context, externalAddress string) bool + GetOracleAddrByExternalAddr(ctx sdk.Context, externalAddress string) (sdk.AccAddress, bool) + GetOracle(ctx sdk.Context, oracleAddr sdk.AccAddress) (oracle crosschaintypes.Oracle, found bool) +} + +type GovKeeper interface { + CheckDisabledPrecompiles(ctx sdk.Context, contractAddress common.Address, methodId []byte) error +} + type StakingKeeper interface { GetDelegation(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, err error) SetDelegation(ctx context.Context, delegation stakingtypes.Delegation) error @@ -64,10 +85,6 @@ type EvmKeeper interface { GetParams(ctx sdk.Context) evmtypes.Params } -type GovKeeper interface { - CheckDisabledPrecompiles(ctx sdk.Context, contractAddress common.Address, methodId []byte) error -} - type SlashingKeeper interface { GetValidatorSigningInfo(ctx context.Context, address sdk.ConsAddress) (slashingtypes.ValidatorSigningInfo, error) } diff --git a/tests/integration/staking_precompile_suite.go b/tests/integration/staking_precompile_suite.go index 413f000a..e6749716 100644 --- a/tests/integration/staking_precompile_suite.go +++ b/tests/integration/staking_precompile_suite.go @@ -7,8 +7,8 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/functionx/fx-core/v8/contract" + stakingprecompile "github.com/functionx/fx-core/v8/precompiles/staking" "github.com/functionx/fx-core/v8/testutil/helpers" - "github.com/functionx/fx-core/v8/x/staking/precompile" ) type StakingPrecompileSuite struct { @@ -97,7 +97,7 @@ func (suite *StakingPrecompileSuite) AllowanceShares(valAddr string, owner, spen } func (suite *StakingPrecompileSuite) LogReward(logs []*ethtypes.Log, valAddr string, addr common.Address) *big.Int { - withdrawABI := precompile.NewWithdrawABI() + withdrawABI := stakingprecompile.NewWithdrawABI() for _, log := range logs { if log.Address.String() == contract.StakingAddress && log.Topics[0] == withdrawABI.Event.ID && diff --git a/x/crosschain/precompile/expected_keepers.go b/x/crosschain/precompile/expected_keepers.go deleted file mode 100644 index 74335440..00000000 --- a/x/crosschain/precompile/expected_keepers.go +++ /dev/null @@ -1,36 +0,0 @@ -package precompile - -import ( - "context" - "math/big" - - sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - - crosschaintypes "github.com/functionx/fx-core/v8/x/crosschain/types" - erc20types "github.com/functionx/fx-core/v8/x/erc20/types" -) - -type BankKeeper interface { - MintCoins(ctx context.Context, moduleName string, amounts sdk.Coins) error - SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoins(ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error -} - -type CrosschainKeeper interface { - ExecuteClaim(ctx sdk.Context, eventNonce uint64) error - BridgeCoinSupply(ctx context.Context, token, target string) (sdk.Coin, error) - CrosschainBaseCoin(ctx sdk.Context, from sdk.AccAddress, receipt string, amount, fee sdk.Coin, fxTarget *crosschaintypes.FxTarget, memo string, originToken bool) error - BridgeCallBaseCoin(ctx sdk.Context, from, refund, to common.Address, coins sdk.Coins, data, memo []byte, quoteId *big.Int, fxTarget *crosschaintypes.FxTarget, originTokenAmount sdkmath.Int) (uint64, error) - GetBaseDenomByErc20(ctx sdk.Context, erc20Addr common.Address) (erc20types.ERC20Token, error) - - HasOracleAddrByExternalAddr(ctx sdk.Context, externalAddress string) bool - GetOracleAddrByExternalAddr(ctx sdk.Context, externalAddress string) (sdk.AccAddress, bool) - GetOracle(ctx sdk.Context, oracleAddr sdk.AccAddress) (oracle crosschaintypes.Oracle, found bool) -} - -type GovKeeper interface { - CheckDisabledPrecompiles(ctx sdk.Context, contractAddress common.Address, methodId []byte) error -}