From 65fc40aff5ba7ec96083d2ed92d4320418035f00 Mon Sep 17 00:00:00 2001 From: RaviChauhan <1chauhanravi0@gmail.com> Date: Wed, 25 Feb 2026 02:35:13 +0530 Subject: [PATCH 1/2] Fix: Replace Ethers.js sendTransaction with Web3.js implementation in promiseTx --- djed-sdk/src/djed/tradeUtils.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/djed-sdk/src/djed/tradeUtils.js b/djed-sdk/src/djed/tradeUtils.js index 456f1f1..a8d0556 100644 --- a/djed-sdk/src/djed/tradeUtils.js +++ b/djed-sdk/src/djed/tradeUtils.js @@ -15,7 +15,7 @@ import { export const scalingFactor = decimalUnscaling("1", SCALING_DECIMALS); export const FEE_UI_UNSCALED = decimalUnscaling( (FEE_UI / 100).toString(), - SCALING_DECIMALS + SCALING_DECIMALS, ); export const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { const amountUnscaled = decimalUnscaling(amountScaled, decimals); @@ -25,7 +25,7 @@ export const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { const totalUnscaled = convertToBC( amountUnscaled, priceUnscaled, - decimals + decimals, ).toString(); const totalScaled = decimalScaling(totalUnscaled, BC_DECIMALS); @@ -38,7 +38,7 @@ export const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { priceUnscaled, priceScaled, }; - } + }, ); }; @@ -118,14 +118,22 @@ export const isTxLimitReached = (amountUSD, totalSCSupply, thresholdSCSupply) => amountUSD > TRANSACTION_USD_LIMIT && BigInt(totalSCSupply) >= BigInt(thresholdSCSupply); -export const promiseTx = (isWalletConnected, tx, signer) => { +export const promiseTx = (isWalletConnected, tx, web3) => { if (!isWalletConnected) { return Promise.reject(new Error("Metamask not connected!")); } - if (!signer) { - return Promise.reject(new Error("Couldn't get Signer")); + + if (!web3 || !web3.eth) { + return Promise.reject(new Error("Web3 instance not provided")); } - return signer.sendTransaction(tx); + + return web3.eth.sendTransaction({ + from: tx.from, + to: tx.to, + value: tx.value, + data: tx.data, + gas: tx.gasLimit || 500000, + }); }; export const verifyTx = (web3, hash) => { From 623a06d9f6a9708ecef5160db66d86a804af5692 Mon Sep 17 00:00:00 2001 From: RaviChauhan <1chauhanravi0@gmail.com> Date: Wed, 25 Feb 2026 10:14:33 +0530 Subject: [PATCH 2/2] Fix: Replace Ethers sendTransaction with Web3 implementation and correct gas precedence --- djed-sdk/dist/esm/index.js | 33 ++++++++++++++++++++++++++------- djed-sdk/dist/umd/index.js | 33 ++++++++++++++++++++++++++------- djed-sdk/src/djed/tradeUtils.js | 23 +++++++++++++++++------ 3 files changed, 69 insertions(+), 20 deletions(-) diff --git a/djed-sdk/dist/esm/index.js b/djed-sdk/dist/esm/index.js index f030428..0baac43 100644 --- a/djed-sdk/dist/esm/index.js +++ b/djed-sdk/dist/esm/index.js @@ -156,7 +156,7 @@ const CONFIRMATION_WAIT_PERIOD = REFRESH_PERIOD + 1000; const scalingFactor = decimalUnscaling("1", SCALING_DECIMALS); const FEE_UI_UNSCALED = decimalUnscaling( (FEE_UI / 100).toString(), - SCALING_DECIMALS + SCALING_DECIMALS, ); const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { const amountUnscaled = decimalUnscaling(amountScaled, decimals); @@ -166,7 +166,7 @@ const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { const totalUnscaled = convertToBC( amountUnscaled, priceUnscaled, - decimals + decimals, ).toString(); const totalScaled = decimalScaling(totalUnscaled, BC_DECIMALS); @@ -179,7 +179,7 @@ const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { priceUnscaled, priceScaled, }; - } + }, ); }; @@ -259,14 +259,33 @@ const isTxLimitReached = (amountUSD, totalSCSupply, thresholdSCSupply) => amountUSD > TRANSACTION_USD_LIMIT && BigInt(totalSCSupply) >= BigInt(thresholdSCSupply); -const promiseTx = (isWalletConnected, tx, signer) => { +const promiseTx = (isWalletConnected, tx, web3) => { if (!isWalletConnected) { return Promise.reject(new Error("Metamask not connected!")); } - if (!signer) { - return Promise.reject(new Error("Couldn't get Signer")); + + if (!web3 || !web3.eth) { + return Promise.reject(new Error("Web3 instance not provided")); + } + + if (!tx?.from) { + return Promise.reject(new Error("Transaction 'from' address is required")); } - return signer.sendTransaction(tx); + + const selectedGas = tx.gas ?? tx.gasLimit ?? 500000; + + return new Promise((resolve, reject) => { + web3.eth + .sendTransaction({ + from: tx.from, + to: tx.to, + value: tx.value, + data: tx.data, + gas: selectedGas, + }) + .on("receipt", resolve) + .on("error", reject); + }); }; const verifyTx = (web3, hash) => { diff --git a/djed-sdk/dist/umd/index.js b/djed-sdk/dist/umd/index.js index 24bf322..caa765c 100644 --- a/djed-sdk/dist/umd/index.js +++ b/djed-sdk/dist/umd/index.js @@ -160,7 +160,7 @@ const scalingFactor = decimalUnscaling("1", SCALING_DECIMALS); const FEE_UI_UNSCALED = decimalUnscaling( (FEE_UI / 100).toString(), - SCALING_DECIMALS + SCALING_DECIMALS, ); const tradeDataPriceCore = (djed, method, decimals, amountScaled) => { const amountUnscaled = decimalUnscaling(amountScaled, decimals); @@ -170,7 +170,7 @@ const totalUnscaled = convertToBC( amountUnscaled, priceUnscaled, - decimals + decimals, ).toString(); const totalScaled = decimalScaling(totalUnscaled, BC_DECIMALS); @@ -183,7 +183,7 @@ priceUnscaled, priceScaled, }; - } + }, ); }; @@ -263,14 +263,33 @@ amountUSD > TRANSACTION_USD_LIMIT && BigInt(totalSCSupply) >= BigInt(thresholdSCSupply); - const promiseTx = (isWalletConnected, tx, signer) => { + const promiseTx = (isWalletConnected, tx, web3) => { if (!isWalletConnected) { return Promise.reject(new Error("Metamask not connected!")); } - if (!signer) { - return Promise.reject(new Error("Couldn't get Signer")); + + if (!web3 || !web3.eth) { + return Promise.reject(new Error("Web3 instance not provided")); + } + + if (!tx?.from) { + return Promise.reject(new Error("Transaction 'from' address is required")); } - return signer.sendTransaction(tx); + + const selectedGas = tx.gas ?? tx.gasLimit ?? 500000; + + return new Promise((resolve, reject) => { + web3.eth + .sendTransaction({ + from: tx.from, + to: tx.to, + value: tx.value, + data: tx.data, + gas: selectedGas, + }) + .on("receipt", resolve) + .on("error", reject); + }); }; const verifyTx = (web3, hash) => { diff --git a/djed-sdk/src/djed/tradeUtils.js b/djed-sdk/src/djed/tradeUtils.js index a8d0556..b439e8b 100644 --- a/djed-sdk/src/djed/tradeUtils.js +++ b/djed-sdk/src/djed/tradeUtils.js @@ -127,12 +127,23 @@ export const promiseTx = (isWalletConnected, tx, web3) => { return Promise.reject(new Error("Web3 instance not provided")); } - return web3.eth.sendTransaction({ - from: tx.from, - to: tx.to, - value: tx.value, - data: tx.data, - gas: tx.gasLimit || 500000, + if (!tx?.from) { + return Promise.reject(new Error("Transaction 'from' address is required")); + } + + const selectedGas = tx.gas ?? tx.gasLimit ?? 500000; + + return new Promise((resolve, reject) => { + web3.eth + .sendTransaction({ + from: tx.from, + to: tx.to, + value: tx.value, + data: tx.data, + gas: selectedGas, + }) + .on("receipt", resolve) + .on("error", reject); }); };