@bosonprotocol/core-sdk 1.47.1-alpha.0 → 1.48.0-alpha.1

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 (85) hide show
  1. package/dist/cjs/erc20/handler.d.ts +73 -0
  2. package/dist/cjs/erc20/handler.d.ts.map +1 -1
  3. package/dist/cjs/erc20/handler.js +198 -0
  4. package/dist/cjs/erc20/handler.js.map +1 -1
  5. package/dist/cjs/erc20/mixin.d.ts +76 -1
  6. package/dist/cjs/erc20/mixin.d.ts.map +1 -1
  7. package/dist/cjs/erc20/mixin.js +67 -0
  8. package/dist/cjs/erc20/mixin.js.map +1 -1
  9. package/dist/cjs/exchanges/handler.d.ts +6 -0
  10. package/dist/cjs/exchanges/handler.d.ts.map +1 -1
  11. package/dist/cjs/exchanges/handler.js +1 -0
  12. package/dist/cjs/exchanges/handler.js.map +1 -1
  13. package/dist/cjs/meta-tx/handler.d.ts +32 -0
  14. package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
  15. package/dist/cjs/meta-tx/handler.js +68 -19
  16. package/dist/cjs/meta-tx/handler.js.map +1 -1
  17. package/dist/cjs/meta-tx/mixin.d.ts +38 -0
  18. package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
  19. package/dist/cjs/meta-tx/mixin.js +29 -1
  20. package/dist/cjs/meta-tx/mixin.js.map +1 -1
  21. package/dist/cjs/native-meta-tx/handler.d.ts +1 -1
  22. package/dist/cjs/native-meta-tx/handler.d.ts.map +1 -1
  23. package/dist/cjs/orchestration/handler.d.ts +59 -1
  24. package/dist/cjs/orchestration/handler.d.ts.map +1 -1
  25. package/dist/cjs/orchestration/handler.js +114 -0
  26. package/dist/cjs/orchestration/handler.js.map +1 -1
  27. package/dist/cjs/orchestration/interface.d.ts +4 -1
  28. package/dist/cjs/orchestration/interface.d.ts.map +1 -1
  29. package/dist/cjs/orchestration/interface.js +23 -5
  30. package/dist/cjs/orchestration/interface.js.map +1 -1
  31. package/dist/cjs/orchestration/mixin.d.ts +49 -1
  32. package/dist/cjs/orchestration/mixin.d.ts.map +1 -1
  33. package/dist/cjs/orchestration/mixin.js +62 -0
  34. package/dist/cjs/orchestration/mixin.js.map +1 -1
  35. package/dist/cjs/utils/signature.d.ts +9 -0
  36. package/dist/cjs/utils/signature.d.ts.map +1 -1
  37. package/dist/cjs/utils/signature.js.map +1 -1
  38. package/dist/esm/erc20/handler.d.ts +73 -0
  39. package/dist/esm/erc20/handler.d.ts.map +1 -1
  40. package/dist/esm/erc20/handler.js +217 -0
  41. package/dist/esm/erc20/handler.js.map +1 -1
  42. package/dist/esm/erc20/mixin.d.ts +76 -1
  43. package/dist/esm/erc20/mixin.d.ts.map +1 -1
  44. package/dist/esm/erc20/mixin.js +79 -1
  45. package/dist/esm/erc20/mixin.js.map +1 -1
  46. package/dist/esm/exchanges/handler.d.ts +6 -0
  47. package/dist/esm/exchanges/handler.d.ts.map +1 -1
  48. package/dist/esm/exchanges/handler.js +1 -1
  49. package/dist/esm/exchanges/handler.js.map +1 -1
  50. package/dist/esm/meta-tx/handler.d.ts +32 -0
  51. package/dist/esm/meta-tx/handler.d.ts.map +1 -1
  52. package/dist/esm/meta-tx/handler.js +66 -12
  53. package/dist/esm/meta-tx/handler.js.map +1 -1
  54. package/dist/esm/meta-tx/mixin.d.ts +38 -0
  55. package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
  56. package/dist/esm/meta-tx/mixin.js +63 -1
  57. package/dist/esm/meta-tx/mixin.js.map +1 -1
  58. package/dist/esm/native-meta-tx/handler.d.ts +1 -1
  59. package/dist/esm/native-meta-tx/handler.d.ts.map +1 -1
  60. package/dist/esm/orchestration/handler.d.ts +59 -1
  61. package/dist/esm/orchestration/handler.d.ts.map +1 -1
  62. package/dist/esm/orchestration/handler.js +126 -2
  63. package/dist/esm/orchestration/handler.js.map +1 -1
  64. package/dist/esm/orchestration/interface.d.ts +4 -1
  65. package/dist/esm/orchestration/interface.d.ts.map +1 -1
  66. package/dist/esm/orchestration/interface.js +15 -0
  67. package/dist/esm/orchestration/interface.js.map +1 -1
  68. package/dist/esm/orchestration/mixin.d.ts +49 -1
  69. package/dist/esm/orchestration/mixin.d.ts.map +1 -1
  70. package/dist/esm/orchestration/mixin.js +74 -0
  71. package/dist/esm/orchestration/mixin.js.map +1 -1
  72. package/dist/esm/utils/signature.d.ts +9 -0
  73. package/dist/esm/utils/signature.d.ts.map +1 -1
  74. package/dist/esm/utils/signature.js.map +1 -1
  75. package/package.json +3 -3
  76. package/src/erc20/handler.ts +354 -0
  77. package/src/erc20/mixin.ts +206 -1
  78. package/src/exchanges/handler.ts +1 -1
  79. package/src/meta-tx/handler.ts +157 -12
  80. package/src/meta-tx/mixin.ts +149 -1
  81. package/src/native-meta-tx/handler.ts +1 -1
  82. package/src/orchestration/handler.ts +267 -1
  83. package/src/orchestration/interface.ts +31 -1
  84. package/src/orchestration/mixin.ts +187 -0
  85. package/src/utils/signature.ts +18 -6
