Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 92 deletions.
23 changes: 9 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
module.exports = {
extends: ["@nuxtjs/eslint-config-typescript", "plugin:prettier/recommended", "plugin:vue/base", "prettier"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
parser: "@typescript-eslint/parser",
ecmaVersion: 2018,
sourceType: "module",
extraFileExtensions: [".vue"],
},
root: true,
env: {
node: true,
browser: true,
},
extends: ["@nuxtjs/eslint-config-typescript", "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
rules: {
// enable additional rules
indent: ["error", 2],
"linebreak-style": ["error", "unix"],
quotes: ["error", "double"],
camelcase: "off",
Expand All @@ -18,16 +25,4 @@ module.exports = {
"no-console": "off",
"@typescript-eslint/no-empty-function": ["off"],
},
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2021,
project: ["./tsconfig.json"],
tsconfigRootDir: __dirname,
sourceType: "module",
ecmaFeatures: {
jsx: false,
},

extraFileExtensions: ["*.vue", ".*.vue"],
},
};
16 changes: 10 additions & 6 deletions src/blocks/Balances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ export default Vue.extend({
},
displayedList(): DisplayToken[] {
const allTokenPrices = this.$accessor.tokens.getTokenPrices;
const returnTokens = <{
[symbol: string]: DisplayToken;
}>{};
const returnTokens = <
{
[symbol: string]: DisplayToken;
}
>{};
this.zkBalances.forEach((token) => {
returnTokens[token.symbol] = {
symbol: token.symbol,
Expand Down Expand Up @@ -143,9 +145,11 @@ export default Vue.extend({
this.$accessor.transaction.getForceUpdateTick; // Force to update the list
const deposits = this.$accessor.transaction.depositList;
const activeDeposits = <ZkInDeposits>{};
const finalDeposits = <{
[tokenSymbol: string]: BigNumber;
}>{};
const finalDeposits = <
{
[tokenSymbol: string]: BigNumber;
}
>{};
for (const tokenSymbol in deposits) {
activeDeposits[tokenSymbol] = deposits[tokenSymbol].filter((tx) => tx.status === "Initiated");
}
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/ChooseContact.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ export default Vue.extend({
this.saveContactModalError = "Name can't be empty";
return;
}
if(this.chosenContact) {
if (this.chosenContact) {
const contact = {
name: this.saveContactInput,
address: (this.chosenContact as ZkInContact).address,
address: (this.chosenContact as ZkInContact).address,
};
this.$accessor.contacts.saveContact(contact);
this.chooseContact(contact);
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/ChooseToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export default Vue.extend({
};
},
computed: {
balances: <ZkInBalance>() => {
balances(): ZkInBalance[] {
return this.tokensType === "L2" ? this.$accessor.wallet.getzkBalances : this.$accessor.wallet.getInitialBalances;
},
displayedList(): Array<ZkInBalance> {
let list: Array<ZkInBalance> = utils.searchInArr(this.search, this.balances, (e) => (e as ZkInBalance).symbol) as ZkInBalance[];
displayedList(): ZkInBalance[] {
let list: ZkInBalance[] = utils.searchInArr(this.search, this.balances, (e) => (e as ZkInBalance).symbol) as ZkInBalance[];
if (this.onlyAllowed) {
list = list.filter((e) => !e.restricted);
}
Expand Down
8 changes: 3 additions & 5 deletions src/blocks/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@
import logo from "@/blocks/Logo.vue";
import userImg from "@/components/userImg.vue";
import accountModal from "@/blocks/modals/AccountModal.vue";
import {formatters} from "stylelint";
import Vue from "vue";
import string = formatters.string;
export default Vue.extend({
components: {
Expand All @@ -60,11 +58,11 @@ export default Vue.extend({
accountModal,
},
computed: {
walletName: string () => {
return this.$accessor.account.name || '';
walletName(): string {
return this.$accessor.account.name || "";
},
walletAddressFull(): string {
return this.$accessor.account.address || '';
return this.$accessor.account.address || "";
},
accountModal: {
get(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/Mint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default Vue.extend({
};
},
computed: {
networkName() {
networkName(): string {
return ETHER_NETWORK_NAME;
},
},
Expand Down
17 changes: 11 additions & 6 deletions src/blocks/Transaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ import amountInput from "@/components/AmountInput.vue";
import loadingBlock from "@/components/LoadingBlock.vue";
import successBlock from "@/components/SuccessBlock.vue";
import { APP_ZKSYNC_BLOCK_EXPLORER } from "@/plugins/build";
import { Address, TokenSymbol, TransactionReceipt } from "zksync/build/types";
import { Address, TransactionReceipt, Transfer } from "zksync/build/types";
import { Transaction } from "zksync/build/wallet";
import { closestPackableTransactionAmount } from "zksync";
Expand All @@ -201,6 +201,7 @@ import { walletData } from "@/plugins/walletData";
import { BigNumber } from "ethers";
import Vue, { PropOptions } from "vue";
import { ChangePubKey, CloseAccount, ForcedExit, TxEthSignature, Withdraw } from "zksync/src/types";
export default Vue.extend({
components: {
Expand Down Expand Up @@ -396,8 +397,8 @@ export default Vue.extend({
this.chosenToken = token;
this.chooseTokenModal = false;
this.transactionMode = "normal";
const balances = <Array<ZkInBalance>>JSON.parse(JSON.stringify(this.$accessor.wallet.getzkBalances)).sort(
(a: ZkInBalance, b: ZkInBalance) => parseFloat(b.balance) - parseFloat(a.balance),
const balances = <Array<ZkInBalance>>(
JSON.parse(JSON.stringify(this.$accessor.wallet.getzkBalances)).sort((a: ZkInBalance, b: ZkInBalance) => parseFloat(b.balance) - parseFloat(a.balance))
);
if (this.chosenToken.restricted) {
let tokenFound = false;
Expand Down Expand Up @@ -497,15 +498,19 @@ export default Vue.extend({
if (this.feesObj === undefined) {
throw new Error("Fee fetching error :(");
}
const withdrawTransaction = (await withdraw({
const withdrawTransaction:
| Array<{ tx?: Transfer | Withdraw | ChangePubKey | CloseAccount | ForcedExit; signature?: TxEthSignature }>[]
| Transaction
| undefined = await withdraw({
address: this.inputtedAddress,
token: (this.chosenToken as ZkInBalance).symbol,
feeToken: this.feeToken.symbol,
amount: txAmount.toString(),
fastWithdraw: this.transactionMode === "fast",
fees: (this.transactionMode === "fast" ? (this.feesObj as ZkInFeesObj)?.fast : (this.feesObj as ZkInFeesObj)?.normal) as string,
store: this.$accessor,
}));
});
let receipt: TransactionReceipt;
this.transactionInfo.amount!.amount = txAmount.toString();
this.transactionInfo.amount!.token = this.chosenToken as ZkInBalance;
Expand All @@ -519,7 +524,7 @@ export default Vue.extend({
name: this.chosenContact ? this.chosenContact.name : "",
};
this.tip = "Waiting for the transaction to be mined...";
receipt = await withdrawTransaction.awaitReceipt();
receipt = await withdrawTransaction?.awaitReceipt();
} else {
this.transactionInfo.hash = withdrawTransaction[0].txHash;
this.transactionInfo.explorerLink = APP_ZKSYNC_BLOCK_EXPLORER + "/transactions/" + withdrawTransaction[0].txHash;
Expand Down
8 changes: 5 additions & 3 deletions src/components/AllowanceInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default Vue.extend({
try {
inputAmount = utils.parseToken(this.token.symbol, val);
} catch (error) {
let errorInfo = `Amount processing error. Common reason behind it — inaccurate amount. Try again paying attention to the decimal amount number format — it should help`;
let errorInfo = "Amount processing error. Common reason behind it — inaccurate amount. Try again paying attention to the decimal amount number format — it should help";
if (error.message && error.message.search("fractional component exceeds decimals") !== -1) {
errorInfo = `Precision exceeded: ${this.token.symbol} doesn't support that many decimal digits`;
}
Expand All @@ -134,7 +134,7 @@ export default Vue.extend({
if (this.minAmount) {
if (inputAmount.lt(this.minAmount)) {
this.error = `Inputted amount is lower than the minimum amount`;
this.error = "Inputted amount is lower than the minimum amount";
return;
}
}
Expand All @@ -143,7 +143,9 @@ export default Vue.extend({
},
chooseMinAmount() {
try {
if(!this.token){return}
if (!this.token) {
return;
}
this.inputtedAmount = utils.handleFormatToken(this.token.symbol, this.minAmount);
} catch (error) {
console.log("Error choose max amount", error);
Expand Down
2 changes: 1 addition & 1 deletion src/components/AmountInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default Vue.extend({
try {
inputAmount = utils.parseToken(this.token.symbol, val);
} catch (error) {
let errorInfo = `Amount processing error. Common reason behind it — inaccurate amount. Try again paying attention to the decimal amount number format — it should help`;
let errorInfo = "Amount processing error. Common reason behind it — inaccurate amount. Try again paying attention to the decimal amount number format — it should help";
if (error.message && error.message.search("fractional component exceeds decimals") !== -1) {
errorInfo = `Precision exceeded: ${this.token.symbol} doesn't support that many decimal digits`;
}
Expand Down
33 changes: 15 additions & 18 deletions src/components/SingleTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
import utils from "@/plugins/utils";
import { APP_ETH_BLOCK_EXPLORER, APP_ZKSYNC_BLOCK_EXPLORER } from "@/plugins/build";
import { ZkInTx } from "@/plugins/types";
import { Address } from "zksync/build/types";
import { Address, TokenSymbol } from "zksync/build/types";
import { walletData } from "@/plugins/walletData";
import { TokenSymbol } from "zksync/build/types";
import moment from "moment";
import Vue, { PropOptions } from "vue";
Expand Down Expand Up @@ -68,18 +67,17 @@ export default Vue.extend({
);
},
walletAddressFull(): Address {
return this.$accessor.account.address || '';
return this.$accessor.account.address || "";
},
displayedAddress(): Address {
if(this.singleTransaction.tx.type === "Transfer") {
if(this.isSameAddress(this.singleTransaction.tx.to || '')) {
if (this.singleTransaction.tx.type === "Transfer") {
if (this.isSameAddress(this.singleTransaction.tx.to || "")) {
return this.singleTransaction.tx.from;
}
}
else if(this.singleTransaction.tx.priority_op) {
} else if (this.singleTransaction.tx.priority_op) {
return this.singleTransaction.tx.priority_op.to;
}
return this.singleTransaction.tx.to || '';
return this.singleTransaction.tx.to || "";
},
transactionStatus(): { text: string; icon: string } {
if (this.singleTransaction.success === false) {
Expand Down Expand Up @@ -119,7 +117,8 @@ export default Vue.extend({
showAddress: false,
tooltip: {
icon: "ri-information-fill",
html: `Activation is required single-time payment to set the signing key associated with the account.<br>Without it no operation can be authorized by your corresponding account.`,
html:
"Activation is required single-time payment to set the signing key associated with the account.<br>Without it no operation can be authorized by your corresponding account.",
},
};
case "Deposit":
Expand Down Expand Up @@ -161,12 +160,10 @@ export default Vue.extend({
if (this.singleTransaction.tx.priority_op) {
return this.singleTransaction.tx.priority_op.token;
}
} else {
if (typeof this.singleTransaction.tx.feeToken === "number") {
return this.$accessor.tokens.getTokenByID(this.singleTransaction.tx.feeToken)!.symbol
} else if (this.singleTransaction.tx.priority_op) {
return this.singleTransaction.tx.priority_op.token;
}
} else if (typeof this.singleTransaction.tx.feeToken === "number") {
return this.$accessor.tokens.getTokenByID(this.singleTransaction.tx.feeToken)!.symbol;
} else if (this.singleTransaction.tx.priority_op) {
return this.singleTransaction.tx.priority_op.token;
}
return this.singleTransaction.tx.token!;
},
Expand All @@ -192,10 +189,10 @@ export default Vue.extend({
return moment(time).fromNow();
},
getFormattedAmount({ tx: { type, priority_op, amount, fee } }: ZkInTx): string {
if(!this.isFeeTransaction) {
return utils.handleFormatToken(this.tokenSymbol, type === "Deposit" && priority_op ? priority_op.amount : amount) || '';
if (!this.isFeeTransaction) {
return utils.handleFormatToken(this.tokenSymbol, type === "Deposit" && priority_op ? priority_op.amount : amount) || "";
} else {
return utils.handleFormatToken(this.tokenSymbol, fee) || '';
return utils.handleFormatToken(this.tokenSymbol, fee) || "";
}
},
getAddressName(address: string): string {
Expand Down
7 changes: 2 additions & 5 deletions src/components/userImg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ export default Vue.extend({
} as PropOptions<Address>,
},
computed: {
walletImg() {
if (!this.wallet) {
return "";
}
return blockie(this.wallet);
walletImg(): string {
return !this.wallet ? "" : blockie(this.wallet);
},
},
});
Expand Down
9 changes: 5 additions & 4 deletions src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import loggingInLoader from "@/blocks/LoggingInLoader.vue";
import { APP_ZK_SCAN } from "@/plugins/build";
import Vue from "vue";
import {Address} from "zksync/src/types";
export default Vue.extend({
components: {
Expand All @@ -29,16 +30,16 @@ export default Vue.extend({
loggingInLoader,
},
computed: {
loggingIn:boolean () => {
loggingIn(): boolean{
return this.$accessor.account.loader;
},
loggedIn() {
loggedIn(): boolean {
return this.$accessor.account.loggedIn;
},
walletAddressFull() {
walletAddressFull(): Address {
return this.$accessor.account.address;
},
getZkScanBaseUrl() {
getZkScanBaseUrl(): string {
return APP_ZK_SCAN;
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/pages/_symbol.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import transactions from "@/blocks/Transactions.vue";
import { ZkInBalance } from "@/plugins/types";
import Vue from "vue";
import { TokenSymbol } from "zksync/src/types";
export default Vue.extend({
components: {
Expand All @@ -56,7 +57,7 @@ export default Vue.extend({
};
},
computed: {
symbol() {
symbol(): TokenSymbol {
return this.$route.params.symbol.toUpperCase();
},
},
Expand Down
3 changes: 2 additions & 1 deletion src/pages/account/_symbol.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import transactions from "@/blocks/Transactions.vue";
import { ZkInBalance } from "@/plugins/types";
import Vue from "vue";
import { TokenSymbol } from "zksync/src/types";
export default Vue.extend({
components: {
Expand All @@ -56,7 +57,7 @@ export default Vue.extend({
};
},
computed: {
symbol() {
symbol(): TokenSymbol {
return this.$route.params.symbol.toUpperCase();
},
},
Expand Down
Loading

0 comments on commit 7d8d44d

Please sign in to comment.