Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wallet calculate gas performance #1794

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f62957e
feat: speed up account balance fetch
arthurgeron Jan 22, 2025
bd56c08
feat: use accounts machine instead of fetching accounts each time
arthurgeron Jan 22, 2025
3a9b1b4
chore: changeset
arthurgeron Jan 23, 2025
818e457
improve: merge calculation of default tip and gas limit
arthurgeron Jan 24, 2025
b9693d5
fix: remove await inside promise.all
arthurgeron Jan 24, 2025
3992076
fix: exception on undefined provider (edge case)
arthurgeron Jan 24, 2025
bc69766
feat: decrease unnecessarily long delay in tx and send machines
arthurgeron Jan 24, 2025
010adaf
chore: changeset
arthurgeron Jan 24, 2025
a32ac8f
fix: e2e tests
arthurgeron Jan 24, 2025
4eb532c
feat: improve tests by remove unecessary timeouts
arthurgeron Jan 24, 2025
1f69419
fix: send machine not being able to read the account variable
arthurgeron Jan 24, 2025
7a6ca5d
chore: revert to withConfig
arthurgeron Jan 24, 2025
913f039
chore: remove pause
arthurgeron Jan 24, 2025
dcfcd2b
chore
arthurgeron Jan 24, 2025
75fe623
fix: not getting an updated reference for acc
arthurgeron Jan 24, 2025
af2c5a9
chore
arthurgeron Jan 24, 2025
cd02b0d
feat: use already available fee data when possible
arthurgeron Jan 24, 2025
51acf68
chore
arthurgeron Jan 27, 2025
6803aca
revert: changeinput timeout
arthurgeron Jan 27, 2025
276aafb
chore
arthurgeron Jan 27, 2025
dce1c54
chore
arthurgeron Jan 27, 2025
d1e1a79
revert: useprovider changes
arthurgeron Jan 27, 2025
b4e4991
chore: fetch account data when not available
arthurgeron Jan 27, 2025
ce2710f
fix: changesets
arthurgeron Jan 27, 2025
3cc18f7
ix: not saving account data in machine context
arthurgeron Jan 27, 2025
29c40b4
fix: getting old max ammount data
arthurgeron Jan 27, 2025
40ac670
fix: strict audit
arthurgeron Jan 27, 2025
65085a8
chore: e2e
arthurgeron Jan 27, 2025
e2f1d2c
fix: ignore vite vulnerability
arthurgeron Jan 28, 2025
35988d5
Merge branch 'master' into ag/feat/fe-808
arthurgeron Jan 30, 2025
f2b0158
fix: outdated artifact action
arthurgeron Feb 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/lemon-maps-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuels/playwright-utils": minor
"fuels-wallet": minor
---

feat: performance improvement from rework on send transaction machine flows
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests-e2e-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

- name: Upload Test Report
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: e2e-test-report
path: packages/e2e-assets/playwright-html
2 changes: 1 addition & 1 deletion examples/cra-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@types/react-dom": "18.3.0",
"@vitejs/plugin-react": "4.2.1",
"typescript": "5.2.2",
"vite": "6.0.3"
"vite": "6.0.8"
}
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
"allowAny": ["react", "react-dom"],
"ignoreMissing": ["react", "react-dom"]
},
"auditConfig": {
"ignoreGhsas": ["GHSA-vg6x-rcgg-rjx6"]
},
"overrides": {
"follow-redirects": ">=1.15.6",
"glob-parent@<5.1.2": ">=5.1.2",
Expand Down Expand Up @@ -128,7 +131,8 @@
"secp256k1@=5.0.0": ">=5.0.1",
"elliptic@<6.6.0": ">=6.6.0",
"cross-spawn@<7.0.5": ">=7.0.5",
"nanoid@<3.3.8": "3.3.8"
"nanoid@<3.3.8": "3.3.8",
"store2@<2.14.4": ">=2.14.4"
}
}
}
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"ts-jest-mock-import-meta": "1.1.0",
"tsconfig-paths-webpack-plugin": "4.1.0",
"typescript": "5.2.2",
"vite": "6.0.3",
"vite": "6.0.8",
"vite-plugin-clean": "1.0.0",
"vite-plugin-static-copy": "2.2.0",
"vite-tsconfig-paths": "5.1.4",
Expand Down
11 changes: 8 additions & 3 deletions packages/app/playwright/crx/assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ test.describe('Check assets', () => {
});

