Skip to content

Commit

Permalink
Fix fee warning dialog behavior (#910)
Browse files Browse the repository at this point in the history
* Fix fee warning dialog behavior

* Update deps

* Update yarn.lock

* Fix table overrides
  • Loading branch information
stefashkaa authored Dec 30, 2022
1 parent f5213ed commit e3605e5
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 195 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@metamask/detect-provider": "^2.0.0",
"@soramitsu/soraneo-wallet-web": "1.12.11",
"@soramitsu/soraneo-wallet-web": "1.12.13",
"@walletconnect/web3-provider": "^1.8.0",
"base-64": "^1.0.0",
"core-js": "^3.26.0",
Expand Down Expand Up @@ -91,6 +91,14 @@
"vue-svg-loader": "^0.16.0",
"vue-template-compiler": "2.6.14"
},
"resolutions": {
"@polkadot/extension-dapp": "^0.44.7",
"@polkadot/extension-inject": "^0.44.7",
"@polkadot/util": "^10.2.1",
"ipfs-unixfs": "6.0.6",
"ipfs-unixfs-exporter": "7.0.6",
"ipfs-unixfs-importer": "9.0.6"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
Expand Down
36 changes: 20 additions & 16 deletions src/styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -631,18 +631,22 @@ $button-custom-shadow: -1px -1px 5px rgba(0, 0, 0, 0.05), 1px 1px 5px rgba(0, 0,
background: transparent;
font-size: var(--s-font-size-medium);
font-weight: 600;

thead {
text-transform: uppercase;
font-size: var(--s-font-size-small);
letter-spacing: var(--s-letter-spacing-mini);

[class^='s-icon-'],
[class*=' s-icon-'] {
@include icon-styles;
}
}


tr {
background-color: transparent;
}

tr,
th {
&,
Expand All @@ -665,31 +669,31 @@ $button-custom-shadow: -1px -1px 5px rgba(0, 0, 0, 0.05), 1px 1px 5px rgba(0, 0,

.el-table__fixed {
height: 100% !important; // overrides element-ui js style property

&:before,
&:after {
content: unset;
}

.el-table__fixed-body-wrapper {
height: 100% !important; // overrides element-ui js style property
}
}

.el-table__body-wrapper {
height: auto !important; // overrides element-ui js style property

&.is-scrolling-left ~ .el-table__fixed {
box-shadow: inherit;
}

.el-scrollbar__bar.is-horizontal {
right: 0;
left: unset;
width: calc(100% - #{$fixed-column-width});
}
}

&.el-table--scrollable-x {
.el-table__body-wrapper {
overflow-x: hidden;
Expand All @@ -699,7 +703,7 @@ $button-custom-shadow: -1px -1px 5px rgba(0, 0, 0, 0.05), 1px 1px 5px rgba(0, 0,
.el-table__empty-block {
width: 100% !important; // overrides element-ui js style property
}

.el-table__empty-text {
color: var(--s-color-base-content-tertiary); // TODO [1.4]: remove after fix in ui-lib
}
Expand All @@ -715,16 +719,16 @@ $button-custom-shadow: -1px -1px 5px rgba(0, 0, 0, 0.05), 1px 1px 5px rgba(0, 0,
width: $cell-index-width;
display: inline-block;
vertical-align: middle;

&--body {
color: var(--s-color-base-content-tertiary);
font-size: var(--s-font-size-small);
font-weight: 800;
}

&--head {
cursor: pointer;

&.active {
color: var(--s-color-theme-accent);
}
Expand All @@ -748,17 +752,17 @@ $button-custom-shadow: -1px -1px 5px rgba(0, 0, 0, 0.05), 1px 1px 5px rgba(0, 0,
line-height: var(--s-line-height-medium);
letter-spacing: var(--s-letter-spacing-mini);
margin: 0 $inner-spacing-mini;

&--head {
flex-flow: column wrap;
line-height: var(--s-line-height-small);

& > span {
margin-right: $inner-spacing-tiny;
white-space: nowrap;
}
}

&--body {
font-weight: 300;
}
Expand Down
39 changes: 16 additions & 23 deletions src/views/AddLiquidity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@

<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { components, mixins } from '@soramitsu/soraneo-wallet-web';
import { FPNumber, Operation } from '@sora-substrate/util';
import { components, mixins, WALLET_CONSTS } from '@soramitsu/soraneo-wallet-web';
import { Operation } from '@sora-substrate/util';
import { XOR } from '@sora-substrate/util/build/assets/consts';
import type { CodecString } from '@sora-substrate/util';
import type { AccountLiquidity } from '@sora-substrate/util/build/poolXyk/types';
Expand Down Expand Up @@ -197,10 +197,10 @@ export default class AddLiquidity extends Mixins(
async mounted(): Promise<void> {
await this.withParentLoading(async () => {
if (this.firstAddress && this.secondAddress) {
if (this.firstRouteAddress && this.secondRouteAddress) {
await this.setData({
firstAddress: this.firstAddress,
secondAddress: this.secondAddress,
firstAddress: this.firstRouteAddress,
secondAddress: this.secondRouteAddress,
});
// If user don't have the liquidity (navigated through the address bar) redirect to the Pool page
if (!this.liquidityInfo) {
Expand All @@ -216,39 +216,32 @@ export default class AddLiquidity extends Mixins(
this.resetData();
}
get firstAddress(): string {
return router.currentRoute.params.firstAddress;
/** First token address from route object */
get firstRouteAddress(): string {
return this.$route.params.firstAddress;
}
get secondAddress(): string {
return router.currentRoute.params.secondAddress;
/** Second token address from route object */
get secondRouteAddress(): string {
return this.$route.params.secondAddress;
}
get areTokensSelected(): boolean {
return !!(this.firstToken && this.secondToken);
}
get chooseTokenClasses(): string {
const buttonClass = 'el-button';
const classes = [buttonClass, buttonClass + '--choose-token'];
if (this.secondAddress) {
classes.push(`${buttonClass}--disabled`);
}
return classes.join(' ');
}
get removeLiquidityFormattedFee(): string {
return this.formatCodecNumber(this.networkFees[Operation.RemoveLiquidity]);
}
get isXorSufficientForNextOperation(): boolean {
const params: { type: Operation; amount?: FPNumber } = {
type: Operation.AddLiquidity,
const params: WALLET_CONSTS.NetworkFeeWarningOptions = {
type: this.isAvailable ? Operation.AddLiquidity : Operation.CreatePair,
};
if (this.firstAddress === XOR.address) {
if (this.firstToken?.address === XOR.address) {
params.amount = this.getFPNumber(this.firstTokenValue);
params.isXor = true;
}
return this.isXorSufficientForNextTx(params);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/Bridge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default class Bridge extends Mixins(
return this.isXorSufficientForNextTx({
type: this.isSoraToEvm ? Operation.EthBridgeOutgoing : Operation.EthBridgeIncoming,
isXorAccountAsset: isXorAccountAsset(this.asset),
isXor: isXorAccountAsset(this.asset),
amount: this.getFPNumber(this.amount),
});
}
Expand Down
22 changes: 14 additions & 8 deletions src/views/RemoveLiquidity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

<script lang="ts">
import { Component, Mixins, Watch } from 'vue-property-decorator';
import { components, mixins } from '@soramitsu/soraneo-wallet-web';
import { components, mixins, WALLET_CONSTS } from '@soramitsu/soraneo-wallet-web';
import { FPNumber, CodecString, Operation } from '@sora-substrate/util';
import { XOR } from '@sora-substrate/util/build/assets/consts';
import type { Asset, AccountAsset } from '@sora-substrate/util/build/assets/types';
Expand Down Expand Up @@ -218,8 +218,8 @@ export default class RemoveLiquidity extends Mixins(
async mounted(): Promise<void> {
await this.withParentLoading(async () => {
this.setAddresses({
firstAddress: this.firstTokenAddress,
secondAddress: this.secondTokenAddress,
firstAddress: this.firstRouteAddress,
secondAddress: this.secondRouteAddress,
});
// If user don't have the liquidity (navigated through the address bar) redirect to the Pool page
if (!this.liquidity) {
Expand All @@ -239,11 +239,13 @@ export default class RemoveLiquidity extends Mixins(
return this.removePart ? Number(this.removePart) : undefined;
}
get firstTokenAddress(): string {
/** First token address from route object */
get firstRouteAddress(): string {
return this.$route.params.firstAddress;
}
get secondTokenAddress(): string {
/** Second token address from route object */
get secondRouteAddress(): string {
return this.$route.params.secondAddress;
}
Expand Down Expand Up @@ -305,9 +307,13 @@ export default class RemoveLiquidity extends Mixins(
}
get isXorSufficientForNextOperation(): boolean {
return this.isXorSufficientForNextTx({
type: Operation.RemoveLiquidity,
});
const params: WALLET_CONSTS.NetworkFeeWarningOptions = { type: Operation.RemoveLiquidity };
if (this.firstToken?.address === XOR.address) {
params.amount = this.getFPNumber(this.firstTokenAmount);
params.isXor = true;
}
return this.isXorSufficientForNextTx(params);
}
get isMaxButtonAvailable(): boolean {
Expand Down
Loading

0 comments on commit e3605e5

Please sign in to comment.