Skip to content

Commit

Permalink
Change 'non-whitelisted' to 'unregistered' in public error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
ezdac committed Aug 21, 2024
1 parent f47600e commit bc79cdd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions common/exchange/rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (

var (
unitRate = big.NewRat(1, 1)
// ErrNonWhitelistedFeeCurrency is returned if the currency specified to use for the fees
// ErrUnregisteredFeeCurrency is returned if the currency specified to use for the fees
// isn't one of the currencies whitelisted for that purpose.
ErrNonWhitelistedFeeCurrency = errors.New("non-whitelisted fee currency address")
ErrUnregisteredFeeCurrency = errors.New("unregistered fee-currency address")
)

// ConvertCurrency does an exchange conversion from currencyFrom to currencyTo of the value given.
Expand All @@ -35,7 +35,7 @@ func ConvertCurrencyToCelo(exchangeRates common.ExchangeRates, currencyAmount *b
}
exchangeRate, ok := exchangeRates[*feeCurrency]
if !ok {
return nil, fmt.Errorf("could not convert from fee currency to native (fee-currency=%s): %w ", feeCurrency, ErrNonWhitelistedFeeCurrency)
return nil, fmt.Errorf("could not convert from fee currency to native (fee-currency=%s): %w ", feeCurrency, ErrUnregisteredFeeCurrency)
}
return new(big.Int).Div(new(big.Int).Mul(currencyAmount, exchangeRate.Denom()), exchangeRate.Num()), nil
}
Expand All @@ -46,7 +46,7 @@ func ConvertCeloToCurrency(exchangeRates common.ExchangeRates, feeCurrency *comm
}
exchangeRate, ok := exchangeRates[*feeCurrency]
if !ok {
return nil, fmt.Errorf("could not convert from native to fee currency (fee-currency=%s): %w ", feeCurrency, ErrNonWhitelistedFeeCurrency)
return nil, fmt.Errorf("could not convert from native to fee currency (fee-currency=%s): %w ", feeCurrency, ErrUnregisteredFeeCurrency)
}
return new(big.Int).Div(new(big.Int).Mul(celoAmount, exchangeRate.Num()), exchangeRate.Denom()), nil
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/fee_currencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func DebitFees(evm *vm.EVM, feeCurrency *common.Address, address common.Address,

maxIntrinsicGasCost, ok := common.MaxAllowedIntrinsicGasCost(evm.Context.FeeCurrencyContext.IntrinsicGasCosts, feeCurrency)
if !ok {
return 0, exchange.ErrNonWhitelistedFeeCurrency
return 0, exchange.ErrUnregisteredFeeCurrency
}

leftoverGas, err := evm.CallWithABI(
Expand Down Expand Up @@ -93,7 +93,7 @@ func CreditFees(
}
maxAllowedGasForDebitAndCredit, ok := common.MaxAllowedIntrinsicGasCost(evm.Context.FeeCurrencyContext.IntrinsicGasCosts, feeCurrency)
if !ok {
return exchange.ErrNonWhitelistedFeeCurrency
return exchange.ErrUnregisteredFeeCurrency
}

maxAllowedGasForCredit := maxAllowedGasForDebitAndCredit - gasUsedDebit
Expand Down Expand Up @@ -123,7 +123,7 @@ func CreditFees(
intrinsicGas, ok := common.CurrencyIntrinsicGasCost(evm.Context.FeeCurrencyContext.IntrinsicGasCosts, feeCurrency)
if !ok {
// this will never happen
return exchange.ErrNonWhitelistedFeeCurrency
return exchange.ErrUnregisteredFeeCurrency
}
gasUsedForDebitAndCredit := gasUsedDebit + gasUsed
if gasUsedForDebitAndCredit > intrinsicGas {
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b
if feeCurrency != nil {
intrinsicGasForFeeCurrency, ok := common.CurrencyIntrinsicGasCost(feeIntrinsicGas, feeCurrency)
if !ok {
return 0, exchange.ErrNonWhitelistedFeeCurrency
return 0, exchange.ErrUnregisteredFeeCurrency
}
if (math.MaxUint64 - gas) < intrinsicGasForFeeCurrency {
return 0, ErrGasUintOverflow
Expand Down
2 changes: 1 addition & 1 deletion core/txpool/celo_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func CeloValidateTransaction(tx *types.Transaction, head *types.Header,
return err
}
if !common.IsCurrencyAllowed(currencyCtx.ExchangeRates, tx.FeeCurrency()) {
return exchange.ErrNonWhitelistedFeeCurrency
return exchange.ErrUnregisteredFeeCurrency
}

return nil
Expand Down

0 comments on commit bc79cdd

Please sign in to comment.