@bosonprotocol/core-sdk 1.23.0-alpha.2 → 1.23.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/accounts/mixin.d.ts +194 -0
- package/dist/cjs/accounts/mixin.d.ts.map +1 -0
- package/dist/cjs/accounts/mixin.js +426 -0
- package/dist/cjs/accounts/mixin.js.map +1 -0
- package/dist/cjs/core-sdk.d.ts +16 -818
- package/dist/cjs/core-sdk.d.ts.map +1 -1
- package/dist/cjs/core-sdk.js +26 -1579
- package/dist/cjs/core-sdk.js.map +1 -1
- package/dist/cjs/disputes/mixin.d.ts +113 -0
- package/dist/cjs/disputes/mixin.d.ts.map +1 -0
- package/dist/cjs/disputes/mixin.js +203 -0
- package/dist/cjs/disputes/mixin.js.map +1 -0
- package/dist/cjs/erc1155/handler.d.ts +9 -0
- package/dist/cjs/erc1155/handler.d.ts.map +1 -0
- package/dist/cjs/erc1155/handler.js +28 -0
- package/dist/cjs/erc1155/handler.js.map +1 -0
- package/dist/cjs/erc1155/index.d.ts +3 -0
- package/dist/cjs/erc1155/index.d.ts.map +1 -0
- package/dist/cjs/erc1155/index.js +29 -0
- package/dist/cjs/erc1155/index.js.map +1 -0
- package/dist/cjs/erc1155/interface.d.ts +3 -0
- package/dist/cjs/erc1155/interface.d.ts.map +1 -0
- package/dist/cjs/erc1155/interface.js +7 -0
- package/dist/cjs/erc1155/interface.js.map +1 -0
- package/dist/cjs/erc20/handler.d.ts +5 -0
- package/dist/cjs/erc20/handler.d.ts.map +1 -1
- package/dist/cjs/erc20/handler.js +12 -1
- package/dist/cjs/erc20/handler.js.map +1 -1
- package/dist/cjs/erc721/handler.d.ts +5 -0
- package/dist/cjs/erc721/handler.d.ts.map +1 -1
- package/dist/cjs/erc721/handler.js +12 -1
- package/dist/cjs/erc721/handler.js.map +1 -1
- package/dist/cjs/event-logs/mixin.d.ts +11 -0
- package/dist/cjs/event-logs/mixin.d.ts.map +1 -0
- package/dist/cjs/event-logs/mixin.js +28 -0
- package/dist/cjs/event-logs/mixin.js.map +1 -0
- package/dist/cjs/exchanges/mixin.d.ts +77 -0
- package/dist/cjs/exchanges/mixin.d.ts.map +1 -0
- package/dist/cjs/exchanges/mixin.js +172 -0
- package/dist/cjs/exchanges/mixin.js.map +1 -0
- package/dist/cjs/funds/mixin.d.ts +42 -0
- package/dist/cjs/funds/mixin.d.ts.map +1 -0
- package/dist/cjs/funds/mixin.js +95 -0
- package/dist/cjs/funds/mixin.js.map +1 -0
- package/dist/cjs/groups/mixin.d.ts +14 -0
- package/dist/cjs/groups/mixin.d.ts.map +1 -0
- package/dist/cjs/groups/mixin.js +33 -0
- package/dist/cjs/groups/mixin.js.map +1 -0
- package/dist/cjs/meta-tx/mixin.d.ts +176 -0
- package/dist/cjs/meta-tx/mixin.d.ts.map +1 -0
- package/dist/cjs/meta-tx/mixin.js +296 -0
- package/dist/cjs/meta-tx/mixin.js.map +1 -0
- package/dist/cjs/metadata/mixin.d.ts +42 -0
- package/dist/cjs/metadata/mixin.d.ts.map +1 -0
- package/dist/cjs/metadata/mixin.js +89 -0
- package/dist/cjs/metadata/mixin.js.map +1 -0
- package/dist/cjs/metadata/subgraph.d.ts +3 -1
- package/dist/cjs/metadata/subgraph.d.ts.map +1 -1
- package/dist/cjs/metadata/subgraph.js +17 -1
- package/dist/cjs/metadata/subgraph.js.map +1 -1
- package/dist/cjs/mixins/base-core-sdk.d.ts +41 -0
- package/dist/cjs/mixins/base-core-sdk.d.ts.map +1 -0
- package/dist/cjs/mixins/base-core-sdk.js +51 -0
- package/dist/cjs/mixins/base-core-sdk.js.map +1 -0
- package/dist/cjs/native-meta-tx/mixin.d.ts +35 -0
- package/dist/cjs/native-meta-tx/mixin.d.ts.map +1 -0
- package/dist/cjs/native-meta-tx/mixin.js +68 -0
- package/dist/cjs/native-meta-tx/mixin.js.map +1 -0
- package/dist/cjs/offers/mixin.d.ts +133 -0
- package/dist/cjs/offers/mixin.d.ts.map +1 -0
- package/dist/cjs/offers/mixin.js +338 -0
- package/dist/cjs/offers/mixin.js.map +1 -0
- package/dist/cjs/orchestration/mixin.d.ts +28 -0
- package/dist/cjs/orchestration/mixin.d.ts.map +1 -0
- package/dist/cjs/orchestration/mixin.js +59 -0
- package/dist/cjs/orchestration/mixin.js.map +1 -0
- package/dist/cjs/subgraph.d.ts +3707 -1509
- package/dist/cjs/subgraph.d.ts.map +1 -1
- package/dist/cjs/subgraph.js +113 -4
- package/dist/cjs/subgraph.js.map +1 -1
- package/dist/cjs/utils/graphql.d.ts +14 -0
- package/dist/cjs/utils/graphql.d.ts.map +1 -1
- package/dist/cjs/utils/signature.d.ts.map +1 -1
- package/dist/cjs/utils/signature.js +5 -1
- package/dist/cjs/utils/signature.js.map +1 -1
- package/dist/cjs/utils/tokenInfoManager.d.ts +6 -2
- package/dist/cjs/utils/tokenInfoManager.d.ts.map +1 -1
- package/dist/cjs/utils/tokenInfoManager.js +39 -6
- package/dist/cjs/utils/tokenInfoManager.js.map +1 -1
- package/dist/esm/accounts/mixin.d.ts +194 -0
- package/dist/esm/accounts/mixin.d.ts.map +1 -0
- package/dist/esm/accounts/mixin.js +342 -0
- package/dist/esm/accounts/mixin.js.map +1 -0
- package/dist/esm/core-sdk.d.ts +16 -818
- package/dist/esm/core-sdk.d.ts.map +1 -1
- package/dist/esm/core-sdk.js +27 -1483
- package/dist/esm/core-sdk.js.map +1 -1
- package/dist/esm/disputes/mixin.d.ts +113 -0
- package/dist/esm/disputes/mixin.d.ts.map +1 -0
- package/dist/esm/disputes/mixin.js +173 -0
- package/dist/esm/disputes/mixin.js.map +1 -0
- package/dist/esm/erc1155/handler.d.ts +9 -0
- package/dist/esm/erc1155/handler.d.ts.map +1 -0
- package/dist/esm/erc1155/handler.js +13 -0
- package/dist/esm/erc1155/handler.js.map +1 -0
- package/dist/esm/erc1155/index.d.ts +3 -0
- package/dist/esm/erc1155/index.d.ts.map +1 -0
- package/dist/esm/erc1155/index.js +3 -0
- package/dist/esm/erc1155/index.js.map +1 -0
- package/dist/esm/erc1155/interface.d.ts +3 -0
- package/dist/esm/erc1155/interface.d.ts.map +1 -0
- package/dist/esm/erc1155/interface.js +4 -0
- package/dist/esm/erc1155/interface.js.map +1 -0
- package/dist/esm/erc20/handler.d.ts +5 -0
- package/dist/esm/erc20/handler.d.ts.map +1 -1
- package/dist/esm/erc20/handler.js +8 -0
- package/dist/esm/erc20/handler.js.map +1 -1
- package/dist/esm/erc721/handler.d.ts +5 -0
- package/dist/esm/erc721/handler.d.ts.map +1 -1
- package/dist/esm/erc721/handler.js +8 -0
- package/dist/esm/erc721/handler.js.map +1 -1
- package/dist/esm/event-logs/mixin.d.ts +11 -0
- package/dist/esm/event-logs/mixin.d.ts.map +1 -0
- package/dist/esm/event-logs/mixin.js +13 -0
- package/dist/esm/event-logs/mixin.js.map +1 -0
- package/dist/esm/exchanges/mixin.d.ts +77 -0
- package/dist/esm/exchanges/mixin.d.ts.map +1 -0
- package/dist/esm/exchanges/mixin.js +141 -0
- package/dist/esm/exchanges/mixin.js.map +1 -0
- package/dist/esm/funds/mixin.d.ts +42 -0
- package/dist/esm/funds/mixin.d.ts.map +1 -0
- package/dist/esm/funds/mixin.js +72 -0
- package/dist/esm/funds/mixin.js.map +1 -0
- package/dist/esm/groups/mixin.d.ts +14 -0
- package/dist/esm/groups/mixin.d.ts.map +1 -0
- package/dist/esm/groups/mixin.js +18 -0
- package/dist/esm/groups/mixin.js.map +1 -0
- package/dist/esm/meta-tx/mixin.d.ts +176 -0
- package/dist/esm/meta-tx/mixin.d.ts.map +1 -0
- package/dist/esm/meta-tx/mixin.js +351 -0
- package/dist/esm/meta-tx/mixin.js.map +1 -0
- package/dist/esm/metadata/mixin.d.ts +42 -0
- package/dist/esm/metadata/mixin.d.ts.map +1 -0
- package/dist/esm/metadata/mixin.js +60 -0
- package/dist/esm/metadata/mixin.js.map +1 -0
- package/dist/esm/metadata/subgraph.d.ts +3 -1
- package/dist/esm/metadata/subgraph.d.ts.map +1 -1
- package/dist/esm/metadata/subgraph.js +14 -0
- package/dist/esm/metadata/subgraph.js.map +1 -1
- package/dist/esm/mixins/base-core-sdk.d.ts +41 -0
- package/dist/esm/mixins/base-core-sdk.d.ts.map +1 -0
- package/dist/esm/mixins/base-core-sdk.js +54 -0
- package/dist/esm/mixins/base-core-sdk.js.map +1 -0
- package/dist/esm/native-meta-tx/mixin.d.ts +35 -0
- package/dist/esm/native-meta-tx/mixin.d.ts.map +1 -0
- package/dist/esm/native-meta-tx/mixin.js +51 -0
- package/dist/esm/native-meta-tx/mixin.js.map +1 -0
- package/dist/esm/offers/mixin.d.ts +133 -0
- package/dist/esm/offers/mixin.d.ts.map +1 -0
- package/dist/esm/offers/mixin.js +276 -0
- package/dist/esm/offers/mixin.js.map +1 -0
- package/dist/esm/orchestration/mixin.d.ts +28 -0
- package/dist/esm/orchestration/mixin.d.ts.map +1 -0
- package/dist/esm/orchestration/mixin.js +42 -0
- package/dist/esm/orchestration/mixin.js.map +1 -0
- package/dist/esm/subgraph.d.ts +3707 -1509
- package/dist/esm/subgraph.d.ts.map +1 -1
- package/dist/esm/subgraph.js +110 -1
- package/dist/esm/subgraph.js.map +1 -1
- package/dist/esm/utils/graphql.d.ts +14 -0
- package/dist/esm/utils/graphql.d.ts.map +1 -1
- package/dist/esm/utils/signature.d.ts.map +1 -1
- package/dist/esm/utils/signature.js +5 -1
- package/dist/esm/utils/signature.js.map +1 -1
- package/dist/esm/utils/tokenInfoManager.d.ts +6 -2
- package/dist/esm/utils/tokenInfoManager.d.ts.map +1 -1
- package/dist/esm/utils/tokenInfoManager.js +39 -6
- package/dist/esm/utils/tokenInfoManager.js.map +1 -1
- package/package.json +3 -3
- package/src/accounts/mixin.ts +484 -0
- package/src/core-sdk.ts +42 -2102
- package/src/disputes/mixin.ts +240 -0
- package/src/erc1155/handler.ts +21 -0
- package/src/erc1155/index.ts +2 -0
- package/src/erc1155/interface.ts +4 -0
- package/src/erc20/handler.ts +14 -0
- package/src/erc721/handler.ts +14 -0
- package/src/event-logs/mixin.ts +16 -0
- package/src/exchanges/mixin.ts +184 -0
- package/src/funds/mixin.ts +99 -0
- package/src/groups/mixin.ts +24 -0
- package/src/meta-tx/mixin.ts +515 -0
- package/src/metadata/mixin.ts +97 -0
- package/src/metadata/product-v1.graphql +77 -1
- package/src/metadata/subgraph.ts +31 -1
- package/src/mixins/base-core-sdk.ts +96 -0
- package/src/native-meta-tx/mixin.ts +77 -0
- package/src/offers/mixin.ts +376 -0
- package/src/offers/queries.graphql +1 -1
- package/src/orchestration/mixin.ts +57 -0
- package/src/subgraph.ts +3620 -1296
- package/src/utils/signature.ts +6 -1
- package/src/utils/tokenInfoManager.ts +44 -6
package/dist/cjs/core-sdk.js
CHANGED
|
@@ -1,71 +1,20 @@
|
|
|
1
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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
3
|
exports.CoreSDK = void 0;
|
|
36
|
-
const
|
|
4
|
+
const mixin_1 = require("./orchestration/mixin");
|
|
5
|
+
const mixin_2 = require("./groups/mixin");
|
|
6
|
+
const mixin_3 = require("./native-meta-tx/mixin");
|
|
7
|
+
const mixin_4 = require("./meta-tx/mixin");
|
|
8
|
+
const mixin_5 = require("./disputes/mixin");
|
|
9
|
+
const base_core_sdk_1 = require("./mixins/base-core-sdk");
|
|
37
10
|
const common_1 = require("@bosonprotocol/common");
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const groups = __importStar(require("./groups"));
|
|
46
|
-
const erc20 = __importStar(require("./erc20"));
|
|
47
|
-
const erc721 = __importStar(require("./erc721"));
|
|
48
|
-
const funds = __importStar(require("./funds"));
|
|
49
|
-
const metaTx = __importStar(require("./meta-tx"));
|
|
50
|
-
const nativeMetaTx = __importStar(require("./native-meta-tx"));
|
|
51
|
-
const metadata = __importStar(require("./metadata"));
|
|
52
|
-
const eventLogs = __importStar(require("./event-logs"));
|
|
53
|
-
const logs_1 = require("./utils/logs");
|
|
54
|
-
class CoreSDK {
|
|
55
|
-
/**
|
|
56
|
-
* Creates an instance of `CoreSDK`
|
|
57
|
-
* @param args - Constructor args
|
|
58
|
-
*/
|
|
59
|
-
constructor(opts) {
|
|
60
|
-
this._web3Lib = opts.web3Lib;
|
|
61
|
-
this._subgraphUrl = opts.subgraphUrl;
|
|
62
|
-
this._protocolDiamond = opts.protocolDiamond;
|
|
63
|
-
this._metadataStorage = opts.metadataStorage;
|
|
64
|
-
this._theGraphStorage = opts.theGraphStorage;
|
|
65
|
-
this._chainId = opts.chainId;
|
|
66
|
-
this._metaTxConfig = opts.metaTx;
|
|
67
|
-
this._lensContracts = opts.lensContracts;
|
|
68
|
-
}
|
|
11
|
+
const mixin_6 = require("./metadata/mixin");
|
|
12
|
+
const mixin_7 = require("./accounts/mixin");
|
|
13
|
+
const mixin_8 = require("./offers/mixin");
|
|
14
|
+
const mixin_9 = require("./funds/mixin");
|
|
15
|
+
const mixin_10 = require("./exchanges/mixin");
|
|
16
|
+
const mixin_11 = require("./event-logs/mixin");
|
|
17
|
+
class CoreSDK extends base_core_sdk_1.BaseCoreSDK {
|
|
69
18
|
/**
|
|
70
19
|
* Creates an instance of `CoreSDK` by using default values derived either from
|
|
71
20
|
* `args.envName` or `args.chainId`.
|
|
@@ -111,1521 +60,19 @@ class CoreSDK {
|
|
|
111
60
|
!!this._metaTxConfig.apiKey &&
|
|
112
61
|
!!this._metaTxConfig.relayerUrl);
|
|
113
62
|
}
|
|
114
|
-
/* -------------------------------------------------------------------------- */
|
|
115
|
-
/* Metadata related methods */
|
|
116
|
-
/* -------------------------------------------------------------------------- */
|
|
117
|
-
/**
|
|
118
|
-
* Stores supported offer metadata via the MetadataStorage instance which was passed in
|
|
119
|
-
* at construction.
|
|
120
|
-
* @param metadata - Offer metadata of type `BASE` or `PRODUCT_V1`.
|
|
121
|
-
* @returns Metadata hash / identifier.
|
|
122
|
-
*/
|
|
123
|
-
storeMetadata(metadata) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
if (!this._metadataStorage) {
|
|
126
|
-
throw new Error("No metadata storage set");
|
|
127
|
-
}
|
|
128
|
-
return this._metadataStorage.storeMetadata(metadata);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Returns supported offer metadata from passed in `MetadataStorage` instance.
|
|
133
|
-
* @param metadataHashOrUri - Metadata hash or uri that can be handled by the
|
|
134
|
-
* storage instance.
|
|
135
|
-
* @returns Offer metadata.
|
|
136
|
-
*/
|
|
137
|
-
getMetadata(metadataHashOrUri) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
if (!this._metadataStorage) {
|
|
140
|
-
throw new Error("No metadata storage set");
|
|
141
|
-
}
|
|
142
|
-
return this._metadataStorage.getMetadata(metadataHashOrUri);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Returns `BASE` type offer metadata entities from subgraph.
|
|
147
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
148
|
-
* @returns BaseMetadataEntities from subgraph.
|
|
149
|
-
*/
|
|
150
|
-
getBaseMetadataEntities(queryVars) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
return metadata.subgraph.getBaseMetadataEntities(this._subgraphUrl, queryVars);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Returns `PRODUCT_V1` type offer metadata entities from subgraph.
|
|
157
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
158
|
-
* @returns ProductV1MetadataEntities from subgraph.
|
|
159
|
-
*/
|
|
160
|
-
getProductV1MetadataEntities(queryVars) {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
return metadata.subgraph.getProductV1MetadataEntities(this._subgraphUrl, queryVars);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
getProductV1Products(queryVars) {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
-
return metadata.subgraph.getProductV1Products(this._subgraphUrl, queryVars);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
getProductWithVariants(productUuid) {
|
|
171
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
return metadata.subgraph.getProductWithVariants(this._subgraphUrl, productUuid);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
/* -------------------------------------------------------------------------- */
|
|
176
|
-
/* Account related methods */
|
|
177
|
-
/* -------------------------------------------------------------------------- */
|
|
178
|
-
/* --------------------------------- Seller --------------------------------- */
|
|
179
|
-
/**
|
|
180
|
-
* Returns seller entity from subgraph.
|
|
181
|
-
* @param sellerId - ID of seller entity to query for.
|
|
182
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
183
|
-
* @returns Seller entity from subgraph.
|
|
184
|
-
*/
|
|
185
|
-
getSellerById(sellerId, queryVars) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
return accounts.subgraph.getSellerById(this._subgraphUrl, sellerId, queryVars);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Returns seller entity from subgraph.
|
|
192
|
-
* @param operator - Operator address of seller entity to query for.
|
|
193
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
194
|
-
* @returns Seller entity from subgraph.
|
|
195
|
-
*/
|
|
196
|
-
getSellerByOperator(operator, queryVars) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
return accounts.subgraph.getSellerByOperator(this._subgraphUrl, operator, queryVars);
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Returns seller entity from subgraph.
|
|
203
|
-
* @param clerk - Clerk address of seller entity to query for.
|
|
204
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
205
|
-
* @returns Seller entity from subgraph.
|
|
206
|
-
*/
|
|
207
|
-
getSellerByClerk(clerk, queryVars) {
|
|
208
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
return accounts.subgraph.getSellerByClerk(this._subgraphUrl, clerk, queryVars);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Returns seller entity from subgraph.
|
|
214
|
-
* @param admin - Admin address of seller entity to query for.
|
|
215
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
216
|
-
* @returns Seller entity from subgraph.
|
|
217
|
-
*/
|
|
218
|
-
getSellerByAdmin(admin, queryVars) {
|
|
219
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
return accounts.subgraph.getSellerByAdmin(this._subgraphUrl, admin, queryVars);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Returns seller entity from subgraph.
|
|
225
|
-
* @param treasury - Treasury address of seller entity to query for.
|
|
226
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
227
|
-
* @returns Seller entity from subgraph.
|
|
228
|
-
*/
|
|
229
|
-
getSellerByTreasury(treasury, queryVars) {
|
|
230
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
-
return accounts.subgraph.getSellerByTreasury(this._subgraphUrl, treasury, queryVars);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Returns seller entity from subgraph. Matches `operator`, `clerk`, `admin` or `treasury`.
|
|
236
|
-
* @param address - Address of seller entity to query for.
|
|
237
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
238
|
-
* @returns Seller entity from subgraph.
|
|
239
|
-
*/
|
|
240
|
-
getSellersByAddress(address, queryVars) {
|
|
241
|
-
var _a;
|
|
242
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
if (address === constants_1.AddressZero) {
|
|
244
|
-
throw new Error(`Unsupported search address '${constants_1.AddressZero}'`);
|
|
245
|
-
}
|
|
246
|
-
const seller = yield accounts.subgraph.getSellerByAddress(this._subgraphUrl, address, queryVars);
|
|
247
|
-
if (!seller && ((_a = this._lensContracts) === null || _a === void 0 ? void 0 : _a.LENS_HUB_CONTRACT)) {
|
|
248
|
-
// If seller is not found per address, try to find per authToken
|
|
249
|
-
const tokenType = common_1.AuthTokenType.LENS; // only LENS for now
|
|
250
|
-
const tokenIds = yield this.fetchUserAuthTokens(address, tokenType);
|
|
251
|
-
const promises = [];
|
|
252
|
-
for (const tokenId of tokenIds) {
|
|
253
|
-
// Just in case the user owns several auth tokens
|
|
254
|
-
const sellerPromise = this.getSellerByAuthToken(tokenId, tokenType, queryVars);
|
|
255
|
-
promises.push(sellerPromise);
|
|
256
|
-
}
|
|
257
|
-
return (yield Promise.all(promises)).filter((seller) => !!seller);
|
|
258
|
-
}
|
|
259
|
-
return [seller].filter((seller) => !!seller);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Returns the array of LENS tokenIds owned by a specified address
|
|
264
|
-
* @param address - Address of seller entity to query for.
|
|
265
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
266
|
-
* @returns Array of tokenIds
|
|
267
|
-
*/
|
|
268
|
-
fetchUserAuthTokens(address, tokenType) {
|
|
269
|
-
var _a, _b, _c;
|
|
270
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
-
if (tokenType !== common_1.AuthTokenType.LENS) {
|
|
272
|
-
// only LENS for now
|
|
273
|
-
throw new Error(`Unsupported authTokenType '${tokenType}'`);
|
|
274
|
-
}
|
|
275
|
-
if (!this._lensContracts || !((_a = this._lensContracts) === null || _a === void 0 ? void 0 : _a.LENS_HUB_CONTRACT)) {
|
|
276
|
-
throw new Error("LENS contract is not configured in Core-SDK");
|
|
277
|
-
}
|
|
278
|
-
const balance = yield erc721.handler.balanceOf({
|
|
279
|
-
contractAddress: (_b = this._lensContracts) === null || _b === void 0 ? void 0 : _b.LENS_HUB_CONTRACT,
|
|
280
|
-
owner: address,
|
|
281
|
-
web3Lib: this._web3Lib
|
|
282
|
-
});
|
|
283
|
-
const balanceBN = bignumber_1.BigNumber.from(balance);
|
|
284
|
-
const promises = [];
|
|
285
|
-
for (let index = 0; balanceBN.gt(index); index++) {
|
|
286
|
-
const tokenIdPromise = erc721.handler.tokenOfOwnerByIndex({
|
|
287
|
-
contractAddress: (_c = this._lensContracts) === null || _c === void 0 ? void 0 : _c.LENS_HUB_CONTRACT,
|
|
288
|
-
owner: address,
|
|
289
|
-
index,
|
|
290
|
-
web3Lib: this._web3Lib
|
|
291
|
-
});
|
|
292
|
-
promises.push(tokenIdPromise);
|
|
293
|
-
}
|
|
294
|
-
const ret = yield Promise.all(promises);
|
|
295
|
-
return ret;
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Returns seller entity from subgraph that owns the given auth token (if any).
|
|
300
|
-
* @param tokenId - tokenId of the Auth Token.
|
|
301
|
-
* @param tokenType - Type of the Auth Token (1 for LENS, ...).
|
|
302
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
303
|
-
* @returns Seller entity from subgraph.
|
|
304
|
-
*/
|
|
305
|
-
getSellerByAuthToken(tokenId, tokenType, queryVars) {
|
|
306
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
307
|
-
if (tokenType !== common_1.AuthTokenType.LENS) {
|
|
308
|
-
// only LENS for now
|
|
309
|
-
throw new Error(`Unsupported authTokenType '${tokenType}'`);
|
|
310
|
-
}
|
|
311
|
-
return accounts.subgraph.getSellerByAuthToken(this._subgraphUrl, tokenId, tokenType, queryVars);
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Returns seller entities from subgraph.
|
|
316
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
317
|
-
* @returns Seller entities from subgraph.
|
|
318
|
-
*/
|
|
319
|
-
getSellers(queryVars) {
|
|
320
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
321
|
-
return accounts.subgraph.getSellers(this._subgraphUrl, queryVars);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Creates seller account by calling the `AccountHandlerFacet` contract.
|
|
326
|
-
* @param sellerToCreate - Addresses and contract URI to set in the seller account.
|
|
327
|
-
* @param overrides - Optional overrides.
|
|
328
|
-
* @returns Transaction response.
|
|
329
|
-
*/
|
|
330
|
-
createSeller(sellerToCreate, overrides = {}) {
|
|
331
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
332
|
-
return accounts.handler.createSeller({
|
|
333
|
-
sellerToCreate,
|
|
334
|
-
web3Lib: this._web3Lib,
|
|
335
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* Creates seller account and offer by calling the `OrchestrationHandlerFacet` contract.
|
|
341
|
-
* This transaction only succeeds if there is no existing seller account for the connected signer.
|
|
342
|
-
* @param sellerToCreate - Addresses to set in the seller account.
|
|
343
|
-
* @param offerToCreate - Offer arguments.
|
|
344
|
-
* @param overrides - Optional overrides.
|
|
345
|
-
* @returns Transaction response.
|
|
346
|
-
*/
|
|
347
|
-
createSellerAndOffer(sellerToCreate, offerToCreate, overrides = {}) {
|
|
348
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
-
return orchestration.handler.createOfferAndSeller({
|
|
350
|
-
sellerToCreate,
|
|
351
|
-
offerToCreate,
|
|
352
|
-
web3Lib: this._web3Lib,
|
|
353
|
-
theGraphStorage: this._theGraphStorage,
|
|
354
|
-
metadataStorage: this._metadataStorage,
|
|
355
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Updates seller account by calling the `AccountHandlerFacet` contract. Only callable
|
|
361
|
-
* by admin.
|
|
362
|
-
* @param sellerUpdates - Values to update.
|
|
363
|
-
* @param overrides - Optional overrides.
|
|
364
|
-
* @returns Transaction response.
|
|
365
|
-
*/
|
|
366
|
-
updateSeller(sellerUpdates, overrides = {}) {
|
|
367
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
-
return accounts.handler.updateSeller({
|
|
369
|
-
sellerUpdates,
|
|
370
|
-
web3Lib: this._web3Lib,
|
|
371
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
/* ---------------------------------- Buyer --------------------------------- */
|
|
376
|
-
/**
|
|
377
|
-
* Returns buyer entity from subgraph.
|
|
378
|
-
* @param buyerId - ID of buyer entity to query for.
|
|
379
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
380
|
-
* @returns Buyer entity from subgraph.
|
|
381
|
-
*/
|
|
382
|
-
getBuyerById(buyerId, queryVars) {
|
|
383
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
return accounts.subgraph.getBuyerById(this._subgraphUrl, buyerId, queryVars);
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
/**
|
|
388
|
-
* Returns buyer entities from subgraph.
|
|
389
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
390
|
-
* @returns Buyer entities from subgraph.
|
|
391
|
-
*/
|
|
392
|
-
getBuyers(queryVars) {
|
|
393
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
394
|
-
return accounts.subgraph.getBuyers(this._subgraphUrl, queryVars);
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
/* ---------------------------- Dispute Resolver ---------------------------- */
|
|
398
|
-
/**
|
|
399
|
-
* Creates a dispute resolver account by calling the `AccountHandlerFacet` contract.
|
|
400
|
-
* @param disputeResolverToCreate - Dispute resolver arguments.
|
|
401
|
-
* @returns Transaction response.
|
|
402
|
-
*/
|
|
403
|
-
createDisputeResolver(disputeResolverToCreate) {
|
|
404
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
405
|
-
return accounts.handler.createDisputeResolver({
|
|
406
|
-
disputeResolverToCreate,
|
|
407
|
-
contractAddress: this._protocolDiamond,
|
|
408
|
-
web3Lib: this._web3Lib
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Utility method to retrieve the created `exchangeId` from logs after calling `commitToOffer`.
|
|
414
|
-
* @param logs - Logs to search in.
|
|
415
|
-
* @returns Created exchange id.
|
|
416
|
-
*/
|
|
417
|
-
getDisputeResolverIdFromLogs(logs) {
|
|
418
|
-
return (0, logs_1.getValueFromLogs)({
|
|
419
|
-
iface: accounts.iface.bosonAccountHandlerIface,
|
|
420
|
-
logs,
|
|
421
|
-
eventArgsKey: "disputeResolverId",
|
|
422
|
-
eventName: "DisputeResolverCreated"
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Updates a dispute resolver account by calling the `AccountHandlerFacet` contract.
|
|
427
|
-
* Note, that the caller must be the specified `admin` address of the dispute resolver account.
|
|
428
|
-
* @param disputeResolverId - Id of dispute resolver to update.
|
|
429
|
-
* @param updates - Values to update for the given dispute resolver.
|
|
430
|
-
* @returns Transaction response.
|
|
431
|
-
*/
|
|
432
|
-
updateDisputeResolver(disputeResolverId, updates) {
|
|
433
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
434
|
-
return accounts.handler.updateDisputeResolver({
|
|
435
|
-
disputeResolverId,
|
|
436
|
-
updates,
|
|
437
|
-
subgraphUrl: this._subgraphUrl,
|
|
438
|
-
contractAddress: this._protocolDiamond,
|
|
439
|
-
web3Lib: this._web3Lib
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Activates a dispute resolver account by calling the `AccountHandlerFacet` contract.
|
|
445
|
-
* Note, that the caller needs to have the ADMIN role.
|
|
446
|
-
* @param disputeResolverId - Id of dispute resolver to activate.
|
|
447
|
-
* @returns Transaction response.
|
|
448
|
-
*/
|
|
449
|
-
activateDisputeResolver(disputeResolverId) {
|
|
450
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
451
|
-
return accounts.handler.activateDisputeResolver({
|
|
452
|
-
disputeResolverId,
|
|
453
|
-
contractAddress: this._protocolDiamond,
|
|
454
|
-
web3Lib: this._web3Lib
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Adds fees to a dispute resolver account by calling the `AccountHandlerFacet`
|
|
460
|
-
* contract. Note, that the caller must be the specified `admin` address of the dispute
|
|
461
|
-
* resolver account.
|
|
462
|
-
* @param disputeResolverId - Id of dispute resolver.
|
|
463
|
-
* @param fees - Dispute resolution fees. Should only contain token addresses that are
|
|
464
|
-
* not already specified.
|
|
465
|
-
* @returns Transaction response.
|
|
466
|
-
*/
|
|
467
|
-
addFeesToDisputeResolver(disputeResolverId, fees) {
|
|
468
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
469
|
-
return accounts.handler.addFeesToDisputeResolver({
|
|
470
|
-
disputeResolverId,
|
|
471
|
-
fees,
|
|
472
|
-
contractAddress: this._protocolDiamond,
|
|
473
|
-
web3Lib: this._web3Lib
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Adds sellers to the allow list of a dispute resolver account by calling the
|
|
479
|
-
* `AccountHandlerFacet` contract. Note, that the caller must be the specified
|
|
480
|
-
* `admin` address of the dispute resolver account.
|
|
481
|
-
* @param disputeResolverId - Id of dispute resolver.
|
|
482
|
-
* @param sellerAllowList - List of seller ids that are allowed to use the dispute resolver.
|
|
483
|
-
* Should only contain seller ids that are not part of the current allow list.
|
|
484
|
-
* @returns Transaction response.
|
|
485
|
-
*/
|
|
486
|
-
addSellersToDisputeResolverAllowList(disputeResolverId, sellerAllowList) {
|
|
487
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
488
|
-
return accounts.handler.addSellersToAllowList({
|
|
489
|
-
disputeResolverId,
|
|
490
|
-
sellerAllowList,
|
|
491
|
-
contractAddress: this._protocolDiamond,
|
|
492
|
-
web3Lib: this._web3Lib
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Removes fees from a dispute resolver account by calling the `AccountHandlerFacet`
|
|
498
|
-
* contract. Note, that the caller must be the specified `admin` address of the dispute
|
|
499
|
-
* resolver account.
|
|
500
|
-
* @param disputeResolverId - Id of dispute resolver.
|
|
501
|
-
* @param feeTokenAddresses - Addresses of fee tokens to remove.
|
|
502
|
-
* @returns Transaction response.
|
|
503
|
-
*/
|
|
504
|
-
removeFeesFromDisputeResolver(disputeResolverId, feeTokenAddresses) {
|
|
505
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
506
|
-
return accounts.handler.removeFeesFromDisputeResolver({
|
|
507
|
-
disputeResolverId,
|
|
508
|
-
feeTokenAddresses,
|
|
509
|
-
contractAddress: this._protocolDiamond,
|
|
510
|
-
web3Lib: this._web3Lib
|
|
511
|
-
});
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Removes sellers from the allow list of a dispute resolver account by calling the
|
|
516
|
-
* `AccountHandlerFacet` contract. Note, that the caller must be the specified
|
|
517
|
-
* `admin` address of the dispute resolver account.
|
|
518
|
-
* @param disputeResolverId - Id of dispute resolver.
|
|
519
|
-
* @param sellerAllowList - List of seller ids that should be removed from the allow
|
|
520
|
-
* list of a dispute resolver.
|
|
521
|
-
* @returns Transaction response.
|
|
522
|
-
*/
|
|
523
|
-
removeSellersFromDisputeResolverAllowList(disputeResolverId, sellerAllowList) {
|
|
524
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
525
|
-
return accounts.handler.removeSellersFromAllowList({
|
|
526
|
-
disputeResolverId,
|
|
527
|
-
sellerAllowList,
|
|
528
|
-
contractAddress: this._protocolDiamond,
|
|
529
|
-
web3Lib: this._web3Lib
|
|
530
|
-
});
|
|
531
|
-
});
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Returns dispute resolver entity from subgraph.
|
|
535
|
-
* @param disputeResolverId - ID of dispute resolver entity to query for.
|
|
536
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
537
|
-
* @returns Dispute resolver entity from subgraph.
|
|
538
|
-
*/
|
|
539
|
-
getDisputeResolverById(disputeResolverId, queryVars) {
|
|
540
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
541
|
-
return accounts.subgraph.getDisputeResolverById(this._subgraphUrl, disputeResolverId, queryVars);
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Returns dispute resolver entities from subgraph.
|
|
546
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
547
|
-
* @returns Dispute resolver entities from subgraph.
|
|
548
|
-
*/
|
|
549
|
-
getDisputeResolvers(queryVars) {
|
|
550
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
551
|
-
return accounts.subgraph.getDisputeResolvers(this._subgraphUrl, queryVars);
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
/* -------------------------------------------------------------------------- */
|
|
555
|
-
/* Offer related methods */
|
|
556
|
-
/* -------------------------------------------------------------------------- */
|
|
557
|
-
/**
|
|
558
|
-
* Creates offer by calling the `OfferHandlerFacet` contract.
|
|
559
|
-
* This transaction only succeeds if there is an existing seller account for connected signer.
|
|
560
|
-
* @param offerToCreate - Offer arguments.
|
|
561
|
-
* @param overrides - Optional overrides.
|
|
562
|
-
* @returns Transaction response.
|
|
563
|
-
*/
|
|
564
|
-
createOffer(offerToCreate, overrides = {}) {
|
|
565
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
566
|
-
return offers.handler.createOffer({
|
|
567
|
-
offerToCreate,
|
|
568
|
-
web3Lib: this._web3Lib,
|
|
569
|
-
theGraphStorage: this._theGraphStorage,
|
|
570
|
-
metadataStorage: this._metadataStorage,
|
|
571
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Creates a batch of offers by calling the `OfferHandlerFacet` contract.
|
|
577
|
-
* This transaction only succeeds if there is an existing seller account for connected signer.
|
|
578
|
-
* @param offersToCreate - Offer arguments.
|
|
579
|
-
* @param overrides - Optional overrides.
|
|
580
|
-
* @returns Transaction response.
|
|
581
|
-
*/
|
|
582
|
-
createOfferBatch(offersToCreate, overrides = {}) {
|
|
583
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
584
|
-
return offers.handler.createOfferBatch({
|
|
585
|
-
offersToCreate,
|
|
586
|
-
web3Lib: this._web3Lib,
|
|
587
|
-
theGraphStorage: this._theGraphStorage,
|
|
588
|
-
metadataStorage: this._metadataStorage,
|
|
589
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
590
|
-
});
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Utility method to retrieve the created `offerId` from logs after calling `createOffer`
|
|
595
|
-
* or `createOfferAndSeller`.
|
|
596
|
-
* @param logs - Logs to search in.
|
|
597
|
-
* @returns Created offer id.
|
|
598
|
-
*/
|
|
599
|
-
getCreatedOfferIdFromLogs(logs) {
|
|
600
|
-
const offerId = (0, logs_1.getValueFromLogs)({
|
|
601
|
-
iface: offers.iface.bosonOfferHandlerIface,
|
|
602
|
-
logs,
|
|
603
|
-
eventArgsKey: "offerId",
|
|
604
|
-
eventName: "OfferCreated"
|
|
605
|
-
});
|
|
606
|
-
return (offerId ||
|
|
607
|
-
(0, logs_1.getValueFromLogs)({
|
|
608
|
-
iface: orchestration.iface.bosonOrchestrationHandlerIface,
|
|
609
|
-
logs,
|
|
610
|
-
eventArgsKey: "offerId",
|
|
611
|
-
eventName: "OfferCreated"
|
|
612
|
-
}));
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* Utility method to retrieve the created `offerIds` from logs after calling `createOfferBatch`
|
|
616
|
-
* @param logs - Logs to search in.
|
|
617
|
-
* @returns Array of created offerIds.
|
|
618
|
-
*/
|
|
619
|
-
getCreatedOfferIdsFromLogs(logs) {
|
|
620
|
-
return (0, logs_1.getValuesFromLogs)({
|
|
621
|
-
iface: offers.iface.bosonOfferHandlerIface,
|
|
622
|
-
logs,
|
|
623
|
-
eventArgsKey: "offerId",
|
|
624
|
-
eventName: "OfferCreated"
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
/**
|
|
628
|
-
* Utility method to retrieve the created `groupIds` from logs after calling `createGroup`
|
|
629
|
-
* @param logs - Logs to search in.
|
|
630
|
-
* @returns Array of group Ids.
|
|
631
|
-
*/
|
|
632
|
-
getCreatedGroupIdsFromLogs(logs) {
|
|
633
|
-
return (0, logs_1.getValuesFromLogs)({
|
|
634
|
-
iface: groups.iface.bosonGroupHandlerIface,
|
|
635
|
-
logs,
|
|
636
|
-
eventArgsKey: "groupId",
|
|
637
|
-
eventName: "GroupCreated"
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
* Utility method to retrieve the created `sellerId` from logs after calling `createSeller`
|
|
642
|
-
* or `createOfferAndSeller`.
|
|
643
|
-
* @param logs - Logs to search in.
|
|
644
|
-
* @returns Created offer id.
|
|
645
|
-
*/
|
|
646
|
-
getCreatedSellerIdFromLogs(logs) {
|
|
647
|
-
const sellerId = (0, logs_1.getValueFromLogs)({
|
|
648
|
-
iface: accounts.iface.bosonAccountHandlerIface,
|
|
649
|
-
logs,
|
|
650
|
-
eventArgsKey: "sellerId",
|
|
651
|
-
eventName: "SellerCreated"
|
|
652
|
-
});
|
|
653
|
-
return (sellerId ||
|
|
654
|
-
(0, logs_1.getValueFromLogs)({
|
|
655
|
-
iface: orchestration.iface.bosonOrchestrationHandlerIface,
|
|
656
|
-
logs,
|
|
657
|
-
eventArgsKey: "sellerId",
|
|
658
|
-
eventName: "SellerCreated"
|
|
659
|
-
}));
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Voids an existing offer by calling the `OfferHandlerFacet` contract.
|
|
663
|
-
* This transaction only succeeds if the connected signer is the `operator`.
|
|
664
|
-
* @param offerId - ID of offer to void.
|
|
665
|
-
* @param overrides - Optional overrides.
|
|
666
|
-
* @returns Transaction response.
|
|
667
|
-
*/
|
|
668
|
-
voidOffer(offerId, overrides = {}) {
|
|
669
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
670
|
-
return offers.handler.voidOffer({
|
|
671
|
-
offerId,
|
|
672
|
-
web3Lib: this._web3Lib,
|
|
673
|
-
subgraphUrl: this._subgraphUrl,
|
|
674
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
675
|
-
});
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Voids a batch of existing offers by calling the `OfferHandlerFacet` contract.
|
|
680
|
-
* This transaction only succeeds if the connected signer is the `operator` of all
|
|
681
|
-
* provided offers.
|
|
682
|
-
* @param offerIds - IDs of offers to void.
|
|
683
|
-
* @param overrides - Optional overrides.
|
|
684
|
-
* @returns Transaction response.
|
|
685
|
-
*/
|
|
686
|
-
voidOfferBatch(offerIds, overrides = {}) {
|
|
687
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
688
|
-
return offers.handler.voidOfferBatch({
|
|
689
|
-
offerIds,
|
|
690
|
-
web3Lib: this._web3Lib,
|
|
691
|
-
subgraphUrl: this._subgraphUrl,
|
|
692
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Returns offer from subgraph.
|
|
698
|
-
* @param offerId - ID of offer.
|
|
699
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
700
|
-
* @returns Offer entity from subgraph.
|
|
701
|
-
*/
|
|
702
|
-
getOfferById(offerId, queryVars) {
|
|
703
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
704
|
-
return offers.subgraph.getOfferById(this._subgraphUrl, offerId, queryVars);
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Returns offers from subgraph.
|
|
709
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
710
|
-
* @returns Offer entities from subgraph.
|
|
711
|
-
*/
|
|
712
|
-
getOffers(queryVars) {
|
|
713
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
714
|
-
return offers.subgraph.getOffers(this._subgraphUrl, queryVars);
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* Renders contractual agreement for given offer.
|
|
719
|
-
* @param offerId - Id of offer to render agreement for.
|
|
720
|
-
* @returns Contractual agreement as string.
|
|
721
|
-
*/
|
|
722
|
-
renderContractualAgreementForOffer(offerId) {
|
|
723
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
724
|
-
const offerData = yield offers.subgraph.getOfferById(this._subgraphUrl, offerId);
|
|
725
|
-
return offers.renderContractualAgreementForOffer(offerData);
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Renders contractual agreement for given offer.
|
|
730
|
-
* @param template - Mustache syntax based template.
|
|
731
|
-
* @param offerData - Offer data.
|
|
732
|
-
* @returns Contractual agreement as string.
|
|
733
|
-
*/
|
|
734
|
-
renderContractualAgreement(template, offerData, offerMetadata) {
|
|
735
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
736
|
-
const tokenInfo = yield this.getExchangeTokenInfo(offerData.exchangeToken);
|
|
737
|
-
return offers.renderContractualAgreement(template, offerData, offerMetadata, tokenInfo);
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
/* -------------------------------------------------------------------------- */
|
|
741
|
-
/* ERC20 / Exchange Token related methods */
|
|
742
|
-
/* -------------------------------------------------------------------------- */
|
|
743
|
-
/**
|
|
744
|
-
* Returns the current allowance of the given token by calling the contract.
|
|
745
|
-
* @param exchangeToken - Address of exchange token.
|
|
746
|
-
* @param overrides - Optional overrides.
|
|
747
|
-
* @returns Allowance for given signer.
|
|
748
|
-
*/
|
|
749
|
-
getExchangeTokenAllowance(exchangeToken, overrides = {}) {
|
|
750
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
751
|
-
return erc20.handler.getAllowance({
|
|
752
|
-
web3Lib: this._web3Lib,
|
|
753
|
-
contractAddress: exchangeToken,
|
|
754
|
-
spender: overrides.spender || this._protocolDiamond,
|
|
755
|
-
owner: overrides.owner || (yield this._web3Lib.getSignerAddress())
|
|
756
|
-
});
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Returns `name`, `decimals` and `symbol` of the given token by calling the contract.
|
|
761
|
-
* @param exchangeToken - Address exchange token.
|
|
762
|
-
* @returns Decimals, name and symbol.
|
|
763
|
-
*/
|
|
764
|
-
getExchangeTokenInfo(exchangeToken) {
|
|
765
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
766
|
-
if (this._tokenInfoManager === undefined) {
|
|
767
|
-
this._tokenInfoManager = new tokenInfoManager_1.TokenInfoManager(this._chainId, this._web3Lib);
|
|
768
|
-
}
|
|
769
|
-
return this._tokenInfoManager.getExchangeTokenInfo(exchangeToken);
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Approves the given amount for the main protocol contract.
|
|
774
|
-
* @param exchangeToken - Address of token to approve.
|
|
775
|
-
* @param value - Amount of allowance.
|
|
776
|
-
* @param overrides - Optional overrides.
|
|
777
|
-
* @returns Transaction response.
|
|
778
|
-
*/
|
|
779
|
-
approveExchangeToken(exchangeToken, value, overrides = {}) {
|
|
780
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
781
|
-
return erc20.handler.approve({
|
|
782
|
-
contractAddress: exchangeToken,
|
|
783
|
-
spender: overrides.spender || this._protocolDiamond,
|
|
784
|
-
value,
|
|
785
|
-
web3Lib: this._web3Lib
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
getProtocolAllowance(exchangeToken, overrides = {}) {
|
|
790
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
791
|
-
return erc20.handler.getAllowance({
|
|
792
|
-
contractAddress: exchangeToken,
|
|
793
|
-
owner: overrides.owner || (yield this._web3Lib.getSignerAddress()),
|
|
794
|
-
spender: overrides.spender || this._protocolDiamond,
|
|
795
|
-
web3Lib: this._web3Lib
|
|
796
|
-
});
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
/* -------------------------------------------------------------------------- */
|
|
800
|
-
/* Funds related methods */
|
|
801
|
-
/* -------------------------------------------------------------------------- */
|
|
802
|
-
/**
|
|
803
|
-
* Deposit funds by calling the `FundsHandlerFacet` contract.
|
|
804
|
-
* @param sellerId - ID of seller account to deposit funds for.
|
|
805
|
-
* @param fundsAmount - Amount of funds.
|
|
806
|
-
* @param fundsTokenAddress - Address of funds token.
|
|
807
|
-
* @returns Transaction response.
|
|
808
|
-
*/
|
|
809
|
-
depositFunds(sellerId, fundsAmount, fundsTokenAddress = constants_1.AddressZero) {
|
|
810
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
811
|
-
return funds.handler.depositFunds({
|
|
812
|
-
sellerId,
|
|
813
|
-
fundsAmount,
|
|
814
|
-
fundsTokenAddress,
|
|
815
|
-
contractAddress: this._protocolDiamond,
|
|
816
|
-
web3Lib: this._web3Lib
|
|
817
|
-
});
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* Returns funds entity from subgraph.
|
|
822
|
-
* @param fundsId - ID of funds entity.
|
|
823
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
824
|
-
* @returns Funds entity from subgraph.
|
|
825
|
-
*/
|
|
826
|
-
getFundsById(fundsId, queryVars) {
|
|
827
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
828
|
-
return funds.subgraph.getFundsById(this._subgraphUrl, fundsId, queryVars);
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Returns funds entities from subgraph.
|
|
833
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
834
|
-
* @returns Funds entities from subgraph.
|
|
835
|
-
*/
|
|
836
|
-
getFunds(queryVars) {
|
|
837
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
838
|
-
return funds.subgraph.getFunds(this._subgraphUrl, queryVars);
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
/**
|
|
842
|
-
* Withdraw selected funds by calling the `FundsHandlerFacet` contract.
|
|
843
|
-
* @param sellerId - ID of seller account to withdraw funds for.
|
|
844
|
-
* @param tokensToWithdraw - Addresses of funds tokens to withdraw.
|
|
845
|
-
* @param amountsToWithdraw - Amounts of funds token to withdraw.
|
|
846
|
-
* @returns Transaction response.
|
|
847
|
-
*/
|
|
848
|
-
withdrawFunds(sellerId, tokensToWithdraw, amountsToWithdraw) {
|
|
849
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
850
|
-
return funds.handler.withdrawFunds({
|
|
851
|
-
sellerId,
|
|
852
|
-
tokensToWithdraw,
|
|
853
|
-
amountsToWithdraw,
|
|
854
|
-
contractAddress: this._protocolDiamond,
|
|
855
|
-
web3Lib: this._web3Lib
|
|
856
|
-
});
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
/**
|
|
860
|
-
* Withdraw all available funds by calling the `FundsHandlerFacet` contract.
|
|
861
|
-
* @param sellerId - ID of seller account to withdraw funds for.
|
|
862
|
-
* @returns Transaction response.
|
|
863
|
-
*/
|
|
864
|
-
withdrawAllAvailableFunds(sellerId) {
|
|
865
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
866
|
-
return funds.handler.withdrawAllAvailableFunds({
|
|
867
|
-
sellerId,
|
|
868
|
-
subgraphUrl: this._subgraphUrl,
|
|
869
|
-
contractAddress: this._protocolDiamond,
|
|
870
|
-
web3Lib: this._web3Lib
|
|
871
|
-
});
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
/* -------------------------------------------------------------------------- */
|
|
875
|
-
/* Exchange related methods */
|
|
876
|
-
/* -------------------------------------------------------------------------- */
|
|
877
|
-
/**
|
|
878
|
-
* Returns exchange entity from subgraph.
|
|
879
|
-
* @param exchangeId - ID of exchange entity.
|
|
880
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
881
|
-
* @returns Exchange entity from subgraph.
|
|
882
|
-
*/
|
|
883
|
-
getExchangeById(exchangeId, queryVars) {
|
|
884
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
885
|
-
return exchanges.subgraph.getExchangeById(this._subgraphUrl, exchangeId, queryVars);
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
/**
|
|
889
|
-
* Returns exchange entities from subgraph.
|
|
890
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
891
|
-
* @returns Exchange entities from subgraph.
|
|
892
|
-
*/
|
|
893
|
-
getExchanges(queryVars) {
|
|
894
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
895
|
-
return exchanges.subgraph.getExchanges(this._subgraphUrl, queryVars);
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Commits to an offer by calling the `ExchangeHandlerContract`.
|
|
900
|
-
* This transaction only succeeds if the seller has deposited funds.
|
|
901
|
-
* @param offerId - ID of offer to commit to.
|
|
902
|
-
* @param overrides - Optional overrides.
|
|
903
|
-
* @returns Transaction response.
|
|
904
|
-
*/
|
|
905
|
-
commitToOffer(offerId, overrides = {}) {
|
|
906
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
907
|
-
const buyer = overrides.buyer || (yield this._web3Lib.getSignerAddress());
|
|
908
|
-
return exchanges.handler.commitToOffer({
|
|
909
|
-
buyer,
|
|
910
|
-
offerId,
|
|
911
|
-
web3Lib: this._web3Lib,
|
|
912
|
-
subgraphUrl: this._subgraphUrl,
|
|
913
|
-
contractAddress: this._protocolDiamond
|
|
914
|
-
});
|
|
915
|
-
});
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Utility method to retrieve the created `exchangeId` from logs after calling `commitToOffer`.
|
|
919
|
-
* @param logs - Logs to search in.
|
|
920
|
-
* @returns Created exchange id.
|
|
921
|
-
*/
|
|
922
|
-
getCommittedExchangeIdFromLogs(logs) {
|
|
923
|
-
return (0, logs_1.getValueFromLogs)({
|
|
924
|
-
iface: exchanges.iface.bosonExchangeHandlerIface,
|
|
925
|
-
logs,
|
|
926
|
-
eventArgsKey: "exchangeId",
|
|
927
|
-
eventName: "BuyerCommitted"
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* Revokes an existing voucher by calling the `ExchangeHandlerContract`.
|
|
932
|
-
* Callable by seller `operator`.
|
|
933
|
-
* @param exchangeId - ID of exchange to revoke.
|
|
934
|
-
* @returns Transaction response.
|
|
935
|
-
*/
|
|
936
|
-
revokeVoucher(exchangeId) {
|
|
937
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
938
|
-
return exchanges.handler.revokeVoucher({
|
|
939
|
-
web3Lib: this._web3Lib,
|
|
940
|
-
contractAddress: this._protocolDiamond,
|
|
941
|
-
exchangeId,
|
|
942
|
-
subgraphUrl: this._subgraphUrl
|
|
943
|
-
});
|
|
944
|
-
});
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* Cancels an existing voucher by calling the `ExchangeHandlerContract`.
|
|
948
|
-
* Callable by buyer.
|
|
949
|
-
* @param exchangeId - ID of exchange to cancel.
|
|
950
|
-
* @returns Transaction response.
|
|
951
|
-
*/
|
|
952
|
-
cancelVoucher(exchangeId) {
|
|
953
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
954
|
-
return exchanges.handler.cancelVoucher({
|
|
955
|
-
web3Lib: this._web3Lib,
|
|
956
|
-
contractAddress: this._protocolDiamond,
|
|
957
|
-
exchangeId,
|
|
958
|
-
subgraphUrl: this._subgraphUrl
|
|
959
|
-
});
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
|
-
/**
|
|
963
|
-
* Redeems an existing voucher by calling the `ExchangeHandlerContract`.
|
|
964
|
-
* Callable by buyer.
|
|
965
|
-
* @param exchangeId - ID of exchange to redeem.
|
|
966
|
-
* @returns Transaction response.
|
|
967
|
-
*/
|
|
968
|
-
redeemVoucher(exchangeId) {
|
|
969
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
970
|
-
return exchanges.handler.redeemVoucher({
|
|
971
|
-
web3Lib: this._web3Lib,
|
|
972
|
-
contractAddress: this._protocolDiamond,
|
|
973
|
-
exchangeId,
|
|
974
|
-
subgraphUrl: this._subgraphUrl
|
|
975
|
-
});
|
|
976
|
-
});
|
|
977
|
-
}
|
|
978
|
-
/**
|
|
979
|
-
* Completes an existing voucher by calling the `ExchangeHandlerContract`.
|
|
980
|
-
* Callable by buyer or seller operator.
|
|
981
|
-
* @param exchangeId - ID of exchange to complete.
|
|
982
|
-
* @returns Transaction response.
|
|
983
|
-
*/
|
|
984
|
-
completeExchange(exchangeId) {
|
|
985
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
986
|
-
return exchanges.handler.completeExchange({
|
|
987
|
-
web3Lib: this._web3Lib,
|
|
988
|
-
contractAddress: this._protocolDiamond,
|
|
989
|
-
exchangeId,
|
|
990
|
-
subgraphUrl: this._subgraphUrl
|
|
991
|
-
});
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* Completes a batch of existing vouchers by calling the `ExchangeHandlerContract`.
|
|
996
|
-
* Callable by buyer or seller operator.
|
|
997
|
-
* @param exchangeIds - IDs of exchange to complete.
|
|
998
|
-
* @returns Transaction response.
|
|
999
|
-
*/
|
|
1000
|
-
completeExchangeBatch(exchangeIds) {
|
|
1001
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1002
|
-
return exchanges.handler.completeExchangeBatch({
|
|
1003
|
-
web3Lib: this._web3Lib,
|
|
1004
|
-
contractAddress: this._protocolDiamond,
|
|
1005
|
-
exchangeIds,
|
|
1006
|
-
subgraphUrl: this._subgraphUrl
|
|
1007
|
-
});
|
|
1008
|
-
});
|
|
1009
|
-
}
|
|
1010
|
-
/**
|
|
1011
|
-
* Expires an existing voucher by calling the `ExchangeHandlerContract`.
|
|
1012
|
-
* @param exchangeId - ID of exchange to expire.
|
|
1013
|
-
* @returns Transaction response.
|
|
1014
|
-
*/
|
|
1015
|
-
expireVoucher(exchangeId) {
|
|
1016
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1017
|
-
return exchanges.handler.expireVoucher({
|
|
1018
|
-
web3Lib: this._web3Lib,
|
|
1019
|
-
contractAddress: this._protocolDiamond,
|
|
1020
|
-
exchangeId,
|
|
1021
|
-
subgraphUrl: this._subgraphUrl
|
|
1022
|
-
});
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
/* -------------------------------------------------------------------------- */
|
|
1026
|
-
/* Dispute related methods */
|
|
1027
|
-
/* -------------------------------------------------------------------------- */
|
|
1028
|
-
/**
|
|
1029
|
-
* Returns dispute entity from subgraph.
|
|
1030
|
-
* @param disputeId - ID of dispute entity.
|
|
1031
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
1032
|
-
* @returns Dispute entity from subgraph.
|
|
1033
|
-
*/
|
|
1034
|
-
getDisputeById(disputeId, queryVars) {
|
|
1035
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1036
|
-
return disputes.subgraph.getDisputeById(this._subgraphUrl, disputeId, queryVars);
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* Returns dispute entities from subgraph.
|
|
1041
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
1042
|
-
* @returns Dispute entities from subgraph.
|
|
1043
|
-
*/
|
|
1044
|
-
getDisputes(queryVars) {
|
|
1045
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1046
|
-
return disputes.subgraph.getDisputes(this._subgraphUrl, queryVars);
|
|
1047
|
-
});
|
|
1048
|
-
}
|
|
1049
|
-
/**
|
|
1050
|
-
* Raises a dispute by calling the `DisputeHandlerContract`.
|
|
1051
|
-
* @param exchangeId - ID of exchange to dispute.
|
|
1052
|
-
* @returns Transaction response.
|
|
1053
|
-
*/
|
|
1054
|
-
raiseDispute(exchangeId) {
|
|
1055
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1056
|
-
return disputes.handler.raiseDispute({
|
|
1057
|
-
exchangeId,
|
|
1058
|
-
contractAddress: this._protocolDiamond,
|
|
1059
|
-
web3Lib: this._web3Lib
|
|
1060
|
-
});
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Retracts a dispute by calling the `DisputeHandlerContract`.
|
|
1065
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1066
|
-
* @returns Transaction response.
|
|
1067
|
-
*/
|
|
1068
|
-
retractDispute(exchangeId) {
|
|
1069
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1070
|
-
return disputes.handler.retractDispute({
|
|
1071
|
-
exchangeId,
|
|
1072
|
-
contractAddress: this._protocolDiamond,
|
|
1073
|
-
web3Lib: this._web3Lib
|
|
1074
|
-
});
|
|
1075
|
-
});
|
|
1076
|
-
}
|
|
1077
|
-
/**
|
|
1078
|
-
* Extends the dispute timeout by calling the `DisputeHandlerContract`.
|
|
1079
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1080
|
-
* @param newDisputeTimeout - New dispute timeout in seconds.
|
|
1081
|
-
* @returns Transaction response.
|
|
1082
|
-
*/
|
|
1083
|
-
extendDisputeTimeout(exchangeId, newDisputeTimeout) {
|
|
1084
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1085
|
-
return disputes.handler.extendDisputeTimeout({
|
|
1086
|
-
exchangeId,
|
|
1087
|
-
newDisputeTimeout,
|
|
1088
|
-
contractAddress: this._protocolDiamond,
|
|
1089
|
-
web3Lib: this._web3Lib
|
|
1090
|
-
});
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
/**
|
|
1094
|
-
* Expires a dispute by calling the `DisputeHandlerContract`.
|
|
1095
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1096
|
-
* @returns Transaction response.
|
|
1097
|
-
*/
|
|
1098
|
-
expireDispute(exchangeId) {
|
|
1099
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1100
|
-
return disputes.handler.expireDispute({
|
|
1101
|
-
exchangeId,
|
|
1102
|
-
contractAddress: this._protocolDiamond,
|
|
1103
|
-
web3Lib: this._web3Lib
|
|
1104
|
-
});
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Expires many disputes by calling the `DisputeHandlerContract`.
|
|
1109
|
-
* @param exchangeIds - IDs of disputed exchanges.
|
|
1110
|
-
* @returns Transaction response.
|
|
1111
|
-
*/
|
|
1112
|
-
expireDisputeBatch(exchangeIds) {
|
|
1113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1114
|
-
return disputes.handler.expireDisputeBatch({
|
|
1115
|
-
exchangeIds,
|
|
1116
|
-
contractAddress: this._protocolDiamond,
|
|
1117
|
-
web3Lib: this._web3Lib
|
|
1118
|
-
});
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
/**
|
|
1122
|
-
* Resolves dispute by calling the `DisputeHandlerContract`. If caller is `buyer` then
|
|
1123
|
-
* signature of `seller` is required as an argument. If caller if `seller` then vice-versa.
|
|
1124
|
-
* The signature can be retrieved by calling the method
|
|
1125
|
-
* `CoreSDK.signDisputeResolutionProposal`.
|
|
1126
|
-
* @param args - Dispute resolve arguments:
|
|
1127
|
-
* - `args.exchangeId` - ID of disputed exchange.
|
|
1128
|
-
* - `args.buyerPercent` - Percentage of deposit the buyer gets.
|
|
1129
|
-
* - `args.sigR` - r signature value of counterparty.
|
|
1130
|
-
* - `args.sigS` - s signature value of counterparty.
|
|
1131
|
-
* - `args.sigV` - v signature value of counterparty.
|
|
1132
|
-
* @returns Transaction response.
|
|
1133
|
-
*/
|
|
1134
|
-
resolveDispute(args) {
|
|
1135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1136
|
-
return disputes.handler.resolveDispute(Object.assign(Object.assign({}, args), { contractAddress: this._protocolDiamond, web3Lib: this._web3Lib }));
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
/**
|
|
1140
|
-
* Escalates dispute by calling the `DisputeHandlerContract`.
|
|
1141
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1142
|
-
* @returns Transaction response.
|
|
1143
|
-
*/
|
|
1144
|
-
escalateDispute(exchangeId) {
|
|
1145
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1146
|
-
return disputes.handler.escalateDispute({
|
|
1147
|
-
exchangeId,
|
|
1148
|
-
contractAddress: this._protocolDiamond,
|
|
1149
|
-
web3Lib: this._web3Lib
|
|
1150
|
-
});
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
/**
|
|
1154
|
-
* Decides dispute by calling the `DisputeHandlerContract`.
|
|
1155
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1156
|
-
* @param buyerPercent - Percentage of deposit buyer gets.
|
|
1157
|
-
* @returns Transaction response.
|
|
1158
|
-
*/
|
|
1159
|
-
decideDispute(exchangeId, buyerPercent) {
|
|
1160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1161
|
-
return disputes.handler.decideDispute({
|
|
1162
|
-
exchangeId,
|
|
1163
|
-
buyerPercent,
|
|
1164
|
-
contractAddress: this._protocolDiamond,
|
|
1165
|
-
web3Lib: this._web3Lib
|
|
1166
|
-
});
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
/**
|
|
1170
|
-
* Refuses escalated dispute by calling the `DisputeHandlerContract`.
|
|
1171
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1172
|
-
* @returns Transaction response.
|
|
1173
|
-
*/
|
|
1174
|
-
refuseEscalatedDispute(exchangeId) {
|
|
1175
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1176
|
-
return disputes.handler.refuseEscalatedDispute({
|
|
1177
|
-
exchangeId,
|
|
1178
|
-
contractAddress: this._protocolDiamond,
|
|
1179
|
-
web3Lib: this._web3Lib
|
|
1180
|
-
});
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Expires escalated dispute by calling the `DisputeHandlerContract`.
|
|
1185
|
-
* @param exchangeId - ID of disputed exchange.
|
|
1186
|
-
* @returns Transaction response.
|
|
1187
|
-
*/
|
|
1188
|
-
expireEscalatedDispute(exchangeId) {
|
|
1189
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1190
|
-
return disputes.handler.expireEscalatedDispute({
|
|
1191
|
-
exchangeId,
|
|
1192
|
-
contractAddress: this._protocolDiamond,
|
|
1193
|
-
web3Lib: this._web3Lib
|
|
1194
|
-
});
|
|
1195
|
-
});
|
|
1196
|
-
}
|
|
1197
|
-
/**
|
|
1198
|
-
* Signs dispute resolution message.
|
|
1199
|
-
* @param args - Dispute resolve arguments:
|
|
1200
|
-
* - `args.exchangeId` - ID of disputed exchange.
|
|
1201
|
-
* - `args.buyerPercentBasisPoints` - Percentage of deposit the buyer gets.
|
|
1202
|
-
* @returns Signature.
|
|
1203
|
-
*/
|
|
1204
|
-
signDisputeResolutionProposal(args) {
|
|
1205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1206
|
-
return disputes.handler.signResolutionProposal(Object.assign(Object.assign({}, args), { web3Lib: this._web3Lib, contractAddress: this._protocolDiamond, chainId: this._chainId }));
|
|
1207
|
-
});
|
|
1208
|
-
}
|
|
1209
|
-
/* -------------------------------------------------------------------------- */
|
|
1210
|
-
/* Meta Tx related methods */
|
|
1211
|
-
/* -------------------------------------------------------------------------- */
|
|
1212
|
-
/**
|
|
1213
|
-
* Encodes and signs a meta transaction that can be relayed.
|
|
1214
|
-
* @param args - Meta transaction args.
|
|
1215
|
-
* @returns Signature.
|
|
1216
|
-
*/
|
|
1217
|
-
signMetaTx(args) {
|
|
1218
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1219
|
-
return metaTx.handler.signMetaTx(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Encodes and signs a meta transaction for `createSeller` that can be relayed.
|
|
1224
|
-
* @param args - Meta transaction args.
|
|
1225
|
-
* @returns Signature.
|
|
1226
|
-
*/
|
|
1227
|
-
signMetaTxCreateSeller(args) {
|
|
1228
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1229
|
-
return metaTx.handler.signMetaTxCreateSeller(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
/**
|
|
1233
|
-
* Encodes and signs a meta transaction for `createOffer` that can be relayed.
|
|
1234
|
-
* @param args - Meta transaction args.
|
|
1235
|
-
* @returns Signature.
|
|
1236
|
-
*/
|
|
1237
|
-
signMetaTxCreateOffer(args) {
|
|
1238
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1239
|
-
return metaTx.handler.signMetaTxCreateOffer(Object.assign({ web3Lib: this._web3Lib, theGraphStorage: this._theGraphStorage, metadataStorage: this._metadataStorage, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
/**
|
|
1243
|
-
* Encodes and signs a meta transaction for `createOfferBatch` that can be relayed.
|
|
1244
|
-
* @param args - Meta transaction args.
|
|
1245
|
-
* @returns Signature.
|
|
1246
|
-
*/
|
|
1247
|
-
signMetaTxCreateOfferBatch(args) {
|
|
1248
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1249
|
-
return metaTx.handler.signMetaTxCreateOfferBatch(Object.assign({ web3Lib: this._web3Lib, theGraphStorage: this._theGraphStorage, metadataStorage: this._metadataStorage, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
/**
|
|
1253
|
-
* Encodes and signs a meta transaction for `createGroup` that can be relayed.
|
|
1254
|
-
* @param args - Meta transaction args.
|
|
1255
|
-
* @returns Signature.
|
|
1256
|
-
*/
|
|
1257
|
-
signMetaTxCreateGroup(args) {
|
|
1258
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1259
|
-
return metaTx.handler.signMetaTxCreateGroup(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
/**
|
|
1263
|
-
* Encodes and signs a meta transaction for `createOfferWithCondition` that can be relayed.
|
|
1264
|
-
* @param args - Meta transaction args.
|
|
1265
|
-
* @returns Signature.
|
|
1266
|
-
*/
|
|
1267
|
-
signMetaTxCreateOfferWithCondition(args) {
|
|
1268
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1269
|
-
return metaTx.handler.signMetaTxCreateOfferWithCondition(Object.assign({ web3Lib: this._web3Lib, theGraphStorage: this._theGraphStorage, metadataStorage: this._metadataStorage, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
/**
|
|
1273
|
-
* Encodes and signs a meta transaction for `voidOffer` that can be relayed.
|
|
1274
|
-
* @param args - Meta transaction args.
|
|
1275
|
-
* @returns Signature.
|
|
1276
|
-
*/
|
|
1277
|
-
signMetaTxVoidOffer(args) {
|
|
1278
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1279
|
-
return metaTx.handler.signMetaTxVoidOffer(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
/**
|
|
1283
|
-
* Encodes and signs a meta transaction for `voidOfferBatch` that can be relayed.
|
|
1284
|
-
* @param args - Meta transaction args.
|
|
1285
|
-
* @returns Signature.
|
|
1286
|
-
*/
|
|
1287
|
-
signMetaTxVoidOfferBatch(args) {
|
|
1288
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1289
|
-
return metaTx.handler.signMetaTxVoidOfferBatch(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
|
-
/**
|
|
1293
|
-
* Encodes and signs a meta transaction for `completeExchangeBatch` that can be relayed.
|
|
1294
|
-
* @param args - Meta transaction args.
|
|
1295
|
-
* @returns Signature.
|
|
1296
|
-
*/
|
|
1297
|
-
signMetaTxCompleteExchange(args) {
|
|
1298
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1299
|
-
return metaTx.handler.signMetaTxCompleteExchange(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1302
|
-
/**
|
|
1303
|
-
* Encodes and signs a meta transaction for `completeExchangeBatch` that can be relayed.
|
|
1304
|
-
* @param args - Meta transaction args.
|
|
1305
|
-
* @returns Signature.
|
|
1306
|
-
*/
|
|
1307
|
-
signMetaTxCompleteExchangeBatch(args) {
|
|
1308
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1309
|
-
return metaTx.handler.signMetaTxCompleteExchangeBatch(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
/**
|
|
1313
|
-
* Encodes and signs a meta transaction for `commitToOffer` that can be relayed.
|
|
1314
|
-
* @param args - Meta transaction args.
|
|
1315
|
-
* @returns Signature.
|
|
1316
|
-
*/
|
|
1317
|
-
signMetaTxCommitToOffer(args) {
|
|
1318
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1319
|
-
return metaTx.handler.signMetaTxCommitToOffer(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* Encodes and signs a meta transaction for `cancelVoucher` that can be relayed.
|
|
1324
|
-
* @param args - Meta transaction args.
|
|
1325
|
-
* @returns Signature.
|
|
1326
|
-
*/
|
|
1327
|
-
signMetaTxCancelVoucher(args) {
|
|
1328
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1329
|
-
return metaTx.handler.signMetaTxCancelVoucher(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
/**
|
|
1333
|
-
* Encodes and signs a meta transaction for `redeemVoucher` that can be relayed.
|
|
1334
|
-
* @param args - Meta transaction args.
|
|
1335
|
-
* @returns Signature.
|
|
1336
|
-
*/
|
|
1337
|
-
signMetaTxRedeemVoucher(args) {
|
|
1338
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1339
|
-
return metaTx.handler.signMetaTxRedeemVoucher(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
/**
|
|
1343
|
-
* Encodes and signs a meta transaction for `expireVoucher` that can be relayed.
|
|
1344
|
-
* @param args - Meta transaction args.
|
|
1345
|
-
* @returns Signature.
|
|
1346
|
-
*/
|
|
1347
|
-
signMetaTxExpireVoucher(args) {
|
|
1348
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1349
|
-
return metaTx.handler.signMetaTxExpireVoucher(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
/**
|
|
1353
|
-
* Encodes and signs a meta transaction for `revokeVoucher` that can be relayed.
|
|
1354
|
-
* @param args - Meta transaction args.
|
|
1355
|
-
* @returns Signature.
|
|
1356
|
-
*/
|
|
1357
|
-
signMetaTxRevokeVoucher(args) {
|
|
1358
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1359
|
-
return metaTx.handler.signMetaTxRevokeVoucher(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
/**
|
|
1363
|
-
* Encodes and signs a meta transaction for `retractDispute` that can be relayed.
|
|
1364
|
-
* @param args - Meta transaction args.
|
|
1365
|
-
* @returns Signature.
|
|
1366
|
-
*/
|
|
1367
|
-
signMetaTxRetractDispute(args) {
|
|
1368
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1369
|
-
return metaTx.handler.signMetaTxRetractDispute(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1370
|
-
});
|
|
1371
|
-
}
|
|
1372
|
-
/**
|
|
1373
|
-
* Encodes and signs a meta transaction for `escalateDispute` that can be relayed.
|
|
1374
|
-
* @param args - Meta transaction args.
|
|
1375
|
-
* @returns Signature.
|
|
1376
|
-
*/
|
|
1377
|
-
signMetaTxEscalateDispute(args) {
|
|
1378
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1379
|
-
return metaTx.handler.signMetaTxEscalateDispute(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
/**
|
|
1383
|
-
* Encodes and signs a meta transaction for `raiseDispute` that can be relayed.
|
|
1384
|
-
* @param args - Meta transaction args.
|
|
1385
|
-
* @returns Signature.
|
|
1386
|
-
*/
|
|
1387
|
-
signMetaTxRaiseDispute(args) {
|
|
1388
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1389
|
-
return metaTx.handler.signMetaTxRaiseDispute(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
/**
|
|
1393
|
-
* Encodes and signs a meta transaction for `resolveDispute` that can be relayed.
|
|
1394
|
-
* @param args - Meta transaction args.
|
|
1395
|
-
* @returns Signature.
|
|
1396
|
-
*/
|
|
1397
|
-
signMetaTxResolveDispute(args) {
|
|
1398
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1399
|
-
return metaTx.handler.signMetaTxResolveDispute(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1400
|
-
});
|
|
1401
|
-
}
|
|
1402
|
-
/**
|
|
1403
|
-
* Encodes and signs a meta transaction for `extendDisputeTimeout` that can be relayed.
|
|
1404
|
-
* @param args - Meta transaction args.
|
|
1405
|
-
* @returns Signature.
|
|
1406
|
-
*/
|
|
1407
|
-
signMetaTxExtendDisputeTimeout(args) {
|
|
1408
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1409
|
-
return metaTx.handler.signMetaTxExtendDisputeTimeout(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* Encodes and signs a meta transaction for `withdrawFunds` that can be relayed.
|
|
1414
|
-
* @param args - Meta transaction args.
|
|
1415
|
-
* @returns Signature.
|
|
1416
|
-
*/
|
|
1417
|
-
signMetaTxWithdrawFunds(args) {
|
|
1418
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1419
|
-
return metaTx.handler.signMetaTxWithdrawFunds(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
|
-
/**
|
|
1423
|
-
* Encodes and signs a meta transaction for `depositFunds` that can be relayed.
|
|
1424
|
-
* @param args - Meta transaction args.
|
|
1425
|
-
* @returns Signature.
|
|
1426
|
-
*/
|
|
1427
|
-
signMetaTxDepositFunds(args) {
|
|
1428
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1429
|
-
return metaTx.handler.signMetaTxDepositFunds(Object.assign({ web3Lib: this._web3Lib, metaTxHandlerAddress: this._protocolDiamond, chainId: this._chainId }, args));
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
/**
|
|
1433
|
-
* Relay a meta transaction,
|
|
1434
|
-
* @param metaTxParams - Required params for meta transaction.
|
|
1435
|
-
* @param overrides - Optional overrides.
|
|
1436
|
-
* @returns Transaction response.
|
|
1437
|
-
*/
|
|
1438
|
-
relayMetaTransaction(metaTxParams, overrides = {}) {
|
|
1439
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1440
|
-
const { metaTxApiId, metaTxApiKey, metaTxRelayerUrl, contractAddress } = this.assertAndGetMetaTxConfig(overrides);
|
|
1441
|
-
return metaTx.handler.relayMetaTransaction({
|
|
1442
|
-
web3LibAdapter: this._web3Lib,
|
|
1443
|
-
contractAddress,
|
|
1444
|
-
chainId: this._chainId,
|
|
1445
|
-
metaTx: {
|
|
1446
|
-
config: {
|
|
1447
|
-
relayerUrl: metaTxRelayerUrl,
|
|
1448
|
-
apiId: metaTxApiId,
|
|
1449
|
-
apiKey: metaTxApiKey
|
|
1450
|
-
},
|
|
1451
|
-
params: {
|
|
1452
|
-
userAddress: overrides.userAddress || (yield this._web3Lib.getSignerAddress()),
|
|
1453
|
-
functionName: metaTxParams.functionName,
|
|
1454
|
-
functionSignature: metaTxParams.functionSignature,
|
|
1455
|
-
nonce: metaTxParams.nonce,
|
|
1456
|
-
sigR: metaTxParams.sigR,
|
|
1457
|
-
sigS: metaTxParams.sigS,
|
|
1458
|
-
sigV: metaTxParams.sigV
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
});
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
/**
|
|
1465
|
-
* Encodes and signs a native "token.approve()" meta transaction that can be relayed.
|
|
1466
|
-
* @param exchangeToken - The address of the token contract.
|
|
1467
|
-
* @param value - The value to be approved.
|
|
1468
|
-
* @param overrides - Optionally specify a spender address (default is the protocol contract address).
|
|
1469
|
-
* @returns Signature.
|
|
1470
|
-
*/
|
|
1471
|
-
signNativeMetaTxApproveExchangeToken(exchangeToken, value, overrides = {}) {
|
|
1472
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1473
|
-
const user = yield this._web3Lib.getSignerAddress();
|
|
1474
|
-
return nativeMetaTx.handler.signNativeMetaTxApproveExchangeToken({
|
|
1475
|
-
web3Lib: this._web3Lib,
|
|
1476
|
-
chainId: this._chainId,
|
|
1477
|
-
user,
|
|
1478
|
-
exchangeToken,
|
|
1479
|
-
spender: overrides.spender || this._protocolDiamond,
|
|
1480
|
-
value
|
|
1481
|
-
});
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
/**
|
|
1485
|
-
* Relay a native meta transaction,
|
|
1486
|
-
* @param metaTxParams - Required params for meta transaction.
|
|
1487
|
-
* @param overrides - Optional overrides.
|
|
1488
|
-
* @returns Transaction response.
|
|
1489
|
-
*/
|
|
1490
|
-
relayNativeMetaTransaction(contractAddress, metaTxParams, overrides = {}) {
|
|
1491
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1492
|
-
const { metaTxApiId, metaTxApiKey, metaTxRelayerUrl } = this.assertAndGetMetaTxConfig(Object.assign(Object.assign({}, overrides), { contractAddress }));
|
|
1493
|
-
return nativeMetaTx.handler.relayNativeMetaTransaction({
|
|
1494
|
-
web3LibAdapter: this._web3Lib,
|
|
1495
|
-
contractAddress,
|
|
1496
|
-
chainId: this._chainId,
|
|
1497
|
-
metaTx: {
|
|
1498
|
-
config: {
|
|
1499
|
-
relayerUrl: metaTxRelayerUrl,
|
|
1500
|
-
apiId: metaTxApiId,
|
|
1501
|
-
apiKey: metaTxApiKey
|
|
1502
|
-
},
|
|
1503
|
-
params: {
|
|
1504
|
-
userAddress: overrides.userAddress || (yield this._web3Lib.getSignerAddress()),
|
|
1505
|
-
functionSignature: metaTxParams.functionSignature,
|
|
1506
|
-
sigR: metaTxParams.sigR,
|
|
1507
|
-
sigS: metaTxParams.sigS,
|
|
1508
|
-
sigV: metaTxParams.sigV
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
});
|
|
1512
|
-
});
|
|
1513
|
-
}
|
|
1514
|
-
/**
|
|
1515
|
-
* Returns information of submitted meta transaction.
|
|
1516
|
-
* See https://docs.biconomy.io/api/native-meta-tx/get-retried-hashes.
|
|
1517
|
-
* @param originalMetaTxHash - Original meta transaction as returned by `coreSDK.relayMetaTransaction`
|
|
1518
|
-
* @param overrides - Optional overrides for meta transaction config.
|
|
1519
|
-
* @returns - Additional meta transaction information.
|
|
1520
|
-
*/
|
|
1521
|
-
getResubmittedMetaTx(originalMetaTxHash, overrides = {}) {
|
|
1522
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1523
|
-
const { metaTxApiId, metaTxApiKey, metaTxRelayerUrl } = this.assertAndGetMetaTxConfig(overrides);
|
|
1524
|
-
return metaTx.handler.getResubmitted({
|
|
1525
|
-
chainId: this._chainId,
|
|
1526
|
-
metaTx: {
|
|
1527
|
-
config: {
|
|
1528
|
-
relayerUrl: metaTxRelayerUrl,
|
|
1529
|
-
apiId: metaTxApiId,
|
|
1530
|
-
apiKey: metaTxApiKey
|
|
1531
|
-
},
|
|
1532
|
-
originalHash: originalMetaTxHash
|
|
1533
|
-
}
|
|
1534
|
-
});
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
assertAndGetMetaTxConfig(overrides = {}) {
|
|
1538
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1539
|
-
const contractAddress = overrides.contractAddress || this._protocolDiamond;
|
|
1540
|
-
const metaTransactionMethod = overrides.metaTransactionMethod || "executeMetaTransaction";
|
|
1541
|
-
const metaTxRelayerUrl = ((_a = overrides.metaTxConfig) === null || _a === void 0 ? void 0 : _a.relayerUrl) || ((_b = this._metaTxConfig) === null || _b === void 0 ? void 0 : _b.relayerUrl);
|
|
1542
|
-
const metaTxApiKey = ((_c = overrides.metaTxConfig) === null || _c === void 0 ? void 0 : _c.apiKey) || ((_d = this._metaTxConfig) === null || _d === void 0 ? void 0 : _d.apiKey);
|
|
1543
|
-
// metaTxApiId is depending on the contract/method(=executeMetaTransaction) to be called with Biconomy
|
|
1544
|
-
const apiIds = (_e = this._metaTxConfig) === null || _e === void 0 ? void 0 : _e.apiIds[contractAddress.toLowerCase()];
|
|
1545
|
-
const metaTxApiId = ((_f = overrides.metaTxConfig) === null || _f === void 0 ? void 0 : _f.apiId) ||
|
|
1546
|
-
(apiIds && apiIds[metaTransactionMethod]);
|
|
1547
|
-
if (!(metaTxRelayerUrl && metaTxApiKey && metaTxApiId)) {
|
|
1548
|
-
throw new Error("CoreSDK not configured to relay meta transactions. Either pass in 'relayerUrl', 'apiKey' and 'apiId' during initialization OR as overrides arguments.");
|
|
1549
|
-
}
|
|
1550
|
-
return {
|
|
1551
|
-
metaTxRelayerUrl,
|
|
1552
|
-
metaTxApiId,
|
|
1553
|
-
metaTxApiKey,
|
|
1554
|
-
contractAddress
|
|
1555
|
-
};
|
|
1556
|
-
}
|
|
1557
|
-
/* -------------------------------------------------------------------------- */
|
|
1558
|
-
/* Event logs */
|
|
1559
|
-
/* -------------------------------------------------------------------------- */
|
|
1560
|
-
/**
|
|
1561
|
-
* Returns event logs from subgraph.
|
|
1562
|
-
* @param queryVars - Optional query variables to skip, order or filter.
|
|
1563
|
-
* @returns Event log entities from subgraph.
|
|
1564
|
-
*/
|
|
1565
|
-
getEventLogs(queryVars) {
|
|
1566
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1567
|
-
return eventLogs.subgraph.getEventLogs(this._subgraphUrl, queryVars);
|
|
1568
|
-
});
|
|
1569
|
-
}
|
|
1570
|
-
/* -------------------------------------------------------------------------- */
|
|
1571
|
-
/* Groups */
|
|
1572
|
-
/* -------------------------------------------------------------------------- */
|
|
1573
|
-
/**
|
|
1574
|
-
* Creates a group of contract addresses
|
|
1575
|
-
* @param groupToCreate - group with the contract condition
|
|
1576
|
-
* @param overrides - Optional overrides.
|
|
1577
|
-
* @returns Transaction response.
|
|
1578
|
-
*/
|
|
1579
|
-
createGroup(groupToCreate, overrides = {}) {
|
|
1580
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1581
|
-
return groups.handler.createGroup({
|
|
1582
|
-
groupToCreate,
|
|
1583
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond,
|
|
1584
|
-
web3Lib: this._web3Lib
|
|
1585
|
-
});
|
|
1586
|
-
});
|
|
1587
|
-
}
|
|
1588
|
-
/**
|
|
1589
|
-
* Creates an offer with a specific conditions
|
|
1590
|
-
* @param offerToCreate - Offer arguments.
|
|
1591
|
-
* @param condition - contract condition applied to the offer
|
|
1592
|
-
* @param overrides - Optional overrides.
|
|
1593
|
-
* @returns Transaction response.
|
|
1594
|
-
*/
|
|
1595
|
-
createOfferWithCondition(offerToCreate, condition, overrides = {}) {
|
|
1596
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1597
|
-
return orchestration.handler.createOfferWithCondition({
|
|
1598
|
-
offerToCreate,
|
|
1599
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond,
|
|
1600
|
-
web3Lib: this._web3Lib,
|
|
1601
|
-
metadataStorage: this._metadataStorage,
|
|
1602
|
-
theGraphStorage: this._theGraphStorage,
|
|
1603
|
-
condition
|
|
1604
|
-
});
|
|
1605
|
-
});
|
|
1606
|
-
}
|
|
1607
|
-
/**
|
|
1608
|
-
* Creates a seller account and offer with a specific conditions
|
|
1609
|
-
* This transaction only succeeds if there is no existing seller account for the connected signer.
|
|
1610
|
-
* @param sellerToCreate - Addresses to set in the seller account.
|
|
1611
|
-
* @param offerToCreate - Offer arguments.
|
|
1612
|
-
* @param condition - contract condition applied to the offer
|
|
1613
|
-
* @param overrides - Optional overrides.
|
|
1614
|
-
* @returns Transaction response.
|
|
1615
|
-
*/
|
|
1616
|
-
createSellerAndOfferWithCondition(sellerToCreate, offerToCreate, condition, overrides = {}) {
|
|
1617
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1618
|
-
return orchestration.handler.createSellerAndOfferWithCondition({
|
|
1619
|
-
sellerToCreate,
|
|
1620
|
-
offerToCreate,
|
|
1621
|
-
contractAddress: overrides.contractAddress || this._protocolDiamond,
|
|
1622
|
-
web3Lib: this._web3Lib,
|
|
1623
|
-
metadataStorage: this._metadataStorage,
|
|
1624
|
-
theGraphStorage: this._theGraphStorage,
|
|
1625
|
-
condition
|
|
1626
|
-
});
|
|
1627
|
-
});
|
|
1628
|
-
}
|
|
1629
63
|
}
|
|
1630
64
|
exports.CoreSDK = CoreSDK;
|
|
65
|
+
(0, base_core_sdk_1.applyMixins)(CoreSDK, [
|
|
66
|
+
mixin_6.MetadataMixin,
|
|
67
|
+
mixin_7.AccountsMixin,
|
|
68
|
+
mixin_8.OfferMixin,
|
|
69
|
+
mixin_9.FundsMixin,
|
|
70
|
+
mixin_10.ExchangesMixin,
|
|
71
|
+
mixin_5.DisputesMixin,
|
|
72
|
+
mixin_4.MetaTxMixin,
|
|
73
|
+
mixin_3.NativeMetaTxMixin,
|
|
74
|
+
mixin_2.GroupsMixin,
|
|
75
|
+
mixin_1.OrchestrationMixin,
|
|
76
|
+
mixin_11.EventLogsMixin
|
|
77
|
+
]);
|
|
1631
78
|
//# sourceMappingURL=core-sdk.js.map
|