Skip to content

Commit 7d28683

Browse files
authored
Merge pull request #64 from blinklabs-io/feat/tx-metadata
feat: transaction metadata
2 parents 637db73 + b133799 commit 7d28683

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

filter/chainsync/option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func WithPolicies(policyIds []string) ChainSyncOptionFunc {
3030
}
3131
}
3232

33-
//WithAssetFingerprints specifies the asset fingerprint (asset1xxx) to filter on
33+
// WithAssetFingerprints specifies the asset fingerprint (asset1xxx) to filter on
3434
func WithAssetFingerprints(assetFingerprints []string) ChainSyncOptionFunc {
3535
return func(c *ChainSync) {
3636
c.filterAssetFingerprints = assetFingerprints[:]

go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ module github.com/blinklabs-io/snek
33
go 1.19
44

55
require (
6-
github.com/blinklabs-io/gouroboros v0.51.0
6+
github.com/blinklabs-io/gouroboros v0.52.0
77
github.com/gen2brain/beeep v0.0.0-20230602101333-f384c29b62dd
88
github.com/kelseyhightower/envconfig v1.4.0
99
go.uber.org/zap v1.25.0
1010
gopkg.in/yaml.v2 v2.4.0
1111
)
1212

13+
// XXX: uncomment when testing local changes to gouroboros
14+
// replace github.com/blinklabs-io/gouroboros v0.52.0 => ../gouroboros
15+
1316
require (
1417
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
1518
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
1619
github.com/godbus/dbus/v5 v5.1.0 // indirect
17-
github.com/jinzhu/copier v0.3.5 // indirect
20+
github.com/jinzhu/copier v0.4.0 // indirect
1821
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
1922
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
2023
github.com/x448/float16 v0.8.4 // indirect

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
2-
github.com/blinklabs-io/gouroboros v0.51.0 h1:cgl2jgTsPAKC1Jdp44vvzKxDn5fYJNooRR2HpP/ZjkI=
3-
github.com/blinklabs-io/gouroboros v0.51.0/go.mod h1:cQt3XVVG2b+cpIJh+DhID7ivsyBQmTsXqbTDZ+7esXI=
2+
github.com/blinklabs-io/gouroboros v0.52.0 h1:5abdw2PXHKHxve26BITukfAzz7OJoTPKWylbyth9Sxk=
3+
github.com/blinklabs-io/gouroboros v0.52.0/go.mod h1:2wCCNNsHNYMT4gQB+bXS0Y99Oeu8+EM96hi7hW22C2w=
44
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
55
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
66
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
@@ -10,8 +10,8 @@ github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/Oq
1010
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
1111
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
1212
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
13-
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
14-
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
13+
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
14+
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
1515
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
1616
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
1717
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=

input/chainsync/tx.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package chainsync
1616

1717
import (
18+
"github.com/blinklabs-io/gouroboros/cbor"
1819
"github.com/blinklabs-io/gouroboros/ledger"
1920
)
2021

@@ -26,19 +27,23 @@ type TransactionEvent struct {
2627
TransactionCbor byteSliceJsonHex `json:"transactionCbor,omitempty"`
2728
Inputs []ledger.TransactionInput `json:"inputs"`
2829
Outputs []ledger.TransactionOutput `json:"outputs"`
30+
Metadata *cbor.Value `json:"metadata,omitempty"`
2931
}
3032

31-
func NewTransactionEvent(block ledger.Block, txBody ledger.TransactionBody, includeCbor bool) TransactionEvent {
33+
func NewTransactionEvent(block ledger.Block, tx ledger.Transaction, includeCbor bool) TransactionEvent {
3234
evt := TransactionEvent{
3335
BlockNumber: block.BlockNumber(),
3436
BlockHash: block.Hash(),
3537
SlotNumber: block.SlotNumber(),
36-
TransactionHash: txBody.Hash(),
37-
Inputs: txBody.Inputs(),
38-
Outputs: txBody.Outputs(),
38+
TransactionHash: tx.Hash(),
39+
Inputs: tx.Inputs(),
40+
Outputs: tx.Outputs(),
3941
}
4042
if includeCbor {
41-
evt.TransactionCbor = txBody.Cbor()
43+
evt.TransactionCbor = tx.Cbor()
44+
}
45+
if tx.Metadata() != nil {
46+
evt.Metadata = tx.Metadata()
4247
}
4348
return evt
4449
}

0 commit comments

Comments
 (0)