@eluvio/elv-client-js 4.0.62 → 4.0.63
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/ElvClient-min.js +10 -10
- package/dist/ElvClient-node-min.js +10 -10
- package/dist/ElvFrameClient-min.js +9 -9
- package/dist/ElvPermissionsClient-min.js +10 -10
- package/dist/ElvWalletClient-min.js +10 -11
- package/dist/ElvWalletClient-node-min.js +9 -9
- package/dist/src/AuthorizationClient.js +2 -2
- package/dist/src/Crypto.js +2 -2
- package/dist/src/ElvClient.js +24 -28
- package/dist/src/EthClient.js +2 -2
- package/dist/src/FrameClient.js +2 -2
- package/dist/src/PermissionsClient.js +2 -2
- package/dist/src/Utils.js +42 -25
- package/dist/src/Validation.js +55 -1
- package/dist/src/client/ABRPublishing.js +2 -2
- package/dist/src/client/AccessGroups.js +262 -43
- package/dist/src/client/ContentAccess.js +2 -2
- package/dist/src/client/ContentManagement.js +3 -3
- package/dist/src/client/Contracts.js +2 -2
- package/dist/src/client/Files.js +2 -2
- package/dist/src/client/LiveConf.js +1 -8
- package/dist/src/client/NFT.js +2 -2
- package/dist/src/walletClient/ClientMethods.js +2 -2
- package/dist/src/walletClient/Profile.js +2 -2
- package/dist/src/walletClient/Utils.js +2 -2
- package/dist/src/walletClient/index.js +40 -18
- package/package.json +1 -1
- package/src/Utils.js +5 -0
- package/src/Validation.js +20 -0
- package/src/client/AccessGroups.js +201 -43
|
@@ -2,8 +2,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
|
2
2
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
3
3
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
4
4
|
var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
var Utils = require("../Utils");
|
|
8
8
|
var RarityToPercentage = function RarityToPercentage(rarity) {
|
|
9
9
|
if (!rarity) {
|
|
@@ -5,8 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
7
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
var _require = require("../ElvClient"),
|
|
11
11
|
ElvClient = _require.ElvClient;
|
|
12
12
|
var Configuration = require("./Configuration");
|
|
@@ -1155,11 +1155,11 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1155
1155
|
});
|
|
1156
1156
|
case 3:
|
|
1157
1157
|
marketplaceInfo = _context17.sent;
|
|
1158
|
-
if (!(this.previewMarketplaceId && this.previewMarketplaceId
|
|
1158
|
+
if (!(this.previewMarketplaceId && Utils.EqualHash(this.previewMarketplaceId, marketplaceInfo.marketplaceId))) {
|
|
1159
1159
|
_context17.next = 6;
|
|
1160
1160
|
break;
|
|
1161
1161
|
}
|
|
1162
|
-
return _context17.abrupt("return", this.
|
|
1162
|
+
return _context17.abrupt("return", this.previewMarketplaceHash);
|
|
1163
1163
|
case 6:
|
|
1164
1164
|
_context17.next = 8;
|
|
1165
1165
|
return this.client.ContentObjectMetadata({
|
|
@@ -1206,15 +1206,36 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1206
1206
|
delete this.cachedMarketplaces[marketplaceId];
|
|
1207
1207
|
}
|
|
1208
1208
|
if (this.cachedMarketplaces[marketplaceId]) {
|
|
1209
|
-
_context19.next =
|
|
1209
|
+
_context19.next = 34;
|
|
1210
1210
|
break;
|
|
1211
1211
|
}
|
|
1212
|
-
|
|
1212
|
+
if (!(this.previewMarketplaceId && Utils.EqualHash(marketplaceId, this.previewMarketplaceId))) {
|
|
1213
|
+
_context19.next = 13;
|
|
1214
|
+
break;
|
|
1215
|
+
}
|
|
1216
|
+
_context19.next = 10;
|
|
1217
|
+
return this.client.ContentObjectMetadata({
|
|
1218
|
+
versionHash: this.previewMarketplaceHash,
|
|
1219
|
+
metadataSubtree: "/public/asset_metadata/info",
|
|
1220
|
+
localizationSubtree: this.localization ? UrlJoin("public", "asset_metadata", "localizations", this.localization, "info") : undefined,
|
|
1221
|
+
linkDepthLimit: 1,
|
|
1222
|
+
resolveLinks: true,
|
|
1223
|
+
resolveIgnoreErrors: true,
|
|
1224
|
+
resolveIncludeSource: true,
|
|
1225
|
+
produceLinkUrls: true,
|
|
1226
|
+
authorizationToken: this.publicStaticToken
|
|
1227
|
+
});
|
|
1228
|
+
case 10:
|
|
1229
|
+
marketplace = _context19.sent;
|
|
1230
|
+
_context19.next = 16;
|
|
1231
|
+
break;
|
|
1232
|
+
case 13:
|
|
1233
|
+
_context19.next = 15;
|
|
1213
1234
|
return this.client.ContentObjectMetadata({
|
|
1214
1235
|
libraryId: this.mainSiteLibraryId,
|
|
1215
1236
|
objectId: this.mainSiteId,
|
|
1216
1237
|
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug, "info"),
|
|
1217
|
-
localizationSubtree: this.localization ? UrlJoin("public", "asset_metadata", "localizations", this.localization, "info") :
|
|
1238
|
+
localizationSubtree: this.localization ? UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug, "localizations", this.localization, "info") : undefined,
|
|
1218
1239
|
linkDepthLimit: 1,
|
|
1219
1240
|
resolveLinks: true,
|
|
1220
1241
|
resolveIgnoreErrors: true,
|
|
@@ -1222,13 +1243,14 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1222
1243
|
produceLinkUrls: true,
|
|
1223
1244
|
authorizationToken: this.publicStaticToken
|
|
1224
1245
|
});
|
|
1225
|
-
case
|
|
1246
|
+
case 15:
|
|
1226
1247
|
marketplace = _context19.sent;
|
|
1248
|
+
case 16:
|
|
1227
1249
|
if (!marketplace.branding.use_tenant_styling) {
|
|
1228
|
-
_context19.next =
|
|
1250
|
+
_context19.next = 23;
|
|
1229
1251
|
break;
|
|
1230
1252
|
}
|
|
1231
|
-
_context19.next =
|
|
1253
|
+
_context19.next = 19;
|
|
1232
1254
|
return this.client.ContentObjectMetadata({
|
|
1233
1255
|
libraryId: this.mainSiteLibraryId,
|
|
1234
1256
|
objectId: this.mainSiteId,
|
|
@@ -1236,17 +1258,17 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1236
1258
|
authorizationToken: this.publicStaticToken,
|
|
1237
1259
|
produceLinkUrls: true
|
|
1238
1260
|
});
|
|
1239
|
-
case
|
|
1261
|
+
case 19:
|
|
1240
1262
|
_context19.t0 = _context19.sent;
|
|
1241
1263
|
if (_context19.t0) {
|
|
1242
|
-
_context19.next =
|
|
1264
|
+
_context19.next = 22;
|
|
1243
1265
|
break;
|
|
1244
1266
|
}
|
|
1245
1267
|
_context19.t0 = {};
|
|
1246
|
-
case
|
|
1268
|
+
case 22:
|
|
1247
1269
|
marketplace.tenantBranding = _context19.t0;
|
|
1248
|
-
case
|
|
1249
|
-
_context19.next =
|
|
1270
|
+
case 23:
|
|
1271
|
+
_context19.next = 25;
|
|
1250
1272
|
return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
|
|
1251
1273
|
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(item, index) {
|
|
1252
1274
|
var authorizationToken;
|
|
@@ -1296,7 +1318,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1296
1318
|
return _ref18.apply(this, arguments);
|
|
1297
1319
|
};
|
|
1298
1320
|
}()));
|
|
1299
|
-
case
|
|
1321
|
+
case 25:
|
|
1300
1322
|
marketplace.items = _context19.sent;
|
|
1301
1323
|
marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
|
|
1302
1324
|
return _objectSpread(_objectSpread({}, collection), {}, {
|
|
@@ -1332,9 +1354,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1332
1354
|
} catch (error) {}
|
|
1333
1355
|
});
|
|
1334
1356
|
this.cachedMarketplaces[marketplaceId] = marketplace;
|
|
1335
|
-
case
|
|
1357
|
+
case 34:
|
|
1336
1358
|
return _context19.abrupt("return", this.cachedMarketplaces[marketplaceId]);
|
|
1337
|
-
case
|
|
1359
|
+
case 35:
|
|
1338
1360
|
case "end":
|
|
1339
1361
|
return _context19.stop();
|
|
1340
1362
|
}
|
package/package.json
CHANGED
package/src/Utils.js
CHANGED
|
@@ -444,6 +444,11 @@ const Utils = {
|
|
|
444
444
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
445
445
|
},
|
|
446
446
|
|
|
447
|
+
FromHex: str => {
|
|
448
|
+
str = str.replace(/^0x/, "");
|
|
449
|
+
return Buffer.from(str, "hex").toString();
|
|
450
|
+
},
|
|
451
|
+
|
|
447
452
|
B64: (str, encoding="utf-8") => {
|
|
448
453
|
return Buffer.from(str, encoding).toString("base64");
|
|
449
454
|
},
|
package/src/Validation.js
CHANGED
|
@@ -88,3 +88,23 @@ exports.ValidateDate = (date) => {
|
|
|
88
88
|
|
|
89
89
|
return new Date(date).getTime();
|
|
90
90
|
};
|
|
91
|
+
|
|
92
|
+
exports.ValidateUserWallet = async ({address, client}) => {
|
|
93
|
+
if(!address) {
|
|
94
|
+
throw Error("Address not specified");
|
|
95
|
+
} else if(!client) {
|
|
96
|
+
throw Error("Client not specified");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const walletAddress = await client.userProfileClient.UserWalletAddress({address});
|
|
100
|
+
|
|
101
|
+
if(!walletAddress) {
|
|
102
|
+
throw Error(`User address has no wallet: ${address}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const balance = await client.GetBalance({address});
|
|
106
|
+
|
|
107
|
+
if(balance < 0.1) {
|
|
108
|
+
throw Error(`User has no funds: ${address}`);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
@@ -15,7 +15,8 @@ const {
|
|
|
15
15
|
ValidatePresence,
|
|
16
16
|
ValidateLibrary,
|
|
17
17
|
ValidateObject,
|
|
18
|
-
ValidateAddress
|
|
18
|
+
ValidateAddress,
|
|
19
|
+
ValidateUserWallet
|
|
19
20
|
} = require("../Validation");
|
|
20
21
|
|
|
21
22
|
|
|
@@ -137,22 +138,39 @@ exports.AccessGroupMembers = async function({contractAddress}) {
|
|
|
137
138
|
|
|
138
139
|
this.Log(`Retrieving members for group ${contractAddress}`);
|
|
139
140
|
|
|
140
|
-
const
|
|
141
|
+
const hasMethod = await this.authClient.ContractHasMethod({
|
|
141
142
|
contractAddress,
|
|
142
|
-
methodName: "
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
143
|
+
methodName: "membersList"
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
if(hasMethod) {
|
|
147
|
+
const length = (await this.CallContractMethod({
|
|
148
|
+
contractAddress,
|
|
149
|
+
methodName: "membersNum"
|
|
150
|
+
})).toNumber();
|
|
151
|
+
|
|
152
|
+
return await Promise.all(
|
|
153
|
+
[...Array(length)].map(async (_, i) =>
|
|
154
|
+
this.utils.FormatAddress(
|
|
155
|
+
await this.CallContractMethod({
|
|
156
|
+
contractAddress,
|
|
157
|
+
methodName: "membersList",
|
|
158
|
+
methodArgs: [i]
|
|
159
|
+
})
|
|
160
|
+
)
|
|
153
161
|
)
|
|
154
|
-
)
|
|
155
|
-
|
|
162
|
+
);
|
|
163
|
+
} else {
|
|
164
|
+
const response = this.utils.FromHex(
|
|
165
|
+
await this.CallContractMethod({
|
|
166
|
+
contractAddress,
|
|
167
|
+
methodName: "getMeta",
|
|
168
|
+
methodArgs: ["members"]
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
return response && JSON.parse(response) ? JSON.parse(response) : [];
|
|
173
|
+
}
|
|
156
174
|
};
|
|
157
175
|
|
|
158
176
|
/**
|
|
@@ -170,22 +188,39 @@ exports.AccessGroupManagers = async function({contractAddress}) {
|
|
|
170
188
|
|
|
171
189
|
this.Log(`Retrieving managers for group ${contractAddress}`);
|
|
172
190
|
|
|
173
|
-
const
|
|
191
|
+
const hasMethod = await this.authClient.ContractHasMethod({
|
|
174
192
|
contractAddress,
|
|
175
|
-
methodName: "
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
methodName: "managersList"
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
if(hasMethod) {
|
|
197
|
+
const length = (await this.CallContractMethod({
|
|
198
|
+
contractAddress,
|
|
199
|
+
methodName: "managersNum"
|
|
200
|
+
})).toNumber();
|
|
201
|
+
|
|
202
|
+
return await Promise.all(
|
|
203
|
+
[...Array(length)].map(async (_, i) =>
|
|
204
|
+
this.utils.FormatAddress(
|
|
205
|
+
await this.CallContractMethod({
|
|
206
|
+
contractAddress,
|
|
207
|
+
methodName: "managersList",
|
|
208
|
+
methodArgs: [i]
|
|
209
|
+
})
|
|
210
|
+
)
|
|
186
211
|
)
|
|
187
|
-
)
|
|
188
|
-
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
const response = this.utils.FromHex(
|
|
215
|
+
await this.CallContractMethod({
|
|
216
|
+
contractAddress,
|
|
217
|
+
methodName: "getMeta",
|
|
218
|
+
methodArgs: ["managers"]
|
|
219
|
+
})
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
return response && JSON.parse(response) ? JSON.parse(response) : [];
|
|
223
|
+
}
|
|
189
224
|
};
|
|
190
225
|
|
|
191
226
|
/**
|
|
@@ -202,12 +237,13 @@ exports.AccessGroupManagers = async function({contractAddress}) {
|
|
|
202
237
|
*
|
|
203
238
|
* @returns {Promise<string>} - Contract address of created access group
|
|
204
239
|
*/
|
|
205
|
-
exports.CreateAccessGroup = async function({name, description, metadata={}}={}) {
|
|
240
|
+
exports.CreateAccessGroup = async function({name, description, metadata={}, visibility=1}={}) {
|
|
206
241
|
this.Log(`Creating access group: ${name || ""} ${description || ""}`);
|
|
207
242
|
let { contractAddress } = await this.authClient.CreateAccessGroup();
|
|
208
243
|
contractAddress = this.utils.FormatAddress(contractAddress);
|
|
209
244
|
|
|
210
245
|
const objectId = this.utils.AddressToObjectId(contractAddress);
|
|
246
|
+
const tenantId = await this.userProfileClient.TenantId();
|
|
211
247
|
|
|
212
248
|
this.Log(`Access group: ${contractAddress} ${objectId}`);
|
|
213
249
|
|
|
@@ -216,19 +252,47 @@ exports.CreateAccessGroup = async function({name, description, metadata={}}={})
|
|
|
216
252
|
objectId: objectId
|
|
217
253
|
});
|
|
218
254
|
|
|
255
|
+
const groupMetadata = {
|
|
256
|
+
public: {
|
|
257
|
+
name,
|
|
258
|
+
description
|
|
259
|
+
},
|
|
260
|
+
name,
|
|
261
|
+
description,
|
|
262
|
+
...metadata
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
if(tenantId) {
|
|
266
|
+
let tenantAdminGroupAddress = this.utils.HashToAddress(tenantId);
|
|
267
|
+
|
|
268
|
+
await this.AddContentObjectGroupPermission({
|
|
269
|
+
objectId,
|
|
270
|
+
groupAddress: tenantAdminGroupAddress,
|
|
271
|
+
permission: "manage"
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
await this.ReplaceContractMetadata({
|
|
275
|
+
contractAddress,
|
|
276
|
+
metadataKey: "_tenantId",
|
|
277
|
+
metadata: tenantId
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
groupMetadata["tenantId"] = tenantId;
|
|
281
|
+
} else {
|
|
282
|
+
console.warn("No tenant ID associated with current tenant.");
|
|
283
|
+
}
|
|
284
|
+
|
|
219
285
|
await this.ReplaceMetadata({
|
|
220
286
|
libraryId: this.contentSpaceLibraryId,
|
|
221
287
|
objectId,
|
|
222
288
|
writeToken: editResponse.write_token,
|
|
223
|
-
metadata:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
...metadata
|
|
231
|
-
}
|
|
289
|
+
metadata: groupMetadata
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
await this.CallContractMethodAndWait({
|
|
293
|
+
contractAddress,
|
|
294
|
+
methodName: "setVisibility",
|
|
295
|
+
methodArgs: [visibility],
|
|
232
296
|
});
|
|
233
297
|
|
|
234
298
|
await this.FinalizeContentObject({
|
|
@@ -332,13 +396,39 @@ exports.AccessGroupMembershipMethod = async function({
|
|
|
332
396
|
exports.AddAccessGroupMember = async function({contractAddress, memberAddress}) {
|
|
333
397
|
contractAddress = ValidateAddress(contractAddress);
|
|
334
398
|
memberAddress = ValidateAddress(memberAddress);
|
|
399
|
+
await ValidateUserWallet({address: memberAddress, client: this});
|
|
335
400
|
|
|
336
|
-
|
|
401
|
+
const hasMethod = await this.authClient.ContractHasMethod({
|
|
402
|
+
contractAddress,
|
|
403
|
+
methodName: "membersList"
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
const response = await this.AccessGroupMembershipMethod({
|
|
337
407
|
contractAddress,
|
|
338
408
|
memberAddress,
|
|
339
409
|
methodName: "grantAccess",
|
|
340
410
|
eventName: "MemberAdded"
|
|
341
411
|
});
|
|
412
|
+
|
|
413
|
+
if(!hasMethod) {
|
|
414
|
+
let memberList = await this.AccessGroupMembers({
|
|
415
|
+
contractAddress
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
memberList.push(memberAddress);
|
|
419
|
+
|
|
420
|
+
memberList = memberList.filter((value, index, self) => {
|
|
421
|
+
return self.indexOf(value) === index;
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
await this.ReplaceContractMetadata({
|
|
425
|
+
contractAddress,
|
|
426
|
+
metadataKey: "members",
|
|
427
|
+
metadata: memberList
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return response;
|
|
342
432
|
};
|
|
343
433
|
|
|
344
434
|
/**
|
|
@@ -357,12 +447,33 @@ exports.RemoveAccessGroupMember = async function({contractAddress, memberAddress
|
|
|
357
447
|
contractAddress = ValidateAddress(contractAddress);
|
|
358
448
|
memberAddress = ValidateAddress(memberAddress);
|
|
359
449
|
|
|
360
|
-
|
|
450
|
+
const hasMethod = await this.authClient.ContractHasMethod({
|
|
451
|
+
contractAddress,
|
|
452
|
+
methodName: "membersList"
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
const response = await this.AccessGroupMembershipMethod({
|
|
361
456
|
contractAddress,
|
|
362
457
|
memberAddress,
|
|
363
458
|
methodName: "revokeAccess",
|
|
364
459
|
eventName: "MemberRevoked"
|
|
365
460
|
});
|
|
461
|
+
|
|
462
|
+
if(!hasMethod) {
|
|
463
|
+
let memberList = await this.AccessGroupMembers({
|
|
464
|
+
contractAddress
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
memberList = memberList.filter(element => element !== memberAddress);
|
|
468
|
+
|
|
469
|
+
return await this.ReplaceContractMetadata({
|
|
470
|
+
contractAddress,
|
|
471
|
+
metadataKey: "members",
|
|
472
|
+
metadata: memberList
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
return response;
|
|
366
477
|
};
|
|
367
478
|
|
|
368
479
|
/**
|
|
@@ -380,13 +491,39 @@ exports.RemoveAccessGroupMember = async function({contractAddress, memberAddress
|
|
|
380
491
|
exports.AddAccessGroupManager = async function({contractAddress, memberAddress}) {
|
|
381
492
|
contractAddress = ValidateAddress(contractAddress);
|
|
382
493
|
memberAddress = ValidateAddress(memberAddress);
|
|
494
|
+
await ValidateUserWallet({address: memberAddress, client: this});
|
|
383
495
|
|
|
384
|
-
|
|
496
|
+
const hasMethod = await this.authClient.ContractHasMethod({
|
|
497
|
+
contractAddress,
|
|
498
|
+
methodName: "membersList"
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
const response = await this.AccessGroupMembershipMethod({
|
|
385
502
|
contractAddress,
|
|
386
503
|
memberAddress,
|
|
387
504
|
methodName: "grantManagerAccess",
|
|
388
505
|
eventName: "ManagerAccessGranted"
|
|
389
506
|
});
|
|
507
|
+
|
|
508
|
+
if(!hasMethod) {
|
|
509
|
+
let managerList = await this.AccessGroupManagers({
|
|
510
|
+
contractAddress
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
managerList.push(memberAddress);
|
|
514
|
+
|
|
515
|
+
managerList = managerList.filter((value, index, self) => {
|
|
516
|
+
return self.indexOf(value) === index;
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
await this.ReplaceContractMetadata({
|
|
520
|
+
contractAddress,
|
|
521
|
+
metadataKey: "managers",
|
|
522
|
+
metadata: managerList
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return response;
|
|
390
527
|
};
|
|
391
528
|
|
|
392
529
|
/**
|
|
@@ -405,12 +542,33 @@ exports.RemoveAccessGroupManager = async function({contractAddress, memberAddres
|
|
|
405
542
|
contractAddress = ValidateAddress(contractAddress);
|
|
406
543
|
memberAddress = ValidateAddress(memberAddress);
|
|
407
544
|
|
|
408
|
-
|
|
545
|
+
const hasMethod = await this.authClient.ContractHasMethod({
|
|
546
|
+
contractAddress,
|
|
547
|
+
methodName: "managersList"
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
const response = await this.AccessGroupMembershipMethod({
|
|
409
551
|
contractAddress,
|
|
410
552
|
memberAddress,
|
|
411
553
|
methodName: "revokeManagerAccess",
|
|
412
554
|
eventName: "ManagerAccessRevoked"
|
|
413
555
|
});
|
|
556
|
+
|
|
557
|
+
if(!hasMethod) {
|
|
558
|
+
let managerList = await this.AccessGroupManagers({
|
|
559
|
+
contractAddress
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
managerList = managerList.filter(element => element !== memberAddress);
|
|
563
|
+
|
|
564
|
+
return await this.ReplaceContractMetadata({
|
|
565
|
+
contractAddress,
|
|
566
|
+
metadataKey: "managers",
|
|
567
|
+
metadata: managerList
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return response;
|
|
414
572
|
};
|
|
415
573
|
|
|
416
574
|
/**
|