Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed May 5, 2022
2 parents 335a5a5 + 67a23c3 commit f4545ee
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 192 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# edge-react-gui

## 2.14.1 (2022-05-02)

- Use explicit gasPrice value for all transactions in stake workflow
- Add 'pending' blocktag to getTransactionCount for stake plugin
- Wallet Connect: Fix hex value handling
- Add Edge Provider utility to convert currency code array to EdgeTokenIdExtended array
- Upgrade edge-currency-accountbased to v0.15.9
- Fix assignment of network fees from info server
- Merge info server fees response with local data instead of overwriting
- Round gas price values to ints before converting to hex
- Prioritize the queried minGasLimit and minGasPrice over the default values
- Add logging of fees
- Add feeUpdateFrequency override and change FTM to 1 min
- Change preference of fee providers
- Do not overwrite baseFeeMultiplier coming from settings
- Fix hex number handling
- Update ZEC checkpoints

## 2.14.0 (2022-04-26)

- Add Tomb Swap
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edge-react-gui",
"version": "2.14.0",
"version": "2.14.1",
"private": true,
"description": "Edge Wallet React GUI",
"homepage": "https://edge.app",
Expand Down Expand Up @@ -109,7 +109,7 @@
"detox": "^18.10.0",
"disklet": "^0.5.2",
"edge-core-js": "^0.19.12",
"edge-currency-accountbased": "^0.15.6",
"edge-currency-accountbased": "^0.15.9",
"edge-currency-bitcoin": "^4.9.21",
"edge-currency-monero": "^0.4.0",
"edge-exchange-plugins": "^0.13.0",
Expand Down
41 changes: 14 additions & 27 deletions src/__tests__/TransactionDetails.ui.test.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
// @flow
/* globals jest describe it expect */

import { type EdgeCurrencyWallet } from 'edge-core-js'
import * as React from 'react'
import ShallowRenderer from 'react-test-renderer/shallow'

import { TransactionDetailsComponent } from '../components/scenes/TransactionDetailsScene.js'
import { getTheme } from '../components/services/ThemeContext.js'
import { type GuiWallet } from '../types/types.js'

