Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "integrate alldomains to helium wallet: (#416)" #419

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"@ledgerhq/react-native-hw-transport-ble": "6.27.2",
"@metaplex-foundation/js": "0.17.6",
"@metaplex-foundation/mpl-bubblegum": "0.6.0",
"@onsol/tldparser": "^0.5.3",
"@pythnetwork/client": "^2.17.0",
"@react-native-async-storage/async-storage": "1.18.1",
"@react-native-community/blur": "4.3.0",
Expand Down Expand Up @@ -292,29 +291,29 @@
"tls": false
},
"browser": {
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"_stream_readable": "readable-stream/readable",
"_stream_transform": "readable-stream/transform",
"_stream_writable": "readable-stream/writable",
"zlib": "browserify-zlib",
"console": "console-browserify",
"constants": "constants-browserify",
"crypto": "react-native-crypto",
"dgram": "react-native-udp",
"dns": "dns.js",
"net": "react-native-tcp",
"domain": "domain-browser",
"fs": "react-native-level-fs",
"http": "@tradle/react-native-http",
"https": "https-browserify",
"net": "react-native-tcp",
"os": "react-native-os",
"path": "path-browserify",
"querystring": "querystring-es3",
"fs": "react-native-level-fs",
"_stream_transform": "readable-stream/transform",
"_stream_readable": "readable-stream/readable",
"_stream_writable": "readable-stream/writable",
"_stream_duplex": "readable-stream/duplex",
"_stream_passthrough": "readable-stream/passthrough",
"dgram": "react-native-udp",
"stream": "stream-browserify",
"timers": "timers-browserify",
"tls": false,
"tty": "tty-browserify",
"vm": "vm-browserify",
"zlib": "browserify-zlib"
"tls": false
}
}
30 changes: 0 additions & 30 deletions src/features/addressBook/ContactDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import useAlert from '@hooks/useAlert'
import CloseButton from '@components/CloseButton'
import { solAddressIsValid, accountNetType } from '@utils/accountUtils'
import { heliumAddressFromSolAddress } from '@helium/spl-utils'
import { useDebounce } from 'use-debounce'
import { fetchDomainOwner } from '@utils/getDomainOwner'
import { HomeNavigationProp } from '../home/homeTypes'
import { useAccountStorage } from '../../storage/AccountStorageProvider'
import {
Expand All @@ -39,7 +37,6 @@ import {
import { useAppStorage } from '../../storage/AppStorageProvider'
import AddressExtra from './AddressExtra'
import { CSAccount } from '../../storage/cloudStorage'
import { useSolana } from '../../solana/SolanaProvider'

const BUTTON_HEIGHT = 55

Expand All @@ -65,9 +62,6 @@ const ContactDetails = ({ action, contact }: Props) => {
const { scannedAddress, setScannedAddress } = useAppStorage()
const spacing = useSpacing()
const { showOKCancelAlert } = useAlert()
const { connection } = useSolana()
// debounce is needed to avoid unneccessary rpc calls
const [debouncedAddress] = useDebounce(address, 800)

useEffect(() => {
if (route.params?.address) {
Expand All @@ -77,30 +71,6 @@ const ContactDetails = ({ action, contact }: Props) => {
}
}, [contact, route])

const handleDomainAddress = useCallback(
async ({ domain }: { domain: string }) => {
if (!connection) return
return fetchDomainOwner(connection, domain)
},
[connection],
)

useEffect(() => {
// only parse addresses which include dots.
if (debouncedAddress.split('.').length === 2) {
handleDomainAddress({ domain: debouncedAddress }).then(
(resolvedAddress) => {
// owner was not found so we do not set the owner address
if (!resolvedAddress) return
setAddress(resolvedAddress)
// if nickname was previously set we ignore setting the domain as nickname
if (nickname) return
setNickname(debouncedAddress)
},
)
}
}, [debouncedAddress, handleDomainAddress, nickname])

const onRequestClose = useCallback(() => {
homeNav.goBack()
}, [homeNav])
Expand Down
15 changes: 8 additions & 7 deletions src/features/payment/PaymentItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
NativeSyntheticEvent,
TextInputEndEditingEventData,
} from 'react-native'
import { useDebouncedCallback } from 'use-debounce'
import { CSAccount } from '../../storage/cloudStorage'
import { useBalance } from '../../utils/Balance'
import { accountNetType, ellipsizeAddress } from '../../utils/accountUtils'
Expand Down Expand Up @@ -121,12 +120,14 @@ const PaymentItem = ({
onToggleMax({ address, index })
}, [address, index, onToggleMax])

// debounce is needed to avoid unneccessary rpc calls
const handleEditAddress = useDebouncedCallback((text?: string) => {
onEditAddress({ address: text || '', index })
}, 800)
const handleEditAddress = useCallback(
(text?: string) => {
onEditAddress({ address: text || '', index })
},
[index, onEditAddress],
)

const handleAddressBlur = useDebouncedCallback(
const handleAddressBlur = useCallback(
(event?: NativeSyntheticEvent<TextInputEndEditingEventData>) => {
const text = event?.nativeEvent.text
handleAddressError({
Expand All @@ -135,7 +136,7 @@ const PaymentItem = ({
isHotspotOrValidator: false,
})
},
800,
[handleAddressError, index],
)

const handleRemove = useCallback(() => {
Expand Down
32 changes: 4 additions & 28 deletions src/features/payment/PaymentScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view
import { useSafeAreaInsets } from 'react-native-safe-area-context'
import Toast from 'react-native-simple-toast'
import { useSelector } from 'react-redux'
import { fetchDomainOwner } from '@utils/getDomainOwner'
import useSubmitTxn from '../../hooks/useSubmitTxn'
import { RootNavigationProp } from '../../navigation/rootTypes'
import { useSolana } from '../../solana/SolanaProvider'
Expand Down Expand Up @@ -132,7 +131,7 @@ const PaymentScreen = () => {
return new BN(balanceBigint.toString())
}
}, [balanceBigint])
const { anchorProvider, connection } = useSolana()
const { anchorProvider } = useSolana()

const appDispatch = useAppDispatch()
const navigation = useNavigation<HomeNavigationProp>()
Expand Down Expand Up @@ -490,14 +489,6 @@ const PaymentScreen = () => {
[dispatch],
)

const handleDomainAddress = useCallback(
async ({ domain }: { domain: string }) => {
if (!connection) return
return fetchDomainOwner(connection, domain)
},
[connection],
)

const handleAddressError = useCallback(
({
index,
Expand All @@ -514,12 +505,6 @@ const PaymentScreen = () => {
}
let invalidAddress = false

// only handle address which include dots.
if (address.split('.').length === 2) {
// retrieve the address which has been set previously by handleEditAddress.
/* eslint-disable-next-line no-param-reassign */
address = paymentState.payments[index].address || ''
}
invalidAddress = !!address && !solAddressIsValid(address)

const wrongNetType =
Expand All @@ -528,28 +513,20 @@ const PaymentScreen = () => {
accountNetType(address) !== networkType
handleSetPaymentError(index, invalidAddress || wrongNetType)
},
[handleSetPaymentError, networkType, paymentState],
[handleSetPaymentError, networkType],
)

const handleEditAddress = useCallback(
async ({ index, address }: { index: number; address: string }) => {
if (index === undefined || !currentAccount || !anchorProvider) return
let domain = ''
if (address.split('.').length === 2) {
const resolvedAddress =
(await handleDomainAddress({ domain: address })) || ''
/* eslint-disable-next-line no-param-reassign */
address = resolvedAddress
// if the address is resolved then the domain could also be an alias/nickname of the address.
if (resolvedAddress) domain = address
}

const allAccounts = unionBy(
contacts,
Object.values(accounts || {}),
({ address: addr }) => addr,
)
let contact = allAccounts.find((c) => c.address === address)
if (!contact) contact = { address, netType: networkType, alias: domain }
if (!contact) contact = { address, netType: networkType, alias: '' }

const createTokenAccountFee =
await calcCreateAssociatedTokenAccountAccountFee(
Expand All @@ -574,7 +551,6 @@ const PaymentScreen = () => {
networkType,
anchorProvider,
mint,
handleDomainAddress,
],
)

Expand Down
16 changes: 0 additions & 16 deletions src/utils/getDomainOwner.ts

This file was deleted.

8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3320,14 +3320,6 @@
mkdirp "^1.0.4"
rimraf "^3.0.2"

"@onsol/tldparser@^0.5.3":
version "0.5.3"
resolved "https://registry.yarnpkg.com/@onsol/tldparser/-/tldparser-0.5.3.tgz#f5a0a06fa69af0e8a2783464bbd32b3e88ad0b1a"
integrity sha512-rICUDhYPwDuO81wo4HI7QSCf6kQiaM0mSv3HKBJPrRxliIvgwanAoU5H0p54HEdAKeS3pmeLi5wB6ROpGxTZ/A==
dependencies:
"@ethersproject/sha2" "^5.7.0"
"@metaplex-foundation/beet-solana" "^0.4.0"

"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2":
version "1.1.2"
resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf"
Expand Down
Loading