From 5f62475de3e4a38a246717da00c4b114c4f0ddb1 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Mon, 4 Apr 2022 22:50:14 -0700 Subject: [PATCH 01/13] Delete unused `GuiWallet` properties --- src/__tests__/TransactionDetails.ui.test.js | 40 ++++++------------- .../TransactionDetails.ui.test.js.snap | 8 ++-- .../components/TransactionRow.test.js | 31 +++++++------- .../scenes/CryptoExchangeQuoteScene.test.js | 28 +------------ src/reducers/scenes/WalletsReducer.js | 32 ++------------- src/types/types.js | 26 +----------- 6 files changed, 38 insertions(+), 127 deletions(-) diff --git a/src/__tests__/TransactionDetails.ui.test.js b/src/__tests__/TransactionDetails.ui.test.js index deb01f7914c..c886c4655f2 100644 --- a/src/__tests__/TransactionDetails.ui.test.js +++ b/src/__tests__/TransactionDetails.ui.test.js @@ -1,7 +1,6 @@ // @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' @@ -9,37 +8,24 @@ import { TransactionDetailsComponent } from '../components/scenes/TransactionDet 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: {}, + primaryNativeBalance: '0', + type: 'wallet:bitcoin' +} +const fakeCoreWallet: any = { + ...fakeGuiWallet, + balances: { BTC: '123123' } } -const fakeGuiWallet: GuiWallet = typeHack -const fakeCoreWallet: EdgeCurrencyWallet = typeHack const settings = { [fakeGuiWallet.currencyCode]: { diff --git a/src/__tests__/__snapshots__/TransactionDetails.ui.test.js.snap b/src/__tests__/__snapshots__/TransactionDetails.ui.test.js.snap index d34e5f49e7d..1cc608240bd 100644 --- a/src/__tests__/__snapshots__/TransactionDetails.ui.test.js.snap +++ b/src/__tests__/__snapshots__/TransactionDetails.ui.test.js.snap @@ -61,7 +61,7 @@ exports[`TransactionDetails.ui should render 1`] = ` /> { it('should render props', () => { const renderer = new ShallowRenderer() - const guiWallet = { + const guiWallet: GuiWallet = { id: 'SXq1f3x21H2e/h5A4ANvrMoK5xs+sQcDoFWHtCG25BA=', type: 'wallet:monero', name: 'Monero', @@ -24,17 +26,14 @@ describe('Transaction List Row', () => { 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: [], @@ -44,15 +43,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', @@ -63,9 +60,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, diff --git a/src/__tests__/scenes/CryptoExchangeQuoteScene.test.js b/src/__tests__/scenes/CryptoExchangeQuoteScene.test.js index 897a9591071..21e3193e4d2 100644 --- a/src/__tests__/scenes/CryptoExchangeQuoteScene.test.js +++ b/src/__tests__/scenes/CryptoExchangeQuoteScene.test.js @@ -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', diff --git a/src/reducers/scenes/WalletsReducer.js b/src/reducers/scenes/WalletsReducer.js index f5442874cdd..9c2e1cc3c6c 100644 --- a/src/reducers/scenes/WalletsReducer.js +++ b/src/reducers/scenes/WalletsReducer.js @@ -1,6 +1,6 @@ // @flow -import type { EdgeCurrencyWallet, EdgeDenomination } from 'edge-core-js' +import type { EdgeCurrencyWallet } from 'edge-core-js' import { type Reducer, combineReducers } from 'redux' import { FIO_WALLET_TYPE, SPECIAL_CURRENCY_INFO, STAKING_BALANCES } from '../../constants/WalletAndCurrencyConstants' @@ -261,32 +261,15 @@ const manageTokensPending = (state = false, action: Action): boolean => { } function schema(wallet: EdgeCurrencyWallet): GuiWallet { - const id: string = wallet.id - const type: string = wallet.type + const { blockHeight, currencyInfo, id, type } = wallet + const { currencyCode, metaTokens } = currencyInfo const name: string = wallet.name || 'no wallet name' - const { currencyCode, metaTokens, denominations } = wallet.currencyInfo const fiatCurrencyCode: string = wallet.fiatCurrencyCode.replace('iso:', '') const isoFiatCurrencyCode: string = wallet.fiatCurrencyCode - const blockHeight: number = wallet.blockHeight // TODO: Fetch the token list asynchonously before dispatching `schema`: const enabledTokens: string[] = [] - const allDenominations: { - [currencyCode: string]: { [denomination: string]: EdgeDenomination } - } = {} - - // Add all parent currency denominations to allDenominations - const parentDenominations = denominations.reduce( - (denominations, denomination) => ({ - ...denominations, - [denomination.multiplier]: denomination - }), - {} - ) - - allDenominations[currencyCode] = parentDenominations - const nativeBalances: { [currencyCode: string]: string } = {} // Add parent currency balance to balances nativeBalances[currencyCode] = wallet.balances[currencyCode] ?? '0' @@ -299,17 +282,10 @@ function schema(wallet: EdgeCurrencyWallet): GuiWallet { const currencyCode: string = metaToken.currencyCode const currencyName: string = metaToken.currencyName const balance: string = wallet.balances[currencyCode] ?? '0' - const denominations: EdgeDenomination[] = metaToken.denominations // Add token balance to allBalances nativeBalances[currencyCode] = balance currencyNames[currencyCode] = currencyName - - // Add all token denominations to allDenominations - const tokenDenominations: { - [denomination: string]: EdgeDenomination - } = denominations.reduce((denominations, denomination) => ({ ...denominations, [denomination.multiplier]: denomination }), {}) - allDenominations[currencyCode] = tokenDenominations }) const primaryNativeBalance: string = nativeBalances[currencyCode] @@ -324,8 +300,6 @@ function schema(wallet: EdgeCurrencyWallet): GuiWallet { currencyCode, isoFiatCurrencyCode, fiatCurrencyCode, - denominations, - allDenominations, metaTokens, enabledTokens, blockHeight diff --git a/src/types/types.js b/src/types/types.js index d48395fb49f..b6b53a15544 100644 --- a/src/types/types.js +++ b/src/types/types.js @@ -15,7 +15,7 @@ import { import { type RootState } from './reduxTypes.js' import { type Theme } from './Theme.js' -export type GuiWallet = { +export type GuiWallet = {| id: string, type: string, name: string, @@ -29,7 +29,7 @@ export type GuiWallet = { enabledTokens: string[], addressLoadingProgress?: number, blockHeight: number | null -} +|} // FIXME: Bandaid for when the GuiWallet object isn't quite ready when some components are loaded export const asSafeDefaultGuiWallet = (guiWallet: GuiWallet): GuiWallet => ({ @@ -183,28 +183,6 @@ export type CurrencyConverter = { convertCurrency: (state: RootState, currencyCode: string, isoFiatCurrencyCode: string, balanceInCryptoDisplay: string) => number } -export const emptyGuiWallet: GuiWallet = { - id: '', - type: '', - name: '', - primaryNativeBalance: '', - nativeBalances: {}, - currencyNames: {}, - currencyCode: '', - isoFiatCurrencyCode: '', - fiatCurrencyCode: '', - metaTokens: [], - enabledTokens: [], - receiveAddress: { - nativeAmount: '', - metadata: {}, - publicAddress: '', - legacyAddress: '' - }, - addressLoadingProgress: 0, - blockHeight: null -} - export const emptyGuiDenomination: GuiDenomination = { name: '', symbol: '', From aa8a8d8b648573878fe9c453da790bffdd26b721 Mon Sep 17 00:00:00 2001 From: William Swanson Date: Wed, 20 Apr 2022 15:26:17 -0700 Subject: [PATCH 02/13] Add the pluginId to `GuiWallet` --- src/__tests__/TransactionDetails.ui.test.js | 1 + src/__tests__/components/TransactionRow.test.js | 1 + src/reducers/scenes/WalletsReducer.js | 3 ++- src/types/types.js | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/__tests__/TransactionDetails.ui.test.js b/src/__tests__/TransactionDetails.ui.test.js index c886c4655f2..c91088ff599 100644 --- a/src/__tests__/TransactionDetails.ui.test.js +++ b/src/__tests__/TransactionDetails.ui.test.js @@ -19,6 +19,7 @@ const fakeGuiWallet: GuiWallet = { metaTokens: [], name: 'wallet name', nativeBalances: {}, + pluginId: 'bitcoin', primaryNativeBalance: '0', type: 'wallet:bitcoin' } diff --git a/src/__tests__/components/TransactionRow.test.js b/src/__tests__/components/TransactionRow.test.js index 73be32aa3f7..4eb7b12d23a 100644 --- a/src/__tests__/components/TransactionRow.test.js +++ b/src/__tests__/components/TransactionRow.test.js @@ -20,6 +20,7 @@ describe('Transaction List Row', () => { id: 'SXq1f3x21H2e/h5A4ANvrMoK5xs+sQcDoFWHtCG25BA=', type: 'wallet:monero', name: 'Monero', + pluginId: 'monero', primaryNativeBalance: '1492780012', nativeBalances: { XMR: '1492780012' }, currencyNames: { XMR: 'Monero' }, diff --git a/src/reducers/scenes/WalletsReducer.js b/src/reducers/scenes/WalletsReducer.js index 9c2e1cc3c6c..806c82a7bce 100644 --- a/src/reducers/scenes/WalletsReducer.js +++ b/src/reducers/scenes/WalletsReducer.js @@ -262,7 +262,7 @@ const manageTokensPending = (state = false, action: Action): boolean => { function schema(wallet: EdgeCurrencyWallet): GuiWallet { const { blockHeight, currencyInfo, id, type } = wallet - const { currencyCode, metaTokens } = currencyInfo + const { currencyCode, metaTokens, pluginId } = currencyInfo const name: string = wallet.name || 'no wallet name' const fiatCurrencyCode: string = wallet.fiatCurrencyCode.replace('iso:', '') @@ -294,6 +294,7 @@ function schema(wallet: EdgeCurrencyWallet): GuiWallet { id, type, name, + pluginId, primaryNativeBalance, nativeBalances, currencyNames, diff --git a/src/types/types.js b/src/types/types.js index b6b53a15544..f19a93753af 100644 --- a/src/types/types.js +++ b/src/types/types.js @@ -19,6 +19,7 @@ export type GuiWallet = {| id: string, type: string, name: string, + pluginId: string, primaryNativeBalance: string, nativeBalances: { [currencyCode: string]: string }, currencyNames: { [currencyCode: string]: string }, From c50fb21cb1d075dd7ded62b20bae817324ec26ae Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 2 May 2022 16:45:44 -0700 Subject: [PATCH 03/13] Some of 2a5261cacd8c5f6c807c82a7e008a0b9b531acc0 We can't use any of the new token management from the core yet --- src/components/themed/WalletList.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/themed/WalletList.js b/src/components/themed/WalletList.js index 04f24013019..711af99cb57 100644 --- a/src/components/themed/WalletList.js +++ b/src/components/themed/WalletList.js @@ -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 }, searchText, allowedCurrencyCodes, excludeCurrencyCodes)) { walletList.push({ id: walletId, fullCurrencyCode: currencyCode, From da93c91d6a481440875cd2994728326b2acde642 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 2 May 2022 16:53:51 -0700 Subject: [PATCH 04/13] Fix filtering of EdgeTokenIdExtended arrays in EdgeProvider chooseCurrencyWallet --- src/components/themed/WalletList.js | 11 ++++++----- src/types/types.js | 1 + src/util/CurrencyInfoHelpers.js | 5 ++++- src/util/utils.js | 20 ++++++-------------- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/components/themed/WalletList.js b/src/components/themed/WalletList.js index 711af99cb57..ee6a4f07137 100644 --- a/src/components/themed/WalletList.js +++ b/src/components/themed/WalletList.js @@ -166,7 +166,7 @@ export function WalletList(props: Props) { const { currencyCode, displayName } = currencyInfo // Initialize wallets - if (checkFilterWallet({ name, currencyCode, currencyName: displayName }, searchText, allowedCurrencyCodes, excludeCurrencyCodes)) { + if (checkFilterWallet({ name, currencyCode, currencyName: displayName, pluginId }, searchText, allowedCurrencyCodes, excludeCurrencyCodes)) { walletList.push({ id: walletId, fullCurrencyCode: currencyCode, @@ -190,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 @@ -213,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({ @@ -231,6 +231,7 @@ 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) @@ -238,7 +239,7 @@ export function WalletList(props: Props) { 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({ diff --git a/src/types/types.js b/src/types/types.js index f19a93753af..372babe07ff 100644 --- a/src/types/types.js +++ b/src/types/types.js @@ -121,6 +121,7 @@ export type CustomTokenInfo = { export type CreateWalletType = { currencyName: string, walletType: string, + pluginId: string, currencyCode: string } diff --git a/src/util/CurrencyInfoHelpers.js b/src/util/CurrencyInfoHelpers.js index 5b463a98b4c..aaae9d3d6ab 100644 --- a/src/util/CurrencyInfoHelpers.js +++ b/src/util/CurrencyInfoHelpers.js @@ -44,10 +44,11 @@ export function sortCurrencyInfos(infos: EdgeCurrencyInfo[]): EdgeCurrencyInfo[] * so make that. */ export function makeCreateWalletType(currencyInfo: EdgeCurrencyInfo): CreateWalletType { - const { currencyCode, walletType, displayName: currencyName } = currencyInfo + const { currencyCode, walletType, displayName: currencyName, pluginId } = currencyInfo return { currencyName, walletType, + pluginId, currencyCode } } @@ -68,11 +69,13 @@ export function getCreateWalletTypes(account: EdgeAccount, filterActivation: boo out.push({ currencyName: 'Bitcoin (Segwit)', walletType: 'wallet:bitcoin-bip49', + pluginId, currencyCode }) out.push({ currencyName: 'Bitcoin (no Segwit)', walletType: 'wallet:bitcoin-bip44', + pluginId, currencyCode }) } else { diff --git a/src/util/utils.js b/src/util/utils.js index f3c36c749d5..4d105f80258 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -6,14 +6,7 @@ import type { EdgeCurrencyInfo, EdgeCurrencyWallet, EdgeDenomination, EdgeMetaTo import { Linking, Platform } from 'react-native' import SafariView from 'react-native-safari-view' -import { - FEE_ALERT_THRESHOLD, - FEE_COLOR_THRESHOLD, - FIAT_CODES_SYMBOLS, - FIAT_PRECISION, - getSpecialCurrencyInfo, - getSymbolFromCurrency -} from '../constants/WalletAndCurrencyConstants.js' +import { FEE_ALERT_THRESHOLD, FEE_COLOR_THRESHOLD, FIAT_CODES_SYMBOLS, FIAT_PRECISION, getSymbolFromCurrency } from '../constants/WalletAndCurrencyConstants.js' import { formatNumber, toLocaleDate, toLocaleDateTime, toLocaleTime } from '../locales/intl.js' import s from '../locales/strings.js' import { getExchangeDenomination } from '../selectors/DenominationSelectors.js' @@ -556,20 +549,19 @@ const asEdgeTokenIdExtended = asObject({ const asCurrencyCodesArray = asMaybe(asArray(asEither(asString, asEdgeTokenIdExtended)), []) -export function checkCurrencyCodesArray(currencyCode: string, currencyCodesArray: any[]): boolean { +export function checkCurrencyCodesArray(currencyCode: string, currencyCodesArray: any[], pluginId: string): boolean { const cleanedArray = asCurrencyCodesArray(currencyCodesArray) return !!cleanedArray.find(item => { if (typeof item === 'string') { return checkCurrencyCodes(item, currencyCode) } else if (typeof item === 'object') { - const { chainCode } = getSpecialCurrencyInfo(item.pluginId) - return checkCurrencyCodes(`${chainCode}-${item.currencyCode ?? ''}`, currencyCode) + return item.pluginId === pluginId && item.currencyCode === currencyCode.toUpperCase() } return undefined }) } -export type FilterDetailsType = { name: string, currencyCode: string, currencyName: string } +export type FilterDetailsType = { name: string, currencyCode: string, currencyName: string, pluginId: string } export function checkFilterWallet( details: FilterDetailsType, @@ -579,11 +571,11 @@ export function checkFilterWallet( ): boolean { const currencyCode = details.currencyCode.toLowerCase() - if (allowedCurrencyCodes && allowedCurrencyCodes.length > 0 && !checkCurrencyCodesArray(currencyCode, allowedCurrencyCodes)) { + if (allowedCurrencyCodes && allowedCurrencyCodes.length > 0 && !checkCurrencyCodesArray(currencyCode, allowedCurrencyCodes, details.pluginId)) { return false } - if (excludeCurrencyCodes && excludeCurrencyCodes.length > 0 && checkCurrencyCodesArray(currencyCode, excludeCurrencyCodes)) { + if (excludeCurrencyCodes && excludeCurrencyCodes.length > 0 && checkCurrencyCodesArray(currencyCode, excludeCurrencyCodes, details.pluginId)) { return false } From cde2536fce88e4fe6dd84b47d0058a5967cc2274 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 28 Apr 2022 21:28:40 -0700 Subject: [PATCH 05/13] Replace error-throwing functionality with method to transform array of string to array of EdgeTokenIdExtended objects It will create as many plugin/currency code object as possible but will ignore any plugins specified in optional filterPlugins array --- src/modules/UI/scenes/Plugins/EdgeProvider.js | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/modules/UI/scenes/Plugins/EdgeProvider.js b/src/modules/UI/scenes/Plugins/EdgeProvider.js index c5236f3caba..ec25bf68cb3 100644 --- a/src/modules/UI/scenes/Plugins/EdgeProvider.js +++ b/src/modules/UI/scenes/Plugins/EdgeProvider.js @@ -120,17 +120,27 @@ export class EdgeProvider extends Bridgeable { // $FlowFixMe // Default empty array is not typed async chooseCurrencyWallet(allowedCurrencyCodes: string[] | EdgeTokenIdExtended[] = []): Promise { const selectedWallet: WalletListResult = await Airship.show(bridge => ( - + 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, @@ -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 { SafariView.show({ url }) } From 13e12e4502e0521c893b77f380520238995dd83c Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 2 May 2022 16:55:03 -0700 Subject: [PATCH 06/13] Upgrade edge-currency-accountbased to v0.15.7 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a7fc144092a..2cf470d5239 100644 --- a/package.json +++ b/package.json @@ -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.7", "edge-currency-bitcoin": "^4.9.21", "edge-currency-monero": "^0.4.0", "edge-exchange-plugins": "^0.13.0", diff --git a/yarn.lock b/yarn.lock index 457da0eaae3..3e862e40148 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5921,10 +5921,10 @@ edge-core-js@^0.19.12: yaob "^0.3.7" yavent "^0.1.3" -edge-currency-accountbased@^0.15.6: - version "0.15.6" - resolved "https://registry.yarnpkg.com/edge-currency-accountbased/-/edge-currency-accountbased-0.15.6.tgz#496099dd9de38b607ab43254177dee6617901d83" - integrity sha512-cP7HN5Rvsx0GU8b9Nq3ZgFNJpgrNxrzA3NfxY2ksOWOR2nvw4o2OisQLmO7qml4sG+UdHod1aiaSahtyzTaZAg== +edge-currency-accountbased@^0.15.7: + version "0.15.7" + resolved "https://registry.yarnpkg.com/edge-currency-accountbased/-/edge-currency-accountbased-0.15.7.tgz#f1d4b18a0511590b6a0442b33c95972d28dfd72e" + integrity sha512-+3647GxKl1aVvHl+ArHDTFjgD8ZKxA3p957wwo5JlW3adR0TSLplNQCvvn3xx+xf8r4lXedr3AH6VIHgfb/YEg== dependencies: "@binance-chain/javascript-sdk" "^2.14.4" "@ethereumjs/common" "^2.4.0" From 8e296ee61a6502769947ded1c2435ecd259f2706 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 2 May 2022 14:29:14 -0700 Subject: [PATCH 07/13] Make sure values passed to hexToDecimal will be interpreted as hex --- src/components/modals/WcSmartContractModal.js | 2 +- src/util/utils.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/modals/WcSmartContractModal.js b/src/components/modals/WcSmartContractModal.js index 6eff5c65b5e..e55be45a492 100644 --- a/src/components/modals/WcSmartContractModal.js +++ b/src/components/modals/WcSmartContractModal.js @@ -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) diff --git a/src/util/utils.js b/src/util/utils.js index 4d105f80258..6954ccb8a88 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -155,7 +155,10 @@ export const removeHexPrefix = (s: string) => s.replace(/^0x/, '') export const isHex = (h: string) => /^[0-9A-F]+$/i.test(h) -export const hexToDecimal = (num: string) => add(num, '0', 10) +export const hexToDecimal = (num: string) => { + const numberString = num.toLowerCase().startsWith('0x') ? num : `0x${num}` + return add(numberString, '0', 10) +} export const roundedFee = (nativeAmount: string, decimalPlacesBeyondLeadingZeros: number, multiplier: string): string => { if (nativeAmount === '') return nativeAmount From 784e6d6f0051da5d34fe6c0719d9fe2cd96f3459 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 2 May 2022 14:39:09 -0700 Subject: [PATCH 08/13] v2.14.1 --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 874b22b561f..4ae71f55c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # edge-react-gui +## 2.14.1 (2022-05-02) + +- 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.7 + - Fix assignment of network fees from info server + - 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 diff --git a/package.json b/package.json index 2cf470d5239..a24a384495e 100644 --- a/package.json +++ b/package.json @@ -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", From bf26a147112f48f90d101693a53c2cbebc2b8055 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 3 May 2022 22:38:27 -0700 Subject: [PATCH 09/13] Upgrade edge-currency-accountbased to v0.15.8 --- CHANGELOG.md | 4 +++- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ae71f55c09..a6df7625cdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,10 @@ - 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.7 +- Upgrade edge-currency-accountbased to v0.15.8 - Fix assignment of network fees from info server + - Merge info server fees response with local data instead of overwriting + - 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 diff --git a/package.json b/package.json index a24a384495e..fcee5909a21 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "detox": "^18.10.0", "disklet": "^0.5.2", "edge-core-js": "^0.19.12", - "edge-currency-accountbased": "^0.15.7", + "edge-currency-accountbased": "^0.15.8", "edge-currency-bitcoin": "^4.9.21", "edge-currency-monero": "^0.4.0", "edge-exchange-plugins": "^0.13.0", diff --git a/yarn.lock b/yarn.lock index 3e862e40148..1f85ba2cec9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5921,10 +5921,10 @@ edge-core-js@^0.19.12: yaob "^0.3.7" yavent "^0.1.3" -edge-currency-accountbased@^0.15.7: - version "0.15.7" - resolved "https://registry.yarnpkg.com/edge-currency-accountbased/-/edge-currency-accountbased-0.15.7.tgz#f1d4b18a0511590b6a0442b33c95972d28dfd72e" - integrity sha512-+3647GxKl1aVvHl+ArHDTFjgD8ZKxA3p957wwo5JlW3adR0TSLplNQCvvn3xx+xf8r4lXedr3AH6VIHgfb/YEg== +edge-currency-accountbased@^0.15.8: + version "0.15.8" + resolved "https://registry.yarnpkg.com/edge-currency-accountbased/-/edge-currency-accountbased-0.15.8.tgz#ea886574d134be64c5b48e25c871277e2f771ea3" + integrity sha512-Q0npOuBm0fO+x8TzRm1OKzgRJwqCx7dXsCbLRnztnWUbxEFPg3VTiPsglF1wtF6qW8AZOi1ExC9kvmihkNmV6g== dependencies: "@binance-chain/javascript-sdk" "^2.14.4" "@ethereumjs/common" "^2.4.0" From bee9c14b091446cc8a867c9abe73655c0c9db168 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 4 May 2022 14:11:08 -0700 Subject: [PATCH 10/13] Upgrade edge-currency-accountbased to v0.15.9 --- CHANGELOG.md | 3 ++- package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6df7625cdd..51642ddaa28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ - 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.8 +- 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 diff --git a/package.json b/package.json index fcee5909a21..be7a3b7e8ff 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "detox": "^18.10.0", "disklet": "^0.5.2", "edge-core-js": "^0.19.12", - "edge-currency-accountbased": "^0.15.8", + "edge-currency-accountbased": "^0.15.9", "edge-currency-bitcoin": "^4.9.21", "edge-currency-monero": "^0.4.0", "edge-exchange-plugins": "^0.13.0", diff --git a/yarn.lock b/yarn.lock index 1f85ba2cec9..1df077cc87b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5921,10 +5921,10 @@ edge-core-js@^0.19.12: yaob "^0.3.7" yavent "^0.1.3" -edge-currency-accountbased@^0.15.8: - version "0.15.8" - resolved "https://registry.yarnpkg.com/edge-currency-accountbased/-/edge-currency-accountbased-0.15.8.tgz#ea886574d134be64c5b48e25c871277e2f771ea3" - integrity sha512-Q0npOuBm0fO+x8TzRm1OKzgRJwqCx7dXsCbLRnztnWUbxEFPg3VTiPsglF1wtF6qW8AZOi1ExC9kvmihkNmV6g== +edge-currency-accountbased@^0.15.9: + version "0.15.9" + resolved "https://registry.yarnpkg.com/edge-currency-accountbased/-/edge-currency-accountbased-0.15.9.tgz#1c3614f42647ea6e13344262b76617737413230e" + integrity sha512-WrLygt4s4Tm7v2SQebuiplhfFyixSva3IhXCvKJJXbT33dUAKA4xKoAkUlpyqsFjkhzJqur75CN/ILaexKNd9Q== dependencies: "@binance-chain/javascript-sdk" "^2.14.4" "@ethereumjs/common" "^2.4.0" From 313fa94222e0399c56a045a61302ac0abafe4a4c Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Thu, 5 May 2022 09:46:16 -0700 Subject: [PATCH 11/13] Use explicit gasPrice value for all transactions in stake workflow --- .../stake-plugins/policies/cemeteryPolicy.js | 62 ++++++++++++++----- .../stake-plugins/policies/masonryPolicy.js | 28 +++++---- 2 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/plugins/stake-plugins/policies/cemeteryPolicy.js b/src/plugins/stake-plugins/policies/cemeteryPolicy.js index 53cba437cd6..253bebec8e9 100644 --- a/src/plugins/stake-plugins/policies/cemeteryPolicy.js +++ b/src/plugins/stake-plugins/policies/cemeteryPolicy.js @@ -162,6 +162,9 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP // Signer const signer = makeSigner(signerSeed) + // Get the gasPrice oracle data (from wallet) + const gasPrice = await multipass(p => p.getGasPrice()) + // Accumulators const gasLimitAcc = makeBigAccumulator('0') let txCount: number = await signer.getTransactionCount() @@ -220,7 +223,11 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP txs.build( (gasLimit => async function approveSwapRouter({ signer }) { - const result = await tokenAContract.connect(signer).approve(spenderAddress, ethers.constants.MaxUint256, { gasLimit, nonce: nextNonce() }) + const result = await tokenAContract.connect(signer).approve(spenderAddress, ethers.constants.MaxUint256, { + gasLimit, + gasPrice, + nonce: nextNonce() + }) cacheTxMetadata(result.hash, parentCurrencyCode, { name: metadataName, category: 'Expense:Fees', @@ -269,8 +276,9 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP result = await swapRouterContract .connect(signer) .addLiquidityETH(tokenAContract.address, amountTokenADesired, amountTokenAMin, amountTokenBMin, signerAddress, deadline, { - nonce: nextNonce(), gasLimit, + gasPrice, + nonce: nextNonce(), value: amountTokenBDesired }) } else { @@ -287,8 +295,9 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP signerAddress, deadline, { - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() } ) cacheTxMetadata(result.hash, parentCurrencyCode, { @@ -349,7 +358,11 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP const allowanceResponse = await lpTokenContract.connect(signer).allowance(signerAddress, spenderAddress) const isFullyAllowed = allowanceResponse.sub(liquidity).gte('0') if (!isFullyAllowed) { - const result = await lpTokenContract.connect(signer).approve(spenderAddress, ethers.constants.MaxUint256, { nonce: nextNonce(), gasLimit }) + const result = await lpTokenContract.connect(signer).approve(spenderAddress, ethers.constants.MaxUint256, { + gasLimit, + gasPrice, + nonce: nextNonce() + }) cacheTxMetadata(result.hash, parentCurrencyCode, { name: metadataName, category: 'Expense:Fees', @@ -363,7 +376,11 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP txs.build( (gasLimit => async function stakeLiquidity({ signer, liquidity }) { - const result = await poolContract.connect(signer).deposit(POOL_ID, liquidity, { nonce: nextNonce(), gasLimit }) + const result = await poolContract.connect(signer).deposit(POOL_ID, liquidity, { + gasLimit, + gasPrice, + nonce: nextNonce() + }) // Amounts need to be calculated here cacheTxMetadata(result.hash, parentCurrencyCode, { @@ -412,7 +429,11 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP // We don't need to unstake liquidity from the pool if (lte(amountToUnstake, '0')) return - const result = await poolContract.connect(signer).withdraw(POOL_ID, amountToUnstake, { nonce: nextNonce(), gasLimit }) + const result = await poolContract.connect(signer).withdraw(POOL_ID, amountToUnstake, { + gasLimit, + gasPrice, + nonce: nextNonce() + }) // Reward transaction metadata policyInfo.rewardAssets .map(asset => asset.tokenId) @@ -439,7 +460,11 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP txs.build( (gasLimit => async function approveSwapRouter({ signer }) { - const result = await lpTokenContract.connect(signer).approve(spenderAddress, ethers.constants.MaxUint256, { nonce: nextNonce(), gasLimit }) + const result = await lpTokenContract.connect(signer).approve(spenderAddress, ethers.constants.MaxUint256, { + gasLimit, + gasPrice, + nonce: nextNonce() + }) cacheTxMetadata(result.hash, parentCurrencyCode, { name: metadataName, category: 'Expense:Fees', @@ -462,8 +487,9 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP result = await swapRouterContract .connect(signer) .removeLiquidityETH(tokenAContract.address, expectedLiquidityAmount, amountTokenAMin, amountTokenBMin, signerAddress, deadline, { - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() }) } else { result = await swapRouterContract @@ -477,8 +503,9 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP signerAddress, deadline, { - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() } ) cacheTxMetadata(result.hash, parentCurrencyCode, { @@ -512,7 +539,11 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP txs.build( (gasLimit => async function claimReward({ signer }) { - const result = await poolContract.connect(signer).withdraw(POOL_ID, 0, { nonce: nextNonce(), gasLimit }) + const result = await poolContract.connect(signer).withdraw(POOL_ID, 0, { + gasLimit, + gasPrice, + nonce: nextNonce() + }) policyInfo.rewardAssets .map(asset => asset.tokenId) @@ -536,10 +567,7 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP // Calculate the fees // - // Calculate the fees: - // 1. Get the gasPrice oracle data (from wallet) - // 2. Calculate the networkFee as the gasLimit * gasPrice in the native token - const gasPrice = await multipass(p => p.getGasPrice()) + // Calculate the networkFee as the gasLimit * gasPrice in the native token const networkFee = gasLimitAcc().mul(gasPrice).toString() allocations.push({ allocationType: 'fee', diff --git a/src/plugins/stake-plugins/policies/masonryPolicy.js b/src/plugins/stake-plugins/policies/masonryPolicy.js index 2fc1ce8b2fc..4fc1a7e40e3 100644 --- a/src/plugins/stake-plugins/policies/masonryPolicy.js +++ b/src/plugins/stake-plugins/policies/masonryPolicy.js @@ -196,6 +196,9 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { // Signer const signer = makeSigner(signerSeed) + // Get the gasPrice oracle data (from wallet) + const gasPrice = await multipass(p => p.getGasPrice()) + // Accumulators const gasLimitAcc = makeBigAccumulator('0') let txCount: number = await signer.getTransactionCount() @@ -223,8 +226,9 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { (gasLimit => async function approvePoolContract({ signer }) { const result = await tokenContract.connect(signer).approve(poolContract.address, ethers.constants.MaxUint256, { - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() }) cacheTxMetadata(result.hash, nativeCurrencyCode, { name: metadataName, @@ -243,8 +247,9 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { (gasLimit => async function name({ signer }) { const result = await poolContract.connect(signer).stake(request.nativeAmount, { - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() }) cacheTxMetadata(result.hash, nativeCurrencyCode, { name: metadataName, @@ -267,8 +272,9 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { (gasLimit => async function name({ signer }) { const result = await poolContract.connect(signer).withdraw(request.nativeAmount, { - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() }) cacheTxMetadata(result.hash, nativeCurrencyCode, { name: metadataName, @@ -301,8 +307,9 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { (gasLimit => async function name({ signer }) { const result = await poolContract.connect(signer).claimReward({ - nonce: nextNonce(), - gasLimit + gasLimit, + gasPrice, + nonce: nextNonce() }) cacheTxMetadata(result.hash, nativeCurrencyCode, { name: metadataName, @@ -327,10 +334,7 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { // Calculate the fees // - // Calculate the fees: - // 1. Get the gasPrice oracle data (from wallet) - // 2. Calculate the networkFee as the gasLimit * gasPrice in the native token - const gasPrice = await multipass(p => p.getGasPrice()) + // Calculate the networkFee as the gasLimit * gasPrice in the native token const networkFee = gasLimitAcc().mul(gasPrice).toString() allocations.push({ allocationType: 'fee', From 21f87e3c4028297ba7d241d3ec27b7ceaf478501 Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Thu, 5 May 2022 12:08:09 -0700 Subject: [PATCH 12/13] Add 'pending' blocktag to getTransactionCount for stake plugin This will hopefully make the transaction account include pending (unconfirmed) transactions. This is to avoid using the same nonce as a pending transaction, which triggers RBF. --- src/plugins/stake-plugins/policies/cemeteryPolicy.js | 2 +- src/plugins/stake-plugins/policies/masonryPolicy.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/stake-plugins/policies/cemeteryPolicy.js b/src/plugins/stake-plugins/policies/cemeteryPolicy.js index 253bebec8e9..e4ea8920cb5 100644 --- a/src/plugins/stake-plugins/policies/cemeteryPolicy.js +++ b/src/plugins/stake-plugins/policies/cemeteryPolicy.js @@ -167,7 +167,7 @@ export const makeCemeteryPolicy = (options: CemeteryPolicyOptions): StakePluginP // Accumulators const gasLimitAcc = makeBigAccumulator('0') - let txCount: number = await signer.getTransactionCount() + let txCount: number = await signer.getTransactionCount('pending') const nextNonce = (): number => txCount++ // Transaction builder diff --git a/src/plugins/stake-plugins/policies/masonryPolicy.js b/src/plugins/stake-plugins/policies/masonryPolicy.js index 4fc1a7e40e3..2896171b0d3 100644 --- a/src/plugins/stake-plugins/policies/masonryPolicy.js +++ b/src/plugins/stake-plugins/policies/masonryPolicy.js @@ -201,7 +201,7 @@ export const makeMasonryPolicy = (): StakePluginPolicy => { // Accumulators const gasLimitAcc = makeBigAccumulator('0') - let txCount: number = await signer.getTransactionCount() + let txCount: number = await signer.getTransactionCount('pending') const nextNonce = (): number => txCount++ // Transaction builder From 67a23c36ccd54e442eb40fdb8b759aa3c110a7f0 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 5 May 2022 14:44:15 -0700 Subject: [PATCH 13/13] Update Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51642ddaa28..77dc31c33b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 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