Skip to content

Commit

Permalink
refactor: updated hotfix branch to V0.0.32 (#791)
Browse files Browse the repository at this point in the history
* Fixed claim tooltip text (#747)

* Create s3-staging.yml

* Create s3-production.yml

* Create s3-hotfix.yml

* Update s3-hotfix.yml

* Update s3-hotfix.yml

* Update s3-hotfix.yml

* Release hotfix merge to master (#746)

* add workflow for release-hotfix

* add on push specific branch

* remove automatic push process

* set inputs on workflow

* add specific branch on dispatch

* Discord link update (#745)

* Create s3-hotfix.yml

* Update s3-hotfix.yml

* Update s3-hotfix.yml

---------

Co-authored-by: Will <korea651@hanmail.net>
Co-authored-by: Ehsan <ehsan.hajian@gmail.com>

* add nft menu on sidebar (#749)

* add nft menu on sidebar

* add customized balloon

* clean up

* Fix total dApps count (#751)

* feat: updated theme color (#741)

* feat: updated theme color on Assets page

* feat: updated theme color on Dashboard page

* feat: updated theme color on dApp staking page

* feat: updated sidebar

* fix: tests

* update css

* update css

* update detail css

* feat: updated header background

* fix: updated hero position on dApp staking page

* update css on feedback

* update detail css

* updates on addItemcard

* update color on tags

* update colors

* feat: updated dark theme

* update uilib & colors

* styles: changed astar-blue-dark to astar-blue

* styles: updated Ecosystem icon

* fix: conflicts

* fix: updated styles

* fix: updated header

* fix: updated modals

* fix: updated play icon

* fix: updated styles on transfer assets page

* fix: updated ui liv

---------

Co-authored-by: Will <korea651@hanmail.net>

* Fix: Use XcmV2WeightLimit in InterlayXcmRepository.ts (#756)

* feat: updated connect wallet drawer (#750)

* feat: updated theme color on Assets page

* feat: updated theme color on Dashboard page

* feat: updated theme color on dApp staking page

* feat: updated sidebar

* fix: tests

* update css

* update css

* update detail css

* feat: updated astar-ui

* feat: updated astar-ui (2)

* feat: updated network modal

* feat: updated 'ip-input' class

* update css on feedback

* update detail css

* updates on addItemcard

* update color on tags

* feat: updated AccountModal logic

* feat: updated account drawer

* feat: updated disconnect button

* feat: updated tests

* fix: test

* fix: conflicts (2)

* fix: store selected address data

* feat: updated drawer

* feat: updated wallet logic

* refactor: clean up

* fix: changed 'disconnect' button position

* feat: store selected theme to local storage

* feat: updated modal drawer

* feat: updated modal drawer

---------

Co-authored-by: Will <korea651@hanmail.net>

* Added github action for broken links (#761)

* Added github action for broken links

* build and check

* e2e tests with  Zombienet (#752)

* Transfer tokens test

* CI integration

* Use env variable po pass BASE_URL to test script

* yaml fix

* Actions script fix

* Another action script fix

* yet another try

* hardcoded versions

* collator version fix

* Links fix

* Github action fix

* It may run now on CI

* Fixed test runner script

* Add asset to a node

* Moved Zombienet tests and configuration to separate folder.

* Stake test

* Increase Playwright test timeout

* Tests and node setup fixes

* Minor fixes

* All tests run stable

* Updated staking test with input validation test

* release hotfix to main (#760)

* add workflow for release-hotfix

* add on push specific branch

* remove automatic push process

* set inputs on workflow

* add specific branch on dispatch

* Discord link update (#745)

* Create s3-hotfix.yml

* Update s3-hotfix.yml

* Update s3-hotfix.yml

* hotfix: added Injective assets (ATOM and INJ) on EVM assets page (#759)

* feat: added ATOM and INJ on EVM assets page

* fix: fetch token data from cbridge API

---------

Co-authored-by: Will <korea651@hanmail.net>
Co-authored-by: Bobo <bobo.kovacevic@gmail.com>
Co-authored-by: Ehsan <ehsan.hajian@gmail.com>

* fix: send non-native tokens with max amount (#768)

* feat: updated XCM logic to V3 for Shiden, Statemine and Kusama (#758)

* wip: KSM xcm V3

* feat: update sdk-core

* feat: updated XCM logic for Kusama to V3

* feat: updated XCM V3 logic for Shiden

* fix: removed console.log

* fix: updated logic for statemine

* fix: updated subscan link for ctust

* feat: updated Bitfrost version to V3

* feat: updated XCM logic for Phala

* refactor: clean up

* fix: enabled XCM deposit/withdrawal on Shiden (#774)

* fix: enabled XCM deposit/withdrawal on Shiden

* test

* test: lint

* fix: clean up

* Update broken-links.yml (#777)

* removed quasar from broken link report (#767)

* dAapp staking e2e tests (#769)

* Unbond test

* Re-stake on/off test

* Claim rewards test, playwright config updates

* On chain check if claim executed

* Added Metamask extension

* Metamask wallet creation

* Trying to fix heap out of memory

* One more try

* One more try to fix CI out of memory

* On more try to fix out of memory error

* Heap size fix

* command fix

* What to say?

* Metamask removed

* Update pull-request-preview.yml

* Pushing commit to rerun ci

* setting up yarn

* Added Metamask back

* Test run on ubuntu-latest

* tsconfig exclude pattern fix

* Linter fixes

---------

Co-authored-by: Ehsan <ehsan.hajian@gmail.com>
Co-authored-by: Nikhil Ranjan <niklabh811@gmail.com>

* feat: added 'help' button on header (#772)

* fix: display EVM withdraw when users have balance in withdrawal

* fix: added help button on header

* fix: removed release note on the template.md

* fix: test

* fix: test (2)

* fix: display ModalConectionTrouble when app is loading

* fix: reset the staking tab after changing accounts (#779)

* Change warning on EVM local transfer (#783)

* update warning message

* update css & only visible on EVM input

* show prev warning

* only visible isH160

* update warning message

* fix: modified header styling for mobile devices (#782)

* fix: updated connect button

* fix: added separator at the top of assets page for mobile devices

* fix: updated header background for mobile devices

* fix: updated margin size inheader

* Automatically create PR on regular and hotfix release (#781)

* Fix for tests who are failing from time to time (#785)

* Return Dwellir endpoint to the portal (#788)

* feat: updated claim logic for ledger accounts (#765)

* feat: updated claim logic for ledger account

* refactor: clean up

* debug: log transport

* debug: log 2

* feat: test log

* feat: test log 2

* feat: test log 3

* feat: test log 4

* feat: test log 5

* feat: test log 6

* refactor: removed console logs

* refactor: clean up

* fix: remove HID popup

* fix: remove HID popup (2)

* refactor: clean up

* test: see console

* refacotr: clean up

* Deployment scripts fix (#790)

---------

Co-authored-by: Bobo <bobo.kovacevic@gmail.com>
Co-authored-by: Ehsan <ehsan.hajian@gmail.com>
Co-authored-by: Will <korea651@hanmail.net>
Co-authored-by: Brendon Votteler <bvotteler@users.noreply.github.com>
Co-authored-by: Nikhil Ranjan <niklabh811@gmail.com>
  • Loading branch information
6 people committed May 15, 2023
1 parent 6d28632 commit 0e088b5
Show file tree
Hide file tree
Showing 16 changed files with 549 additions and 93 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/s3-hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ jobs:
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy app build to S3 bucket
run: aws s3 sync ./dist/spa s3://astar-apps --delete
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: 'Merge release-hotfix to main'
body: 'This is an auto-generated PR to merge release-hotfix to main'
branch: main
base: release-hotfix
delete-branch: false
8 changes: 8 additions & 0 deletions .github/workflows/s3-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ jobs:
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy app build to S3 bucket
run: aws s3 sync ./dist/spa s3://astar-apps --delete
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: 'Merge main to release-hotfix'
body: 'This is an auto-generated PR to merge main to release-hotfix'
branch: release-hotfix
base: main
delete-branch: false
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ yarn-error.log*

# Firebase cache
.firebase/
/test-results/
/playwright-report/
/playwright/.cache/
/test-results/
/playwright-report/
/playwright/.cache/

# End-to-end tests
test-results/
playwright-report/
playwright/.cache/


# Zombienet binaries
zombienet-macos
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@polkadot/api": "^9.13.6",
"@polkadot/api-contract": "^9.13.6",
"@polkadot/extension-dapp": "0.44.8",
"@polkadot/hw-ledger": "^12.1.2",
"@polkadot/keyring": "^10.3.1",
"@polkadot/networks": "^10.3.1",
"@polkadot/rpc-provider": "^9.13.6",
Expand Down
62 changes: 0 additions & 62 deletions playwright-report/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 1 : 0,
/*
Limit workers to 1 because tests depends on a single Zombienet instance.
It shouldn't be like that but spawning Zombienet for every test is time consuming.
Expand Down
23 changes: 20 additions & 3 deletions src/components/dapp-staking/my-staking/MyRewards.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,26 @@
{{ $n(pendingRewards) }} {{ nativeTokenSymbol }}
</span>
</div>
<span class="text--eras">
({{ amountOfEras }} {{ $t('myReward.era') }}{{ amountOfEras > 1 ? 's' : '' }})
</span>
<div class="row--eras">
<span class="text--eras">
({{ amountOfEras }} {{ $t('myReward.era') }}{{ amountOfEras > 1 ? 's' : '' }})
</span>
<span class="wrapper--icon-help">
<astar-icon-help size="16" />
<q-tooltip max-width="200px" class="box--tooltip">
<div>
<span class="text--tooltip">{{ $t('myReward.claimable.limitation') }}</span>
</div>
<br />
<div class="row--ledgers">
<span class="text--tooltip">{{ $t('myReward.claimable.nativeWallets') }}</span>
<span class="text--tooltip">{{ $t('myReward.claimable.ledgerX') }}</span>
<span class="text--tooltip">{{ $t('myReward.claimable.ledgerSPlus') }}</span>
<span class="text--tooltip">{{ $t('myReward.claimable.ledgerS') }}</span>
</div>
</q-tooltip>
</span>
</div>
</div>
<astar-button
:width="80"
Expand Down
11 changes: 11 additions & 0 deletions src/components/dapp-staking/my-staking/styles/my-rewards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
font-size: 18px;
}

.row--eras {
display: flex;
align-items: center;
column-gap: 8px;
}

.body--dark {
.card {
background: $body-bg-dark;
Expand Down Expand Up @@ -129,6 +135,11 @@
padding: 8px 16px;
}

.row--ledgers {
display: flex;
flex-direction: column;
}

.body--dark {
.claim-warning {
color: $gray-1;
Expand Down
6 changes: 3 additions & 3 deletions src/config/chainEndpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const providerEndpoints: ChainProvider[] = [
info: 'Smart contract platform for decentralized applications (dapps) on the Polkadot network',
endpoints: [
{ name: 'Astar', endpoint: 'wss://rpc.astar.network' },
// { name: 'Dwellir', endpoint: 'wss://astar-rpc.dwellir.com' },
{ name: 'Dwellir', endpoint: 'wss://astar-rpc.dwellir.com' },
{ name: 'Blast', endpoint: 'wss://astar.public.blastapi.io' },
{ name: 'OnFinality', endpoint: 'wss://astar.api.onfinality.io/public-ws' },
{ name: 'RadiumBlock', endpoint: 'wss://astar.public.curie.radiumblock.co/ws' },
Expand Down Expand Up @@ -67,7 +67,7 @@ export const providerEndpoints: ChainProvider[] = [
info: 'Smart contract platform for decentralized applications (dapps) on the Kusama network',
endpoints: [
{ name: 'Shiden', endpoint: 'wss://rpc.shiden.astar.network' },
// { name: 'Dwellir', endpoint: 'wss://shiden-rpc.dwellir.com' },
{ name: 'Dwellir', endpoint: 'wss://shiden-rpc.dwellir.com' },
{ name: 'Blast', endpoint: 'wss://shiden.public.blastapi.io' },
{ name: 'OnFinality', endpoint: 'wss://shiden.api.onfinality.io/public-ws' },
{ name: 'Light Client (experimental)', endpoint: 'light://substrate-connect/kusama/shiden' },
Expand Down Expand Up @@ -95,7 +95,7 @@ export const providerEndpoints: ChainProvider[] = [
info: 'The test network of the layer 2 scaling blockchain',
endpoints: [
{ name: 'Shibuya', endpoint: 'wss://rpc.shibuya.astar.network' },
// { name: 'Dwellir', endpoint: 'wss://shibuya-rpc.dwellir.com' },
{ name: 'Dwellir', endpoint: 'wss://shibuya-rpc.dwellir.com' },
{ name: 'Blast', endpoint: 'wss://shibuya.public.blastapi.io/' },
{ name: 'Light Client (experimental)', endpoint: 'light://substrate-connect/tokyo/shibuya' },
],
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export * from './dapps-staking/useDappRedirect';
export * from './dapps-staking/useDispatchGetDapps';
export * from './wallet/useWalletIcon';
export * from './wallet/useEvmWallet';
export * from './wallet/useLedger';
export * from './xcm/useXcmBridge';
export * from './transfer/useTokenTransfer';
export * from './xcm/useTransferRouter';
Expand Down
24 changes: 19 additions & 5 deletions src/hooks/useClaimAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import { $api } from 'boot/api';
import { useCurrentEra, useBalance } from 'src/hooks';
import { displayCustomMessage, TxType } from 'src/hooks/custom-signature/message';
import { useStore } from 'src/store';
import { useLedger } from 'src/hooks';
import { container } from 'src/v2/common';
import { DappCombinedInfo } from 'src/v2/models/DappsStaking';
import { IDappStakingService } from 'src/v2/services';
import { Symbols } from 'src/v2/symbols';
import { ethers } from 'ethers';
import { computed, ref, watchEffect } from 'vue';
import { computed, ref, watchEffect, watch } from 'vue';
import { useI18n } from 'vue-i18n';

const MAX_BATCH_WEIGHT = new BN('50000000000');
const MAX_BATCH_WEIGHT = new BN('50000000000'); // Memo: ≒56 eras
const MAX_BATCH_WEIGHT_LEDGER = new BN('6000000000'); //Memo: 6 eras
const MAX_BATCH_WEIGHT_LEDGER_S = new BN('2000000000'); //Memo:2 eras

export function useClaimAll() {
let batchTxs: PayloadWithWeight[] = [];
Expand All @@ -33,6 +36,15 @@ export function useClaimAll() {
const { t } = useI18n();
const { era } = useCurrentEra();
const { accountData } = useBalance(senderAddress);
const { isLedgerAccount, isLedgerNanoS } = useLedger();

const maxBatchWeight = computed<BN>(() => {
if (isLedgerAccount.value) {
return isLedgerNanoS.value ? MAX_BATCH_WEIGHT_LEDGER_S : MAX_BATCH_WEIGHT_LEDGER;
} else {
return MAX_BATCH_WEIGHT;
}
});

const transferableBalance = computed(() => {
const balance = accountData.value
Expand All @@ -41,7 +53,7 @@ export function useClaimAll() {
return Number(balance);
});

watchEffect(async () => {
const updateClaimEras = async (): Promise<void> => {
try {
isLoading.value = true;
const api = $api;
Expand Down Expand Up @@ -82,7 +94,9 @@ export function useClaimAll() {
} finally {
isLoading.value = false;
}
});
};

watch([isSendingTx, senderAddress], updateClaimEras);

const claimAll = async (): Promise<void> => {
const api = $api;
Expand All @@ -100,7 +114,7 @@ export function useClaimAll() {
for (let i = 0; i < batchTxsRef.length; i++) {
const tx = batchTxsRef[i];
const weight = tx.isWeightV2 ? tx.asWeightV2().refTime.toBn() : tx.asWeightV1();
if (totalWeight.add(weight).gt(MAX_BATCH_WEIGHT)) {
if (totalWeight.add(weight).gt(maxBatchWeight.value)) {
break;
}

Expand Down
97 changes: 97 additions & 0 deletions src/hooks/wallet/useLedger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { Ledger } from '@polkadot/hw-ledger';
import { useAccount } from 'src/hooks/useAccount';
import { useStore } from 'src/store';
import { computed, ref, watch } from 'vue';

enum LedgerId {
nanoS = 'nanoS',
nanoSPlus = 'nanoSP',
nanoX = 'nanoX',
}

export const useLedger = () => {
const isLedgerAccount = ref<boolean>(false);
const isLedgerNanoS = ref<boolean>(false);
const ledger = ref<Ledger>();
const ledgerAccount = ref<string>('');
const { currentAccount } = useAccount();

const store = useStore();
const isH160 = computed<boolean>(() => store.getters['general/isH160Formatted']);

const handleReset = (): void => {
isLedgerAccount.value = false;
isLedgerNanoS.value = false;
ledger.value = undefined;
ledgerAccount.value = '';
};

const handleLedgerData = async (): Promise<void> => {
// Memo: make sure `transport` has been closed before creating ledger transport
if (ledger.value && ledgerAccount.value) {
const transport = (ledger.value as any).__internal__app.transport;
transport.close();
}

if (!currentAccount.value || isH160.value) {
handleReset();
return;
}
try {
if (!('hid' in window.navigator)) {
console.error('WebHID API is not supported in this browser.');
handleReset();
return;
}

const hidDevices = (await (window.navigator as any).hid.getDevices()) as any;
if (process.env.DEV) {
console.info('hidDevices', hidDevices);
}

if (hidDevices.length === 0) {
handleReset();
return;
}

hidDevices.some(async (device: any) => {
try {
if (device?.productName?.toLowerCase().includes('nano')) {
const ledgerData = new Ledger('hid', 'astar');
const { address } = await ledgerData.getAddress();
if (process.env.DEV) {
console.info('ledgerData', ledgerData);
}

if (address) {
ledger.value = ledgerData;
const deviceModel = (ledgerData as any).__internal__app.transport.deviceModel;
ledgerAccount.value = address;
isLedgerAccount.value = address === currentAccount.value;
isLedgerNanoS.value = deviceModel.id === LedgerId.nanoS;
} else {
handleReset();
}
}
} catch (error: any) {
const idLedgerLocked = '0x5515';
if (error.message.includes(idLedgerLocked)) {
store.dispatch('general/showAlertMsg', {
msg: error.message,
alertType: 'error',
});
handleReset();
}
} finally {
return;
}
});
} catch (error) {
handleReset();
}
};

watch([currentAccount], handleLedgerData, { immediate: true });

return { isLedgerAccount, isLedgerNanoS };
};
8 changes: 8 additions & 0 deletions src/i18n/en-US/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ export default {
'The number of eras that is shown here is per dApp. You may need to claim multiple times if you have too many unclaimed eras.',
restakeTip:
'By turning on, your rewards will be automatically re-staked when you make a claim.',
claimable: {
limitation:
'There is a limitation on the number of eras that can be claimed in one transaction.',
nativeWallets: 'Native wallets: ≒56 eras',
ledgerX: 'Ledger Nano X: 6 eras',
ledgerSPlus: 'Ledger Nano S Plus: 6 eras',
ledgerS: 'Ledger Nano S: 2 eras',
},
},
dappStaking: {
myStaking: 'My Staking',
Expand Down
8 changes: 8 additions & 0 deletions tests/common-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { sendTransaction } from './zombienet/tx-utils';
import { KeyringPair } from '@polkadot/keyring/types';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import { EraStakingPointsIndividualClaim } from 'src/store/dapp-staking/calculation';
import { RewardDestination } from 'src/v2/models';

export const NODE_ENDPOINT = process.env.ENDPOINT || 'ws://127.0.0.1:57083';
export let chainDecimals = 18;
Expand Down Expand Up @@ -90,3 +91,10 @@ export const forceUnbondingPeriod = async (): Promise<void> => {
await sendTransaction(api.tx.sudo.sudo(api.tx.dappsStaking.forceNewEra()), signer);
}
};

export const setRewardDestination = async (rewardDestination: RewardDestination): Promise<void> => {
const api = await getApi();
const signer = await getSigner();
const tx = api.tx.dappsStaking.setRewardDestination(rewardDestination);
await sendTransaction(tx, signer);
};
10 changes: 5 additions & 5 deletions tests/dappstaking-transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import {
forceNewEra,
getAccountLedger,
getBalance,
getContractEraStake,
getCurrentEra,
getStakedAmount,
setRewardDestination,
} from './common-api';

const TEST_DAPP_ADDRESS = '0x0000000000000000000000000000000000000001';
Expand Down Expand Up @@ -124,7 +123,7 @@ test.describe('dApp staking transactions', () => {
await forceNewEra();

await page.goto('/custom-node/dapp-staking/discover');
page.getByRole('button', { name: 'Claim' }).click();
await page.getByRole('button', { name: 'Claim' }).click();
await signTransaction(context);
await expect(page.getByText('Success', { exact: true }).first()).toBeVisible();

Expand All @@ -139,20 +138,21 @@ test.describe('dApp staking transactions', () => {
await stake(page, context, BigInt(1000));

// Check initial state
await setRewardDestination('StakeBalance');
await expect(page.getByText('ON', { exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'Turn off' })).toBeVisible();
let ledger = await getAccountLedger(ALICE_ADDRESS);
expect(ledger.rewardDestination.toString()).toEqual('StakeBalance');

page.getByRole('button', { name: 'Turn off' }).click();
await page.getByRole('button', { name: 'Turn off' }).click();
await signTransaction(context);
await page.waitForSelector('.four', { state: 'hidden' });
await expect(page.getByText('OFF', { exact: true })).toBeVisible();
await expect(page.getByRole('button', { name: 'Turn on' })).toBeVisible();
ledger = await getAccountLedger(ALICE_ADDRESS);
expect(ledger.rewardDestination.toString()).toEqual('FreeBalance');

page.getByRole('button', { name: 'Turn on' }).click();
await page.getByRole('button', { name: 'Turn on' }).click();
await signTransaction(context);
await page.waitForSelector('.four', { state: 'hidden' });
await expect(page.getByText('ON', { exact: true })).toBeVisible();
Expand Down
Loading

0 comments on commit 0e088b5

Please sign in to comment.