test('should show valid asset value 0.002000', async () => {
expect(
await page.getByText('0.002000', { exact: true }).isVisible()
).toBeTruthy();
await expect
.poll(
async () => {
return await page.getByText('0.002000', { exact: true }).isVisible();
},
{ timeout: 10000 }
)
.toBeTruthy();
});

test('should show USDCIcon AlertTriangle', async () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/app/playwright/crx/crx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ test.describe('FuelWallet Extension', () => {
extensionId,
}) => {
const popupPage = await context.newPage();
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
const page = await context.waitForEvent('page', {
const pagePromise = context.waitForEvent('page', {
predicate: (page) => page.url().includes('sign-up'),
});
await popupPage.goto(`chrome-extension://${extensionId}/popup.html`);
const page = await pagePromise;
expect(page.url()).toContain('sign-up');
});

Expand Down
60 changes: 33 additions & 27 deletions packages/app/playwright/e2e/SendTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ test.describe('SendTransaction', () => {

const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
await btnLocator.click();

Expand Down Expand Up @@ -95,8 +93,6 @@ test.describe('SendTransaction', () => {
// make sure the button is enabled
const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
await btnLocator.click();

Expand Down Expand Up @@ -140,8 +136,6 @@ test.describe('SendTransaction', () => {

const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
await btnLocator.click();

Expand Down Expand Up @@ -173,12 +167,9 @@ test.describe('SendTransaction', () => {

// Waiting button change to Review in order to ensure that fee amount is updated
await page.waitForSelector('button:has-text("Review")');
await page.waitForTimeout(1000);

const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
await btnLocator.click();

Expand Down Expand Up @@ -215,12 +206,9 @@ test.describe('SendTransaction', () => {

// Waiting button change to Review in order to change fee amount
await page.waitForSelector('button:has-text("Review")');
await page.waitForTimeout(1000);

const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
await btnLocator.click();

Expand Down Expand Up @@ -253,27 +241,38 @@ test.describe('SendTransaction', () => {

// Waiting button change to Review in order to ensure that fee amount is updated
await page.waitForSelector('button:has-text("Review")');
await page.waitForTimeout(1000);

// Selecting and extracting regular fee amount
await expect
.poll(
async () => {
return await getByAriaLabel(page, 'fee value:Regular').isVisible();
},
{ timeout: 10000 }
)
.toBeTruthy();
const regularFeeComponent = getByAriaLabel(page, 'fee value:Regular');
await regularFeeComponent.click();

// Waiting button change to Review in order to ensure that fee amount is updated
await page.waitForSelector('button:has-text("Review")');
await page.waitForTimeout(1000);

const btnLocatorBeforeApprv = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocatorBeforeApprv);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocatorBeforeApprv);
await btnLocatorBeforeApprv.click();

// Waiting button change to Approve in order to get updated fee amount
await page.waitForSelector('button:has-text("Submit")');
await page.waitForTimeout(1000);

await expect
.poll(
async () => {
return await getButtonByText(page, 'Back').isVisible();
},
{ timeout: 10000 }
)
.toBeTruthy();
// Going back to select other fee value
await getButtonByText(page, 'Back').click();

Expand All @@ -283,27 +282,37 @@ test.describe('SendTransaction', () => {

// Waiting button change to Review in order to change fee amount
await page.waitForSelector('button:has-text("Review")');
await page.waitForTimeout(1000);

const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
await btnLocator.click();

// Waiting button change to Approve in order to get updated fee amount
await page.waitForSelector('button:has-text("Submit")');
await page.waitForTimeout(1000);

await hasText(page, '0.001 ETH');

await page.waitForTimeout(1000);
await expect
.poll(
async () => {
return await getButtonByText(page, 'Submit').isEnabled();
},
{ timeout: 10000 }
)
.toBeTruthy();
await getButtonByText(page, 'Submit').click();
await hasText(page, '0.001 ETH');

// Wait for transaction to be confirmed
await hasText(page, 'success');
await expect
.poll(
async () => {
return await hasText(page, 'success');
},
{ timeout: 10000 }
)
.toBeTruthy();
});

test('Send max amount transaction', async () => {
Expand Down Expand Up @@ -337,15 +346,12 @@ test.describe('SendTransaction', () => {
// Fee values change
await new Promise((resolve) => setTimeout(resolve, 3000));

const maxAmountAfterFee = await getInputByName(page, 'amount').inputValue();

// Submit transaction

const btnLocator = getButtonByText(page, 'Review');

await expectButtonToBeEnabled(btnLocator);
await page.waitForTimeout(5000);
await expectButtonToBeEnabled(btnLocator);
const maxAmountAfterFee = await getInputByName(page, 'amount').inputValue();
await btnLocator.click();

// Approve transaction
Expand Down
35 changes: 14 additions & 21 deletions packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,26 @@ const selectors = {
proposedTxRequest(state: TransactionRequestState) {
return state.context.response?.proposedTxRequest;
},
isLoadingAccounts(state: TransactionRequestState) {
return state.matches('fetchingAccount');
},
errors(state: TransactionRequestState) {
if (!state.context.errors) return {};
const simulateTxErrors = state.context.errors?.simulateTxErrors;
const hasSimulateTxErrors = Boolean(simulateTxErrors);
const txApproveError = state.context.errors?.txApproveError;
return { txApproveError, simulateTxErrors, hasSimulateTxErrors };
},
status(externalLoading?: boolean) {
return useCallback(
(state: TransactionRequestState) => {
const isLoading = state.hasTag('loading');
const isClosed = state.matches('done') || state.matches('failed');

if (state.matches('idle')) return TxRequestStatus.idle;
if (externalLoading || isLoading) return TxRequestStatus.loading;
if (state.matches('txFailed')) return TxRequestStatus.failed;
if (state.matches('txSuccess')) return TxRequestStatus.success;
if (state.matches('sendingTx')) return TxRequestStatus.sending;
if (isClosed) return TxRequestStatus.inactive;
return TxRequestStatus.waitingApproval;
},
[externalLoading]
);
status() {
return useCallback((state: TransactionRequestState) => {
const isLoading = state.hasTag('loading');
const isClosed = state.matches('done') || state.matches('failed');

if (state.matches('idle')) return TxRequestStatus.idle;
if (isLoading) return TxRequestStatus.loading;
if (state.matches('txFailed')) return TxRequestStatus.failed;
if (state.matches('txSuccess')) return TxRequestStatus.success;
if (state.matches('sendingTx')) return TxRequestStatus.sending;
if (isClosed) return TxRequestStatus.inactive;
return TxRequestStatus.waitingApproval;
}, []);
},
title(state: TransactionRequestState) {
if (state.matches('txSuccess')) return 'Transaction sent';
Expand Down Expand Up @@ -95,12 +89,11 @@ export function useTransactionRequest(opts: UseTransactionRequestOpts = {}) {
},
});

const isLoadingAccounts = useSelector(service, selectors.isLoadingAccounts);
const account = useSelector(service, selectors.account);
const ctx = useSelector(service, selectors.context);
const errors = useSelector(service, selectors.errors);
const providerUrl = ctx.input.providerUrl;
const txStatusSelector = selectors.status(isLoadingAccounts);
const txStatusSelector = selectors.status();
const txStatus = useSelector(service, txStatusSelector);
const title = useSelector(service, selectors.title);
const txSummarySimulated = useSelector(service, selectors.txSummarySimulated);
Expand Down
Loading
Loading