Skip to content
Open
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
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PODS:
- disklet (0.5.2):
- React
- DoubleConversion (1.1.6)
- edge-core-js (2.35.0):
- edge-core-js (2.36.0):
- React-Core
- edge-currency-accountbased (4.65.0):
- React-Core
Expand Down Expand Up @@ -3333,7 +3333,7 @@ SPEC CHECKSUMS:
CNIOWindows: 3047f2d8165848a3936a0a755fee27c6b5ee479b
disklet: 8a20bf8a568635b6e6bb8f93297dac13ee5cef98
DoubleConversion: cb417026b2400c8f53ae97020b2be961b59470cb
edge-core-js: 2e9266c5197e8f556058acf4874e5e554985e590
edge-core-js: 14585f490c37ceed37a021c6639251dd47ef4546
edge-currency-accountbased: 2675384ce7cf6bd99cb657bfc314511d22619a73
edge-currency-plugins: bcb24eb550c6bf1b94e03c59405c8967aa4fbb89
edge-exchange-plugins: 8211083b576441118577f2fbede95c4fa025dd05
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"deprecated-react-native-prop-types": "^5.0.0",
"detect-bundler": "^1.1.0",
"disklet": "^0.5.2",
"edge-core-js": "^2.35.0",
"edge-core-js": "file:../edge-core-js",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Local file dependency in package.json

The edge-core-js dependency is changed to "file:../edge-core-js", which is a local file reference for development. This breaks the build for anyone without that specific directory structure and should not be committed to the repository. The dependency should reference a published version or a git URL instead.

Fix in Cursor Fix in Web

"edge-currency-accountbased": "^4.65.0",
"edge-currency-monero": "^2.0.1",
"edge-currency-plugins": "^3.8.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ exports[`initialState 1`] = `
"subcategories": [],
"wallets": {
"fioWallets": [],
"selectedCurrencyCode": "",
"selectedTokenId": null,
"selectedWalletId": "",
},
},
Expand Down
15 changes: 9 additions & 6 deletions src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from '@jest/globals'
import { log10 } from 'biggystring'

