@opensea/seaport-js 1.0.1-beta.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +141 -5
  3. package/lib/abi/ERC1155.d.ts +29 -29
  4. package/lib/abi/ERC1155.js +319 -0
  5. package/lib/abi/ERC1155.js.map +1 -0
  6. package/lib/abi/ERC20.d.ts +29 -29
  7. package/lib/abi/ERC20.js +317 -0
  8. package/lib/abi/ERC20.js.map +1 -0
  9. package/lib/abi/ERC721.d.ts +29 -29
  10. package/lib/abi/ERC721.js +337 -0
  11. package/lib/abi/ERC721.js.map +1 -0
  12. package/lib/abi/Seaport.d.ts +112 -112
  13. package/lib/abi/Seaport.js +2585 -0
  14. package/lib/abi/Seaport.js.map +1 -0
  15. package/lib/constants.d.ts +53 -49
  16. package/lib/constants.js +78 -0
  17. package/lib/constants.js.map +1 -0
  18. package/lib/index.d.ts +2 -2
  19. package/lib/index.js +6 -2
  20. package/lib/index.js.map +1 -1
  21. package/lib/seaport.d.ts +184 -181
  22. package/lib/seaport.js +732 -0
  23. package/lib/seaport.js.map +1 -0
  24. package/lib/typechain/ERC1155.d.ts +189 -0
  25. package/lib/typechain/ERC1155.js +3 -0
  26. package/lib/typechain/ERC1155.js.map +1 -0
  27. package/lib/typechain/ERC20.d.ts +209 -0
  28. package/lib/typechain/ERC20.js +3 -0
  29. package/lib/typechain/ERC20.js.map +1 -0
  30. package/lib/typechain/ERC721.d.ts +220 -0
  31. package/lib/typechain/ERC721.js +3 -0
  32. package/lib/typechain/ERC721.js.map +1 -0
  33. package/lib/typechain/Seaport.d.ts +686 -0
  34. package/lib/typechain/Seaport.js +3 -0
  35. package/lib/typechain/Seaport.js.map +1 -0
  36. package/lib/typechain/common.d.ts +21 -0
  37. package/lib/typechain/common.js +3 -0
  38. package/lib/typechain/common.js.map +1 -0
  39. package/lib/types.d.ts +221 -207
  40. package/lib/types.js +3 -0
  41. package/lib/types.js.map +1 -0
  42. package/lib/utils/approval.d.ts +9 -9
  43. package/lib/utils/approval.js +108 -0
  44. package/lib/utils/approval.js.map +1 -0
  45. package/lib/utils/balance.d.ts +4 -4
  46. package/lib/utils/balance.js +86 -0
  47. package/lib/utils/balance.js.map +1 -0
  48. package/lib/utils/balanceAndApprovalCheck.d.ts +108 -108
  49. package/lib/utils/balanceAndApprovalCheck.js +322 -0
  50. package/lib/utils/balanceAndApprovalCheck.js.map +1 -0
  51. package/lib/utils/criteria.d.ts +14 -13
  52. package/lib/utils/criteria.js +91 -0
  53. package/lib/utils/criteria.js.map +1 -0
  54. package/lib/utils/fulfill.d.ts +84 -84
  55. package/lib/utils/fulfill.js +573 -0
  56. package/lib/utils/fulfill.js.map +1 -0
  57. package/lib/utils/gcd.d.ts +3 -3
  58. package/lib/utils/gcd.js +25 -0
  59. package/lib/utils/gcd.js.map +1 -0
  60. package/lib/utils/item.d.ts +29 -30
  61. package/lib/utils/item.js +136 -0
  62. package/lib/utils/item.js.map +1 -0
  63. package/lib/utils/match.d.ts +49 -49
  64. package/lib/utils/match.js +56 -0
  65. package/lib/utils/match.js.map +1 -0
  66. package/lib/utils/merkletree.d.ts +11 -11
  67. package/lib/utils/merkletree.js +32 -0
  68. package/lib/utils/merkletree.js.map +1 -0
  69. package/lib/utils/order.d.ts +37 -37
  70. package/lib/utils/order.js +224 -0
  71. package/lib/utils/order.js.map +1 -0
  72. package/lib/utils/usecase.d.ts +4 -4
  73. package/lib/utils/usecase.js +158 -0
  74. package/lib/utils/usecase.js.map +1 -0
  75. package/package.json +43 -43
  76. package/lib/index.esm.mjs +0 -2
  77. package/lib/index.esm.mjs.map +0 -1
  78. package/lib/index.modern.mjs +0 -2
  79. package/lib/index.modern.mjs.map +0 -1
  80. package/lib/index.umd.js +0 -2
  81. package/lib/index.umd.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.balanceOf = void 0;
