diff --git a/package.json b/package.json index 6ccfd2608..9ab4ac60e 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "polkaswap-exchange-web", - "version": "1.15.0", + "name": "adar", + "version": "0.1.4", "repository": { "type": "git", - "url": "https://github.com/sora-xor/polkaswap-exchange-web.git" + "url": "https://github.com/soramitsu/adar.git" }, "license": "Apache-2.0", "private": true, diff --git a/public/adar/about/about1.svg b/public/adar/about/about1.svg new file mode 100644 index 000000000..64a6233ca --- /dev/null +++ b/public/adar/about/about1.svg @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/App.vue b/src/App.vue index 261b357ce..e256db5c2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -69,7 +69,7 @@ import type { ConnectToNodeOptions } from '@/types/nodes'; import type { SubNetwork } from '@/utils/ethers-util'; import type { FeatureFlags } from '@/store/settings/types'; import getters from './store/web3/getters'; -import { RecipientStatus } from './store/routeAssets/types'; +import { RecipientStatus, TransactionInfo } from './store/routeAssets/types'; @Component({ components: { @@ -360,6 +360,7 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) @mutation.routeAssets.setRecipientStatus private setRecipientStatus!: any; @mutation.routeAssets.setRecipientCompleted private setRecipientCompleted!: any; @getter.wallet.transactions.activeTxs activeTransactions!: Array; + @mutation.routeAssets.setTxInfo private setTxInfo!: (txInfo: TransactionInfo) => void; handleChangeTransactionADAR(value: Nullable, oldValue: Nullable): void { if ( @@ -390,16 +391,26 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) status: RecipientStatus.FAILED, }); }); - } else if (value.status === TransactionStatus.InBlock || isNewTx) { + } else if (value.status === TransactionStatus.InBlock) { if (isNewTx) { + const { id, blockId, from } = value; + this.setTxInfo({ txId: id as string, blockId: blockId as string, from: from as string }); recipients.forEach((reciever) => { this.setRecipientStatus({ id: reciever.id, - status: RecipientStatus.SUCCESS, + status: RecipientStatus.PASSED, }); - this.setRecipientCompleted(reciever.id); + // this.setRecipientCompleted(reciever.id); }); } + } else if (value.status === TransactionStatus.Finalized) { + recipients.forEach((reciever) => { + this.setRecipientStatus({ + id: reciever.id, + status: RecipientStatus.SUCCESS, + }); + this.setRecipientCompleted(reciever.id); + }); } // remove active tx on finalized or error status // this.removeActiveTxs([value.id as string]); diff --git a/src/components/App/Menu/AppInfoPopper.vue b/src/components/App/Menu/AppInfoPopper.vue index 6ab1e1187..f4710276d 100644 --- a/src/components/App/Menu/AppInfoPopper.vue +++ b/src/components/App/Menu/AppInfoPopper.vue @@ -48,7 +48,8 @@ import { app, SocialNetworkLinks, Links } from '@/consts'; @Component export default class AppInfoPopper extends Mixins(TranslationMixin, mixins.LoadingMixin) { - readonly SocialNetworkLinks = SocialNetworkLinks; + // readonly SocialNetworkLinks = SocialNetworkLinks; + readonly SocialNetworkLinks = []; readonly app = app; specVersion: Nullable = null; @@ -61,18 +62,18 @@ export default class AppInfoPopper extends Mixins(TranslationMixin, mixins.Loadi get textLinks(): Array<{ title: string; href: string }> { return [ - { - title: this.t('helpDialog.privacyPolicy'), - href: Links.privacy, - }, + // { + // title: this.t('helpDialog.privacyPolicy'), + // href: Links.privacy, + // }, { title: this.t('releaseNotesText'), href: Links.releaseNotes, }, - { - title: this.t('helpDialog.termsOfService'), - href: Links.terms, - }, + // { + // title: this.t('helpDialog.termsOfService'), + // href: Links.terms, + // }, ]; } diff --git a/src/components/App/Menu/AppMenu.vue b/src/components/App/Menu/AppMenu.vue index 5cbaf68f6..646aa797c 100644 --- a/src/components/App/Menu/AppMenu.vue +++ b/src/components/App/Menu/AppMenu.vue @@ -59,10 +59,10 @@ class="el-menu-item menu-item--small" tabindex="0" @click.native="openSoraDownloadDialog" - /> + /> --> - --> + - + +
+ +
Select report file format
+
+ {{ `You can either use the PDF or CSV format.` }} +
+
+ + {{ 'PDF' }} + + + {{ 'CSV' }} + +
+
+
+ + + + + diff --git a/src/modules/ADAR/components/RouteAssets/Stages/Done.vue b/src/modules/ADAR/components/RouteAssets/Stages/Done.vue index 5257528c5..ef28dcd53 100644 --- a/src/modules/ADAR/components/RouteAssets/Stages/Done.vue +++ b/src/modules/ADAR/components/RouteAssets/Stages/Done.vue @@ -40,8 +40,13 @@ > {{ 'RE-RUN FAILED TRANSACTIONS' }} - - {{ 'DOWNLOAD PDF OVERVIEW' }} + + {{ 'DOWNLOAD Report' }} + @@ -99,7 +110,7 @@ import TranslationMixin from '@/components/mixins/TranslationMixin'; import { action, getter, state } from '@/store/decorators'; import { components, SUBQUERY_TYPES } from '@soramitsu/soraneo-wallet-web'; import { groupBy, sumBy } from 'lodash'; -import { Recipient, RecipientStatus } from '@/store/routeAssets/types'; +import { Recipient, RecipientStatus, TransactionInfo } from '@/store/routeAssets/types'; import { FPNumber } from '@sora-substrate/util/build'; import { AccountAsset, Asset } from '@sora-substrate/util/build/assets/types'; import WarningMessage from '../WarningMessage.vue'; @@ -111,6 +122,7 @@ import autoTable from 'jspdf-autotable'; WarningMessage, FailedTransactionsDialog: adarLazyComponent(AdarComponents.RouteAssetsFailedTransactionsDialog), ConfirmFinishRoutingDialog: adarLazyComponent(AdarComponents.RouteAssetsConfirmFinishRoutingDialog), + SelectReportFormatDialog: adarLazyComponent(AdarComponents.RouteAssetsSelectReportFormatDialog), }, }) export default class RoutingCompleted extends Mixins(TranslationMixin) { @@ -118,12 +130,15 @@ export default class RoutingCompleted extends Mixins(TranslationMixin) { @getter.routeAssets.completedRecipients private completedRecipients!: Array; @getter.routeAssets.incompletedRecipients private incompletedRecipients!: Array; @getter.routeAssets.recipients private recipients!: Array; + @getter.routeAssets.batchTxInfo private batchTxInfo!: TransactionInfo; + @getter.routeAssets.batchTxDatetime private batchTxDatetime!: Nullable; @state.wallet.account.fiatPriceObject private fiatPriceObject!: any; @state.wallet.account.accountAssets private accountAssets!: Array; @action.routeAssets.cancelProcessing private cancelProcessing!: () => void; showFailedTransactionsDialog = false; showFinishRoutingDialog = false; + showSelectReportFormatDialog = false; get incompletedRecipientsLength() { return this.incompletedRecipients.length; @@ -187,10 +202,14 @@ export default class RoutingCompleted extends Mixins(TranslationMixin) { this.showFinishRoutingDialog = false; } - downloadPDF() { - const doc = new JsPDF({ putOnlyUsedFonts: true, orientation: 'landscape' }); - const headers = ['№', 'Name', 'Wallet', 'USD', 'Input Token', 'Token', 'Amount', 'Status']; - const data = this.recipients.map((recipient, idx) => { + onReportDownloadClick() { + this.showSelectReportFormatDialog = true; + } + + headers = ['№', 'NAME', 'WALLET', 'USD', 'INPUT TOKEN', 'TOKEN', 'AMOUNT', 'RATE', 'STATUS']; + + get reportData() { + return this.recipients.map((recipient, idx) => { return [ `${idx + 1}`, recipient.name.toString(), @@ -199,12 +218,80 @@ export default class RoutingCompleted extends Mixins(TranslationMixin) { this.inputToken.symbol, recipient.asset.symbol, (recipient.amount?.toFixed(5) || '').toString(), + recipient.exchangeRate || '', recipient.status.toString(), ]; }); + } + + downloadCSV() { + const { txId, blockId, from } = this.batchTxInfo; + const datetime = this.batchTxDatetime; + const csvContent = + 'data:text/csv;charset=utf-8,' + + `Transaction Id - ${txId}\n` + + `Block Id - ${blockId}\n` + + `Sender wallet - ${from}\n` + + `Datetime - ${datetime?.toLocaleString()}\n` + + this.headers.join(',') + + '\n' + + this.reportData.map((e) => e.join(',')).join('\n'); + const encodedUri = encodeURI(csvContent); + const link = document.createElement('a'); + link.setAttribute('href', encodedUri); + link.setAttribute('download', `ADAR-${new Date().toLocaleDateString('en-GB')}.csv`); + document.body.appendChild(link); // Required for FF + + link.click(); + } + + downloadPDF() { + const doc = new JsPDF({ putOnlyUsedFonts: true, orientation: 'landscape' }); + const { txId, blockId, from } = this.batchTxInfo; + const datetime = this.batchTxDatetime; + doc.setFontSize(12); + doc.text(`Transaction Id - ${txId}`, 5, 5); + doc.text(`Block Id - ${blockId}`, 5, 10); + doc.text(`Sender wallet - ${from}`, 5, 15); + doc.text(`Datetime - ${datetime?.toLocaleString()}`, 5, 20); autoTable(doc, { - head: [headers], - body: data, + head: [this.headers], + body: this.reportData, + startY: 25, + margin: { top: 5, left: 5, right: 5, bottom: 5 }, + styles: { + lineColor: [237, 228, 231], + lineWidth: 0.3, + fontSize: 10, + }, + headStyles: { + textColor: [161, 154, 157], + fillColor: [253, 247, 251], + }, + bodyStyles: { + fillColor: [253, 247, 251], + textColor: [38, 38, 45], + cellPadding: { top: 10, right: 5, bottom: 10, left: 5 }, + }, + alternateRowStyles: { + fillColor: [255, 250, 251], + }, + columnStyles: { + 8: { + fontStyle: 'bold', + }, + }, + didParseCell: function (data) { + if (data.row.section === 'body') { + if (data.cell.text.includes(RecipientStatus.FAILED)) { + data.cell.styles.textColor = [231, 76, 60]; + } + if (data.cell.text.includes(RecipientStatus.SUCCESS)) { + data.cell.styles.textColor = [52, 173, 135]; + } + } + }, + // includeHiddenHtml: true }); doc.save(`ADAR-${new Date().toLocaleDateString('en-GB')}.pdf`); } diff --git a/src/modules/ADAR/components/RouteAssets/Stages/ReviewDetails.vue b/src/modules/ADAR/components/RouteAssets/Stages/ReviewDetails.vue index 03901ee6d..183ababe4 100644 --- a/src/modules/ADAR/components/RouteAssets/Stages/ReviewDetails.vue +++ b/src/modules/ADAR/components/RouteAssets/Stages/ReviewDetails.vue @@ -38,6 +38,13 @@ +
+
ESTImated ADAR fee (0.75%)
+
+ {{ formatNumber(adarFee) }}
+
+
Total Tokens available
@@ -125,7 +132,7 @@