11import { baseToCommon } from 'src/shared/units/convert' ;
2- import type { Asset , AddressAction , Client } from 'defi-sdk' ;
2+ import type { Asset , AddressAction , Client , NFT } from 'defi-sdk' ;
33import { client as defaultClient } from 'defi-sdk' ;
44import { rejectAfterDelay } from 'src/shared/rejectAfterDelay' ;
55import { valueToHex } from 'src/shared/units/valueToHex' ;
@@ -11,8 +11,11 @@ import type { TypedData } from '../message-signing/TypedData';
1111import type { InterpretResponse } from './types' ;
1212import { getGas } from './getGas' ;
1313import type { ChainId } from './ChainId' ;
14- import { getFungibleAsset } from './actionAsset' ;
15- import { convertAssetToFungibleOutline } from './addressAction' ;
14+ import { getFungibleAsset , getNftAsset } from './actionAsset' ;
15+ import {
16+ convertAssetToFungibleOutline ,
17+ convertNftToNftPreview ,
18+ } from './addressAction' ;
1619
1720type LegacyInterpretResponse = Omit < InterpretResponse , 'action' > & {
1821 action : AddressAction | null ;
@@ -129,73 +132,85 @@ async function convertToNewInterpretation(
129132 direction : 'in' as const ,
130133 amount : {
131134 currency,
132- quantity : baseToCommon (
133- transfer . quantity ,
134- getDecimals ( {
135- asset : getFungibleAsset (
136- transfer . asset
137- ) as Asset ,
138- chain : createChain (
139- legacyAction . transaction . chain
140- ) ,
141- } )
142- ) . toFixed ( ) ,
143- value : baseToCommon (
144- transfer . quantity ,
145- getDecimals ( {
146- asset : getFungibleAsset (
147- transfer . asset
148- ) as Asset ,
149- chain : createChain (
150- legacyAction . transaction . chain
151- ) ,
152- } )
153- )
154- . multipliedBy ( transfer . price || 0 )
155- . toNumber ( ) ,
135+ quantity : getFungibleAsset ( transfer . asset )
136+ ? baseToCommon (
137+ transfer . quantity ,
138+ getDecimals ( {
139+ asset : getFungibleAsset (
140+ transfer . asset
141+ ) as Asset ,
142+ chain : createChain (
143+ legacyAction . transaction . chain
144+ ) ,
145+ } )
146+ ) . toFixed ( )
147+ : '1' ,
148+ value : getFungibleAsset ( transfer . asset )
149+ ? baseToCommon (
150+ transfer . quantity ,
151+ getDecimals ( {
152+ asset : getFungibleAsset (
153+ transfer . asset
154+ ) as Asset ,
155+ chain : createChain (
156+ legacyAction . transaction . chain
157+ ) ,
158+ } )
159+ )
160+ . multipliedBy ( transfer . price || 0 )
161+ . toNumber ( )
162+ : null ,
156163 usdValue : null ,
157164 } ,
158165 fungible : convertAssetToFungibleOutline (
159166 getFungibleAsset ( transfer . asset )
160167 ) ,
161- nft : null ,
168+ nft : convertNftToNftPreview (
169+ getNftAsset ( transfer . asset ) as NFT | null
170+ ) ,
162171 } )
163172 ) || [ ] ) ,
164173 ...( legacyAction . content . transfers . outgoing ?. map (
165174 ( transfer ) => ( {
166175 direction : 'out' as const ,
167176 amount : {
168177 currency,
169- quantity : baseToCommon (
170- transfer . quantity ,
171- getDecimals ( {
172- asset : getFungibleAsset (
173- transfer . asset
174- ) as Asset ,
175- chain : createChain (
176- legacyAction . transaction . chain
177- ) ,
178- } )
179- ) . toFixed ( ) ,
180- value : baseToCommon (
181- transfer . quantity ,
182- getDecimals ( {
183- asset : getFungibleAsset (
184- transfer . asset
185- ) as Asset ,
186- chain : createChain (
187- legacyAction . transaction . chain
188- ) ,
189- } )
190- )
191- . multipliedBy ( transfer . price || 0 )
192- . toNumber ( ) ,
178+ quantity : getFungibleAsset ( transfer . asset )
179+ ? baseToCommon (
180+ transfer . quantity ,
181+ getDecimals ( {
182+ asset : getFungibleAsset (
183+ transfer . asset
184+ ) as Asset ,
185+ chain : createChain (
186+ legacyAction . transaction . chain
187+ ) ,
188+ } )
189+ ) . toFixed ( )
190+ : '1' ,
191+ value : getFungibleAsset ( transfer . asset )
192+ ? baseToCommon (
193+ transfer . quantity ,
194+ getDecimals ( {
195+ asset : getFungibleAsset (
196+ transfer . asset
197+ ) as Asset ,
198+ chain : createChain (
199+ legacyAction . transaction . chain
200+ ) ,
201+ } )
202+ )
203+ . multipliedBy ( transfer . price || 0 )
204+ . toNumber ( )
205+ : null ,
193206 usdValue : null ,
194207 } ,
195208 fungible : convertAssetToFungibleOutline (
196209 getFungibleAsset ( transfer . asset )
197210 ) ,
198- nft : null ,
211+ nft : convertNftToNftPreview (
212+ getNftAsset ( transfer . asset ) as NFT | null
213+ ) ,
199214 } )
200215 ) || [ ] ) ,
201216 ]
0 commit comments