@bosonprotocol/core-sdk 1.1.1 → 1.2.0-alpha.0

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 (132) hide show
  1. package/dist/cjs/accounts/index.d.ts +17 -0
  2. package/dist/cjs/accounts/index.d.ts.map +1 -0
  3. package/dist/cjs/accounts/index.js +37 -0
  4. package/dist/cjs/accounts/index.js.map +1 -0
  5. package/dist/cjs/accounts/interface.d.ts +6 -0
  6. package/dist/cjs/accounts/interface.d.ts.map +1 -0
  7. package/dist/cjs/accounts/interface.js +11 -0
  8. package/dist/cjs/accounts/interface.js.map +1 -0
  9. package/dist/cjs/accounts/subgraph.d.ts +5 -0
  10. package/dist/cjs/accounts/subgraph.d.ts.map +1 -0
  11. package/dist/cjs/accounts/subgraph.js +39 -0
  12. package/dist/cjs/accounts/subgraph.js.map +1 -0
  13. package/dist/cjs/accounts/types.d.ts +10 -0
  14. package/dist/cjs/accounts/types.d.ts.map +1 -0
  15. package/dist/cjs/accounts/types.js +3 -0
  16. package/dist/cjs/accounts/types.js.map +1 -0
  17. package/dist/cjs/core-sdk.d.ts +8 -1
  18. package/dist/cjs/core-sdk.d.ts.map +1 -1
  19. package/dist/cjs/core-sdk.js +31 -3
  20. package/dist/cjs/core-sdk.js.map +1 -1
  21. package/dist/cjs/offers/handler.d.ts +0 -5
  22. package/dist/cjs/offers/handler.d.ts.map +1 -1
  23. package/dist/cjs/offers/handler.js +10 -23
  24. package/dist/cjs/offers/handler.js.map +1 -1
  25. package/dist/cjs/offers/index.d.ts +11 -12
  26. package/dist/cjs/offers/index.d.ts.map +1 -1
  27. package/dist/cjs/offers/index.js +2 -1
  28. package/dist/cjs/offers/index.js.map +1 -1
  29. package/dist/cjs/offers/interface.d.ts +1 -3
  30. package/dist/cjs/offers/interface.d.ts.map +1 -1
  31. package/dist/cjs/offers/interface.js +3 -16
  32. package/dist/cjs/offers/interface.js.map +1 -1
  33. package/dist/cjs/offers/storage.d.ts +13 -0
  34. package/dist/cjs/offers/storage.d.ts.map +1 -0
  35. package/dist/cjs/offers/storage.js +30 -0
  36. package/dist/cjs/offers/storage.js.map +1 -0
  37. package/dist/cjs/offers/subgraph.d.ts +3 -3
  38. package/dist/cjs/offers/subgraph.d.ts.map +1 -1
  39. package/dist/cjs/offers/subgraph.js +23 -16
  40. package/dist/cjs/offers/subgraph.js.map +1 -1
  41. package/dist/cjs/offers/types.d.ts +11 -6
  42. package/dist/cjs/offers/types.d.ts.map +1 -1
  43. package/dist/cjs/orchestration/handler.d.ts +12 -0
  44. package/dist/cjs/orchestration/handler.d.ts.map +1 -0
  45. package/dist/cjs/orchestration/handler.js +36 -0
  46. package/dist/cjs/orchestration/handler.js.map +1 -0
  47. package/dist/cjs/orchestration/index.d.ts +3 -0
  48. package/dist/cjs/orchestration/index.d.ts.map +1 -0
  49. package/dist/cjs/orchestration/index.js +29 -0
  50. package/dist/cjs/orchestration/index.js.map +1 -0
  51. package/dist/cjs/orchestration/interface.d.ts +6 -0
  52. package/dist/cjs/orchestration/interface.d.ts.map +1 -0
  53. package/dist/cjs/orchestration/interface.js +13 -0
  54. package/dist/cjs/orchestration/interface.js.map +1 -0
  55. package/dist/cjs/utils/logs.d.ts +4 -0
  56. package/dist/cjs/utils/logs.d.ts.map +1 -0
  57. package/dist/cjs/utils/logs.js +13 -0
  58. package/dist/cjs/utils/logs.js.map +1 -0
  59. package/dist/esm/accounts/index.d.ts +17 -0
  60. package/dist/esm/accounts/index.d.ts.map +1 -0
  61. package/dist/esm/accounts/index.js +8 -0
  62. package/dist/esm/accounts/index.js.map +1 -0
  63. package/dist/esm/accounts/interface.d.ts +6 -0
  64. package/dist/esm/accounts/interface.d.ts.map +1 -0
  65. package/dist/esm/accounts/interface.js +11 -0
  66. package/dist/esm/accounts/interface.js.map +1 -0
  67. package/dist/esm/accounts/subgraph.d.ts +5 -0
  68. package/dist/esm/accounts/subgraph.d.ts.map +1 -0
  69. package/dist/esm/accounts/subgraph.js +24 -0
  70. package/dist/esm/accounts/subgraph.js.map +1 -0
  71. package/dist/esm/accounts/types.d.ts +10 -0
  72. package/dist/esm/accounts/types.d.ts.map +1 -0
  73. package/dist/esm/accounts/types.js +2 -0
  74. package/dist/esm/accounts/types.js.map +1 -0
  75. package/dist/esm/core-sdk.d.ts +8 -1
  76. package/dist/esm/core-sdk.d.ts.map +1 -1
  77. package/dist/esm/core-sdk.js +27 -3
  78. package/dist/esm/core-sdk.js.map +1 -1
  79. package/dist/esm/offers/handler.d.ts +0 -5
  80. package/dist/esm/offers/handler.d.ts.map +1 -1
  81. package/dist/esm/offers/handler.js +9 -19
  82. package/dist/esm/offers/handler.js.map +1 -1
  83. package/dist/esm/offers/index.d.ts +11 -12
  84. package/dist/esm/offers/index.d.ts.map +1 -1
  85. package/dist/esm/offers/index.js +1 -0
  86. package/dist/esm/offers/index.js.map +1 -1
  87. package/dist/esm/offers/interface.d.ts +1 -3
  88. package/dist/esm/offers/interface.d.ts.map +1 -1
  89. package/dist/esm/offers/interface.js +3 -14
  90. package/dist/esm/offers/interface.js.map +1 -1
  91. package/dist/esm/offers/storage.d.ts +13 -0
  92. package/dist/esm/offers/storage.d.ts.map +1 -0
  93. package/dist/esm/offers/storage.js +15 -0
  94. package/dist/esm/offers/storage.js.map +1 -0
  95. package/dist/esm/offers/subgraph.d.ts +3 -3
  96. package/dist/esm/offers/subgraph.d.ts.map +1 -1
  97. package/dist/esm/offers/subgraph.js +22 -15
  98. package/dist/esm/offers/subgraph.js.map +1 -1
  99. package/dist/esm/offers/types.d.ts +11 -6
  100. package/dist/esm/offers/types.d.ts.map +1 -1
  101. package/dist/esm/orchestration/handler.d.ts +12 -0
  102. package/dist/esm/orchestration/handler.d.ts.map +1 -0
  103. package/dist/esm/orchestration/handler.js +21 -0
  104. package/dist/esm/orchestration/handler.js.map +1 -0
  105. package/dist/esm/orchestration/index.d.ts +3 -0
  106. package/dist/esm/orchestration/index.d.ts.map +1 -0
  107. package/dist/esm/orchestration/index.js +3 -0
  108. package/dist/esm/orchestration/index.js.map +1 -0
  109. package/dist/esm/orchestration/interface.d.ts +6 -0
  110. package/dist/esm/orchestration/interface.d.ts.map +1 -0
  111. package/dist/esm/orchestration/interface.js +9 -0
  112. package/dist/esm/orchestration/interface.js.map +1 -0
  113. package/dist/esm/utils/logs.d.ts +4 -0
  114. package/dist/esm/utils/logs.d.ts.map +1 -0
  115. package/dist/esm/utils/logs.js +9 -0
  116. package/dist/esm/utils/logs.js.map +1 -0
  117. package/package.json +3 -3
  118. package/src/accounts/index.ts +9 -0
  119. package/src/accounts/interface.ts +17 -0
  120. package/src/accounts/subgraph.ts +35 -0
  121. package/src/accounts/types.ts +10 -0
  122. package/src/core-sdk.ts +49 -7
  123. package/src/offers/handler.ts +9 -26
  124. package/src/offers/index.ts +1 -0
  125. package/src/offers/interface.ts +4 -23
  126. package/src/offers/storage.ts +23 -0
  127. package/src/offers/subgraph.ts +25 -18
  128. package/src/offers/types.ts +11 -6
  129. package/src/orchestration/handler.ts +39 -0
  130. package/src/orchestration/index.ts +2 -0
  131. package/src/orchestration/interface.ts +21 -0
  132. package/src/utils/logs.ts +16 -0