const typeHack: any = {
allDenominations: {
BTC: {
// prettier-ignore
'100000000': {
name: 'BTC',
multiplier: '100000000',
symbol: '₿'
}
}
},
denominations: [
{
name: 'BTC',
multiplier: '100000000',
symbol: '₿'
}
],
balances: { BTC: '123123' },
const fakeGuiWallet: GuiWallet = {
blockHeight: 12345,
currencyNames: { BTC: 'Bitcoin' },
currencyCode: 'BTC',
currencyInfo: {},
displayPrivateSeed: 'private seed',
displayPublicSeed: 'public seed',
fiatCurrencyCode: 'iso:USD',
enabledTokens: [],
fiatCurrencyCode: 'USD',
id: '123',
name: 'wallet name'
isoFiatCurrencyCode: 'iso:USD',
metaTokens: [],
name: 'wallet name',
nativeBalances: {},
pluginId: 'bitcoin',
primaryNativeBalance: '0',
type: 'wallet:bitcoin'
}
const fakeCoreWallet: any = {
...fakeGuiWallet,
balances: { BTC: '123123' }
}
const fakeGuiWallet: GuiWallet = typeHack
const fakeCoreWallet: EdgeCurrencyWallet = typeHack

const settings = {
[fakeGuiWallet.currencyCode]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ exports[`TransactionDetails.ui should render 1`] = `
/>
<WithTheme(TileComponent)
onPress={[Function]}
title="Amount in iso:USD"
title="Amount in USD"
type="editable"
>
<View
Expand Down Expand Up @@ -256,7 +256,7 @@ exports[`TransactionDetails.ui should render with negative nativeAmount and fiat
/>
<WithTheme(TileComponent)
onPress={[Function]}
title="Amount in iso:USD"
title="Amount in USD"
type="editable"
>
<View
Expand Down Expand Up @@ -451,7 +451,7 @@ exports[`TransactionDetails.ui should render with tx date off by 1000x in future
/>
<WithTheme(TileComponent)
onPress={[Function]}
title="Amount in iso:USD"
title="Amount in USD"
type="editable"
>
<View
Expand Down Expand Up @@ -646,7 +646,7 @@ exports[`TransactionDetails.ui should render with tx date off by 1000x in past 1
/>
<WithTheme(TileComponent)
onPress={[Function]}
title="Amount in iso:USD"
title="Amount in USD"
type="editable"
>
<View
Expand Down
32 changes: 15 additions & 17 deletions src/__tests__/components/TransactionRow.test.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
// @flow
/* globals describe it expect */
/* eslint-disable flowtype/require-valid-file-annotation */

import { abs, toFixed } from 'biggystring'
import { type EdgeTransaction } from 'edge-core-js'
import * as React from 'react'
import ShallowRenderer from 'react-test-renderer/shallow'

import { getTheme } from '../../components/services/ThemeContext.js'
import { TransactionListRowComponent } from '../../components/themed/TransactionListRow.js'
import { EDGE_CONTENT_SERVER, getSymbolFromCurrency } from '../../constants/WalletAndCurrencyConstants.js'
import { getSymbolFromCurrency } from '../../constants/WalletAndCurrencyConstants.js'
import { formatNumber } from '../../locales/intl.js'
import { type GuiWallet } from '../../types/types.js'
import { convertNativeToDisplay, decimalOrZero, isSentTransaction, truncateDecimals } from '../../util/utils'

describe('Transaction List Row', () => {
it('should render props', () => {
const renderer = new ShallowRenderer()
const guiWallet = {
const guiWallet: GuiWallet = {
id: 'SXq1f3x21H2e/h5A4ANvrMoK5xs+sQcDoFWHtCG25BA=',
type: 'wallet:monero',
name: 'Monero',
pluginId: 'monero',
primaryNativeBalance: '1492780012',
nativeBalances: { XMR: '1492780012' },
currencyNames: { XMR: 'Monero' },
currencyCode: 'XMR',
isoFiatCurrencyCode: 'iso:USD',
fiatCurrencyCode: 'USD',
denominations: [{}],
allDenominations: { XMR: {} },
metaTokens: [],
enabledTokens: [],
receiveAddress: { metadata: {}, nativeAmount: '0', publicAddress: '432hJPUp2C...' },
blockHeight: 1688551,
symbolImage: `${EDGE_CONTENT_SERVER}/XMR/XMR.png`,
symbolImageDarkMono: `${EDGE_CONTENT_SERVER}/XMR/XMR_dark.png`,
key: 'SXq1f3x21H2e/h5A4ANvrMoK5xs+sQcDoFWHtCG25BA='
blockHeight: 1688551
}
const transaction = {
const amountFiat = 4424808418353299.5

const wallet: any = { id: 'SXq1f3x21H…', type: 'wallet:monero' }
const transaction: EdgeTransaction = {
blockHeight: 1683022,
date: 1539555412.068,
ourReceiveAddresses: [],
Expand All @@ -44,15 +44,13 @@ describe('Transaction List Row', () => {
nativeAmount: '-32295514330000',
networkFee: '0',
currencyCode: 'XMR',
wallet: { id: 'SXq1f3x21H…', type: 'wallet:monero' },
wallet,
otherParams: {},
SVGMetadataElement: { name: 'ShapeShift', category: '', notes: 'Exchanged …' },
dateString: 'Oct 14, 2018',
time: '3:16 PM',
key: 0,
metadata: {
amountFiat: 4424808418353299.5
}
metadata: { amountFiat }
}
const displayDenomination = {
multiplier: '1000000000000',
Expand All @@ -63,9 +61,9 @@ describe('Transaction List Row', () => {
const cryptoAmount = convertNativeToDisplay(displayDenomination.multiplier)(abs(transaction.nativeAmount ?? ''))
const cryptoAmountFormat = formatNumber(decimalOrZero(truncateDecimals(cryptoAmount), 6))
// FiatAmount
const fiatAmount = abs(transaction.metadata.amountFiat.toFixed(2))
const fiatAmount = abs(amountFiat.toFixed(2))
const fiatAmountFormat = formatNumber(toFixed(fiatAmount, 2, 2), { toFixed: 2 })
const props = {
const props: any = {
cryptoAmount: cryptoAmountFormat,
denominationSymbol: displayDenomination.symbol,
fiatAmount: fiatAmountFormat,
Expand Down
28 changes: 2 additions & 26 deletions src/__tests__/scenes/CryptoExchangeQuoteScene.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,10 @@ describe('CryptoExchangeQuoteScreenComponent', () => {
},
request: {
fromWallet: {
fiatCurrencyCode: 'USD',
allDenominations: {
BTC: {
// prettier-ignore
'100000000': {
name: 'BTC',
multiplier: '100000000',
symbol: '₿'
}
}
}
fiatCurrencyCode: 'USD'
},
toWallet: {
fiatCurrencyCode: 'USD',
allDenominations: {
ETH: {
// prettier-ignore
'100000000': {
name: 'ETH',
multiplier: '100000000',
symbol: 'ETH'
}
}
},
fromCurrencyCode: 'BTC',
toCurrencyCode: 'ETH',
nativeAmount: '1000',
quoteFor: 'from'
fiatCurrencyCode: 'USD'
},
fee: '1',
fromDisplayAmount: '1',
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/WcSmartContractModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const WcSmartContractModal = (props: Props) => {
amountCrypto = hexToDecimal(params.value)
}
if (isHex(removeHexPrefix(params?.gas ?? '')) && isHex(removeHexPrefix(params?.gasPrice ?? ''))) {
networkFeeCrypto = hexToDecimal(removeHexPrefix(mul(params.gas, params.gasPrice, 16)))
networkFeeCrypto = hexToDecimal(mul(params.gas, params.gasPrice, 16))
}

const amountDenom = getDenominationFromCurrencyInfo(wallet.currencyInfo, amountCurrencyCode)
Expand Down
15 changes: 9 additions & 6 deletions src/components/themed/WalletList.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ export function WalletList(props: Props) {
key: walletId
})
} else if (wallet != null) {
const { enabledTokens, name, currencyCode, currencyNames } = asSafeDefaultGuiWallet(wallet)
const { enabledTokens, name, pluginId, currencyNames } = asSafeDefaultGuiWallet(wallet)
const { currencyInfo } = account.currencyConfig[pluginId]
const { currencyCode, displayName } = currencyInfo

// Initialize wallets
if (checkFilterWallet({ name, currencyCode, currencyName: currencyNames[currencyCode] }, searchText, allowedCurrencyCodes, excludeCurrencyCodes)) {
if (checkFilterWallet({ name, currencyCode, currencyName: displayName, pluginId }, searchText, allowedCurrencyCodes, excludeCurrencyCodes)) {
walletList.push({
id: walletId,
fullCurrencyCode: currencyCode,
Expand All @@ -188,7 +190,7 @@ export function WalletList(props: Props) {

if (
checkFilterWallet(
{ name, currencyCode: tokenCode, currencyName: customTokenInfo?.currencyName ?? currencyNames[tokenCode] ?? '' },
{ name, currencyCode: tokenCode, currencyName: customTokenInfo?.currencyName ?? currencyNames[tokenCode] ?? '', pluginId },
searchText,
allowedCurrencyCodes,
excludeCurrencyCodes
Expand All @@ -211,10 +213,10 @@ export function WalletList(props: Props) {
// Initialize Create Wallets
const createWalletCurrencies = getCreateWalletTypes(account, filterActivation)
for (const createWalletCurrency of createWalletCurrencies) {
const { currencyCode, currencyName } = createWalletCurrency
const { currencyCode, currencyName, pluginId } = createWalletCurrency

if (
checkFilterWallet({ name: '', currencyCode, currencyName }, searchText, allowedCurrencyCodes, excludeCurrencyCodes) &&
checkFilterWallet({ name: '', currencyCode, currencyName, pluginId }, searchText, allowedCurrencyCodes, excludeCurrencyCodes) &&
!checkFromExistingWallets(walletList, currencyCode)
) {
sortedWalletlist.push({
Expand All @@ -229,14 +231,15 @@ export function WalletList(props: Props) {
// Initialize Create Tokens
const currencyInfos = getCurrencyInfos(account)
for (const currencyInfo of currencyInfos) {
const { pluginId } = currencyInfo
for (const metaToken of currencyInfo.metaTokens) {
const { currencyCode, currencyName } = metaToken
// Fix for when the token code and chain code are the same (like EOS/TLOS)
if (currencyCode === currencyInfo.currencyCode) continue
const fullCurrencyCode = `${currencyInfo.currencyCode}-${currencyCode}`

if (
checkFilterWallet({ name: '', currencyCode, currencyName }, searchText, allowedCurrencyCodes, excludeCurrencyCodes) &&
checkFilterWallet({ name: '', currencyCode, currencyName, pluginId }, searchText, allowedCurrencyCodes, excludeCurrencyCodes) &&
!checkFromExistingWallets(walletList, fullCurrencyCode)
) {
sortedWalletlist.push({
Expand Down
37 changes: 32 additions & 5 deletions src/modules/UI/scenes/Plugins/EdgeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,27 @@ export class EdgeProvider extends Bridgeable {
// $FlowFixMe // Default empty array is not typed
async chooseCurrencyWallet(allowedCurrencyCodes: string[] | EdgeTokenIdExtended[] = []): Promise<string> {
const selectedWallet: WalletListResult = await Airship.show(bridge => (
<WalletListModal bridge={bridge} showCreateWallet allowedCurrencyCodes={allowedCurrencyCodes} headerTitle={s.strings.choose_your_wallet} />
<WalletListModal
bridge={bridge}
showCreateWallet
allowedCurrencyCodes={
this._plugin.filterPlugins != null
? this.convertCurrencyCodesToEdgeTokenIds(
allowedCurrencyCodes.filter(code => typeof code === 'string'),
this._plugin.filterPlugins
)
: allowedCurrencyCodes
}
headerTitle={s.strings.choose_your_wallet}
/>
))

const { walletId, currencyCode } = selectedWallet
if (walletId && currencyCode) {
this._dispatch(selectWallet(walletId, currencyCode))
// If allowedCurrencyCodes is an array of EdgeTokenIdExtended objects
if (allowedCurrencyCodes.length > 0 && allowedCurrencyCodes.every(code => typeof code === 'object')) {
const { pluginId, displayName } = this._state.core.account.currencyWallets[walletId].currencyInfo
if (this._plugin.filterPlugins != null && this._plugin.filterPlugins.includes(pluginId)) {
throw new Error(sprintf(s.strings.UnsupportedCurrency, `${displayName}-${currencyCode}`, this._plugin.displayName))
}
const { pluginId } = this._state.core.account.currencyWallets[walletId].currencyInfo
const tokenId = getTokenId(this._state.core.account, pluginId, currencyCode)
return Promise.resolve({
pluginId,
Expand Down Expand Up @@ -493,6 +503,23 @@ export class EdgeProvider extends Bridgeable {
return orderData
}

// Convert an array of currency codes to an array of EdgeTokenIdExtended objects by creating all possible plugin/token combinations, ignoring any plugin passed as filterPlugins.
convertCurrencyCodesToEdgeTokenIds(currencyCodes: string[], filterPlugins?: string[] = []): EdgeTokenIdExtended[] {
const tokenIds: EdgeTokenIdExtended[] = []
for (const pluginId of Object.keys(this._state.core.account.currencyConfig).filter(plugin => !filterPlugins.includes(plugin))) {
const { currencyCode, metaTokens } = this._state.core.account.currencyConfig[pluginId].currencyInfo
if (currencyCodes.includes(currencyCode)) {
tokenIds.push({ pluginId, currencyCode })
}
for (const allowedCode of currencyCodes) {
if (metaTokens.find(token => token.currencyCode === allowedCode) != null) {
tokenIds.push({ pluginId, currencyCode: allowedCode })
}
}
}
return tokenIds
}

async openSafariView(url: string): Promise<mixed> {
SafariView.show({ url })
}
Expand Down
Loading

0 comments on commit f4545ee

Please sign in to comment.