@bosonprotocol/core-sdk 1.30.0-alpha.2 → 1.30.0-alpha.21

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 (153) hide show
  1. package/dist/cjs/accounts/interface.d.ts.map +1 -1
  2. package/dist/cjs/accounts/interface.js +9 -4
  3. package/dist/cjs/accounts/interface.js.map +1 -1
  4. package/dist/cjs/accounts/mixin.d.ts +0 -7
  5. package/dist/cjs/accounts/mixin.d.ts.map +1 -1
  6. package/dist/cjs/accounts/mixin.js +2 -16
  7. package/dist/cjs/accounts/mixin.js.map +1 -1
  8. package/dist/cjs/accounts/subgraph.d.ts +0 -1
  9. package/dist/cjs/accounts/subgraph.d.ts.map +1 -1
  10. package/dist/cjs/accounts/subgraph.js +4 -12
  11. package/dist/cjs/accounts/subgraph.js.map +1 -1
  12. package/dist/cjs/accounts/types.d.ts +0 -1
  13. package/dist/cjs/accounts/types.d.ts.map +1 -1
  14. package/dist/cjs/exchanges/handler.d.ts +5 -0
  15. package/dist/cjs/exchanges/handler.d.ts.map +1 -1
  16. package/dist/cjs/exchanges/handler.js +46 -15
  17. package/dist/cjs/exchanges/handler.js.map +1 -1
  18. package/dist/cjs/exchanges/interface.d.ts +1 -0
  19. package/dist/cjs/exchanges/interface.d.ts.map +1 -1
  20. package/dist/cjs/exchanges/interface.js +5 -1
  21. package/dist/cjs/exchanges/interface.js.map +1 -1
  22. package/dist/cjs/exchanges/mixin.d.ts +11 -0
  23. package/dist/cjs/exchanges/mixin.d.ts.map +1 -1
  24. package/dist/cjs/exchanges/mixin.js +21 -0
  25. package/dist/cjs/exchanges/mixin.js.map +1 -1
  26. package/dist/cjs/forwarder/mock-interface.d.ts +20 -0
  27. package/dist/cjs/forwarder/mock-interface.d.ts.map +1 -1
  28. package/dist/cjs/groups/interface.d.ts +6 -1
  29. package/dist/cjs/groups/interface.d.ts.map +1 -1
  30. package/dist/cjs/groups/interface.js +15 -9
  31. package/dist/cjs/groups/interface.js.map +1 -1
  32. package/dist/cjs/meta-tx/biconomy.d.ts.map +1 -1
  33. package/dist/cjs/meta-tx/biconomy.js +0 -1
  34. package/dist/cjs/meta-tx/biconomy.js.map +1 -1
  35. package/dist/cjs/meta-tx/handler.d.ts +4 -0
  36. package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
  37. package/dist/cjs/meta-tx/handler.js +42 -7
  38. package/dist/cjs/meta-tx/handler.js.map +1 -1
  39. package/dist/cjs/meta-tx/mixin.d.ts +6 -0
  40. package/dist/cjs/meta-tx/mixin.d.ts.map +1 -1
  41. package/dist/cjs/meta-tx/mixin.js +17 -5
  42. package/dist/cjs/meta-tx/mixin.js.map +1 -1
  43. package/dist/cjs/offers/mixin.d.ts.map +1 -1
  44. package/dist/cjs/offers/mixin.js +1 -1
  45. package/dist/cjs/offers/mixin.js.map +1 -1
  46. package/dist/cjs/offers/renderContractualAgreement.d.ts.map +1 -1
  47. package/dist/cjs/offers/renderContractualAgreement.js.map +1 -1
  48. package/dist/cjs/orchestration/interface.d.ts.map +1 -1
  49. package/dist/cjs/orchestration/interface.js +5 -4
  50. package/dist/cjs/orchestration/interface.js.map +1 -1
  51. package/dist/cjs/subgraph.d.ts +156 -39
  52. package/dist/cjs/subgraph.d.ts.map +1 -1
  53. package/dist/cjs/subgraph.js +11 -4
  54. package/dist/cjs/subgraph.js.map +1 -1
  55. package/dist/cjs/voucher/handler.d.ts +1 -0
  56. package/dist/cjs/voucher/handler.d.ts.map +1 -1
  57. package/dist/cjs/voucher/handler.js +1 -1
  58. package/dist/cjs/voucher/handler.js.map +1 -1
  59. package/dist/cjs/voucher/interface.d.ts +1 -1
  60. package/dist/cjs/voucher/interface.d.ts.map +1 -1
  61. package/dist/cjs/voucher/interface.js +3 -2
  62. package/dist/cjs/voucher/interface.js.map +1 -1
  63. package/dist/cjs/voucher/mixin.d.ts +1 -1
  64. package/dist/cjs/voucher/mixin.d.ts.map +1 -1
  65. package/dist/cjs/voucher/mixin.js +2 -1
  66. package/dist/cjs/voucher/mixin.js.map +1 -1
  67. package/dist/esm/accounts/interface.d.ts.map +1 -1
  68. package/dist/esm/accounts/interface.js +9 -2
  69. package/dist/esm/accounts/interface.js.map +1 -1
  70. package/dist/esm/accounts/mixin.d.ts +0 -7
  71. package/dist/esm/accounts/mixin.d.ts.map +1 -1
  72. package/dist/esm/accounts/mixin.js +0 -12
  73. package/dist/esm/accounts/mixin.js.map +1 -1
  74. package/dist/esm/accounts/subgraph.d.ts +0 -1
  75. package/dist/esm/accounts/subgraph.d.ts.map +1 -1
  76. package/dist/esm/accounts/subgraph.js +3 -14
  77. package/dist/esm/accounts/subgraph.js.map +1 -1
  78. package/dist/esm/accounts/types.d.ts +0 -1
  79. package/dist/esm/accounts/types.d.ts.map +1 -1
  80. package/dist/esm/exchanges/handler.d.ts +5 -0
  81. package/dist/esm/exchanges/handler.d.ts.map +1 -1
  82. package/dist/esm/exchanges/handler.js +39 -8
  83. package/dist/esm/exchanges/handler.js.map +1 -1
  84. package/dist/esm/exchanges/interface.d.ts +1 -0
  85. package/dist/esm/exchanges/interface.d.ts.map +1 -1
  86. package/dist/esm/exchanges/interface.js +3 -0
  87. package/dist/esm/exchanges/interface.js.map +1 -1
  88. package/dist/esm/exchanges/mixin.d.ts +11 -0
  89. package/dist/esm/exchanges/mixin.d.ts.map +1 -1
  90. package/dist/esm/exchanges/mixin.js +20 -1
  91. package/dist/esm/exchanges/mixin.js.map +1 -1
  92. package/dist/esm/forwarder/mock-interface.d.ts +20 -0
  93. package/dist/esm/forwarder/mock-interface.d.ts.map +1 -1
  94. package/dist/esm/groups/interface.d.ts +6 -1
  95. package/dist/esm/groups/interface.d.ts.map +1 -1
  96. package/dist/esm/groups/interface.js +13 -8
  97. package/dist/esm/groups/interface.js.map +1 -1
  98. package/dist/esm/meta-tx/biconomy.d.ts.map +1 -1
  99. package/dist/esm/meta-tx/biconomy.js +0 -1
  100. package/dist/esm/meta-tx/biconomy.js.map +1 -1
  101. package/dist/esm/meta-tx/handler.d.ts +4 -0
  102. package/dist/esm/meta-tx/handler.d.ts.map +1 -1
  103. package/dist/esm/meta-tx/handler.js +48 -6
  104. package/dist/esm/meta-tx/handler.js.map +1 -1
  105. package/dist/esm/meta-tx/mixin.d.ts +6 -0
  106. package/dist/esm/meta-tx/mixin.d.ts.map +1 -1
  107. package/dist/esm/meta-tx/mixin.js +21 -3
  108. package/dist/esm/meta-tx/mixin.js.map +1 -1
  109. package/dist/esm/offers/mixin.d.ts.map +1 -1
  110. package/dist/esm/offers/mixin.js +1 -1
  111. package/dist/esm/offers/mixin.js.map +1 -1
  112. package/dist/esm/offers/renderContractualAgreement.d.ts.map +1 -1
  113. package/dist/esm/offers/renderContractualAgreement.js.map +1 -1
  114. package/dist/esm/orchestration/interface.d.ts.map +1 -1
  115. package/dist/esm/orchestration/interface.js +5 -4
  116. package/dist/esm/orchestration/interface.js.map +1 -1
  117. package/dist/esm/subgraph.d.ts +156 -39
  118. package/dist/esm/subgraph.d.ts.map +1 -1
  119. package/dist/esm/subgraph.js +9 -3
  120. package/dist/esm/subgraph.js.map +1 -1
  121. package/dist/esm/voucher/handler.d.ts +1 -0
  122. package/dist/esm/voucher/handler.d.ts.map +1 -1
  123. package/dist/esm/voucher/handler.js +1 -1
  124. package/dist/esm/voucher/handler.js.map +1 -1
  125. package/dist/esm/voucher/interface.d.ts +1 -1
  126. package/dist/esm/voucher/interface.d.ts.map +1 -1
  127. package/dist/esm/voucher/interface.js +3 -2
  128. package/dist/esm/voucher/interface.js.map +1 -1
  129. package/dist/esm/voucher/mixin.d.ts +1 -1
  130. package/dist/esm/voucher/mixin.d.ts.map +1 -1
  131. package/dist/esm/voucher/mixin.js +2 -1
  132. package/dist/esm/voucher/mixin.js.map +1 -1
  133. package/package.json +4 -3
  134. package/src/accounts/interface.ts +9 -2
  135. package/src/accounts/mixin.ts +0 -20
  136. package/src/accounts/subgraph.ts +3 -19
  137. package/src/accounts/types.ts +0 -1
  138. package/src/exchanges/handler.ts +70 -15
  139. package/src/exchanges/interface.ts +11 -0
  140. package/src/exchanges/mixin.ts +28 -1
  141. package/src/groups/interface.ts +17 -9
  142. package/src/groups/queries.graphql +3 -1
  143. package/src/meta-tx/biconomy.ts +0 -1
  144. package/src/meta-tx/handler.ts +64 -6
  145. package/src/meta-tx/mixin.ts +29 -3
  146. package/src/offers/mixin.ts +7 -2
  147. package/src/offers/queries.graphql +1 -0
  148. package/src/offers/renderContractualAgreement.ts +0 -1
  149. package/src/orchestration/interface.ts +5 -4
  150. package/src/subgraph.ts +160 -41
  151. package/src/voucher/handler.ts +2 -1
  152. package/src/voucher/interface.ts +6 -2
  153. package/src/voucher/mixin.ts +2 -0
@@ -8,11 +8,16 @@ import {
8
8
  encodeCompleteExchangeBatch,
9
9
  encodeRevokeVoucher,
10
10
  encodeExpireVoucher,
11
- encodeRedeemVoucher
11
+ encodeRedeemVoucher,
12
+ encodeCommitToConditionalOffer
12
13
  } from "./interface";
13
14
  import { getOfferById } from "../offers/subgraph";
14
15
  import { getExchangeById, getExchanges } from "../exchanges/subgraph";
15
- import { ExchangeFieldsFragment, ExchangeState } from "../subgraph";
16
+ import {
17
+ ExchangeFieldsFragment,
18
+ ExchangeState,
19
+ OfferFieldsFragment
20
+ } from "../subgraph";
16
21
  import { ensureAllowance } from "../erc20/handler";
17
22
 
18
23
  type BaseExchangeHandlerArgs = {
@@ -21,32 +26,47 @@ type BaseExchangeHandlerArgs = {
21
26
  web3Lib: Web3LibAdapter;
22
27
  };
23
28
 
24
- export async function commitToOffer(
25
- args: BaseExchangeHandlerArgs & {
26
- buyer: string;
27
- offerId: BigNumberish;
28
- }
29
- ): Promise<TransactionResponse> {
30
- const offer = await getOfferById(args.subgraphUrl, args.offerId);
31
-
29
+ function checkOfferIsCommittable(
30
+ offerId: BigNumberish,
31
+ offer: OfferFieldsFragment
32
+ ) {
32
33
  if (!offer) {
33
- throw new Error(`Offer with id ${args.offerId} does not exist`);
34
+ throw new Error(`Offer with id ${offerId.toString()} does not exist`);
34
35
  }
35
36
 
36
37
  if (offer.voidedAt) {
37
- throw new Error(`Offer with id ${args.offerId} has been voided`);
38
+ throw new Error(`Offer with id ${offerId.toString()} has been voided`);
38
39
  }
39
40
 
40
41
  if (Date.now() < Number(offer.validFromDate) * 1000) {
41
- throw new Error(`Offer with id ${args.offerId} is not valid yet`);
42
+ throw new Error(`Offer with id ${offerId.toString()} is not valid yet`);
42
43
  }
43
44
 
44
45
  if (Date.now() >= Number(offer.validUntilDate) * 1000) {
45
- throw new Error(`Offer with id ${args.offerId} is not valid anymore`);
46
+ throw new Error(`Offer with id ${offerId.toString()} is not valid anymore`);
46
47
  }
47
48
 
48
49
  if (Number(offer.quantityAvailable) === 0) {
49
- throw new Error(`Offer with id ${args.offerId} is sold out`);
50
+ throw new Error(`Offer with id ${offerId.toString()} is sold out`);
51
+ }
52
+ }
53
+
54
+ export async function commitToOffer(
55
+ args: BaseExchangeHandlerArgs & {
56
+ buyer: string;
57
+ offerId: BigNumberish;
58
+ }
59
+ ): Promise<TransactionResponse> {
60
+ const offer = await getOfferById(args.subgraphUrl, args.offerId);
61
+
62
+ await checkOfferIsCommittable(args.offerId, offer);
63
+
64
+ if (offer.condition) {
65
+ // keep compatibility with previous version
66
+ return commitToConditionalOffer({
67
+ ...args,
68
+ tokenId: offer.condition.minTokenId
69
+ });
50
70
  }
51
71
 
52
72
  if (offer.exchangeToken.address !== AddressZero) {
@@ -69,6 +89,41 @@ export async function commitToOffer(
69
89
  });
70
90
  }
71
91
 
92
+ export async function commitToConditionalOffer(
93
+ args: BaseExchangeHandlerArgs & {
94
+ buyer: string;
95
+ offerId: BigNumberish;
96
+ tokenId: BigNumberish;
97
+ }
98
+ ): Promise<TransactionResponse> {
99
+ const offer = await getOfferById(args.subgraphUrl, args.offerId);
100
+
101
+ await checkOfferIsCommittable(args.offerId, offer);
102
+
103
+ if (offer.exchangeToken.address !== AddressZero) {
104
+ const owner = await args.web3Lib.getSignerAddress();
105
+ // check if we need the committer to approve the token first
106
+ await ensureAllowance({
107
+ owner,
108
+ spender: args.contractAddress,
109
+ contractAddress: offer.exchangeToken.address,
110
+ value: offer.price,
111
+ web3Lib: args.web3Lib
112
+ });
113
+ }
114
+
115
+ return args.web3Lib.sendTransaction({
116
+ from: args.buyer,
117
+ to: args.contractAddress,
118
+ data: encodeCommitToConditionalOffer(
119
+ args.buyer,
120
+ args.offerId,
121
+ args.tokenId
122
+ ),
123
+ value: offer.exchangeToken.address === AddressZero ? offer.price : "0"
124
+ });
125
+ }
126
+
72
127
  export async function completeExchange(
73
128
  args: BaseExchangeHandlerArgs & {
74
129
  exchangeId: BigNumberish;
@@ -13,6 +13,17 @@ export function encodeCommitToOffer(buyer: string, offerId: BigNumberish) {
13
13
  ]);
14
14
  }
15
15
 
16
+ export function encodeCommitToConditionalOffer(
17
+ buyer: string,
18
+ offerId: BigNumberish,
19
+ tokenId: BigNumberish
20
+ ) {
21
+ return bosonExchangeHandlerIface.encodeFunctionData(
22
+ "commitToConditionalOffer",
23
+ [buyer, offerId, tokenId]
24
+ );
25
+ }
26
+
16
27
  export function encodeCompleteExchange(exchangeId: BigNumberish) {
17
28
  return bosonExchangeHandlerIface.encodeFunctionData("completeExchange", [
18
29
  exchangeId
@@ -10,7 +10,8 @@ import {
10
10
  redeemVoucher,
11
11
  completeExchange,
12
12
  completeExchangeBatch,
13
- expireVoucher
13
+ expireVoucher,
14
+ commitToConditionalOffer
14
15
  } from "./handler";
15
16
  import { getExchangeById, getExchanges } from "./subgraph";
16
17
  import { bosonExchangeHandlerIface } from "./interface";
@@ -67,6 +68,32 @@ export class ExchangesMixin extends BaseCoreSDK {
67
68
  });
68
69
  }
69
70
 
71
+ /**
72
+ * Commits to a conditional offer by calling the `ExchangeHandlerContract`.
73
+ * This transaction only succeeds if the seller has deposited funds.
74
+ * @param offerId - ID of offer to commit to.
75
+ * @param tokenId - ID of the token to use for the conditional commit
76
+ * @param overrides - Optional overrides.
77
+ * @returns Transaction response.
78
+ */
79
+ public async commitToConditionalOffer(
80
+ offerId: BigNumberish,
81
+ tokenId: BigNumberish,
82
+ overrides: Partial<{
83
+ buyer: string;
84
+ }> = {}
85
+ ): Promise<TransactionResponse> {
86
+ const buyer = overrides.buyer || (await this._web3Lib.getSignerAddress());
87
+ return commitToConditionalOffer({
88
+ buyer,
89
+ offerId,
90
+ tokenId,
91
+ web3Lib: this._web3Lib,
92
+ subgraphUrl: this._subgraphUrl,
93
+ contractAddress: this._protocolDiamond
94
+ });
95
+ }
96
+
70
97
  /**
71
98
  * Utility method to retrieve the created `exchangeId` from logs after calling `commitToOffer`.
72
99
  * @param logs - Logs to search in.
@@ -17,20 +17,28 @@ export function encodeCreateGroup(args: CreateGroupArgs) {
17
17
 
18
18
  export function createGroupArgsToStructs(
19
19
  args: CreateGroupArgs
20
- ): [GroupStruct, ConditionStruct] {
20
+ ): [GroupStruct, Omit<ConditionStruct, "gatingType"> & { gating: number }] {
21
21
  return [
22
22
  {
23
23
  id: "0",
24
24
  sellerId: "0",
25
25
  offerIds: args.offerIds
26
26
  },
27
- {
28
- method: args.method,
29
- tokenType: args.tokenType,
30
- tokenAddress: args.tokenAddress,
31
- tokenId: args.tokenId,
32
- threshold: args.threshold,
33
- maxCommits: args.maxCommits
34
- }
27
+ conditionArgsToStructs(args)
35
28
  ];
36
29
  }
30
+
31
+ export function conditionArgsToStructs(
32
+ args: ConditionStruct
33
+ ): Omit<ConditionStruct, "gatingType"> & { gating: number } {
34
+ return {
35
+ method: args.method,
36
+ tokenType: args.tokenType,
37
+ tokenAddress: args.tokenAddress,
38
+ gating: args.gatingType,
39
+ minTokenId: args.minTokenId,
40
+ maxTokenId: args.maxTokenId,
41
+ threshold: args.threshold,
42
+ maxCommits: args.maxCommits
43
+ };
44
+ }
@@ -3,7 +3,9 @@ fragment BaseConditionFields on ConditionEntity {
3
3
  method
4
4
  tokenType
5
5
  tokenAddress
6
- tokenId
6
+ gatingType
7
+ minTokenId
8
+ maxTokenId
7
9
  threshold
8
10
  maxCommits
9
11
  }
@@ -169,7 +169,6 @@ export class Biconomy {
169
169
  });
170
170
  }
171
171
  }
172
- console.log("[Biconomy.wait] resubmittedResponse", resubmittedResponse);
173
172
  return resubmittedResponse;
174
173
  }
175
174
  }
@@ -398,7 +398,7 @@ export async function signMetaTxCreateSeller(
398
398
  return signMetaTx({
399
399
  ...args,
400
400
  functionName:
401
- "createSeller((uint256,address,address,address,address,bool,string),(uint256,uint8),(string,uint256))",
401
+ "createSeller((uint256,address,address,address,address,bool,string),(uint256,uint8),(string,uint256,bytes32))",
402
402
  functionSignature: encodeCreateSeller(args.createSellerArgs)
403
403
  });
404
404
  }
@@ -455,7 +455,7 @@ export async function signMetaTxCreateOffer(
455
455
  return signMetaTx({
456
456
  ...args,
457
457
  functionName:
458
- "createOffer((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,uint256)",
458
+ "createOffer((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool,uint256),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,uint256)",
459
459
  functionSignature: encodeCreateOffer(args.createOfferArgs)
460
460
  });
461
461
  }
@@ -486,7 +486,7 @@ export async function signMetaTxCreateOfferBatch(
486
486
  return signMetaTx({
487
487
  ...args,
488
488
  functionName:
489
- "createOfferBatch((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool)[],(uint256,uint256,uint256,uint256)[],(uint256,uint256,uint256)[],uint256[],uint256[])",
489
+ "createOfferBatch((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool,uint256)[],(uint256,uint256,uint256,uint256)[],(uint256,uint256,uint256)[],uint256[],uint256[])",
490
490
  functionSignature: encodeCreateOfferBatch(args.createOffersArgs)
491
491
  });
492
492
  }
@@ -605,7 +605,7 @@ export async function signMetaTxCreateGroup(
605
605
  return signMetaTx({
606
606
  ...args,
607
607
  functionName:
608
- "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint256,uint256,uint256))",
608
+ "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint8,uint256,uint256,uint256,uint256))",
609
609
  functionSignature: encodeCreateGroup(args.createGroupArgs)
610
610
  });
611
611
  }
@@ -786,7 +786,7 @@ export async function signMetaTxCreateOfferWithCondition(
786
786
  return signMetaTx({
787
787
  ...args,
788
788
  functionName:
789
- "createOfferWithCondition((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,(uint8,uint8,address,uint256,uint256,uint256),uint256)",
789
+ "createOfferWithCondition((uint256,uint256,uint256,uint256,uint256,uint256,address,string,string,bool,uint256),(uint256,uint256,uint256,uint256),(uint256,uint256,uint256),uint256,(uint8,uint8,address,uint8,uint256,uint256,uint256,uint256),uint256)",
790
790
  functionSignature: encodeCreateOfferWithCondition(
791
791
  args.offerToCreate,
792
792
  args.condition
@@ -850,6 +850,65 @@ export async function signMetaTxCommitToOffer(
850
850
  };
851
851
  }
852
852
 
853
+ export async function signMetaTxCommitToConditionalOffer(
854
+ args: BaseMetaTxArgs & {
855
+ offerId: BigNumberish;
856
+ tokenId: BigNumberish;
857
+ }
858
+ ): Promise<SignedMetaTx> {
859
+ const functionName = "commitToConditionalOffer(address,uint256,uint256)";
860
+
861
+ const offerType = [
862
+ { name: "buyer", type: "address" },
863
+ { name: "offerId", type: "uint256" },
864
+ { name: "tokenId", type: "uint256" }
865
+ ];
866
+
867
+ const metaTransactionType = [
868
+ { name: "nonce", type: "uint256" },
869
+ { name: "from", type: "address" },
870
+ { name: "contractAddress", type: "address" },
871
+ { name: "functionName", type: "string" },
872
+ { name: "offerDetails", type: "MetaTxConditionalOfferDetails" }
873
+ ];
874
+
875
+ const customSignatureType = {
876
+ MetaTxCommitToConditionalOffer: metaTransactionType,
877
+ MetaTxConditionalOfferDetails: offerType
878
+ };
879
+
880
+ const buyerAddress = await args.web3Lib.getSignerAddress();
881
+
882
+ const message = {
883
+ nonce: args.nonce.toString(),
884
+ from: buyerAddress,
885
+ contractAddress: args.metaTxHandlerAddress,
886
+ functionName,
887
+ offerDetails: {
888
+ buyer: buyerAddress,
889
+ offerId: args.offerId.toString(),
890
+ tokenId: args.tokenId.toString()
891
+ }
892
+ };
893
+
894
+ const signatureParams = await prepareDataSignatureParameters({
895
+ ...args,
896
+ verifyingContractAddress: args.metaTxHandlerAddress,
897
+ customSignatureType,
898
+ primaryType: "MetaTxCommitToConditionalOffer",
899
+ message
900
+ });
901
+
902
+ return {
903
+ ...signatureParams,
904
+ functionName,
905
+ functionSignature: bosonExchangeHandlerIface.encodeFunctionData(
906
+ "commitToConditionalOffer",
907
+ [buyerAddress, args.offerId, args.tokenId]
908
+ )
909
+ };
910
+ }
911
+
853
912
  export async function signMetaTxCancelVoucher(
854
913
  args: BaseMetaTxArgs & {
855
914
  exchangeId: BigNumberish;
@@ -1193,7 +1252,6 @@ export async function relayMetaTransaction(args: {
1193
1252
 
1194
1253
  const txHash = waitResponse.data.newHash;
1195
1254
  const txReceipt = await args.web3LibAdapter.getTransactionReceipt(txHash);
1196
- console.log("[relayBiconomyMetaTransaction.wait] txReceipt", txReceipt);
1197
1255
  return {
1198
1256
  to: txReceipt?.to || contractAddress,
1199
1257
  from: txReceipt?.from || metaTx.params.userAddress,
@@ -131,7 +131,6 @@ export class MetaTxMixin extends BaseCoreSDK {
131
131
  const fieldsToUpdate = {
132
132
  assistant:
133
133
  currentAccount === pendingSellerUpdate.assistant?.toLowerCase(),
134
- clerk: currentAccount === pendingSellerUpdate.clerk?.toLowerCase(),
135
134
  admin: currentAccount === pendingSellerUpdate.admin?.toLowerCase(),
136
135
  authToken:
137
136
  pendingSellerUpdate.authTokenType !== undefined &&
@@ -140,7 +139,6 @@ export class MetaTxMixin extends BaseCoreSDK {
140
139
  };
141
140
  if (
142
141
  fieldsToUpdate.assistant ||
143
- fieldsToUpdate.clerk ||
144
142
  fieldsToUpdate.admin ||
145
143
  fieldsToUpdate.authToken
146
144
  ) {
@@ -151,7 +149,6 @@ export class MetaTxMixin extends BaseCoreSDK {
151
149
  fieldsToUpdate: {
152
150
  assistant:
153
151
  currentAccount === pendingSellerUpdate.assistant.toLowerCase(),
154
- clerk: currentAccount === pendingSellerUpdate.clerk.toLowerCase(),
155
152
  admin: currentAccount === pendingSellerUpdate.admin.toLowerCase(),
156
153
  authToken: pendingSellerUpdate.authTokenType !== AuthTokenType.NONE
157
154
  }
@@ -596,6 +593,16 @@ export class MetaTxMixin extends BaseCoreSDK {
596
593
  "web3Lib" | "metaTxHandlerAddress" | "chainId"
597
594
  >
598
595
  ) {
596
+ const offer = await getOfferById(this._subgraphUrl, args.offerId);
597
+
598
+ if (offer.condition) {
599
+ // keep compatibility with previous version
600
+ return this.signMetaTxCommitToConditionalOffer({
601
+ ...args,
602
+ tokenId: offer.condition.minTokenId
603
+ });
604
+ }
605
+
599
606
  return handler.signMetaTxCommitToOffer({
600
607
  web3Lib: this._web3Lib,
601
608
  metaTxHandlerAddress: this._protocolDiamond,
@@ -604,6 +611,25 @@ export class MetaTxMixin extends BaseCoreSDK {
604
611
  });
605
612
  }
606
613
 
614
+ /**
615
+ * Encodes and signs a meta transaction for `commitToConditionalOffer` that can be relayed.
616
+ * @param args - Meta transaction args.
617
+ * @returns Signature.
618
+ */
619
+ public async signMetaTxCommitToConditionalOffer(
620
+ args: Omit<
621
+ Parameters<typeof handler.signMetaTxCommitToConditionalOffer>[0],
622
+ "web3Lib" | "metaTxHandlerAddress" | "chainId"
623
+ >
624
+ ) {
625
+ return handler.signMetaTxCommitToConditionalOffer({
626
+ web3Lib: this._web3Lib,
627
+ metaTxHandlerAddress: this._protocolDiamond,
628
+ chainId: this._chainId,
629
+ ...args
630
+ });
631
+ }
632
+
607
633
  /**
608
634
  * Encodes and signs a meta transaction for `cancelVoucher` that can be relayed.
609
635
  * @param args - Meta transaction args.
@@ -408,8 +408,13 @@ export class OfferMixin extends BaseCoreSDK {
408
408
  offerCondition: subgraph.OfferFieldsFragment["condition"],
409
409
  buyerAddress: string
410
410
  ): Promise<boolean> {
411
- const { tokenId, tokenType, threshold, method, tokenAddress } =
412
- offerCondition;
411
+ const {
412
+ minTokenId: tokenId,
413
+ tokenType,
414
+ threshold,
415
+ method,
416
+ tokenAddress
417
+ } = offerCondition;
413
418
  if (tokenType === TokenType.FungibleToken) {
414
419
  const balance: string = await erc20.handler.balanceOf({
415
420
  contractAddress: tokenAddress,
@@ -71,6 +71,7 @@ fragment BaseOfferFields on Offer {
71
71
  metadataHash
72
72
  voided
73
73
  voidedAt
74
+ collectionIndex
74
75
  disputeResolverId
75
76
  numberOfCommits
76
77
  numberOfRedemptions
@@ -4,7 +4,6 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
4
4
  import { utils } from "@bosonprotocol/common";
5
5
  import Mustache from "mustache";
6
6
  import { formatUnits } from "@ethersproject/units";
7
- import { productV1 } from "@bosonprotocol/metadata";
8
7
 
9
8
  import { CreateOfferArgs } from "./types";
10
9
  import {
@@ -6,6 +6,7 @@ import { createOfferArgsToStructs } from "../offers/interface";
6
6
  import { CreateSellerArgs } from "../accounts/types";
7
7
  import { CreateOfferArgs } from "../offers/types";
8
8
  import { BigNumberish } from "@ethersproject/bignumber";
9
+ import { conditionArgsToStructs } from "../groups/interface";
9
10
 
10
11
  export const bosonOrchestrationHandlerIface = new Interface(
11
12
  abis.IBosonOrchestrationHandlerABI
@@ -44,7 +45,7 @@ export function encodeCreateOfferWithCondition(
44
45
  offerArgs[1], // offerDates
45
46
  offerArgs[2], // offerDurations
46
47
  offerArgs[3], // disputeResolverId
47
- condition,
48
+ conditionArgsToStructs(condition),
48
49
  offerArgs[4] // agentId
49
50
  ]
50
51
  );
@@ -65,7 +66,7 @@ export function encodeCreateSellerAndOfferWithCondition(
65
66
  offerArgs[1], // offerDates
66
67
  offerArgs[2], // offerDurations
67
68
  offerArgs[3], // disputeResolverId
68
- condition,
69
+ conditionArgsToStructs(condition),
69
70
  sellerArgs.authTokenStruct,
70
71
  sellerArgs.voucherInitValues,
71
72
  offerArgs[4] // agentId
@@ -108,7 +109,7 @@ export function encodeCreatePremintedOfferWithCondition(
108
109
  offerArgs[2], // offerDurations
109
110
  offerArgs[3], // disputeResolverId
110
111
  reservedRangeLength,
111
- condition,
112
+ conditionArgsToStructs(condition),
112
113
  offerArgs[4] // agentId
113
114
  ]
114
115
  );
@@ -154,7 +155,7 @@ export function encodeCreateSellerAndPremintedOfferWithCondition(
154
155
  offerArgs[2], // offerDurations
155
156
  offerArgs[3], // disputeResolverId
156
157
  reservedRangeLength,
157
- condition,
158
+ conditionArgsToStructs(condition),
158
159
  sellerArgs.authTokenStruct,
159
160
  sellerArgs.voucherInitValues,
160
161
  offerArgs[4] // agentId