Skip to content

Commit

Permalink
feature: GAMetaTx initial struct
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed Aug 13, 2019
1 parent a9af711 commit 43cef35
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions aeternity/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,3 +1173,56 @@ func NewGAAttachTx(OwnerID string, AccountNonce uint64, Code string, AuthFunc []
CallData: CallData,
}
}

// GAMetaTx wraps a normal Tx (that is not a GAAttachTx) that will only be
// executed if the contract located at GaID returns true
type GAMetaTx struct {
GaID string
AuthData string
AbiVersion uint16
Gas big.Int
GasPrice big.Int
Fee big.Int
TTL uint64
Tx Tx
}

// RLP returns a byte serialized representation
func (tx *GAMetaTx) RLP() (rlpRawMsg []byte, err error) {
gaID, err := buildIDTag(IDTagContract, tx.GaID)
if err != nil {
return
}
authDataBinary, err := Decode(tx.AuthData)
if err != nil {
return
}

rlpRawMsg, err = buildRLPMessage(
ObjectTagGeneralizedAccountMetaTransaction,
rlpMessageVersion,
gaID,
authDataBinary,
tx.AbiVersion,
tx.Fee,
tx.Gas,
tx.GasPrice,
tx.TTL,
tx.Tx,
)
return
}

// NewGAMetaTx creates a GAMetaTx
func NewGAMetaTx(GaID string, AuthData string, AbiVersion uint16, Gas big.Int, GasPrice big.Int, Fee big.Int, TTL uint64, Tx Tx) GAMetaTx {
return GAMetaTx{
GaID: GaID,
AuthData: AuthData,
AbiVersion: AbiVersion,
Gas: Gas,
GasPrice: GasPrice,
Fee: Fee,
TTL: TTL,
Tx: Tx,
}
}

0 comments on commit 43cef35

Please sign in to comment.