@@ -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
3132type 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
3738func 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
0 commit comments