@bosonprotocol/core-sdk 1.25.0-alpha.12 → 1.25.0-alpha.14

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 (162) hide show
  1. package/dist/cjs/accounts/mixin.d.ts +4 -4
  2. package/dist/cjs/accounts/mixin.d.ts.map +1 -1
  3. package/dist/cjs/accounts/mixin.js +8 -8
  4. package/dist/cjs/accounts/mixin.js.map +1 -1
  5. package/dist/cjs/accounts/subgraph.d.ts +1 -1
  6. package/dist/cjs/accounts/subgraph.d.ts.map +1 -1
  7. package/dist/cjs/accounts/subgraph.js +7 -7
  8. package/dist/cjs/accounts/subgraph.js.map +1 -1
  9. package/dist/cjs/accounts/types.d.ts +1 -1
  10. package/dist/cjs/accounts/types.d.ts.map +1 -1
  11. package/dist/cjs/exchanges/handler.js +12 -12
  12. package/dist/cjs/exchanges/handler.js.map +1 -1
  13. package/dist/cjs/exchanges/mixin.d.ts +3 -3
  14. package/dist/cjs/exchanges/mixin.js +3 -3
  15. package/dist/cjs/index.d.ts +1 -0
  16. package/dist/cjs/index.d.ts.map +1 -1
  17. package/dist/cjs/index.js +2 -1
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/meta-tx/handler.d.ts +25 -0
  20. package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
  21. package/dist/cjs/meta-tx/handler.js +42 -2
  22. package/dist/cjs/meta-tx/handler.js.map +1 -1
  23. package/dist/cjs/meta-tx/mixin.d.ts +23 -1
  24. package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
  25. package/dist/cjs/meta-tx/mixin.js +64 -1
  26. package/dist/cjs/meta-tx/mixin.js.map +1 -1
  27. package/dist/cjs/offers/handler.d.ts +15 -0
  28. package/dist/cjs/offers/handler.d.ts.map +1 -1
  29. package/dist/cjs/offers/handler.js +28 -4
  30. package/dist/cjs/offers/handler.js.map +1 -1
  31. package/dist/cjs/offers/interface.d.ts +1 -1
  32. package/dist/cjs/offers/interface.d.ts.map +1 -1
  33. package/dist/cjs/offers/interface.js +3 -2
  34. package/dist/cjs/offers/interface.js.map +1 -1
  35. package/dist/cjs/offers/mixin.d.ts +26 -3
  36. package/dist/cjs/offers/mixin.d.ts.map +1 -1
  37. package/dist/cjs/offers/mixin.js +46 -3
  38. package/dist/cjs/offers/mixin.js.map +1 -1
  39. package/dist/cjs/offers/renderContractualAgreement.d.ts.map +1 -1
  40. package/dist/cjs/offers/renderContractualAgreement.js +5 -4
  41. package/dist/cjs/offers/renderContractualAgreement.js.map +1 -1
  42. package/dist/cjs/seaport/abi.d.ts +41 -0
  43. package/dist/cjs/seaport/abi.d.ts.map +1 -0
  44. package/dist/cjs/seaport/abi.js +153 -0
  45. package/dist/cjs/seaport/abi.js.map +1 -0
  46. package/dist/cjs/seaport/handler.d.ts +46 -0
  47. package/dist/cjs/seaport/handler.d.ts.map +1 -0
  48. package/dist/cjs/seaport/handler.js +28 -0
  49. package/dist/cjs/seaport/handler.js.map +1 -0
  50. package/dist/cjs/seaport/index.d.ts +2 -0
  51. package/dist/cjs/seaport/index.d.ts.map +1 -0
  52. package/dist/cjs/seaport/index.js +28 -0
  53. package/dist/cjs/seaport/index.js.map +1 -0
  54. package/dist/cjs/subgraph.d.ts +945 -212
  55. package/dist/cjs/subgraph.d.ts.map +1 -1
  56. package/dist/cjs/subgraph.js +43 -17
  57. package/dist/cjs/subgraph.js.map +1 -1
  58. package/dist/cjs/voucher/handler.d.ts +17 -0
  59. package/dist/cjs/voucher/handler.d.ts.map +1 -1
  60. package/dist/cjs/voucher/handler.js +28 -1
  61. package/dist/cjs/voucher/handler.js.map +1 -1
  62. package/dist/cjs/voucher/interface.d.ts +3 -0
  63. package/dist/cjs/voucher/interface.d.ts.map +1 -1
  64. package/dist/cjs/voucher/interface.js +21 -1
  65. package/dist/cjs/voucher/interface.js.map +1 -1
  66. package/dist/cjs/voucher/mixin.d.ts +8 -0
  67. package/dist/cjs/voucher/mixin.d.ts.map +1 -1
  68. package/dist/cjs/voucher/mixin.js +36 -0
  69. package/dist/cjs/voucher/mixin.js.map +1 -1
  70. package/dist/esm/accounts/mixin.d.ts +4 -4
  71. package/dist/esm/accounts/mixin.d.ts.map +1 -1
  72. package/dist/esm/accounts/mixin.js +8 -8
  73. package/dist/esm/accounts/mixin.js.map +1 -1
  74. package/dist/esm/accounts/subgraph.d.ts +1 -1
  75. package/dist/esm/accounts/subgraph.d.ts.map +1 -1
  76. package/dist/esm/accounts/subgraph.js +5 -5
  77. package/dist/esm/accounts/subgraph.js.map +1 -1
  78. package/dist/esm/accounts/types.d.ts +1 -1
  79. package/dist/esm/accounts/types.d.ts.map +1 -1
  80. package/dist/esm/exchanges/handler.js +12 -12
  81. package/dist/esm/exchanges/handler.js.map +1 -1
  82. package/dist/esm/exchanges/mixin.d.ts +3 -3
  83. package/dist/esm/exchanges/mixin.js +3 -3
  84. package/dist/esm/index.d.ts +1 -0
  85. package/dist/esm/index.d.ts.map +1 -1
  86. package/dist/esm/index.js +1 -0
  87. package/dist/esm/index.js.map +1 -1
  88. package/dist/esm/meta-tx/handler.d.ts +25 -0
  89. package/dist/esm/meta-tx/handler.d.ts.map +1 -1
  90. package/dist/esm/meta-tx/handler.js +51 -3
  91. package/dist/esm/meta-tx/handler.js.map +1 -1
  92. package/dist/esm/meta-tx/mixin.d.ts +23 -1
  93. package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
  94. package/dist/esm/meta-tx/mixin.js +81 -1
  95. package/dist/esm/meta-tx/mixin.js.map +1 -1
  96. package/dist/esm/offers/handler.d.ts +15 -0
  97. package/dist/esm/offers/handler.d.ts.map +1 -1
  98. package/dist/esm/offers/handler.js +21 -3
  99. package/dist/esm/offers/handler.js.map +1 -1
  100. package/dist/esm/offers/interface.d.ts +1 -1
  101. package/dist/esm/offers/interface.d.ts.map +1 -1
  102. package/dist/esm/offers/interface.js +3 -2
  103. package/dist/esm/offers/interface.js.map +1 -1
  104. package/dist/esm/offers/mixin.d.ts +26 -3
  105. package/dist/esm/offers/mixin.d.ts.map +1 -1
  106. package/dist/esm/offers/mixin.js +42 -3
  107. package/dist/esm/offers/mixin.js.map +1 -1
  108. package/dist/esm/offers/renderContractualAgreement.d.ts.map +1 -1
  109. package/dist/esm/offers/renderContractualAgreement.js +5 -4
  110. package/dist/esm/offers/renderContractualAgreement.js.map +1 -1
  111. package/dist/esm/seaport/abi.d.ts +41 -0
  112. package/dist/esm/seaport/abi.d.ts.map +1 -0
  113. package/dist/esm/seaport/abi.js +150 -0
  114. package/dist/esm/seaport/abi.js.map +1 -0
  115. package/dist/esm/seaport/handler.d.ts +46 -0
  116. package/dist/esm/seaport/handler.d.ts.map +1 -0
  117. package/dist/esm/seaport/handler.js +24 -0
  118. package/dist/esm/seaport/handler.js.map +1 -0
  119. package/dist/esm/seaport/index.d.ts +2 -0
  120. package/dist/esm/seaport/index.d.ts.map +1 -0
  121. package/dist/esm/seaport/index.js +2 -0
  122. package/dist/esm/seaport/index.js.map +1 -0
  123. package/dist/esm/subgraph.d.ts +945 -212
  124. package/dist/esm/subgraph.d.ts.map +1 -1
  125. package/dist/esm/subgraph.js +40 -14
  126. package/dist/esm/subgraph.js.map +1 -1
  127. package/dist/esm/voucher/handler.d.ts +17 -0
  128. package/dist/esm/voucher/handler.d.ts.map +1 -1
  129. package/dist/esm/voucher/handler.js +19 -1
  130. package/dist/esm/voucher/handler.js.map +1 -1
  131. package/dist/esm/voucher/interface.d.ts +3 -0
  132. package/dist/esm/voucher/interface.d.ts.map +1 -1
  133. package/dist/esm/voucher/interface.js +17 -0
  134. package/dist/esm/voucher/interface.js.map +1 -1
  135. package/dist/esm/voucher/mixin.d.ts +8 -0
  136. package/dist/esm/voucher/mixin.d.ts.map +1 -1
  137. package/dist/esm/voucher/mixin.js +32 -0
  138. package/dist/esm/voucher/mixin.js.map +1 -1
  139. package/package.json +3 -3
  140. package/src/accounts/interface.ts +1 -1
  141. package/src/accounts/mixin.ts +15 -14
  142. package/src/accounts/queries.graphql +4 -4
  143. package/src/accounts/subgraph.ts +6 -6
  144. package/src/accounts/types.ts +1 -1
  145. package/src/exchanges/handler.ts +13 -13
  146. package/src/exchanges/mixin.ts +3 -3
  147. package/src/index.ts +1 -0
  148. package/src/meta-tx/handler.ts +108 -3
  149. package/src/meta-tx/mixin.ts +143 -3
  150. package/src/metadata/base.graphql +3 -0
  151. package/src/offers/handler.ts +36 -3
  152. package/src/offers/interface.ts +4 -2
  153. package/src/offers/mixin.ts +57 -2
  154. package/src/offers/queries.graphql +13 -0
  155. package/src/offers/renderContractualAgreement.ts +6 -9
  156. package/src/seaport/abi.ts +149 -0
  157. package/src/seaport/handler.ts +57 -0
  158. package/src/seaport/index.ts +1 -0
  159. package/src/subgraph.ts +977 -222
  160. package/src/voucher/handler.ts +39 -1
  161. package/src/voucher/interface.ts +23 -0
  162. package/src/voucher/mixin.ts +58 -0
