@eluvio/elv-client-js 4.0.17 → 4.0.18

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.
@@ -2228,8 +2228,22 @@ exports.DropStatus = /*#__PURE__*/function () {
2228
2228
  }();
2229
2229
 
2230
2230
  /* OFFERS */
2231
- // TODO: Document
2232
2231
 
2232
+ /**
2233
+ * Retrieve offers for the specified parameters
2234
+ *
2235
+ * @methodGroup Offers
2236
+ * @namedParams
2237
+ * @param {string=} contractAddress - The address of an NFT contract
2238
+ * @param {string=} tokenId - The token ID of an NFT
2239
+ * @param {string=} buyerAddress - The address of the offerrer
2240
+ * @param {string=} sellerAddress - The address of the offerree
2241
+ * @param {Array<String>=} statuses - Status to filter results by. Allowed values: "ACTIVE", "ACCEPTED", "CANCELLED", "DECLINED", "INVALID"
2242
+ * @param {number} start=0 - The index to start from
2243
+ * @param {number=} limit=10 - The maximum number of results to return
2244
+ *
2245
+ * @returns {Promise<Array<Object>>} - Offers matching the specified filters
2246
+ */
2233
2247
  exports.MarketplaceOffers = /*#__PURE__*/function () {
2234
2248
  var _ref82 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41(_ref81) {
2235
2249
  var contractAddress, tokenId, buyerAddress, sellerAddress, statuses, _ref81$start, start, _ref81$limit, limit, path, queryParams, offers;
@@ -2281,6 +2295,22 @@ exports.MarketplaceOffers = /*#__PURE__*/function () {
2281
2295
  return _ref82.apply(this, arguments);
2282
2296
  };
2283
2297
  }();
2298
+
2299
+ /**
2300
+ * <b><i>Requires login</i></b>
2301
+ *
2302
+ * Create or update an offer on the specified NFT
2303
+ *
2304
+ * @methodGroup Offers
2305
+ * @namedParams
2306
+ * @param {string} contractAddress - The contract address of the NFT
2307
+ * @param {string} tokenId - The token ID of the NFT
2308
+ * @param {string=} offerId - IF modifying an existing offer, the ID of the offer
2309
+ * @param {number} price - The amount to offer
2310
+ * @param {number=} expiresAt - The time (in epoch ms) the offer will expire
2311
+ *
2312
+ * @returns {Promise<Object>} - Info about the created/updated offer
2313
+ */
2284
2314
  exports.CreateMarketplaceOffer = /*#__PURE__*/function () {
2285
2315
  var _ref84 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42(_ref83) {
2286
2316
  var contractAddress, tokenId, offerId, price, expiresAt, response;
@@ -2337,6 +2367,16 @@ exports.CreateMarketplaceOffer = /*#__PURE__*/function () {
2337
2367
  return _ref84.apply(this, arguments);
2338
2368
  };
2339
2369
  }();
2370
+
2371
+ /**
2372
+ * <b><i>Requires login</i></b>
2373
+ *
2374
+ * Cancel the specified offer
2375
+ *
2376
+ * @methodGroup Offers
2377
+ * @namedParams
2378
+ * @param {string} offerId - The ID of the offer
2379
+ */
2340
2380
  exports.RemoveMarketplaceOffer = /*#__PURE__*/function () {
2341
2381
  var _ref86 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(_ref85) {
2342
2382
  var offerId;
@@ -2364,6 +2404,16 @@ exports.RemoveMarketplaceOffer = /*#__PURE__*/function () {
2364
2404
  return _ref86.apply(this, arguments);
2365
2405
  };
2366
2406
  }();
2407
+
2408
+ /**
2409
+ * <b><i>Requires login</i></b>
2410
+ *
2411
+ * Accept the specified offer
2412
+ *
2413
+ * @methodGroup Offers
2414
+ * @namedParams
2415
+ * @param {string} offerId - The ID of the offer
2416
+ */
2367
2417
  exports.AcceptMarketplaceOffer = /*#__PURE__*/function () {
2368
2418
  var _ref88 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(_ref87) {
2369
2419
  var offerId;
@@ -2391,6 +2441,16 @@ exports.AcceptMarketplaceOffer = /*#__PURE__*/function () {
2391
2441
  return _ref88.apply(this, arguments);
2392
2442
  };
2393
2443
  }();
2444
+
2445
+ /**
2446
+ * <b><i>Requires login</i></b>
2447
+ *
2448
+ * Reject the specified offer
2449
+ *
2450
+ * @methodGroup Offers
2451
+ * @namedParams
2452
+ * @param {string} offerId - The ID of the offer
2453
+ */
2394
2454
  exports.RejectMarketplaceOffer = /*#__PURE__*/function () {
2395
2455
  var _ref90 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45(_ref89) {
2396
2456
  var offerId;
@@ -2417,4 +2477,127 @@ exports.RejectMarketplaceOffer = /*#__PURE__*/function () {
2417
2477
  return function (_x31) {
2418
2478
  return _ref90.apply(this, arguments);
2419
2479
  };
2480
+ }();
2481
+
2482
+ /* Voting */
2483
+
2484
+ /**
2485
+ * <b><i>Requires login</i></b>
2486
+ *
2487
+ * Retrieve the current status of the specified voting event
2488
+ *
2489
+ * @methodGroup Voting
2490
+ * @namedParams
2491
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
2492
+ * @param {string} votingEventId - The ID of the voting event
2493
+ *
2494
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
2495
+ */
2496
+ exports.VoteStatus = /*#__PURE__*/function () {
2497
+ var _ref92 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46(_ref91) {
2498
+ var tenantId, votingEventId;
2499
+ return _regeneratorRuntime.wrap(function _callee46$(_context46) {
2500
+ while (1) switch (_context46.prev = _context46.next) {
2501
+ case 0:
2502
+ tenantId = _ref91.tenantId, votingEventId = _ref91.votingEventId;
2503
+ _context46.next = 3;
2504
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
2505
+ path: UrlJoin("as", "votes", tenantId, votingEventId),
2506
+ headers: {
2507
+ Authorization: "Bearer ".concat(this.AuthToken())
2508
+ }
2509
+ }));
2510
+ case 3:
2511
+ return _context46.abrupt("return", _context46.sent);
2512
+ case 4:
2513
+ case "end":
2514
+ return _context46.stop();
2515
+ }
2516
+ }, _callee46, this);
2517
+ }));
2518
+ return function (_x32) {
2519
+ return _ref92.apply(this, arguments);
2520
+ };
2521
+ }();
2522
+
2523
+ /**
2524
+ * <b><i>Requires login</i></b>
2525
+ *
2526
+ * Cast a vote for the specified item in the specified voting event
2527
+ *
2528
+ * @methodGroup Voting
2529
+ * @namedParams
2530
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
2531
+ * @param {string} votingEventId - The ID of the voting event
2532
+ * @param {string} sku - The SKU of the item to vote for
2533
+ *
2534
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
2535
+ */
2536
+ exports.CastVote = /*#__PURE__*/function () {
2537
+ var _ref94 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee47(_ref93) {
2538
+ var tenantId, votingEventId, sku;
2539
+ return _regeneratorRuntime.wrap(function _callee47$(_context47) {
2540
+ while (1) switch (_context47.prev = _context47.next) {
2541
+ case 0:
2542
+ tenantId = _ref93.tenantId, votingEventId = _ref93.votingEventId, sku = _ref93.sku;
2543
+ _context47.next = 3;
2544
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
2545
+ path: UrlJoin("as", "votes", tenantId, votingEventId, sku),
2546
+ method: "POST",
2547
+ headers: {
2548
+ Authorization: "Bearer ".concat(this.AuthToken())
2549
+ }
2550
+ }));
2551
+ case 3:
2552
+ return _context47.abrupt("return", _context47.sent);
2553
+ case 4:
2554
+ case "end":
2555
+ return _context47.stop();
2556
+ }
2557
+ }, _callee47, this);
2558
+ }));
2559
+ return function (_x33) {
2560
+ return _ref94.apply(this, arguments);
2561
+ };
2562
+ }();
2563
+
2564
+ /**
2565
+ * <b><i>Requires login</i></b>
2566
+ *
2567
+ * Revoke a previously cast vote for the specified item in the specified voting event
2568
+ *
2569
+ * @methodGroup Voting
2570
+ * @namedParams
2571
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
2572
+ * @param {string} votingEventId - The ID of the voting event
2573
+ * @param {string} sku - The SKU of the item to vote for
2574
+ *
2575
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
2576
+ */
2577
+ exports.RevokeVote = /*#__PURE__*/function () {
2578
+ var _ref96 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee48(_ref95) {
2579
+ var tenantId, votingEventId, sku;
2580
+ return _regeneratorRuntime.wrap(function _callee48$(_context48) {
2581
+ while (1) switch (_context48.prev = _context48.next) {
2582
+ case 0:
2583
+ tenantId = _ref95.tenantId, votingEventId = _ref95.votingEventId, sku = _ref95.sku;
2584
+ _context48.next = 3;
2585
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
2586
+ path: UrlJoin("as", "votes", tenantId, votingEventId, sku),
2587
+ method: "DELETE",
2588
+ headers: {
2589
+ Authorization: "Bearer ".concat(this.AuthToken())
2590
+ }
2591
+ }));
2592
+ case 3:
2593
+ return _context48.abrupt("return", _context48.sent);
2594
+ case 4:
2595
+ case "end":
2596
+ return _context48.stop();
2597
+ }
2598
+ }, _callee48, this);
2599
+ }));
2600
+ return function (_x34) {
2601
+ return _ref96.apply(this, arguments);
2602
+ };
2420
2603
  }();
