From 25b49304bc21259cf88ac560564f0bc9a190e504 Mon Sep 17 00:00:00 2001 From: dreamer Date: Thu, 18 Apr 2024 17:42:27 +0800 Subject: [PATCH] format code --- contracts/erc20_test.go | 7 +++---- modules/farm/keeper/proposal_hook.go | 7 ++++--- modules/farm/types/params.go | 6 +++--- modules/token/depinject.go | 1 - modules/token/keeper/erc20_test.go | 2 +- modules/token/keeper/evm.go | 4 ++-- modules/token/keeper/evm_hook.go | 8 ++++---- modules/token/keeper/legacy_msg_server.go | 6 +++--- modules/token/keeper/token.go | 3 +-- modules/token/simulation/operations.go | 4 ++-- modules/token/types/expected_keepers.go | 5 ++--- simapp/mocks/depinject.go | 6 +++--- simapp/mocks/evm.go | 6 +++--- types/evm.go | 3 +-- 14 files changed, 32 insertions(+), 36 deletions(-) diff --git a/contracts/erc20_test.go b/contracts/erc20_test.go index dc222137..d287b7ef 100644 --- a/contracts/erc20_test.go +++ b/contracts/erc20_test.go @@ -6,9 +6,8 @@ import ( "github.com/irisnet/irismod/contracts" ) - func TestERC20(t *testing.T) { - for k,v := range contracts.ERC20TokenContract.ABI.Events { - t.Logf("event:%s ,id: %s", k,v.ID) + for k, v := range contracts.ERC20TokenContract.ABI.Events { + t.Logf("event:%s ,id: %s", k, v.ID) } -} \ No newline at end of file +} diff --git a/modules/farm/keeper/proposal_hook.go b/modules/farm/keeper/proposal_hook.go index 0d8bbffe..7b985ab5 100644 --- a/modules/farm/keeper/proposal_hook.go +++ b/modules/farm/keeper/proposal_hook.go @@ -20,7 +20,7 @@ func NewGovHook(k Keeper) GovHook { return GovHook{k} } -//AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral +// AfterProposalFailedMinDeposit callback when the proposal is deleted due to insufficient collateral func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) { info, has := h.k.GetEscrowInfo(ctx, proposalID) if !has { @@ -30,7 +30,7 @@ func (h GovHook) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint6 h.k.refundEscrow(ctx, info) } -//AfterProposalVotingPeriodEnded callback when proposal voting is complete +// AfterProposalVotingPeriodEnded callback when proposal voting is complete func (h GovHook) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) { info, has := h.k.GetEscrowInfo(ctx, proposalID) if !has { @@ -60,7 +60,8 @@ func (h GovHook) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) {} // AfterProposalDeposit is a function that... // // takes in ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress. -func (h GovHook) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) {} +func (h GovHook) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) { +} // AfterProposalVote is a Go function. // diff --git a/modules/farm/types/params.go b/modules/farm/types/params.go index 72818e58..ee8efb10 100644 --- a/modules/farm/types/params.go +++ b/modules/farm/types/params.go @@ -20,9 +20,9 @@ func NewParams(createPoolFee sdk.Coin, maxRewardCategories uint32, taxRate sdk.D // DefaultParams returns a default set of parameters. func DefaultParams() Params { return NewParams( - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), - 2, - sdk.NewDecWithPrec(4, 1) , + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5000)), + 2, + sdk.NewDecWithPrec(4, 1), ) } diff --git a/modules/token/depinject.go b/modules/token/depinject.go index 7337668c..5e8492c0 100644 --- a/modules/token/depinject.go +++ b/modules/token/depinject.go @@ -59,7 +59,6 @@ type TokenOutputs struct { TokenKeeper keeper.Keeper Module appmodule.AppModule - } // ProvideModule provides a module for the token with the given inputs and returns the token keeper and module. diff --git a/modules/token/keeper/erc20_test.go b/modules/token/keeper/erc20_test.go index 35d97b01..2154f32c 100644 --- a/modules/token/keeper/erc20_test.go +++ b/modules/token/keeper/erc20_test.go @@ -92,7 +92,7 @@ func (suite *KeeperTestSuite) TestSwapToERC20() { sender := token.GetOwner() receiver := common.BytesToAddress(sender.Bytes()) - balanceBefore := suite.bk.GetBalance(suite.ctx, sender,token.MinUnit) + balanceBefore := suite.bk.GetBalance(suite.ctx, sender, token.MinUnit) suite.Run("swap to erc20", func() { amount := sdk.NewCoin(token.MinUnit, sdk.NewInt(1e18)) diff --git a/modules/token/keeper/evm.go b/modules/token/keeper/evm.go index 4a7df0bf..1eaa7e61 100644 --- a/modules/token/keeper/evm.go +++ b/modules/token/keeper/evm.go @@ -38,7 +38,7 @@ func (k Keeper) CallEVM( method string, args ...interface{}, ) (*types.Result, error) { - data, err := contractABI.Pack(method, args...) + data, err := contractABI.Pack(method, args...) if err != nil { return nil, errorsmod.Wrap( tokentypes.ErrABIPack, @@ -123,4 +123,4 @@ func (k Keeper) CallEVMWithData( } return res, nil -} \ No newline at end of file +} diff --git a/modules/token/keeper/evm_hook.go b/modules/token/keeper/evm_hook.go index 8db35054..0a6cd39c 100644 --- a/modules/token/keeper/evm_hook.go +++ b/modules/token/keeper/evm_hook.go @@ -61,7 +61,7 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip if len(eventArgs) != 3 { return errorsmod.Wrapf( - types.ErrInvalidContract, + types.ErrInvalidContract, "swapToNative event has wrong number of parameters, expected 3, actual: %d", len(eventArgs), ) @@ -70,7 +70,7 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip to, ok := eventArgs[1].(string) if !ok || len(to) == 0 { return errorsmod.Wrap( - types.ErrInvalidContract, + types.ErrInvalidContract, "swapToNative event `to` parameters is invalid, expected string", ) } @@ -78,7 +78,7 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip receiver, err := sdk.AccAddressFromBech32(to) if err != nil { return errorsmod.Wrapf( - types.ErrInvalidContract, + types.ErrInvalidContract, "swapToNative event `to` parameters is invalid, expected iaa address, actual: %s", to, ) @@ -87,7 +87,7 @@ func (hook erc20Hook) PostTxProcessing(ctx sdk.Context, msg core.Message, receip amount, ok := eventArgs[2].(*big.Int) if !ok || amount.Cmp(big.NewInt(0)) == 0 { return errorsmod.Wrap( - types.ErrInvalidContract, + types.ErrInvalidContract, "swapToNative event `amount` parameters is invalid, expected `*big.Int`", ) } diff --git a/modules/token/keeper/legacy_msg_server.go b/modules/token/keeper/legacy_msg_server.go index c53b0a17..75aa2971 100644 --- a/modules/token/keeper/legacy_msg_server.go +++ b/modules/token/keeper/legacy_msg_server.go @@ -63,9 +63,9 @@ func (m legacyMsgServer) MintToken(goCtx context.Context, msg *v1beta1.MsgMintTo return &v1beta1.MsgMintTokenResponse{}, err } _, err = m.server.MintToken(goCtx, &v1.MsgMintToken{ - Coin: coin, - Receiver: msg.To, - Owner: msg.Owner, + Coin: coin, + Receiver: msg.To, + Owner: msg.Owner, }) return &v1beta1.MsgMintTokenResponse{}, err } diff --git a/modules/token/keeper/token.go b/modules/token/keeper/token.go index cc7b0cc8..5ac0621f 100644 --- a/modules/token/keeper/token.go +++ b/modules/token/keeper/token.go @@ -87,7 +87,6 @@ func (k Keeper) HasMinUint(ctx sdk.Context, minUint string) bool { return store.Has(types.KeyMinUint(minUint)) } - // HasContract asserts a token exists by contract func (k Keeper) HasContract(ctx sdk.Context, contract string) bool { store := ctx.KVStore(k.storeKey) @@ -320,7 +319,7 @@ func (k Keeper) setDenomMetaData(ctx sdk.Context, token v1.Token) { k.bankKeeper.SetDenomMetaData(ctx, denomMetaData) } -func(k Keeper) assertTokenValid(ctx sdk.Context, token v1.Token) error { +func (k Keeper) assertTokenValid(ctx sdk.Context, token v1.Token) error { if k.HasSymbol(ctx, token.Symbol) { return errorsmod.Wrapf( types.ErrSymbolAlreadyExists, diff --git a/modules/token/simulation/operations.go b/modules/token/simulation/operations.go index 8712ca61..75ca34a3 100644 --- a/modules/token/simulation/operations.go +++ b/modules/token/simulation/operations.go @@ -281,8 +281,8 @@ func SimulateMintToken( Denom: token.GetMinUnit(), Amount: sdkmath.NewIntWithDecimal(100, int(token.GetScale())), }, - Receiver: simToAccount.Address.String(), - Owner: token.GetOwner().String(), + Receiver: simToAccount.Address.String(), + Owner: token.GetOwner().String(), } ownerAccount, found := simtypes.FindAccount(accs, token.GetOwner()) diff --git a/modules/token/types/expected_keepers.go b/modules/token/types/expected_keepers.go index 0eaf71ec..9f46852a 100644 --- a/modules/token/types/expected_keepers.go +++ b/modules/token/types/expected_keepers.go @@ -65,12 +65,11 @@ type EVMKeeper interface { } // ICS20Keeper defines the expected keeper of ICS20 -type ICS20Keeper interface{ +type ICS20Keeper interface { HasTrace(ctx sdk.Context, denom string) bool } // Hook defines the hook interface type Hook interface { - PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error + PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error } - diff --git a/simapp/mocks/depinject.go b/simapp/mocks/depinject.go index 5abe9fb4..2ba691b4 100644 --- a/simapp/mocks/depinject.go +++ b/simapp/mocks/depinject.go @@ -12,8 +12,8 @@ import ( // Returns a tokentypes.EVMKeeper. func ProvideEVMKeeper() tokentypes.EVMKeeper { return &evm{ - erc20s: make(map[common.Address]*erc20), - } + erc20s: make(map[common.Address]*erc20), + } } // ProvideICS20Keeper returns an instance of tokentypes.ICS20Keeper. @@ -22,4 +22,4 @@ func ProvideEVMKeeper() tokentypes.EVMKeeper { // Returns a tokentypes.ICS20Keeper. func ProvideICS20Keeper() tokentypes.ICS20Keeper { return &transferKeeper{} -} \ No newline at end of file +} diff --git a/simapp/mocks/evm.go b/simapp/mocks/evm.go index b585f658..89638e56 100644 --- a/simapp/mocks/evm.go +++ b/simapp/mocks/evm.go @@ -50,7 +50,7 @@ func (e *evm) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogge balance: make(map[common.Address]*big.Int), } return &types.Result{ - Hash: contractAddr.Hex(), + Hash: contractAddr.Hex(), }, nil } @@ -114,14 +114,14 @@ func (erc20 erc20) call(method *abi.Method, data []byte) ([]byte, error) { case "decimals": return method.Outputs.Pack(erc20.scale) case "balanceOf": - balance,ok := erc20.balance[args[0].(common.Address)] + balance, ok := erc20.balance[args[0].(common.Address)] if !ok { return method.Outputs.Pack(big.NewInt(0)) } return method.Outputs.Pack(balance) case "mint": to := args[0].(common.Address) - balance,ok := erc20.balance[args[0].(common.Address)] + balance, ok := erc20.balance[args[0].(common.Address)] if !ok { balance = big.NewInt(0) } diff --git a/types/evm.go b/types/evm.go index 4811dd4e..70b8e2a1 100644 --- a/types/evm.go +++ b/types/evm.go @@ -164,6 +164,5 @@ func (s *HexString) UnmarshalJSON(data []byte) error { // CompiledContract contains compiled bytecode and abi type CompiledContract struct { ABI abi.ABI - Bin HexString + Bin HexString } -