Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight committed Dec 16, 2024
1 parent ae69013 commit 6d8ecea
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions packages/app/src/systems/Transaction/services/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6d8ecea

Please sign in to comment.