Skip to content

Commit

Permalink
fixup! Upgrade edge-core-js to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
swansontec authored and paullinator committed Jan 5, 2024
1 parent 12b1067 commit 163f262
Show file tree
Hide file tree
Showing 42 changed files with 80 additions and 91 deletions.
1 change: 0 additions & 1 deletion src/__tests__/components/ExchangeQuoteComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ describe('ExchangeQuote', () => {
return {
transaction: {
blockHeight: 500000,
tokenId: null,
currencyCode: 'BTC',
date: 1524476980,
deviceDescription: 'iphone12',
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/components/TransactionListRow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ describe('TransactionListRow', () => {
transaction={{
blockHeight: 10,
currencyCode: 'BTC',
tokenId: null,
date: 123456789,
nativeAmount: '-100001',
isSend: true,
Expand Down
2 changes: 0 additions & 2 deletions src/__tests__/modals/AccelerateTxModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ describe('AccelerateTxModalComponent', () => {
replacedTx={{
blockHeight: 0,
currencyCode: 'BTC',
tokenId: null,
date: 0,
isSend: true,
memos: [],
Expand All @@ -40,7 +39,6 @@ describe('AccelerateTxModalComponent', () => {
acceleratedTx={{
blockHeight: 0,
currencyCode: 'BTC',
tokenId: null,
date: 0,
isSend: true,
memos: [],
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/modals/AdvancedDetailsCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('AdvancedDetailsCard', () => {
transaction={{
blockHeight: 0,
currencyCode: 'BCH',
tokenId: null,
date: 0,
isSend: true,
memos: [],
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/scenes/CryptoExchangeQuoteScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ describe('CryptoExchangeQuoteScreenComponent', () => {
transaction: {
blockHeight: 500000,
currencyCode: 'BTC',
tokenId: null,
date: 1524476980,
deviceDescription: 'iphone12',
isSend: false,
Expand Down
2 changes: 0 additions & 2 deletions src/__tests__/scenes/TransactionDetailsScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('TransactionDetailsScene', () => {
<TransactionDetailsScene
{...fakeSceneProps('transactionDetails', {
edgeTransaction: {
tokenId: null,
blockHeight: 0,
currencyCode: 'BTC',
date: 1535752780.947, // 2018-08-31T21:59:40.947Z
Expand Down Expand Up @@ -106,7 +105,6 @@ describe('TransactionDetailsScene', () => {
<TransactionDetailsScene
{...fakeSceneProps('transactionDetails', {
edgeTransaction: {
tokenId: null,
blockHeight: 0,
currencyCode: 'BTC',
date: 1535752780.947, // 2018-08-31T21:59:40.947Z
Expand Down
4 changes: 2 additions & 2 deletions src/actions/DeepLinkingActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export async function handleLink(navigation: NavigationBase, dispatch: Dispatch,
for (const wallet of Object.values(currencyWallets)) {
const parsedUri = await wallet.parseUri(link.uri).catch(e => undefined)
if (parsedUri != null) {
const { tokenId } = parsedUri
const { tokenId = null } = parsedUri
matchingWalletIdsAndUris.push({ currencyCode: parsedUri.currencyCode, walletId: wallet.id, parsedUri, tokenId })
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ export async function handleLink(navigation: NavigationBase, dispatch: Dispatch,
}

async function launchAzteco(navigation: NavigationBase, edgeWallet: EdgeCurrencyWallet, uri: string): Promise<void> {
const address = await edgeWallet.getReceiveAddress()
const address = await edgeWallet.getReceiveAddress({ tokenId: null })
const response = await fetch(`${uri}${address.publicAddress}`)
if (response.ok) {
showToast(lstrings.azteco_success)
Expand Down
2 changes: 1 addition & 1 deletion src/actions/ScanActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function handleWalletUris(
fioAddress?: string
): ThunkAction<Promise<void>> {
return async (dispatch, getState) => {
const { legacyAddress, metadata, minNativeAmount, nativeAmount, publicAddress, uniqueIdentifier, tokenId } = parsedUri
const { legacyAddress, metadata, minNativeAmount, nativeAmount, publicAddress, uniqueIdentifier, tokenId = null } = parsedUri
const currencyCode: string = parsedUri.currencyCode ?? wallet.currencyInfo.currencyCode

// Coin operations
Expand Down
2 changes: 1 addition & 1 deletion src/actions/WalletActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function selectEOSWallet(navigation: NavigationBase, walletId: string, currencyC
currencyInfo: { currencyCode, pluginId }
} = wallet
const walletName = name ?? ''
const { publicAddress } = await wallet.getReceiveAddress()
const { publicAddress } = await wallet.getReceiveAddress({ tokenId: null })

if (publicAddress !== '') {
// already activated
Expand Down
4 changes: 2 additions & 2 deletions src/actions/WalletListActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const getFirstCurrencyAddress = async (currencyCode: string, getState: GetState)
})
if (walletId) {
const wallet = edgeWallets[walletId]
return (await wallet.getReceiveAddress()).publicAddress
return (await wallet.getReceiveAddress({ tokenId: null })).publicAddress
}

// Wallet Creation
Expand All @@ -79,7 +79,7 @@ const getFirstCurrencyAddress = async (currencyCode: string, getState: GetState)
const wallet = await showFullScreenSpinner(lstrings.wallet_list_referral_link_currency_loading, createWallet)
logActivity(`Create Wallet (wallet list): ${account.username} -- ${createWalletTypes.walletType} -- ${defaultIsoFiat ?? ''}`)

const receiveAddress = await wallet.getReceiveAddress()
const receiveAddress = await wallet.getReceiveAddress({ tokenId: null })
return receiveAddress.publicAddress
}

Expand Down
2 changes: 1 addition & 1 deletion src/actions/WalletListMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function walletListMenuAction(
if (tokenId == null) {
if (fioAddress) {
additionalMsg = lstrings.fragmet_wallets_delete_fio_extra_message_mobile
} else if (wallet.currencyInfo.metaTokens.length > 0) {
} else if (Object.keys(wallet.currencyConfig.allTokens).length > 0) {
additionalMsg = lstrings.fragmet_wallets_delete_eth_extra_message
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/components/icons/CryptoIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CryptoIconComponent = (props: Props) => {
if (pluginId == null) return null

// Get Currency Icon URI
const icon = getCurrencyIconUris(pluginId, tokenId ?? undefined)
const icon = getCurrencyIconUris(pluginId, tokenId)
const source = { uri: mono ? icon.symbolImageDarkMono : icon.symbolImage }

// Return Currency logo from the edge server
Expand Down
6 changes: 3 additions & 3 deletions src/components/scenes/Fio/FioAddressRegisterScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class FioAddressRegister extends React.Component<Props, State> {
checkFreeAddress = async () => {
try {
const { fioPlugin } = this.props
const publicDomains = await fioPlugin.otherMethods.getDomains(fioPlugin.currencyInfo.defaultSettings.freeAddressRef)
const publicDomains = await fioPlugin.otherMethods.getDomains(fioPlugin.currencyInfo.defaultSettings?.freeAddressRef)
if (publicDomains.findIndex((publicDomain: FioPublicDomain) => publicDomain.free) > -1) {
this.setState({ showFreeAddressLink: true })
}
Expand All @@ -105,7 +105,7 @@ export class FioAddressRegister extends React.Component<Props, State> {
getPublicDomains = async () => {
const { fioPlugin } = this.props
try {
const publicDomains = await fioPlugin.otherMethods.getDomains(fioPlugin.currencyInfo.defaultSettings.fallbackRef)
const publicDomains = await fioPlugin.otherMethods.getDomains(fioPlugin.currencyInfo.defaultSettings?.fallbackRef)
const publicDomainsConverted = publicDomains
// @ts-expect-error
.sort(publicDomain => (publicDomain.domain === FIO_DOMAIN_DEFAULT.name ? -1 : 1))
Expand Down Expand Up @@ -149,7 +149,7 @@ export class FioAddressRegister extends React.Component<Props, State> {
if (!fioWallets.length) return
if (!selectedWallet) return
const publicKey = selectedWallet.publicWalletInfo.keys.publicKey
const url = `${fioPlugin.currencyInfo.defaultSettings.fioAddressRegUrl}${fioPlugin.currencyInfo.defaultSettings.freeAddressRef}?publicKey=${publicKey}`
const url = `${fioPlugin.currencyInfo.defaultSettings?.fioAddressRegUrl}${fioPlugin.currencyInfo.defaultSettings?.freeAddressRef}?publicKey=${publicKey}`
try {
await openLink(url)
} catch (e: any) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/scenes/Fio/FioConnectWalletConfirmScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class FioConnectWalletConfirm extends React.Component<Props, State> {
walletId: wallet.id,
tokenCode: wallet.currencyCode,
chainCode: wallet.chainCode,
publicAddress: (await wallet.edgeWallet.getReceiveAddress()).publicAddress
publicAddress: (await wallet.edgeWallet.getReceiveAddress({ tokenId: null })).publicAddress
}))

let publicAddresses = await Promise.all(promiseArray)
Expand All @@ -70,7 +70,7 @@ export class FioConnectWalletConfirm extends React.Component<Props, State> {
walletId: wallet.id,
tokenCode: wallet.currencyCode,
chainCode: wallet.chainCode,
publicAddress: (await wallet.edgeWallet.getReceiveAddress()).publicAddress
publicAddress: (await wallet.edgeWallet.getReceiveAddress({ tokenId: null })).publicAddress
}))

publicAddresses = await Promise.all(promiseArray)
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/Fio/FioCreateHandleScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const FioCreateHandleScene = (props: Props) => {
body: JSON.stringify({
address: fioAccountName,
referralCode: freeRegRefCode,
publicKey: (await wallet.getReceiveAddress()).publicAddress,
publicKey: (await wallet.getReceiveAddress({ tokenId: null })).publicAddress,
redirectUrl: '',
apiToken: freeRegApiToken
})
Expand Down
4 changes: 2 additions & 2 deletions src/components/scenes/Fio/FioNameConfirmScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class FioNameConfirm extends React.PureComponent<Props> {
const response = await fioPlugin.otherMethods.buyAddressRequest(
{
address: fioName,
referralCode: fioPlugin.currencyInfo.defaultSettings.defaultRef,
referralCode: fioPlugin.currencyInfo.defaultSettings?.defaultRef,
publicKey: ownerPublicKey
},
true
)
if (response.error) {
if (response.errorCode && response.errorCode === ONE_FREE_ADDRESS_PER_DOMAIN_ERROR && response.code === 400) {
const publicDomains = await fioPlugin.otherMethods.getDomains(fioPlugin.currencyInfo.defaultSettings.fallbackRef)
const publicDomains = await fioPlugin.otherMethods.getDomains(fioPlugin.currencyInfo.defaultSettings?.fallbackRef)
// @ts-expect-error
const domainExists = publicDomains.find(domain => domain.domain === fioName.split(FIO_ADDRESS_DELIMITER)[1])
if (domainExists && !domainExists.free) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/Fio/FioRequestConfirmationScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class FioRequestConfirmationConnected extends React.Component<Props, Stat
const { amounts } = route.params
const { walletAddresses, fioAddressFrom } = this.state
const walletAddress = walletAddresses.find(({ fioAddress }) => fioAddress === fioAddressFrom)
const { publicAddress } = await edgeWallet.getReceiveAddress()
const { publicAddress } = await edgeWallet.getReceiveAddress({ tokenId: null })

if (walletAddress && fioPlugin) {
const { fioWallet } = walletAddress
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/MigrateWalletCalculateFeeScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const MigrateWalletCalculateFeeComponent = (props: Props) => {

const assetPromises = bundle.map((asset, i) => {
return async () => {
const publicAddress = SPECIAL_CURRENCY_INFO[pluginId].dummyPublicAddress ?? (await wallet.getReceiveAddress()).publicAddress
const publicAddress = SPECIAL_CURRENCY_INFO[pluginId].dummyPublicAddress ?? (await wallet.getReceiveAddress({ tokenId: null })).publicAddress
const spendInfo: EdgeSpendInfo = {
tokenId: asset.tokenId,
spendTargets: [{ publicAddress }],
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/MigrateWalletCompletionScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const MigrateWalletCompletionComponent = (props: Props) => {
// Change old wallet name
if (createdNewWallet) await oldWallet.renameWallet(`${oldWalletName}${lstrings.migrate_wallet_old_fragment}`)

const addressInfo = await newWallet.getReceiveAddress()
const addressInfo = await newWallet.getReceiveAddress({ tokenId: null })
const newPublicAddress = addressInfo.segwitAddress ?? addressInfo.publicAddress

const tokenItems = bundle.filter((pair: any): pair is MigrateWalletTokenItem => pair.tokenId != null)
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/RequestScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class RequestSceneComponent extends React.Component<Props, State> {
if (wallet == null) return
if (isKeysOnlyPlugin(wallet.currencyInfo.pluginId)) return

const receiveAddress = await wallet.getReceiveAddress()
const receiveAddress = await wallet.getReceiveAddress({ tokenId: null })
const addresses: AddressInfo[] = []

// Handle segwitAddress
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/WcConnectScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const WcConnectScene = (props: Props) => {
}, [proposal])

useAsyncEffect(async () => {
const r = await wallet.getReceiveAddress()
const r = await wallet.getReceiveAddress({ tokenId: null })
setWalletAddress(r.publicAddress)
}, [wallet])

Expand Down
2 changes: 1 addition & 1 deletion src/components/themed/ExplorerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ExplorerCard = (props: Props) => {
//

const handlePress = useHandler(async () => {
const receiveAddress = await wallet.getReceiveAddress()
const receiveAddress = await wallet.getReceiveAddress({ tokenId: null })
const url = sprintf(addressExplorer, receiveAddress.publicAddress)
await Linking.openURL(url)
})
Expand Down
1 change: 1 addition & 0 deletions src/components/themed/TransactionListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { lstrings } from '../../locales/strings'
import { getDisplayDenomination, getExchangeDenomination } from '../../selectors/DenominationSelectors'
import { useSelector } from '../../types/reactRedux'
import { NavigationBase } from '../../types/routerTypes'
import { getWalletTokenId } from '../../util/CurrencyInfoHelpers'
import {
DECIMAL_PRECISION,
decimalOrZero,
Expand Down
4 changes: 2 additions & 2 deletions src/components/themed/TransactionListTop.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { add, gt, mul, round } from 'biggystring'
import { EdgeAccount, EdgeBalances, EdgeCurrencyWallet, EdgeDenomination, EdgeTokenId } from 'edge-core-js'
import { EdgeAccount, EdgeBalanceMap, EdgeCurrencyWallet, EdgeDenomination, EdgeTokenId } from 'edge-core-js'
import * as React from 'react'
import { ActivityIndicator, TouchableOpacity, View } from 'react-native'
import { AirshipBridge } from 'react-native-airship'
Expand Down Expand Up @@ -57,7 +57,7 @@ interface OwnProps {

interface StateProps {
account: EdgeAccount
balanceMap: EdgeBalances
balanceMap: EdgeBalanceMap
currencyCode: string
displayDenomination: EdgeDenomination
exchangeDenomination: EdgeDenomination
Expand Down
4 changes: 2 additions & 2 deletions src/components/tiles/AddressTile2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const AddressTile2 = React.forwardRef((props: Props, ref: React.Forwarded
fioAddress = address.toLowerCase()
address = publicAddress
} catch (e: any) {
if (!e.code || e.code !== fioPlugin.currencyInfo.defaultSettings.errorCodes.INVALID_FIO_ADDRESS) {
if (!e.code || e.code !== fioPlugin.currencyInfo.defaultSettings?.errorCodes.INVALID_FIO_ADDRESS) {
setLoading(false)
return showError(e)
}
Expand Down Expand Up @@ -227,7 +227,7 @@ export const AddressTile2 = React.forwardRef((props: Props, ref: React.Forwarded
const wallet = currencyWallets[walletId]

// Prefer segwit address if the selected wallet has one
const { segwitAddress, publicAddress } = await wallet.getReceiveAddress()
const { segwitAddress, publicAddress } = await wallet.getReceiveAddress({ tokenId: null })
const address = segwitAddress != null ? segwitAddress : publicAddress
await changeAddress(address)
})
Expand Down
7 changes: 3 additions & 4 deletions src/controllers/edgeProvider/EdgeProviderServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class EdgeProviderServer implements EdgeProviderMethods {
const wallet = this._selectedWallet
if (wallet == null) throw new Error('No selected wallet')

const receiveAddress = await wallet.getReceiveAddress()
const receiveAddress = await wallet.getReceiveAddress({ tokenId: null })
if (options.metadata != null) {
receiveAddress.metadata = options.metadata
}
Expand All @@ -167,7 +167,7 @@ export class EdgeProviderServer implements EdgeProviderMethods {
const { currencyConfig, currencyInfo, fiatCurrencyCode } = wallet
const { currencyCode } = tokenId == null ? currencyInfo : currencyConfig.allTokens[tokenId]
const walletName = getWalletName(wallet)
const receiveAddress = await wallet.getReceiveAddress()
const receiveAddress = await wallet.getReceiveAddress({ tokenId: null })
const icons = getCurrencyIconUris(wallet.currencyInfo.pluginId, tokenId)

const returnObject: WalletDetails = {
Expand Down Expand Up @@ -426,7 +426,7 @@ export class EdgeProviderServer implements EdgeProviderMethods {
const wallet = this._selectedWallet
if (wallet == null) throw new Error('No selected wallet')

const { publicAddress } = await wallet.getReceiveAddress()
const { publicAddress } = await wallet.getReceiveAddress({ tokenId: null })
const signedMessage = await wallet.signMessage(message, { otherParams: { publicAddress } })
console.log(`signMessage public address:***${publicAddress}***`)
console.log(`signMessage signedMessage:***${signedMessage}***`)
Expand Down Expand Up @@ -555,7 +555,6 @@ export function getReturnCurrencyCode(allowedCurrencyCodes: string[] | undefined

function cleanTx(tx: EdgeTransaction): EdgeTransaction {
const newTx: EdgeTransaction = {
tokenId: tx.tokenId,
blockHeight: tx.blockHeight,
confirmations: tx.confirmations,
currencyCode: tx.currencyCode,
Expand Down
5 changes: 2 additions & 3 deletions src/controllers/edgeProvider/types/edgeProviderCleaners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
WalletDetails
} from './edgeProviderTypes'

const asEdgeMetadata = asObject<EdgeMetadata>({
const asEdgeMetadata = asObject<EdgeMetadata & { amountFiat?: number }>({
amountFiat: asOptional(asNumber),
bizId: asOptional(asNumber),
category: asOptional(asString),
Expand Down Expand Up @@ -45,10 +45,9 @@ const asEdgeMemo = asObject<EdgeMemo>({
})

const asEdgeTransaction = asObject<EdgeTransaction>({
tokenId: asEdgeTokenId,
walletId: asString,
tokenId: asEdgeTokenId,
currencyCode: asString,
tokenId: asOptional(asString, null),

// Amounts:
nativeAmount: asString,
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useWalletConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function useWalletConnect(): WalletConnect {
const chainId = SPECIAL_CURRENCY_INFO[wallet.currencyInfo.pluginId].walletConnectV2ChainId
if (chainId == null) return

const address = await wallet.getReceiveAddress()
const address = await wallet.getReceiveAddress({ tokenId: null })
const supportedNamespaces = getSupportedNamespaces(chainId, address.publicAddress)

// Check that we support all required methods
Expand Down Expand Up @@ -238,7 +238,7 @@ export const getAccounts = async (currencyWallets: { [walletId: string]: EdgeCur
const chainId = SPECIAL_CURRENCY_INFO[wallet.currencyInfo.pluginId].walletConnectV2ChainId
if (chainId == null) continue

const address = await currencyWallets[walletId].getReceiveAddress()
const address = await currencyWallets[walletId].getReceiveAddress({ tokenId: null })
const account = `${chainId.namespace}:${chainId.reference}:${address.publicAddress}`
map.set(account, walletId)
}
Expand Down
Loading

0 comments on commit 163f262

Please sign in to comment.