github.com/hyperledger/burrow@v0.34.5-0.20220512172541-77f09336001d/txs/payload/call_tx.go (about) 1 package payload 2 3 import ( 4 "fmt" 5 6 "github.com/hyperledger/burrow/acm/acmstate" 7 "github.com/hyperledger/burrow/crypto" 8 ) 9 10 func NewCallTx(st acmstate.AccountGetter, from *crypto.PublicKey, to *crypto.Address, data []byte, 11 amt, gasLimit, fee uint64) (*CallTx, error) { 12 13 addr := from.GetAddress() 14 acc, err := st.GetAccount(addr) 15 if err != nil { 16 return nil, err 17 } 18 if acc == nil { 19 return nil, fmt.Errorf("NewCallTx: could not find account with address %v", addr) 20 } 21 22 sequence := acc.Sequence + 1 23 return NewCallTxWithSequence(from, to, data, amt, gasLimit, fee, sequence), nil 24 } 25 26 func NewCallTxWithSequence(from *crypto.PublicKey, to *crypto.Address, data []byte, 27 amt, gasLimit, fee, sequence uint64) *CallTx { 28 input := &TxInput{ 29 Address: from.GetAddress(), 30 Amount: amt, 31 Sequence: sequence, 32 } 33 34 return &CallTx{ 35 Input: input, 36 Address: to, 37 GasLimit: gasLimit, 38 Fee: fee, 39 Data: data, 40 } 41 } 42 43 func (tx *CallTx) Type() Type { 44 return TypeCall 45 } 46 func (tx *CallTx) GetInputs() []*TxInput { 47 return []*TxInput{tx.Input} 48 } 49 50 func (tx *CallTx) String() string { 51 return fmt.Sprintf("CallTx{%v -> %s: %v}", tx.Input, tx.Address, tx.Data) 52 } 53 54 func (tx *CallTx) Any() *Any { 55 return &Any{ 56 CallTx: tx, 57 } 58 }