-
+
{{ t('footer.statistics.dialog.useCeres') }}
@@ -49,7 +49,8 @@ import type { Indexer } from '@/types/indexers';
export default class SelectIndexer extends Mixins(TranslationMixin) {
@Prop({ default: () => [], type: Array }) indexers!: Array
;
- @ModelSync('value', 'input', { type: String }) readonly indexerType!: IndexerType;
+ @ModelSync('indexer', 'update:indexer', { type: String }) readonly indexerType!: IndexerType;
+ @ModelSync('ceres', 'update:ceres', { type: Boolean }) readonly useCeres!: boolean;
}
diff --git a/src/components/App/Footer/StatisticsDialog.vue b/src/components/App/Footer/StatisticsDialog.vue
index e65d571de..d5c2deda8 100644
--- a/src/components/App/Footer/StatisticsDialog.vue
+++ b/src/components/App/Footer/StatisticsDialog.vue
@@ -1,8 +1,8 @@
@@ -13,10 +13,11 @@
import { components, mixins, WALLET_CONSTS, WALLET_TYPES } from '@soramitsu/soraneo-wallet-web';
import { Component, Mixins } from 'vue-property-decorator';
+import { getIndexerName } from '@/components/App/Footer/Indexer/utils';
import TranslationMixin from '@/components/mixins/TranslationMixin';
import { Components } from '@/consts';
import { lazyComponent } from '@/router';
-import { state, mutation } from '@/store/decorators';
+import { action, state, mutation } from '@/store/decorators';
import { Indexer } from '@/types/indexers';
const IndexerListView = 'IndexerListView';
@@ -32,40 +33,26 @@ const IndexerInfoView = 'IndexerInfoView';
export default class SelectIndexerDialog extends Mixins(TranslationMixin, mixins.NotificationMixin) {
@state.settings.selectIndexerDialogVisibility private selectIndexerDialogVisibility!: boolean;
@state.wallet.settings.soraNetwork soraNetwork!: Nullable;
- @state.wallet.settings.subqueryEndpoint subqueryEndpoint!: Indexer['endpoint'];
- @state.wallet.settings.subsquidEndpoint subsquidEndpoint!: Indexer['endpoint'];
- @state.wallet.settings.subqueryStatus private subqueryStatus!: WALLET_TYPES.ConnectionStatus;
- @state.wallet.settings.subsquidStatus private subsquidStatus!: WALLET_TYPES.ConnectionStatus;
+ @state.wallet.settings.indexers private indexersData!: Record;
@state.wallet.settings.indexerType indexerType!: Indexer['type'];
+ @state.wallet.account.ceresFiatValuesUsage private ceresFiatValuesUsage!: boolean;
@mutation.settings.setSelectIndexerDialogVisibility setSelectIndexerDialogVisibility!: (flag: boolean) => void;
- @mutation.wallet.settings.setIndexerType setIndexerType!: (type: WALLET_CONSTS.IndexerType) => void;
+ @action.wallet.settings.selectIndexer private selectIndexer!: (type: WALLET_CONSTS.IndexerType) => Promise;
+ @action.wallet.account.useCeresApiForFiatValues private useCeresApiForFiatValues!: (flag: boolean) => Promise;
currentView = IndexerListView;
- get isSubqueryOnline(): boolean {
- return this.subqueryStatus === WALLET_TYPES.ConnectionStatus.Available;
- }
-
- get isSubsquidOnline(): boolean {
- return this.subsquidStatus === WALLET_TYPES.ConnectionStatus.Available;
- }
-
get indexers(): Indexer[] {
- return [
- {
- name: 'Subquery',
- type: WALLET_CONSTS.IndexerType.SUBQUERY,
- endpoint: this.subqueryEndpoint,
- online: this.isSubqueryOnline,
- },
- {
- name: 'Subsquid',
- type: WALLET_CONSTS.IndexerType.SUBSQUID,
- endpoint: this.subsquidEndpoint,
- online: this.isSubsquidOnline,
- },
- ];
+ return Object.keys(WALLET_CONSTS.IndexerType).map((key) => {
+ const type = WALLET_CONSTS.IndexerType[key];
+ return {
+ name: getIndexerName(type),
+ type,
+ endpoint: this.indexersData[type].endpoint,
+ online: this.indexersData[type].status === WALLET_TYPES.ConnectionStatus.Available,
+ };
+ });
}
get indexer(): Indexer {
@@ -86,7 +73,11 @@ export default class SelectIndexerDialog extends Mixins(TranslationMixin, mixins
}
get useCeresApi(): boolean {
- return true;
+ return this.ceresFiatValuesUsage;
+ }
+
+ set useCeresApi(flag: boolean) {
+ this.useCeresApiForFiatValues(flag);
}
get selectedIndexerType(): WALLET_CONSTS.IndexerType {
@@ -101,8 +92,8 @@ export default class SelectIndexerDialog extends Mixins(TranslationMixin, mixins
this.handleIndexer(indexer);
}
- handleIndexer(indexer: Indexer): void {
- this.setIndexerType(indexer.type);
+ async handleIndexer(indexer: Indexer): Promise {
+ await this.selectIndexer(indexer.type);
if (this.indexer.type === indexer.type && this.currentView === IndexerInfoView) {
this.handleBack();
diff --git a/src/components/mixins/TranslationMixin.ts b/src/components/mixins/TranslationMixin.ts
index 2de6bb95f..188dfdc2b 100644
--- a/src/components/mixins/TranslationMixin.ts
+++ b/src/components/mixins/TranslationMixin.ts
@@ -29,7 +29,6 @@ const TranslationConsts = {
TVL: 'TVL',
EVM: 'EVM',
Kusama: 'Kusama',
- Metamask: 'MetaMask',
ROI: 'ROI', // Return of investment
mbps: 'mbps',
online: 'Online',
diff --git a/src/components/mixins/WalletConnectMixin.ts b/src/components/mixins/WalletConnectMixin.ts
index 8491fb1a5..eb6736703 100644
--- a/src/components/mixins/WalletConnectMixin.ts
+++ b/src/components/mixins/WalletConnectMixin.ts
@@ -5,7 +5,7 @@ import { PageNames } from '@/consts';
import router from '@/router';
import { action, getter, mutation, state } from '@/store/decorators';
import { getWalletAddress, formatAddress } from '@/utils';
-import ethersUtil, { Provider } from '@/utils/ethers-util';
+import { Provider, METAMASK_ERROR } from '@/utils/ethers-util';
import type { BridgeNetworkType } from '@sora-substrate/util/build/bridgeProxy/consts';
import type { BridgeNetworkId } from '@sora-substrate/util/build/bridgeProxy/types';
@@ -13,15 +13,6 @@ import type { BridgeNetworkId } from '@sora-substrate/util/build/bridgeProxy/typ
const checkExtensionKey = 'provider.messages.checkExtension';
const installExtensionKey = 'provider.messages.installExtension';
-const getProviderName = (provider: Provider) => {
- switch (provider) {
- case Provider.Metamask:
- return 'provider.metamask';
- default:
- return 'provider.default';
- }
-};
-
const handleProviderError = (provider: Provider, error: any): string => {
switch (provider) {
case Provider.Metamask:
@@ -33,11 +24,8 @@ const handleProviderError = (provider: Provider, error: any): string => {
const handleMetamaskError = (error: any): string => {
switch (error.code) {
- // 4001: User rejected the request
- // -32002: Already processing eth_requestAccounts. Please wait
- // -32002: Request of type 'wallet_requestPermissions' already pending for origin. Please wait
- case -32002:
- case 4001:
+ case METAMASK_ERROR.AlreadyProcessing:
+ case METAMASK_ERROR.UserRejectedRequest:
return 'provider.messages.extensionLogin';
default:
return checkExtensionKey;
@@ -46,6 +34,8 @@ const handleMetamaskError = (error: any): string => {
@Component
export default class WalletConnectMixin extends Mixins(TranslationMixin) {
+ @state.web3.evmProvider evmProvider!: Nullable;
+ @state.web3.evmProviderLoading evmProviderLoading!: boolean;
@state.web3.evmAddress evmAddress!: string;
@state.web3.networkSelected networkSelected!: BridgeNetworkId;
@state.web3.networkType networkType!: BridgeNetworkType;
@@ -53,20 +43,17 @@ export default class WalletConnectMixin extends Mixins(TranslationMixin) {
@getter.wallet.account.isLoggedIn isSoraAccountConnected!: boolean;
@getter.bridge.isSubBridge isSubBridge!: boolean;
- // update selected evm network without metamask request
- @mutation.web3.resetProvidedEvmNetwork resetProvidedEvmNetwork!: FnWithoutArgs;
- @mutation.web3.resetEvmAddress resetEvmAddress!: FnWithoutArgs;
- @mutation.web3.setEvmAddress setEvmAddress!: (address: string) => void;
@mutation.web3.setSelectAccountDialogVisibility private setSelectAccountDialogVisibility!: (flag: boolean) => void;
+ @mutation.web3.setSelectProviderDialogVisibility setSelectProviderDialogVisibility!: (flag: boolean) => void;
@action.web3.changeEvmNetworkProvided changeEvmNetworkProvided!: AsyncFnWithoutArgs;
- @action.web3.updateProvidedEvmNetwork updateProvidedEvmNetwork!: (networkHex?: string) => Promise;
+ @action.web3.selectEvmProvider selectEvmProvider!: (provider: Provider) => Promise;
+ @action.web3.resetEvmProviderConnection resetEvmProviderConnection!: FnWithoutArgs;
+ @action.web3.disconnectExternalNetwork disconnectExternalNetwork!: AsyncFnWithoutArgs;
getWalletAddress = getWalletAddress;
formatAddress = formatAddress;
- isExternalWalletConnecting = false;
-
connectSoraWallet(): void {
router.push({ name: PageNames.Wallet });
}
@@ -75,18 +62,23 @@ export default class WalletConnectMixin extends Mixins(TranslationMixin) {
this.setSelectAccountDialogVisibility(true);
}
- async connectEvmWallet(): Promise {
- this.isExternalWalletConnecting = true;
- // For now it's only Metamask
- const provider = Provider.Metamask;
+ connectEvmWallet(): void {
+ // [TODO: WalletConnect] Remove
+ this.connectEvmProvider(Provider.Metamask);
+ // [TODO: WalletConnect] Enable
+ // this.setSelectProviderDialogVisibility(true);
+ }
+
+ getEvmProviderIcon(provider: Provider): string {
+ return provider ? `/wallet/${provider}.svg` : '';
+ }
+
+ async connectEvmProvider(provider: Provider): Promise {
try {
- const address = await ethersUtil.onConnect({ provider });
- this.setEvmAddress(address);
+ await this.selectEvmProvider(provider);
} catch (error: any) {
- const name = this.t(getProviderName(provider));
const key = this.te(error.message) ? error.message : handleProviderError(provider, error);
-
- const message = this.t(key, { name });
+ const message = this.t(key, { name: provider });
const showCancelButton = key === installExtensionKey;
this.$alert(message, {
@@ -98,8 +90,6 @@ export default class WalletConnectMixin extends Mixins(TranslationMixin) {
}
},
});
- } finally {
- this.isExternalWalletConnecting = false;
}
}
}
diff --git a/src/components/pages/AddLiquidity/Confirm.vue b/src/components/pages/AddLiquidity/Confirm.vue
index 93f233a34..2c7c17957 100644
--- a/src/components/pages/AddLiquidity/Confirm.vue
+++ b/src/components/pages/AddLiquidity/Confirm.vue
@@ -45,7 +45,7 @@
@click="handleConfirm"
>
- {{ t('exchange.insufficientBalance', { tokenSymbol: insufficientBalanceTokenSymbol }) }}
+ {{ t('insufficientBalanceText', { tokenSymbol: insufficientBalanceTokenSymbol }) }}
{{ t('exchange.confirm') }}
diff --git a/src/components/pages/AddLiquidity/TransactionDetails.vue b/src/components/pages/AddLiquidity/TransactionDetails.vue
index 954268d79..8eee7501f 100644
--- a/src/components/pages/AddLiquidity/TransactionDetails.vue
+++ b/src/components/pages/AddLiquidity/TransactionDetails.vue
@@ -3,17 +3,17 @@
{{ t('createPair.pricePool') }}
{{ t('bridge.networkInfo') }}
- {{ name }}
+
+
{{ name }}
+
+
+ {{ info.content }}
+
+
@@ -18,6 +24,7 @@
-
-
diff --git a/src/components/pages/Moonpay/MoonpayHistory.vue b/src/components/pages/Moonpay/MoonpayHistory.vue
index fd4d4b662..884f87094 100644
--- a/src/components/pages/Moonpay/MoonpayHistory.vue
+++ b/src/components/pages/Moonpay/MoonpayHistory.vue
@@ -112,8 +112,6 @@ export default class MoonpayHistory extends Mixins(mixins.PaginationSearchMixin,
@action.moonpay.getTransactions private getTransactions!: AsyncFnWithoutArgs;
@action.moonpay.getCurrencies private getCurrencies!: AsyncFnWithoutArgs;
- private unwatchEthereum!: FnWithoutArgs;
-
pageAmount = 5; // override PaginationSearchMixin
currentView = HistoryView;
selectedItem: any = {};
@@ -121,35 +119,11 @@ export default class MoonpayHistory extends Mixins(mixins.PaginationSearchMixin,
created(): void {
this.withApi(async () => {
this.initMoonpayApi(); // MoonpayBridgeInitMixin
-
await this.prepareEvmNetwork();
-
await Promise.all([this.getTransactions(), this.getCurrencies()]);
-
- this.unwatchEthereum = await ethersUtil.watchEthereum({
- onAccountChange: (addressList: string[]) => {
- if (addressList.length) {
- this.setEvmAddress(addressList[0]);
- } else {
- this.resetEvmAddress();
- }
- },
- onNetworkChange: (networkHex: string) => {
- this.updateProvidedEvmNetwork(networkHex);
- },
- onDisconnect: () => {
- this.resetProvidedEvmNetwork();
- },
- });
});
}
- beforeDestroy(): void {
- if (typeof this.unwatchEthereum === 'function') {
- this.unwatchEthereum();
- }
- }
-
get currenciesById(): MoonpayCurrenciesById {
return this.currencies.reduce(
(result, item) => ({
@@ -235,7 +209,7 @@ export default class MoonpayHistory extends Mixins(mixins.PaginationSearchMixin,
if (!this.evmAddress) return this.t('connectWalletText');
if (this.bridgeTxToSora) return this.t('moonpay.buttons.view');
- if (!this.externalAccountIsMoonpayRecipient) return this.t('bridgeTransaction.changeAccount');
+ if (!this.externalAccountIsMoonpayRecipient) return this.t('changeAccountText');
if (!this.isValidNetwork) return this.t('changeNetworkText');
return this.t('moonpay.buttons.transfer');
diff --git a/src/components/pages/Referrals/ConfirmBonding.vue b/src/components/pages/Referrals/ConfirmBonding.vue
index f38164c82..8bf404af6 100644
--- a/src/components/pages/Referrals/ConfirmBonding.vue
+++ b/src/components/pages/Referrals/ConfirmBonding.vue
@@ -15,7 +15,7 @@
-
+
@@ -26,14 +26,14 @@
:key="type"
:icon="icon"
:active="active"
- :disabled="parentLoading || loading"
+ :disabled="chartIsLoading"
size="small"
@click="selectChartType(type)"
/>
{
if (this.isInsufficientBalance) {
- this.$alert(
- this.t('exchange.insufficientBalance', { tokenSymbol: this.tokenFrom ? this.tokenFrom.symbol : '' }),
- { title: this.t('errorText') }
- );
+ this.$alert(this.t('insufficientBalanceText', { tokenSymbol: this.tokenFrom ? this.tokenFrom.symbol : '' }), {
+ title: this.t('errorText'),
+ });
this.$emit('confirm');
} else {
try {
diff --git a/src/components/pages/Swap/TransactionDetails.vue b/src/components/pages/Swap/TransactionDetails.vue
index 7349dc9d1..43ddf10e7 100644
--- a/src/components/pages/Swap/TransactionDetails.vue
+++ b/src/components/pages/Swap/TransactionDetails.vue
@@ -31,7 +31,7 @@
/>
{{ title }}
{{ description }}
-
+
diff --git a/src/components/shared/Dialog/SelectProvider.vue b/src/components/shared/Dialog/SelectProvider.vue
new file mode 100644
index 000000000..c537a8e89
--- /dev/null
+++ b/src/components/shared/Dialog/SelectProvider.vue
@@ -0,0 +1,90 @@
+