Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 2 deletions djed-sdk/src/djed/reserveCoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const tradeDataPriceBuyRc = async (djed, rcDecimals, amountScaled) => {
totalBCUnscaled,
};
} catch (error) {
console.log("error", error);
console.error("tradeDataPriceBuyRc error:", error);
throw new Error("Failed to calculate reserve coin buy price", { cause: error });
}
};

Expand Down Expand Up @@ -66,7 +67,8 @@ export const tradeDataPriceSellRc = async (djed, rcDecimals, amountScaled) => {
totalBCUnscaled: totalBCAmount.toString(),
};
} catch (error) {
console.log("error", error);
console.error("tradeDataPriceSellRc error:", error);
throw new Error("Failed to calculate reserve coin sell price", { cause: error });
}
};

Expand Down
9 changes: 6 additions & 3 deletions djed-sdk/src/djed/stableCoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const tradeDataPriceBuySc = async (djed, scDecimals, amountScaled) => {
totalBCUnscaled,
};
} catch (error) {
console.log("error", error);
console.error("tradeDataPriceBuySc error:", error);
throw new Error("Failed to calculate stable coin buy price", { cause: error });
}
};

Expand Down Expand Up @@ -71,7 +72,8 @@ export const tradeDataPriceSellSc = async (djed, scDecimals, amountScaled) => {
totalBCScaled: decimalScaling(totalBCAmount.toString(), BC_DECIMALS),
};
} catch (error) {
console.log("error", error);
console.error("tradeDataPriceSellSc error:", error);
throw new Error("Failed to calculate stable coin sell price", { cause: error });
}
};

Expand Down Expand Up @@ -129,6 +131,7 @@ export const calculateFutureScPrice = async ({
: futurePrice.toString();
}
} catch (error) {
console.log("calculateFutureScPrice error ", error);
console.error("calculateFutureScPrice error:", error);
throw new Error("Failed to calculate future stable coin price", { cause: error });
}
Comment on lines 133 to 136

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calculateFutureScPrice calls web3Promise(...), but web3Promise is not imported in this module (only decimalScaling/buildTx are imported from ../helpers). That will cause a ReferenceError at runtime when this function is called (and now gets wrapped by the new throw). Import web3Promise from ../helpers (or reference the correct helper) so the function can actually execute contract calls.

Copilot uses AI. Check for mistakes.
};
3 changes: 2 additions & 1 deletion djed-sdk/src/djed/tradeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export const getFees = async (djed) => {
fee,
};
} catch (error) {
console.log("error", error);
console.error("getFees error:", error);
throw new Error("Failed to fetch fees from contract", { cause: error });
}
Comment on lines 201 to 204

Copilot AI Mar 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are only in src/, but djed-sdk/package.json exports dist/umd/index.js + dist/esm/index.js and .npmignore excludes src/. As-is, publishing/consuming the package will not include this improved error handling. Please rebuild and commit the dist/ outputs (or add a build/prepublish step and/or point main/module at the built output generated during publish).

Copilot uses AI. Check for mistakes.
};
Loading