11import { Panel } from "@namada/components" ;
2+ import { MaxMaspTxAmountProps } from "@namada/sdk-multicore" ;
23import { AccountType } from "@namada/types" ;
34import { MaspSyncCover } from "App/Common/MaspSyncCover" ;
45import { NamadaTransferTopHeader } from "App/NamadaTransfer/NamadaTransferTopHeader" ;
@@ -9,6 +10,7 @@ import {
910} from "App/Transfer/TransferModule" ;
1011import { allDefaultAccountsAtom } from "atoms/accounts" ;
1112import {
13+ estimateMaxMaspTxAmountAtom ,
1214 lastCompletedShieldedSyncAtom ,
1315 namadaShieldedAssetsAtom ,
1416} from "atoms/balance/atoms" ;
@@ -25,7 +27,8 @@ import { wallets } from "integrations";
2527import invariant from "invariant" ;
2628import { useAtom , useAtomValue } from "jotai" ;
2729import { createTransferDataFromNamada } from "lib/transactions" ;
28- import { useState } from "react" ;
30+ import { useMemo , useState } from "react" ;
31+ import { isNamadaAsset , toBaseAmount } from "utils" ;
2932
3033export const MaspUnshield : React . FC = ( ) => {
3134 const [ displayAmount , setDisplayAmount ] = useState < BigNumber | undefined > ( ) ;
@@ -140,6 +143,43 @@ export const MaspUnshield: React.FC = () => {
140143 }
141144 }
142145 } ;
146+
147+ const www = useMemo ( ( ) => {
148+ let props : MaxMaspTxAmountProps | null ;
149+ if ( ! feeProps || ! account || ! destinationAddress || ! selectedAsset ) {
150+ props = null ;
151+ } else {
152+ props = {
153+ maxNotes : 6 ,
154+ source : account . pseudoExtendedKey ! ,
155+ target : destinationAddress ,
156+ token : selectedAsset . asset . address ,
157+ feeToken : feeProps . gasConfig . gasToken ,
158+ amount :
159+ isNamadaAsset ( selectedAsset . asset ) ?
160+ selectedAsset . amount . toString ( )
161+ : toBaseAmount ( selectedAsset . asset , selectedAsset . amount ) . toString ( ) ,
162+ feeAmount : feeProps . gasConfig . gasPriceInMinDenom
163+ . times ( feeProps . gasConfig . gasLimit )
164+ . toString ( ) ,
165+ } ;
166+ console . log ( props . feeAmount ) ;
167+ console . log ( props . amount ) ;
168+ console . log ( feeProps . gasConfig . gasPriceInMinDenom . toString ( ) ) ;
169+ }
170+
171+ return estimateMaxMaspTxAmountAtom ( props ) ;
172+ } , [
173+ selectedAsset ?. asset . address ,
174+ feeProps . gasConfig . gasToken ,
175+ feeProps ?. gasConfig . gasLimit . toString ( ) ,
176+ account ?. pseudoExtendedKey ,
177+ destinationAddress ,
178+ ] ) ;
179+
180+ const res = useAtomValue ( www ) ;
181+ console . log ( res ) ;
182+
143183 // We stop the ledger status check when the transfer is in progress
144184 setLedgerStatusStop ( isPerformingTransfer ) ;
145185
0 commit comments