Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Naming + fixing ERC1155 quantity potentially falsy
Browse files Browse the repository at this point in the history
  • Loading branch information
lambertkevin committed Mar 24, 2022
1 parent af1810f commit 31177aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/families/ethereum/modules/erc1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type { ModeModule, Transaction } from "../types";
import type { Account } from "../../../types";
import { prepareTransaction } from "./erc721";

const notOwnedNft = createCustomErrorClass("NotOwnedNft");
const notEnoughNftOwned = createCustomErrorClass("NotEnoughNftOwned");
const notTokenIdsProvided = createCustomErrorClass("NotTokenIdsProvided");
const quantityNeedsToBePositive = createCustomErrorClass(
const NotOwnedNft = createCustomErrorClass("NotOwnedNft");
const NotEnoughNftOwned = createCustomErrorClass("NotEnoughNftOwned");
const NotTokenIdsProvided = createCustomErrorClass("NotTokenIdsProvided");
const QuantityNeedsToBePositive = createCustomErrorClass(
"QuantityNeedsToBePositive"
);

Expand Down Expand Up @@ -47,8 +47,8 @@ const erc1155Transfer: ModeModule = {
}

t.quantities?.forEach((quantity) => {
if (quantity.isLessThan(1)) {
result.errors.amount = new quantityNeedsToBePositive();
if (!quantity || quantity.isLessThan(1)) {
result.errors.amount = new QuantityNeedsToBePositive();
}
});

Expand All @@ -62,15 +62,15 @@ const erc1155Transfer: ModeModule = {
const transferQuantity = Number(t.quantities?.[index]);

if (!nft) {
return new notOwnedNft();
return new NotOwnedNft();
}

if (transferQuantity && !nft.amount.gte(transferQuantity)) {
return new notEnoughNftOwned();
return new NotEnoughNftOwned();
}

return true;
}, true as true | Error) || new notTokenIdsProvided();
}, true as true | Error) || new NotTokenIdsProvided();

if (!enoughTokensOwned || enoughTokensOwned instanceof Error) {
result.errors.amount = enoughTokensOwned;
Expand Down
4 changes: 2 additions & 2 deletions src/families/ethereum/modules/erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ModeModule, Transaction } from "../types";
import type { Account } from "../../../types";
import { apiForCurrency } from "../../../api/Ethereum";

const notOwnedNft = createCustomErrorClass("NotOwnedNft");
const NotOwnedNft = createCustomErrorClass("NotOwnedNft");

export type Modes = "erc721.transfer";

Expand Down Expand Up @@ -72,7 +72,7 @@ const erc721Transfer: ModeModule = {
(n) => n.tokenId === t.tokenIds?.[0] && n.contract === t.collection
)
) {
result.errors.amount = new notOwnedNft();
result.errors.amount = new NotOwnedNft();
}
}
},
Expand Down

0 comments on commit 31177aa

Please sign in to comment.