Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Apr 18, 2024
1 parent 243e67b commit 25b4930
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 36 deletions.
7 changes: 3 additions & 4 deletions contracts/erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
7 changes: 4 additions & 3 deletions modules/farm/keeper/proposal_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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.
//
Expand Down
6 changes: 3 additions & 3 deletions modules/farm/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
}

Expand Down
1 change: 0 additions & 1 deletion modules/token/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion modules/token/keeper/erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions modules/token/keeper/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -123,4 +123,4 @@ func (k Keeper) CallEVMWithData(
}

return res, nil
}
}
8 changes: 4 additions & 4 deletions modules/token/keeper/evm_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand All @@ -70,15 +70,15 @@ 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",
)
}

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,
)
Expand All @@ -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`",
)
}
Expand Down
6 changes: 3 additions & 3 deletions modules/token/keeper/legacy_msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions modules/token/keeper/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions modules/token/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
5 changes: 2 additions & 3 deletions modules/token/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

6 changes: 3 additions & 3 deletions simapp/mocks/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -22,4 +22,4 @@ func ProvideEVMKeeper() tokentypes.EVMKeeper {
// Returns a tokentypes.ICS20Keeper.
func ProvideICS20Keeper() tokentypes.ICS20Keeper {
return &transferKeeper{}
}
}
6 changes: 3 additions & 3 deletions simapp/mocks/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions types/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 25b4930

Please sign in to comment.