Skip to content

Commit

Permalink
feature(resolver): cns integration (#2959)
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss authored Jan 5, 2024
1 parent c2ff585 commit 30061c5
Show file tree
Hide file tree
Showing 38 changed files with 2,129 additions and 125 deletions.
2 changes: 2 additions & 0 deletions apps/wallet-mobile/src/TxHistory/TxHistoryNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {useSelectedWallet} from '../SelectedWallet'
import {COLORS} from '../theme'
import {useFrontendFees, useStakingKey, useWalletName} from '../yoroi-wallets/hooks'
import {isMainnetNetworkId} from '../yoroi-wallets/utils'
import {CardanoMobile} from '../yoroi-wallets/wallets'
import {ModalInfo} from './ModalInfo'
import {TxDetails} from './TxDetails'
import {TxHistory} from './TxHistory'
Expand Down Expand Up @@ -96,6 +97,7 @@ export const TxHistoryNavigator = () => {
apiKey: CONFIG.UNSTOPPABLE_API_KEY,
},
},
csl: CardanoMobile,
})
const resolverStorage = resolverStorageMaker()
return resolverManagerMaker(resolverStorage, resolverApi)
Expand Down
1 change: 0 additions & 1 deletion apps/wallet-mobile/src/features/Claim/module/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const postClaimTokens =
if (isLeft(response)) {
return asClaimApiError(response.error)
} else {
console.log('---------- | -----------')
const claimToken = response.value.data
if (!ClaimTokensApiResponseSchema.safeParse(claimToken).success) throw new Api.Errors.ResponseMalformed()

Expand Down
11 changes: 11 additions & 0 deletions apps/wallet-mobile/src/features/Send/common/useSendReceiver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export const useSendReceiver = () => {
enabled: false,
},
)

const isNotResolvedDomain = React.useMemo(
() =>
!isUnsupportedDomain &&
!isResolvingAddressess &&
cryptoAddresses.length > 0 &&
cryptoAddresses.every(({error}) => error !== null),
[cryptoAddresses, isResolvingAddressess, isUnsupportedDomain],
)

const debouncedRefetch = React.useMemo(() => debounceMaker(refetch, 300), [refetch])

const cancelPendingRequests = React.useCallback(
Expand Down Expand Up @@ -65,6 +75,7 @@ export const useSendReceiver = () => {
}, [addressRecordsFetched, cryptoAddresses, isSuccess])

return {
isNotResolvedDomain,
isResolvingAddressess,
isUnsupportedDomain,
receiverError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Boundary} from '../../../../../components'
import {SelectedWalletProvider} from '../../../../../SelectedWallet'
import {YoroiWallet} from '../../../../../yoroi-wallets/cardano/types'
import {mocks as walletMocks} from '../../../../../yoroi-wallets/mocks/wallet'
import {CardanoMobile} from '../../../../../yoroi-wallets/wallets'
import {SendProvider} from '../../../common/SendContext'
import {InputReceiver} from './InputReceiver'

Expand All @@ -20,6 +21,7 @@ storiesOf('Send InputReceiver', module)
apiKey: 'apiKey',
},
},
csl: CardanoMobile,
})
const resolverStorage = resolverStorageMaker()
const resolverManager = resolverManagerMaker(resolverStorage, resolverApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Boundary} from '../../../../../components'
import {SelectedWalletProvider} from '../../../../../SelectedWallet'
import {YoroiWallet} from '../../../../../yoroi-wallets/cardano/types'
import {mocks as walletMocks} from '../../../../../yoroi-wallets/mocks/wallet'
import {CardanoMobile} from '../../../../../yoroi-wallets/wallets'
import {initialState, SendProvider, SendState} from '../../../common/SendContext'
import {ShowResolvedAddressSelected} from './ShowResolvedAddressSelected'

