Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ceres fiat option #1212

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^2.0.0",
"@soramitsu/soraneo-wallet-web": "1.24.0",
"@soramitsu/soraneo-wallet-web": "1.25.0",
"@walletconnect/web3-provider": "^1.8.0",
"core-js": "^3.26.0",
"country-code-emoji": "^2.3.0",
11 changes: 7 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -108,8 +108,11 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
@getter.libraryDesignSystem libraryDesignSystem!: DesignSystem;

@mutation.wallet.settings.setSoraNetwork private setSoraNetwork!: (network: WALLET_CONSTS.SoraNetwork) => void;
@mutation.wallet.settings.setSubqueryEndpoint private setSubqueryEndpoint!: (endpoint: string) => void;
@mutation.wallet.settings.setSubsquidEndpoint private setSubsquidEndpoint!: (endpoint: string) => void;
@mutation.wallet.settings.setIndexerEndpoint private setIndexerEndpoint!: (options: {
indexer: WALLET_CONSTS.IndexerType;
endpoint: string;
}) => void;

@mutation.settings.setDefaultNodes private setDefaultNodes!: (nodes: Array<Node>) => void;
@mutation.settings.setNetworkChainGenesisHash private setNetworkChainGenesisHash!: (hash?: string) => void;
@mutation.settings.setFaucetUrl private setFaucetUrl!: (url: string) => void;
@@ -243,8 +246,8 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
api.bridgeProxy.sub.parachainIds = data.PARACHAIN_IDS;
}

this.setSubqueryEndpoint(data.SUBQUERY_ENDPOINT);
this.setSubsquidEndpoint(data.SUBSQUID_ENDPOINT);
this.setIndexerEndpoint({ indexer: WALLET_CONSTS.IndexerType.SUBQUERY, endpoint: data.SUBQUERY_ENDPOINT });
this.setIndexerEndpoint({ indexer: WALLET_CONSTS.IndexerType.SUBSQUID, endpoint: data.SUBSQUID_ENDPOINT });

