Merge pull request #142 from hermeznetwork/feature/api-boilerplate

Add GET histroy-transactions endpoint
This commit is contained in:
Eduard S
2020-09-22 15:39:13 +02:00
committed by GitHub
21 changed files with 4114 additions and 88 deletions

View File

@@ -1,5 +1,7 @@
package common
import "math"
// Fee is a type that represents the percentage of tokens that will be paid in a transaction
// to incentivaise the materialization of it
type Fee float64
@@ -16,6 +18,20 @@ type RecommendedFee struct {
// FeeSelector is used to select a percentage from the FeePlan.
type FeeSelector uint8
// Percentage returns the associated percentage of the FeeSelector
func (f FeeSelector) Percentage() float64 {
if f == 0 {
return 0
//nolint:gomnd
} else if f <= 32 { //nolint:gomnd
return math.Pow(10, -24+(float64(f)/2)) //nolint:gomnd
} else if f <= 223 { //nolint:gomnd
return math.Pow(10, -8+(0.041666666666667*(float64(f)-32))) //nolint:gomnd
} else {
return math.Pow(10, float64(f)-224) //nolint:gomnd
}
}
// MaxFeePlan is the maximum value of the FeePlan
const MaxFeePlan = 256

View File

@@ -27,15 +27,15 @@ const (
// TxTypeCreateAccountDepositTransfer represents L1->L2 transfer + L2->L2 transfer
TxTypeCreateAccountDepositTransfer TxType = "CreateAccountDepositTransfer"
// TxTypeDepositTransfer TBD
TxTypeDepositTransfer TxType = "TxTypeDepositTransfer"
TxTypeDepositTransfer TxType = "DepositTransfer"
// TxTypeForceTransfer TBD
TxTypeForceTransfer TxType = "TxTypeForceTransfer"
TxTypeForceTransfer TxType = "ForceTransfer"
// TxTypeForceExit TBD
TxTypeForceExit TxType = "TxTypeForceExit"
TxTypeForceExit TxType = "ForceExit"
// TxTypeTransferToEthAddr TBD
TxTypeTransferToEthAddr TxType = "TxTypeTransferToEthAddr"
TxTypeTransferToEthAddr TxType = "TransferToEthAddr"
// TxTypeTransferToBJJ TBD
TxTypeTransferToBJJ TxType = "TxTypeTransferToBJJ"
TxTypeTransferToBJJ TxType = "TransferToBJJ"
)
// Tx is a struct used by the TxSelector & BatchBuilder as a generic type generated from L1Tx & PoolL2Tx