@@ -61,7 +61,7 @@ export class MaestroAdapter implements Adapter {
61
61
} ) ) ;
62
62
}
63
63
64
- private async getAllUtxosDataByAddress ( address : string , queryParams ?: UtxosByAddressQueryParams ) : Promise < UtxoWithSlot [ ] > {
64
+ private async getAllUtxosDataByPaymentCred ( credential : string , queryParams ?: UtxosByAddressQueryParams ) : Promise < UtxoWithSlot [ ] > {
65
65
let cursor : string | null | undefined = null ;
66
66
const utxosData : UtxoWithSlot [ ] = [ ] ;
67
67
@@ -71,8 +71,8 @@ export class MaestroAdapter implements Adapter {
71
71
72
72
do {
73
73
queryParams . cursor = cursor ;
74
- const utxos = await this . maestroClient . addresses . utxosByAddress (
75
- address ,
74
+ const utxos = await this . maestroClient . addresses . utxosByPaymentCred (
75
+ credential ,
76
76
queryParams
77
77
) ;
78
78
utxosData . push ( ...utxos . data ) ;
@@ -375,8 +375,8 @@ export class MaestroAdapter implements Adapter {
375
375
errors : unknown [ ] ;
376
376
} > {
377
377
const v2Config = DexV2Constant . CONFIG [ this . networkId ] ;
378
- const utxosData = await this . getAllUtxosDataByAddress (
379
- v2Config . factoryAddress ,
378
+ const utxosData = await this . getAllUtxosDataByPaymentCred (
379
+ v2Config . factoryScriptHashBech32 ,
380
380
{
381
381
asset : v2Config . factoryAsset ,
382
382
}
@@ -598,24 +598,24 @@ export class MaestroAdapter implements Adapter {
598
598
return Big ( priceNum . toString ( ) ) . div ( priceDen . toString ( ) ) ;
599
599
}
600
600
601
+ // MARK: LBE V2
601
602
public async getAllLbeV2Factories ( ) : Promise < {
602
603
factories : LbeV2Types . FactoryState [ ] ;
603
604
errors : unknown [ ] ;
604
605
} > {
605
606
const config = LbeV2Constant . CONFIG [ this . networkId ] ;
606
- const utxos = await this . maestroClient . addresses . utxosByAddress (
607
+ const utxosData = await this . getAllUtxosDataByPaymentCred (
607
608
config . factoryHashBech32 ,
608
609
{
609
610
asset : config . factoryAsset ,
610
611
}
611
- ) ;
612
- const utxosData = utxos . data ;
612
+ )
613
613
614
614
const factories : LbeV2Types . FactoryState [ ] = [ ] ;
615
615
const errors : unknown [ ] = [ ] ;
616
616
for ( const utxo of utxosData ) {
617
617
try {
618
- if ( utxo . datum ?. type != "inline" ) {
618
+ if ( utxo . datum ?. type != "inline" || ! utxo . datum ?. bytes ) {
619
619
throw new Error (
620
620
`Cannot find datum of LBE V2 Factory, tx: ${ utxo . tx_hash } `
621
621
) ;
@@ -626,7 +626,7 @@ export class MaestroAdapter implements Adapter {
626
626
utxo . address ,
627
627
{ txHash : utxo . tx_hash , index : utxo . index } ,
628
628
this . mapMaestroAssetToValue ( utxo . assets ) ,
629
- utxo . datum . hash
629
+ utxo . datum ?. bytes
630
630
) ;
631
631
factories . push ( factory ) ;
632
632
} catch ( err ) {
@@ -684,19 +684,18 @@ export class MaestroAdapter implements Adapter {
684
684
} > {
685
685
const config = LbeV2Constant . CONFIG [ this . networkId ] ;
686
686
687
- const utxos = await this . maestroClient . addresses . utxosByAddress (
687
+ const utxosData = await this . getAllUtxosDataByPaymentCred (
688
688
config . treasuryHashBech32 ,
689
689
{
690
690
asset : config . treasuryAsset ,
691
691
}
692
692
) ;
693
- const utxosData = utxos . data ;
694
693
695
694
const treasuries : LbeV2Types . TreasuryState [ ] = [ ] ;
696
695
const errors : unknown [ ] = [ ] ;
697
696
for ( const utxo of utxosData ) {
698
697
try {
699
- if ( utxo . datum ?. type != "inline" ) {
698
+ if ( utxo . datum ?. type != "inline" || ! utxo . datum ?. bytes ) {
700
699
throw new Error (
701
700
`Cannot find datum of LBE V2 Treasury, tx: ${ utxo . tx_hash } `
702
701
) ;
@@ -707,7 +706,7 @@ export class MaestroAdapter implements Adapter {
707
706
utxo . address ,
708
707
{ txHash : utxo . tx_hash , index : utxo . index } ,
709
708
this . mapMaestroAssetToValue ( utxo . assets ) ,
710
- utxo . datum . hash
709
+ utxo . datum ?. bytes
711
710
) ;
712
711
treasuries . push ( treasury ) ;
713
712
} catch ( err ) {
@@ -738,19 +737,18 @@ export class MaestroAdapter implements Adapter {
738
737
} > {
739
738
const config = LbeV2Constant . CONFIG [ this . networkId ] ;
740
739
741
- const utxos = await this . maestroClient . addresses . utxosByAddress (
740
+ const utxosData = await this . getAllUtxosDataByPaymentCred (
742
741
config . managerHashBech32 ,
743
742
{
744
743
asset : config . managerAsset ,
745
744
}
746
745
) ;
747
- const utxosData = utxos . data ;
748
746
749
747
const managers : LbeV2Types . ManagerState [ ] = [ ] ;
750
748
const errors : unknown [ ] = [ ] ;
751
749
for ( const utxo of utxosData ) {
752
750
try {
753
- if ( utxo . datum ?. type != "inline" ) {
751
+ if ( utxo . datum ?. type != "inline" || ! utxo . datum ?. bytes ) {
754
752
throw new Error (
755
753
`Cannot find datum of Lbe V2 Manager, tx: ${ utxo . tx_hash } `
756
754
) ;
@@ -761,7 +759,7 @@ export class MaestroAdapter implements Adapter {
761
759
utxo . address ,
762
760
{ txHash : utxo . tx_hash , index : utxo . index } ,
763
761
this . mapMaestroAssetToValue ( utxo . assets ) ,
764
- utxo . datum . hash
762
+ utxo . datum ?. bytes
765
763
) ;
766
764
managers . push ( manager ) ;
767
765
} catch ( err ) {
@@ -792,19 +790,18 @@ export class MaestroAdapter implements Adapter {
792
790
} > {
793
791
const config = LbeV2Constant . CONFIG [ this . networkId ] ;
794
792
795
- const utxos = await this . maestroClient . addresses . utxosByAddress (
793
+ const utxosData = await this . getAllUtxosDataByPaymentCred (
796
794
config . sellerHashBech32 ,
797
795
{
798
796
asset : config . sellerAsset ,
799
797
}
800
798
) ;
801
- const utxosData = utxos . data ;
802
799
803
800
const sellers : LbeV2Types . SellerState [ ] = [ ] ;
804
801
const errors : unknown [ ] = [ ] ;
805
802
for ( const utxo of utxosData ) {
806
803
try {
807
- if ( utxo . datum ?. type != "inline" ) {
804
+ if ( utxo . datum ?. type != "inline" || ! utxo . datum ?. bytes ) {
808
805
throw new Error (
809
806
`Cannot find datum of Lbe V2 Seller, tx: ${ utxo . tx_hash } `
810
807
) ;
@@ -815,7 +812,7 @@ export class MaestroAdapter implements Adapter {
815
812
utxo . address ,
816
813
{ txHash : utxo . tx_hash , index : utxo . index } ,
817
814
this . mapMaestroAssetToValue ( utxo . assets ) ,
818
- utxo . datum . hash
815
+ utxo . datum ?. bytes
819
816
) ;
820
817
sellers . push ( seller ) ;
821
818
} catch ( err ) {
@@ -846,19 +843,18 @@ export class MaestroAdapter implements Adapter {
846
843
} > {
847
844
const config = LbeV2Constant . CONFIG [ this . networkId ] ;
848
845
849
- const utxos = await this . maestroClient . addresses . utxosByAddress (
846
+ const utxosData = await this . getAllUtxosDataByPaymentCred (
850
847
config . orderHashBech32 ,
851
848
{
852
849
asset : config . orderAsset ,
853
850
}
854
851
) ;
855
- const utxosData = utxos . data ;
856
852
857
853
const orders : LbeV2Types . OrderState [ ] = [ ] ;
858
854
const errors : unknown [ ] = [ ] ;
859
855
for ( const utxo of utxosData ) {
860
856
try {
861
- if ( utxo . datum ?. type != "inline" ) {
857
+ if ( utxo . datum ?. type != "inline" || ! utxo . datum ?. bytes ) {
862
858
throw new Error (
863
859
`Cannot find datum of Lbe V2 Order, tx: ${ utxo . tx_hash } `
864
860
) ;
@@ -869,7 +865,7 @@ export class MaestroAdapter implements Adapter {
869
865
utxo . address ,
870
866
{ txHash : utxo . tx_hash , index : utxo . index } ,
871
867
this . mapMaestroAssetToValue ( utxo . assets ) ,
872
- utxo . datum . hash
868
+ utxo . datum ?. bytes
873
869
) ;
874
870
orders . push ( order ) ;
875
871
} catch ( err ) {
0 commit comments