Skip to content

Commit b246a8f

Browse files
authored
chore(deps): gouroboros 0.149.0 (#589)
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
1 parent 028e263 commit b246a8f

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

event/tx.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewTransactionEvent(
7070
BlockHash: block.Hash().String(),
7171
Inputs: tx.Inputs(),
7272
Outputs: tx.Outputs(),
73-
Fee: tx.Fee(),
73+
Fee: tx.Fee().Uint64(),
7474
Witnesses: tx.Witnesses(),
7575
}
7676
if includeCbor {
@@ -94,7 +94,7 @@ func NewTransactionEvent(
9494
if withdrawals := tx.Withdrawals(); len(withdrawals) > 0 {
9595
evt.Withdrawals = make(map[string]uint64)
9696
for addr, amount := range withdrawals {
97-
evt.Withdrawals[addr.String()] = amount
97+
evt.Withdrawals[addr.String()] = amount.Uint64()
9898
}
9999
}
100100
return evt

filter/cardano/cardano_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package cardano
1616
import (
1717
"bytes"
1818
"encoding/hex"
19+
"math/big"
1920
"testing"
2021
"time"
2122

@@ -100,8 +101,8 @@ func (m MockOutput) Address() ledger.Address {
100101
return m.address
101102
}
102103

103-
func (m MockOutput) Amount() uint64 {
104-
return m.amount
104+
func (m MockOutput) Amount() *big.Int {
105+
return big.NewInt(int64(m.amount))
105106
}
106107

107108
func (m MockOutput) Assets() *common.MultiAsset[common.MultiAssetTypeOutput] {
@@ -328,7 +329,7 @@ func TestFilterByPolicyId(t *testing.T) {
328329
)
329330
assetName := cbor.NewByteString([]byte("asset1"))
330331
assetsData[policyId] = map[cbor.ByteString]common.MultiAssetTypeOutput{
331-
assetName: 1, // Add asset with quantity 1
332+
assetName: big.NewInt(1), // Add asset with quantity 1
332333
}
333334
assets := common.NewMultiAsset(assetsData)
334335

@@ -381,7 +382,7 @@ func TestFilterByAssetFingerprint(t *testing.T) {
381382
)
382383
assetName := cbor.NewByteString([]byte("asset1"))
383384
assetsData[policyId] = map[cbor.ByteString]common.MultiAssetTypeOutput{
384-
assetName: 1, // Add asset with quantity 1
385+
assetName: big.NewInt(1), // Add asset with quantity 1
385386
}
386387
assets := common.NewMultiAsset(assetsData)
387388

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ 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.146.0
10+
github.com/blinklabs-io/gouroboros v0.149.0
1111
github.com/blinklabs-io/plutigo v0.0.20
1212
github.com/btcsuite/btcd/btcutil v1.1.6
1313
github.com/gen2brain/beeep v0.11.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ 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.146.0 h1:bZD6GAbHpTRhaUEDFuD+s21eZwdAwWBJ5w5ebBRJKLk=
21-
github.com/blinklabs-io/gouroboros v0.146.0/go.mod h1:qRfnn0az84aaPjsvtQK52yoApww0bxQsMu9LJgQ1ftg=
20+
github.com/blinklabs-io/gouroboros v0.149.0 h1:Kgnnn6l/ogwdOwppqRzZi8EGtNu0B+/4hjvkgSL/Wes=
21+
github.com/blinklabs-io/gouroboros v0.149.0/go.mod h1:UqNKi2y70+0s+0QxSwox+pdB++lq2RqUSWtErngs8NQ=
2222
github.com/blinklabs-io/ouroboros-mock v0.4.0 h1:ppOcTMnC/2f5rYYSlvNqcGfAQOIpMCSDUrNh9K6a4mY=
2323
github.com/blinklabs-io/ouroboros-mock v0.4.0/go.mod h1:e+Kck8bmdOuaN7IfkbVvbqAVlskXNXB95oHI3YlFG5g=
2424
github.com/blinklabs-io/plutigo v0.0.20 h1:WLHwEOCdquQgcfjVrWpgxjLQ7GG2vXFAq6/LWtsXutg=

input/chainsync/transaction_output.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"encoding/hex"
1919
"fmt"
2020
"log/slog"
21+
"math/big"
2122

2223
"github.com/SundaeSwap-finance/kugo"
2324
"github.com/blinklabs-io/gouroboros/cbor"
@@ -29,16 +30,16 @@ import (
2930

3031
// ResolvedTransactionOutput represents a concrete implementation of the TransactionOutput interface
3132
type ResolvedTransactionOutput struct {
32-
AddressField common.Address `json:"address"`
33-
AssetsField *common.MultiAsset[uint64] `json:"assets,omitempty"`
34-
AmountField uint64 `json:"amount"`
33+
AddressField common.Address `json:"address"`
34+
AssetsField *common.MultiAsset[common.MultiAssetTypeOutput] `json:"assets,omitempty"`
35+
AmountField uint64 `json:"amount"`
3536
}
3637

3738
func ExtractAssetDetailsFromMatch(
3839
match kugo.Match,
39-
) (common.MultiAsset[uint64], uint64, error) {
40+
) (common.MultiAsset[common.MultiAssetTypeOutput], uint64, error) {
4041
// Initialize the map that will store the assets
41-
assetsMap := map[common.Blake2b224]map[cbor.ByteString]uint64{}
42+
assetsMap := map[common.Blake2b224]map[cbor.ByteString]common.MultiAssetTypeOutput{}
4243
totalLovelace := uint64(0)
4344

4445
// Iterate over all policies (asset types) in the Value map
@@ -57,7 +58,7 @@ func ExtractAssetDetailsFromMatch(
5758
policyBlake := common.NewBlake2b224(policyIdBytes)
5859

5960
// Prepare the map for this policy's assets
60-
policyAssets := make(map[cbor.ByteString]uint64)
61+
policyAssets := make(map[cbor.ByteString]common.MultiAssetTypeOutput)
6162

6263
// Iterate over all assets within this policyId
6364
for assetName, amount := range assets {
@@ -71,15 +72,14 @@ func ExtractAssetDetailsFromMatch(
7172
}
7273

7374
byteStringAssetName := cbor.NewByteString([]byte(assetName))
74-
assetAmount := amount.Uint64()
75-
policyAssets[byteStringAssetName] = assetAmount
75+
policyAssets[byteStringAssetName] = amount.BigInt()
7676
slog.Debug("Get policyId, assetName, assetAmount from match.Value")
7777
slog.Debug(
7878
fmt.Sprintf(
79-
"policyId: %s, assetName: %s, amount: %d\n",
79+
"policyId: %s, assetName: %s, amount: %v\n",
8080
policyId,
8181
assetName,
82-
assetAmount,
82+
amount,
8383
),
8484
)
8585
}
@@ -123,7 +123,7 @@ func NewResolvedTransactionOutput(
123123
AddressField: addr,
124124
AmountField: amount,
125125
// return assets if there are any, otherwise return nil
126-
AssetsField: func() *common.MultiAsset[uint64] {
126+
AssetsField: func() *common.MultiAsset[common.MultiAssetTypeOutput] {
127127
if len(assets.Policies()) > 0 {
128128
return &assets
129129
}
@@ -136,11 +136,11 @@ func (txOut ResolvedTransactionOutput) Address() common.Address {
136136
return txOut.AddressField
137137
}
138138

139-
func (txOut ResolvedTransactionOutput) Amount() uint64 {
140-
return txOut.AmountField
139+
func (txOut ResolvedTransactionOutput) Amount() *big.Int {
140+
return new(big.Int).SetUint64(txOut.AmountField)
141141
}
142142

143-
func (txOut ResolvedTransactionOutput) Assets() *common.MultiAsset[uint64] {
143+
func (txOut ResolvedTransactionOutput) Assets() *common.MultiAsset[common.MultiAssetTypeOutput] {
144144
return txOut.AssetsField
145145
}
146146

input/chainsync/transaction_output_test.go

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

1717
import (
1818
"encoding/json"
19+
"math/big"
1920
"testing"
2021

2122
"github.com/blinklabs-io/gouroboros/cbor"
@@ -34,9 +35,9 @@ func TestResolvedTransactionOutput_MarshalJSON(t *testing.T) {
3435

3536
// Create assets for the resolved output
3637
assets := common.NewMultiAsset(
37-
map[common.Blake2b224]map[cbor.ByteString]uint64{
38+
map[common.Blake2b224]map[cbor.ByteString]common.MultiAssetTypeOutput{
3839
common.NewBlake2b224([]byte("policy1")): {
39-
cbor.NewByteString([]byte("TokenA")): 100,
40+
cbor.NewByteString([]byte("TokenA")): big.NewInt(100),
4041
},
4142
},
4243
)
@@ -55,6 +56,7 @@ func TestResolvedTransactionOutput_MarshalJSON(t *testing.T) {
5556
}
5657

5758
// Expected JSON string
59+
// Note: *big.Int serializes to a string in JSON
5860
expectedJSON := `{
5961
"address":"addr_test1wq5yehcpw4e3r32rltrww40e6ezdckr9v9l0ehptsxeynlg630pts",
6062
"amount":2000000,
@@ -64,7 +66,7 @@ func TestResolvedTransactionOutput_MarshalJSON(t *testing.T) {
6466
"nameHex":"546f6b656e41",
6567
"policyId":"706f6c69637931000000000000000000000000000000000000000000",
6668
"fingerprint":"asset174ghjk04g2dpjv8zuw6s99rm09wmfvmgtfl84n",
67-
"amount":100
69+
"amount":"100"
6870
}
6971
]
7072
}`

0 commit comments

Comments
 (0)