@@ -1,7 +1,8 @@
1
- import { abis, ConditionStruct } from "@bosonprotocol/common";
1
+ import { abis, ConditionStruct, FullOfferArgs } from "@bosonprotocol/common";
2
2
  import { Interface } from "@ethersproject/abi";
3
3
  import { createSellerArgsToStruct } from "../accounts/interface";
4
4
  import { createOfferArgsToStructs } from "../offers/interface";
5
+ import { fullOfferArgsToStruct } from "../exchanges/interface";
5
6
 
6
7
  import { CreateSellerArgs } from "../accounts/types";
7
8
  import { CreateOfferArgs } from "../offers/types";
@@ -181,3 +182,32 @@ export function encodeRaiseAndEscalateDispute(exchangeId: BigNumberish) {
181
182
  [exchangeId]
182
183
  );
183
184
  }
185
+
186
+ export function encodeCommitToOfferAndRedeemVoucher(offerId: BigNumberish) {
187
+ return bosonOrchestrationHandlerIface.encodeFunctionData(
188
+ "commitToOfferAndRedeemVoucher",
189
+ [offerId]
190
+ );
191
+ }
192
+
193
+ export function encodeCommitToConditionalOfferAndRedeemVoucher(
194
+ offerId: BigNumberish,
195
+ tokenId: BigNumberish
196
+ ) {
197
+ return bosonOrchestrationHandlerIface.encodeFunctionData(
198
+ "commitToConditionalOfferAndRedeemVoucher",
199
+ [offerId, tokenId]
200
+ );
201
+ }
202
+
203
+ export function encodeCreateOfferCommitAndRedeem(args: FullOfferArgs) {
204
+ return bosonOrchestrationHandlerIface.encodeFunctionData(
205
+ "createOfferCommitAndRedeem",
206
+ [
207
+ fullOfferArgsToStruct(args),
208
+ args.offerCreator,
209
+ args.signature,
210
+ args.conditionalTokenId || "0"
211
+ ]
212
+ );
213
+ }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  ConditionStruct,
3
+ FullOfferArgs,
3
4
  TransactionResponse,
4
5
  TransactionRequest,
5
6
  Web3LibAdapter
@@ -415,6 +416,192 @@ export class OrchestrationMixin<
415
416
  }
416
417
  }
