Skip to content

Commit

Permalink
construction/payloads: Transaction input field should be data accordi… (
Browse files Browse the repository at this point in the history
#53)

* construction/payloads: Transaction input field should be data according to Ethereum spec

* Rename data_ to twData
  • Loading branch information
akramhussein authored Jul 26, 2021
1 parent 68306c7 commit 741feac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions services/construction_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (s *ConstructionAPIService) ConstructionPayloads(
From: checkFrom,
To: checkTo,
Value: amount,
Input: tx.Data(),
Data: tx.Data(),
Nonce: tx.Nonce(),
GasPrice: gasPrice,
GasLimit: tx.Gas(),
Expand Down Expand Up @@ -308,7 +308,7 @@ func (s *ConstructionAPIService) ConstructionCombine(
unsignedTx.Value,
unsignedTx.GasLimit,
unsignedTx.GasPrice,
unsignedTx.Input,
unsignedTx.Data,
)

signer := ethTypes.NewEIP155Signer(unsignedTx.ChainID)
Expand Down Expand Up @@ -366,7 +366,7 @@ func (s *ConstructionAPIService) ConstructionParse(

tx.To = t.To().String()
tx.Value = t.Value()
tx.Input = t.Data()
tx.Data = t.Data()
tx.Nonce = t.Nonce()
tx.GasPrice = t.GasPrice()
tx.GasLimit = t.Gas()
Expand Down
2 changes: 1 addition & 1 deletion services/construction_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestConstructionService(t *testing.T) {
}, metadataResponse)

// Test Payloads
unsignedRaw := `{"from":"0xe3a5B4d7f79d64088C8d4ef153A7DDe2B2d47309","to":"0x57B414a0332B5CaB885a451c2a28a07d1e9b8a8d","value":"0x9864aac3510d02","input":"0x","nonce":"0x0","gas_price":"0x3b9aca00","gas":"0x5208","chain_id":"0x3"}` // nolint
unsignedRaw := `{"from":"0xe3a5B4d7f79d64088C8d4ef153A7DDe2B2d47309","to":"0x57B414a0332B5CaB885a451c2a28a07d1e9b8a8d","value":"0x9864aac3510d02","data":"0x","nonce":"0x0","gas_price":"0x3b9aca00","gas":"0x5208","chain_id":"0x3"}` // nolint
payloadsResponse, err := servicer.ConstructionPayloads(ctx, &types.ConstructionPayloadsRequest{
NetworkIdentifier: networkIdentifier,
Operations: ops,
Expand Down
10 changes: 5 additions & 5 deletions services/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ type transaction struct {
From string `json:"from"`
To string `json:"to"`
Value *big.Int `json:"value"`
Input []byte `json:"input"`
Data []byte `json:"data"`
Nonce uint64 `json:"nonce"`
GasPrice *big.Int `json:"gas_price"`
GasLimit uint64 `json:"gas"`
Expand All @@ -140,7 +140,7 @@ type transactionWire struct {
From string `json:"from"`
To string `json:"to"`
Value string `json:"value"`
Input string `json:"input"`
Data string `json:"data"`
Nonce string `json:"nonce"`
GasPrice string `json:"gas_price"`
GasLimit string `json:"gas"`
Expand All @@ -152,7 +152,7 @@ func (t *transaction) MarshalJSON() ([]byte, error) {
From: t.From,
To: t.To,
Value: hexutil.EncodeBig(t.Value),
Input: hexutil.Encode(t.Input),
Data: hexutil.Encode(t.Data),
Nonce: hexutil.EncodeUint64(t.Nonce),
GasPrice: hexutil.EncodeBig(t.GasPrice),
GasLimit: hexutil.EncodeUint64(t.GasLimit),
Expand All @@ -173,7 +173,7 @@ func (t *transaction) UnmarshalJSON(data []byte) error {
return err
}

input, err := hexutil.Decode(tw.Input)
twData, err := hexutil.Decode(tw.Data)
if err != nil {
return err
}
Expand Down Expand Up @@ -201,7 +201,7 @@ func (t *transaction) UnmarshalJSON(data []byte) error {
t.From = tw.From
t.To = tw.To
t.Value = value
t.Input = input
t.Data = twData
t.Nonce = nonce
t.GasPrice = gasPrice
t.GasLimit = gasLimit
Expand Down

0 comments on commit 741feac

Please sign in to comment.