@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.
- 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":"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"}
|
|
@@ -9,26 +9,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.getAllOffersOfOperator = exports.getAllOffersOfOperatorQuery = exports.getOfferById = exports.getOfferByIdQuery = exports.offerFieldsFragment = void 0;
|
|
13
13
|
const subgraph_1 = require("../utils/subgraph");
|
|
14
14
|
exports.offerFieldsFragment = `
|
|
15
15
|
fragment offerFields on Offer {
|
|
16
16
|
id
|
|
17
17
|
createdAt
|
|
18
18
|
price
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
sellerDeposit
|
|
20
|
+
buyerCancelPenalty
|
|
21
|
+
quantityAvailable
|
|
22
22
|
validFromDate
|
|
23
23
|
validUntilDate
|
|
24
|
-
|
|
24
|
+
redeemableFromDate
|
|
25
25
|
fulfillmentPeriodDuration
|
|
26
26
|
voucherValidDuration
|
|
27
27
|
metadataUri
|
|
28
|
-
|
|
28
|
+
offerChecksum
|
|
29
29
|
voidedAt
|
|
30
30
|
seller {
|
|
31
|
-
|
|
31
|
+
id
|
|
32
|
+
operator
|
|
33
|
+
admin
|
|
34
|
+
clerk
|
|
35
|
+
treasury
|
|
36
|
+
active
|
|
32
37
|
}
|
|
33
38
|
exchangeToken {
|
|
34
39
|
address
|
|
@@ -60,15 +65,17 @@ function getOfferById(subgraphUrl, offerId) {
|
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
67
|
exports.getOfferById = getOfferById;
|
|
63
|
-
exports.
|
|
64
|
-
query
|
|
65
|
-
$
|
|
68
|
+
exports.getAllOffersOfOperatorQuery = `
|
|
69
|
+
query GetAllOffersOfOperatorQuery(
|
|
70
|
+
$operator: String!,
|
|
66
71
|
$first: Int,
|
|
67
72
|
$skip: Int,
|
|
68
73
|
$orderBy: String,
|
|
69
74
|
$orderDirection: String
|
|
70
75
|
) {
|
|
71
|
-
|
|
76
|
+
sellers(where: {
|
|
77
|
+
operator: $operator
|
|
78
|
+
}) {
|
|
72
79
|
offers(
|
|
73
80
|
first: $first
|
|
74
81
|
skip: $skip
|
|
@@ -81,14 +88,14 @@ query GetAllOffersOfSellerQuery(
|
|
|
81
88
|
}
|
|
82
89
|
${exports.offerFieldsFragment}
|
|
83
90
|
`;
|
|
84
|
-
function
|
|
91
|
+
function getAllOffersOfOperator(subgraphUrl, operatorAddress, opts = {}) {
|
|
85
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
const {
|
|
87
|
-
if (!
|
|
93
|
+
const { sellers } = yield (0, subgraph_1.fetchSubgraph)(subgraphUrl, exports.getAllOffersOfOperatorQuery, Object.assign({ operator: operatorAddress.toLowerCase(), first: 100, skip: 0, orderBy: "createdAt", orderDirection: "desc" }, opts));
|
|
94
|
+
if (!sellers) {
|
|
88
95
|
return [];
|
|
89
96
|
}
|
|
90
|
-
return
|
|
97
|
+
return sellers[0].offers;
|
|
91
98
|
});
|
|
92
99
|
}
|
|
93
|
-
exports.
|
|
100
|
+
exports.getAllOffersOfOperator = getAllOffersOfOperator;
|
|
94
101
|
//# sourceMappingURL=subgraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/offers/subgraph.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAkE;AAGrD,QAAA,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/offers/subgraph.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,gDAAkE;AAGrD,QAAA,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsClC,CAAC;AAEW,QAAA,iBAAiB,GAAG;;;;;;EAM/B,2BAAmB;CACpB,CAAC;AAEF,SAAsB,YAAY,CAChC,WAAmB,EACnB,OAAqB;;QAErB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAA,wBAAa,EACnC,WAAW,EACX,yBAAiB,EACjB,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE,CAChC,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAXD,oCAWC;AAEY,QAAA,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;EAqBzC,2BAAmB;CACpB,CAAC;AAEF,SAAsB,sBAAsB,CAC1C,WAAmB,EACnB,eAAuB,EACvB,OAAuB,EAAE;;QAEzB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,wBAAa,EAEpC,WAAW,EAAE,mCAA2B,kBACzC,QAAQ,EAAE,eAAe,CAAC,WAAW,EAAE,EACvC,KAAK,EAAE,GAAG,EACV,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,MAAM,IACnB,IAAI,EACP,CAAC;QAEH,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,EAAE,CAAC;SACX;QAED,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3B,CAAC;CAAA;AArBD,wDAqBC"}
|
|
@@ -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,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createOfferAndSeller = void 0;
|
|
13
|
+
const common_1 = require("@bosonprotocol/common");
|
|
14
|
+
const interface_1 = require("./interface");
|
|
15
|
+
const storage_1 = require("../offers/storage");
|
|
16
|
+
function createOfferAndSeller(args) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
common_1.utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
19
|
+
abortEarly: false
|
|
20
|
+
});
|
|
21
|
+
common_1.utils.validation.createSellerArgsSchema.validateSync(args.sellerToCreate, {
|
|
22
|
+
abortEarly: false
|
|
23
|
+
});
|
|
24
|
+
yield (0, storage_1.storeMetadataOnTheGraph)({
|
|
25
|
+
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
26
|
+
metadataStorage: args.metadataStorage,
|
|
27
|
+
theGraphStorage: args.theGraphStorage
|
|
28
|
+
});
|
|
29
|
+
return args.web3Lib.sendTransaction({
|
|
30
|
+
to: args.contractAddress,
|
|
31
|
+
data: (0, interface_1.encodeCreateSellerAndOffer)(args.sellerToCreate, args.offerToCreate)
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.createOfferAndSeller = createOfferAndSeller;
|
|
36
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/orchestration/handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAK+B;AAC/B,2CAAyD;AACzD,+CAA4D;AAK5D,SAAsB,oBAAoB,CAAC,IAO1C;;QACC,cAAK,CAAC,UAAU,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE;YACtE,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QAEH,cAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,EAAE;YACxE,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QAEH,MAAM,IAAA,iCAAuB,EAAC;YAC5B,iBAAiB,EAAE,IAAI,CAAC,aAAa,CAAC,WAAW;YACjD,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;YAClC,EAAE,EAAE,IAAI,CAAC,eAAe;YACxB,IAAI,EAAE,IAAA,sCAA0B,EAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC;SAC1E,CAAC,CAAC;IACL,CAAC;CAAA;AA1BD,oDA0BC"}
|
|
@@ -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,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.iface = exports.handler = void 0;
|
|
27
|
+
exports.handler = __importStar(require("./handler"));
|
|
28
|
+
exports.iface = __importStar(require("./interface"));
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchestration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqC;AACrC,qDAAqC"}
|
|
@@ -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,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeCreateSellerAndOffer = exports.bosonOrchestrationHandlerIface = void 0;
|
|
4
|
+
const common_1 = require("@bosonprotocol/common");
|
|
5
|
+
const abi_1 = require("@ethersproject/abi");
|
|
6
|
+
const interface_1 = require("../accounts/interface");
|
|
7
|
+
const interface_2 = require("../offers/interface");
|
|
8
|
+
exports.bosonOrchestrationHandlerIface = new abi_1.Interface(common_1.abis.IBosonOrchestrationHandlerABI);
|
|
9
|
+
function encodeCreateSellerAndOffer(seller, offer) {
|
|
10
|
+
return exports.bosonOrchestrationHandlerIface.encodeFunctionData("createSellerAndOffer", [(0, interface_1.createSellerArgsToStruct)(seller), (0, interface_2.createOfferArgsToStruct)(offer)]);
|
|
11
|
+
}
|
|
12
|
+
exports.encodeCreateSellerAndOffer = encodeCreateSellerAndOffer;
|
|
13
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/orchestration/interface.ts"],"names":[],"mappings":";;;AAAA,kDAA6C;AAC7C,4CAA+C;AAC/C,qDAAiE;AACjE,mDAA8D;AAKjD,QAAA,8BAA8B,GAAG,IAAI,eAAS,CACzD,aAAI,CAAC,6BAA6B,CACnC,CAAC;AAEF,SAAgB,0BAA0B,CACxC,MAAwB,EACxB,KAAsB;IAEtB,OAAO,sCAA8B,CAAC,kBAAkB,CACtD,sBAAsB,EACtB,CAAC,IAAA,oCAAwB,EAAC,MAAM,CAAC,EAAE,IAAA,mCAAuB,EAAC,KAAK,CAAC,CAAC,CACnE,CAAC;AACJ,CAAC;AARD,gEAQC"}
|
|
@@ -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,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCreatedOfferIdFromLogs = void 0;
|
|
4
|
+
function getCreatedOfferIdFromLogs(iface, logs) {
|
|
5
|
+
const parsedLogs = logs.map((log) => iface.parseLog(log));
|
|
6
|
+
const [offerCreatedLog] = parsedLogs.filter((log) => log.name === "OfferCreated");
|
|
7
|
+
if (!offerCreatedLog) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return String(offerCreatedLog.args.offerId);
|
|
11
|
+
}
|
|
12
|
+
exports.getCreatedOfferIdFromLogs = getCreatedOfferIdFromLogs;
|
|
13
|
+
//# sourceMappingURL=logs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/utils/logs.ts"],"names":[],"mappings":";;;AAGA,SAAgB,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;AAZD,8DAYC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * as iface from "./interface";
|
|
2
|
+
export * as subgraph from "./subgraph";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
export declare const validation: {
|
|
5
|
+
createSellerArgsSchema: import("yup/lib/object").OptionalObjectSchema<{
|
|
6
|
+
operator: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
7
|
+
admin: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
8
|
+
clerk: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
9
|
+
treasury: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
10
|
+
}, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<{
|
|
11
|
+
operator: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
12
|
+
admin: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
13
|
+
clerk: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
14
|
+
treasury: import("yup/lib/string").RequiredStringSchema<string, import("yup/lib/types").AnyObject>;
|
|
15
|
+
}>>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/accounts/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,SAAS,CAAC;AAExB,eAAO,MAAM,UAAU;;;;;;;;;;;;CAEtB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { utils } from "@bosonprotocol/common";
|
|
2
|
+
export * as iface from "./interface";
|
|
3
|
+
export * as subgraph from "./subgraph";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export const validation = {
|
|
6
|
+
createSellerArgsSchema: utils.validation.createSellerArgsSchema
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,cAAc,SAAS,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,sBAAsB,EAAE,KAAK,CAAC,UAAU,CAAC,sBAAsB;CAChE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SellerStruct } from "@bosonprotocol/common";
|
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
|
3
|
+
import { CreateSellerArgs } from "./types";
|
|
4
|
+
export declare const bosonAccountHandlerIface: Interface;
|
|
5
|
+
export declare function createSellerArgsToStruct(args: CreateSellerArgs): Partial<SellerStruct>;
|
|
6
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/accounts/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAQ,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,wBAAwB,WAEpC,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,YAAY,CAAC,CAMvB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { abis } from "@bosonprotocol/common";
|
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
|
3
|
+
export const bosonAccountHandlerIface = new Interface(abis.IBosonAccountHandlerABI);
|
|
4
|
+
export function createSellerArgsToStruct(args) {
|
|
5
|
+
return {
|
|
6
|
+
id: "0",
|
|
7
|
+
active: true,
|
|
8
|
+
...args
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/accounts/interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,SAAS,CACnD,IAAI,CAAC,uBAAuB,CAC7B,CAAC;AAEF,MAAM,UAAU,wBAAwB,CACtC,IAAsB;IAEtB,OAAO;QACL,EAAE,EAAE,GAAG;QACP,MAAM,EAAE,IAAI;QACZ,GAAG,IAAI;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RawSellerFromSubgraph } from "./types";
|
|
2
|
+
export declare const sellerFieldsFragment = "\nfragment sellerFields on Seller {\n id\n operator\n admin\n clerk\n treasury\n active\n}\n";
|
|
3
|
+
export declare const getSellerByOperatorQuery: string;
|
|
4
|
+
export declare function getSellerByOperator(subgraphUrl: string, operatorAddress: string): Promise<RawSellerFromSubgraph>;
|
|
5
|
+
//# sourceMappingURL=subgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../src/accounts/subgraph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,eAAO,MAAM,oBAAoB,uGAShC,CAAC;AAEF,eAAO,MAAM,wBAAwB,QAOpC,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,qBAAqB,CAAC,CAQhC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { fetchSubgraph } from "../utils/subgraph";
|
|
2
|
+
export const sellerFieldsFragment = `
|
|
3
|
+
fragment sellerFields on Seller {
|
|
4
|
+
id
|
|
5
|
+
operator
|
|
6
|
+
admin
|
|
7
|
+
clerk
|
|
8
|
+
treasury
|
|
9
|
+
active
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
export const getSellerByOperatorQuery = `
|
|
13
|
+
query GetSellersByOperator($operator: String!) {
|
|
14
|
+
sellers(operator: $operator) {
|
|
15
|
+
...sellerFields
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${sellerFieldsFragment}
|
|
19
|
+
`;
|
|
20
|
+
export async function getSellerByOperator(subgraphUrl, operatorAddress) {
|
|
21
|
+
const { sellers } = await fetchSubgraph(subgraphUrl, getSellerByOperatorQuery, { operator: operatorAddress });
|
|
22
|
+
return sellers[0];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=subgraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/accounts/subgraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;CASnC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;EAMtC,oBAAoB;CACrB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,eAAuB;IAEvB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,aAAa,CACrC,WAAW,EACX,wBAAwB,EACxB,EAAE,QAAQ,EAAE,eAAe,EAAE,CAC9B,CAAC;IAEF,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/accounts/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,oBAAY,qBAAqB,GAAG;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/accounts/types.ts"],"names":[],"mappings":""}
|
package/dist/esm/core-sdk.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Web3LibAdapter, TransactionResponse, MetadataStorage, AnyMetadata, Log } from "@bosonprotocol/common";
|
|
2
2
|
import { BigNumberish } from "@ethersproject/bignumber";
|
|
3
|
+
import * as accounts from "./accounts";
|
|
3
4
|
import * as offers from "./offers";
|
|
4
5
|
import { MultiQueryOpts } from "./utils/subgraph";
|
|
5
6
|
export declare class CoreSDK {
|
|
@@ -24,6 +25,10 @@ export declare class CoreSDK {
|
|
|
24
25
|
}): CoreSDK;
|
|
25
26
|
storeMetadata(metadata: AnyMetadata): Promise<string>;
|
|
26
27
|
getMetadata(metadataHashOrUri: string): Promise<AnyMetadata>;
|
|
28
|
+
getSellerByOperator(operator: string): Promise<accounts.RawSellerFromSubgraph>;
|
|
29
|
+
createSellerAndOffer(sellerToCreate: accounts.CreateSellerArgs, offerToCreate: offers.CreateOfferArgs, overrides?: Partial<{
|
|
30
|
+
contractAddress: string;
|
|
31
|
+
}>): Promise<TransactionResponse>;
|
|
27
32
|
createOffer(offerToCreate: offers.CreateOfferArgs, overrides?: Partial<{
|
|
28
33
|
contractAddress: string;
|
|
29
34
|
}>): Promise<TransactionResponse>;
|
|
@@ -32,7 +37,9 @@ export declare class CoreSDK {
|
|
|
32
37
|
contractAddress: string;
|
|
33
38
|
}>): Promise<TransactionResponse>;
|
|
34
39
|
getOfferById(offerId: BigNumberish): Promise<offers.RawOfferFromSubgraph>;
|
|
35
|
-
getAllOffersOfSeller(
|
|
40
|
+
getAllOffersOfSeller(sellerFilter: {
|
|
41
|
+
operatorAddress: string;
|
|
42
|
+
}, opts?: MultiQueryOpts): Promise<offers.RawOfferFromSubgraph[]>;
|
|
36
43
|
getExchangeTokenAllowance(exchangeToken: string, overrides?: Partial<{
|
|
37
44
|
spender: string;
|
|
38
45
|
owner: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-sdk.d.ts","sourceRoot":"","sources":["../../src/core-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EAEnB,eA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;IAcW,oBAAoB,CAC/B,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,YAAY,EACnB,SAAS,GAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAM,GACN,OAAO,CAAC,mBAAmB,CAAC;CAQhC"}
|
package/dist/esm/core-sdk.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { getDefaultConfig } from "@bosonprotocol/common";
|
|
2
|
+
import * as accounts from "./accounts";
|
|
2
3
|
import * as offers from "./offers";
|
|
4
|
+
import * as orchestration from "./orchestration";
|
|
3
5
|
import * as erc20 from "./erc20";
|
|
6
|
+
import { getCreatedOfferIdFromLogs } from "./utils/logs";
|
|
4
7
|
export class CoreSDK {
|
|
5
8
|
_web3Lib;
|
|
6
9
|
_metadataStorage;
|
|
@@ -39,6 +42,19 @@ export class CoreSDK {
|
|
|
39
42
|
}
|
|
40
43
|
return this._metadataStorage.getMetadata(metadataHashOrUri);
|
|
41
44
|
}
|
|
45
|
+
async getSellerByOperator(operator) {
|
|
46
|
+
return accounts.subgraph.getSellerByOperator(this._subgraphUrl, operator);
|
|
47
|
+
}
|
|
48
|
+
async createSellerAndOffer(sellerToCreate, offerToCreate, overrides = {}) {
|
|
49
|
+
return orchestration.handler.createOfferAndSeller({
|
|
50
|
+
sellerToCreate,
|
|
51
|
+
offerToCreate,
|
|
52
|
+
web3Lib: this._web3Lib,
|
|
53
|
+
theGraphStorage: this._theGraphStorage,
|
|
54
|
+
metadataStorage: this._metadataStorage,
|
|
55
|
+
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
56
|
+
});
|
|
57
|
+
}
|
|
42
58
|
async createOffer(offerToCreate, overrides = {}) {
|
|
43
59
|
return offers.handler.createOffer({
|
|
44
60
|
offerToCreate,
|
|
@@ -49,7 +65,12 @@ export class CoreSDK {
|
|
|
49
65
|
});
|
|
50
66
|
}
|
|
51
67
|
getCreatedOfferIdFromLogs(logs) {
|
|
52
|
-
|
|
68
|
+
try {
|
|
69
|
+
return getCreatedOfferIdFromLogs(offers.iface.bosonOfferHandlerIface, logs);
|
|
70
|
+
}
|
|
71
|
+
catch (offerError) {
|
|
72
|
+
return getCreatedOfferIdFromLogs(orchestration.iface.bosonOrchestrationHandlerIface, logs);
|
|
73
|
+
}
|
|
53
74
|
}
|
|
54
75
|
async voidOffer(offerId, overrides = {}) {
|
|
55
76
|
return offers.handler.voidOffer({
|
|
@@ -62,8 +83,11 @@ export class CoreSDK {
|
|
|
62
83
|
async getOfferById(offerId) {
|
|
63
84
|
return offers.subgraph.getOfferById(this._subgraphUrl, offerId);
|
|
64
85
|
}
|
|
65
|
-
async getAllOffersOfSeller(
|
|
66
|
-
|
|
86
|
+
async getAllOffersOfSeller(sellerFilter, opts = {}) {
|
|
87
|
+
if (sellerFilter.operatorAddress) {
|
|
88
|
+
return offers.subgraph.getAllOffersOfOperator(this._subgraphUrl, sellerFilter.operatorAddress, opts);
|
|
89
|
+
}
|
|
90
|
+
return [];
|
|
67
91
|
}
|
|
68
92
|
async getExchangeTokenAllowance(exchangeToken, overrides = {}) {
|
|
69
93
|
return erc20.handler.getAllowance({
|
package/dist/esm/core-sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-sdk.js","sourceRoot":"","sources":["../../src/core-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EAIjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"core-sdk.js","sourceRoot":"","sources":["../../src/core-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EAIjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,aAAa,MAAM,iBAA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MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACjD,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;YAC/B,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;YAC3B,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC;SAC9B,CAAC,CAAC;QAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC/B,aAAqB,EACrB,KAAmB,EACnB,YAEK,EAAE;QAEP,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAC3B,eAAe,EAAE,aAAa;YAC9B,OAAO,EAAE,SAAS,CAAC,OAAO,IAAI,IAAI,CAAC,gBAAgB;YACnD,KAAK;YACL,OAAO,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -14,9 +14,4 @@ export declare function voidOffer(args: {
|
|
|
14
14
|
offerId: BigNumberish;
|
|
15
15
|
web3Lib: Web3LibAdapter;
|
|
16
16
|
}): Promise<TransactionResponse>;
|
|
17
|
-
export declare function storeMetadataOnTheGraph(args: {
|
|
18
|
-
metadataUriOrHash: string;
|
|
19
|
-
metadataStorage: MetadataStorage;
|
|
20
|
-
theGraphStorage: MetadataStorage;
|
|
21
|
-
}): Promise<string>;
|
|
22
17
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/offers/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EAEhB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/offers/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,eAAe,EAEhB,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,aAAa,EAAE,eAAe,CAAC;IAC/B,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,CAe/B;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,cAAc,CAAC;CACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsB/B"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { utils } from "@bosonprotocol/common";
|
|
2
2
|
import { bosonOfferHandlerIface, encodeCreateOffer } from "./interface";
|
|
3
3
|
import { getOfferById } from "./subgraph";
|
|
4
|
+
import { storeMetadataOnTheGraph } from "./storage";
|
|
4
5
|
export async function createOffer(args) {
|
|
5
|
-
|
|
6
|
+
utils.validation.createOfferArgsSchema.validateSync(args.offerToCreate, {
|
|
6
7
|
abortEarly: false
|
|
7
8
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
await storeMetadataOnTheGraph({
|
|
14
|
-
metadataUriOrHash: args.offerToCreate.metadataHash,
|
|
15
|
-
metadataStorage: args.metadataStorage,
|
|
16
|
-
theGraphStorage: args.theGraphStorage
|
|
17
|
-
});
|
|
18
|
-
}
|
|
9
|
+
await storeMetadataOnTheGraph({
|
|
10
|
+
metadataUriOrHash: args.offerToCreate.metadataUri,
|
|
11
|
+
metadataStorage: args.metadataStorage,
|
|
12
|
+
theGraphStorage: args.theGraphStorage
|
|
13
|
+
});
|
|
19
14
|
return args.web3Lib.sendTransaction({
|
|
20
15
|
to: args.contractAddress,
|
|
21
16
|
data: encodeCreateOffer(args.offerToCreate)
|
|
@@ -30,17 +25,12 @@ export async function voidOffer(args) {
|
|
|
30
25
|
throw new Error(`Offer with id "${args.offerId}" is already voided`);
|
|
31
26
|
}
|
|
32
27
|
const signerAddress = await args.web3Lib.getSignerAddress();
|
|
33
|
-
if (offer.seller.
|
|
34
|
-
throw new Error(`Signer with address "${signerAddress}" is not the
|
|
28
|
+
if (offer.seller.operator.toLowerCase() !== signerAddress.toLowerCase()) {
|
|
29
|
+
throw new Error(`Signer with address "${signerAddress}" is not the operator "${offer.seller.operator}"`);
|
|
35
30
|
}
|
|
36
31
|
return args.web3Lib.sendTransaction({
|
|
37
32
|
to: args.contractAddress,
|
|
38
33
|
data: bosonOfferHandlerIface.encodeFunctionData("voidOffer", [args.offerId])
|
|
39
34
|
});
|
|
40
35
|
}
|
|
41
|
-
export async function storeMetadataOnTheGraph(args) {
|
|
42
|
-
const metadata = await args.metadataStorage.getMetadata(args.metadataUriOrHash);
|
|
43
|
-
const metadataUri = await args.theGraphStorage.storeMetadata(metadata);
|
|
44
|
-
return metadataUri;
|
|
45
|
-
}
|
|
46
36
|
//# sourceMappingURL=handler.js.map
|