diff --git a/frontend/src/components/NewPlayer.tsx b/frontend/src/components/NewPlayer.tsx index e66aada..7b0ceed 100644 --- a/frontend/src/components/NewPlayer.tsx +++ b/frontend/src/components/NewPlayer.tsx @@ -141,11 +141,9 @@ export default function NewPlayer({ ); request.addChangeOutput(gasCoin.owner, provider.getBaseAssetId()); - const { gasLimit, maxFee } = await provider.estimateTxGasAndFee({ - transactionRequest: request, - }); - console.log(`New Player Cost gasLimit: ${gasLimit}, Maxfee: ${maxFee}`); - request.gasLimit = gasLimit; + const txCost = await wallet.getTransactionCost(request); + const { gasUsed, maxFee } = txCost; + request.gasLimit = gasUsed; request.maxFee = maxFee; // return; diff --git a/frontend/src/components/modals/HarvestModal.tsx b/frontend/src/components/modals/HarvestModal.tsx index ffb6cf8..aec5ec0 100644 --- a/frontend/src/components/modals/HarvestModal.tsx +++ b/frontend/src/components/modals/HarvestModal.tsx @@ -117,12 +117,11 @@ export default function HarvestModal({ provider.getBaseAssetId() ); request.addChangeOutput(gasCoin.owner, provider.getBaseAssetId()); - const { gasLimit, maxFee } = await provider.estimateTxGasAndFee({ - transactionRequest: request, - }); - request.gasLimit = gasLimit; + const txCost = await wallet.getTransactionCost(request); + const { gasUsed, maxFee } = txCost; + request.gasLimit = gasUsed; request.maxFee = maxFee; - console.log(`Harvest Cost gasLimit: ${gasLimit}, Maxfee: ${maxFee}`); + console.log(`Harvest Cost gasLimit: ${gasUsed}, Maxfee: ${maxFee}`); const response = await axios.post(`http://167.71.42.88:3000/sign`, { request: request.toJSON(), jobId: data.jobId, diff --git a/frontend/src/components/modals/PlantModal.tsx b/frontend/src/components/modals/PlantModal.tsx index 45c3dd6..a756a52 100644 --- a/frontend/src/components/modals/PlantModal.tsx +++ b/frontend/src/components/modals/PlantModal.tsx @@ -124,12 +124,11 @@ export default function PlantModal({ provider.getBaseAssetId() ); request.addChangeOutput(gasCoin.owner, provider.getBaseAssetId()); - const { gasLimit, maxFee } = await provider.estimateTxGasAndFee({ - transactionRequest: request, - }); - request.gasLimit = gasLimit; + const txCost = await wallet.getTransactionCost(request); + const { gasUsed, maxFee } = txCost; + request.gasLimit = gasUsed; request.maxFee = maxFee; - console.log(`Plant Cost gasLimit: ${gasLimit}, Maxfee: ${maxFee}`); + console.log(`Plant Cost gasLimit: ${gasUsed}, Maxfee: ${maxFee}`); const response = await axios.post(`http://167.71.42.88:3000/sign`, { request: request.toJSON(), jobId: data.jobId,