@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 @@
1
+ {"version":3,"file":"Seaport.js","sourceRoot":"","sources":["../../src/typechain/Seaport.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import type { Listener } from "@ethersproject/providers";
2
+ import type { Event, EventFilter } from "ethers";
3
+ export interface TypedEvent<TArgsArray extends Array<any> = any, TArgsObject = any> extends Event {
4
+ args: TArgsArray & TArgsObject;
5
+ }
6
+ export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {
7
+ }
8
+ export interface TypedListener<TEvent extends TypedEvent> {
9
+ (...listenerArg: [...__TypechainArgsArray<TEvent>, TEvent]): void;
10
+ }
11
+ declare type __TypechainArgsArray<T> = T extends TypedEvent<infer U> ? U : never;
12
+ export interface OnEvent<TRes> {
13
+ <TEvent extends TypedEvent>(eventFilter: TypedEventFilter<TEvent>, listener: TypedListener<TEvent>): TRes;
14
+ (eventName: string, listener: Listener): TRes;
15
+ }
16
+ export declare type MinEthersFactory<C, ARGS> = {
17
+ deploy(...a: ARGS[]): Promise<C>;
18
+ };
19
+ export declare type GetContractTypeFromFactory<F> = F extends MinEthersFactory<infer C, any> ? C : never;
20
+ export declare type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any> ? Parameters<F["deploy"]> : never;
21
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/typechain/common.ts"],"names":[],"mappings":""}
package/lib/types.d.ts CHANGED
@@ -1,207 +1,221 @@
1
- import type { OrderStruct, Seaport as TypeChainSeaportContract } from "./typechain/Seaport";
2
- import { BigNumber, BigNumberish, Contract, ContractTransaction, Overrides, PayableOverrides, PopulatedTransaction } from "ethers";
3
- import { ItemType, OrderType } from "./constants";
4
- import type { ERC721 } from "./typechain/ERC721";
5
- import type { ERC20 } from "./typechain/ERC20";
6
- export declare type SeaportConfig = {
7
- ascendingAmountFulfillmentBuffer?: number;
8
- balanceAndApprovalChecksOnOrderCreation?: boolean;
9
- conduitKeyToConduit?: Record<string, string>;
10
- overrides?: {
11
- contractAddress?: string;
12
- defaultConduitKey?: string;
13
- };
14
- };
15
- export declare type OfferItem = {
16
- itemType: ItemType;
17
- token: string;
18
- identifierOrCriteria: string;
19
- startAmount: string;
20
- endAmount: string;
21
- };
22
- export declare type ConsiderationItem = {
23
- itemType: ItemType;
24
- token: string;
25
- identifierOrCriteria: string;
26
- startAmount: string;
27
- endAmount: string;
28
- recipient: string;
29
- };
30
- export declare type Item = OfferItem | ConsiderationItem;
31
- export declare type OrderParameters = {
32
- offerer: string;
33
- zone: string;
34
- orderType: OrderType;
35
- startTime: BigNumberish;
36
- endTime: BigNumberish;
37
- zoneHash: string;
38
- salt: string;
39
- offer: OfferItem[];
40
- consideration: ConsiderationItem[];
41
- totalOriginalConsiderationItems: BigNumberish;
42
- conduitKey: string;
43
- };
44
- export declare type OrderComponents = OrderParameters & {
45
- counter: number;
46
- };
47
- export declare type Order = {
48
- parameters: OrderParameters;
49
- signature: string;
50
- };
51
- export declare type AdvancedOrder = Order & {
52
- numerator: BigNumber;
53
- denominator: BigNumber;
54
- extraData: string;
55
- };
56
- export declare type BasicErc721Item = {
57
- itemType: ItemType.ERC721;
58
- token: string;
59
- identifier: string;
60
- };
61
- export declare type Erc721ItemWithCriteria = {
62
- itemType: ItemType.ERC721;
63
- token: string;
64
- identifiers: string[];
65
- amount?: string;
66
- endAmount?: string;
67
- };
68
- declare type Erc721Item = BasicErc721Item | Erc721ItemWithCriteria;
69
- export declare type BasicErc1155Item = {
70
- itemType: ItemType.ERC1155;
71
- token: string;
72
- identifier: string;
73
- amount: string;
74
- endAmount?: string;
75
- };
76
- export declare type Erc1155ItemWithCriteria = {
77
- itemType: ItemType.ERC1155;
78
- token: string;
79
- identifiers: string[];
80
- amount: string;
81
- endAmount?: string;
82
- };
83
- declare type Erc1155Item = BasicErc1155Item | Erc1155ItemWithCriteria;
84
- export declare type CurrencyItem = {
85
- token?: string;
86
- amount: string;
87
- endAmount?: string;
88
- };
89
- export declare type CreateInputItem = Erc721Item | Erc1155Item | CurrencyItem;
90
- export declare type ConsiderationInputItem = CreateInputItem & {
91
- recipient?: string;
92
- };
93
- export declare type TipInputItem = CreateInputItem & {
94
- recipient: string;
95
- };
96
- export declare type Fee = {
97
- recipient: string;
98
- basisPoints: number;
99
- };
100
- export declare type CreateOrderInput = {
101
- conduitKey?: string;
102
- zone?: string;
103
- startTime?: string;
104
- endTime?: string;
105
- offer: readonly CreateInputItem[];
106
- consideration: readonly ConsiderationInputItem[];
107
- counter?: number;
108
- fees?: readonly Fee[];
109
- allowPartialFills?: boolean;
110
- restrictedByZone?: boolean;
111
- useProxy?: boolean;
112
- salt?: string;
113
- };
114
- export declare type InputCriteria = {
115
- identifier: string;
116
- proof: string[];
117
- };
118
- export declare type OrderStatus = {
119
- isValidated: boolean;
120
- isCancelled: boolean;
121
- totalFilled: BigNumber;
122
- totalSize: BigNumber;
123
- };
124
- export declare type OrderWithCounter = {
125
- parameters: OrderComponents;
126
- signature: string;
127
- };
128
- export declare type ContractMethodReturnType<T extends Contract, U extends keyof T["callStatic"]> = Awaited<ReturnType<T["callStatic"][U]>>;
129
- export declare type TransactionMethods<T = unknown> = {
130
- buildTransaction: (overrides?: Overrides) => Promise<PopulatedTransaction>;
131
- callStatic: (overrides?: Overrides) => Promise<T>;
132
- estimateGas: (overrides?: Overrides) => Promise<BigNumber>;
133
- transact: (overrides?: Overrides) => Promise<ContractTransaction>;
134
- };
135
- export declare type ApprovalAction = {
136
- type: "approval";
137
- token: string;
138
- identifierOrCriteria: string;
139
- itemType: ItemType;
140
- operator: string;
141
- transactionMethods: TransactionMethods<ContractMethodReturnType<ERC721, "setApprovalForAll">> | TransactionMethods<ContractMethodReturnType<ERC20, "approve">>;
142
- };
143
- export declare type ExchangeAction<T = unknown> = {
144
- type: "exchange";
145
- transactionMethods: TransactionMethods<T>;
146
- };
147
- export declare type CreateOrderAction = {
148
- type: "create";
149
- getMessageToSign: () => Promise<string>;
150
- createOrder: () => Promise<OrderWithCounter>;
151
- };
152
- export declare type TransactionAction = ApprovalAction | ExchangeAction;
153
- export declare type CreateOrderActions = readonly [
154
- ...ApprovalAction[],
155
- CreateOrderAction
156
- ];
157
- export declare type OrderExchangeActions<T> = readonly [
158
- ...ApprovalAction[],
159
- ExchangeAction<T>
160
- ];
161
- export declare type OrderUseCase<T extends CreateOrderAction | ExchangeAction> = {
162
- actions: T extends CreateOrderAction ? CreateOrderActions : OrderExchangeActions<T extends ExchangeAction<infer U> ? U : never>;
163
- executeAllActions: () => Promise<T extends CreateOrderAction ? OrderWithCounter : ContractTransaction>;
164
- };
165
- export declare type FulfillmentComponent = {
166
- orderIndex: number;
167
- itemIndex: number;
168
- }[];
169
- export declare type Fulfillment = {
170
- offerComponents: FulfillmentComponent[];
171
- considerationComponents: FulfillmentComponent[];
172
- };
173
- declare type MatchOrdersFulfillmentComponent = {
174
- orderIndex: number;
175
- itemIndex: number;
176
- };
177
- export declare type MatchOrdersFulfillment = {
178
- offerComponents: MatchOrdersFulfillmentComponent[];
179
- considerationComponents: MatchOrdersFulfillmentComponent[];
180
- };
181
- export declare type SeaportContract = TypeChainSeaportContract & {
182
- encodeFunctionData(functionFragment: "matchOrders", values: [OrderStruct[], MatchOrdersFulfillment[]]): string;
183
- matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
184
- from?: string | Promise<string>;
185
- }): Promise<ContractTransaction>;
186
- functions: TypeChainSeaportContract["functions"] & {
187
- matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
188
- from?: string | Promise<string>;
189
- }): Promise<ContractTransaction>;
190
- };
191
- callStatic: TypeChainSeaportContract["callStatic"] & {
192
- matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
193
- from?: string | Promise<string>;
194
- }): Promise<ContractTransaction>;
195
- };
196
- estimateGas: TypeChainSeaportContract["estimateGas"] & {
197
- matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
198
- from?: string | Promise<string>;
199
- }): Promise<BigNumber>;
200
- };
201
- populateTranscation: TypeChainSeaportContract["populateTransaction"] & {
202
- matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
203
- from?: string | Promise<string>;
204
- }): Promise<PopulatedTransaction>;
205
- };
206
- };
207
- export {};
1
+ import type { OrderStruct, Seaport as TypeChainSeaportContract } from "./typechain/Seaport";
2
+ import { BigNumber, BigNumberish, BytesLike, Contract, ContractTransaction, ethers, Overrides, PayableOverrides, PopulatedTransaction } from "ethers";
3
+ import { ItemType, OrderType } from "./constants";
4
+ import type { ERC721 } from "./typechain/ERC721";
5
+ import type { ERC20 } from "./typechain/ERC20";
6
+ export declare type SeaportConfig = {
7
+ ascendingAmountFulfillmentBuffer?: number;
8
+ balanceAndApprovalChecksOnOrderCreation?: boolean;
9
+ conduitKeyToConduit?: Record<string, string>;
10
+ overrides?: {
11
+ contractAddress?: string;
12
+ defaultConduitKey?: string;
13
+ };
14
+ };
15
+ declare type TypedDataDomain = {
16
+ name?: string;
17
+ version?: string;
18
+ chainId?: BigNumberish;
19
+ verifyingContract?: string;
20
+ salt?: BytesLike;
21
+ };
22
+ declare type TypedDataField = {
23
+ name: string;
24
+ type: string;
25
+ };
26
+ export declare type Signer = ethers.Signer & {
27
+ _signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
28
+ };
29
+ export declare type OfferItem = {
30
+ itemType: ItemType;
31
+ token: string;
32
+ identifierOrCriteria: string;
33
+ startAmount: string;
34
+ endAmount: string;
35
+ };
36
+ export declare type ConsiderationItem = {
37
+ itemType: ItemType;
38
+ token: string;
39
+ identifierOrCriteria: string;
40
+ startAmount: string;
41
+ endAmount: string;
42
+ recipient: string;
43
+ };
44
+ export declare type Item = OfferItem | ConsiderationItem;
45
+ export declare type OrderParameters = {
46
+ offerer: string;
47
+ zone: string;
48
+ orderType: OrderType;
49
+ startTime: BigNumberish;
50
+ endTime: BigNumberish;
51
+ zoneHash: string;
52
+ salt: string;
53
+ offer: OfferItem[];
54
+ consideration: ConsiderationItem[];
55
+ totalOriginalConsiderationItems: BigNumberish;
56
+ conduitKey: string;
57
+ };
58
+ export declare type OrderComponents = OrderParameters & {
59
+ counter: number;
60
+ };
61
+ export declare type Order = {
62
+ parameters: OrderParameters;
63
+ signature: string;
64
+ };
65
+ export declare type AdvancedOrder = Order & {
66
+ numerator: BigNumber;
67
+ denominator: BigNumber;
68
+ extraData: string;
69
+ };
70
+ export declare type BasicErc721Item = {
71
+ itemType: ItemType.ERC721;
72
+ token: string;
73
+ identifier: string;
74
+ };
75
+ export declare type Erc721ItemWithCriteria = {
76
+ itemType: ItemType.ERC721;
77
+ token: string;
78
+ identifiers: string[];
79
+ amount?: string;
80
+ endAmount?: string;
81
+ };
82
+ declare type Erc721Item = BasicErc721Item | Erc721ItemWithCriteria;
83
+ export declare type BasicErc1155Item = {
84
+ itemType: ItemType.ERC1155;
85
+ token: string;
86
+ identifier: string;
87
+ amount: string;
88
+ endAmount?: string;
89
+ };
90
+ export declare type Erc1155ItemWithCriteria = {
91
+ itemType: ItemType.ERC1155;
92
+ token: string;
93
+ identifiers: string[];
94
+ amount: string;
95
+ endAmount?: string;
96
+ };
97
+ declare type Erc1155Item = BasicErc1155Item | Erc1155ItemWithCriteria;
98
+ export declare type CurrencyItem = {
99
+ token?: string;
100
+ amount: string;
101
+ endAmount?: string;
102
+ };
103
+ export declare type CreateInputItem = Erc721Item | Erc1155Item | CurrencyItem;
104
+ export declare type ConsiderationInputItem = CreateInputItem & {
105
+ recipient?: string;
106
+ };
107
+ export declare type TipInputItem = CreateInputItem & {
108
+ recipient: string;
109
+ };
110
+ export declare type Fee = {
111
+ recipient: string;
112
+ basisPoints: number;
113
+ };
114
+ export declare type CreateOrderInput = {
115
+ conduitKey?: string;
116
+ zone?: string;
117
+ startTime?: string;
118
+ endTime?: string;
119
+ offer: readonly CreateInputItem[];
120
+ consideration: readonly ConsiderationInputItem[];
121
+ counter?: number;
122
+ fees?: readonly Fee[];
123
+ allowPartialFills?: boolean;
124
+ restrictedByZone?: boolean;
125
+ useProxy?: boolean;
126
+ salt?: string;
127
+ };
128
+ export declare type InputCriteria = {
129
+ identifier: string;
130
+ proof: string[];
131
+ };
132
+ export declare type OrderStatus = {
133
+ isValidated: boolean;
134
+ isCancelled: boolean;
135
+ totalFilled: BigNumber;
136
+ totalSize: BigNumber;
137
+ };
138
+ export declare type OrderWithCounter = {
139
+ parameters: OrderComponents;
140
+ signature: string;
141
+ };
142
+ export declare type ContractMethodReturnType<T extends Contract, U extends keyof T["callStatic"]> = Awaited<ReturnType<T["callStatic"][U]>>;
143
+ export declare type TransactionMethods<T = unknown> = {
144
+ buildTransaction: (overrides?: Overrides) => Promise<PopulatedTransaction>;
145
+ callStatic: (overrides?: Overrides) => Promise<T>;
146
+ estimateGas: (overrides?: Overrides) => Promise<BigNumber>;
147
+ transact: (overrides?: Overrides) => Promise<ContractTransaction>;
148
+ };
149
+ export declare type ApprovalAction = {
150
+ type: "approval";
151
+ token: string;
152
+ identifierOrCriteria: string;
153
+ itemType: ItemType;
154
+ operator: string;
155
+ transactionMethods: TransactionMethods<ContractMethodReturnType<ERC721, "setApprovalForAll">> | TransactionMethods<ContractMethodReturnType<ERC20, "approve">>;
156
+ };
157
+ export declare type ExchangeAction<T = unknown> = {
158
+ type: "exchange";
159
+ transactionMethods: TransactionMethods<T>;
160
+ };
161
+ export declare type CreateOrderAction = {
162
+ type: "create";
163
+ getMessageToSign: () => Promise<string>;
164
+ createOrder: () => Promise<OrderWithCounter>;
165
+ };
166
+ export declare type TransactionAction = ApprovalAction | ExchangeAction;
167
+ export declare type CreateOrderActions = readonly [
168
+ ...ApprovalAction[],
169
+ CreateOrderAction
170
+ ];
171
+ export declare type OrderExchangeActions<T> = readonly [
172
+ ...ApprovalAction[],
173
+ ExchangeAction<T>
174
+ ];
175
+ export declare type OrderUseCase<T extends CreateOrderAction | ExchangeAction> = {
176
+ actions: T extends CreateOrderAction ? CreateOrderActions : OrderExchangeActions<T extends ExchangeAction<infer U> ? U : never>;
177
+ executeAllActions: () => Promise<T extends CreateOrderAction ? OrderWithCounter : ContractTransaction>;
178
+ };
179
+ export declare type FulfillmentComponent = {
180
+ orderIndex: number;
181
+ itemIndex: number;
182
+ }[];
183
+ export declare type Fulfillment = {
184
+ offerComponents: FulfillmentComponent[];
185
+ considerationComponents: FulfillmentComponent[];
186
+ };
187
+ declare type MatchOrdersFulfillmentComponent = {
188
+ orderIndex: number;
189
+ itemIndex: number;
190
+ };
191
+ export declare type MatchOrdersFulfillment = {
192
+ offerComponents: MatchOrdersFulfillmentComponent[];
193
+ considerationComponents: MatchOrdersFulfillmentComponent[];
194
+ };
195
+ export declare type SeaportContract = TypeChainSeaportContract & {
196
+ encodeFunctionData(functionFragment: "matchOrders", values: [OrderStruct[], MatchOrdersFulfillment[]]): string;
197
+ matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
198
+ from?: string | Promise<string>;
199
+ }): Promise<ContractTransaction>;
200
+ functions: TypeChainSeaportContract["functions"] & {
201
+ matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
202
+ from?: string | Promise<string>;
203
+ }): Promise<ContractTransaction>;
204
+ };
205
+ callStatic: TypeChainSeaportContract["callStatic"] & {
206
+ matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
207
+ from?: string | Promise<string>;
208
+ }): Promise<ContractTransaction>;
209
+ };
210
+ estimateGas: TypeChainSeaportContract["estimateGas"] & {
211
+ matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
212
+ from?: string | Promise<string>;
213
+ }): Promise<BigNumber>;
214
+ };
215
+ populateTranscation: TypeChainSeaportContract["populateTransaction"] & {
216
+ matchOrders(orders: OrderStruct[], fulfillments: MatchOrdersFulfillment[], overrides?: PayableOverrides & {
217
+ from?: string | Promise<string>;
218
+ }): Promise<PopulatedTransaction>;
219
+ };
220
+ };
221
+ export {};
package/lib/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,9 +1,9 @@
1
- import { providers as multicallProviders } from "@0xsequence/multicall";
2
- import { BigNumber, providers } from "ethers";
3
- import type { ApprovalAction, Item } from "../types";
4
- import type { InsufficientApprovals } from "./balanceAndApprovalCheck";
5
- export declare const approvedItemAmount: (owner: string, item: Item, operator: string, multicallProvider: multicallProviders.MulticallProvider) => Promise<BigNumber>;
6
- /**
7
- * Get approval actions given a list of insufficent approvals.
8
- */
9
- export declare function getApprovalActions(insufficientApprovals: InsufficientApprovals, signer: providers.JsonRpcSigner): Promise<ApprovalAction[]>;
1
+ import { providers as multicallProviders } from "@0xsequence/multicall";
2
+ import { BigNumber, Signer } from "ethers";
3
+ import type { ApprovalAction, Item } from "../types";
4
+ import type { InsufficientApprovals } from "./balanceAndApprovalCheck";
5
+ export declare const approvedItemAmount: (owner: string, item: Item, operator: string, multicallProvider: multicallProviders.MulticallProvider) => Promise<BigNumber>;
6
+ /**
7
+ * Get approval actions given a list of insufficent approvals.
8
+ */
9
+ export declare function getApprovalActions(insufficientApprovals: InsufficientApprovals, signer: Signer): Promise<ApprovalAction[]>;
@@ -0,0 +1,108 @@
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.getApprovalActions = exports.approvedItemAmount = void 0;
40
+ var ethers_1 = require("ethers");
41
+ var ERC20_1 = require("../abi/ERC20");
42
+ var ERC721_1 = require("../abi/ERC721");
43
+ var constants_1 = require("../constants");
44
+ var item_1 = require("./item");
45
+ var usecase_1 = require("./usecase");
46
+ var approvedItemAmount = function (owner, item, operator, multicallProvider) { return __awaiter(void 0, void 0, void 0, function () {
47
+ var contract, contract;
48
+ return __generator(this, function (_a) {
49
+ if ((0, item_1.isErc721Item)(item.itemType) || (0, item_1.isErc1155Item)(item.itemType)) {
50
+ contract = new ethers_1.Contract(item.token, ERC721_1.ERC721ABI, multicallProvider);
51
+ return [2 /*return*/, contract.isApprovedForAll(owner, operator).then(function (isApprovedForAll) {
52
+ // Setting to the max int to consolidate types and simplify
53
+ return isApprovedForAll ? constants_1.MAX_INT : ethers_1.BigNumber.from(0);
54
+ })];
55
+ }
56
+ else if (item.itemType === constants_1.ItemType.ERC20) {
57
+ contract = new ethers_1.Contract(item.token, ERC20_1.ERC20ABI, multicallProvider);
58
+ return [2 /*return*/, contract.allowance(owner, operator)];
59
+ }
60
+ // We don't need to check approvals for native tokens
61
+ return [2 /*return*/, constants_1.MAX_INT];
62
+ });
63
+ }); };
64
+ exports.approvedItemAmount = approvedItemAmount;
65
+ /**
66
+ * Get approval actions given a list of insufficent approvals.
67
+ */
68
+ function getApprovalActions(insufficientApprovals, signer) {
69
+ var _this = this;
70
+ return Promise.all(insufficientApprovals
71
+ .filter(function (approval, index) {
72
+ return index === insufficientApprovals.length - 1 ||
73
+ insufficientApprovals[index + 1].token !== approval.token;
74
+ })
75
+ .map(function (_a) {
76
+ var token = _a.token, operator = _a.operator, itemType = _a.itemType, identifierOrCriteria = _a.identifierOrCriteria;
77
+ return __awaiter(_this, void 0, void 0, function () {
78
+ var contract, contract;
79
+ return __generator(this, function (_b) {
80
+ if ((0, item_1.isErc721Item)(itemType) || (0, item_1.isErc1155Item)(itemType)) {
81
+ contract = new ethers_1.Contract(token, ERC721_1.ERC721ABI, signer);
82
+ return [2 /*return*/, {
83
+ type: "approval",
84
+ token: token,
85
+ identifierOrCriteria: identifierOrCriteria,
86
+ itemType: itemType,
87
+ operator: operator,
88
+ transactionMethods: (0, usecase_1.getTransactionMethods)(contract.connect(signer), "setApprovalForAll", [operator, true]),
89
+ }];
90
+ }
91
+ else {
92
+ contract = new ethers_1.Contract(token, ERC20_1.ERC20ABI, signer);
93
+ return [2 /*return*/, {
94
+ type: "approval",
95
+ token: token,
96
+ identifierOrCriteria: identifierOrCriteria,
97
+ itemType: itemType,
98
+ transactionMethods: (0, usecase_1.getTransactionMethods)(contract.connect(signer), "approve", [operator, constants_1.MAX_INT]),
99
+ operator: operator,
100
+ }];
101
+ }
102
+ return [2 /*return*/];
103
+ });
104
+ });
105
+ }));
106
+ }
107
+ exports.getApprovalActions = getApprovalActions;
108
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../src/utils/approval.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iCAAqD;AACrD,sCAAwC;AACxC,wCAA0C;AAC1C,0CAAiD;AAKjD,+BAAqD;AACrD,qCAAkD;AAE3C,IAAM,kBAAkB,GAAG,UAChC,KAAa,EACb,IAAU,EACV,QAAgB,EAChB,iBAAuD;;;QAEvD,IAAI,IAAA,mBAAY,EAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAA,oBAAa,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAEzD,QAAQ,GAAG,IAAI,iBAAQ,CAC3B,IAAI,CAAC,KAAK,EACV,kBAAS,EACT,iBAAiB,CACR,CAAC;YACZ,sBAAO,QAAQ,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAC,gBAAgB;oBACtE,2DAA2D;oBAC3D,OAAA,gBAAgB,CAAC,CAAC,CAAC,mBAAO,CAAC,CAAC,CAAC,kBAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBAA9C,CAA8C,CAC/C,EAAC;SACH;aAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,oBAAQ,CAAC,KAAK,EAAE;YACrC,QAAQ,GAAG,IAAI,iBAAQ,CAC3B,IAAI,CAAC,KAAK,EACV,gBAAQ,EACR,iBAAiB,CACT,CAAC;YAEX,sBAAO,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAC;SAC5C;QAED,qDAAqD;QACrD,sBAAO,mBAAO,EAAC;;KAChB,CAAC;AA7BW,QAAA,kBAAkB,sBA6B7B;AAEF;;GAEG;AACH,SAAgB,kBAAkB,CAChC,qBAA4C,EAC5C,MAAc;IAFhB,iBA8CC;IA1CC,OAAO,OAAO,CAAC,GAAG,CAChB,qBAAqB;SAClB,MAAM,CACL,UAAC,QAAQ,EAAE,KAAK;QACd,OAAA,KAAK,KAAK,qBAAqB,CAAC,MAAM,GAAG,CAAC;YAC1C,qBAAqB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,KAAK;IADzD,CACyD,CAC5D;SACA,GAAG,CAAC,UAAO,EAAmD;YAAjD,KAAK,WAAA,EAAE,QAAQ,cAAA,EAAE,QAAQ,cAAA,EAAE,oBAAoB,0BAAA;;;;gBAC3D,IAAI,IAAA,mBAAY,EAAC,QAAQ,CAAC,IAAI,IAAA,oBAAa,EAAC,QAAQ,CAAC,EAAE;oBAE/C,QAAQ,GAAG,IAAI,iBAAQ,CAAC,KAAK,EAAE,kBAAS,EAAE,MAAM,CAAW,CAAC;oBAElE,sBAAO;4BACL,IAAI,EAAE,UAAU;4BAChB,KAAK,OAAA;4BACL,oBAAoB,sBAAA;4BACpB,QAAQ,UAAA;4BACR,QAAQ,UAAA;4BACR,kBAAkB,EAAE,IAAA,+BAAqB,EACvC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EACxB,mBAAmB,EACnB,CAAC,QAAQ,EAAE,IAAI,CAAC,CACjB;yBACF,EAAC;iBACH;qBAAM;oBACC,QAAQ,GAAG,IAAI,iBAAQ,CAAC,KAAK,EAAE,gBAAQ,EAAE,MAAM,CAAU,CAAC;oBAEhE,sBAAO;4BACL,IAAI,EAAE,UAAU;4BAChB,KAAK,OAAA;4BACL,oBAAoB,sBAAA;4BACpB,QAAQ,UAAA;4BACR,kBAAkB,EAAE,IAAA,+BAAqB,EACvC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EACxB,SAAS,EACT,CAAC,QAAQ,EAAE,mBAAO,CAAC,CACpB;4BACD,QAAQ,UAAA;yBACT,EAAC;iBACH;;;;KACF,CAAC,CACL,CAAC;AACJ,CAAC;AA9CD,gDA8CC"}
@@ -1,4 +1,4 @@
1
- import { providers as multicallProviders } from "@0xsequence/multicall";
2
- import { BigNumber } from "ethers";
3
- import type { InputCriteria, Item } from "../types";
4
- export declare const balanceOf: (owner: string, item: Item, multicallProvider: multicallProviders.MulticallProvider, criteria?: InputCriteria | undefined) => Promise<BigNumber>;
1
+ import { providers as multicallProviders } from "@0xsequence/multicall";
2
+ import { BigNumber } from "ethers";
3
+ import type { InputCriteria, Item } from "../types";
4
+ export declare const balanceOf: (owner: string, item: Item, multicallProvider: multicallProviders.MulticallProvider, criteria?: InputCriteria | undefined) => Promise<BigNumber>;