if (data.FAUCET_URL) {
this.setFaucetUrl(data.FAUCET_URL);
26 changes: 4 additions & 22 deletions src/components/App/Footer/AppFooter.vue
Original file line number Diff line number Diff line change
@@ -200,17 +200,12 @@ export default class AppFooter extends Mixins(TranslationMixin) {
}

// Statistics connection
@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<WALLET_CONSTS.IndexerType, WALLET_TYPES.IndexerState>;

showStatisticsDialog = false;

get indexerStatus(): WALLET_TYPES.ConnectionStatus {
if (this.indexerType === WALLET_CONSTS.IndexerType.SUBQUERY) {
return this.subqueryStatus;
} else {
return this.subsquidStatus;
}
return this.indexersData[this.indexerType].status;
}

get statisticsConnectionClass(): Status {
@@ -226,25 +221,12 @@ export default class AppFooter extends Mixins(TranslationMixin) {
}
}

private get statisticsStatusKey(): string {
switch (this.subqueryStatus) {
case WALLET_TYPES.ConnectionStatus.Unavailable:
return 'unavailable';
case WALLET_TYPES.ConnectionStatus.Loading:
return 'loading';
case WALLET_TYPES.ConnectionStatus.Available:
return 'available';
default:
return 'loading';
}
}

get statisticsConnectionText(): string {
return this.t(`footer.statistics.title.${this.statisticsStatusKey}`);
return this.t(`footer.statistics.title.${this.indexerStatus}`);
}

get statisticsConnectionDesc(): string {
return this.t(`footer.statistics.desc.${this.statisticsStatusKey}`);
return this.t(`footer.statistics.desc.${this.indexerStatus}`);
}

openStatisticsDialog(): void {
5 changes: 3 additions & 2 deletions src/components/App/Footer/Indexer/SelectIndexer.vue
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
<div class="statistics-dialog__group">
<div class="statistics-dialog__item">
<div class="switcher">
<s-switch disabled :value="false" />
<s-switch v-model="useCeres" />
<span>{{ t('footer.statistics.dialog.useCeres') }}</span>
</div>
</div>
@@ -49,7 +49,8 @@ import type { Indexer } from '@/types/indexers';
export default class SelectIndexer extends Mixins(TranslationMixin) {
@Prop({ default: () => [], type: Array }) indexers!: Array<Indexer>;

@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;
}
</script>

57 changes: 24 additions & 33 deletions src/components/App/Footer/StatisticsDialog.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<dialog-base :visible.sync="visibility" :title="t('footer.statistics.dialog.title')" class="select-indexer-dialog">
<select-indexer
v-model="selectedIndexerType"
:ceres-api="useCeresApi"
:indexer.sync="selectedIndexerType"
:ceres.sync="useCeresApi"
:indexers="indexers"
:environment="soraNetwork"
/>
@@ -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<WALLET_CONSTS.SoraNetwork>;
@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<WALLET_CONSTS.IndexerType, WALLET_TYPES.IndexerState>;
@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<void>;
@action.wallet.account.useCeresApiForFiatValues private useCeresApiForFiatValues!: (flag: boolean) => Promise<void>;

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<void> {
await this.selectIndexer(indexer.type);

if (this.indexer.type === indexer.type && this.currentView === IndexerInfoView) {
this.handleBack();
4 changes: 2 additions & 2 deletions src/views/Explore/Container.vue
Original file line number Diff line number Diff line change
@@ -57,14 +57,14 @@ export default class ExploreContainer extends Mixins(mixins.LoadingMixin, Transl
@getter.wallet.account.isLoggedIn private isLoggedIn!: boolean;

exploreQuery = '';
private isAccountItems = storage.get(storageKey as any) ? JSON.parse(storage.get(storageKey as any)) : false;
private isAccountItems = storage.get(storageKey) ? JSON.parse(storage.get(storageKey)) : false;

get isAccountItemsOnly(): boolean {
return this.isAccountItems;
}

set isAccountItemsOnly(value: boolean) {
storage.set(storageKey as any, value); // TODO: Update StorageKey
storage.set(storageKey, value);
this.isAccountItems = value;
}

4 changes: 2 additions & 2 deletions src/views/Explore/Tokens.vue
Original file line number Diff line number Diff line change
@@ -227,14 +227,14 @@ export default class Tokens extends Mixins(ExplorePageMixin, TranslationMixin) {

@getter.assets.whitelistAssets private whitelistAssets!: Array<Asset>;

private isSynths = storage.get(storageKey as any) ? JSON.parse(storage.get(storageKey as any)) : false;
private isSynths = storage.get(storageKey) ? JSON.parse(storage.get(storageKey)) : false;

get isSynthsOnly(): boolean {
return this.isSynths;
}

set isSynthsOnly(value: boolean) {
storage.set(storageKey as any, value); // TODO: Update StorageKey
storage.set(storageKey, value);
this.isSynths = value;
}

8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -2357,10 +2357,10 @@
vue-property-decorator "^9.1.2"
vuex "^3.6.2"

"@soramitsu/soraneo-wallet-web@1.24.0":
version "1.24.0"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.24.0.tgz#af7c0bbd2c099982ef8514866bd23b4d4d182163"
integrity sha512-DqDcsj+xPnrXC55Xtx4k2QJxCT0F8ivX3ZSupGznJuOf6ueNx+U9F1VzoB1d67Cg+ixKx4jAUlHGmuWfw032dg==
"@soramitsu/soraneo-wallet-web@1.25.0":
version "1.25.0"
resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.25.0.tgz#edce75cb2d4771601b3eb6990d9a317008d564d1"
integrity sha512-s/jDmnAce0uf52I0113rvBLs3GpeB9mQOvS3vRUYJZjS0NdmwkW/Uec7B5mT+WiPsZnOs/bbybt8ket5Tgl97g==
dependencies:
"@polkadot/vue-identicon" "2.12.1"
"@sora-substrate/util" "1.24.1"