Skip to content

Commit

Permalink
rename const
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy committed Sep 26, 2023
1 parent 408def7 commit 34a6fbf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions x/cronos/keeper/precompiles/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (
)

const (
EVMDenomPrefix = "evm/"
MintName = "mint"
BurnName = "burn"
BalanceOfName = "balanceOf"
TransferName = "transfer"
EVMDenomPrefix = "evm/"
MintMethodName = "mint"
BurnMethodName = "burn"
BalanceOfMethodName = "balanceOf"
TransferMethodName = "transfer"
)

var (
Expand Down Expand Up @@ -62,12 +62,12 @@ func (bc *BankContract) RequiredGas(input []byte) uint64 {
return 0
}
switch method.Name {
case MintName, BurnName:
case MintMethodName, BurnMethodName:
return 1000
case BalanceOfName:
return 1000
case TransferName:
case BalanceOfMethodName:
return 1000
case TransferMethodName:
return 150000
default:
return 0
}
Expand Down Expand Up @@ -98,7 +98,7 @@ func (bc *BankContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) (
stateDB := evm.StateDB.(ExtStateDB)
precompileAddr := bc.Address()
switch method.Name {
case MintName, BurnName:
case MintMethodName, BurnMethodName:
if readonly {
return nil, errors.New("the method is not readonly")
}
Expand Down Expand Up @@ -142,7 +142,7 @@ func (bc *BankContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) (
return nil, err
}
return method.Outputs.Pack(true)
case BalanceOfName:
case BalanceOfMethodName:
args, err := method.Inputs.Unpack(contract.Input[4:])
if err != nil {
return nil, errors.New("fail to unpack input arguments")
Expand All @@ -152,7 +152,7 @@ func (bc *BankContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) (
// query from storage
balance := bc.bankKeeper.GetBalance(stateDB.CacheContext(), sdk.AccAddress(addr.Bytes()), EVMDenom(token)).Amount.BigInt()
return method.Outputs.Pack(balance)
case TransferName:
case TransferMethodName:
if readonly {
return nil, errors.New("the method is not readonly")
}
Expand Down
18 changes: 9 additions & 9 deletions x/cronos/keeper/precompiles/ica.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
)

const (
RegisterAccountName = "registerAccount"
QueryAccountName = "queryAccount"
SubmitMsgsName = "submitMsgs"
RegisterAccountMethodName = "registerAccount"
QueryAccountMethodName = "queryAccount"
SubmitMsgsMethodName = "submitMsgs"
)

var (
Expand Down Expand Up @@ -63,11 +63,11 @@ func (ic *IcaContract) RequiredGas(input []byte) uint64 {
return 0
}
switch method.Name {
case RegisterAccountName:
case RegisterAccountMethodName:
return 1000
case QueryAccountName:
case QueryAccountMethodName:
return 1000
case SubmitMsgsName:
case SubmitMsgsMethodName:
return 1000
default:
return 0
Expand All @@ -93,7 +93,7 @@ func (ic *IcaContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([
converter := cronosevents.IcaConvertEvent
var execErr error
switch method.Name {
case RegisterAccountName:
case RegisterAccountMethodName:
if readonly {
return nil, errors.New("the method is not readonly")
}
Expand All @@ -115,7 +115,7 @@ func (ic *IcaContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([
return nil, execErr
}
return method.Outputs.Pack(true)
case QueryAccountName:
case QueryAccountMethodName:
args, err := method.Inputs.Unpack(contract.Input[4:])
if err != nil {
return nil, errors.New("fail to unpack input arguments")
Expand All @@ -137,7 +137,7 @@ func (ic *IcaContract) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([
icaAddress = response.InterchainAccountAddress
}
return method.Outputs.Pack(icaAddress)
case SubmitMsgsName:
case SubmitMsgsMethodName:
if readonly {
return nil, errors.New("the method is not readonly")
}
Expand Down

0 comments on commit 34a6fbf

Please sign in to comment.