From 6d8ecea063ce035dc7fe7dd4981989620acb3ad8 Mon Sep 17 00:00:00 2001 From: LuizAsFight Date: Mon, 16 Dec 2024 17:00:48 -0300 Subject: [PATCH 1/5] chore --- .../Transaction/services/transaction.tsx | 74 ++++++++++--------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/packages/app/src/systems/Transaction/services/transaction.tsx b/packages/app/src/systems/Transaction/services/transaction.tsx index 1ec72b956..e15173744 100644 --- a/packages/app/src/systems/Transaction/services/transaction.tsx +++ b/packages/app/src/systems/Transaction/services/transaction.tsx @@ -207,52 +207,58 @@ export class TxService { we'll work always based on the first inputted transactioRequest, then cloning it and manipulating then outputting a proposedTxRequest, which will be the one to go for approval */ + // debugger; + // const xxx = await wallet.provider.dryRun(inputTransactionRequest); + // debugger; + const proposedTxRequest = clone(inputTransactionRequest); - if (!skipCustomFee) { - // if the user has inputted a custom tip, we set it to the proposedTxRequest - if (inputCustomTip) { - proposedTxRequest.tip = inputCustomTip; - } - // if the user has inputted a custom gas Limit, we set it to the proposedTxRequest - if (inputCustomGasLimit) { - setGasLimitToTxRequest(proposedTxRequest, inputCustomGasLimit); - } else { - // if the user has not inputted a custom gas Limit, we increase the original one in 20% to avoid OutOfGas errors - setGasLimitToTxRequest( - proposedTxRequest, - initialGasLimit.mul(12).div(10) - ); - } - const { maxFee } = await provider.estimateTxGasAndFee({ - transactionRequest: proposedTxRequest, - }); - - // if the maxFee is greater than the initial maxFee, we set it to the new maxFee, and refund the transaction - if (maxFee.gt(initialMaxFee)) { - proposedTxRequest.maxFee = maxFee; - const txCost = await wallet.getTransactionCost(proposedTxRequest, { - estimateTxDependencies: true, - }); - await wallet.fund(proposedTxRequest, { - estimatedPredicates: txCost.estimatedPredicates, - addedSignatures: txCost.addedSignatures, - gasPrice: txCost.gasPrice, - updateMaxFee: txCost.updateMaxFee, - requiredQuantities: [], - }); - } - } + // if (!skipCustomFee) { + // // if the user has inputted a custom tip, we set it to the proposedTxRequest + // if (inputCustomTip) { + // proposedTxRequest.tip = inputCustomTip; + // } + // // if the user has inputted a custom gas Limit, we set it to the proposedTxRequest + // if (inputCustomGasLimit) { + // setGasLimitToTxRequest(proposedTxRequest, inputCustomGasLimit); + // } else { + // // if the user has not inputted a custom gas Limit, we increase the original one in 20% to avoid OutOfGas errors + // setGasLimitToTxRequest( + // proposedTxRequest, + // initialGasLimit.mul(12).div(10) + // ); + // } + // const { maxFee } = await provider.estimateTxGasAndFee({ + // transactionRequest: proposedTxRequest, + // }); + + // // if the maxFee is greater than the initial maxFee, we set it to the new maxFee, and refund the transaction + // if (maxFee.gt(initialMaxFee)) { + // proposedTxRequest.maxFee = maxFee; + // const txCost = await wallet.getTransactionCost(proposedTxRequest, { + // estimateTxDependencies: true, + // }); + // await wallet.fund(proposedTxRequest, { + // estimatedPredicates: txCost.estimatedPredicates, + // addedSignatures: txCost.addedSignatures, + // gasPrice: txCost.gasPrice, + // updateMaxFee: txCost.updateMaxFee, + // requiredQuantities: [], + // }); + // } + // } const transaction = proposedTxRequest.toTransaction(); const abiMap = await getAbiMap({ inputs: transaction.inputs, }); + // debugger; const txSummary = await getTransactionSummaryFromRequest({ provider, transactionRequest: proposedTxRequest, abiMap, }); + // debugger; const baseFee = proposedTxRequest.maxFee.sub( proposedTxRequest.tip ?? bn(0) From bdce830c97f142155c6ec490de2cc9e9f9d866c5 Mon Sep 17 00:00:00 2001 From: Nelito Junior Date: Sat, 21 Dec 2024 02:52:03 -0300 Subject: [PATCH 2/5] feat: skip custom fee handling --- examples/cra-dapp/package.json | 4 +- package.json | 2 +- packages/app/package.json | 4 +- .../DApp/hooks/useTransactionRequest.tsx | 1 + .../TransactionRequest/TransactionRequest.tsx | 2 + .../app/src/systems/Send/hooks/useSend.tsx | 3 +- .../src/systems/Send/machines/sendMachine.ts | 3 + .../components/TxContent/TxContent.tsx | 9 ++- .../Transaction/pages/TxApprove/TxApprove.tsx | 2 + .../Transaction/services/transaction.tsx | 75 ++++++++++--------- 10 files changed, 63 insertions(+), 42 deletions(-) diff --git a/examples/cra-dapp/package.json b/examples/cra-dapp/package.json index adfaecf44..48f0fbfe9 100644 --- a/examples/cra-dapp/package.json +++ b/examples/cra-dapp/package.json @@ -8,9 +8,9 @@ }, "dependencies": { "@fuels/connectors": "0.35.1", - "@fuels/react": "0.35.1", + "@fuels/react": "0.39.0-pr-446-73", "@tanstack/react-query": "5.28.4", - "fuels": "0.96.1", + "fuels": "0.0.0-pr-3487-20241220190150", "react": "18.3.1", "react-dom": "18.3.1" }, diff --git a/package.json b/package.json index e88a941ca..45c900602 100644 --- a/package.json +++ b/package.json @@ -124,7 +124,7 @@ "send@<0.19.0": ">=0.19.0", "serve-static@<1.16.0": ">=1.16.0", "rollup@>=4.0.0 <4.22.4": ">=4.22.4", - "fuels": "0.96.1", + "fuels": "0.0.0-pr-3487-20241220190150", "secp256k1@=5.0.0": ">=5.0.1", "elliptic@<6.6.0": ">=6.6.0", "cross-spawn@<7.0.5": ">=7.0.5", diff --git a/packages/app/package.json b/packages/app/package.json index b524d4492..8b017b7fe 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -21,6 +21,8 @@ }, "dependencies": { "@fontsource/source-code-pro": "5.0.13", + "@fuel-ts/math": "0.97.2", + "@fuel-ts/providers": "0.73.0", "@fuel-ui/css": "0.23.3", "@fuel-ui/icons": "0.23.3", "@fuel-ui/react": "0.23.3", @@ -44,7 +46,7 @@ "events": "3.3.0", "fake-indexeddb": "4.0.2", "framer-motion": "10.16.4", - "fuels": "0.96.1", + "fuels": "0.0.0-pr-3487-20241220190150", "json-edit-react": "1.13.3", "json-rpc-2.0": "1.7.0", "lodash.debounce": "4.0.8", diff --git a/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx b/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx index 6ff1ba477..f4d7aa391 100644 --- a/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx +++ b/packages/app/src/systems/DApp/hooks/useTransactionRequest.tsx @@ -142,6 +142,7 @@ export function useTransactionRequest(opts: UseTransactionRequestOpts = {}) { } function request(input: TxInputs['request']) { + console.log('request', input); service.send('START', { input }); } diff --git a/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx b/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx index 433923442..e5de4132f 100644 --- a/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx +++ b/packages/app/src/systems/DApp/pages/TransactionRequest/TransactionRequest.tsx @@ -93,6 +93,7 @@ export function TransactionRequest() { errors={errors.simulateTxErrors} isConfirm fees={fees} + skipCustomFee={txRequest.input.skipCustomFee} /> )} {shouldShowTxExecuted && ( @@ -100,6 +101,7 @@ export function TransactionRequest() { showDetails tx={txSummaryExecuted} txStatus={executedStatus()} + skipCustomFee={txRequest.input.skipCustomFee} footer={ status('failed') && (