Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes underflow when try to use fractional ETH as number in orders #1031

Merged
merged 2 commits into from Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "opensea-js",
"version": "6.0.4",
"version": "6.0.5",
"description": "JavaScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data!",
"license": "MIT",
"author": "OpenSea Developers",
Expand Down
12 changes: 3 additions & 9 deletions src/sdk.ts
Expand Up @@ -944,14 +944,11 @@ export class OpenSeaSDK {
const decimals = paymentToken?.decimals ?? 18;

const startAmountWei = ethers.utils.parseUnits(
FixedNumber.from(startAmount).toString(),
startAmount.toString(),
decimals
);
const endAmountWei = endAmount
? ethers.utils.parseUnits(
FixedNumber.from(endAmount).toString(),
decimals
)
? ethers.utils.parseUnits(endAmount.toString(), decimals)
: undefined;
const priceDiffWei =
endAmountWei !== undefined
Expand All @@ -962,10 +959,7 @@ export class OpenSeaSDK {
const endPrice = endAmountWei;
const extra = priceDiffWei;
const reservePrice = englishAuctionReservePrice
? ethers.utils.parseUnits(
FixedNumber.from(startAmount).toString(),
decimals
)
? ethers.utils.parseUnits(startAmount.toString(), decimals)
: undefined;

// Validation
Expand Down
4 changes: 2 additions & 2 deletions test/integration/postOrder.spec.ts
Expand Up @@ -15,7 +15,7 @@ suite("SDK: order posting", () => {
test("Post Buy Order", async () => {
const buyOrder = {
accountAddress: walletAddress,
startAmount: OFFER_AMOUNT,
startAmount: +OFFER_AMOUNT,
asset: {
tokenAddress: "0x1a92f7381b9f03921564a437210bb9396471050c",
tokenId: "2288",
Expand All @@ -34,7 +34,7 @@ suite("SDK: order posting", () => {

const sellOrder = {
accountAddress: walletAddress,
startAmount: LISTING_AMOUNT,
startAmount: +LISTING_AMOUNT,
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe keep one as a string or it might be smart to test all variations of bignumberish inputs to ensure their resulting values are equal

asset: {
tokenAddress: TOKEN_ADDRESS,
tokenId: TOKEN_ID,
Expand Down