import { selectDisplayDenomByCurrencyCode } from '../selectors/DenominationSelectors'
import { selectDisplayDenom } from '../selectors/DenominationSelectors'
import { btcCurrencyInfo } from '../util/fake/fakeBtcInfo'
import { makeFakeCurrencyConfig } from '../util/fake/fakeCurrencyConfig'
import { ethCurrencyInfo } from '../util/fake/fakeEthInfo'
Expand Down Expand Up @@ -393,15 +393,18 @@ describe('getDisplayDenomination', function () {
const input = [
{
pluginId: 'bitcoin',
currencyCode: 'BTC'
currencyCode: 'BTC',
tokenId: null
},
{
pluginId: 'ethereum',
currencyCode: 'ETH'
currencyCode: 'ETH',
tokenId: null
},
{
pluginId: 'ethereum',
currencyCode: 'TKN'
currencyCode: 'TKN',
tokenId: '1985365e9f78359a9B6AD760e32412f4a445E862'
}
] as const
const output = [
Expand All @@ -425,10 +428,10 @@ describe('getDisplayDenomination', function () {
const currencyConfig =
state.core.account.currencyConfig[currency.pluginId]
expect(
selectDisplayDenomByCurrencyCode(
selectDisplayDenom(
state as any,
currencyConfig as any,
currency.currencyCode
currency.tokenId
)
).toMatchObject(output[index])
})
Expand Down
11 changes: 3 additions & 8 deletions src/actions/CreateWalletActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ import type {
import { Airship } from '../components/services/AirshipInstance'
import { SPECIAL_CURRENCY_INFO } from '../constants/WalletAndCurrencyConstants'
import { lstrings } from '../locales/strings'
import { getExchangeDenomByCurrencyCode } from '../selectors/DenominationSelectors'
import { getExchangeDenom } from '../selectors/DenominationSelectors'
import type { TokenWalletCreateItem } from '../selectors/getCreateWalletList'
import { config } from '../theme/appConfig'
import type { ThunkAction } from '../types/reduxTypes'
import type { NavigationBase } from '../types/routerTypes'
import type { EdgeAsset } from '../types/types'
import { getWalletTokenId } from '../util/CurrencyInfoHelpers'
import { logActivity } from '../util/logger'
import { filterNull } from '../util/safeFilters'
import { logEvent } from '../util/tracking'
Expand Down Expand Up @@ -155,16 +154,12 @@ export function createAccountTransaction(
createdCurrencyWallet.currencyInfo.currencyCode
const currencyPlugin =
account.currencyConfig[createdCurrencyWallet.currencyInfo.pluginId]
const { paymentAddress, amount, currencyCode } = activationPaymentInfo
const { paymentAddress, amount, tokenId } = activationPaymentInfo
const handleAvailability =
await currencyPlugin.otherMethods.validateAccount(accountName)
const paymentDenom = getExchangeDenomByCurrencyCode(
paymentWallet.currencyConfig,
currencyCode
)
const paymentDenom = getExchangeDenom(paymentWallet.currencyConfig, tokenId)
let nativeAmount = mul(amount, paymentDenom.multiplier)
nativeAmount = toFixed(nativeAmount, 0, 0)
const tokenId = getWalletTokenId(paymentWallet, currencyCode)

if (handleAvailability.result === 'AccountAvailable') {
navigation.push('send2', {
Expand Down
18 changes: 11 additions & 7 deletions src/actions/LoginActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { EdgeAccount, EdgeCreateCurrencyWallet } from 'edge-core-js/types'
import type {
EdgeAccount,
EdgeCreateCurrencyWallet,
EdgeTokenId
} from 'edge-core-js/types'
import {
getSupportedBiometryType,
hasSecurityAlerts,
Expand Down Expand Up @@ -53,7 +57,7 @@ const MIN_CREATE_WALLET_TIMEOUT = 20000

function getFirstActiveWalletInfo(account: EdgeAccount): {
walletId: string
currencyCode: string
tokenId: EdgeTokenId
} {
// Find the first wallet:
const [walletId] = account.activeWalletIds
Expand All @@ -64,13 +68,13 @@ function getFirstActiveWalletInfo(account: EdgeAccount): {
for (const pluginId of Object.keys(account.currencyConfig)) {
const { currencyInfo } = account.currencyConfig[pluginId]
if (currencyInfo.walletType === walletKey.type) {
return { walletId, currencyCode: currencyInfo.currencyCode }
return { walletId, tokenId: null }
}
}
}

// The user has no wallets:
return { walletId: '', currencyCode: '' }
return { walletId: '', tokenId: null }
}

export function initializeAccount(
Expand Down Expand Up @@ -257,7 +261,7 @@ export function initializeAccount(
let accountInitObject: AccountInitPayload = {
...initialState,
account,
currencyCode: '',
tokenId: null,
pinLoginEnabled: false,
isTouchEnabled: await isTouchEnabled(account),
isTouchSupported: (await getSupportedBiometryType()) !== false,
Expand All @@ -267,9 +271,9 @@ export function initializeAccount(
try {
if (!newAccount) {
// We have a wallet
const { walletId, currencyCode } = getFirstActiveWalletInfo(account)
const { walletId, tokenId } = getFirstActiveWalletInfo(account)
accountInitObject.walletId = walletId
accountInitObject.currencyCode = currencyCode
accountInitObject.tokenId = tokenId
}

accountInitObject = { ...accountInitObject, ...syncedSettings }
Expand Down
5 changes: 1 addition & 4 deletions src/actions/ScanActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,7 @@ async function sweepPrivateKeys(

// Check for a $50 maximum sweep for light accounts:
const sendNativeAmount = abs(unsignedTx.nativeAmount)
const multiplier = getCurrencyCodeMultiplier(
wallet.currencyConfig,
wallet.currencyInfo.currencyCode
)
const multiplier = getCurrencyCodeMultiplier(wallet.currencyConfig, null)
const sendExchangeAmount = div(
sendNativeAmount,
multiplier,
Expand Down
30 changes: 11 additions & 19 deletions src/actions/WalletActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
SPECIAL_CURRENCY_INFO
} from '../constants/WalletAndCurrencyConstants'
import { lstrings } from '../locales/strings'
import { selectDisplayDenomByCurrencyCode } from '../selectors/DenominationSelectors'
import { selectDisplayDenom } from '../selectors/DenominationSelectors'
import { convertCurrency } from '../selectors/WalletSelectors'
import type { ThunkAction } from '../types/reduxTypes'
import type { NavigationBase } from '../types/routerTypes'
Expand Down Expand Up @@ -78,7 +78,7 @@ export function selectWalletToken({
dispatch(updateMostRecentWalletsSelected(walletId, tokenId))

const currentWalletId = state.ui.wallets.selectedWalletId
const currentWalletCurrencyCode = state.ui.wallets.selectedCurrencyCode
const currentWalletTokenId = state.ui.wallets.selectedTokenId

if (tokenId != null) {
const { unactivatedTokenIds } = wallet
Expand All @@ -90,13 +90,10 @@ export function selectWalletToken({
await dispatch(activateWalletTokens(navigation, wallet, [tokenId]))
return false
}
if (
walletId !== currentWalletId ||
currencyCode !== currentWalletCurrencyCode
) {
if (walletId !== currentWalletId || tokenId !== currentWalletTokenId) {
dispatch({
type: 'UI/WALLETS/SELECT_WALLET',
data: { walletId, currencyCode }
data: { walletId, tokenId }
})
}
return true
Expand All @@ -110,7 +107,7 @@ export function selectWalletToken({
if (
alwaysActivate ||
walletId !== currentWalletId ||
currencyCode !== currentWalletCurrencyCode
tokenId !== currentWalletTokenId
) {
return await dispatch(
selectActivationRequiredWallet(navigation, walletId, currencyCode)
Expand All @@ -119,13 +116,10 @@ export function selectWalletToken({
return true
}

if (
walletId !== currentWalletId ||
currencyCode !== currentWalletCurrencyCode
) {
if (walletId !== currentWalletId || tokenId !== currentWalletTokenId) {
dispatch({
type: 'UI/WALLETS/SELECT_WALLET',
data: { walletId, currencyCode }
data: { walletId, tokenId }
})
}
return true
Expand All @@ -148,7 +142,7 @@ function selectActivationRequiredWallet(
// already activated
dispatch({
type: 'UI/WALLETS/SELECT_WALLET',
data: { walletId, currencyCode }
data: { walletId, tokenId: null }
})
return true
} else {
Expand Down Expand Up @@ -257,17 +251,15 @@ export function activateWalletTokens(
if (currencyPluginId !== pluginId)
throw new Error('Internal Error: Fee asset mismatch.')

const paymentCurrencyCode = getCurrencyCode(wallet, feeTokenId)

const multiplier = getCurrencyCodeMultiplier(
wallet.currencyConfig,
paymentCurrencyCode
feeTokenId
)
const exchangeNetworkFee = div(nativeFee, multiplier, multiplier.length)
const feeDenom = selectDisplayDenomByCurrencyCode(
const feeDenom = selectDisplayDenom(
state,
wallet.currencyConfig,
paymentCurrencyCode
feeTokenId
)
const displayFee = div(
nativeFee,
Expand Down
10 changes: 4 additions & 6 deletions src/actions/scene/StakingActions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { add } from 'biggystring'
import type { EdgeAccount, EdgeCurrencyWallet } from 'edge-core-js'
import type { EdgeAccount, EdgeCurrencyWallet, EdgeTokenId } from 'edge-core-js'

import { SPECIAL_CURRENCY_INFO } from '../../constants/WalletAndCurrencyConstants'
import { ENV } from '../../env'
Expand All @@ -15,7 +15,7 @@ import { getPositionAllocations } from '../../util/stakeUtils'
import { datelog } from '../../util/utils'

export const updateStakingState = (
currencyCode: string,
tokenId: EdgeTokenId,
wallet: EdgeCurrencyWallet
): ThunkAction<Promise<void>> => {
return async (dispatch, getState) => {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const updateStakingState = (
const stakePolicies = stakePlugin.getPolicies({
pluginId,
wallet,
currencyCode
tokenId
})
for (const stakePolicy of stakePolicies) {
stakePolicyMap[stakePolicy.stakePolicyId] = stakePolicy
Expand All @@ -58,9 +58,7 @@ export const updateStakingState = (
stakePositionMap[stakePolicy.stakePolicyId] = stakePosition
const { staked, earned } = getPositionAllocations(stakePosition)
total = [...staked, ...earned]
.filter(
p => p.currencyCode === currencyCode && p.pluginId === pluginId
)
.filter(p => p.tokenId === tokenId && p.pluginId === pluginId)
.reduce((prev, curr) => add(prev, curr.nativeAmount), '0')
} catch (err) {
console.error(err)
Expand Down
Loading
Loading