Skip to content

Commit

Permalink
Rename new to next
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBenc committed Jan 12, 2021
1 parent d764874 commit c3e0754
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions app/frontend/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,17 +1055,17 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF
})
}

const exploreNewAccount = async (state: State) => {
const exploreNextAccount = async (state: State) => {
try {
loadingAction(state, 'Loading account')
const newAccount = await wallet.exploreNewAccount()
const accountInfo = await newAccount.getAccountInfo(state.validStakepools)
const nextAccount = await wallet.exploreNextAccount()
const accountInfo = await nextAccount.getAccountInfo(state.validStakepools)
const accountsInfo = [...state.accountsInfo, accountInfo]
setState({
accountsInfo,
...getWalletInfo(accountsInfo),
})
setActiveAccount(state, newAccount.accountIndex)
setActiveAccount(state, nextAccount.accountIndex)
} catch (e) {
setErrorState('walletLoadingError', e)
setState({
Expand Down Expand Up @@ -1545,7 +1545,7 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF
setActiveAccount,
setTargetAccount,
setSourceAccount,
exploreNewAccount,
exploreNextAccount,
switchSourceAndTargetAccounts,
loadPoolCertificateTx,
downloadPoolSignature,
Expand Down
6 changes: 3 additions & 3 deletions app/frontend/components/pages/accounts/accountTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type TileProps = {
rewardsBalance: number | null
shouldShowSaturatedBanner: boolean
setActiveAccount: any
exploreNewAccount: any
exploreNextAccount: any
activeAccountIndex: number
showDelegationModal: any
showSendTransactionModal: any
Expand All @@ -28,7 +28,7 @@ const AccountTile = ({
rewardsBalance,
shouldShowSaturatedBanner,
setActiveAccount,
exploreNewAccount,
exploreNextAccount,
activeAccountIndex,
showDelegationModal,
showSendTransactionModal,
Expand Down Expand Up @@ -87,7 +87,7 @@ const AccountTile = ({
<button
className="button primary nowrap"
onClick={() => {
exploreNewAccount()
exploreNextAccount()
}}
>
Explore
Expand Down
24 changes: 12 additions & 12 deletions app/frontend/wallet/account-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const AccountManager = ({config, cryptoProvider, blockchainExplorer}) => {
return accounts[accountIndex]
}

function discoverNewAccount() {
function discoverNextAccount() {
return Account({
config,
cryptoProvider,
Expand All @@ -18,7 +18,7 @@ const AccountManager = ({config, cryptoProvider, blockchainExplorer}) => {
})
}

async function addNewAccount(account) {
async function addNextAccount(account) {
await account.init() // To ensure user exported pubkey
const isLastAccountUsed =
accounts.length > 0 ? await accounts[accounts.length - 1].isAccountUsed() : true
Expand All @@ -38,30 +38,30 @@ const AccountManager = ({config, cryptoProvider, blockchainExplorer}) => {
const isBulkExportSupported = cryptoProvider.isFeatureSupported(
CryptoProviderFeatures.BULK_EXPORT
)
async function _discoverNewAccount(accountIndex: number) {
const newAccount = accounts[accountIndex] || discoverNewAccount()
async function _discoverNextAccount(accountIndex: number) {
const newAccount = accounts[accountIndex] || discoverNextAccount()
const isAccountUsed = await newAccount.isAccountUsed()
if (accountIndex === accounts.length) await addNewAccount(newAccount)
if (accountIndex === accounts.length) await addNextAccount(newAccount)
const shouldExplore = isAccountUsed && config.shouldExportPubKeyBulk && isBulkExportSupported

return shouldExplore && (await _discoverNewAccount(accountIndex + 1))
return shouldExplore && (await _discoverNextAccount(accountIndex + 1))
}
await _discoverNewAccount(Math.max(0, accounts.length - 1))
await _discoverNextAccount(Math.max(0, accounts.length - 1))
return accounts
}

async function exploreNewAccount() {
async function exploreNextAccount() {
// remove rejected promises from pubkey cache
cryptoProvider.cleanXpubCache()
const newAccount = discoverNewAccount()
await addNewAccount(newAccount)
return newAccount
const nextAccount = discoverNextAccount()
await addNextAccount(nextAccount)
return nextAccount
}

return {
getAccount,
discoverAccounts,
exploreNewAccount,
exploreNextAccount,
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/frontend/wallet/shelley-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const ShelleyWallet = ({config, cryptoProvider}) => {
getAccountsInfo,
getValidStakepools,
getAccount: accountManager.getAccount,
exploreNewAccount: accountManager.exploreNewAccount,
exploreNextAccount: accountManager.exploreNextAccount,
}
}

Expand Down

0 comments on commit c3e0754

Please sign in to comment.