Add ProcessTxs send fees to Coordinator accounts

This commit is contained in:
arnaucube
2020-10-26 17:35:23 +01:00
parent 382bcfeee1
commit 8f24aa93c9
17 changed files with 195 additions and 65 deletions

View File

@@ -60,7 +60,7 @@ func NewL1Tx(l1Tx *L1Tx) (*L1Tx, error) {
if l1Tx.ToIdx == Idx(0) {
txType = TxTypeDeposit
} else if l1Tx.ToIdx == Idx(1) {
txType = TxTypeExit
txType = TxTypeForceExit
} else if l1Tx.ToIdx >= IdxUserThreshold {
if l1Tx.LoadAmount.Int64() == int64(0) {
txType = TxTypeForceTransfer

View File

@@ -250,6 +250,7 @@ func (tx PoolL2Tx) Tx() Tx {
FromIdx: tx.FromIdx,
ToIdx: tx.ToIdx,
Amount: tx.Amount,
TokenID: tx.TokenID,
Nonce: &tx.Nonce,
Fee: &tx.Fee,
Type: tx.Type,

View File

@@ -1,6 +1,7 @@
package common
import (
"bytes"
"database/sql/driver"
"encoding/hex"
"errors"
@@ -145,6 +146,33 @@ type Tx struct {
Nonce *Nonce `meddler:"nonce"`
}
func (tx *Tx) String() string {
buf := bytes.NewBufferString("")
fmt.Fprintf(buf, "Type: %s, ", tx.Type)
fmt.Fprintf(buf, "FromIdx: %s, ", tx.FromIdx)
if tx.Type == TxTypeTransfer ||
tx.Type == TxTypeDepositTransfer ||
tx.Type == TxTypeCreateAccountDepositTransfer {
fmt.Fprintf(buf, "ToIdx: %s, ", tx.ToIdx)
}
if tx.Type == TxTypeDeposit ||
tx.Type == TxTypeDepositTransfer ||
tx.Type == TxTypeCreateAccountDepositTransfer {
fmt.Fprintf(buf, "LoadAmount: %d, ", tx.LoadAmount)
}
if tx.Type != TxTypeDeposit {
fmt.Fprintf(buf, "Amount: %s, ", tx.Amount)
}
if tx.Type == TxTypeTransfer ||
tx.Type == TxTypeDepositTransfer ||
tx.Type == TxTypeCreateAccountDepositTransfer {
fmt.Fprintf(buf, "Fee: %d, ", tx.Fee)
}
fmt.Fprintf(buf, "TokenID: %d\n", tx.TokenID)
return buf.String()
}
// L1Tx returns a *L1Tx from the Tx
func (tx *Tx) L1Tx() (*L1Tx, error) {
return &L1Tx{