Skip to content

Commit

Permalink
Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBenc committed Jan 14, 2021
1 parent 620cd72 commit 6565156
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/frontend/actions.ts
Expand Up @@ -146,7 +146,7 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF

const conversionRatesPromise = getConversionRates(state)
const usingHwWallet = wallet.isHwWallet()
const hwWalletName = usingHwWallet ? wallet.getHwWalletName() : undefined
const hwWalletName = usingHwWallet ? wallet.getWalletName() : undefined
if (usingHwWallet) loadingAction(state, `Waiting for ${hwWalletName}...`)
const demoRootSecret = (await mnemonicToWalletSecretDef(
ADALITE_CONFIG.ADALITE_DEMO_WALLET_MNEMONIC
Expand All @@ -155,8 +155,8 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF
const autoLogin = state.autoLogin
const ticker2Id = null
const shouldShowPremiumBanner =
state.shouldShowPremiumBanner && walletInfo.balance > PREMIUM_MEMBER_BALANCE_TRESHHOLD
const isBigDelegator = walletInfo.balance > BIG_DELEGATOR_THRESHOLD
state.shouldShowPremiumBanner && PREMIUM_MEMBER_BALANCE_TRESHHOLD < 0
// should work for full wallet balance
setState({
accounts: accountsInfo,
walletIsLoaded: true,
Expand Down Expand Up @@ -1181,7 +1181,7 @@ export default ({setState, getState}: {setState: SetStateFn; getState: GetStateF
selectedAccount: accountIndex,
})
resetSendFormFields(newState)
selectAdaliteStakepool()
selectAdaliteStakepool(newState)
resetTransactionSummary(newState)
}

Expand Down
22 changes: 22 additions & 0 deletions app/frontend/wallet/account.ts
Expand Up @@ -279,6 +279,10 @@ const Account = ({
const visibleAddresses = await getVisibleAddresses()
const transactionHistory = await getHistory()
const stakingHistory = await getStakingHistory(shelleyAccountInfo, validStakepools)
const poolRecommendation = await getPoolRecommendation(
shelleyAccountInfo.delegation,
stakingBalance
)
return {
validStakepools,
balance,
Expand All @@ -292,6 +296,7 @@ const Account = ({
transactionHistory,
stakingHistory,
visibleAddresses,
poolRecommendation,
}
}

Expand Down Expand Up @@ -402,6 +407,22 @@ const Account = ({
}
}

async function getPoolRecommendation(pool: any, stake: number): Promise<any> {
const poolHash = pool ? pool.poolHash : null
const poolRecommendation = await blockchainExplorer.getPoolRecommendation(poolHash, stake)
if (!poolRecommendation.recommendedPoolHash || config.ADALITE_ENFORCE_STAKEPOOL) {
Object.assign(poolRecommendation, {
recommendedPoolHash: config.ADALITE_STAKE_POOL_ID,
})
}
const delegatesToRecommended = poolRecommendation.recommendedPoolHash === pool.poolHash
return {
...poolRecommendation,
shouldShowSaturatedBanner:
!delegatesToRecommended && poolRecommendation.status === 'GivenPoolSaturated',
}
}

function isAccountUsed(): Promise<boolean> {
return myAddresses.areAddressesUsed()
}
Expand All @@ -424,6 +445,7 @@ const Account = ({
getWalletInfo,
getPoolInfo,
accountIndex,
getPoolRecommendation,
isAccountUsed,
}
}
Expand Down
12 changes: 8 additions & 4 deletions app/frontend/wallet/wallet.ts
Expand Up @@ -38,13 +38,17 @@ const Wallet = ({config, cryptoProvider}) => {
return cryptoProvider.isHwWallet()
}

function getHwWalletName() {
return isHwWallet ? (cryptoProvider as any).getHwWalletName() : undefined
function getWalletName() {
return cryptoProvider.getWalletName()
}

function submitTx(signedTx): Promise<any> {
const params = {
walletType: getWalletName(),
// TODO: stakeKey
}
const {txBody, txHash} = signedTx
return blockchainExplorer.submitTxRaw(txHash, txBody)
return blockchainExplorer.submitTxRaw(txHash, txBody, params)
}

function getWalletSecretDef() {
Expand Down Expand Up @@ -79,7 +83,7 @@ const Wallet = ({config, cryptoProvider}) => {

return {
isHwWallet,
getHwWalletName,
getWalletName,
submitTx,
getWalletSecretDef,
fetchTxInfo,
Expand Down

0 comments on commit 6565156

Please sign in to comment.