Skip to content

Commit 6c0b33a

Browse files
add init to specific functions
1 parent 0a64953 commit 6c0b33a

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

packages/sdk/src/lib/dataProtectorCore/IExecDataProtectorCore.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class IExecDataProtectorCore extends IExecDataProtectorModule {
3232
async protectData(
3333
args: ProtectDataParams
3434
): Promise<ProtectedDataWithSecretProps> {
35+
await this.init();
3536
await isValidProvider(this.iexec);
3637
return protectData({
3738
...args,
@@ -44,28 +45,33 @@ class IExecDataProtectorCore extends IExecDataProtectorModule {
4445
}
4546

4647
async grantAccess(args: GrantAccessParams): Promise<GrantedAccess> {
48+
await this.init();
4749
await isValidProvider(this.iexec);
4850
return grantAccess({ ...args, iexec: this.iexec });
4951
}
5052

5153
async revokeOneAccess(args: GrantedAccess): Promise<RevokedAccess> {
54+
await this.init();
5255
await isValidProvider(this.iexec);
5356
return revokeOneAccess({ ...args, iexec: this.iexec });
5457
}
5558

5659
async revokeAllAccess(args: RevokeAllAccessParams): Promise<RevokedAccess[]> {
60+
await this.init();
5761
await isValidProvider(this.iexec);
5862
return revokeAllAccess({ ...args, iexec: this.iexec });
5963
}
6064

6165
async transferOwnership(args: TransferParams): Promise<TransferResponse> {
66+
await this.init();
6267
await isValidProvider(this.iexec);
6368
return transferOwnership({ ...args, iexec: this.iexec });
6469
}
6570

6671
async processProtectedData(
6772
args: ProcessProtectedDataParams
6873
): Promise<ProcessProtectedDataResponse> {
74+
await this.init();
6975
await isValidProvider(this.iexec);
7076
return processProtectedData({
7177
...args,
@@ -74,23 +80,28 @@ class IExecDataProtectorCore extends IExecDataProtectorModule {
7480
}
7581

7682
// ----- READ METHODS -----
77-
getProtectedData(args?: GetProtectedDataParams): Promise<ProtectedData[]> {
83+
async getProtectedData(
84+
args?: GetProtectedDataParams
85+
): Promise<ProtectedData[]> {
86+
await this.init();
7887
return getProtectedData({
7988
...args,
8089
iexec: this.iexec,
8190
graphQLClient: this.graphQLClient,
8291
});
8392
}
8493

85-
getGrantedAccess(
94+
async getGrantedAccess(
8695
args: GetGrantedAccessParams
8796
): Promise<GrantedAccessResponse> {
97+
await this.init();
8898
return getGrantedAccess({ ...args, iexec: this.iexec });
8999
}
90100

91101
async getResultFromCompletedTask(
92102
args: GetResultFromCompletedTaskParams
93103
): Promise<GetResultFromCompletedTaskResponse> {
104+
await this.init();
94105
await isValidProvider(this.iexec);
95106
return getResultFromCompletedTask({
96107
...args,

packages/sdk/src/lib/dataProtectorSharing/IExecDataProtectorSharing.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
6969
// -------------------- Collection --------------------
7070

7171
async createCollection(): Promise<CreateCollectionResponse> {
72+
await this.init();
7273
await isValidProvider(this.iexec);
7374
return createCollection({
7475
iexec: this.iexec,
@@ -79,6 +80,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
7980
async removeCollection(
8081
args: RemoveCollectionParams
8182
): Promise<SuccessWithTransactionHash> {
83+
await this.init();
8284
await isValidProvider(this.iexec);
8385
return removeCollection({
8486
...args,
@@ -90,6 +92,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
9092
async addToCollection(
9193
args: AddToCollectionParams
9294
): Promise<SuccessWithTransactionHash> {
95+
await this.init();
9396
await isValidProvider(this.iexec);
9497
return addToCollection({
9598
...args,
@@ -101,6 +104,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
101104
async removeProtectedDataFromCollection(
102105
args: RemoveFromCollectionParams
103106
): Promise<SuccessWithTransactionHash> {
107+
await this.init();
104108
await isValidProvider(this.iexec);
105109
return removeProtectedDataFromCollection({
106110
...args,
@@ -114,6 +118,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
114118
async setProtectedDataToRenting(
115119
args: SetProtectedDataToRentingParams
116120
): Promise<SuccessWithTransactionHash> {
121+
await this.init();
117122
await isValidProvider(this.iexec);
118123
return setProtectedDataToRenting({
119124
...args,
@@ -126,6 +131,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
126131
async setProtectedDataRentingParams(
127132
args: SetProtectedDataRentingParams
128133
): Promise<SuccessWithTransactionHash> {
134+
await this.init();
129135
await isValidProvider(this.iexec);
130136
return setProtectedDataToRenting({
131137
...args,
@@ -137,6 +143,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
137143
async rentProtectedData(
138144
args: RentProtectedDataParams
139145
): Promise<SuccessWithTransactionHash> {
146+
await this.init();
140147
await isValidProvider(this.iexec);
141148
return rentProtectedData({
142149
...args,
@@ -148,6 +155,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
148155
async removeProtectedDataFromRenting(
149156
args: RemoveProtectedDataFromRentingParams
150157
): Promise<SuccessWithTransactionHash> {
158+
await this.init();
151159
await isValidProvider(this.iexec);
152160
return removeProtectedDataFromRenting({
153161
...args,
@@ -161,6 +169,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
161169
async setProtectedDataForSale(
162170
args: SetProtectedDataForSaleParams
163171
): Promise<SuccessWithTransactionHash> {
172+
await this.init();
164173
await isValidProvider(this.iexec);
165174
return setProtectedDataForSale({
166175
...args,
@@ -172,6 +181,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
172181
async buyProtectedData(
173182
args: BuyProtectedDataParams
174183
): Promise<SuccessWithTransactionHash> {
184+
await this.init();
175185
await isValidProvider(this.iexec);
176186
return buyProtectedData({
177187
...args,
@@ -183,6 +193,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
183193
async removeProtectedDataForSale(
184194
args: RemoveProtectedDataForSaleParams
185195
): Promise<SuccessWithTransactionHash> {
196+
await this.init();
186197
await isValidProvider(this.iexec);
187198
return removeProtectedDataForSale({
188199
...args,
@@ -196,6 +207,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
196207
async setSubscriptionParams(
197208
args: SetSubscriptionParams
198209
): Promise<SuccessWithTransactionHash> {
210+
await this.init();
199211
await isValidProvider(this.iexec);
200212
return setSubscriptionParams({
201213
...args,
@@ -207,6 +219,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
207219
async setProtectedDataToSubscription(
208220
args: SetProtectedDataToSubscriptionParams
209221
): Promise<SuccessWithTransactionHash> {
222+
await this.init();
210223
await isValidProvider(this.iexec);
211224
return setProtectedDataToSubscription({
212225
...args,
@@ -218,6 +231,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
218231
async subscribeToCollection(
219232
args: SubscribeToCollectionParams
220233
): Promise<SuccessWithTransactionHash> {
234+
await this.init();
221235
await isValidProvider(this.iexec);
222236
return subscribeToCollection({
223237
...args,
@@ -229,6 +243,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
229243
async removeProtectedDataFromSubscription(
230244
args: RemoveProtectedDataFromSubscriptionParams
231245
): Promise<SuccessWithTransactionHash> {
246+
await this.init();
232247
await isValidProvider(this.iexec);
233248
return removeProtectedDataFromSubscription({
234249
...args,
@@ -243,6 +258,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
243258
async consumeProtectedData(
244259
args: ConsumeProtectedDataParams
245260
): Promise<ConsumeProtectedDataResponse> {
261+
await this.init();
246262
await isValidProvider(this.iexec);
247263
return consumeProtectedData({
248264
...args,
@@ -254,6 +270,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
254270
// -------------------- Apps whitelist --------------------
255271

256272
async createAddOnlyAppWhitelist(): Promise<CreateAppWhitelistResponse> {
273+
await this.init();
257274
await isValidProvider(this.iexec);
258275
return createAddOnlyAppWhitelist({
259276
iexec: this.iexec,
@@ -264,6 +281,7 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
264281
async addAppToAddOnlyAppWhitelist(
265282
args: AddAppToAppWhitelistParams
266283
): Promise<SuccessWithTransactionHash> {
284+
await this.init();
267285
await isValidProvider(this.iexec);
268286
return addAppToAddOnlyAppWhitelist({
269287
...args,
@@ -276,62 +294,69 @@ class IExecDataProtectorSharing extends IExecDataProtectorModule {
276294
* Read-only functions *
277295
******************************************************************/
278296

279-
getProtectedDataInCollections(
297+
async getProtectedDataInCollections(
280298
args?: GetProtectedDataInCollectionsParams
281299
): Promise<GetProtectedDataInCollectionsResponse> {
300+
await this.init();
282301
return getProtectedDataInCollections({
283302
...args,
284303
graphQLClient: this.graphQLClient,
285304
});
286305
}
287306

288-
getProtectedDataPricingParams(
307+
async getProtectedDataPricingParams(
289308
args: GetProtectedDataPricingParams
290309
): Promise<GetProtectedDataPricingParamsResponse> {
310+
await this.init();
291311
return getProtectedDataPricingParams({
292312
...args,
293313
graphQLClient: this.graphQLClient,
294314
});
295315
}
296316

297-
getCollectionOwners(
317+
async getCollectionOwners(
298318
args?: GetCollectionOwnersParams
299319
): Promise<GetCollectionOwnersResponse> {
320+
await this.init();
300321
return getCollectionOwners({
301322
...args,
302323
iexec: this.iexec,
303324
graphQLClient: this.graphQLClient,
304325
});
305326
}
306327

307-
getCollectionsByOwner(
328+
async getCollectionsByOwner(
308329
args: GetCollectionsByOwnerParams
309330
): Promise<GetCollectionsByOwnerResponse> {
331+
await this.init();
310332
return getCollectionsByOwner({
311333
...args,
312334
graphQLClient: this.graphQLClient,
313335
});
314336
}
315337

316-
getCollectionSubscriptions(
338+
async getCollectionSubscriptions(
317339
args?: GetCollectionSubscriptionsParams
318340
): Promise<GetCollectionSubscriptionsResponse> {
341+
await this.init();
319342
return getCollectionSubscriptions({
320343
...args,
321344
graphQLClient: this.graphQLClient,
322345
});
323346
}
324347

325-
getRentals(args?: GetRentalsParams): Promise<GetRentalsResponse> {
348+
async getRentals(args?: GetRentalsParams): Promise<GetRentalsResponse> {
349+
await this.init();
326350
return getRentals({
327351
...args,
328352
graphQLClient: this.graphQLClient,
329353
});
330354
}
331355

332-
getUserAddOnlyAppWhitelist(
356+
async getUserAddOnlyAppWhitelist(
333357
args?: GetUserAppWhitelistParams
334358
): Promise<GetUserAppWhitelistResponse> {
359+
await this.init();
335360
return getUserAddOnlyAppWhitelist({
336361
...args,
337362
iexec: this.iexec,

0 commit comments

Comments
 (0)