Expand All @@ -32,6 +33,7 @@ const Wrapper = ({ns}: {ns: Partial<SendState>}) => {
apiKey: 'apiKey',
},
},
csl: CardanoMobile,
})
const resolverStorage = resolverStorageMaker()
const resolverManager = resolverManagerMaker(resolverStorage, resolverApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Boundary} from '../../../../../components'
import {SelectedWalletProvider} from '../../../../../SelectedWallet'
import {YoroiWallet} from '../../../../../yoroi-wallets/cardano/types'
import {mocks as walletMocks} from '../../../../../yoroi-wallets/mocks/wallet'
import {CardanoMobile} from '../../../../../yoroi-wallets/wallets'
import {SendProvider} from '../../../common/SendContext'
import {NotifySupportedNameServers} from './NotifySupportedNameServers'

Expand All @@ -21,6 +22,7 @@ const Initial = () => {
apiKey: 'apiKey',
},
},
csl: CardanoMobile,
})
const resolverStorage = resolverStorageMaker()
const resolverManager = resolverManagerMaker(resolverStorage, resolverApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Boundary} from '../../../../../components'
import {SelectedWalletProvider} from '../../../../../SelectedWallet'
import {YoroiWallet} from '../../../../../yoroi-wallets/cardano/types'
import {mocks as walletMocks} from '../../../../../yoroi-wallets/mocks/wallet'
import {CardanoMobile} from '../../../../../yoroi-wallets/wallets'
import {initialState, SendProvider, SendState} from '../../../common/SendContext'
import {SelectNameServer} from './SelectNameServer'

Expand All @@ -31,6 +32,7 @@ const UnselectedNS = () => {
apiKey: 'apiKey',
},
},
csl: CardanoMobile,
})
const resolverStorage = resolverStorageMaker()
const resolverManager = resolverManagerMaker(resolverStorage, resolverApi)
Expand All @@ -53,6 +55,7 @@ const SelectedNS = () => {
apiKey: 'apiKey',
},
},
csl: CardanoMobile,
})
const resolverStorage = resolverStorageMaker()
const resolverManager = resolverManagerMaker(resolverStorage, resolverApi)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ export const StartMultiTokenTxScreen = () => {
const receiver = targets[selectedTargetIndex].receiver
const shouldOpenAddToken = Amounts.toArray(amounts).length === 0

const {isResolvingAddressess, receiverError, isUnsupportedDomain} = useSendReceiver()
const {isResolvingAddressess, receiverError, isUnsupportedDomain, isNotResolvedDomain} = useSendReceiver()
const {isValidatingAddress, addressError, addressValidated} = useSendAddress()

const isLoading = isResolvingAddressess || isValidatingAddress
const {hasReceiverError, receiverErrorMessage} = useReceiverError({
isNotResolvedDomain,
isUnsupportedDomain,
isLoading,
receiverError,
Expand Down Expand Up @@ -111,11 +112,13 @@ export const StartMultiTokenTxScreen = () => {
const Actions = ({style, ...props}: ViewProps) => <View style={[styles.actions, style]} {...props} />

const useReceiverError = ({
isNotResolvedDomain,
isUnsupportedDomain,
receiverError,
addressError,
isLoading,
}: {
isNotResolvedDomain: boolean
isUnsupportedDomain: boolean
isLoading: boolean
receiverError: Error | null
Expand All @@ -127,6 +130,8 @@ const useReceiverError = ({
if (isLoading) return {hasReceiverError: false, receiverErrorMessage: ''}
if (isUnsupportedDomain)
return {hasReceiverError: true, receiverErrorMessage: strings.helperResolverErrorUnsupportedDomain}
if (isNotResolvedDomain)
return {hasReceiverError: true, receiverErrorMessage: strings.helperResolverErrorUnsupportedDomain}
if (receiverError != null)
return {hasReceiverError: true, receiverErrorMessage: strings.helperResolverErrorUnsupportedDomain}
if (addressError instanceof AddressErrorWrongNetwork)
Expand Down
Loading

0 comments on commit 30061c5

Please sign in to comment.