File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
packages/cardano-services/src/util/BlockfrostProvider Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { Cardano } from '@cardano-sdk/core' ;
2
2
import { Responses } from '@blockfrost/blockfrost-js' ;
3
+ import { Value } from '@cardano-sdk/core/dist/cjs/Cardano' ;
3
4
4
5
type Unpacked < T > = T extends ( infer U ) [ ] ? U : T ;
5
6
type BlockfrostAddressUtxoContent = Responses [ 'address_utxo_content' ] ;
@@ -105,17 +106,21 @@ export const BlockfrostToCore = {
105
106
} ) ,
106
107
107
108
txOut : ( blockfrost : BlockfrostOutput ) : Cardano . TxOut => {
109
+ const value : Cardano . Value = {
110
+ coins : BigInt ( blockfrost . amount . find ( ( { unit } ) => unit === 'lovelace' ) ! . quantity )
111
+ } ;
112
+
108
113
const assets : Cardano . TokenMap = new Map ( ) ;
109
114
for ( const { quantity, unit } of blockfrost . amount ) {
110
115
if ( unit === 'lovelace' ) continue ;
111
116
assets . set ( Cardano . AssetId ( unit ) , BigInt ( quantity ) ) ;
112
117
}
118
+
119
+ if ( assets . size > 0 ) value . assets = assets ;
120
+
113
121
return {
114
122
address : Cardano . PaymentAddress ( blockfrost . address ) ,
115
- value : {
116
- assets : assets . size > 0 ? assets : undefined ,
117
- coins : BigInt ( blockfrost . amount . find ( ( { unit } ) => unit === 'lovelace' ) ! . quantity )
118
- }
123
+ value
119
124
} ;
120
125
}
121
126
} ;
You can’t perform that action at this time.
0 commit comments