40
+ var ethers_1 = require("ethers");
41
+ var ERC1155_1 = require("../abi/ERC1155");
42
+ var ERC20_1 = require("../abi/ERC20");
43
+ var ERC721_1 = require("../abi/ERC721");
44
+ var constants_1 = require("../constants");
45
+ var item_1 = require("./item");
46
+ var balanceOf = function (owner, item, multicallProvider, criteria) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var contract, contract, startAmount, endAmount, contract;
48
+ return __generator(this, function (_a) {
49
+ if ((0, item_1.isErc721Item)(item.itemType)) {
50
+ contract = new ethers_1.Contract(item.token, ERC721_1.ERC721ABI, multicallProvider);
51
+ if (item.itemType === constants_1.ItemType.ERC721_WITH_CRITERIA) {
52
+ return [2 /*return*/, criteria
53
+ ? contract
54
+ .ownerOf(criteria.identifier)
55
+ .then(function (ownerOf) {
56
+ return ethers_1.BigNumber.from(Number(ownerOf.toLowerCase() === owner.toLowerCase()));
57
+ })
58
+ : contract.balanceOf(owner)];
59
+ }
60
+ return [2 /*return*/, contract
61
+ .ownerOf(item.identifierOrCriteria)
62
+ .then(function (ownerOf) {
63
+ return ethers_1.BigNumber.from(Number(ownerOf.toLowerCase() === owner.toLowerCase()));
64
+ })];
65
+ }
66
+ else if ((0, item_1.isErc1155Item)(item.itemType)) {
67
+ contract = new ethers_1.Contract(item.token, ERC1155_1.ERC1155ABI, multicallProvider);
68
+ if (item.itemType === constants_1.ItemType.ERC1155_WITH_CRITERIA) {
69
+ if (!criteria) {
70
+ startAmount = ethers_1.BigNumber.from(item.startAmount);
71
+ endAmount = ethers_1.BigNumber.from(item.endAmount);
72
+ return [2 /*return*/, startAmount.gt(endAmount) ? startAmount : endAmount];
73
+ }
74
+ return [2 /*return*/, contract.balanceOf(owner, criteria.identifier)];
75
+ }
76
+ return [2 /*return*/, contract.balanceOf(owner, item.identifierOrCriteria)];
77
+ }
78
+ if ((0, item_1.isErc20Item)(item.itemType)) {
79
+ contract = new ethers_1.Contract(item.token, ERC20_1.ERC20ABI, multicallProvider);
80
+ return [2 /*return*/, contract.balanceOf(owner)];
81
+ }
82
+ return [2 /*return*/, multicallProvider.getBalance(owner)];
83
+ });
84
+ }); };
85
+ exports.balanceOf = balanceOf;
86
+ //# sourceMappingURL=balance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/utils/balance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAA6C;AAC7C,0CAA4C;AAC5C,sCAAwC;AACxC,wCAA0C;AAC1C,0CAAwC;AAKxC,+BAAkE;AAE3D,IAAM,SAAS,GAAG,UACvB,KAAa,EACb,IAAU,EACV,iBAAuD,EACvD,QAAwB;;;QAExB,IAAI,IAAA,mBAAY,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACzB,QAAQ,GAAG,IAAI,iBAAQ,CAC3B,IAAI,CAAC,KAAK,EACV,kBAAS,EACT,iBAAiB,CACR,CAAC;YAEZ,IAAI,IAAI,CAAC,QAAQ,KAAK,oBAAQ,CAAC,oBAAoB,EAAE;gBACnD,sBAAO,QAAQ;wBACb,CAAC,CAAC,QAAQ;6BACL,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;6BAC5B,IAAI,CAAC,UAAC,OAAO;4BACZ,OAAA,kBAAS,CAAC,IAAI,CACZ,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CACtD;wBAFD,CAEC,CACF;wBACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAC;aAC/B;YAED,sBAAO,QAAQ;qBACZ,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC;qBAClC,IAAI,CAAC,UAAC,OAAO;oBACZ,OAAA,kBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;gBAArE,CAAqE,CACtE,EAAC;SACL;aAAM,IAAI,IAAA,oBAAa,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACjC,QAAQ,GAAG,IAAI,iBAAQ,CAC3B,IAAI,CAAC,KAAK,EACV,oBAAU,EACV,iBAAiB,CACP,CAAC;YAEb,IAAI,IAAI,CAAC,QAAQ,KAAK,oBAAQ,CAAC,qBAAqB,EAAE;gBACpD,IAAI,CAAC,QAAQ,EAAE;oBAGP,WAAW,GAAG,kBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAC/C,SAAS,GAAG,kBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAEjD,sBAAO,WAAW,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAC;iBAC5D;gBACD,sBAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAC;aACvD;YAED,sBAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,EAAC;SAC7D;QAED,IAAI,IAAA,kBAAW,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YACxB,QAAQ,GAAG,IAAI,iBAAQ,CAC3B,IAAI,CAAC,KAAK,EACV,gBAAQ,EACR,iBAAiB,CACT,CAAC;YACX,sBAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAC;SAClC;QAED,sBAAO,iBAAiB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAC;;KAC5C,CAAC;AA9DW,QAAA,SAAS,aA8DpB"}
@@ -1,108 +1,108 @@
1
- import { providers as multicallProviders } from "@0xsequence/multicall";
2
- import { BigNumber } from "ethers";
3
- import { ItemType } from "../constants";
4
- import type { InputCriteria, Item, OrderParameters } from "../types";
5
- import { getSummedTokenAndIdentifierAmounts, TimeBasedItemParams } from "./item";
6
- export declare type BalancesAndApprovals = {
7
- token: string;
8
- identifierOrCriteria: string;
9
- balance: BigNumber;
10
- approvedAmount: BigNumber;
11
- itemType: ItemType;
12
- }[];
13
- export declare type InsufficientBalances = {
14
- token: string;
15
- identifierOrCriteria: string;
16
- requiredAmount: BigNumber;
17
- amountHave: BigNumber;
18
- itemType: ItemType;
19
- }[];
20
- export declare type InsufficientApprovals = {
21
- token: string;
22
- identifierOrCriteria: string;
23
- approvedAmount: BigNumber;
24
- requiredApprovedAmount: BigNumber;
25
- operator: string;
26
- itemType: ItemType;
27
- }[];
28
- export declare const getBalancesAndApprovals: ({ owner, items, criterias, operator, multicallProvider, }: {
29
- owner: string;
30
- items: Item[];
31
- criterias: InputCriteria[];
32
- operator: string;
33
- multicallProvider: multicallProviders.MulticallProvider;
34
- }) => Promise<BalancesAndApprovals>;
35
- export declare const getInsufficientBalanceAndApprovalAmounts: ({ balancesAndApprovals, tokenAndIdentifierAmounts, operator, }: {
36
- balancesAndApprovals: BalancesAndApprovals;
37
- tokenAndIdentifierAmounts: ReturnType<typeof getSummedTokenAndIdentifierAmounts>;
38
- operator: string;
39
- }) => {
40
- insufficientBalances: InsufficientBalances;
41
- insufficientApprovals: InsufficientApprovals;
42
- };
43
- /**
44
- * 1. The offerer should have sufficient balance of all offered items.
45
- * 2. If the order does not indicate proxy utilization, the offerer should have sufficient approvals set
46
- * for the Seaport contract for all offered ERC20, ERC721, and ERC1155 items.
47
- * 3. If the order does indicate proxy utilization, the offerer should have sufficient approvals set
48
- * for their respective proxy contract for all offered ERC20, ERC721, and ERC1155 items.
49
- */
50
- export declare const validateOfferBalancesAndApprovals: ({ offer, criterias, balancesAndApprovals, timeBasedItemParams, throwOnInsufficientBalances, throwOnInsufficientApprovals, operator, }: {
51
- balancesAndApprovals: BalancesAndApprovals;
52
- timeBasedItemParams?: TimeBasedItemParams | undefined;
53
- throwOnInsufficientBalances?: boolean | undefined;
54
- throwOnInsufficientApprovals?: boolean | undefined;
55
- operator: string;
56
- } & Pick<OrderParameters, "offer"> & {
57
- criterias: InputCriteria[];
58
- }) => InsufficientApprovals;
59
- /**
60
- * When fulfilling a basic order, the following requirements need to be checked to ensure that the order will be fulfillable:
61
- * 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
62
- * 2. The fulfiller should have sufficient balance of all consideration items except for those with an
63
- * item type that matches the order's offered item type — by way of example, if the fulfilled order offers
64
- * an ERC20 item and requires an ERC721 item to the offerer and the same ERC20 item to another recipient,
65
- * the fulfiller needs to own the ERC721 item but does not need to own the ERC20 item as it will be sourced from the offerer.
66
- * 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
67
- * Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order except
68
- * for ERC20 items with an item type that matches the order's offered item type.
69
- * 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
70
- * respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order
71
- * except for ERC20 items with an item type that matches the order's offered item type.
72
- * 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
73
- * be able to supply the sum total of those items as msg.value.
74
- *
75
- * @returns the list of insufficient owner and proxy approvals
76
- */
77
- export declare const validateBasicFulfillBalancesAndApprovals: ({ offer, consideration, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: {
78
- offererBalancesAndApprovals: BalancesAndApprovals;
79
- fulfillerBalancesAndApprovals: BalancesAndApprovals;
80
- timeBasedItemParams: TimeBasedItemParams;
81
- offererOperator: string;
82
- fulfillerOperator: string;
83
- } & Pick<OrderParameters, "offer" | "consideration">) => InsufficientApprovals;
84
- /**
85
- * When fulfilling a standard order, the following requirements need to be checked to ensure that the order will be fulfillable:
86
- * 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
87
- * 2. The fulfiller should have sufficient balance of all consideration items after receiving all offered items
88
- * — by way of example, if the fulfilled order offers an ERC20 item and requires an ERC721 item to the offerer
89
- * and the same ERC20 item to another recipient with an amount less than or equal to the offered amount,
90
- * the fulfiller does not need to own the ERC20 item as it will first be received from the offerer.
91
- * 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
92
- * Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
93
- * 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
94
- * respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
95
- * 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
96
- * be able to supply the sum total of those items as msg.value.
97
- *
98
- * @returns the list of insufficient owner and proxy approvals
99
- */
100
- export declare const validateStandardFulfillBalancesAndApprovals: ({ offer, consideration, offerCriteria, considerationCriteria, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: Pick<OrderParameters, "offer" | "consideration"> & {
101
- offerCriteria: InputCriteria[];
102
- considerationCriteria: InputCriteria[];
103
- offererBalancesAndApprovals: BalancesAndApprovals;
104
- fulfillerBalancesAndApprovals: BalancesAndApprovals;
105
- timeBasedItemParams: TimeBasedItemParams;
106
- offererOperator: string;
107
- fulfillerOperator: string;
108
- }) => InsufficientApprovals;
1
+ import { providers as multicallProviders } from "@0xsequence/multicall";
2
+ import { BigNumber } from "ethers";
3
+ import { ItemType } from "../constants";
4
+ import type { InputCriteria, Item, OrderParameters } from "../types";
5
+ import { getSummedTokenAndIdentifierAmounts, TimeBasedItemParams } from "./item";
6
+ export declare type BalancesAndApprovals = {
7
+ token: string;
8
+ identifierOrCriteria: string;
9
+ balance: BigNumber;
10
+ approvedAmount: BigNumber;
11
+ itemType: ItemType;
12
+ }[];
13
+ export declare type InsufficientBalances = {
14
+ token: string;
15
+ identifierOrCriteria: string;
16
+ requiredAmount: BigNumber;
17
+ amountHave: BigNumber;
18
+ itemType: ItemType;
19
+ }[];
20
+ export declare type InsufficientApprovals = {
21
+ token: string;
22
+ identifierOrCriteria: string;
23
+ approvedAmount: BigNumber;
24
+ requiredApprovedAmount: BigNumber;
25
+ operator: string;
26
+ itemType: ItemType;
27
+ }[];
28
+ export declare const getBalancesAndApprovals: ({ owner, items, criterias, operator, multicallProvider, }: {
29
+ owner: string;
30
+ items: Item[];
31
+ criterias: InputCriteria[];
32
+ operator: string;
33
+ multicallProvider: multicallProviders.MulticallProvider;
34
+ }) => Promise<BalancesAndApprovals>;
35
+ export declare const getInsufficientBalanceAndApprovalAmounts: ({ balancesAndApprovals, tokenAndIdentifierAmounts, operator, }: {
36
+ balancesAndApprovals: BalancesAndApprovals;
37
+ tokenAndIdentifierAmounts: ReturnType<typeof getSummedTokenAndIdentifierAmounts>;
38
+ operator: string;
39
+ }) => {
40
+ insufficientBalances: InsufficientBalances;
41
+ insufficientApprovals: InsufficientApprovals;
42
+ };
43
+ /**
44
+ * 1. The offerer should have sufficient balance of all offered items.
45
+ * 2. If the order does not indicate proxy utilization, the offerer should have sufficient approvals set
46
+ * for the Seaport contract for all offered ERC20, ERC721, and ERC1155 items.
47
+ * 3. If the order does indicate proxy utilization, the offerer should have sufficient approvals set
48
+ * for their respective proxy contract for all offered ERC20, ERC721, and ERC1155 items.
49
+ */
50
+ export declare const validateOfferBalancesAndApprovals: ({ offer, criterias, balancesAndApprovals, timeBasedItemParams, throwOnInsufficientBalances, throwOnInsufficientApprovals, operator, }: {
51
+ balancesAndApprovals: BalancesAndApprovals;
52
+ timeBasedItemParams?: TimeBasedItemParams | undefined;
53
+ throwOnInsufficientBalances?: boolean | undefined;
54
+ throwOnInsufficientApprovals?: boolean | undefined;
55
+ operator: string;
56
+ } & Pick<OrderParameters, "offer"> & {
57
+ criterias: InputCriteria[];
58
+ }) => InsufficientApprovals;
59
+ /**
60
+ * When fulfilling a basic order, the following requirements need to be checked to ensure that the order will be fulfillable:
61
+ * 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
62
+ * 2. The fulfiller should have sufficient balance of all consideration items except for those with an
63
+ * item type that matches the order's offered item type — by way of example, if the fulfilled order offers
64
+ * an ERC20 item and requires an ERC721 item to the offerer and the same ERC20 item to another recipient,
65
+ * the fulfiller needs to own the ERC721 item but does not need to own the ERC20 item as it will be sourced from the offerer.
66
+ * 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
67
+ * Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order except
68
+ * for ERC20 items with an item type that matches the order's offered item type.
69
+ * 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
70
+ * respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order
71
+ * except for ERC20 items with an item type that matches the order's offered item type.
72
+ * 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
73
+ * be able to supply the sum total of those items as msg.value.
74
+ *
75
+ * @returns the list of insufficient owner and proxy approvals
76
+ */
77
+ export declare const validateBasicFulfillBalancesAndApprovals: ({ offer, consideration, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: {
78
+ offererBalancesAndApprovals: BalancesAndApprovals;
79
+ fulfillerBalancesAndApprovals: BalancesAndApprovals;
80
+ timeBasedItemParams: TimeBasedItemParams;
81
+ offererOperator: string;
82
+ fulfillerOperator: string;
83
+ } & Pick<OrderParameters, "offer" | "consideration">) => InsufficientApprovals;
84
+ /**
85
+ * When fulfilling a standard order, the following requirements need to be checked to ensure that the order will be fulfillable:
86
+ * 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
87
+ * 2. The fulfiller should have sufficient balance of all consideration items after receiving all offered items
88
+ * — by way of example, if the fulfilled order offers an ERC20 item and requires an ERC721 item to the offerer
89
+ * and the same ERC20 item to another recipient with an amount less than or equal to the offered amount,
90
+ * the fulfiller does not need to own the ERC20 item as it will first be received from the offerer.
91
+ * 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
92
+ * Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
93
+ * 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
94
+ * respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
95
+ * 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
96
+ * be able to supply the sum total of those items as msg.value.
97
+ *
98
+ * @returns the list of insufficient owner and proxy approvals
99
+ */
100
+ export declare const validateStandardFulfillBalancesAndApprovals: ({ offer, consideration, offerCriteria, considerationCriteria, offererBalancesAndApprovals, fulfillerBalancesAndApprovals, timeBasedItemParams, offererOperator, fulfillerOperator, }: Pick<OrderParameters, "offer" | "consideration"> & {
101
+ offerCriteria: InputCriteria[];
102
+ considerationCriteria: InputCriteria[];
103
+ offererBalancesAndApprovals: BalancesAndApprovals;
104
+ fulfillerBalancesAndApprovals: BalancesAndApprovals;
105
+ timeBasedItemParams: TimeBasedItemParams;
106
+ offererOperator: string;
107
+ fulfillerOperator: string;
108
+ }) => InsufficientApprovals;
@@ -0,0 +1,322 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
66
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
67
+ if (ar || !(i in from)) {
68
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
69
+ ar[i] = from[i];
70
+ }
71
+ }
72
+ return to.concat(ar || Array.prototype.slice.call(from));
73
+ };
74
+ Object.defineProperty(exports, "__esModule", { value: true });
75
+ exports.validateStandardFulfillBalancesAndApprovals = exports.validateBasicFulfillBalancesAndApprovals = exports.validateOfferBalancesAndApprovals = exports.getInsufficientBalanceAndApprovalAmounts = exports.getBalancesAndApprovals = void 0;
76
+ var ethers_1 = require("ethers");
77
+ var constants_1 = require("../constants");
78
+ var approval_1 = require("./approval");
79
+ var balance_1 = require("./balance");
80
+ var criteria_1 = require("./criteria");
81
+ var item_1 = require("./item");
82
+ var findBalanceAndApproval = function (balancesAndApprovals, token, identifierOrCriteria) {
83
+ var balanceAndApproval = balancesAndApprovals.find(function (_a) {
84
+ var checkedToken = _a.token, checkedIdentifierOrCriteria = _a.identifierOrCriteria;
85
+ return token.toLowerCase() === checkedToken.toLowerCase() &&
86
+ checkedIdentifierOrCriteria.toLowerCase() ===
87
+ identifierOrCriteria.toLowerCase();
88
+ });
89
+ if (!balanceAndApproval) {
90
+ throw new Error("Balances and approvals didn't contain all tokens and identifiers");
91
+ }
92
+ return balanceAndApproval;
93
+ };
94
+ var getBalancesAndApprovals = function (_a) {
95
+ var owner = _a.owner, items = _a.items, criterias = _a.criterias, operator = _a.operator, multicallProvider = _a.multicallProvider;
96
+ return __awaiter(void 0, void 0, void 0, function () {
97
+ var itemToCriteria;
98
+ return __generator(this, function (_b) {
99
+ itemToCriteria = (0, criteria_1.getItemToCriteriaMap)(items, criterias);
100
+ return [2 /*return*/, Promise.all(items.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
101
+ var approvedAmountPromise;
102
+ var _a;
103
+ var _b, _c;
104
+ return __generator(this, function (_d) {
105
+ switch (_d.label) {
106
+ case 0:
107
+ approvedAmountPromise = Promise.resolve(ethers_1.BigNumber.from(0));
108
+ if ((0, item_1.isErc721Item)(item.itemType) || (0, item_1.isErc1155Item)(item.itemType)) {
109
+ approvedAmountPromise = (0, approval_1.approvedItemAmount)(owner, item, operator, multicallProvider);
110
+ }
111
+ else if ((0, item_1.isErc20Item)(item.itemType)) {
112
+ approvedAmountPromise = (0, approval_1.approvedItemAmount)(owner, item, operator, multicallProvider);
113
+ }
114
+ // If native token, we don't need to check for approvals
115
+ else {
116
+ approvedAmountPromise = Promise.resolve(constants_1.MAX_INT);
117
+ }
118
+ _a = {
119
+ token: item.token,
120
+ identifierOrCriteria: (_c = (_b = itemToCriteria.get(item)) === null || _b === void 0 ? void 0 : _b.identifier) !== null && _c !== void 0 ? _c : item.identifierOrCriteria
121
+ };
122
+ return [4 /*yield*/, (0, balance_1.balanceOf)(owner, item, multicallProvider, itemToCriteria.get(item))];
123
+ case 1:
124
+ _a.balance = _d.sent();
125
+ return [4 /*yield*/, approvedAmountPromise];
126
+ case 2: return [2 /*return*/, (_a.approvedAmount = _d.sent(),
127
+ _a.itemType = item.itemType,
128
+ _a)];
129
+ }
130
+ });
131
+ }); }))];
132
+ });
133
+ });
134
+ };
135
+ exports.getBalancesAndApprovals = getBalancesAndApprovals;
136
+ var getInsufficientBalanceAndApprovalAmounts = function (_a) {
137
+ var balancesAndApprovals = _a.balancesAndApprovals, tokenAndIdentifierAmounts = _a.tokenAndIdentifierAmounts, operator = _a.operator;
138
+ var tokenAndIdentifierAndAmountNeeded = __spreadArray([], __read(Object.entries(tokenAndIdentifierAmounts).map(function (_a) {
139
+ var _b = __read(_a, 2), token = _b[0], identifierToAmount = _b[1];
140
+ return Object.entries(identifierToAmount).map(function (_a) {
141
+ var _b = __read(_a, 2), identifierOrCriteria = _b[0], amountNeeded = _b[1];
142
+ return [token, identifierOrCriteria, amountNeeded];
143
+ });
144
+ })), false).flat();
145
+ var filterBalancesOrApprovals = function (filterKey) {
146
+ return tokenAndIdentifierAndAmountNeeded
147
+ .filter(function (_a) {
148
+ var _b = __read(_a, 3), token = _b[0], identifierOrCriteria = _b[1], amountNeeded = _b[2];
149
+ return findBalanceAndApproval(balancesAndApprovals, token, identifierOrCriteria)[filterKey].lt(amountNeeded);
150
+ })
151
+ .map(function (_a) {
152
+ var _b = __read(_a, 3), token = _b[0], identifierOrCriteria = _b[1], amount = _b[2];
153
+ var balanceAndApproval = findBalanceAndApproval(balancesAndApprovals, token, identifierOrCriteria);
154
+ return {
155
+ token: token,
156
+ identifierOrCriteria: identifierOrCriteria,
157
+ requiredAmount: amount,
158
+ amountHave: balanceAndApproval[filterKey],
159
+ itemType: balanceAndApproval.itemType,
160
+ };
161
+ });
162
+ };
163
+ var mapToApproval = function (insufficientBalance) { return ({
164
+ token: insufficientBalance.token,
165
+ identifierOrCriteria: insufficientBalance.identifierOrCriteria,
166
+ approvedAmount: insufficientBalance.amountHave,
167
+ requiredApprovedAmount: insufficientBalance.requiredAmount,
168
+ itemType: insufficientBalance.itemType,
169
+ operator: operator,
170
+ }); };
171
+ var _b = __read([
172
+ filterBalancesOrApprovals("balance"),
173
+ filterBalancesOrApprovals("approvedAmount").map(mapToApproval),
174
+ ], 2), insufficientBalances = _b[0], insufficientApprovals = _b[1];
175
+ return {
176
+ insufficientBalances: insufficientBalances,
177
+ insufficientApprovals: insufficientApprovals,
178
+ };
179
+ };
180
+ exports.getInsufficientBalanceAndApprovalAmounts = getInsufficientBalanceAndApprovalAmounts;
181
+ /**
182
+ * 1. The offerer should have sufficient balance of all offered items.
183
+ * 2. If the order does not indicate proxy utilization, the offerer should have sufficient approvals set
184
+ * for the Seaport contract for all offered ERC20, ERC721, and ERC1155 items.
185
+ * 3. If the order does indicate proxy utilization, the offerer should have sufficient approvals set
186
+ * for their respective proxy contract for all offered ERC20, ERC721, and ERC1155 items.
187
+ */
188
+ var validateOfferBalancesAndApprovals = function (_a) {
189
+ var offer = _a.offer, criterias = _a.criterias, balancesAndApprovals = _a.balancesAndApprovals, timeBasedItemParams = _a.timeBasedItemParams, _b = _a.throwOnInsufficientBalances, throwOnInsufficientBalances = _b === void 0 ? true : _b, throwOnInsufficientApprovals = _a.throwOnInsufficientApprovals, operator = _a.operator;
190
+ var _c = (0, exports.getInsufficientBalanceAndApprovalAmounts)({
191
+ balancesAndApprovals: balancesAndApprovals,
192
+ tokenAndIdentifierAmounts: (0, item_1.getSummedTokenAndIdentifierAmounts)({
193
+ items: offer,
194
+ criterias: criterias,
195
+ timeBasedItemParams: timeBasedItemParams
196
+ ? __assign(__assign({}, timeBasedItemParams), { isConsiderationItem: false }) : undefined,
197
+ }),
198
+ operator: operator,
199
+ }), insufficientBalances = _c.insufficientBalances, insufficientApprovals = _c.insufficientApprovals;
200
+ if (throwOnInsufficientBalances && insufficientBalances.length > 0) {
201
+ throw new Error("The offerer does not have the amount needed to create or fulfill.");
202
+ }
203
+ if (throwOnInsufficientApprovals && insufficientApprovals.length > 0) {
204
+ throw new Error("The offerer does not have the sufficient approvals.");
205
+ }
206
+ return insufficientApprovals;
207
+ };
208
+ exports.validateOfferBalancesAndApprovals = validateOfferBalancesAndApprovals;
209
+ /**
210
+ * When fulfilling a basic order, the following requirements need to be checked to ensure that the order will be fulfillable:
211
+ * 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
212
+ * 2. The fulfiller should have sufficient balance of all consideration items except for those with an
213
+ * item type that matches the order's offered item type — by way of example, if the fulfilled order offers
214
+ * an ERC20 item and requires an ERC721 item to the offerer and the same ERC20 item to another recipient,
215
+ * the fulfiller needs to own the ERC721 item but does not need to own the ERC20 item as it will be sourced from the offerer.
216
+ * 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
217
+ * Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order except
218
+ * for ERC20 items with an item type that matches the order's offered item type.
219
+ * 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
220
+ * respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order
221
+ * except for ERC20 items with an item type that matches the order's offered item type.
222
+ * 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
223
+ * be able to supply the sum total of those items as msg.value.
224
+ *
225
+ * @returns the list of insufficient owner and proxy approvals
226
+ */
227
+ var validateBasicFulfillBalancesAndApprovals = function (_a) {
228
+ var offer = _a.offer, consideration = _a.consideration, offererBalancesAndApprovals = _a.offererBalancesAndApprovals, fulfillerBalancesAndApprovals = _a.fulfillerBalancesAndApprovals, timeBasedItemParams = _a.timeBasedItemParams, offererOperator = _a.offererOperator, fulfillerOperator = _a.fulfillerOperator;
229
+ (0, exports.validateOfferBalancesAndApprovals)({
230
+ offer: offer,
231
+ criterias: [],
232
+ balancesAndApprovals: offererBalancesAndApprovals,
233
+ timeBasedItemParams: timeBasedItemParams,
234
+ throwOnInsufficientApprovals: true,
235
+ operator: offererOperator,
236
+ });
237
+ var considerationWithoutOfferItemType = consideration.filter(function (item) { return item.itemType !== offer[0].itemType; });
238
+ var _b = (0, exports.getInsufficientBalanceAndApprovalAmounts)({
239
+ balancesAndApprovals: fulfillerBalancesAndApprovals,
240
+ tokenAndIdentifierAmounts: (0, item_1.getSummedTokenAndIdentifierAmounts)({
241
+ items: considerationWithoutOfferItemType,
242
+ criterias: [],
243
+ timeBasedItemParams: __assign(__assign({}, timeBasedItemParams), { isConsiderationItem: true }),
244
+ }),
245
+ operator: fulfillerOperator,
246
+ }), insufficientBalances = _b.insufficientBalances, insufficientApprovals = _b.insufficientApprovals;
247
+ if (insufficientBalances.length > 0) {
248
+ throw new Error("The fulfiller does not have the balances needed to fulfill.");
249
+ }
250
+ return insufficientApprovals;
251
+ };
252
+ exports.validateBasicFulfillBalancesAndApprovals = validateBasicFulfillBalancesAndApprovals;
253
+ /**
254
+ * When fulfilling a standard order, the following requirements need to be checked to ensure that the order will be fulfillable:
255
+ * 1. Offer checks need to be performed to ensure that the offerer still has sufficient balance and approvals
256
+ * 2. The fulfiller should have sufficient balance of all consideration items after receiving all offered items
257
+ * — by way of example, if the fulfilled order offers an ERC20 item and requires an ERC721 item to the offerer
258
+ * and the same ERC20 item to another recipient with an amount less than or equal to the offered amount,
259
+ * the fulfiller does not need to own the ERC20 item as it will first be received from the offerer.
260
+ * 3. If the fulfiller does not elect to utilize a proxy, they need to have sufficient approvals set for the
261
+ * Seaport contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
262
+ * 4. If the fulfiller does elect to utilize a proxy, they need to have sufficient approvals set for their
263
+ * respective proxy contract for all ERC20, ERC721, and ERC1155 consideration items on the fulfilled order.
264
+ * 5. If the fulfilled order specifies Ether (or other native tokens) as consideration items, the fulfiller must
265
+ * be able to supply the sum total of those items as msg.value.
266
+ *
267
+ * @returns the list of insufficient owner and proxy approvals
268
+ */
269
+ var validateStandardFulfillBalancesAndApprovals = function (_a) {
270
+ var offer = _a.offer, consideration = _a.consideration, offerCriteria = _a.offerCriteria, considerationCriteria = _a.considerationCriteria, offererBalancesAndApprovals = _a.offererBalancesAndApprovals, fulfillerBalancesAndApprovals = _a.fulfillerBalancesAndApprovals, timeBasedItemParams = _a.timeBasedItemParams, offererOperator = _a.offererOperator, fulfillerOperator = _a.fulfillerOperator;
271
+ (0, exports.validateOfferBalancesAndApprovals)({
272
+ offer: offer,
273
+ criterias: offerCriteria,
274
+ balancesAndApprovals: offererBalancesAndApprovals,
275
+ timeBasedItemParams: timeBasedItemParams,
276
+ throwOnInsufficientApprovals: true,
277
+ operator: offererOperator,
278
+ });
279
+ var fulfillerBalancesAndApprovalsAfterReceivingOfferedItems = addToExistingBalances({
280
+ items: offer,
281
+ criterias: offerCriteria,
282
+ balancesAndApprovals: fulfillerBalancesAndApprovals,
283
+ timeBasedItemParams: timeBasedItemParams,
284
+ });
285
+ var _b = (0, exports.getInsufficientBalanceAndApprovalAmounts)({
286
+ balancesAndApprovals: fulfillerBalancesAndApprovalsAfterReceivingOfferedItems,
287
+ tokenAndIdentifierAmounts: (0, item_1.getSummedTokenAndIdentifierAmounts)({
288
+ items: consideration,
289
+ criterias: considerationCriteria,
290
+ timeBasedItemParams: __assign(__assign({}, timeBasedItemParams), { isConsiderationItem: true }),
291
+ }),
292
+ operator: fulfillerOperator,
293
+ }), insufficientBalances = _b.insufficientBalances, insufficientApprovals = _b.insufficientApprovals;
294
+ if (insufficientBalances.length > 0) {
295
+ throw new Error("The fulfiller does not have the balances needed to fulfill.");
296
+ }
297
+ return insufficientApprovals;
298
+ };
299
+ exports.validateStandardFulfillBalancesAndApprovals = validateStandardFulfillBalancesAndApprovals;
300
+ var addToExistingBalances = function (_a) {
301
+ var items = _a.items, criterias = _a.criterias, timeBasedItemParams = _a.timeBasedItemParams, balancesAndApprovals = _a.balancesAndApprovals;
302
+ var summedItemAmounts = (0, item_1.getSummedTokenAndIdentifierAmounts)({
303
+ items: items,
304
+ criterias: criterias,
305
+ timeBasedItemParams: __assign(__assign({}, timeBasedItemParams), { isConsiderationItem: false }),
306
+ });
307
+ // Deep clone existing balances
308
+ var balancesAndApprovalsAfterReceivingItems = balancesAndApprovals.map(function (item) { return (__assign({}, item)); });
309
+ // Add each summed item amount to the existing balances as we may want tocheck balances after receiving all items
310
+ Object.entries(summedItemAmounts).forEach(function (_a) {
311
+ var _b = __read(_a, 2), token = _b[0], identifierOrCriteriaToAmount = _b[1];
312
+ return Object.entries(identifierOrCriteriaToAmount).forEach(function (_a) {
313
+ var _b = __read(_a, 2), identifierOrCriteria = _b[0], amount = _b[1];
314
+ var balanceAndApproval = findBalanceAndApproval(balancesAndApprovalsAfterReceivingItems, token, identifierOrCriteria);
315
+ var balanceAndApprovalIndex = balancesAndApprovalsAfterReceivingItems.indexOf(balanceAndApproval);
316
+ balancesAndApprovalsAfterReceivingItems[balanceAndApprovalIndex].balance =
317
+ balancesAndApprovalsAfterReceivingItems[balanceAndApprovalIndex].balance.add(amount);
318
+ });
319
+ });
320
+ return balancesAndApprovalsAfterReceivingItems;
321
+ };
322
+ //# sourceMappingURL=balanceAndApprovalCheck.js.map