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