Skip to content

Commit b0bab65

Browse files
committed
feat: consolidate token polling and batch RPC requests
This commit consolidates polling for native and ERC20 tokens into a single RPC request, streamlining the process and reducing the number of RPC calls. Additionally, all RPC requests across account addresses are now batched through the `multicall3` contract, enhancing performance.
1 parent 1b5a2dc commit b0bab65

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { Suite } from 'mocha';
2+
import TestDappPage from '../../page-objects/pages/test-dapp';
3+
import FixtureBuilder from '../../fixture-builder';
4+
import { WINDOW_TITLES, withFixtures } from '../../helpers';
5+
import { KNOWN_PUBLIC_KEY_ADDRESSES } from '../../../stub/keyring-bridge';
6+
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
7+
import CreateContractModal from '../../page-objects/pages/dialog/create-contract';
8+
import TransactionConfirmation from '../../page-objects/pages/confirmations/redesign/transaction-confirmation';
9+
import HomePage from '../../page-objects/pages/home/homepage';
10+
import NFTListPage from '../../page-objects/pages/home/nft-list';
11+
import SetApprovalForAllTransactionConfirmation from '../../page-objects/pages/confirmations/redesign/set-approval-for-all-transaction-confirmation';
12+
import ActivityListPage from '../../page-objects/pages/home/activity-list';
13+
14+
describe('Ledger Hardware', function (this: Suite) {
15+
it('can perform actions on an ERC-721 token', async function () {
16+
await withFixtures(
17+
{
18+
fixtures: new FixtureBuilder()
19+
.withTrezorAccount()
20+
.withPermissionControllerConnectedToTestDapp({
21+
account: KNOWN_PUBLIC_KEY_ADDRESSES[0].address,
22+
})
23+
.build(),
24+
title: this.test?.fullTitle(),
25+
dapp: true,
26+
},
27+
async ({ driver, localNodes }) => {
28+
(await localNodes?.[0]?.setAccountBalance(
29+
KNOWN_PUBLIC_KEY_ADDRESSES[0].address,
30+
'0x100000000000000000000',
31+
)) ?? console.error('localNodes is undefined or empty');
32+
await loginWithBalanceValidation(
33+
driver,
34+
undefined,
35+
undefined,
36+
'1208925.8196',
37+
);
38+
39+
// deploy action
40+
const testDappPage = new TestDappPage(driver);
41+
await testDappPage.openTestDappPage();
42+
await testDappPage.checkPageIsLoaded();
43+
await testDappPage.clickERC721DeployButton();
44+
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
45+
const createContractModal = new CreateContractModal(driver);
46+
await createContractModal.checkPageIsLoaded();
47+
await createContractModal.clickConfirm();
48+
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
49+
await testDappPage.checkERC721TokenAddressesValue(
50+
'0xcB17707e0623251182A654BEdaE16429C78A7424',
51+
);
52+
53+
// mint action
54+
await testDappPage.clickERC721MintButton();
55+
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
56+
const mintConfirmation = new TransactionConfirmation(driver);
57+
await mintConfirmation.clickFooterConfirmButton();
58+
await driver.switchToWindowWithTitle(
59+
WINDOW_TITLES.ExtensionInFullScreenView,
60+
);
61+
const homePage = new HomePage(driver);
62+
await homePage.goToNftTab();
63+
const nftListPage = new NFTListPage(driver);
64+
// Check that NFT image is displayed in NFT tab on homepagexp
65+
await nftListPage.checkNftImageIsDisplayed();
66+
await homePage.goToActivityList();
67+
const activityListPage = new ActivityListPage(driver);
68+
await activityListPage.checkTransactionActivityByText('Deposit');
69+
await activityListPage.checkWaitForTransactionStatus('confirmed');
70+
71+
// approve action
72+
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
73+
await testDappPage.clickERC721ApproveButton();
74+
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
75+
const approveConfirmation = new TransactionConfirmation(driver);
76+
await approveConfirmation.clickFooterConfirmButton();
77+
await driver.switchToWindowWithTitle(
78+
WINDOW_TITLES.ExtensionInFullScreenView,
79+
);
80+
await homePage.goToActivityList();
81+
await activityListPage.checkTransactionActivityByText(
82+
'Approve TDN spending cap',
83+
);
84+
await activityListPage.checkWaitForTransactionStatus('confirmed');
85+
86+
// set approval for all
87+
await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp);
88+
await testDappPage.clickERC721SetApprovalForAllButton();
89+
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
90+
const setApprovalForAllConfirmation =
91+
new SetApprovalForAllTransactionConfirmation(driver);
92+
await setApprovalForAllConfirmation.checkSetApprovalForAllTitle();
93+
await setApprovalForAllConfirmation.checkSetApprovalForAllSubHeading();
94+
await setApprovalForAllConfirmation.clickScrollToBottomButton();
95+
await setApprovalForAllConfirmation.clickFooterConfirmButton();
96+
await driver.switchToWindowWithTitle(
97+
WINDOW_TITLES.ExtensionInFullScreenView,
98+
);
99+
await homePage.goToActivityList();
100+
await activityListPage.checkTransactionActivityByText(
101+
'Approve TDN with no spend limit',
102+
);
103+
await activityListPage.checkWaitForTransactionStatus('confirmed');
104+
},
105+
);
106+
});
107+
});

0 commit comments

Comments
 (0)