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

@@ -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{