@@ -129,34 +38,30 @@ import { useAction, useGetter, useStateAttribute } from '@/common/store/helper';
import { useRoute, useRouter } from 'vue-router';
import { useTheme } from 'vuetify';
import {
- mdiContentCopy, mdiLinkOff, mdiBitcoin, mdiInformation,
+ mdiContentCopy, mdiLinkOff,
} from '@mdi/js';
+import PegInAccountSelect from '@/pegin/components/create/PegInAccountSelect.vue';
import * as constants from '@/common/store/constants';
import { computed, ref, watch } from 'vue';
import { truncateString } from '@/common/utils';
-import {
- AccountBalance, BtcAccount, SatoshiBig, WeiBig,
-} from '@/common/types';
+import { WeiBig } from '@/common/types';
import EnvironmentContextProviderService from '@/common/providers/EnvironmentContextProvider';
export default {
name: 'TopBar',
+ components: {
+ PegInAccountSelect,
+ },
setup() {
const router = useRouter();
const route = useRoute();
const themeLight = ref(false);
- const selectedAccountType = ref();
const vuetifyTheme = useTheme();
const account = useGetter
('web3Session', constants.SESSION_GET_CHECKSUMMED_ACCOUNT);
- const connectedBtcWallet = useGetter('pegInTx', constants.WALLET_NAME);
- const selectedBtcAccountBalance = useGetter('pegInTx', constants.PEGIN_TX_GET_SELECTED_BALANCE);
- const stateSelectedAccount = useStateAttribute('pegInTx', 'selectedAccount');
const truncatedAccount = computed(() => truncateString(account.value));
const balance = useStateAttribute('web3Session', 'balance');
- const loadingBalance = useStateAttribute('pegInTx', 'loadingBalance');
- const balances = useStateAttribute('pegInTx', 'balances');
const environmentContext = EnvironmentContextProviderService.getEnvironmentContext();
const accountBalance = computed(() => {
@@ -166,33 +71,6 @@ export default {
const clearSession = useAction('web3Session', constants.WEB3_SESSION_CLEAR_ACCOUNT);
- const balancesPerAccountType = computed(() => ([
- {
- title: balances.value.legacy.toBTCTrimmedString(),
- value: constants.BITCOIN_LEGACY_ADDRESS,
- appendText: 'Legacy',
- appendColor: 'pink',
- },
- {
- title: balances.value.segwit.toBTCTrimmedString(),
- value: constants.BITCOIN_SEGWIT_ADDRESS,
- appendText: 'Segwit',
- appendColor: 'orange',
- },
- {
- title: balances.value.nativeSegwit.toBTCTrimmedString(),
- value: constants.BITCOIN_NATIVE_SEGWIT_ADDRESS,
- appendText: 'Native Segwit',
- appendColor: 'teal',
- },
- ]));
-
- const selectedAccountTypeBadge = computed(() => {
- const selected = balancesPerAccountType.value
- .find(({ value }) => value === selectedAccountType.value);
- return { color: selected?.appendColor, text: selected?.appendText };
- });
-
function disconnectWallet() {
clearSession();
router.push({ name: 'Home' });
@@ -210,16 +88,10 @@ export default {
return vuetifyTheme.global.current.value.dark ? require('@/assets/logo-rootstock-white.svg') : require('@/assets/logo-rootstock-black.svg');
}
- if (stateSelectedAccount.value) {
- selectedAccountType.value = stateSelectedAccount.value;
- }
-
watch(themeLight, (enabledLight) => {
vuetifyTheme.global.name.value = enabledLight ? 'light' : 'dark';
});
- const tooltipText = 'Listed amounts represent the balance using addresses from your first account including change.';
-
return {
goHome,
getLogoSrc,
@@ -232,15 +104,7 @@ export default {
accountBalance,
balance,
environmentContext,
- connectedBtcWallet,
- selectedBtcAccountBalance,
- loadingBalance,
- balancesPerAccountType,
- selectedAccountType,
- mdiBitcoin,
- mdiInformation,
- selectedAccountTypeBadge,
- tooltipText,
+ isPeginSelected: computed(() => route.name === 'Create'),
};
},
};
diff --git a/src/common/router/index.ts b/src/common/router/index.ts
index 4f262685d..3805e782b 100644
--- a/src/common/router/index.ts
+++ b/src/common/router/index.ts
@@ -63,7 +63,7 @@ const routes: Readonly = [
path: '/pegin',
name: 'PegIn',
component: () => import(/* webpackChunkName: "pegin" */ '../../pegin/views/PegIn.vue'),
- beforeEnter: [checkAcceptedTerms, checkRSKConnection],
+ beforeEnter: [checkAcceptedTerms],
},
{
path: '/pegout',
diff --git a/src/common/services/EnkryptService.ts b/src/common/services/EnkryptService.ts
index 6f8d20830..4cf3eacf0 100644
--- a/src/common/services/EnkryptService.ts
+++ b/src/common/services/EnkryptService.ts
@@ -36,7 +36,7 @@ export default class EnkryptService extends WalletService {
}
availableAccounts(): BtcAccount[] {
- return [constants.BITCOIN_NATIVE_SEGWIT_ADDRESS];
+ return [BtcAccount.BITCOIN_NATIVE_SEGWIT_ADDRESS];
}
isConnected(): Promise {
diff --git a/src/common/services/LeatherService.ts b/src/common/services/LeatherService.ts
index ff5ed8343..2f3b5482a 100644
--- a/src/common/services/LeatherService.ts
+++ b/src/common/services/LeatherService.ts
@@ -35,7 +35,7 @@ export default class LeatherService extends WalletService {
// eslint-disable-next-line class-methods-use-this
public availableAccounts(): BtcAccount[] {
return [
- constants.BITCOIN_NATIVE_SEGWIT_ADDRESS,
+ BtcAccount.BITCOIN_NATIVE_SEGWIT_ADDRESS,
];
}
diff --git a/src/common/services/LedgerService.ts b/src/common/services/LedgerService.ts
index 0c1f5bac6..af52c28a3 100644
--- a/src/common/services/LedgerService.ts
+++ b/src/common/services/LedgerService.ts
@@ -22,9 +22,9 @@ export default class LedgerService extends WalletService {
// eslint-disable-next-line class-methods-use-this
public availableAccounts(): BtcAccount[] {
return [
- constants.BITCOIN_LEGACY_ADDRESS,
- constants.BITCOIN_SEGWIT_ADDRESS,
- constants.BITCOIN_NATIVE_SEGWIT_ADDRESS,
+ BtcAccount.BITCOIN_LEGACY_ADDRESS,
+ BtcAccount.BITCOIN_SEGWIT_ADDRESS,
+ BtcAccount.BITCOIN_NATIVE_SEGWIT_ADDRESS,
];
}
@@ -113,14 +113,14 @@ export default class LedgerService extends WalletService {
let addressList: Array = [];
const { legacy, segwit, nativeSegwit } = this.addressesToFetch;
addressList = addressList.concat(
- this.getDerivedAddresses(legacy.count, legacy.lastIndex, constants.BITCOIN_LEGACY_ADDRESS),
+ this.getDerivedAddresses(legacy.count, legacy.lastIndex, BtcAccount.BITCOIN_LEGACY_ADDRESS),
).concat(
- this.getDerivedAddresses(segwit.count, segwit.lastIndex, constants.BITCOIN_SEGWIT_ADDRESS),
+ this.getDerivedAddresses(segwit.count, segwit.lastIndex, BtcAccount.BITCOIN_SEGWIT_ADDRESS),
).concat(
this.getDerivedAddresses(
nativeSegwit.count,
nativeSegwit.lastIndex,
- constants.BITCOIN_NATIVE_SEGWIT_ADDRESS,
+ BtcAccount.BITCOIN_NATIVE_SEGWIT_ADDRESS,
),
);
return addressList;
diff --git a/src/common/services/TrezorService.ts b/src/common/services/TrezorService.ts
index d711aa1da..1c6f4c2e5 100644
--- a/src/common/services/TrezorService.ts
+++ b/src/common/services/TrezorService.ts
@@ -57,9 +57,9 @@ export default class TrezorService extends WalletService {
// eslint-disable-next-line class-methods-use-this
public availableAccounts(): BtcAccount[] {
return [
- constants.BITCOIN_LEGACY_ADDRESS,
- constants.BITCOIN_SEGWIT_ADDRESS,
- constants.BITCOIN_NATIVE_SEGWIT_ADDRESS,
+ BtcAccount.BITCOIN_LEGACY_ADDRESS,
+ BtcAccount.BITCOIN_SEGWIT_ADDRESS,
+ BtcAccount.BITCOIN_NATIVE_SEGWIT_ADDRESS,
];
}
diff --git a/src/common/services/WalletService.ts b/src/common/services/WalletService.ts
index 39169541b..db549133a 100644
--- a/src/common/services/WalletService.ts
+++ b/src/common/services/WalletService.ts
@@ -301,9 +301,9 @@ export default abstract class WalletService {
protected async setAccountsXpub(accountIdx: number): Promise {
this.extendedPubKeys = {
- p2pkh: await this.getXpub(constants.BITCOIN_LEGACY_ADDRESS, accountIdx),
- p2sh: await this.getXpub(constants.BITCOIN_SEGWIT_ADDRESS, accountIdx),
- p2wpkh: await this.getXpub(constants.BITCOIN_NATIVE_SEGWIT_ADDRESS, accountIdx),
+ p2pkh: await this.getXpub(BtcAccount.BITCOIN_LEGACY_ADDRESS, accountIdx),
+ p2sh: await this.getXpub(BtcAccount.BITCOIN_SEGWIT_ADDRESS, accountIdx),
+ p2wpkh: await this.getXpub(BtcAccount.BITCOIN_NATIVE_SEGWIT_ADDRESS, accountIdx),
};
}
diff --git a/src/common/services/XverseService.ts b/src/common/services/XverseService.ts
index d79c667d1..b2d866899 100644
--- a/src/common/services/XverseService.ts
+++ b/src/common/services/XverseService.ts
@@ -110,7 +110,7 @@ export default class XverseService extends WalletService {
}
availableAccounts(): BtcAccount[] {
- return [constants.BITCOIN_SEGWIT_ADDRESS];
+ return [BtcAccount.BITCOIN_SEGWIT_ADDRESS];
}
name(): Record<'formal_name' | 'short_name' | 'long_name', string> {
diff --git a/src/common/types/pegInTx.ts b/src/common/types/pegInTx.ts
index 6e2666550..cbcde0ca6 100644
--- a/src/common/types/pegInTx.ts
+++ b/src/common/types/pegInTx.ts
@@ -3,9 +3,11 @@ import SatoshiBig from '@/common/types/SatoshiBig';
import { WalletService } from '@/common/services';
import * as constants from '@/common/store/constants';
-export type BtcAccount = 'BITCOIN_LEGACY_ADDRESS' |
- 'BITCOIN_SEGWIT_ADDRESS' |
- 'BITCOIN_NATIVE_SEGWIT_ADDRESS';
+export enum BtcAccount {
+ BITCOIN_LEGACY_ADDRESS = 'BITCOIN_LEGACY_ADDRESS',
+ BITCOIN_SEGWIT_ADDRESS = 'BITCOIN_SEGWIT_ADDRESS',
+ BITCOIN_NATIVE_SEGWIT_ADDRESS = 'BITCOIN_NATIVE_SEGWIT_ADDRESS'
+}
export type BtcWallet = 'WALLET_LEDGER' | 'WALLET_TREZOR' | 'WALLET_LEATHER' | 'WALLET_XVERSE' | 'WALLET_ENKRYPT';
diff --git a/src/common/views/Home.vue b/src/common/views/Home.vue
index 4ce377150..063d3ab0e 100644
--- a/src/common/views/Home.vue
+++ b/src/common/views/Home.vue
@@ -138,7 +138,7 @@ export default {
async function selectConversion(txType: NonNullable) {
addPeg(txType);
- if (!rskAccount.value) {
+ if (txType === constants.PEG_OUT_TRANSACTION_TYPE && !rskAccount.value) {
try {
await connectWeb3();
} catch (e) {
diff --git a/src/pegin/components/create/PegInAccountSelect.vue b/src/pegin/components/create/PegInAccountSelect.vue
index 5ee9a1ea6..3e177ef16 100644
--- a/src/pegin/components/create/PegInAccountSelect.vue
+++ b/src/pegin/components/create/PegInAccountSelect.vue
@@ -1,86 +1,73 @@
-
-
- Wallet Balance
-
-
-
-
-
+
+
+
+
+ {{ walletService.name().formal_name }} | {{ selectedAccountBalance.toBTCTrimmedString() }}
{{ environmentContext.getBtcTicker() }}
-
-
- {{ balances.nativeSegwit.toBTCTrimmedString() }}
+ {{ selectedAccountBalance.toBTCString() }} {{ environmentContext.getBtcTicker() }}
+
-
-
Native Segwit
-
-
-
-
-
-
- {{ environmentContext.getBtcTicker() }}
-
-
-
-
+
+
+
+
+
{{ selectedAccountTypeBadge.text }}
-
-
-
-
-
- {{ props.title }}
-
-
-
- {{ environmentContext.getBtcTicker() }}
-
-
-
-
- {{ item.raw.appendText }}
-
-
-
-
-
-
-
-
-
-
-
- Loading balances...
-
+
+
+
+
+
+
+ {{ selectedAccountTypeBadge.text }}
+
+
+
+
+
+
+ {{ item.appendText }}
+
+
+
+
+
+
+
+
-
-
+
+