Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: transaction metadata #64

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion filter/chainsync/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func WithPolicies(policyIds []string) ChainSyncOptionFunc {
}
}

//WithAssetFingerprints specifies the asset fingerprint (asset1xxx) to filter on
// WithAssetFingerprints specifies the asset fingerprint (asset1xxx) to filter on
func WithAssetFingerprints(assetFingerprints []string) ChainSyncOptionFunc {
return func(c *ChainSync) {
c.filterAssetFingerprints = assetFingerprints[:]
Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ module github.com/blinklabs-io/snek
go 1.19

require (
github.com/blinklabs-io/gouroboros v0.51.0
github.com/blinklabs-io/gouroboros v0.52.0
github.com/gen2brain/beeep v0.0.0-20230602101333-f384c29b62dd
github.com/kelseyhightower/envconfig v1.4.0
go.uber.org/zap v1.25.0
gopkg.in/yaml.v2 v2.4.0
)

// XXX: uncomment when testing local changes to gouroboros
// replace github.com/blinklabs-io/gouroboros v0.52.0 => ../gouroboros

require (
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/copier v0.4.0 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/x448/float16 v0.8.4 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/blinklabs-io/gouroboros v0.51.0 h1:cgl2jgTsPAKC1Jdp44vvzKxDn5fYJNooRR2HpP/ZjkI=
github.com/blinklabs-io/gouroboros v0.51.0/go.mod h1:cQt3XVVG2b+cpIJh+DhID7ivsyBQmTsXqbTDZ+7esXI=
github.com/blinklabs-io/gouroboros v0.52.0 h1:5abdw2PXHKHxve26BITukfAzz7OJoTPKWylbyth9Sxk=
github.com/blinklabs-io/gouroboros v0.52.0/go.mod h1:2wCCNNsHNYMT4gQB+bXS0Y99Oeu8+EM96hi7hW22C2w=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
Expand All @@ -10,8 +10,8 @@ github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/Oq
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
Expand Down
19 changes: 14 additions & 5 deletions input/chainsync/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package chainsync

import (
"github.com/blinklabs-io/gouroboros/cbor"
"github.com/blinklabs-io/gouroboros/ledger"
)

Expand All @@ -26,19 +27,27 @@ type TransactionEvent struct {
TransactionCbor byteSliceJsonHex `json:"transactionCbor,omitempty"`
Inputs []ledger.TransactionInput `json:"inputs"`
Outputs []ledger.TransactionOutput `json:"outputs"`
Metadata *cbor.Value `json:"metadata,omitempty"`
MetadataCbor byteSliceJsonHex `json:"metadataCbor,omitempty"`
wolf31o2 marked this conversation as resolved.
Show resolved Hide resolved
}

func NewTransactionEvent(block ledger.Block, txBody ledger.TransactionBody, includeCbor bool) TransactionEvent {
func NewTransactionEvent(block ledger.Block, tx ledger.Transaction, includeCbor bool) TransactionEvent {
evt := TransactionEvent{
BlockNumber: block.BlockNumber(),
BlockHash: block.Hash(),
SlotNumber: block.SlotNumber(),
TransactionHash: txBody.Hash(),
Inputs: txBody.Inputs(),
Outputs: txBody.Outputs(),
TransactionHash: tx.Hash(),
Inputs: tx.Inputs(),
Outputs: tx.Outputs(),
}
if includeCbor {
evt.TransactionCbor = txBody.Cbor()
evt.TransactionCbor = tx.Cbor()
}
if tx.Metadata() != nil {
evt.Metadata = tx.Metadata()
if includeCbor {
evt.MetadataCbor = tx.Metadata().Cbor()
}
}
return evt
}
Loading