417
418
 
419
+ /**
420
+ * Commits to a seller-initiated offer and immediately redeems the voucher in
421
+ * a single transaction by calling the `OrchestrationHandler`.
422
+ * @param offerId - ID of offer to commit to.
423
+ * @param overrides - Optional overrides.
424
+ * @returns Transaction response.
425
+ */
426
+ // Overload: returnTxInfo is true → returns TransactionRequest
427
+ public async commitToOfferAndRedeemVoucher(
428
+ offerId: BigNumberish,
429
+ overrides: Partial<{
430
+ contractAddress: string;
431
+ returnTxInfo: true;
432
+ }>
433
+ ): Promise<TransactionRequest>;
434
+
435
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
436
+ public async commitToOfferAndRedeemVoucher(
437
+ offerId: BigNumberish,
438
+ overrides?: Partial<{
439
+ contractAddress: string;
440
+ returnTxInfo?: false;
441
+ }>
442
+ ): Promise<TransactionResponse>;
443
+
444
+ // Implementation
445
+ public async commitToOfferAndRedeemVoucher(
446
+ offerId: BigNumberish,
447
+ overrides: Partial<{
448
+ contractAddress: string;
449
+ returnTxInfo?: boolean;
450
+ }> = {}
451
+ ): Promise<TransactionResponse | TransactionRequest> {
452
+ const { returnTxInfo } = overrides;
453
+
454
+ const commitArgs = {
455
+ offerId,
456
+ web3Lib: this._web3Lib,
457
+ subgraphUrl: this._subgraphUrl,
458
+ metadataStorage: this._metadataStorage,
459
+ theGraphStorage: this._theGraphStorage,
460
+ contractAddress: overrides.contractAddress || this._protocolDiamond
461
+ } as const satisfies Parameters<
462
+ typeof handler.commitToOfferAndRedeemVoucher
463
+ >[0];
464
+
465
+ if (returnTxInfo === true) {
466
+ return handler.commitToOfferAndRedeemVoucher({
467
+ ...commitArgs,
468
+ returnTxInfo: true
469
+ });
470
+ } else {
471
+ return handler.commitToOfferAndRedeemVoucher({
472
+ ...commitArgs,
473
+ returnTxInfo: false
474
+ });
475
+ }
476
+ }
477
+
478
+ /**
479
+ * Commits to a conditional offer and immediately redeems the voucher in a
480
+ * single transaction by calling the `OrchestrationHandler`.
481
+ * @param offerId - ID of offer to commit to.
482
+ * @param tokenId - ID of the token to use for the conditional commit.
483
+ * @param overrides - Optional overrides.
484
+ * @returns Transaction response.
485
+ */
486
+ // Overload: returnTxInfo is true → returns TransactionRequest
487
+ public async commitToConditionalOfferAndRedeemVoucher(
488
+ offerId: BigNumberish,
489
+ tokenId: BigNumberish,
490
+ overrides: Partial<{
491
+ contractAddress: string;
492
+ returnTxInfo: true;
493
+ }>
494
+ ): Promise<TransactionRequest>;
495
+
496
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
497
+ public async commitToConditionalOfferAndRedeemVoucher(
498
+ offerId: BigNumberish,
499
+ tokenId: BigNumberish,
500
+ overrides?: Partial<{
501
+ contractAddress: string;
502
+ returnTxInfo?: false;
503
+ }>
504
+ ): Promise<TransactionResponse>;
505
+
506
+ // Implementation
507
+ public async commitToConditionalOfferAndRedeemVoucher(
508
+ offerId: BigNumberish,
509
+ tokenId: BigNumberish,
510
+ overrides: Partial<{
511
+ contractAddress: string;
512
+ returnTxInfo?: boolean;
513
+ }> = {}
514
+ ): Promise<TransactionResponse | TransactionRequest> {
515
+ const { returnTxInfo } = overrides;
516
+
517
+ const commitArgs = {
518
+ offerId,
519
+ tokenId,
520
+ web3Lib: this._web3Lib,
521
+ subgraphUrl: this._subgraphUrl,
522
+ metadataStorage: this._metadataStorage,
523
+ theGraphStorage: this._theGraphStorage,
524
+ contractAddress: overrides.contractAddress || this._protocolDiamond
525
+ } as const satisfies Parameters<
526
+ typeof handler.commitToConditionalOfferAndRedeemVoucher
527
+ >[0];
528
+
529
+ if (returnTxInfo === true) {
530
+ return handler.commitToConditionalOfferAndRedeemVoucher({
531
+ ...commitArgs,
532
+ returnTxInfo: true
533
+ });
534
+ } else {
535
+ return handler.commitToConditionalOfferAndRedeemVoucher({
536
+ ...commitArgs,
537
+ returnTxInfo: false
538
+ });
539
+ }
540
+ }
541
+
542
+ /**
543
+ * Creates an offer, commits to it and immediately redeems the voucher in a
544
+ * single transaction by calling the `OrchestrationHandler`.
545
+ * @param createOfferAndCommitArgs - Offer and commit arguments.
546
+ * @param overrides - Optional overrides.
547
+ * @returns Transaction response.
548
+ */
549
+ // Overload: returnTxInfo is true → returns TransactionRequest
550
+ public async createOfferCommitAndRedeem(
551
+ createOfferAndCommitArgs: FullOfferArgs,
552
+ overrides: Partial<{
553
+ contractAddress: string;
554
+ txRequest: TransactionRequest;
555
+ returnTxInfo: true;
556
+ }>
557
+ ): Promise<TransactionRequest>;
558
+
559
+ // Overload: returnTxInfo is false or undefined → returns TransactionResponse
560
+ public async createOfferCommitAndRedeem(
561
+ createOfferAndCommitArgs: FullOfferArgs,
562
+ overrides?: Partial<{
563
+ contractAddress: string;
564
+ txRequest: TransactionRequest;
565
+ returnTxInfo?: false;
566
+ }>
567
+ ): Promise<TransactionResponse>;
568
+
569
+ // Implementation
570
+ public async createOfferCommitAndRedeem(
571
+ createOfferAndCommitArgs: FullOfferArgs,
572
+ overrides: Partial<{
573
+ contractAddress: string;
574
+ txRequest: TransactionRequest;
575
+ returnTxInfo?: boolean;
576
+ }> = {}
577
+ ): Promise<TransactionResponse | TransactionRequest> {
578
+ const { returnTxInfo } = overrides;
579
+
580
+ const offerArgs = {
581
+ createOfferAndCommitArgs,
582
+ web3Lib: this._web3Lib,
583
+ subgraphUrl: this._subgraphUrl,
584
+ metadataStorage: this._metadataStorage,
585
+ theGraphStorage: this._theGraphStorage,
586
+ contractAddress: overrides.contractAddress || this._protocolDiamond,
587
+ txRequest: overrides.txRequest
588
+ } as const satisfies Parameters<
589
+ typeof handler.createOfferCommitAndRedeem
590
+ >[0];
591
+
592
+ if (returnTxInfo === true) {
593
+ return handler.createOfferCommitAndRedeem({
594
+ ...offerArgs,
595
+ returnTxInfo: true
596
+ });
597
+ } else {
598
+ return handler.createOfferCommitAndRedeem({
599
+ ...offerArgs,
600
+ returnTxInfo: false
601
+ });
602
+ }
603
+ }
604
+
418
605
  /**
419
606
  * Raises a dispute and immediately escalates it
420
607
  * @param exchangeId - Exchange ID
@@ -20,12 +20,24 @@ export type StructuredData = {
20
20
  type: string;
21
21
  }[];
22
22
  };
23
- domain: {
24
- name: string;
25
- version: string;
26
- verifyingContract: string;
27
- salt: string;
28
- };
23
+ domain:
24
+ | {
25
+ name: string;
26
+ version: string;
27
+ verifyingContract: string;
28
+ salt: string;
29
+ }
30
+ | {
31
+ name: string;
32
+ version: string;
33
+ verifyingContract: string;
34
+ chainId: number | string;
35
+ }
36
+ | {
37
+ name: string;
38
+ verifyingContract: string;
39
+ chainId: number | string;
40
+ };
29
41
  primaryType: string;
30
42
  message: Record<string, unknown>;
31
43
  };