Skip to content

Commit fdf3a7c

Browse files
committed
chore(deps): gouroboros 0.142.0 and plutigo 0.0.16
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 917cf38 commit fdf3a7c

File tree

8 files changed

+90
-36
lines changed

8 files changed

+90
-36
lines changed

docs/docs.go

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

event/tx.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package event
1616

1717
import (
18-
"github.com/blinklabs-io/gouroboros/cbor"
1918
"github.com/blinklabs-io/gouroboros/ledger"
2019
lcommon "github.com/blinklabs-io/gouroboros/ledger/common"
2120
)
@@ -32,7 +31,7 @@ type TransactionEvent struct {
3231
Transaction ledger.Transaction `json:"-"`
3332
Witnesses lcommon.TransactionWitnessSet `json:"witnesses,omitempty"`
3433
Withdrawals map[string]uint64 `json:"withdrawals,omitempty"`
35-
Metadata *cbor.LazyValue `json:"metadata,omitempty"`
34+
Metadata lcommon.TransactionMetadatum `json:"metadata,omitempty"`
3635
BlockHash string `json:"blockHash"`
3736
ReferenceInputs []ledger.TransactionInput `json:"referenceInputs,omitempty"`
3837
Certificates []ledger.Certificate `json:"certificates,omitempty"`

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ toolchain go1.24.4
77
require (
88
github.com/SundaeSwap-finance/kugo v1.3.0
99
github.com/SundaeSwap-finance/ogmigo/v6 v6.2.0
10-
github.com/blinklabs-io/gouroboros v0.140.0
11-
github.com/blinklabs-io/plutigo v0.0.14
10+
github.com/blinklabs-io/gouroboros v0.142.0
11+
github.com/blinklabs-io/plutigo v0.0.16
1212
github.com/btcsuite/btcd/btcutil v1.1.6
1313
github.com/gen2brain/beeep v0.11.1
1414
github.com/gin-gonic/gin v1.11.0

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ github.com/aws/aws-sdk-go v1.55.6 h1:cSg4pvZ3m8dgYcgqB97MrcdjUmZ1BeMYKUxMMB89IPk
1717
github.com/aws/aws-sdk-go v1.55.6/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
1818
github.com/bits-and-blooms/bitset v1.20.0 h1:2F+rfL86jE2d/bmw7OhqUg2Sj/1rURkBn3MdfoPyRVU=
1919
github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
20-
github.com/blinklabs-io/gouroboros v0.140.0 h1:dFK2iunkTflCI2hlDSGZJJ7JerYhpdE41HnBUVvjj9E=
21-
github.com/blinklabs-io/gouroboros v0.140.0/go.mod h1:FxKQNNNRQN5F/Cl4pnW7SHhpPo7fD57mTPGo4N9ulnY=
22-
github.com/blinklabs-io/ouroboros-mock v0.3.9 h1:UnciDccJ5tZCR1xI0BcxGZcYjJ/PS5MpnjiiGtrZ680=
23-
github.com/blinklabs-io/ouroboros-mock v0.3.9/go.mod h1:uTkE8/LAYL7yQSntH48Pudf5Xn+jaBWMj+9udbzYXhI=
24-
github.com/blinklabs-io/plutigo v0.0.14 h1:K45/tQpZwJFdCcrhigepbdSPQG/+0pp99cCrbJdSl44=
25-
github.com/blinklabs-io/plutigo v0.0.14/go.mod h1:W4TnQiGhc6da5G+jXAW3O/Q/tgqG9QoITRJ1FCXd260=
20+
github.com/blinklabs-io/gouroboros v0.142.0 h1:vBsQfcPsZF7EX+1uw1Gcg0uCYvkjsEVHn2qEqlMC0lY=
21+
github.com/blinklabs-io/gouroboros v0.142.0/go.mod h1:pC42tYVwkd34ohGrWAIHhLOWhhpmrBa0M/QUE+4gC8Q=
22+
github.com/blinklabs-io/ouroboros-mock v0.4.0 h1:ppOcTMnC/2f5rYYSlvNqcGfAQOIpMCSDUrNh9K6a4mY=
23+
github.com/blinklabs-io/ouroboros-mock v0.4.0/go.mod h1:e+Kck8bmdOuaN7IfkbVvbqAVlskXNXB95oHI3YlFG5g=
24+
github.com/blinklabs-io/plutigo v0.0.16 h1:3+1eOby9ckoDXb+8ObCBQ4BGbHZ6z7cxGFDR4cbS+7Y=
25+
github.com/blinklabs-io/plutigo v0.0.16/go.mod h1:aT3mJAh1s8JJ8C42ygd8OyGDQZ8f+w8Uge2+C/9BLug=
2626
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
2727
github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=
2828
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=

input/chainsync/block_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type MockBlockHeader struct {
3131
hash common.Blake2b256
3232
prevHash common.Blake2b256
3333
issuerVkey common.IssuerVkey
34+
blockBodyHash common.Blake2b256
3435
}
3536

3637
func (m MockBlockHeader) Hash() common.Blake2b256 {
@@ -65,6 +66,10 @@ func (m MockBlockHeader) Cbor() []byte {
6566
return m.cborBytes
6667
}
6768

69+
func (m MockBlockHeader) BlockBodyHash() common.Blake2b256 {
70+
return m.blockBodyHash
71+
}
72+
6873
// MockBlock implements Block interface
6974
type MockBlock struct {
7075
MockBlockHeader
@@ -87,6 +92,10 @@ func (m MockBlock) Utxorpc() (*utxorpc.Block, error) {
8792
return nil, nil
8893
}
8994

95+
func (m MockBlock) BlockBodyHash() common.Blake2b256 {
96+
return m.MockBlockHeader.BlockBodyHash()
97+
}
98+
9099
func (m MockBlock) IsShelley() bool {
91100
return m.era.Name == "Shelley"
92101
}

internal/config/config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ const (
7373
)
7474

7575
type Config struct {
76-
ByronGenesis ByronGenesisConfig `yaml:"byron_genesis" envconfig:"BYRON_GENESIS"`
77-
Plugin map[string]map[string]map[any]any `yaml:"plugins" envconfig:"PLUGINS"`
78-
Logging LoggingConfig `yaml:"logging" envconfig:"LOGGING"`
76+
ByronGenesis ByronGenesisConfig `yaml:"byron_genesis" envconfig:"BYRON_GENESIS"`
77+
Plugin map[string]map[string]map[any]any `yaml:"plugins" envconfig:"PLUGINS"`
78+
Logging LoggingConfig `yaml:"logging" envconfig:"LOGGING"`
7979
ConfigFile string `yaml:"-"`
80-
Input string `yaml:"input" envconfig:"INPUT"`
81-
Output string `yaml:"output" envconfig:"OUTPUT"`
82-
KupoUrl string `yaml:"kupo_url" envconfig:"KUPO_URL"`
83-
Api ApiConfig `yaml:"api" envconfig:"API"`
84-
Debug DebugConfig `yaml:"debug" envconfig:"DEBUG"`
85-
ShelleyGenesis ShelleyGenesisConfig `yaml:"shelley_genesis" envconfig:"SHELLEY_GENESIS"`
80+
Input string `yaml:"input" envconfig:"INPUT"`
81+
Output string `yaml:"output" envconfig:"OUTPUT"`
82+
KupoUrl string `yaml:"kupo_url" envconfig:"KUPO_URL"`
83+
Api ApiConfig `yaml:"api" envconfig:"API"`
84+
Debug DebugConfig `yaml:"debug" envconfig:"DEBUG"`
85+
ShelleyGenesis ShelleyGenesisConfig `yaml:"shelley_genesis" envconfig:"SHELLEY_GENESIS"`
8686
ShelleyTransEpoch int32 `yaml:"shelley_trans_epoch" envconfig:"SHELLEY_TRANS_EPOCH"`
8787
Version bool `yaml:"-"`
8888
}

openapi/test/api_default_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/push/push.go

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ import (
1919
"encoding/json"
2020
"errors"
2121
"fmt"
22+
"math/big"
2223
"os"
2324

2425
"github.com/blinklabs-io/adder/event"
2526
"github.com/blinklabs-io/adder/internal/logging"
2627
"github.com/blinklabs-io/adder/output/push/fcm"
2728
"github.com/blinklabs-io/adder/plugin"
28-
"github.com/blinklabs-io/gouroboros/cbor"
29+
"github.com/blinklabs-io/gouroboros/ledger/common"
2930
"golang.org/x/oauth2/google"
3031
)
3132

@@ -306,40 +307,54 @@ func (p *PushOutput) OutputChan() <-chan event.Event {
306307
// This should probably go in gouroboros module
307308
// extractCIP20FromMetadata extracts the CIP20 message from the transaction metadata
308309
// and returns it as a JSON string.
309-
func extractCIP20FromMetadata(metadata *cbor.LazyValue) (string, error) {
310+
func extractCIP20FromMetadata(
311+
metadata common.TransactionMetadatum,
312+
) (string, error) {
310313
if metadata == nil {
311314
return "", errors.New("metadata is nil")
312315
}
313316

314-
if _, err := metadata.Decode(); err != nil {
315-
return "", fmt.Errorf("could not decode metadata: %w", err)
316-
}
317-
318-
metadataMap, ok := metadata.Value().(map[any]any)
317+
metaMap, ok := metadata.(common.MetaMap)
319318
if !ok {
320-
return "", errors.New("metadata value is not of the expected map type")
319+
return "", errors.New("metadata is not a MetaMap")
321320
}
322321

323-
// Extract the nested value for key 674
324-
nestedValue, found := metadataMap[uint64(674)]
322+
var nestedValue common.TransactionMetadatum
323+
found := false
324+
for _, pair := range metaMap.Pairs {
325+
if keyInt, ok := pair.Key.(common.MetaInt); ok &&
326+
keyInt.Value.Cmp(big.NewInt(674)) == 0 {
327+
nestedValue = pair.Value
328+
found = true
329+
break
330+
}
331+
}
325332
if !found {
326333
return "", errors.New("key 674 not found in metadata")
327334
}
328335

329-
// Assert the nested value is a map
330-
nestedMap, ok := nestedValue.(map[any]any)
336+
nestedMap, ok := nestedValue.(common.MetaMap)
331337
if !ok {
332338
return "", errors.New("nested value for key 674 is not a map")
333339
}
334340

335-
msgValue, found := nestedMap["msg"]
341+
var msgValue common.TransactionMetadatum
342+
found = false
343+
for _, pair := range nestedMap.Pairs {
344+
if keyText, ok := pair.Key.(common.MetaText); ok &&
345+
keyText.Value == "msg" {
346+
msgValue = pair.Value
347+
found = true
348+
break
349+
}
350+
}
336351
if !found {
337352
return "", errors.New("key 'msg' not found in nested metadata map")
338353
}
339354

340355
msgStruct := map[string]any{
341356
"674": map[string]any{
342-
"msg": msgValue,
357+
"msg": metadatumToAny(msgValue),
343358
},
344359
}
345360

@@ -350,3 +365,30 @@ func extractCIP20FromMetadata(metadata *cbor.LazyValue) (string, error) {
350365

351366
return string(jsonBytes), nil
352367
}
368+
369+
func metadatumToAny(md common.TransactionMetadatum) any {
370+
switch v := md.(type) {
371+
case common.MetaInt:
372+
return v.Value
373+
case common.MetaBytes:
374+
return v.Value
375+
case common.MetaText:
376+
return v.Value
377+
case common.MetaList:
378+
var list []any
379+
for _, item := range v.Items {
380+
list = append(list, metadatumToAny(item))
381+
}
382+
return list
383+
case common.MetaMap:
384+
m := make(map[any]any)
385+
for _, pair := range v.Pairs {
386+
key := metadatumToAny(pair.Key)
387+
value := metadatumToAny(pair.Value)
388+
m[key] = value
389+
}
390+
return m
391+
default:
392+
return nil
393+
}
394+
}

0 commit comments

Comments
 (0)