Skip to content

Commit e874c8a

Browse files
impelcryptobobo-k2
andauthored
hotfix: merge the hotfix branch to main (#1453)
* feat: added ETH rebate banner (#1445) * feat: added rebate banner * fix: remove banner * feat: updated banner * ACS link (#1447) * ACS link * Tooltip fix * Fix for breaking change in runtime (#1449) * Move stake implementtion (#1446) * Logic implemented * Loosing bonus warning * EVM move and improved messages * Min stake check fix * Amount component bug fix * Remaining tokens bug fix * Styling updates * Min amount check fix * Min stake move warning * Enable staking tokens locked in democracy (#1451) * Locked in democracy to useBalance * Treat tokens locked in democracy as available for staking * fix: updated RPC (#1452) * Temporary disable unstake from unregistered call (#1454) --------- Co-authored-by: Bobo <[email protected]>
1 parent a13e1f5 commit e874c8a

25 files changed

+407
-84
lines changed
111 KB
Loading

src/components/assets/NativeAssetList.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ export default defineComponent({
341341
const store = useStore();
342342
const isLoading = computed<boolean>(() => store.getters['general/isLoading']);
343343
const selectedAddress = computed(() => store.getters['general/selectedAddress']);
344-
const { balance, accountData, isLoadingBalance } = useBalance(selectedAddress);
344+
const { balance, accountData, isLoadingBalance, lockedInDemocracy } =
345+
useBalance(selectedAddress);
345346
const { numEvmDeposit } = useEvmDeposit();
346347
const { currentNetworkName, nativeTokenSymbol, isSupportAuTransfer } = useNetworkInfo();
347348
const { faucetBalRequirement } = useFaucet();
@@ -404,7 +405,6 @@ export default defineComponent({
404405
// Memo: `vesting ` -> there has been inputted 1 space here
405406
const vesting = accountDataRef.locks.find((it) => u8aToString(it.id) === 'vesting ');
406407
const dappStake = accountDataRef.locks.find((it) => u8aToString(it.id) === 'dapstake');
407-
const democracy = accountDataRef.locks.find((it) => u8aToString(it.id) === 'democrac');
408408
const reserved = accountDataRef.reserved;
409409
410410
if (vesting) {
@@ -424,8 +424,10 @@ export default defineComponent({
424424
reservedTtl.value = Number(ethers.utils.formatEther(amount));
425425
}
426426
427-
if (democracy) {
428-
lockInDemocracy.value = Number(ethers.utils.formatEther(democracy.amount.toString()));
427+
if (lockedInDemocracy.value) {
428+
lockInDemocracy.value = Number(
429+
ethers.utils.formatEther(lockedInDemocracy.value.toString())
430+
);
429431
}
430432
});
431433

src/components/bridge/ccip/Ccip.vue

+19-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@
2626
:load-is-approved="loadIsApproved"
2727
@update:isApproveMaxAmount="(value: boolean) => (isApproveMaxAmount = value)"
2828
/>
29-
<information
30-
v-if="rightUi === 'information'"
31-
:transfer-type="HistoryTxType.CCIP_BRIDGE"
32-
:is-history="false"
33-
/>
29+
<div v-if="rightUi === 'information'">
30+
<information :transfer-type="HistoryTxType.CCIP_BRIDGE" :is-history="false" />
31+
<div v-if="isGasRebate" class="row--banner">
32+
<img
33+
class="banner--eth-rebates"
34+
src="~assets/img/banner/banner-eth-rebate.png"
35+
alt="eth-rebate"
36+
/>
37+
</div>
38+
</div>
3439
<select-chain
3540
v-if="rightUi === 'select-chain'"
3641
v-click-away="cancelHighlight"
@@ -59,7 +64,7 @@ import { computed, defineComponent, ref } from 'vue';
5964
import { useCcipBridge } from '../../../hooks/bridge/useCcipBridge';
6065
import { wait } from '@astar-network/astar-sdk-core';
6166
import { reverseObject } from 'src/modules/common';
62-
import { CcipNetworkName, ccipNetworkParam, CcipNetworkParam } from 'src/modules/ccip-bridge';
67+
import { CcipNetworkName, ccipNetworkParam } from 'src/modules/ccip-bridge';
6368
6469
type RightUi = 'information' | 'select-chain';
6570
@@ -106,6 +111,13 @@ export default defineComponent({
106111
const { currentAccount } = useAccount();
107112
const { screenSize, width } = useBreakpoints();
108113
114+
const isGasRebate = computed<boolean>(() => {
115+
return (
116+
toChainName.value === CcipNetworkName.Soneium &&
117+
fromChainName.value === CcipNetworkName.AstarEvm
118+
);
119+
});
120+
109121
const handleSetChain = async (chain: CcipNetworkName): Promise<void> => {
110122
let query = { from: '', to: '' };
111123
const selectedChain = reverseObject(ccipNetworkParam)[chain];
@@ -189,6 +201,7 @@ export default defineComponent({
189201
isHighlightRightUi,
190202
isModalSelectChain,
191203
loadIsApproved,
204+
isGasRebate,
192205
setRightUi,
193206
getSelectableChains,
194207
cancelHighlight,

src/components/bridge/ccip/CcipBridge.vue

+4
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@
132132
})
133133
}}
134134
</li>
135+
<li v-if="toChainName === CcipNetworkName.Soneium">
136+
{{ $t('bridge.rebate') }}
137+
</li>
135138
<li>
136139
{{ $t('bridge.warningCcipTime', { time: bridgeTime }) }}
137140
</li>
@@ -368,6 +371,7 @@ export default defineComponent({
368371
isApproveButtonDisabled,
369372
isBridgeButtonDisabled,
370373
isH160,
374+
CcipNetworkName,
371375
truncate,
372376
bridge,
373377
approve,

src/components/bridge/ccip/styles/ccip.scss

+18
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@
3434
}
3535
}
3636

37+
.row--banner {
38+
margin-top: 16px;
39+
}
40+
41+
.banner--eth-rebates {
42+
width: 348px;
43+
border-radius: 6px;
44+
@media (min-width: $sm) {
45+
width: 412px;
46+
}
47+
@media (min-width: $md) {
48+
width: 320px;
49+
}
50+
@media (min-width: $xl) {
51+
width: 420px;
52+
}
53+
}
54+
3755
.half-opacity {
3856
opacity: 0.4;
3957
transition: all 0.3s ease 0s;

src/components/header/mobile/MobileNav.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}}</a>
5757
</nav>
5858
<a class="surge-mobile" :href="surgeUrl" target="_blank">
59-
<img :src="require('src/assets/img/surge_token.webp')" alt="Surge" />
59+
<img :src="require('src/assets/img/surge_token.webp')" alt="Go to ACS" />
6060
</a>
6161

6262
<div class="gradient-bg">

src/components/sidenav/SidebarDesktop.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
</div>
9191
<div>
9292
<a class="surge" :href="surgeUrl" target="_blank">
93-
<img :src="require('src/assets/img/surge_token.webp')" alt="Surge" />
93+
<img :src="require('src/assets/img/surge_token.webp')" alt="Go to ACS" />
9494
</a>
9595
<q-tooltip>
9696
<span class="text--tooltip">{{ $t('joinSurge') }}</span>

src/hooks/useBalance.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ETHEREUM_EXTENSION } from 'src/modules/account';
22
import { VoidFn } from '@polkadot/api/types';
33
import { BalanceLockTo212 } from '@polkadot/types/interfaces';
44
import { PalletBalancesBalanceLock, PalletVestingVestingInfo } from 'src/v2/models';
5-
import { BN } from '@polkadot/util';
5+
import { BN, u8aToString } from '@polkadot/util';
66
import { $api, $web3 } from 'boot/api';
77
import { SystemAccount } from 'src/modules/account';
88
import { useStore } from 'src/store';
@@ -167,6 +167,12 @@ export function useBalance(addressRef: Ref<string>) {
167167
const useableBalance = computed(() => {
168168
return accountData.value?.getUsableFeeBalance().toString() || '0';
169169
});
170+
const lockedInDemocracy = computed(() => {
171+
const lock = accountData.value?.locks.find((it) => u8aToString(it.id) === 'democrac');
172+
173+
return lock ? lock.amount.toBigInt() : BigInt(0);
174+
});
175+
170176
const isLoadingBalance = ref<boolean>(true);
171177

172178
const { balanceRef, accountDataRef, isLoadingAccount } = useCall(addressRef);
@@ -196,7 +202,7 @@ export function useBalance(addressRef: Ref<string>) {
196202
{ immediate: true }
197203
);
198204

199-
return { balance, accountData, useableBalance, isLoadingBalance };
205+
return { balance, accountData, useableBalance, isLoadingBalance, lockedInDemocracy };
200206
}
201207

202208
export class AccountData {

src/i18n/en-US/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default {
4444
help: 'Help',
4545
share: 'Share',
4646
multisig: 'Multisig',
47-
joinSurge: 'Join Astar Surge',
47+
joinSurge: 'Go to ACS',
4848
sort: {
4949
sortBy: 'Sort by',
5050
amountHightToLow: 'Amount: High to Low',
@@ -941,6 +941,10 @@ export default {
941941
unregisteredDappInfo:
942942
'This project has been unregistered but If you are currently entitled to Bonus you will be entitled to it as well as basic rewards as long as you do not move/unstake the fund during this Period. Unstake if you still want to (it has {days} days unlocking period).',
943943
voteSuccess: 'You successfully voted on {number} dApp(s). All pending rewards are claimed.',
944+
moveSuccess: 'You successfully moved your stake to {number} dApp(s).',
945+
looseBonusWarning:
946+
'You will partially loose your bonus rewards if you move your stake to more than {number} dApp(s).',
947+
looseAllBonusWarning: 'You will loose your bonus rewards if you move your stake.',
944948
unbondSuccess: 'You successfully unbonded from {dapp}.',
945949
unbondFromUnregisteredSuccess: 'You successfully unbonded from unregistered dApp {dapp}.',
946950
claimRewardSuccess: 'You successfully claimed your rewards.',
@@ -959,6 +963,8 @@ export default {
959963
registerNow: 'Register now',
960964
willUnstakeAll:
961965
'The operation will unstake all of your staked tokens because the minimum staking amount is {amount} tokens.',
966+
willMoveAll:
967+
'The operation will move all of your staked tokens because the minimum staking amount is {amount} tokens.',
962968
onboarding: {
963969
introducing: 'Introducing',
964970
innovativeWayOfStaking: 'Innovative way of staking',
@@ -1011,10 +1017,14 @@ export default {
10111017
addAmounts: 'Please add the amount to each card.',
10121018
review: 'Check everything is ok before confirming.',
10131019
availableAfterStaking: 'Available amount after staking',
1020+
remainingAmountAfterMoving: 'Remaining amount on origin dApp after moving',
10141021
beSureToVote:
10151022
'Be sure you vote on dapps otherwise those tokens are not eligible for any rewards.',
10161023
yourAvailableBalance: 'Your available balance',
1024+
availableToMove: 'Available to move',
10171025
moveFunds: 'Move funds',
1026+
safeMoveInfo:
1027+
'You can move your stake to up to {number} dApp(s) without loosing your bonus rewards.',
10181028
},
10191029
registration: {
10201030
success: 'You successfully registered dApp {name} to the store.',
@@ -1137,6 +1147,7 @@ export default {
11371147
slippage: 'Slippage: {percent}%',
11381148
feeOnTransaction: 'Transaction fee: {amount} {symbol}',
11391149
feeOnBridge: 'Bridge fee: {amount} {symbol}',
1150+
rebate: 'You will receive 0.00008 ETH for gas on Soneium',
11401151
gelatoApiError: 'Bridge UI is not available, please try again later',
11411152
warningHighTraffic:
11421153
'High bridge traffic may delay withdrawal transactions up to 5 hours. We appreciate your patience.',

src/links/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const polkadotJsUrl = {
5353
},
5454
};
5555

56-
export const surgeUrl = 'https://surge.sakefinance.com/';
56+
export const surgeUrl = 'https://acs.astar.network/';
5757

5858
export const ccipExplorerUrl = 'https://ccip.chain.link';
5959

src/staking-v3/components/my-staking/MyDapps.vue

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
{{ $t('stakingV3.unregisteredDappInfo', { days: constants?.unlockingPeriod ?? '--' }) }}
3838
</span>
3939
<astar-button
40+
:disabled="true"
4041
class="btn--unregistered-dapp"
4142
@click="unstakeFromUnregistered(key, getDappName(key))"
4243
>

src/staking-v3/components/vote/VotingNote.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export default defineComponent({
8888
}
8989
9090
.note-container {
91-
background-color: $white;
9291
padding: 16px;
9392
border-radius: 16px;
93+
border: 1px solid $navy-1;
9494
}
9595
9696
.note--title {

src/staking-v3/components/vote/VotingWizard.vue

+48-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
{{ title }}
66
</div>
77
<div class="balance-container">
8-
{{ $t('stakingV3.voting.yourAvailableBalance') }}
8+
{{
9+
isBonusEntitledMove
10+
? $t('stakingV3.voting.availableToMove')
11+
: $t('stakingV3.voting.yourAvailableBalance')
12+
}}
913
<token-balance-native :balance="availableToVoteDisplay.toString()" />
1014
</div>
1115
</div>
@@ -27,8 +31,16 @@
2731
/>
2832
</div>
2933
</div>
34+
<div v-if="isBonusEntitledMove">
35+
{{
36+
allowedNumberOfMoves == 0
37+
? $t('stakingV3.looseAllBonusWarning')
38+
: $t('stakingV3.voting.safeMoveInfo', { number: allowedNumberOfMoves })
39+
}}
40+
</div>
3041
</div>
3142
<wizard-steps
43+
v-if="!isMove"
3244
:steps="wizardSteps"
3345
:selected-step-index="selectedStepIndex"
3446
:completed-steps="completedSteps"
@@ -39,7 +51,10 @@
3951
<choose-dapps-panel
4052
v-if="selectedStepIndex === Steps.ChooseDapps"
4153
:on-dapps-selected="handleDappsSelected"
54+
:on-dapps-selection-changed="handleDappsSelectionChanged"
4255
:scroll-to-top="scrollToWizardTop"
56+
:move-from-address="moveFromAddress"
57+
:error-message="looseBonusWarningMessage"
4358
/>
4459
<choose-amounts-panel
4560
v-if="selectedStepIndex === Steps.AddAmount"
@@ -50,6 +65,7 @@
5065
:on-amounts-entered="handleAmountsEntered"
5166
:on-remove-dapp="handleRemoveDapp"
5267
:on-go-back="handleGoBackToDapps"
68+
:is-move="isMove"
5369
/>
5470
<review-panel
5571
v-if="selectedStepIndex === Steps.Review"
@@ -128,6 +144,7 @@ export default defineComponent({
128144
const stakesEntered = ref<boolean>(false);
129145
const isConfirmed = ref<boolean>(false);
130146
const showRestakeModal = ref<boolean>(false);
147+
const isLoosingBonus = ref<boolean>(false);
131148
const wizard = ref();
132149
const {
133150
totalStakeAmount,
@@ -139,7 +156,13 @@ export default defineComponent({
139156
availableToMoveFrom,
140157
canVote,
141158
vote,
159+
isBonusEntitledMove,
160+
isMove,
161+
stakeToMove,
162+
isPartiallyLosingBonus,
163+
allowedNumberOfMoves,
142164
} = useVote(selectedDapps, props.moveFromAddress);
165+
143166
const completedSteps = computed<Map<number, boolean>>(
144167
() =>
145168
new Map([
@@ -149,6 +172,18 @@ export default defineComponent({
149172
])
150173
);
151174
175+
const looseBonusWarningMessage = computed<string>(() =>{
176+
if (isLoosingBonus.value && allowedNumberOfMoves.value > 0) {
177+
return t('stakingV3.looseBonusWarning', { number: allowedNumberOfMoves.value });
178+
}
179+
180+
if (isLoosingBonus.value && allowedNumberOfMoves.value == 0) {
181+
return t('stakingV3.looseAllBonusWarning');
182+
}
183+
184+
return '';
185+
});
186+
152187
const { totalStakerRewards, stakerInfo } = useDappStaking();
153188
154189
const stakeInfo = computed<StakeInfo>(() => ({
@@ -197,6 +232,10 @@ export default defineComponent({
197232
scrollToWizardTop();
198233
};
199234
235+
const handleDappsSelectionChanged = (_: DappVote[], after: DappVote[]): void => {
236+
isLoosingBonus.value = isBonusEntitledMove.value && isPartiallyLosingBonus(after.length);
237+
};
238+
200239
const handleAmountsEntered = (): void => {
201240
selectedComponentIndex.value = Steps.Review;
202241
stakesEntered.value = true;
@@ -211,7 +250,7 @@ export default defineComponent({
211250
};
212251
213252
const handleConfirmAndRestake = async (): Promise<void> => {
214-
if (totalStakerRewards.value > BigInt(0) && stakerInfo.value.size > 0) {
253+
if (totalStakerRewards.value > BigInt(0) && stakerInfo.value.size > 0 && !isMove.value) {
215254
setShowRestakeModal(true);
216255
} else {
217256
await handleConfirm(false);
@@ -281,6 +320,10 @@ export default defineComponent({
281320
showRestakeModal,
282321
totalStakerRewards,
283322
canVote,
323+
isBonusEntitledMove,
324+
isMove,
325+
isLoosingBonus,
326+
stakeToMove,
284327
vote,
285328
handleStepSelected: handleSelectComponent,
286329
handleDappsSelected,
@@ -293,6 +336,9 @@ export default defineComponent({
293336
scrollToWizardTop,
294337
setShowRestakeModal,
295338
handleRestakeConfirm,
339+
handleDappsSelectionChanged,
340+
allowedNumberOfMoves,
341+
looseBonusWarningMessage,
296342
};
297343
},
298344
});

0 commit comments

Comments
 (0)