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

LL-8982 Add error for 0 qty ERC1155 NFT send #1659

Merged
merged 3 commits into from
Jan 28, 2022
Merged
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
9 changes: 9 additions & 0 deletions src/families/ethereum/modules/erc1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { prepareTransaction } from "./erc721";
const notOwnedNft = createCustomErrorClass("NotOwnedNft");
const notEnoughNftOwned = createCustomErrorClass("NotEnoughNftOwned");
const notTokenIdsProvided = createCustomErrorClass("NotTokenIdsProvided");
const quantityNeedsToBePositive = createCustomErrorClass(
Copy link
Contributor

Choose a reason for hiding this comment

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

errors need to start with uppercase (indeed it's also a mistake for all other vars)

Copy link
Contributor

Choose a reason for hiding this comment

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

to be taken into consideration later

"QuantityNeedsToBePositive"
);

export type Modes = "erc1155.transfer";

Expand Down Expand Up @@ -43,6 +46,12 @@ const erc1155Transfer: ModeModule = {
result.errors.amount = new NotEnoughBalanceInParentAccount();
}

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

const enoughTokensOwned: true | Error =
t.tokenIds?.reduce((acc, tokenId, index) => {
if (acc instanceof Error) {
Expand Down