package/src/core-sdk.ts CHANGED
@@ -7,8 +7,11 @@ import {
7
7
  Log
8
8
  } from "@bosonprotocol/common";
9
9
  import { BigNumberish } from "@ethersproject/bignumber";
10
+ import * as accounts from "./accounts";
10
11
  import * as offers from "./offers";
12
+ import * as orchestration from "./orchestration";
11
13
  import * as erc20 from "./erc20";
14
+ import { getCreatedOfferIdFromLogs } from "./utils/logs";
12
15
  import { MultiQueryOpts } from "./utils/subgraph";
13
16
 
14
17
  export class CoreSDK {
@@ -70,6 +73,29 @@ export class CoreSDK {
70
73
  return this._metadataStorage.getMetadata(metadataHashOrUri);
71
74
  }
72
75
 
76
+ public async getSellerByOperator(
77
+ operator: string
78
+ ): Promise<accounts.RawSellerFromSubgraph> {
79
+ return accounts.subgraph.getSellerByOperator(this._subgraphUrl, operator);
80
+ }
81
+
82
+ public async createSellerAndOffer(
83
+ sellerToCreate: accounts.CreateSellerArgs,
84
+ offerToCreate: offers.CreateOfferArgs,
85
+ overrides: Partial<{
86
+ contractAddress: string;
87
+ }> = {}
88
+ ): Promise<TransactionResponse> {
89
+ return orchestration.handler.createOfferAndSeller({
90
+ sellerToCreate,
91
+ offerToCreate,
92
+ web3Lib: this._web3Lib,
93
+ theGraphStorage: this._theGraphStorage,
94
+ metadataStorage: this._metadataStorage,
95
+ contractAddress: overrides.contractAddress || this._protocolDiamond
96
+ });
97
+ }
98
+
73
99
  public async createOffer(
74
100
  offerToCreate: offers.CreateOfferArgs,
75
101
  overrides: Partial<{
@@ -86,7 +112,17 @@ export class CoreSDK {
86
112
  }
87
113
 
88
114
  public getCreatedOfferIdFromLogs(logs: Log[]): string | null {
89
- return offers.iface.getCreatedOfferIdFromLogs(logs);
115
+ try {
116
+ return getCreatedOfferIdFromLogs(
117
+ offers.iface.bosonOfferHandlerIface,
118
+ logs
119
+ );
120
+ } catch (offerError) {
121
+ return getCreatedOfferIdFromLogs(
122
+ orchestration.iface.bosonOrchestrationHandlerIface,
123
+ logs
124
+ );
125
+ }
90
126
  }
91
127
 
92
128
  public async voidOffer(
@@ -110,14 +146,20 @@ export class CoreSDK {
110
146
  }
111
147
 
112
148
  public async getAllOffersOfSeller(
113
- sellerAddress: string,
149
+ sellerFilter: {
150
+ operatorAddress: string;
151
+ // TODO: add support for sellerId, adminAddress, clerkAddress, treasuryAddress
152
+ },
114
153
  opts: MultiQueryOpts = {}
115
154
  ): Promise<offers.RawOfferFromSubgraph[]> {
116
- return offers.subgraph.getAllOffersOfSeller(
117
- this._subgraphUrl,
118
- sellerAddress,
119
- opts
120
- );
155
+ if (sellerFilter.operatorAddress) {
156
+ return offers.subgraph.getAllOffersOfOperator(
157
+ this._subgraphUrl,
158
+ sellerFilter.operatorAddress,
159
+ opts
160
+ );
161
+ }
162
+ return [];
121
163
  }
122
164
 
123
165
  public async getExchangeTokenAllowance(
@@ -7,6 +7,7 @@ import {
7
7
  } from "@bosonprotocol/common";
8
8
  import { bosonOfferHandlerIface, encodeCreateOffer } from "./interface";
9
9
  import { getOfferById } from "./subgraph";
10
+ import { storeMetadataOnTheGraph } from "./storage";
10
11
  import { CreateOfferArgs } from "./types";
11
12
 
12
13
  export async function createOffer(args: {
@@ -16,21 +17,15 @@ export async function createOffer(args: {
16
17
  metadataStorage?: MetadataStorage;
17
18
  theGraphStorage?: MetadataStorage;
18
19
  }): Promise<TransactionResponse> {
19
- await utils.validation.createOfferArgsSchema.validate(args.offerToCreate, {
20
+ utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
20
21
  abortEarly: false
21
22
  });
22
23
 
23
- // We use the feature `ipfsOnEthereum` in our subgraph to resolve metadata from IPFS
24
- // and store them in the graph. In order for the graph node to reliably resolve them,
25
- // we need to add the metadata additionally to the IPFS node of the graph.
26
- // See https://thegraph.com/docs/en/developer/assemblyscript-api/#ipfs-api
27
- if (args.metadataStorage && args.theGraphStorage) {
28
- await storeMetadataOnTheGraph({
29
- metadataUriOrHash: args.offerToCreate.metadataHash,
30
- metadataStorage: args.metadataStorage,
31
- theGraphStorage: args.theGraphStorage
32
- });
33
- }
24
+ await storeMetadataOnTheGraph({
25
+ metadataUriOrHash: args.offerToCreate.metadataUri,
26
+ metadataStorage: args.metadataStorage,
27
+ theGraphStorage: args.theGraphStorage
28
+ });
34
29
 
35
30
  return args.web3Lib.sendTransaction({
36
31
  to: args.contractAddress,
@@ -55,9 +50,9 @@ export async function voidOffer(args: {
55
50
  }
56
51
 
57
52
  const signerAddress = await args.web3Lib.getSignerAddress();
58
- if (offer.seller.address.toLowerCase() !== signerAddress.toLowerCase()) {
53
+ if (offer.seller.operator.toLowerCase() !== signerAddress.toLowerCase()) {
59
54
  throw new Error(
60
- `Signer with address "${signerAddress}" is not the seller "${offer.seller.address}"`
55
+ `Signer with address "${signerAddress}" is not the operator "${offer.seller.operator}"`
61
56
  );
62
57
  }
63
58
 
@@ -66,15 +61,3 @@ export async function voidOffer(args: {
66
61
  data: bosonOfferHandlerIface.encodeFunctionData("voidOffer", [args.offerId])
67
62
  });
68
63
  }
69
-
70
- export async function storeMetadataOnTheGraph(args: {
71
- metadataUriOrHash: string;
72
- metadataStorage: MetadataStorage;
73
- theGraphStorage: MetadataStorage;
74
- }): Promise<string> {
75
- const metadata = await args.metadataStorage.getMetadata(
76
- args.metadataUriOrHash
77
- );
78
- const metadataUri = await args.theGraphStorage.storeMetadata(metadata);
79
- return metadataUri;
80
- }
@@ -3,6 +3,7 @@ import { utils } from "@bosonprotocol/common";
3
3
  export * as handler from "./handler";
4
4
  export * as subgraph from "./subgraph";
5
5
  export * as iface from "./interface";
6
+ export * as storage from "./storage";
6
7
  export * from "./types";
7
8
 
8
9
  export const validation = {
@@ -1,28 +1,10 @@
1
- import { OfferStruct, utils, abis, Log } from "@bosonprotocol/common";
1
+ import { OfferStruct, utils, abis } from "@bosonprotocol/common";
2
2
  import { Interface } from "@ethersproject/abi";
3
3
  import { getAddress } from "@ethersproject/address";
4
4
  import { CreateOfferArgs } from "./types";
5
5
 
6
6
  export const bosonOfferHandlerIface = new Interface(abis.IBosonOfferHandlerABI);
7
7
 
8
- export function getCreatedOfferIdFromLogs(logs: Log[]) {
9
- const parsedLogs = logs.map((log) => parseLog(log.data, log.topics));
10
-
11
- const [offerCreatedLog] = parsedLogs.filter(
12
- (log) => log.name === "OfferCreated"
13
- );
14
-
15
- if (!offerCreatedLog) {
16
- return null;
17
- }
18
-
19
- return String(offerCreatedLog.args.offerId);
20
- }
21
-
22
- export function parseLog(data: string, topics: string[]) {
23
- return bosonOfferHandlerIface.parseLog({ data, topics });
24
- }
25
-
26
8
  export function encodeCreateOffer(args: CreateOfferArgs) {
27
9
  return bosonOfferHandlerIface.encodeFunctionData("createOffer", [
28
10
  createOfferArgsToStruct(args)
@@ -34,10 +16,9 @@ export function createOfferArgsToStruct(
34
16
  ): Partial<OfferStruct> {
35
17
  const {
36
18
  exchangeToken,
37
- seller,
38
19
  validFromDateInMS,
39
20
  validUntilDateInMS,
40
- redeemableDateInMS,
21
+ redeemableFromDateInMS,
41
22
  fulfillmentPeriodDurationInMS,
42
23
  voucherValidDurationInMS,
43
24
  ...restArgs
@@ -45,12 +26,12 @@ export function createOfferArgsToStruct(
45
26
 
46
27
  return {
47
28
  id: "0",
29
+ sellerId: "0",
48
30
  ...restArgs,
49
31
  exchangeToken: getAddress(exchangeToken),
50
- seller: getAddress(seller),
51
32
  validFromDate: utils.timestamp.msToSec(validFromDateInMS),
52
33
  validUntilDate: utils.timestamp.msToSec(validUntilDateInMS),
53
- redeemableDate: utils.timestamp.msToSec(redeemableDateInMS),
34
+ redeemableFromDate: utils.timestamp.msToSec(redeemableFromDateInMS),
54
35
  fulfillmentPeriodDuration: utils.timestamp.msToSec(
55
36
  fulfillmentPeriodDurationInMS
56
37
  ),
@@ -0,0 +1,23 @@
1
+ import { MetadataStorage } from "@bosonprotocol/common";
2
+
3
+ /**
4
+ * We use the feature `ipfsOnEthereum` in our subgraph to resolve metadata from IPFS
5
+ * and store them in the graph. In order for the graph node to reliably resolve them,
6
+ * we need to add the metadata additionally to the IPFS node of the graph.
7
+ * See https://thegraph.com/docs/en/developer/assemblyscript-api/#ipfs-api
8
+ */
9
+ export async function storeMetadataOnTheGraph(args: {
10
+ metadataUriOrHash: string;
11
+ metadataStorage?: MetadataStorage;
12
+ theGraphStorage?: MetadataStorage;
13
+ }): Promise<string | null> {
14
+ if (args.metadataStorage && args.theGraphStorage) {
15
+ const metadata = await args.metadataStorage.getMetadata(
16
+ args.metadataUriOrHash
17
+ );
18
+ const metadataUri = await args.theGraphStorage.storeMetadata(metadata);
19
+ return metadataUri;
20
+ }
21
+
22
+ return null;
23
+ }
@@ -7,19 +7,24 @@ fragment offerFields on Offer {
7
7
  id
8
8
  createdAt
9
9
  price
10
- deposit
11
- penalty
12
- quantity
10
+ sellerDeposit
11
+ buyerCancelPenalty
12
+ quantityAvailable
13
13
  validFromDate
14
14
  validUntilDate
15
- redeemableDate
15
+ redeemableFromDate
16
16
  fulfillmentPeriodDuration
17
17
  voucherValidDuration
18
18
  metadataUri
19
- metadataHash
19
+ offerChecksum
20
20
  voidedAt
21
21
  seller {
22
- address
22
+ id
23
+ operator
24
+ admin
25
+ clerk
26
+ treasury
27
+ active
23
28
  }
24
29
  exchangeToken {
25
30
  address
@@ -59,15 +64,17 @@ export async function getOfferById(
59
64
  return offer;
60
65
  }
61
66
 
62
- export const getAllOffersOfSellerQuery = `
63
- query GetAllOffersOfSellerQuery(
64
- $seller: ID!,
67
+ export const getAllOffersOfOperatorQuery = `
68
+ query GetAllOffersOfOperatorQuery(
69
+ $operator: String!,
65
70
  $first: Int,
66
71
  $skip: Int,
67
72
  $orderBy: String,
68
73
  $orderDirection: String
69
74
  ) {
70
- seller(id: $seller) {
75
+ sellers(where: {
76
+ operator: $operator
77
+ }) {
71
78
  offers(
72
79
  first: $first
73
80
  skip: $skip
@@ -81,15 +88,15 @@ query GetAllOffersOfSellerQuery(
81
88
  ${offerFieldsFragment}
82
89
  `;
83
90
 
84
- export async function getAllOffersOfSeller(
91
+ export async function getAllOffersOfOperator(
85
92
  subgraphUrl: string,
86
- sellerAddress: string,
93
+ operatorAddress: string,
87
94
  opts: MultiQueryOpts = {}
88
95
  ): Promise<RawOfferFromSubgraph[]> {
89
- const { seller } = await fetchSubgraph<{
90
- seller: { offers: RawOfferFromSubgraph[] };
91
- }>(subgraphUrl, getAllOffersOfSellerQuery, {
92
- seller: sellerAddress.toLowerCase(),
96
+ const { sellers } = await fetchSubgraph<{
97
+ sellers: { offers: RawOfferFromSubgraph[] };
98
+ }>(subgraphUrl, getAllOffersOfOperatorQuery, {
99
+ operator: operatorAddress.toLowerCase(),
93
100
  first: 100,
94
101
  skip: 0,
95
102
  orderBy: "createdAt",
@@ -97,9 +104,9 @@ export async function getAllOffersOfSeller(
97
104
  ...opts
98
105
  });
99
106
 
100
- if (!seller) {
107
+ if (!sellers) {
101
108
  return [];
102
109
  }
103
110
 
104
- return seller.offers;
111
+ return sellers[0].offers;
105
112
  }
@@ -4,19 +4,24 @@ export type RawOfferFromSubgraph = {
4
4
  id: string;
5
5
  createdAt: string;
6
6
  price: string;
7
- deposit: string;
8
- penalty: string;
9
- quantity: string;
7
+ sellerDeposit: string;
8
+ buyerCancelPenalty: string;
9
+ quantityAvailable: string;
10
10
  validFromDate: string;
11
11
  validUntilDate: string;
12
- redeemableDate: string;
12
+ redeemableFromDate: string;
13
13
  fulfillmentPeriodDuration: string;
14
14
  voucherValidDuration: string;
15
15
  metadataUri: string;
16
- metadataHash: string;
16
+ offerChecksum: string;
17
17
  voidedAt: null | string;
18
18
  seller: {
19
- address: string;
19
+ id: string;
20
+ operator: string;
21
+ admin: string;
22
+ clerk: string;
23
+ treasury: string;
24
+ active: boolean;
20
25
  };
21
26
  exchangeToken: {
22
27
  address: string;
@@ -0,0 +1,39 @@
1
+ import {
2
+ Web3LibAdapter,
3
+ TransactionResponse,
4
+ MetadataStorage,
5
+ utils
6
+ } from "@bosonprotocol/common";
7
+ import { encodeCreateSellerAndOffer } from "./interface";
8
+ import { storeMetadataOnTheGraph } from "../offers/storage";
9
+
10
+ import { CreateOfferArgs } from "../offers/types";
11
+ import { CreateSellerArgs } from "../accounts/types";
12
+
13
+ export async function createOfferAndSeller(args: {
14
+ offerToCreate: CreateOfferArgs;
15
+ sellerToCreate: CreateSellerArgs;
16
+ contractAddress: string;
17
+ web3Lib: Web3LibAdapter;
18
+ metadataStorage?: MetadataStorage;
19
+ theGraphStorage?: MetadataStorage;
20
+ }): Promise<TransactionResponse> {
21
+ utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
22
+ abortEarly: false
23
+ });
24
+
25
+ utils.validation.createSellerArgsSchema.validateSync(args.sellerToCreate, {
26
+ abortEarly: false
27
+ });
28
+
29
+ await storeMetadataOnTheGraph({
30
+ metadataUriOrHash: args.offerToCreate.metadataUri,
31
+ metadataStorage: args.metadataStorage,
32
+ theGraphStorage: args.theGraphStorage
33
+ });
34
+
35
+ return args.web3Lib.sendTransaction({
36
+ to: args.contractAddress,
37
+ data: encodeCreateSellerAndOffer(args.sellerToCreate, args.offerToCreate)
38
+ });
39
+ }
@@ -0,0 +1,2 @@
1
+ export * as handler from "./handler";
2
+ export * as iface from "./interface";
@@ -0,0 +1,21 @@
1
+ import { abis } from "@bosonprotocol/common";
2
+ import { Interface } from "@ethersproject/abi";
3
+ import { createSellerArgsToStruct } from "../accounts/interface";
4
+ import { createOfferArgsToStruct } from "../offers/interface";
5
+
6
+ import { CreateSellerArgs } from "../accounts/types";
7
+ import { CreateOfferArgs } from "../offers/types";
8
+
9
+ export const bosonOrchestrationHandlerIface = new Interface(
10
+ abis.IBosonOrchestrationHandlerABI
11
+ );
12
+
13
+ export function encodeCreateSellerAndOffer(
14
+ seller: CreateSellerArgs,
15
+ offer: CreateOfferArgs
16
+ ) {
17
+ return bosonOrchestrationHandlerIface.encodeFunctionData(
18
+ "createSellerAndOffer",
19
+ [createSellerArgsToStruct(seller), createOfferArgsToStruct(offer)]
20
+ );
21
+ }
@@ -0,0 +1,16 @@
1
+ import { Log } from "@bosonprotocol/common";
2
+ import { Interface } from "@ethersproject/abi";
3
+
4
+ export function getCreatedOfferIdFromLogs(iface: Interface, logs: Log[]) {
5
+ const parsedLogs = logs.map((log) => iface.parseLog(log));
6
+
7
+ const [offerCreatedLog] = parsedLogs.filter(
8
+ (log) => log.name === "OfferCreated"
9
+ );
10
+
11
+ if (!offerCreatedLog) {
12
+ return null;
13
+ }
14
+
15
+ return String(offerCreatedLog.args.offerId);
16
+ }