@@ -2,6 +2,7 @@ var WalletConfiguration = {
2
2
  demo: {
3
3
  configUrl: "https://demov3.net955210.contentfabric.io/config",
4
4
  stateStoreUrls: ["https://appsvc.svc.eluv.io/dv3"],
5
+ badgerAddress: "0x39e9d567137217e8f7dae73bf168db28d242bb31",
5
6
  staging: {
6
7
  siteLibraryId: "ilib36Wi5fJDLXix8ckL7ZfaAJwJXWGD",
7
8
  siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
@@ -12,6 +13,7 @@ var WalletConfiguration = {
12
13
  main: {
13
14
  configUrl: "https://main.net955305.contentfabric.io/config",
14
15
  stateStoreUrls: ["https://appsvc.svc.eluv.io/main"],
16
+ badgerAddress: "0xa042a585bbbac4419ba39c397f35ab749fc470f0",
15
17
  staging: {
16
18
  siteLibraryId: "ilib2GdaYEFxB7HyLPhSDPKMyPLhV8x9",
17
19
  siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
@@ -1,6 +1,9 @@
1
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
1
2
  var _typeof = require("@babel/runtime/helpers/typeof");
2
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
7
  var Utils = require("../Utils");
5
8
  var UrlJoin = require("url-join");
6
9
  var StateStorePath = function StateStorePath(_ref) {
@@ -186,7 +189,7 @@ exports.RemoveProfileMetadata = /*#__PURE__*/function () {
186
189
  }();
187
190
 
188
191
  /**
189
- * Retrieve profile info for the specified user, including address, username and profile image (if set)
192
+ * Retrieve profile info for the specified user, including address, username, profile image (if set) and badges (if any)
190
193
  *
191
194
  * @methodGroup Profile
192
195
  * @param {string=} userAddress - Address of the user
@@ -196,7 +199,7 @@ exports.RemoveProfileMetadata = /*#__PURE__*/function () {
196
199
  */
197
200
  exports.Profile = /*#__PURE__*/function () {
198
201
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref9) {
199
- var userAddress, userName, imageUrl;
202
+ var userAddress, userName, imageUrl, badgeData, badges;
200
203
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
201
204
  while (1) switch (_context4.prev = _context4.next) {
202
205
  case 0:
@@ -239,12 +242,37 @@ exports.Profile = /*#__PURE__*/function () {
239
242
  });
240
243
  case 13:
241
244
  imageUrl = _context4.sent;
245
+ _context4.next = 16;
246
+ return this.ProfileMetadata({
247
+ type: "app",
248
+ mode: "public",
249
+ appId: "elv-badge-srv",
250
+ userAddress: this.badgerAddress,
251
+ key: "badges_".concat(Utils.FormatAddress(userAddress))
252
+ });
253
+ case 16:
254
+ badgeData = _context4.sent;
255
+ badges = [];
256
+ if (badgeData) {
257
+ try {
258
+ badgeData = JSON.parse(badgeData).badges;
259
+ badges = Object.keys(badgeData).map(function (badgeName) {
260
+ return _objectSpread(_objectSpread({}, badgeData[badgeName]), {}, {
261
+ name: badgeName
262
+ });
263
+ });
264
+ } catch (error) {
265
+ this.Log("Failed to load badge info for ".concat(userName || userAddress), true);
266
+ this.Log(error, true);
267
+ }
268
+ }
242
269
  return _context4.abrupt("return", {
243
270
  userAddress: Utils.FormatAddress(userAddress),
244
271
  userName: userName,
245
- imageUrl: imageUrl
272
+ imageUrl: imageUrl,
273
+ badges: badges
246
274
  });
247
- case 15:
275
+ case 20:
248
276
  case "end":
249
277
  return _context4.stop();
250
278
  }
@@ -69,6 +69,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
69
69
  this.stateStoreClient = new HTTPClient({
70
70
  uris: this.stateStoreUrls
71
71
  });
72
+ this.badgerAddress = Configuration[network].badgerAddress;
72
73
 
73
74
  // Caches
74
75
  this.cachedMarketplaces = {};
@@ -1018,7 +1019,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1018
1019
  value: function () {
1019
1020
  var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
1020
1021
  var _this5 = this;
1021
- var marketplaceInfo, marketplaceId, marketplaceHashPromise, marketplace;
1022
+ var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
1022
1023
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1023
1024
  while (1) switch (_context15.prev = _context15.next) {
1024
1025
  case 0:
@@ -1026,17 +1027,20 @@ var ElvWalletClient = /*#__PURE__*/function () {
1026
1027
  marketplaceParams: marketplaceParams
1027
1028
  });
1028
1029
  marketplaceId = marketplaceInfo.marketplaceId;
1029
- marketplaceHashPromise = this.LatestMarketplaceHash({
1030
+ _context15.next = 4;
1031
+ return this.LatestMarketplaceHash({
1030
1032
  marketplaceParams: marketplaceParams
1031
1033
  });
1034
+ case 4:
1035
+ marketplaceHash = _context15.sent;
1032
1036
  if (this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
1033
1037
  delete this.cachedMarketplaces[marketplaceId];
1034
1038
  }
1035
1039
  if (this.cachedMarketplaces[marketplaceId]) {
1036
- _context15.next = 23;
1040
+ _context15.next = 21;
1037
1041
  break;
1038
1042
  }
1039
- _context15.next = 7;
1043
+ _context15.next = 9;
1040
1044
  return this.client.ContentObjectMetadata({
1041
1045
  libraryId: this.mainSiteLibraryId,
1042
1046
  objectId: this.mainSiteId,
@@ -1049,9 +1053,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
1049
1053
  produceLinkUrls: true,
1050
1054
  authorizationToken: this.publicStaticToken
1051
1055
  });
1052
- case 7:
1056
+ case 9:
1053
1057
  marketplace = _context15.sent;
1054
- _context15.next = 10;
1058
+ _context15.next = 12;
1055
1059
  return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
1056
1060
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
1057
1061
  var authorizationToken;
@@ -1101,7 +1105,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1101
1105
  return _ref13.apply(this, arguments);
1102
1106
  };
1103
1107
  }()));
1104
- case 10:
1108
+ case 12:
1105
1109
  marketplace.items = _context15.sent;
1106
1110
  marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
1107
1111
  return _objectSpread(_objectSpread({}, collection), {}, {
@@ -1110,14 +1114,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
1110
1114
  });
1111
1115
  marketplace.retrievedAt = Date.now();
1112
1116
  marketplace.marketplaceId = marketplaceId;
1113
- _context15.next = 16;
1114
- return marketplaceHashPromise;
1115
- case 16:
1116
- marketplace.versionHash = _context15.sent;
1117
- _context15.next = 19;
1118
- return marketplaceHashPromise;
1119
- case 19:
1120
- marketplace.marketplaceHash = _context15.sent;
1117
+ marketplace.versionHash = marketplaceHash;
1118
+ marketplace.marketplaceHash = marketplaceHash;
1121
1119
  if (this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
1122
1120
  marketplace.branding.preview = true;
1123
1121
  }
@@ -1143,9 +1141,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
1143
1141
  } catch (error) {}
1144
1142
  });
1145
1143
  this.cachedMarketplaces[marketplaceId] = marketplace;
1146
- case 23:
1144
+ case 21:
1147
1145
  return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
1148
- case 24:
1146
+ case 22:
1149
1147
  case "end":
1150
1148
  return _context15.stop();
1151
1149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.17",
3
+ "version": "4.0.18",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -1310,8 +1310,22 @@ exports.DropStatus = async function({marketplace, eventId, dropId}) {
1310
1310
 
1311
1311
 
1312
1312
  /* OFFERS */
1313
- // TODO: Document
1314
1313
 
1314
+ /**
1315
+ * Retrieve offers for the specified parameters
1316
+ *
1317
+ * @methodGroup Offers
1318
+ * @namedParams
1319
+ * @param {string=} contractAddress - The address of an NFT contract
1320
+ * @param {string=} tokenId - The token ID of an NFT
1321
+ * @param {string=} buyerAddress - The address of the offerrer
1322
+ * @param {string=} sellerAddress - The address of the offerree
1323
+ * @param {Array<String>=} statuses - Status to filter results by. Allowed values: "ACTIVE", "ACCEPTED", "CANCELLED", "DECLINED", "INVALID"
1324
+ * @param {number} start=0 - The index to start from
1325
+ * @param {number=} limit=10 - The maximum number of results to return
1326
+ *
1327
+ * @returns {Promise<Array<Object>>} - Offers matching the specified filters
1328
+ */
1315
1329
  exports.MarketplaceOffers = async function({contractAddress, tokenId, buyerAddress, sellerAddress, statuses, start=0, limit=10}) {
1316
1330
  let path = UrlJoin("as", "mkt", "offers", "ls");
1317
1331
  if(buyerAddress) {
@@ -1354,6 +1368,21 @@ exports.MarketplaceOffers = async function({contractAddress, tokenId, buyerAddre
1354
1368
  }));
1355
1369
  };
1356
1370
 
1371
+ /**
1372
+ * <b><i>Requires login</i></b>
1373
+ *
1374
+ * Create or update an offer on the specified NFT
1375
+ *
1376
+ * @methodGroup Offers
1377
+ * @namedParams
1378
+ * @param {string} contractAddress - The contract address of the NFT
1379
+ * @param {string} tokenId - The token ID of the NFT
1380
+ * @param {string=} offerId - IF modifying an existing offer, the ID of the offer
1381
+ * @param {number} price - The amount to offer
1382
+ * @param {number=} expiresAt - The time (in epoch ms) the offer will expire
1383
+ *
1384
+ * @returns {Promise<Object>} - Info about the created/updated offer
1385
+ */
1357
1386
  exports.CreateMarketplaceOffer = async function({contractAddress, tokenId, offerId, price, expiresAt}) {
1358
1387
  let response;
1359
1388
  if(offerId) {
@@ -1391,6 +1420,15 @@ exports.CreateMarketplaceOffer = async function({contractAddress, tokenId, offer
1391
1420
  return response.offer_id;
1392
1421
  };
1393
1422
 
1423
+ /**
1424
+ * <b><i>Requires login</i></b>
1425
+ *
1426
+ * Cancel the specified offer
1427
+ *
1428
+ * @methodGroup Offers
1429
+ * @namedParams
1430
+ * @param {string} offerId - The ID of the offer
1431
+ */
1394
1432
  exports.RemoveMarketplaceOffer = async function({offerId}) {
1395
1433
  return await this.client.authClient.MakeAuthServiceRequest({
1396
1434
  path: UrlJoin("as", "wlt", "mkt", "offers", offerId),
@@ -1401,7 +1439,15 @@ exports.RemoveMarketplaceOffer = async function({offerId}) {
1401
1439
  });
1402
1440
  };
1403
1441
 
1404
-
1442
+ /**
1443
+ * <b><i>Requires login</i></b>
1444
+ *
1445
+ * Accept the specified offer
1446
+ *
1447
+ * @methodGroup Offers
1448
+ * @namedParams
1449
+ * @param {string} offerId - The ID of the offer
1450
+ */
1405
1451
  exports.AcceptMarketplaceOffer = async function({offerId}) {
1406
1452
  return await this.client.authClient.MakeAuthServiceRequest({
1407
1453
  path: UrlJoin("as", "wlt", "mkt", "offers", "accept", offerId),
@@ -1412,6 +1458,15 @@ exports.AcceptMarketplaceOffer = async function({offerId}) {
1412
1458
  });
1413
1459
  };
1414
1460
 
1461
+ /**
1462
+ * <b><i>Requires login</i></b>
1463
+ *
1464
+ * Reject the specified offer
1465
+ *
1466
+ * @methodGroup Offers
1467
+ * @namedParams
1468
+ * @param {string} offerId - The ID of the offer
1469
+ */
1415
1470
  exports.RejectMarketplaceOffer = async function({offerId}) {
1416
1471
  return await this.client.authClient.MakeAuthServiceRequest({
1417
1472
  path: UrlJoin("as", "wlt", "mkt", "offers", "decline", offerId),
@@ -1421,3 +1476,79 @@ exports.RejectMarketplaceOffer = async function({offerId}) {
1421
1476
  }
1422
1477
  });
1423
1478
  };
1479
+
1480
+
1481
+ /* Voting */
1482
+
1483
+ /**
1484
+ * <b><i>Requires login</i></b>
1485
+ *
1486
+ * Retrieve the current status of the specified voting event
1487
+ *
1488
+ * @methodGroup Voting
1489
+ * @namedParams
1490
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
1491
+ * @param {string} votingEventId - The ID of the voting event
1492
+ *
1493
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
1494
+ */
1495
+ exports.VoteStatus = async function ({tenantId, votingEventId}) {
1496
+ return await Utils.ResponseToJson(
1497
+ this.client.authClient.MakeAuthServiceRequest({
1498
+ path: UrlJoin("as", "votes", tenantId, votingEventId),
1499
+ headers: {
1500
+ Authorization: `Bearer ${this.AuthToken()}`
1501
+ }
1502
+ })
1503
+ );
1504
+ };
1505
+
1506
+ /**
1507
+ * <b><i>Requires login</i></b>
1508
+ *
1509
+ * Cast a vote for the specified item in the specified voting event
1510
+ *
1511
+ * @methodGroup Voting
1512
+ * @namedParams
1513
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
1514
+ * @param {string} votingEventId - The ID of the voting event
1515
+ * @param {string} sku - The SKU of the item to vote for
1516
+ *
1517
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
1518
+ */
1519
+ exports.CastVote = async function ({tenantId, votingEventId, sku}) {
1520
+ return await Utils.ResponseToJson(
1521
+ this.client.authClient.MakeAuthServiceRequest({
1522
+ path: UrlJoin("as", "votes", tenantId, votingEventId, sku),
1523
+ method: "POST",
1524
+ headers: {
1525
+ Authorization: `Bearer ${this.AuthToken()}`
1526
+ }
1527
+ })
1528
+ );
1529
+ };
1530
+
1531
+ /**
1532
+ * <b><i>Requires login</i></b>
1533
+ *
1534
+ * Revoke a previously cast vote for the specified item in the specified voting event
1535
+ *
1536
+ * @methodGroup Voting
1537
+ * @namedParams
1538
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
1539
+ * @param {string} votingEventId - The ID of the voting event
1540
+ * @param {string} sku - The SKU of the item to vote for
1541
+ *
1542
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
1543
+ */
1544
+ exports.RevokeVote = async function ({tenantId, votingEventId, sku}) {
1545
+ return await Utils.ResponseToJson(
1546
+ this.client.authClient.MakeAuthServiceRequest({
1547
+ path: UrlJoin("as", "votes", tenantId, votingEventId, sku),
1548
+ method: "DELETE",
1549
+ headers: {
1550
+ Authorization: `Bearer ${this.AuthToken()}`
1551
+ }
1552
+ })
1553
+ );
1554
+ };
@@ -2,6 +2,7 @@ let WalletConfiguration = {
2
2
  demo: {
3
3
  configUrl: "https://demov3.net955210.contentfabric.io/config",
4
4
  stateStoreUrls: ["https://appsvc.svc.eluv.io/dv3"],
5
+ badgerAddress: "0x39e9d567137217e8f7dae73bf168db28d242bb31",
5
6
  staging: {
6
7
  siteLibraryId: "ilib36Wi5fJDLXix8ckL7ZfaAJwJXWGD",
7
8
  siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
@@ -12,6 +13,7 @@ let WalletConfiguration = {
12
13
  main: {
13
14
  configUrl: "https://main.net955305.contentfabric.io/config",
14
15
  stateStoreUrls: ["https://appsvc.svc.eluv.io/main"],
16
+ badgerAddress: "0xa042a585bbbac4419ba39c397f35ab749fc470f0",
15
17
  staging: {
16
18
  siteLibraryId: "ilib2GdaYEFxB7HyLPhSDPKMyPLhV8x9",
17
19
  siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
@@ -116,7 +116,7 @@ exports.RemoveProfileMetadata = async function({type="app", mode="public", appId
116
116
  };
117
117
 
118
118
  /**
119
- * Retrieve profile info for the specified user, including address, username and profile image (if set)
119
+ * Retrieve profile info for the specified user, including address, username, profile image (if set) and badges (if any)
120
120
  *
121
121
  * @methodGroup Profile
122
122
  * @param {string=} userAddress - Address of the user
@@ -139,10 +139,33 @@ exports.Profile = async function({userAddress, userName}) {
139
139
 
140
140
  const imageUrl = await this.ProfileMetadata({type: "user", userAddress, key: "icon_url"});
141
141
 
142
+ let badgeData = await this.ProfileMetadata({
143
+ type: "app",
144
+ mode: "public",
145
+ appId: "elv-badge-srv",
146
+ userAddress: this.badgerAddress,
147
+ key: `badges_${Utils.FormatAddress(userAddress)}`
148
+ });
149
+
150
+ let badges = [];
151
+ if(badgeData) {
152
+ try {
153
+ badgeData = (JSON.parse(badgeData)).badges;
154
+ badges = Object.keys(badgeData).map(badgeName => ({
155
+ ...badgeData[badgeName],
156
+ name: badgeName
157
+ }));
158
+ } catch(error) {
159
+ this.Log(`Failed to load badge info for ${userName || userAddress}`, true);
160
+ this.Log(error, true);
161
+ }
162
+ }
163
+
142
164
  return {
143
165
  userAddress: Utils.FormatAddress(userAddress),
144
166
  userName,
145
- imageUrl
167
+ imageUrl,
168
+ badges
146
169
  };
147
170
  };
148
171
 
@@ -51,6 +51,7 @@ class ElvWalletClient {
51
51
 
52
52
  this.stateStoreUrls = Configuration[network].stateStoreUrls;
53
53
  this.stateStoreClient = new HTTPClient({uris: this.stateStoreUrls});
54
+ this.badgerAddress = Configuration[network].badgerAddress;
54
55
 
55
56
  // Caches
56
57
  this.cachedMarketplaces = {};