Skip to content

Commit

Permalink
marshal to bin [goreleaser]
Browse files Browse the repository at this point in the history
  • Loading branch information
trajan0x committed Oct 10, 2024
1 parent 3ad23c2 commit d325d3f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ethergo/util/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
gasPriceAttr = "tx.GasPrice"
gasFeeCapAttr = "tx.GasFeeCap"
gasTipCapAttr = "tx.GasTipCap"
txRawAttr = "tx.Raw"
)

// TxToAttributes converts a transaction to a slice of attribute.KeyValue.
Expand All @@ -33,6 +34,12 @@ func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue {
} else {
from = call.From.Hex()
}

bin, err := transaction.MarshalBinary()
if err != nil {
bin = []byte(fmt.Sprintf("could not be marshalled: %v", err))
}

var attributes = []attribute.KeyValue{
attribute.String(hashAttr, transaction.Hash().Hex()),
attribute.String(fromAttr, from),
Expand All @@ -46,6 +53,7 @@ func TxToAttributes(transaction *types.Transaction) []attribute.KeyValue {
// nolint: gosec
attribute.Int64(gasLimitAttr, int64(transaction.Gas())),
attribute.String(chainIDAttr, BigPtrToString(transaction.ChainId())),
attribute.String(txRawAttr, common.Bytes2Hex(bin))),

Check failure on line 56 in ethergo/util/attributes.go

View workflow job for this annotation

GitHub Actions / Build (1.22.x)

syntax error: unexpected ) in composite literal; possibly missing comma or }

Check failure on line 56 in ethergo/util/attributes.go

View workflow job for this annotation

GitHub Actions / Go Generate (Module Changes) (services/explorer)

expected operand, found ','

Check failure on line 56 in ethergo/util/attributes.go

View workflow job for this annotation

GitHub Actions / Go Generate (Module Changes) (services/scribe)

expected operand, found ','
}

if transaction.Type() == types.LegacyTxType && transaction.GasPrice() != nil {

Check failure on line 59 in ethergo/util/attributes.go

View workflow job for this annotation

GitHub Actions / Build (1.22.x)

syntax error: non-declaration statement outside function body

Check failure on line 59 in ethergo/util/attributes.go

View workflow job for this annotation

GitHub Actions / Go Generate (Module Changes) (services/explorer)

missing ',' in composite literal

Check failure on line 59 in ethergo/util/attributes.go

View workflow job for this annotation

GitHub Actions / Go Generate (Module Changes) (services/scribe)

missing ',' in composite literal
Expand Down

0 comments on commit d325d3f

Please sign in to comment.