Abstracts away from pubkey addr -> app/chain-specific "actors"
This commit is contained in:
+5
-5
@@ -67,14 +67,14 @@ func NewRaw(d []byte) Raw {
|
||||
|
||||
// Fee attaches a fee payment to the embedded tx
|
||||
type Fee struct {
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Fee types.Coin `json:"fee"`
|
||||
Payer data.Bytes `json:"payer"` // the address who pays the fee
|
||||
Tx basecoin.Tx `json:"tx"`
|
||||
Fee types.Coin `json:"fee"`
|
||||
Payer basecoin.Actor `json:"payer"` // the address who pays the fee
|
||||
// Gas types.Coin `json:"gas"` // ?????
|
||||
}
|
||||
|
||||
func NewFee(tx basecoin.Tx, fee types.Coin, addr []byte) *Fee {
|
||||
return &Fee{Tx: tx, Fee: fee, Payer: addr}
|
||||
func NewFee(tx basecoin.Tx, fee types.Coin, payer basecoin.Actor) *Fee {
|
||||
return &Fee{Tx: tx, Fee: fee, Payer: payer}
|
||||
}
|
||||
|
||||
func (f *Fee) ValidateBasic() error {
|
||||
|
||||
+11
-10
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/basecoin"
|
||||
"github.com/tendermint/go-wire/data"
|
||||
|
||||
"github.com/tendermint/basecoin/errors"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
@@ -13,13 +12,14 @@ import (
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type TxInput struct {
|
||||
Address data.Bytes `json:"address"`
|
||||
Coins types.Coins `json:"coins"`
|
||||
Sequence int `json:"sequence"` // Nonce: Must be 1 greater than the last committed TxInput
|
||||
Address basecoin.Actor `json:"address"`
|
||||
Coins types.Coins `json:"coins"`
|
||||
Sequence int `json:"sequence"` // Nonce: Must be 1 greater than the last committed TxInput
|
||||
}
|
||||
|
||||
func (txIn TxInput) ValidateBasic() error {
|
||||
if len(txIn.Address) != 20 {
|
||||
// TODO: knowledge of app-specific codings?
|
||||
if txIn.Address.App == "" {
|
||||
return errors.InvalidAddress()
|
||||
}
|
||||
if !txIn.Coins.IsValid() {
|
||||
@@ -38,7 +38,7 @@ func (txIn TxInput) String() string {
|
||||
return fmt.Sprintf("TxInput{%v,%v,%v}", txIn.Address, txIn.Coins, txIn.Sequence)
|
||||
}
|
||||
|
||||
func NewTxInput(addr []byte, coins types.Coins, sequence int) TxInput {
|
||||
func NewTxInput(addr basecoin.Actor, coins types.Coins, sequence int) TxInput {
|
||||
input := TxInput{
|
||||
Address: addr,
|
||||
Coins: coins,
|
||||
@@ -50,12 +50,13 @@ func NewTxInput(addr []byte, coins types.Coins, sequence int) TxInput {
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type TxOutput struct {
|
||||
Address data.Bytes `json:"address"`
|
||||
Coins types.Coins `json:"coins"`
|
||||
Address basecoin.Actor `json:"address"`
|
||||
Coins types.Coins `json:"coins"`
|
||||
}
|
||||
|
||||
func (txOut TxOutput) ValidateBasic() error {
|
||||
if len(txOut.Address) != 20 {
|
||||
// TODO: knowledge of app-specific codings?
|
||||
if txOut.Address.App == "" {
|
||||
return errors.InvalidAddress()
|
||||
}
|
||||
if !txOut.Coins.IsValid() {
|
||||
@@ -71,7 +72,7 @@ func (txOut TxOutput) String() string {
|
||||
return fmt.Sprintf("TxOutput{%X,%v}", txOut.Address, txOut.Coins)
|
||||
}
|
||||
|
||||
func NewTxOutput(addr []byte, coins types.Coins) TxOutput {
|
||||
func NewTxOutput(addr basecoin.Actor, coins types.Coins) TxOutput {
|
||||
output := TxOutput{
|
||||
Address: addr,
|
||||
Coins: coins,
|
||||
|
||||
Reference in New Issue
Block a user