@bosonprotocol/core-sdk 1.1.1 → 1.2.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.
- package/dist/cjs/accounts/index.d.ts +17 -0
- package/dist/cjs/accounts/index.d.ts.map +1 -0
- package/dist/cjs/accounts/index.js +37 -0
- package/dist/cjs/accounts/index.js.map +1 -0
- package/dist/cjs/accounts/interface.d.ts +6 -0
- package/dist/cjs/accounts/interface.d.ts.map +1 -0
- package/dist/cjs/accounts/interface.js +11 -0
- package/dist/cjs/accounts/interface.js.map +1 -0
- package/dist/cjs/accounts/subgraph.d.ts +5 -0
- package/dist/cjs/accounts/subgraph.d.ts.map +1 -0
- package/dist/cjs/accounts/subgraph.js +39 -0
- package/dist/cjs/accounts/subgraph.js.map +1 -0
- package/dist/cjs/accounts/types.d.ts +10 -0
- package/dist/cjs/accounts/types.d.ts.map +1 -0
- package/dist/cjs/accounts/types.js +3 -0
- package/dist/cjs/accounts/types.js.map +1 -0
- package/dist/cjs/core-sdk.d.ts +8 -1
- package/dist/cjs/core-sdk.d.ts.map +1 -1
- package/dist/cjs/core-sdk.js +31 -3
- package/dist/cjs/core-sdk.js.map +1 -1
- package/dist/cjs/offers/handler.d.ts +0 -5
- package/dist/cjs/offers/handler.d.ts.map +1 -1
- package/dist/cjs/offers/handler.js +10 -23
- package/dist/cjs/offers/handler.js.map +1 -1
- package/dist/cjs/offers/index.d.ts +11 -12
- package/dist/cjs/offers/index.d.ts.map +1 -1
- package/dist/cjs/offers/index.js +2 -1
- package/dist/cjs/offers/index.js.map +1 -1
- package/dist/cjs/offers/interface.d.ts +1 -3
- package/dist/cjs/offers/interface.d.ts.map +1 -1
- package/dist/cjs/offers/interface.js +3 -16
- package/dist/cjs/offers/interface.js.map +1 -1
- package/dist/cjs/offers/storage.d.ts +13 -0
- package/dist/cjs/offers/storage.d.ts.map +1 -0
- package/dist/cjs/offers/storage.js +30 -0
- package/dist/cjs/offers/storage.js.map +1 -0
- package/dist/cjs/offers/subgraph.d.ts +3 -3
- package/dist/cjs/offers/subgraph.d.ts.map +1 -1
- package/dist/cjs/offers/subgraph.js +23 -16
- package/dist/cjs/offers/subgraph.js.map +1 -1
- package/dist/cjs/offers/types.d.ts +11 -6
- package/dist/cjs/offers/types.d.ts.map +1 -1
- package/dist/cjs/orchestration/handler.d.ts +12 -0
- package/dist/cjs/orchestration/handler.d.ts.map +1 -0
- package/dist/cjs/orchestration/handler.js +36 -0
- package/dist/cjs/orchestration/handler.js.map +1 -0
- package/dist/cjs/orchestration/index.d.ts +3 -0
- package/dist/cjs/orchestration/index.d.ts.map +1 -0
- package/dist/cjs/orchestration/index.js +29 -0
- package/dist/cjs/orchestration/index.js.map +1 -0
- package/dist/cjs/orchestration/interface.d.ts +6 -0
- package/dist/cjs/orchestration/interface.d.ts.map +1 -0
- package/dist/cjs/orchestration/interface.js +13 -0
- package/dist/cjs/orchestration/interface.js.map +1 -0
- package/dist/cjs/utils/logs.d.ts +4 -0
- package/dist/cjs/utils/logs.d.ts.map +1 -0
- package/dist/cjs/utils/logs.js +13 -0
- package/dist/cjs/utils/logs.js.map +1 -0
- package/dist/esm/accounts/index.d.ts +17 -0
- package/dist/esm/accounts/index.d.ts.map +1 -0
- package/dist/esm/accounts/index.js +8 -0
- package/dist/esm/accounts/index.js.map +1 -0
- package/dist/esm/accounts/interface.d.ts +6 -0
- package/dist/esm/accounts/interface.d.ts.map +1 -0
- package/dist/esm/accounts/interface.js +11 -0
- package/dist/esm/accounts/interface.js.map +1 -0
- package/dist/esm/accounts/subgraph.d.ts +5 -0
- package/dist/esm/accounts/subgraph.d.ts.map +1 -0
- package/dist/esm/accounts/subgraph.js +24 -0
- package/dist/esm/accounts/subgraph.js.map +1 -0
- package/dist/esm/accounts/types.d.ts +10 -0
- package/dist/esm/accounts/types.d.ts.map +1 -0
- package/dist/esm/accounts/types.js +2 -0
- package/dist/esm/accounts/types.js.map +1 -0
- package/dist/esm/core-sdk.d.ts +8 -1
- package/dist/esm/core-sdk.d.ts.map +1 -1
- package/dist/esm/core-sdk.js +27 -3
- package/dist/esm/core-sdk.js.map +1 -1
- package/dist/esm/offers/handler.d.ts +0 -5
- package/dist/esm/offers/handler.d.ts.map +1 -1
- package/dist/esm/offers/handler.js +9 -19
- package/dist/esm/offers/handler.js.map +1 -1
- package/dist/esm/offers/index.d.ts +11 -12
- package/dist/esm/offers/index.d.ts.map +1 -1
- package/dist/esm/offers/index.js +1 -0
- package/dist/esm/offers/index.js.map +1 -1
- package/dist/esm/offers/interface.d.ts +1 -3
- package/dist/esm/offers/interface.d.ts.map +1 -1
- package/dist/esm/offers/interface.js +3 -14
- package/dist/esm/offers/interface.js.map +1 -1
- package/dist/esm/offers/storage.d.ts +13 -0
- package/dist/esm/offers/storage.d.ts.map +1 -0
- package/dist/esm/offers/storage.js +15 -0
- package/dist/esm/offers/storage.js.map +1 -0
- package/dist/esm/offers/subgraph.d.ts +3 -3
- package/dist/esm/offers/subgraph.d.ts.map +1 -1
- package/dist/esm/offers/subgraph.js +22 -15
- package/dist/esm/offers/subgraph.js.map +1 -1
- package/dist/esm/offers/types.d.ts +11 -6
- package/dist/esm/offers/types.d.ts.map +1 -1
- package/dist/esm/orchestration/handler.d.ts +12 -0
- package/dist/esm/orchestration/handler.d.ts.map +1 -0
- package/dist/esm/orchestration/handler.js +21 -0
- package/dist/esm/orchestration/handler.js.map +1 -0
- package/dist/esm/orchestration/index.d.ts +3 -0
- package/dist/esm/orchestration/index.d.ts.map +1 -0
- package/dist/esm/orchestration/index.js +3 -0
- package/dist/esm/orchestration/index.js.map +1 -0
- package/dist/esm/orchestration/interface.d.ts +6 -0
- package/dist/esm/orchestration/interface.d.ts.map +1 -0
- package/dist/esm/orchestration/interface.js +9 -0
- package/dist/esm/orchestration/interface.js.map +1 -0
- package/dist/esm/utils/logs.d.ts +4 -0
- package/dist/esm/utils/logs.d.ts.map +1 -0
- package/dist/esm/utils/logs.js +9 -0
- package/dist/esm/utils/logs.js.map +1 -0
- package/package.json +3 -3
- package/src/accounts/index.ts +9 -0
- package/src/accounts/interface.ts +17 -0
- package/src/accounts/subgraph.ts +35 -0
- package/src/accounts/types.ts +10 -0
- package/src/core-sdk.ts +49 -7
- package/src/offers/handler.ts +9 -26
- package/src/offers/index.ts +1 -0
- package/src/offers/interface.ts +4 -23
- package/src/offers/storage.ts +23 -0
- package/src/offers/subgraph.ts +25 -18
- package/src/offers/types.ts +11 -6
- package/src/orchestration/handler.ts +39 -0
- package/src/orchestration/index.ts +2 -0
- package/src/orchestration/interface.ts +21 -0
- package/src/utils/logs.ts +16 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/offers/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,EACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/offers/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,EACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAGpD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAMjC;IACC,KAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;QACtE,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,MAAM,uBAAuB,CAAC;QAC5B,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,WAAW;QACjD,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,eAAe,EAAE,IAAI,CAAC,eAAe;KACtC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC;KAC5C,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAK/B;IACC,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAEjE,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,OAAO,kBAAkB,CAAC,CAAC;KACnE;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,OAAO,qBAAqB,CAAC,CAAC;KACtE;IAED,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAC5D,IAAI,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,aAAa,CAAC,WAAW,EAAE,EAAE;QACvE,MAAM,IAAI,KAAK,CACb,wBAAwB,aAAa,0BAA0B,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,CACxF,CAAC;KACH;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC7E,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
export * as handler from "./handler";
|
|
2
2
|
export * as subgraph from "./subgraph";
|
|
3
3
|
export * as iface from "./interface";
|
|
4
|
+
export * as storage from "./storage";
|
|
4
5
|
export * from "./types";
|
|
5
6
|
export declare const validation: {
|
|
6
7
|
createOfferArgsSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
7
8
|
price: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
sellerDeposit: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
10
|
+
buyerCancelPenalty: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
11
|
+
quantityAvailable: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
11
12
|
validFromDateInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
12
13
|
validUntilDateInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
13
|
-
|
|
14
|
+
redeemableFromDateInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
14
15
|
fulfillmentPeriodDurationInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
15
16
|
voucherValidDurationInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
16
|
-
seller: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
17
17
|
exchangeToken: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
18
18
|
metadataUri: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
19
|
-
|
|
19
|
+
offerChecksum: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
20
20
|
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
|
|
21
21
|
price: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
sellerDeposit: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
23
|
+
buyerCancelPenalty: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
24
|
+
quantityAvailable: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
25
25
|
validFromDateInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
26
26
|
validUntilDateInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
27
|
-
|
|
27
|
+
redeemableFromDateInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
28
28
|
fulfillmentPeriodDurationInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
29
29
|
voucherValidDurationInMS: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
30
|
-
seller: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
31
30
|
exchangeToken: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
32
31
|
metadataUri: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
33
|
-
|
|
32
|
+
offerChecksum: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
34
33
|
}>>;
|
|
35
34
|
baseMetadataSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
36
35
|
name: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAItB,CAAC"}
|
package/dist/esm/offers/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { utils } from "@bosonprotocol/common";
|
|
|
2
2
|
export * as handler from "./handler";
|
|
3
3
|
export * as subgraph from "./subgraph";
|
|
4
4
|
export * as iface from "./interface";
|
|
5
|
+
export * as storage from "./storage";
|
|
5
6
|
export * from "./types";
|
|
6
7
|
export const validation = {
|
|
7
8
|
createOfferArgsSchema: utils.validation.createOfferArgsSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,qBAAqB;IAC7D,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,kBAAkB;IACvD,uBAAuB,EAAE,KAAK,CAAC,UAAU,CAAC,uBAAuB;CAClE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/offers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,qBAAqB,EAAE,KAAK,CAAC,UAAU,CAAC,qBAAqB;IAC7D,kBAAkB,EAAE,KAAK,CAAC,UAAU,CAAC,kBAAkB;IACvD,uBAAuB,EAAE,KAAK,CAAC,UAAU,CAAC,uBAAuB;CAClE,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { OfferStruct
|
|
1
|
+
import { OfferStruct } from "@bosonprotocol/common";
|
|
2
2
|
import { Interface } from "@ethersproject/abi";
|
|
3
3
|
import { CreateOfferArgs } from "./types";
|
|
4
4
|
export declare const bosonOfferHandlerIface: Interface;
|
|
5
|
-
export declare function getCreatedOfferIdFromLogs(logs: Log[]): string;
|
|
6
|
-
export declare function parseLog(data: string, topics: string[]): import("@ethersproject/abi").LogDescription;
|
|
7
5
|
export declare function encodeCreateOffer(args: CreateOfferArgs): string;
|
|
8
6
|
export declare function createOfferArgsToStruct(args: CreateOfferArgs): Partial<OfferStruct>;
|
|
9
7
|
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/offers/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/offers/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,sBAAsB,WAA4C,CAAC;AAEhF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,eAAe,UAItD;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,WAAW,CAAC,CAwBtB"}
|
|
@@ -2,32 +2,21 @@ import { utils, abis } from "@bosonprotocol/common";
|
|
|
2
2
|
import { Interface } from "@ethersproject/abi";
|
|
3
3
|
import { getAddress } from "@ethersproject/address";
|
|
4
4
|
export const bosonOfferHandlerIface = new Interface(abis.IBosonOfferHandlerABI);
|
|
5
|
-
export function getCreatedOfferIdFromLogs(logs) {
|
|
6
|
-
const parsedLogs = logs.map((log) => parseLog(log.data, log.topics));
|
|
7
|
-
const [offerCreatedLog] = parsedLogs.filter((log) => log.name === "OfferCreated");
|
|
8
|
-
if (!offerCreatedLog) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return String(offerCreatedLog.args.offerId);
|
|
12
|
-
}
|
|
13
|
-
export function parseLog(data, topics) {
|
|
14
|
-
return bosonOfferHandlerIface.parseLog({ data, topics });
|
|
15
|
-
}
|
|
16
5
|
export function encodeCreateOffer(args) {
|
|
17
6
|
return bosonOfferHandlerIface.encodeFunctionData("createOffer", [
|
|
18
7
|
createOfferArgsToStruct(args)
|
|
19
8
|
]);
|
|
20
9
|
}
|
|
21
10
|
export function createOfferArgsToStruct(args) {
|
|
22
|
-
const { exchangeToken,
|
|
11
|
+
const { exchangeToken, validFromDateInMS, validUntilDateInMS, redeemableFromDateInMS, fulfillmentPeriodDurationInMS, voucherValidDurationInMS, ...restArgs } = args;
|
|
23
12
|
return {
|
|
24
13
|
id: "0",
|
|
14
|
+
sellerId: "0",
|
|
25
15
|
...restArgs,
|
|
26
16
|
exchangeToken: getAddress(exchangeToken),
|
|
27
|
-
seller: getAddress(seller),
|
|
28
17
|
validFromDate: utils.timestamp.msToSec(validFromDateInMS),
|
|
29
18
|
validUntilDate: utils.timestamp.msToSec(validUntilDateInMS),
|
|
30
|
-
|
|
19
|
+
redeemableFromDate: utils.timestamp.msToSec(redeemableFromDateInMS),
|
|
31
20
|
fulfillmentPeriodDuration: utils.timestamp.msToSec(fulfillmentPeriodDurationInMS),
|
|
32
21
|
voucherValidDuration: utils.timestamp.msToSec(voucherValidDurationInMS)
|
|
33
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/offers/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/offers/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAEhF,MAAM,UAAU,iBAAiB,CAAC,IAAqB;IACrD,OAAO,sBAAsB,CAAC,kBAAkB,CAAC,aAAa,EAAE;QAC9D,uBAAuB,CAAC,IAAI,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,IAAqB;IAErB,MAAM,EACJ,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,6BAA6B,EAC7B,wBAAwB,EACxB,GAAG,QAAQ,EACZ,GAAG,IAAI,CAAC;IAET,OAAO;QACL,EAAE,EAAE,GAAG;QACP,QAAQ,EAAE,GAAG;QACb,GAAG,QAAQ;QACX,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC;QACxC,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACzD,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,kBAAkB,CAAC;QAC3D,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,sBAAsB,CAAC;QACnE,yBAAyB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAChD,6BAA6B,CAC9B;QACD,oBAAoB,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,wBAAwB,CAAC;KACxE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MetadataStorage } from "@bosonprotocol/common";
|
|
2
|
+
/**
|
|
3
|
+
* We use the feature `ipfsOnEthereum` in our subgraph to resolve metadata from IPFS
|
|
4
|
+
* and store them in the graph. In order for the graph node to reliably resolve them,
|
|
5
|
+
* we need to add the metadata additionally to the IPFS node of the graph.
|
|
6
|
+
* See https://thegraph.com/docs/en/developer/assemblyscript-api/#ipfs-api
|
|
7
|
+
*/
|
|
8
|
+
export declare function storeMetadataOnTheGraph(args: {
|
|
9
|
+
metadataUriOrHash: string;
|
|
10
|
+
metadataStorage?: MetadataStorage;
|
|
11
|
+
theGraphStorage?: MetadataStorage;
|
|
12
|
+
}): Promise<string | null>;
|
|
13
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/offers/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAUzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use the feature `ipfsOnEthereum` in our subgraph to resolve metadata from IPFS
|
|
3
|
+
* and store them in the graph. In order for the graph node to reliably resolve them,
|
|
4
|
+
* we need to add the metadata additionally to the IPFS node of the graph.
|
|
5
|
+
* See https://thegraph.com/docs/en/developer/assemblyscript-api/#ipfs-api
|
|
6
|
+
*/
|
|
7
|
+
export async function storeMetadataOnTheGraph(args) {
|
|
8
|
+
if (args.metadataStorage && args.theGraphStorage) {
|
|
9
|
+
const metadata = await args.metadataStorage.getMetadata(args.metadataUriOrHash);
|
|
10
|
+
const metadataUri = await args.theGraphStorage.storeMetadata(metadata);
|
|
11
|
+
return metadataUri;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/offers/storage.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,IAI7C;IACC,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,EAAE;QAChD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CACrD,IAAI,CAAC,iBAAiB,CACvB,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACvE,OAAO,WAAW,CAAC;KACpB;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
2
2
|
import { MultiQueryOpts } from "../utils/subgraph";
|
|
3
3
|
import { RawOfferFromSubgraph } from "./types";
|
|
4
|
-
export declare const offerFieldsFragment = "\nfragment offerFields on Offer {\n id\n createdAt\n price\n
|
|
4
|
+
export declare const offerFieldsFragment = "\nfragment offerFields on Offer {\n id\n createdAt\n price\n sellerDeposit\n buyerCancelPenalty\n quantityAvailable\n validFromDate\n validUntilDate\n redeemableFromDate\n fulfillmentPeriodDuration\n voucherValidDuration\n metadataUri\n offerChecksum\n voidedAt\n seller {\n id\n operator\n admin\n clerk\n treasury\n active\n }\n exchangeToken {\n address\n decimals\n name\n symbol\n }\n metadata {\n name \n description\n externalUrl\n schemaUrl\n type\n }\n}\n";
|
|
5
5
|
export declare const getOfferByIdQuery: string;
|
|
6
6
|
export declare function getOfferById(subgraphUrl: string, offerId: BigNumberish): Promise<RawOfferFromSubgraph>;
|
|
7
|
-
export declare const
|
|
8
|
-
export declare function
|
|
7
|
+
export declare const getAllOffersOfOperatorQuery: string;
|
|
8
|
+
export declare function getAllOffersOfOperator(subgraphUrl: string, operatorAddress: string, opts?: MultiQueryOpts): Promise<RawOfferFromSubgraph[]>;
|
|
9
9
|
//# sourceMappingURL=subgraph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../src/offers/subgraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../src/offers/subgraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAiB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,eAAO,MAAM,mBAAmB,shBAsC/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAO7B,CAAC;AAEF,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AAED,eAAO,MAAM,2BAA2B,QAsBvC,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACvB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAiBjC"}
|
|
@@ -4,19 +4,24 @@ fragment offerFields on Offer {
|
|
|
4
4
|
id
|
|
5
5
|
createdAt
|
|
6
6
|
price
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
sellerDeposit
|
|
8
|
+
buyerCancelPenalty
|
|
9
|
+
quantityAvailable
|
|
10
10
|
validFromDate
|
|
11
11
|
validUntilDate
|
|
12
|
-
|
|
12
|
+
redeemableFromDate
|
|
13
13
|
fulfillmentPeriodDuration
|
|
14
14
|
voucherValidDuration
|
|
15
15
|
metadataUri
|
|
16
|
-
|
|
16
|
+
offerChecksum
|
|
17
17
|
voidedAt
|
|
18
18
|
seller {
|
|
19
|
-
|
|
19
|
+
id
|
|
20
|
+
operator
|
|
21
|
+
admin
|
|
22
|
+
clerk
|
|
23
|
+
treasury
|
|
24
|
+
active
|
|
20
25
|
}
|
|
21
26
|
exchangeToken {
|
|
22
27
|
address
|
|
@@ -45,15 +50,17 @@ export async function getOfferById(subgraphUrl, offerId) {
|
|
|
45
50
|
const { offer } = await fetchSubgraph(subgraphUrl, getOfferByIdQuery, { offerId: offerId.toString() });
|
|
46
51
|
return offer;
|
|
47
52
|
}
|
|
48
|
-
export const
|
|
49
|
-
query
|
|
50
|
-
$
|
|
53
|
+
export const getAllOffersOfOperatorQuery = `
|
|
54
|
+
query GetAllOffersOfOperatorQuery(
|
|
55
|
+
$operator: String!,
|
|
51
56
|
$first: Int,
|
|
52
57
|
$skip: Int,
|
|
53
58
|
$orderBy: String,
|
|
54
59
|
$orderDirection: String
|
|
55
60
|
) {
|
|
56
|
-
|
|
61
|
+
sellers(where: {
|
|
62
|
+
operator: $operator
|
|
63
|
+
}) {
|
|
57
64
|
offers(
|
|
58
65
|
first: $first
|
|
59
66
|
skip: $skip
|
|
@@ -66,18 +73,18 @@ query GetAllOffersOfSellerQuery(
|
|
|
66
73
|
}
|
|
67
74
|
${offerFieldsFragment}
|
|
68
75
|
`;
|
|
69
|
-
export async function
|
|
70
|
-
const {
|
|
71
|
-
|
|
76
|
+
export async function getAllOffersOfOperator(subgraphUrl, operatorAddress, opts = {}) {
|
|
77
|
+
const { sellers } = await fetchSubgraph(subgraphUrl, getAllOffersOfOperatorQuery, {
|
|
78
|
+
operator: operatorAddress.toLowerCase(),
|
|
72
79
|
first: 100,
|
|
73
80
|
skip: 0,
|
|
74
81
|
orderBy: "createdAt",
|
|
75
82
|
orderDirection: "desc",
|
|
76
83
|
...opts
|
|
77
84
|
});
|
|
78
|
-
if (!
|
|
85
|
+
if (!sellers) {
|
|
79
86
|
return [];
|
|
80
87
|
}
|
|
81
|
-
return
|
|
88
|
+
return sellers[0].offers;
|
|
82
89
|
}
|
|
83
90
|
//# sourceMappingURL=subgraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/offers/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAGlE,MAAM,CAAC,MAAM,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/offers/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAkB,MAAM,mBAAmB,CAAC;AAGlE,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsClC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;EAM/B,mBAAmB;CACpB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,WAAmB,EACnB,OAAqB;IAErB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,aAAa,CACnC,WAAW,EACX,iBAAiB,EACjB,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAChC,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;EAqBzC,mBAAmB;CACpB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,eAAuB,EACvB,OAAuB,EAAE;IAEzB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,aAAa,CAEpC,WAAW,EAAE,2BAA2B,EAAE;QAC3C,QAAQ,EAAE,eAAe,CAAC,WAAW,EAAE;QACvC,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,CAAC;QACP,OAAO,EAAE,WAAW;QACpB,cAAc,EAAE,MAAM;QACtB,GAAG,IAAI;KACR,CAAC,CAAC;IAEH,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,EAAE,CAAC;KACX;IAED,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC3B,CAAC"}
|
|
@@ -3,19 +3,24 @@ export declare type RawOfferFromSubgraph = {
|
|
|
3
3
|
id: string;
|
|
4
4
|
createdAt: string;
|
|
5
5
|
price: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
sellerDeposit: string;
|
|
7
|
+
buyerCancelPenalty: string;
|
|
8
|
+
quantityAvailable: string;
|
|
9
9
|
validFromDate: string;
|
|
10
10
|
validUntilDate: string;
|
|
11
|
-
|
|
11
|
+
redeemableFromDate: string;
|
|
12
12
|
fulfillmentPeriodDuration: string;
|
|
13
13
|
voucherValidDuration: string;
|
|
14
14
|
metadataUri: string;
|
|
15
|
-
|
|
15
|
+
offerChecksum: string;
|
|
16
16
|
voidedAt: null | string;
|
|
17
17
|
seller: {
|
|
18
|
-
|
|
18
|
+
id: string;
|
|
19
|
+
operator: string;
|
|
20
|
+
admin: string;
|
|
21
|
+
clerk: string;
|
|
22
|
+
treasury: string;
|
|
23
|
+
active: boolean;
|
|
19
24
|
};
|
|
20
25
|
exchangeToken: {
|
|
21
26
|
address: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/offers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,oBAAY,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/offers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,oBAAY,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,yBAAyB,EAAE,MAAM,CAAC;IAClC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAC;IACxB,MAAM,EAAE;QACN,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,aAAa,EAAE;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,QAAQ,EAAE,IAAI,GAAG;QACf,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Web3LibAdapter, TransactionResponse, MetadataStorage } from "@bosonprotocol/common";
|
|
2
|
+
import { CreateOfferArgs } from "../offers/types";
|
|
3
|
+
import { CreateSellerArgs } from "../accounts/types";
|
|
4
|
+
export declare function createOfferAndSeller(args: {
|
|
5
|
+
offerToCreate: CreateOfferArgs;
|
|
6
|
+
sellerToCreate: CreateSellerArgs;
|
|
7
|
+
contractAddress: string;
|
|
8
|
+
web3Lib: Web3LibAdapter;
|
|
9
|
+
metadataStorage?: MetadataStorage;
|
|
10
|
+
theGraphStorage?: MetadataStorage;
|
|
11
|
+
}): Promise<TransactionResponse>;
|
|
12
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/orchestration/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,aAAa,EAAE,eAAe,CAAC;IAC/B,cAAc,EAAE,gBAAgB,CAAC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAmB/B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { utils } from "@bosonprotocol/common";
|
|
2
|
+
import { encodeCreateSellerAndOffer } from "./interface";
|
|
3
|
+
import { storeMetadataOnTheGraph } from "../offers/storage";
|
|
4
|
+
export async function createOfferAndSeller(args) {
|
|
5
|
+
utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
6
|
+
abortEarly: false
|
|
7
|
+
});
|
|
8
|
+
utils.validation.createSellerArgsSchema.validateSync(args.sellerToCreate, {
|
|
9
|
+
abortEarly: false
|
|
10
|
+
});
|
|
11
|
+
await storeMetadataOnTheGraph({
|
|
12
|
+
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
13
|
+
metadataStorage: args.metadataStorage,
|
|
14
|
+
theGraphStorage: args.theGraphStorage
|
|
15
|
+
});
|
|
16
|
+
return args.web3Lib.sendTransaction({
|
|
17
|
+
to: args.contractAddress,
|
|
18
|
+
data: encodeCreateSellerAndOffer(args.sellerToCreate, args.offerToCreate)
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/orchestration/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,EACN,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAK5D,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAO1C;IACC,KAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;QACtE,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE;QACxE,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,MAAM,uBAAuB,CAAC;QAC5B,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,WAAW;QACjD,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,eAAe,EAAE,IAAI,CAAC,eAAe;KACtC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QAClC,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,IAAI,EAAE,0BAA0B,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC;KAC1E,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Interface } from "@ethersproject/abi";
|
|
2
|
+
import { CreateSellerArgs } from "../accounts/types";
|
|
3
|
+
import { CreateOfferArgs } from "../offers/types";
|
|
4
|
+
export declare const bosonOrchestrationHandlerIface: Interface;
|
|
5
|
+
export declare function encodeCreateSellerAndOffer(seller: CreateSellerArgs, offer: CreateOfferArgs): string;
|
|
6
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/orchestration/interface.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,eAAO,MAAM,8BAA8B,WAE1C,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,eAAe,UAMvB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
export const bosonOrchestrationHandlerIface = new Interface(abis.IBosonOrchestrationHandlerABI);
|
|
6
|
+
export function encodeCreateSellerAndOffer(seller, offer) {
|
|
7
|
+
return bosonOrchestrationHandlerIface.encodeFunctionData("createSellerAndOffer", [createSellerArgsToStruct(seller), createOfferArgsToStruct(offer)]);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/orchestration/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAK9D,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,SAAS,CACzD,IAAI,CAAC,6BAA6B,CACnC,CAAC;AAEF,MAAM,UAAU,0BAA0B,CACxC,MAAwB,EACxB,KAAsB;IAEtB,OAAO,8BAA8B,CAAC,kBAAkB,CACtD,sBAAsB,EACtB,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAC,CACnE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../../src/utils/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,UAYtE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function getCreatedOfferIdFromLogs(iface, logs) {
|
|
2
|
+
const parsedLogs = logs.map((log) => iface.parseLog(log));
|
|
3
|
+
const [offerCreatedLog] = parsedLogs.filter((log) => log.name === "OfferCreated");
|
|
4
|
+
if (!offerCreatedLog) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return String(offerCreatedLog.args.offerId);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/utils/logs.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,yBAAyB,CAAC,KAAgB,EAAE,IAAW;IACrE,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAE1D,MAAM,CAAC,eAAe,CAAC,GAAG,UAAU,CAAC,MAAM,CACzC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,cAAc,CACrC,CAAC;IAEF,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,IAAI,CAAC;KACb;IAED,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bosonprotocol/core-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-alpha.1",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"access": "restricted"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@bosonprotocol/common": "1.
|
|
33
|
+
"@bosonprotocol/common": "1.2.0-alpha.1",
|
|
34
34
|
"@ethersproject/abi": "^5.5.0",
|
|
35
35
|
"@ethersproject/address": "^5.5.0",
|
|
36
36
|
"@ethersproject/bignumber": "^5.5.0",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"ts-jest": "^27.1.3",
|
|
47
47
|
"typescript": "^4.5.5"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "1f3bdbe38c4d7e96c551e589ec890d8797b04ee6"
|
|
50
50
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SellerStruct, abis } from "@bosonprotocol/common";
|
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
|
3
|
+
import { CreateSellerArgs } from "./types";
|
|
4
|
+
|
|
5
|
+
export const bosonAccountHandlerIface = new Interface(
|
|
6
|
+
abis.IBosonAccountHandlerABI
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
export function createSellerArgsToStruct(
|
|
10
|
+
args: CreateSellerArgs
|
|
11
|
+
): Partial<SellerStruct> {
|
|
12
|
+
return {
|
|
13
|
+
id: "0",
|
|
14
|
+
active: true,
|
|
15
|
+
...args
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { fetchSubgraph } from "../utils/subgraph";
|
|
2
|
+
import { RawSellerFromSubgraph } from "./types";
|
|
3
|
+
|
|
4
|
+
export const sellerFieldsFragment = `
|
|
5
|
+
fragment sellerFields on Seller {
|
|
6
|
+
id
|
|
7
|
+
operator
|
|
8
|
+
admin
|
|
9
|
+
clerk
|
|
10
|
+
treasury
|
|
11
|
+
active
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const getSellerByOperatorQuery = `
|
|
16
|
+
query GetSellersByOperator($operator: String!) {
|
|
17
|
+
sellers(operator: $operator) {
|
|
18
|
+
...sellerFields
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
${sellerFieldsFragment}
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export async function getSellerByOperator(
|
|
25
|
+
subgraphUrl: string,
|
|
26
|
+
operatorAddress: string
|
|
27
|
+
): Promise<RawSellerFromSubgraph> {
|
|
28
|
+
const { sellers } = await fetchSubgraph<{ sellers: RawSellerFromSubgraph }>(
|
|
29
|
+
subgraphUrl,
|
|
30
|
+
getSellerByOperatorQuery,
|
|
31
|
+
{ operator: operatorAddress }
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return sellers[0];
|
|
35
|
+
}
|