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

Release/fleek/1.8.0 #685

Merged
merged 11 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions env.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"FEATURE_FLAGS": {
"moonpay": true
},
"SUBQUERY_ENDPOINT": "https://api.subquery.network/sq/sora-xor/sora",
"DEFAULT_NETWORKS": [
{
"chain": "SORA",
Expand All @@ -26,8 +27,8 @@
},
{
"chain": "SORA",
"name": "SORA Community (Lux8)",
"address": "wss://sora.lux8.net"
"name": "OnFinality",
"address": "wss://sora.api.onfinality.io/public-ws"
}
],
"NETWORK_TYPE": "Prod",
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkaswap-exchange-web",
"version": "1.7.0",
"version": "1.8.0",
"license": "Apache-2.0",
"private": true,
"author": "[email protected] <[email protected]>",
Expand All @@ -20,18 +20,18 @@
},
"dependencies": {
"@metamask/detect-provider": "^1.2.0",
"@soramitsu/soraneo-wallet-web": "^1.7.31",
"@soramitsu/soraneo-wallet-web": "1.8.23",
"@walletconnect/web3-provider": "^1.6.6",
"core-js": "^3.6.4",
"direct-vuex": "^0.12.1",
"ethers": "^5.5.4",
"lodash": "^4.17.21",
"vue": "^2.6.14",
"vue-class-component": "^7.2.6",
"vue-i18n": "^8.11.2",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.5.3",
"vuex": "^3.1.3",
"vuex-class": "^0.3.2"
"vuex": "^3.1.3"
},
"devDependencies": {
"@babel/runtime": "^7.12.5",
Expand Down Expand Up @@ -74,6 +74,7 @@
"ts-jest": "^27.0.5",
"typescript": "~4.4.4",
"vue-cli-plugin-electron-builder": "^3.0.0-alpha.3",
"vue-svg-loader": "^0.16.0",
"vue-template-compiler": "^2.6.14"
},
"gitHooks": {
Expand Down
1 change: 1 addition & 0 deletions public/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"moonpay": true
},
"FAUCET_URL": "https://faucet.dev.sora2.tachi.soramitsu.co.jp/",
"SUBQUERY_ENDPOINT": "https://api.subquery.network/sq/sora-xor/sora-dev",
"DEFAULT_NETWORKS": [
{
"chain": "SORA-dev Testnet",
Expand Down
7 changes: 3 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@
<meta name="author" property="author" content="SORA">
<meta name="twitter:title" content="Polkaswap — The DEX for the Interoperable Future." />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="<%= BASE_URL %>polkaswap-share-image.jpg" />
<meta name="twitter:image" content="https://polkaswap.io/<%= BASE_URL %>polkaswap-share-image.jpg" />
<meta name="twitter:site" content="@polkaswap" />
<meta name="twitter:description" content="Cross-chain exchange of assets, simple creation and listing of new assets, and the easiest swaps ever. The interoperable future of Polkadot is here and we are at the forefront!" />
<meta property="og:title" content="Polkaswap — The DEX for the Interoperable Future.">
<meta property="og:description" content="Cross-chain exchange of assets, simple creation and listing of new assets, and the easiest swaps ever. The interoperable future of Polkadot is here and we are at the forefront!" />
<meta property="og:site_name" content="Polkaswap" />
<meta property="og:type" content="website">
<meta property="og:url" content="https://polkaswap.io/">
<meta property="og:image" content="<%= BASE_URL %>polkaswap-share-image.jpg">
<meta property="og:image:secure_url" content="<%= BASE_URL %>polkaswap-share-image.jpg" />
<meta property="og:image" content="https://polkaswap.io/<%= BASE_URL %>polkaswap-share-image.jpg">
<meta property="og:image:secure_url" content="https://polkaswap.io/<%= BASE_URL %>polkaswap-share-image.jpg" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="630" />
</head>
Expand Down
119 changes: 68 additions & 51 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
:visible="menuVisibility"
:on-select="goTo"
:is-about-page-opened="isAboutPage"
@open-download-dialog="openDownloadDialog"
@click.native="handleAppMenuClick"
>
<app-logo-button slot="head" class="app-logo--menu" :theme="libraryTheme" @click="goTo(PageNames.Swap)" />
<app-logo-button slot="head" class="app-logo--menu" :theme="libraryTheme" @click="goToSwap" />
</app-menu>
<div class="app-body" :class="{ 'app-body__about': isAboutPage }">
<s-scrollbar class="app-body-scrollbar">
Expand All @@ -35,27 +36,31 @@
</div>
</div>
<referrals-confirm-invite-user :visible.sync="showConfirmInviteUser" />
<bridge-transfer-notification />
<mobile-popup :visible.sync="showMobilePopup" />
</s-design-system-provider>
</template>

<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { Action, Getter } from 'vuex-class';
import { FPNumber, History, connection } from '@sora-substrate/util';
import { FPNumber, History, connection, HistoryItem } from '@sora-substrate/util';
import { mixins, getExplorerLinks, WALLET_CONSTS, WALLET_TYPES } from '@soramitsu/soraneo-wallet-web';
import Theme from '@soramitsu/soramitsu-js-ui/lib/types/Theme';
import type DesignSystem from '@soramitsu/soramitsu-js-ui/lib/types/DesignSystem';

import NodeErrorMixin from '@/components/mixins/NodeErrorMixin';
import SoraLogo from '@/components/logo/Sora.vue';
import MobilePopup from '@/components/MobilePopup/MobilePopup.vue';

import { PageNames, Components, Language } from '@/consts';
import axiosInstance, { updateBaseUrl } from '@/api';
import router, { goTo, lazyComponent } from '@/router';
import { action, getter, mutation, state } from '@/store/decorators';
import { preloadFontFace } from '@/utils';
import { getLocale } from '@/lang';
import type { ConnectToNodeOptions } from '@/types/nodes';
import type { SubNetwork } from '@/utils/ethers-util';
import type { FeatureFlags } from '@/store/settings/types';

@Component({
components: {
Expand All @@ -64,46 +69,48 @@ import type { SubNetwork } from '@/utils/ethers-util';
AppMenu: lazyComponent(Components.AppMenu),
AppLogoButton: lazyComponent(Components.AppLogoButton),
ReferralsConfirmInviteUser: lazyComponent(Components.ReferralsConfirmInviteUser),
BridgeTransferNotification: lazyComponent(Components.BridgeTransferNotification),
MobilePopup,
},
})
export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) {
readonly PageNames = PageNames;
readonly PoolChildPages = [PageNames.AddLiquidity, PageNames.RemoveLiquidity, PageNames.CreatePair];

menuVisibility = false;
showConfirmInviteUser = false;
showMobilePopup = false;

@state.wallet.settings.soraNetwork private soraNetwork!: Nullable<WALLET_CONSTS.SoraNetwork>;
@state.referrals.storageReferrer storageReferrer!: string;
@state.settings.blockNumber blockNumber!: number;

@getter.wallet.transactions.firstReadyTx firstReadyTransaction!: Nullable<HistoryItem>;
@getter.wallet.account.isLoggedIn isSoraAccountConnected!: boolean;
@getter.libraryTheme libraryTheme!: Theme;
@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.settings.setDefaultNodes private setDefaultNodes!: (nodes: Array<Node>) => void;
@mutation.settings.setNetworkChainGenesisHash private setNetworkChainGenesisHash!: (hash?: string) => void;
@mutation.settings.setFaucetUrl private setFaucetUrl!: (url: string) => void;
@mutation.settings.setFeatureFlags private setFeatureFlags!: (data: FeatureFlags) => void;
@mutation.settings.resetBlockNumberSubscription private resetBlockNumberSubscription!: VoidFunction;
@mutation.rewards.unsubscribeAccountMarketMakerInfo private unsubscribeMarketMakerInfo!: VoidFunction;
@mutation.referrals.unsubscribeFromInvitedUsers private unsubscribeFromInvitedUsers!: VoidFunction;
@mutation.web3.setSubNetworks private setSubNetworks!: (data: Array<SubNetwork>) => void;
@mutation.referrals.resetStorageReferrer private resetStorageReferrer!: VoidFunction;

@action.wallet.settings.setApiKeys private setApiKeys!: (apiKeys: WALLET_TYPES.ApiKeysObject) => Promise<void>;
@action.wallet.subscriptions.resetNetworkSubscriptions private resetNetworkSubscriptions!: AsyncVoidFn;
@action.wallet.subscriptions.resetInternalSubscriptions private resetInternalSubscriptions!: AsyncVoidFn;
@action.wallet.subscriptions.activateNetwokSubscriptions private activateNetwokSubscriptions!: AsyncVoidFn;
@action.settings.connectToNode private connectToNode!: (options: ConnectToNodeOptions) => Promise<void>;
@action.settings.setLanguage private setLanguage!: (lang: Language) => Promise<void>;
@action.web3.setSmartContracts private setSmartContracts!: (data: Array<SubNetwork>) => Promise<void>;
@action.referrals.getReferrer private getReferrer!: AsyncVoidFn;

@Getter soraNetwork!: WALLET_CONSTS.SoraNetwork;
@Getter libraryTheme!: Theme;
@Getter libraryDesignSystem!: DesignSystem;
@Getter firstReadyTransaction!: History;
@Getter blockNumber!: number;
@Getter('isLoggedIn') isSoraAccountConnected!: boolean;
@Getter('storageReferral', { namespace: 'referrals' }) storageReferral!: string;
@Getter('referral', { namespace: 'referrals' }) referral!: string;

// Wallet
@Action activateNetwokSubscriptions!: AsyncVoidFn;
@Action resetNetworkSubscriptions!: AsyncVoidFn;
@Action resetInternalSubscriptions!: AsyncVoidFn;
@Action setSoraNetwork!: (networkType: string) => Promise<void>;
@Action setApiKeys!: (options: WALLET_TYPES.ApiKeysObject) => Promise<void>;

@Action setDefaultNodes!: (nodes: any) => Promise<void>;
@Action setNetworkChainGenesisHash!: (hash: string) => Promise<void>;
@Action connectToNode!: (options: ConnectToNodeOptions) => Promise<void>;
@Action setFaucetUrl!: (url: string) => Promise<void>;
@Action setLanguage!: (lang: Language) => Promise<void>;
@Action setFeatureFlags!: (options: any) => Promise<void>;
@Action resetBlockNumberSubscription!: AsyncVoidFn;
@Action('unsubscribeAccountMarketMakerInfo', { namespace: 'rewards' }) unsubscribeMarketMakerInfo!: AsyncVoidFn;
@Action('setSubNetworks', { namespace: 'web3' }) setSubNetworks!: (data: Array<SubNetwork>) => Promise<void>;
@Action('setSmartContracts', { namespace: 'web3' }) setSmartContracts!: (data: Array<SubNetwork>) => Promise<void>;
@Action('getReferral', { namespace: 'referrals' }) getReferral!: (invitedUserId: string) => Promise<void>;
@Action('setReferral', { namespace: 'referrals' }) setReferral!: (value: string) => Promise<void>;
@Watch('firstReadyTransaction', { deep: true })
private handleNotifyAboutTransaction(value: History): void {
this.handleChangeTransaction(value);
private handleNotifyAboutTransaction(value: History, oldValue: History): void {
this.handleChangeTransaction(value, oldValue);
}

@Watch('nodeIsConnected')
Expand All @@ -125,18 +132,18 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
}
}

@Watch('storageReferral', { immediate: true })
private async confirmInviteUserIfHasStorage(storageReferralValue: string): Promise<void> {
if (this.isSoraAccountConnected && storageReferralValue?.length) {
@Watch('storageReferrer', { immediate: true })
private async confirmInviteUserIfHasStorage(storageReferrerValue: string): Promise<void> {
if (this.isSoraAccountConnected && !!storageReferrerValue) {
await this.confirmInvititation();
}
}

async confirmInvititation(): Promise<void> {
await this.getReferral(this.account.address);
if (this.storageReferral) {
if (this.storageReferral === this.account.address) {
this.setReferral('');
await this.getReferrer();
if (this.storageReferrer) {
if (this.storageReferrer === this.account.address) {
this.resetStorageReferrer();
} else {
this.showConfirmInviteUser = true;
}
Expand All @@ -149,7 +156,7 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)

updateBaseUrl(router);

await this.setLanguage(getLocale() as any);
await this.setLanguage(getLocale() as Language);

await this.withLoading(async () => {
const { data } = await axiosInstance.get('/env.json');
Expand All @@ -159,17 +166,18 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
}

await this.setApiKeys(data?.API_KEYS);
await this.setFeatureFlags(data?.FEATURE_FLAGS);
await this.setSoraNetwork(data.NETWORK_TYPE);
await this.setDefaultNodes(data?.DEFAULT_NETWORKS);
await this.setSubNetworks(data.SUB_NETWORKS);
this.setFeatureFlags(data?.FEATURE_FLAGS);
this.setSoraNetwork(data.NETWORK_TYPE);
this.setSubqueryEndpoint(data.SUBQUERY_ENDPOINT);
this.setDefaultNodes(data?.DEFAULT_NETWORKS);
this.setSubNetworks(data.SUB_NETWORKS);
await this.setSmartContracts(data.SUB_NETWORKS);

if (data.FAUCET_URL) {
this.setFaucetUrl(data.FAUCET_URL);
}
if (data.CHAIN_GENESIS_HASH) {
await this.setNetworkChainGenesisHash(data.CHAIN_GENESIS_HASH);
this.setNetworkChainGenesisHash(data.CHAIN_GENESIS_HASH);
}

// connection to node
Expand All @@ -194,6 +202,10 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
this.closeMenu();
}

goToSwap(): void {
this.goTo(PageNames.Swap);
}

toggleMenu(): void {
this.menuVisibility = !this.menuVisibility;
}
Expand All @@ -211,11 +223,16 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin)
}
}

openDownloadDialog(): void {
this.showMobilePopup = true;
}

async beforeDestroy(): Promise<void> {
await this.resetInternalSubscriptions();
await this.resetNetworkSubscriptions();
await this.resetBlockNumberSubscription();
await this.unsubscribeMarketMakerInfo();
this.resetBlockNumberSubscription();
this.unsubscribeFromInvitedUsers();
this.unsubscribeMarketMakerInfo();
await connection.close();
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { axiosInstance } from '@sora-substrate/util';
import VueRouter from 'vue-router';
import type VueRouter from 'vue-router';

export const BASE_URL = process.env.BASE_URL;

Expand Down
9 changes: 9 additions & 0 deletions src/assets/img/metamask.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/img/mobile/app-store-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/img/mobile/google-play-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading