@bosonprotocol/core-sdk 1.22.0-alpha.5 → 1.22.0-alpha.7

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 (37) hide show
  1. package/dist/cjs/core-sdk.d.ts +24 -0
  2. package/dist/cjs/core-sdk.d.ts.map +1 -1
  3. package/dist/cjs/core-sdk.js +42 -0
  4. package/dist/cjs/core-sdk.js.map +1 -1
  5. package/dist/cjs/meta-tx/handler.d.ts +8 -1
  6. package/dist/cjs/meta-tx/handler.d.ts.map +1 -1
  7. package/dist/cjs/meta-tx/handler.js +15 -1
  8. package/dist/cjs/meta-tx/handler.js.map +1 -1
  9. package/dist/cjs/orchestration/handler.d.ts +9 -0
  10. package/dist/cjs/orchestration/handler.d.ts.map +1 -1
  11. package/dist/cjs/orchestration/handler.js +18 -1
  12. package/dist/cjs/orchestration/handler.js.map +1 -1
  13. package/dist/cjs/orchestration/interface.d.ts +1 -0
  14. package/dist/cjs/orchestration/interface.d.ts.map +1 -1
  15. package/dist/cjs/orchestration/interface.js +17 -1
  16. package/dist/cjs/orchestration/interface.js.map +1 -1
  17. package/dist/esm/core-sdk.d.ts +24 -0
  18. package/dist/esm/core-sdk.d.ts.map +1 -1
  19. package/dist/esm/core-sdk.js +46 -0
  20. package/dist/esm/core-sdk.js.map +1 -1
  21. package/dist/esm/meta-tx/handler.d.ts +8 -1
  22. package/dist/esm/meta-tx/handler.d.ts.map +1 -1
  23. package/dist/esm/meta-tx/handler.js +16 -0
  24. package/dist/esm/meta-tx/handler.js.map +1 -1
  25. package/dist/esm/orchestration/handler.d.ts +9 -0
  26. package/dist/esm/orchestration/handler.d.ts.map +1 -1
  27. package/dist/esm/orchestration/handler.js +15 -1
  28. package/dist/esm/orchestration/handler.js.map +1 -1
  29. package/dist/esm/orchestration/interface.d.ts +1 -0
  30. package/dist/esm/orchestration/interface.d.ts.map +1 -1
  31. package/dist/esm/orchestration/interface.js +15 -0
  32. package/dist/esm/orchestration/interface.js.map +1 -1
  33. package/package.json +3 -3
  34. package/src/core-sdk.ts +65 -0
  35. package/src/meta-tx/handler.ts +35 -1
  36. package/src/orchestration/handler.ts +31 -1
  37. package/src/orchestration/interface.ts +23 -0
@@ -5,7 +5,9 @@ import {
5
5
  Web3LibAdapter,
6
6
  TransactionResponse,
7
7
  utils,
8
- MetadataStorage
8
+ MetadataStorage,
9
+ CreateGroupArgs,
10
+ ConditionStruct
9
11
  } from "@bosonprotocol/common";
10
12
  import { storeMetadataOnTheGraph } from "../offers/storage";
11
13
  import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
@@ -24,6 +26,8 @@ import { isAddress } from "@ethersproject/address";
24
26
  import { AddressZero } from "@ethersproject/constants";
25
27
  import { encodeDepositFunds, encodeWithdrawFunds } from "../funds/interface";
26
28
  import { bosonDisputeHandlerIface } from "../disputes/interface";
29
+ import { encodeCreateGroup } from "../groups/interface";
30
+ import { encodeCreateOfferWithCondition } from "../orchestration/interface";
27
31
 
28
32
  export type BaseMetaTxArgs = {
29
33
  web3Lib: Web3LibAdapter;
@@ -211,6 +215,36 @@ export async function signMetaTxExpireVoucher(
211
215
  });
212
216
  }
213
217
 
218
+ export async function signMetaTxCreateGroup(
219
+ args: BaseMetaTxArgs & {
220
+ createGroupArgs: CreateGroupArgs;
221
+ }
222
+ ) {
223
+ return signMetaTx({
224
+ ...args,
225
+ functionName:
226
+ "createGroup((uint256,uint256,uint256[]),(uint8,uint8,address,uint256,uint256,uint256))",
227
+ functionSignature: encodeCreateGroup(args.createGroupArgs)
228
+ });
229
+ }
230
+
231
+ export async function signMetaTxCreateOfferWithCondition(
232
+ args: BaseMetaTxArgs & {
233
+ offerToCreate: CreateOfferArgs;
234
+ condition: ConditionStruct;
235
+ }
236
+ ) {
237
+ return signMetaTx({
238
+ ...args,
239
+ functionName:
240
+ "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)",
241
+ functionSignature: encodeCreateOfferWithCondition(
242
+ args.offerToCreate,
243
+ args.condition
244
+ )
245
+ });
246
+ }
247
+
214
248
  export async function signMetaTxCommitToOffer(
215
249
  args: BaseMetaTxArgs & {
216
250
  offerId: BigNumberish;
@@ -7,7 +7,8 @@ import {
7
7
  } from "@bosonprotocol/common";
8
8
  import {
9
9
  encodeCreateOfferWithCondition,
10
- encodeCreateSellerAndOffer
10
+ encodeCreateSellerAndOffer,
11
+ encodeCreateSellerAndOfferWithCondition
11
12
  } from "./interface";
12
13
  import { storeMetadataOnTheGraph } from "../offers/storage";
13
14
 
@@ -65,3 +66,32 @@ export async function createOfferWithCondition(args: {
65
66
  data: encodeCreateOfferWithCondition(args.offerToCreate, args.condition)
66
67
  });
67
68
  }
69
+
70
+ export async function createSellerAndOfferWithCondition(args: {
71
+ sellerToCreate: CreateSellerArgs;
72
+ offerToCreate: CreateOfferArgs;
73
+ contractAddress: string;
74
+ web3Lib: Web3LibAdapter;
75
+ metadataStorage?: MetadataStorage;
76
+ theGraphStorage?: MetadataStorage;
77
+ condition: ConditionStruct;
78
+ }): Promise<TransactionResponse> {
79
+ utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
80
+ abortEarly: false
81
+ });
82
+
83
+ await storeMetadataOnTheGraph({
84
+ metadataUriOrHash: args.offerToCreate.metadataUri,
85
+ metadataStorage: args.metadataStorage,
86
+ theGraphStorage: args.theGraphStorage
87
+ });
88
+
89
+ return args.web3Lib.sendTransaction({
90
+ to: args.contractAddress,
91
+ data: encodeCreateSellerAndOfferWithCondition(
92
+ args.sellerToCreate,
93
+ args.offerToCreate,
94
+ args.condition
95
+ )
96
+ });
97
+ }
@@ -48,3 +48,26 @@ export function encodeCreateOfferWithCondition(
48
48
  ]
49
49
  );
50
50
  }
51
+
52
+ export function encodeCreateSellerAndOfferWithCondition(
53
+ seller: CreateSellerArgs,
54
+ offer: CreateOfferArgs,
55
+ condition: ConditionStruct
56
+ ) {
57
+ const sellerArgs = createSellerArgsToStruct(seller);
58
+ const offerArgs = createOfferArgsToStructs(offer);
59
+ return bosonOrchestrationHandlerIface.encodeFunctionData(
60
+ "createSellerAndOfferWithCondition",
61
+ [
62
+ sellerArgs.sellerStruct,
63
+ offerArgs[0], // offer
64
+ offerArgs[1], // offerDates
65
+ offerArgs[2], // offerDurations
66
+ offerArgs[3], // disputeResolverId
67
+ condition,
68
+ sellerArgs.authTokenStruct,
69
+ sellerArgs.voucherInitValues,
70
+ offerArgs[4] // agentId
71
+ ]
72
+ );
73
+ }