1- import { mul , toFixed } from 'biggystring'
21import { EdgeAccount , EdgeCurrencyConfig , EdgeCurrencyWallet , EdgeDenomination , EdgeTransaction } from 'edge-core-js'
32import * as React from 'react'
43import { View } from 'react-native'
@@ -7,12 +6,12 @@ import { sprintf } from 'sprintf-js'
76
87import { FIO_STR } from '../../../constants/WalletAndCurrencyConstants'
98import { lstrings } from '../../../locales/strings'
10- import { getExchangeDenomByCurrencyCode , selectDisplayDenomByCurrencyCode } from '../../../selectors/DenominationSelectors'
9+ import { selectDisplayDenomByCurrencyCode } from '../../../selectors/DenominationSelectors'
1110import { config } from '../../../theme/appConfig'
1211import { connect } from '../../../types/reactRedux'
1312import { EdgeSceneProps } from '../../../types/routerTypes'
1413import { EdgeAsset } from '../../../types/types'
15- import { getTokenIdForced } from '../../../util/CurrencyInfoHelpers '
14+ import { CryptoAmount } from '../../../util/CryptoAmount '
1615import { getWalletName } from '../../../util/CurrencyWalletHelpers'
1716import { getDomainRegInfo } from '../../../util/FioAddressUtils'
1817import { logEvent , TrackingEventName , TrackingValues } from '../../../util/tracking'
@@ -33,7 +32,6 @@ interface StateProps {
3332 fioPlugin ?: EdgeCurrencyConfig
3433 fioWallets : EdgeCurrencyWallet [ ]
3534 fioDisplayDenomination : EdgeDenomination
36- pluginId : string
3735 isConnected : boolean
3836}
3937
@@ -121,7 +119,7 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
121119 }
122120
123121 onNextPress = ( ) : void => {
124- const { account, isConnected, navigation, route, onLogEvent : logEvent } = this . props
122+ const { account, isConnected, navigation, route, onLogEvent } = this . props
125123 const { fioDomain, selectedWallet } = route . params
126124 const { feeValue, paymentInfo : allPaymentInfo , paymentWallet } = this . state
127125
@@ -143,11 +141,16 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
143141 this . props . onSelectWallet ( walletId , paymentCurrencyCode )
144142
145143 const wallet = account . currencyWallets [ walletId ]
146- const exchangeDenomination = getExchangeDenomByCurrencyCode ( wallet . currencyConfig , paymentCurrencyCode )
147- let nativeAmount = mul ( allPaymentInfo [ paymentCurrencyCode ] . amount , exchangeDenomination . multiplier )
148- nativeAmount = toFixed ( nativeAmount , 0 , 0 )
144+ const { amount : exchangeAmount , address : paymentAddress } = allPaymentInfo [ paymentCurrencyCode ]
145+
146+ const cryptoAmount = new CryptoAmount ( {
147+ exchangeAmount,
148+ currencyCode : paymentCurrencyCode ,
149+ currencyConfig : wallet . currencyConfig
150+ } )
151+
152+ const { tokenId, nativeAmount } = cryptoAmount
149153
150- const tokenId = getTokenIdForced ( account , wallet . currencyInfo . pluginId , paymentCurrencyCode )
151154 const sendParams : SendScene2Params = {
152155 walletId,
153156 tokenId,
@@ -162,7 +165,7 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
162165 spendTargets : [
163166 {
164167 nativeAmount,
165- publicAddress : allPaymentInfo [ paymentCurrencyCode ] . address
168+ publicAddress : paymentAddress
166169 }
167170 ] ,
168171 metadata : {
@@ -184,7 +187,12 @@ class FioDomainRegisterSelectWallet extends React.PureComponent<Props, LocalStat
184187 buttons = { { ok : { label : lstrings . string_ok_cap } } }
185188 />
186189 ) ) . catch ( err => showError ( err ) )
187- logEvent ( 'Fio_Domain_Register' , { exchangeAmount : String ( feeValue ) , currencyCode : paymentWallet . currencyCode } )
190+ onLogEvent ( 'Fio_Domain_Register' , {
191+ conversionValues : {
192+ conversionType : 'crypto' ,
193+ cryptoAmount
194+ }
195+ } )
188196 navigation . navigate ( 'homeTab' , { screen : 'home' } )
189197 }
190198 }
@@ -276,7 +284,6 @@ export const FioDomainRegisterSelectWalletScene = connect<StateProps, DispatchPr
276284 fioWallets : state . ui . wallets . fioWallets ,
277285 fioPlugin : state . core . account . currencyConfig . fio ,
278286 fioDisplayDenomination : selectDisplayDenomByCurrencyCode ( state , params . selectedWallet . currencyConfig , FIO_STR ) ,
279- pluginId : params . selectedWallet . currencyInfo . pluginId ,
280287 isConnected : state . network . isConnected
281288 } ) ,
282289 dispatch => ( {
0 commit comments