@@ -34,17 +34,17 @@ export class AccountsMixin extends BaseCoreSDK {
34
34
 
35
35
  /**
36
36
  * Returns seller entity from subgraph.
37
- * @param operator - Operator address of seller entity to query for.
37
+ * @param assistant - Assistant address of seller entity to query for.
38
38
  * @param queryVars - Optional query variables to skip, order or filter.
39
39
  * @returns Seller entity from subgraph.
40
40
  */
41
- public async getSellerByOperator(
42
- operator: string,
41
+ public async getSellerByAssistant(
42
+ assistant: string,
43
43
  queryVars?: subgraph.GetSellersQueryQueryVariables
44
44
  ): Promise<subgraph.SellerFieldsFragment> {
45
- return accounts.subgraph.getSellerByOperator(
45
+ return accounts.subgraph.getSellerByAssistant(
46
46
  this._subgraphUrl,
47
- operator,
47
+ assistant,
48
48
  queryVars
49
49
  );
50
50
  }
@@ -101,7 +101,7 @@ export class AccountsMixin extends BaseCoreSDK {
101
101
  }
102
102
 
103
103
  /**
104
- * Returns seller entity from subgraph. Matches `operator`, `clerk`, `admin` or `treasury`.
104
+ * Returns seller entity from subgraph. Matches `assistant`, `clerk`, `admin` or `treasury`.
105
105
  * @param address - Address of seller entity to query for.
106
106
  * @param queryVars - Optional query variables to skip, order or filter.
107
107
  * @returns Seller entity from subgraph.
@@ -318,7 +318,8 @@ export class AccountsMixin extends BaseCoreSDK {
318
318
  await this._web3Lib.getSignerAddress()
319
319
  ).toLowerCase();
320
320
  const fieldsToUpdate = {
321
- operator: currentAccount === pendingSellerUpdate.operator?.toLowerCase(),
321
+ assistant:
322
+ currentAccount === pendingSellerUpdate.assistant?.toLowerCase(),
322
323
  clerk: currentAccount === pendingSellerUpdate.clerk?.toLowerCase(),
323
324
  admin: currentAccount === pendingSellerUpdate.admin?.toLowerCase(),
324
325
  authToken:
@@ -327,7 +328,7 @@ export class AccountsMixin extends BaseCoreSDK {
327
328
  pendingSellerUpdate.tokenType !== AuthTokenType.NONE
328
329
  };
329
330
  if (
330
- fieldsToUpdate.operator ||
331
+ fieldsToUpdate.assistant ||
331
332
  fieldsToUpdate.clerk ||
332
333
  fieldsToUpdate.admin ||
333
334
  fieldsToUpdate.authToken
@@ -335,8 +336,8 @@ export class AccountsMixin extends BaseCoreSDK {
335
336
  return this.optInToSellerUpdate({
336
337
  id: sellerUpdates.id,
337
338
  fieldsToUpdate: {
338
- operator:
339
- currentAccount === pendingSellerUpdate.operator.toLowerCase(),
339
+ assistant:
340
+ currentAccount === pendingSellerUpdate.assistant.toLowerCase(),
340
341
  clerk: currentAccount === pendingSellerUpdate.clerk.toLowerCase(),
341
342
  admin: currentAccount === pendingSellerUpdate.admin.toLowerCase(),
342
343
  authToken: pendingSellerUpdate.tokenType !== AuthTokenType.NONE
@@ -414,7 +415,7 @@ export class AccountsMixin extends BaseCoreSDK {
414
415
  * @returns Created exchange id.
415
416
  */
416
417
  public getPendingSellerUpdateFromLogs(logs: Log[]): {
417
- operator: string;
418
+ assistant: string;
418
419
  clerk: string;
419
420
  admin: string;
420
421
  tokenType: number;
@@ -424,7 +425,7 @@ export class AccountsMixin extends BaseCoreSDK {
424
425
  // SellerUpdatePending or SellerUpdateApplied events
425
426
  const valuesFromLogs = getValuesFromLogsExt<
426
427
  | {
427
- operator: string;
428
+ assistant: string;
428
429
  clerk: string;
429
430
  admin: string;
430
431
  }
@@ -440,7 +441,7 @@ export class AccountsMixin extends BaseCoreSDK {
440
441
  });
441
442
  const pendingSellerStruct = (
442
443
  valuesFromLogs["pendingSeller"] as {
443
- operator: string;
444
+ assistant: string;
444
445
  clerk: string;
445
446
  admin: string;
446
447
  }[]
@@ -452,7 +453,7 @@ export class AccountsMixin extends BaseCoreSDK {
452
453
  }[]
453
454
  )?.[0];
454
455
  return {
455
- operator: pendingSellerStruct?.operator,
456
+ assistant: pendingSellerStruct?.assistant,
456
457
  admin: pendingSellerStruct?.admin,
457
458
  clerk: pendingSellerStruct?.clerk,
458
459
  tokenId: pendingAuthTokenStruct?.tokenId,
@@ -235,7 +235,7 @@ fragment SellerFields on Seller {
235
235
 
236
236
  fragment BaseSellerFields on Seller {
237
237
  id
238
- operator
238
+ assistant
239
239
  admin
240
240
  clerk
241
241
  treasury
@@ -248,7 +248,7 @@ fragment BaseSellerFields on Seller {
248
248
  }
249
249
 
250
250
  fragment PendingSellerFields on PendingSeller {
251
- operator
251
+ assistant
252
252
  admin
253
253
  clerk
254
254
  authTokenId
@@ -323,7 +323,7 @@ fragment BaseDisputeResolverFields on DisputeResolver {
323
323
  admin
324
324
  clerk
325
325
  treasury
326
- operator
326
+ assistant
327
327
  metadataUri
328
328
  active
329
329
  sellerAllowList
@@ -333,7 +333,7 @@ fragment BaseDisputeResolverFields on DisputeResolver {
333
333
  }
334
334
 
335
335
  fragment PendingDisputeResolverFields on PendingDisputeResolver {
336
- operator
336
+ assistant
337
337
  admin
338
338
  clerk
339
339
  }
@@ -71,15 +71,15 @@ export async function getSellers(
71
71
  return sellers;
72
72
  }
73
73
 
74
- export async function getSellerByOperator(
74
+ export async function getSellerByAssistant(
75
75
  subgraphUrl: string,
76
- operatorAddress: string,
76
+ assistantAddress: string,
77
77
  queryVars: GetSellersQueryQueryVariables = {}
78
78
  ): Promise<SellerFieldsFragment | undefined> {
79
79
  const sellers = await getSellers(subgraphUrl, {
80
80
  sellersFilter: {
81
81
  ...queryVars.sellersFilter,
82
- operator: operatorAddress.toLowerCase()
82
+ assistant: assistantAddress.toLowerCase()
83
83
  },
84
84
  ...queryVars
85
85
  });
@@ -153,13 +153,13 @@ export async function getSellerByAddress(
153
153
  address: string,
154
154
  queryVars: GetSellersQueryQueryVariables = {}
155
155
  ): Promise<SellerFieldsFragment> {
156
- const [operator, admin, clerk] = await Promise.all([
157
- getSellerByOperator(subgraphUrl, address, queryVars),
156
+ const [assistant, admin, clerk] = await Promise.all([
157
+ getSellerByAssistant(subgraphUrl, address, queryVars),
158
158
  getSellerByAdmin(subgraphUrl, address, queryVars),
159
159
  getSellerByClerk(subgraphUrl, address, queryVars)
160
160
  ]);
161
161
 
162
- return operator || admin || clerk;
162
+ return assistant || admin || clerk;
163
163
  }
164
164
 
165
165
  export async function getDisputeResolverById(
@@ -18,7 +18,7 @@ export {
18
18
 
19
19
  export type CreateDisputeResolverArgs = {
20
20
  escalationResponsePeriodInMS: number;
21
- operator: string;
21
+ assistant: string;
22
22
  admin: string;
23
23
  clerk: string;
24
24
  treasury: string;
@@ -123,7 +123,7 @@ export async function revokeVoucher(
123
123
 
124
124
  assertExchange(args.exchangeId, exchange);
125
125
  assertExchangeState(exchange, ExchangeState.Committed);
126
- assertSignerIsOperator(signerAddress, exchange);
126
+ assertSignerIsAssistant(signerAddress, exchange);
127
127
 
128
128
  return args.web3Lib.sendTransaction({
129
129
  to: args.contractAddress,
@@ -218,13 +218,13 @@ function assertExchangeState(
218
218
  }
219
219
  }
220
220
 
221
- function assertSignerIsOperator(
221
+ function assertSignerIsAssistant(
222
222
  signer: string,
223
223
  exchange: ExchangeFieldsFragment
224
224
  ) {
225
- if (exchange.seller.operator.toLowerCase() !== signer.toLowerCase()) {
225
+ if (exchange.seller.assistant.toLowerCase() !== signer.toLowerCase()) {
226
226
  throw new Error(
227
- `Signer ${signer} is not the operator ${exchange.seller.operator}`
227
+ `Signer ${signer} is not the assistant ${exchange.seller.assistant}`
228
228
  );
229
229
  }
230
230
  }
@@ -237,24 +237,24 @@ function assertSignerIsBuyer(signer: string, exchange: ExchangeFieldsFragment) {
237
237
  }
238
238
  }
239
239
 
240
- function assertSignerIsBuyerOrOperator(
240
+ function assertSignerIsBuyerOrAssistant(
241
241
  signer: string,
242
242
  exchange: ExchangeFieldsFragment
243
243
  ) {
244
244
  const { seller, buyer } = exchange;
245
245
  const buyerAddress = buyer.wallet;
246
- const operatorAddress = seller.operator;
247
- const isSignerOperator =
248
- signer.toLowerCase() === operatorAddress.toLowerCase();
246
+ const assistantAddress = seller.assistant;
247
+ const isSignerAssistant =
248
+ signer.toLowerCase() === assistantAddress.toLowerCase();
249
249
  const isSignerBuyer = signer.toLowerCase() === buyerAddress.toLowerCase();
250
250
 
251
- if (!isSignerOperator && !isSignerBuyer) {
251
+ if (!isSignerAssistant && !isSignerBuyer) {
252
252
  throw new Error(
253
- `Signer ${signer} is required to be the buyer ${buyerAddress} or operator ${operatorAddress}`
253
+ `Signer ${signer} is required to be the buyer ${buyerAddress} or assistant ${assistantAddress}`
254
254
  );
255
255
  }
256
256
 
257
- return { isSignerBuyer, isSignerOperator };
257
+ return { isSignerBuyer, isSignerAssistant };
258
258
  }
259
259
 
260
260
  function assertCompletableExchange(
@@ -264,12 +264,12 @@ function assertCompletableExchange(
264
264
  ) {
265
265
  assertExchange(exchangeId, exchange);
266
266
 
267
- const { isSignerOperator, isSignerBuyer } = assertSignerIsBuyerOrOperator(
267
+ const { isSignerAssistant, isSignerBuyer } = assertSignerIsBuyerOrAssistant(
268
268
  signer,
269
269
  exchange
270
270
  );
271
271
 
272
- if (isSignerOperator && !isSignerBuyer) {
272
+ if (isSignerAssistant && !isSignerBuyer) {
273
273
  const elapsedSinceRedeemMS =
274
274
  Date.now() - Number(exchange.redeemedDate || "0") * 1000;
275
275
  const didDisputePeriodElapse =
@@ -83,7 +83,7 @@ export class ExchangesMixin extends BaseCoreSDK {
83
83
 
84
84
  /**
85
85
  * Revokes an existing voucher by calling the `ExchangeHandlerContract`.
86
- * Callable by seller `operator`.
86
+ * Callable by seller `assistant`.
87
87
  * @param exchangeId - ID of exchange to revoke.
88
88
  * @returns Transaction response.
89
89
  */
@@ -134,7 +134,7 @@ export class ExchangesMixin extends BaseCoreSDK {
134
134
 
135
135
  /**
136
136
  * Completes an existing voucher by calling the `ExchangeHandlerContract`.
137
- * Callable by buyer or seller operator.
137
+ * Callable by buyer or seller assistant.
138
138
  * @param exchangeId - ID of exchange to complete.
139
139
  * @returns Transaction response.
140
140
  */
@@ -151,7 +151,7 @@ export class ExchangesMixin extends BaseCoreSDK {
151
151
 
152
152
  /**
153
153
  * Completes a batch of existing vouchers by calling the `ExchangeHandlerContract`.
154
- * Callable by buyer or seller operator.
154
+ * Callable by buyer or seller assistant.
155
155
  * @param exchangeIds - IDs of exchange to complete.
156
156
  * @returns Transaction response.
157
157
  */
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ export * as subgraph from "./subgraph";
13
13
  export * as groups from "./groups";
14
14
  export * as forwarder from "./forwarder";
15
15
  export * as voucher from "./voucher";
16
+ export * as seaport from "./seaport";
16
17
 
17
18
  export {
18
19
  defaultConfigs,
@@ -37,7 +37,12 @@ import { encodeDepositFunds, encodeWithdrawFunds } from "../funds/interface";
37
37
  import { bosonDisputeHandlerIface } from "../disputes/interface";
38
38
  import { encodeCreateGroup } from "../groups/interface";
39
39
  import { encodeCreateOfferWithCondition } from "../orchestration/interface";
40
- import { encodePreMint, encodeSetApprovalForAll } from "../voucher/interface";
40
+ import {
41
+ encodeCallExternalContract,
42
+ encodePreMint,
43
+ encodeSetApprovalForAll,
44
+ encodeSetApprovalForAllToContract
45
+ } from "../voucher/interface";
41
46
  import { hexZeroPad } from "@ethersproject/bytes";
42
47
  import { keccak256 } from "@ethersproject/keccak256";
43
48
  import { id } from "@ethersproject/hash";
@@ -460,6 +465,38 @@ export async function signMetaTxVoidOfferBatch(
460
465
  });
461
466
  }
462
467
 
468
+ export async function signMetaTxExtendOffer(
469
+ args: BaseMetaTxArgs & {
470
+ offerId: BigNumberish;
471
+ validUntil: BigNumberish;
472
+ }
473
+ ) {
474
+ return signMetaTx({
475
+ ...args,
476
+ functionName: "extendOffer(uint256,uint256)",
477
+ functionSignature: bosonOfferHandlerIface.encodeFunctionData(
478
+ "extendOffer",
479
+ [args.offerId, args.validUntil]
480
+ )
481
+ });
482
+ }
483
+
484
+ export async function signMetaTxExtendOfferBatch(
485
+ args: BaseMetaTxArgs & {
486
+ offerIds: BigNumberish[];
487
+ validUntil: BigNumberish;
488
+ }
489
+ ) {
490
+ return signMetaTx({
491
+ ...args,
492
+ functionName: "extendOfferBatch(uint256[],uint256)",
493
+ functionSignature: bosonOfferHandlerIface.encodeFunctionData(
494
+ "extendOfferBatch",
495
+ [args.offerIds, args.validUntil]
496
+ )
497
+ });
498
+ }
499
+
463
500
  export async function signMetaTxCompleteExchangeBatch(
464
501
  args: BaseMetaTxArgs & {
465
502
  exchangeIds: BigNumberish[];
@@ -522,12 +559,13 @@ export async function signMetaTxReserveRange(
522
559
  args: BaseMetaTxArgs & {
523
560
  offerId: BigNumberish;
524
561
  length: BigNumberish;
562
+ to: string;
525
563
  }
526
564
  ) {
527
565
  return signMetaTx({
528
566
  ...args,
529
- functionName: "reserveRange(uint256,uint256)",
530
- functionSignature: encodeReserveRange(args.offerId, args.length)
567
+ functionName: "reserveRange(uint256,uint256,address)",
568
+ functionSignature: encodeReserveRange(args.offerId, args.length, args.to)
531
569
  });
532
570
  }
533
571
 
@@ -592,6 +630,73 @@ export async function signMetaTxSetApprovalForAll(
592
630
  });
593
631
  }
594
632
 
633
+ export async function signMetaTxSetApprovalForAllToContract(
634
+ args: BaseVoucherMetaTxArgs & {
635
+ operator: string;
636
+ approved: boolean;
637
+ batchId: BigNumberish;
638
+ forwarderAbi:
639
+ | typeof abis.MockForwarderABI
640
+ | typeof abis.BiconomyForwarderABI;
641
+ },
642
+ overrides: {
643
+ txGas?: number;
644
+ } = {}
645
+ ): Promise<SignedVoucherMetaTx> {
646
+ const localConfig = defaultConfigs.find(
647
+ (config) => config.envName === "local"
648
+ );
649
+ const isLocal = localConfig.chainId === args.chainId;
650
+ const functionSignature = encodeSetApprovalForAllToContract(
651
+ args.operator,
652
+ args.approved
653
+ );
654
+ if (isLocal) {
655
+ return signVoucherMetaTx({
656
+ ...args,
657
+ functionSignature
658
+ });
659
+ }
660
+ const txGas = overrides.txGas || 100000; // TODO: estimate the gas needed
661
+ return signBiconomyVoucherMetaTx({
662
+ ...args,
663
+ functionSignature,
664
+ txGas
665
+ });
666
+ }
667
+
668
+ export async function signMetaTxCallExternalContract(
669
+ args: BaseVoucherMetaTxArgs & {
670
+ to: string;
671
+ data: string;
672
+ batchId: BigNumberish;
673
+ forwarderAbi:
674
+ | typeof abis.MockForwarderABI
675
+ | typeof abis.BiconomyForwarderABI;
676
+ },
677
+ overrides: {
678
+ txGas?: number;
679
+ } = {}
680
+ ): Promise<SignedVoucherMetaTx> {
681
+ const localConfig = defaultConfigs.find(
682
+ (config) => config.envName === "local"
683
+ );
684
+ const isLocal = localConfig.chainId === args.chainId;
685
+ const functionSignature = encodeCallExternalContract(args.to, args.data);
686
+ if (isLocal) {
687
+ return signVoucherMetaTx({
688
+ ...args,
689
+ functionSignature
690
+ });
691
+ }
692
+ const txGas = overrides.txGas || 500000; // TODO: estimate the gas needed
693
+ return signBiconomyVoucherMetaTx({
694
+ ...args,
695
+ functionSignature,
696
+ txGas
697
+ });
698
+ }
699
+
595
700
  export async function signMetaTxCreateOfferWithCondition(
596
701
  args: BaseMetaTxArgs & {
597
702
  offerToCreate: CreateOfferArgs;
@@ -142,14 +142,20 @@ export class MetaTxMixin extends BaseCoreSDK {
142
142
  public async signMetaTxReserveRange(
143
143
  args: Omit<
144
144
  Parameters<typeof handler.signMetaTxReserveRange>[0],
145
- "web3Lib" | "metaTxHandlerAddress" | "chainId"
146
- >
145
+ "web3Lib" | "metaTxHandlerAddress" | "chainId" | "to"
146
+ > & { to: "seller" | "contract" }
147
147
  ) {
148
+ const offer = await getOfferById(this._subgraphUrl, args.offerId);
149
+
148
150
  return handler.signMetaTxReserveRange({
149
151
  web3Lib: this._web3Lib,
150
152
  metaTxHandlerAddress: this._protocolDiamond,
151
153
  chainId: this._chainId,
152
- ...args
154
+ ...args,
155
+ to:
156
+ args.to === "contract"
157
+ ? offer.seller.voucherCloneAddress
158
+ : offer.seller.assistant
153
159
  });
154
160
  }
155
161
 
@@ -236,6 +242,102 @@ export class MetaTxMixin extends BaseCoreSDK {
236
242
  });
237
243
  }
238
244
 
245
+ public async signMetaTxSetApprovalForAllToContract(
246
+ args: Omit<
247
+ Parameters<typeof handler.signMetaTxSetApprovalForAllToContract>[0],
248
+ | "web3Lib"
249
+ | "bosonVoucherAddress"
250
+ | "chainId"
251
+ | "nonce"
252
+ | "forwarderAddress"
253
+ | "batchId"
254
+ | "forwarderAbi"
255
+ >,
256
+ overrides: Partial<{
257
+ batchId?: BigNumberish;
258
+ txGas?: number;
259
+ }> = {}
260
+ ) {
261
+ const sellerAddress = await this._web3Lib.getSignerAddress();
262
+ const seller = await accounts.subgraph.getSellerByAddress(
263
+ this._subgraphUrl,
264
+ sellerAddress
265
+ );
266
+ const forwarderAddress = this._contracts.forwarder;
267
+ const batchId = overrides.batchId || 0;
268
+ const nonce = await getNonce({
269
+ contractAddress: forwarderAddress,
270
+ user: sellerAddress,
271
+ web3Lib: this._web3Lib,
272
+ batchId,
273
+ forwarderAbi: this._metaTxConfig.forwarderAbi
274
+ });
275
+
276
+ return handler.signMetaTxSetApprovalForAllToContract(
277
+ {
278
+ web3Lib: this._web3Lib,
279
+ bosonVoucherAddress: seller.voucherCloneAddress,
280
+ chainId: this._chainId,
281
+ nonce,
282
+ forwarderAddress,
283
+ batchId,
284
+ forwarderAbi: this._metaTxConfig.forwarderAbi,
285
+ ...args
286
+ },
287
+ {
288
+ txGas: overrides.txGas
289
+ }
290
+ );
291
+ }
292
+
293
+ public async signMetaTxCallExternalContract(
294
+ args: Omit<
295
+ Parameters<typeof handler.signMetaTxCallExternalContract>[0],
296
+ | "web3Lib"
297
+ | "bosonVoucherAddress"
298
+ | "chainId"
299
+ | "nonce"
300
+ | "forwarderAddress"
301
+ | "batchId"
302
+ | "forwarderAbi"
303
+ >,
304
+ overrides: Partial<{
305
+ batchId?: BigNumberish;
306
+ txGas?: number;
307
+ }> = {}
308
+ ) {
309
+ const sellerAddress = await this._web3Lib.getSignerAddress();
310
+ const seller = await accounts.subgraph.getSellerByAddress(
311
+ this._subgraphUrl,
312
+ sellerAddress
313
+ );
314
+ const forwarderAddress = this._contracts.forwarder;
315
+ const batchId = overrides.batchId || 0;
316
+ const nonce = await getNonce({
317
+ contractAddress: forwarderAddress,
318
+ user: sellerAddress,
319
+ web3Lib: this._web3Lib,
320
+ batchId,
321
+ forwarderAbi: this._metaTxConfig.forwarderAbi
322
+ });
323
+
324
+ return handler.signMetaTxCallExternalContract(
325
+ {
326
+ web3Lib: this._web3Lib,
327
+ bosonVoucherAddress: seller.voucherCloneAddress,
328
+ chainId: this._chainId,
329
+ nonce,
330
+ forwarderAddress,
331
+ batchId,
332
+ forwarderAbi: this._metaTxConfig.forwarderAbi,
333
+ ...args
334
+ },
335
+ {
336
+ txGas: overrides.txGas
337
+ }
338
+ );
339
+ }
340
+
239
341
  public async relayBiconomyMetaTransaction(
240
342
  contractAddress: string,
241
343
  metaTxParams: {
@@ -340,6 +442,44 @@ export class MetaTxMixin extends BaseCoreSDK {
340
442
  });
341
443
  }
342
444
 
445
+ /**
446
+ * Encodes and signs a meta transaction for `extendOffer` that can be relayed.
447
+ * @param args - Meta transaction args.
448
+ * @returns Signature.
449
+ */
450
+ public async signMetaTxExtendOffer(
451
+ args: Omit<
452
+ Parameters<typeof handler.signMetaTxExtendOffer>[0],
453
+ "web3Lib" | "metaTxHandlerAddress" | "chainId"
454
+ >
455
+ ) {
456
+ return handler.signMetaTxExtendOffer({
457
+ web3Lib: this._web3Lib,
458
+ metaTxHandlerAddress: this._protocolDiamond,
459
+ chainId: this._chainId,
460
+ ...args
461
+ });
462
+ }
463
+
464
+ /**
465
+ * Encodes and signs a meta transaction for `extendOfferBatch` that can be relayed.
466
+ * @param args - Meta transaction args.
467
+ * @returns Signature.
468
+ */
469
+ public async signMetaTxExtendOfferBatch(
470
+ args: Omit<
471
+ Parameters<typeof handler.signMetaTxExtendOfferBatch>[0],
472
+ "web3Lib" | "metaTxHandlerAddress" | "chainId"
473
+ >
474
+ ) {
475
+ return handler.signMetaTxExtendOfferBatch({
476
+ web3Lib: this._web3Lib,
477
+ metaTxHandlerAddress: this._protocolDiamond,
478
+ chainId: this._chainId,
479
+ ...args
480
+ });
481
+ }
482
+
343
483
  /**
344
484
  * Encodes and signs a meta transaction for `completeExchangeBatch` that can be relayed.
345
485
  * @param args - Meta transaction args.
@@ -39,6 +39,9 @@ fragment BaseBaseMetadataEntityFields on BaseMetadataEntity {
39
39
  description
40
40
  externalUrl
41
41
  animationUrl
42
+ animationMetadata {
43
+ ...BaseAnimationMetadataFields
44
+ }
42
45
  licenseUrl
43
46
  condition
44
47
  schemaUrl
@@ -73,6 +73,7 @@ export async function reserveRange(args: {
73
73
  subgraphUrl: string;
74
74
  offerId: BigNumberish;
75
75
  length: BigNumberish;
76
+ to: string;
76
77
  web3Lib: Web3LibAdapter;
77
78
  }): Promise<TransactionResponse> {
78
79
  const offerFromSubgraph = await getOfferById(args.subgraphUrl, args.offerId);
@@ -87,7 +88,7 @@ export async function reserveRange(args: {
87
88
 
88
89
  return args.web3Lib.sendTransaction({
89
90
  to: args.contractAddress,
90
- data: encodeReserveRange(args.offerId, args.length)
91
+ data: encodeReserveRange(args.offerId, args.length, args.to)
91
92
  });
92
93
  }
93
94
 
@@ -145,6 +146,38 @@ export async function voidOfferBatch(args: {
145
146
  });
146
147
  }
147
148
 
149
+ export async function extendOffer(args: {
150
+ contractAddress: string;
151
+ subgraphUrl: string;
152
+ offerId: BigNumberish;
153
+ validUntil: BigNumberish;
154
+ web3Lib: Web3LibAdapter;
155
+ }): Promise<TransactionResponse> {
156
+ return args.web3Lib.sendTransaction({
157
+ to: args.contractAddress,
158
+ data: bosonOfferHandlerIface.encodeFunctionData("extendOffer", [
159
+ args.offerId,
160
+ args.validUntil
161
+ ])
162
+ });
163
+ }
164
+
165
+ export async function extendOfferBatch(args: {
166
+ contractAddress: string;
167
+ subgraphUrl: string;
168
+ offerIds: BigNumberish[];
169
+ validUntil: BigNumberish;
170
+ web3Lib: Web3LibAdapter;
171
+ }): Promise<TransactionResponse> {
172
+ return args.web3Lib.sendTransaction({
173
+ to: args.contractAddress,
174
+ data: bosonOfferHandlerIface.encodeFunctionData("extendOfferBatch", [
175
+ args.offerIds,
176
+ args.validUntil
177
+ ])
178
+ });
179
+ }
180
+
148
181
  function checkIfOfferVoidable(
149
182
  offerId: BigNumberish,
150
183
  signerAddress: string,
@@ -159,11 +192,11 @@ function checkIfOfferVoidable(
159
192
  }
160
193
 
161
194
  if (
162
- offerFromSubgraph.seller.operator.toLowerCase() !==
195
+ offerFromSubgraph.seller.assistant.toLowerCase() !==
163
196
  signerAddress.toLowerCase()
164
197
  ) {
165
198
  throw new Error(
166
- `Signer with address "${signerAddress}" is not the operator "${offerFromSubgraph.seller.operator}" of offer with id "${offerId}"`
199
+ `Signer with address "${signerAddress}" is not the assistant "${offerFromSubgraph.seller.assistant}" of offer with id "${offerId}"`
167
200
  );
168
201
  }
169
202
  }
@@ -132,10 +132,12 @@ export function argsToOfferDurationsStruct(
132
132
 
133
133
  export function encodeReserveRange(
134
134
  offerId: BigNumberish,
135
- length: BigNumberish
135
+ length: BigNumberish,
136
+ to: string
136
137
  ) {
137
138
  return bosonOfferHandlerIface.encodeFunctionData("reserveRange", [
138
139
  offerId,
139
- length
140
+ length,
141
+ to
140
142
  ]);
141
143
  }