@eluvio/elv-client-js 4.0.4 → 4.0.6

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.
Files changed (45) hide show
  1. package/dist/ElvClient-min.js +12 -11
  2. package/dist/ElvClient-node-min.js +12 -17
  3. package/dist/ElvFrameClient-min.js +12 -11
  4. package/dist/ElvPermissionsClient-min.js +10 -9
  5. package/dist/ElvWalletClient-min.js +11 -10
  6. package/dist/ElvWalletClient-node-min.js +12 -17
  7. package/dist/src/AuthorizationClient.js +1556 -2077
  8. package/dist/src/ContentObjectVerification.js +134 -185
  9. package/dist/src/Crypto.js +225 -322
  10. package/dist/src/ElvClient.js +823 -1117
  11. package/dist/src/ElvWallet.js +64 -106
  12. package/dist/src/EthClient.js +719 -974
  13. package/dist/src/FrameClient.js +222 -318
  14. package/dist/src/HttpClient.js +112 -154
  15. package/dist/src/Id.js +1 -6
  16. package/dist/src/LogMessage.js +4 -8
  17. package/dist/src/PermissionsClient.js +973 -1271
  18. package/dist/src/RemoteSigner.js +161 -232
  19. package/dist/src/UserProfileClient.js +781 -1038
  20. package/dist/src/Utils.js +160 -302
  21. package/dist/src/Validation.js +2 -17
  22. package/dist/src/client/ABRPublishing.js +772 -942
  23. package/dist/src/client/AccessGroups.js +849 -1095
  24. package/dist/src/client/ContentAccess.js +3263 -4132
  25. package/dist/src/client/ContentManagement.js +1811 -2283
  26. package/dist/src/client/Contracts.js +468 -614
  27. package/dist/src/client/Files.js +1505 -1845
  28. package/dist/src/client/NFT.js +94 -116
  29. package/dist/src/client/NTP.js +326 -425
  30. package/dist/src/index.js +2 -5
  31. package/dist/src/walletClient/ClientMethods.js +1412 -1551
  32. package/dist/src/walletClient/Configuration.js +4 -2
  33. package/dist/src/walletClient/Notifications.js +98 -127
  34. package/dist/src/walletClient/Profile.js +184 -246
  35. package/dist/src/walletClient/Utils.js +76 -122
  36. package/dist/src/walletClient/index.js +1169 -1493
  37. package/package.json +3 -2
  38. package/src/Crypto.js +1 -1
  39. package/src/ElvClient.js +1 -3
  40. package/src/Utils.js +1 -1
  41. package/src/walletClient/ClientMethods.js +133 -11
  42. package/src/walletClient/index.js +1 -0
  43. package/testScripts/Test.js +0 -1
  44. package/utilities/NFTIngest.js +527 -0
  45. package/utilities/lib/concerns/LocalFile.js +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -60,7 +60,7 @@
60
60
  ],
61
61
  "dependencies": {
62
62
  "@babel/runtime": "^7.8.4",
63
- "@eluvio/crypto": ">=1.0.8",
63
+ "@eluvio/crypto": ">=1.0.12",
64
64
  "@eluvio/elv-abr-profile": "^1.0.0",
65
65
  "@sindresorhus/slugify": "^1.1.0",
66
66
  "babel-loader": "^8.0.6",
@@ -78,6 +78,7 @@
78
78
  "fraction.js": "^4.0.12",
79
79
  "hash.js": "^1.1.7",
80
80
  "image-type": "^4.1.0",
81
+ "isarray": "^2.0.5",
81
82
  "js-polyfills": "^0.1.42",
82
83
  "jsonpath-plus": "^6.0.1",
83
84
  "kind-of": "^6.0.3",
package/src/Crypto.js CHANGED
@@ -1,4 +1,4 @@
1
- if(typeof Buffer === "undefined") { Buffer = require("buffer/").Buffer; }
1
+ require("buffer");
2
2
 
3
3
  const bs58 = require("bs58");
4
4
  const Stream = require("stream");
package/src/ElvClient.js CHANGED
@@ -1,6 +1,4 @@
1
- if(typeof Buffer === "undefined") {
2
- Buffer = require("buffer/").Buffer;
3
- }
1
+ require("buffer");
4
2
 
5
3
  const URI = require("urijs");
6
4
  const Ethers = require("ethers");
package/src/Utils.js CHANGED
@@ -1,4 +1,4 @@
1
- if(typeof Buffer === "undefined") { Buffer = require("buffer/").Buffer; }
1
+ require("buffer");
2
2
 
3
3
  const bs58 = require("bs58");
4
4
  const BigNumber = require("bignumber.js").default;
@@ -66,7 +66,7 @@ exports.UserWalletBalance = async function(checkOnboard=false) {
66
66
  if(!this.loggedIn) { return; }
67
67
 
68
68
  // eslint-disable-next-line no-unused-vars
69
- const { balance, usage_hold, payout_hold, stripe_id, stripe_payouts_enabled } = await this.client.utils.ResponseToJson(
69
+ const { balance, usage_hold, payout_hold, locked_offer_balance, stripe_id, stripe_payouts_enabled } = await this.client.utils.ResponseToJson(
70
70
  await this.client.authClient.MakeAuthServiceRequest({
71
71
  path: UrlJoin("as", "wlt", "mkt", "bal"),
72
72
  method: "GET",
@@ -79,9 +79,10 @@ exports.UserWalletBalance = async function(checkOnboard=false) {
79
79
  const userStripeId = stripe_id;
80
80
  const userStripeEnabled = stripe_payouts_enabled;
81
81
  const totalWalletBalance = parseFloat(balance || 0);
82
- const availableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(usage_hold || 0));
82
+ const lockedWalletBalance = parseFloat(locked_offer_balance || 0);
83
+ const availableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(usage_hold || 0) - lockedWalletBalance);
83
84
  const pendingWalletBalance = Math.max(0, totalWalletBalance - availableWalletBalance);
84
- const withdrawableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(payout_hold || 0));
85
+ const withdrawableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(Math.max(payout_hold, lockedWalletBalance) || 0));
85
86
 
86
87
  if(checkOnboard && stripe_id && !stripe_payouts_enabled) {
87
88
  // Refresh stripe enabled flag
@@ -106,6 +107,7 @@ exports.UserWalletBalance = async function(checkOnboard=false) {
106
107
  let balances = {
107
108
  totalWalletBalance,
108
109
  availableWalletBalance,
110
+ lockedWalletBalance,
109
111
  pendingWalletBalance,
110
112
  withdrawableWalletBalance,
111
113
  };
@@ -355,14 +357,20 @@ exports.UserTransfers = async function({userAddress, sortBy="created", sortDesc=
355
357
  */
356
358
  exports.TenantConfiguration = async function({tenantId, contractAddress}) {
357
359
  try {
358
- return await Utils.ResponseToJson(
359
- this.client.authClient.MakeAuthServiceRequest({
360
- path: contractAddress ?
361
- UrlJoin("as", "config", "nft", contractAddress) :
362
- UrlJoin("as", "config", "tnt", tenantId),
363
- method: "GET",
364
- })
365
- );
360
+ contractAddress = contractAddress ? Utils.FormatAddress(contractAddress) : undefined;
361
+
362
+ if(!this.tenantConfigs[contractAddress || tenantId]) {
363
+ this.tenantConfigs[contractAddress || tenantId] = await Utils.ResponseToJson(
364
+ this.client.authClient.MakeAuthServiceRequest({
365
+ path: contractAddress ?
366
+ UrlJoin("as", "config", "nft", contractAddress) :
367
+ UrlJoin("as", "config", "tnt", tenantId),
368
+ method: "GET",
369
+ })
370
+ );
371
+ }
372
+
373
+ return this.tenantConfigs[contractAddress || tenantId];
366
374
  } catch(error) {
367
375
  this.Log("Failed to load tenant configuration", true, error);
368
376
 
@@ -1291,3 +1299,117 @@ exports.DropStatus = async function({marketplace, eventId, dropId}) {
1291
1299
  return "";
1292
1300
  }
1293
1301
  };
1302
+
1303
+
1304
+ /* OFFERS */
1305
+ // TODO: Document
1306
+
1307
+ exports.MarketplaceOffers = async function({contractAddress, tokenId, buyerAddress, sellerAddress, statuses, start=0, limit=10}) {
1308
+ let path = UrlJoin("as", "mkt", "offers", "ls");
1309
+ if(buyerAddress) {
1310
+ path = UrlJoin(path, "b", Utils.FormatAddress(buyerAddress));
1311
+ } else if(sellerAddress) {
1312
+ path = UrlJoin(path, "s", Utils.FormatAddress(sellerAddress));
1313
+ }
1314
+
1315
+ if(contractAddress) {
1316
+ path = UrlJoin(path, "c", Utils.FormatAddress(contractAddress));
1317
+
1318
+ if(tokenId) {
1319
+ path = UrlJoin(path, "t", tokenId);
1320
+ }
1321
+ }
1322
+
1323
+ let queryParams = {
1324
+ start,
1325
+ limit
1326
+ };
1327
+
1328
+ if(statuses && statuses.length > 0) {
1329
+ queryParams.include = statuses.join(",");
1330
+ }
1331
+
1332
+ const offers = await Utils.ResponseToJson(
1333
+ this.client.authClient.MakeAuthServiceRequest({
1334
+ path: path,
1335
+ method: "GET",
1336
+ queryParams
1337
+ })
1338
+ );
1339
+
1340
+ return offers
1341
+ .map(offer => ({
1342
+ ...offer,
1343
+ created: offer.created * 1000,
1344
+ updated: offer.updated * 1000,
1345
+ expiration: offer.expiration * 1000
1346
+ }));
1347
+ };
1348
+
1349
+ exports.CreateMarketplaceOffer = async function({contractAddress, tokenId, offerId, price, expiresAt}) {
1350
+ let response;
1351
+ if(offerId) {
1352
+ response = await Utils.ResponseToJson(
1353
+ this.client.authClient.MakeAuthServiceRequest({
1354
+ path: UrlJoin("as", "wlt", "mkt", "offers", offerId),
1355
+ method: "PUT",
1356
+ body: {
1357
+ price,
1358
+ expiration: Math.floor(expiresAt / 1000)
1359
+ },
1360
+ headers: {
1361
+ Authorization: `Bearer ${this.AuthToken()}`
1362
+ }
1363
+ })
1364
+ );
1365
+ } else {
1366
+ response = await Utils.ResponseToJson(
1367
+ this.client.authClient.MakeAuthServiceRequest({
1368
+ path: UrlJoin("as", "wlt", "mkt", "offers", contractAddress, tokenId),
1369
+ method: "POST",
1370
+ body: {
1371
+ contract: contractAddress,
1372
+ token: tokenId,
1373
+ price,
1374
+ expiration: Math.floor(expiresAt / 1000)
1375
+ },
1376
+ headers: {
1377
+ Authorization: `Bearer ${this.AuthToken()}`
1378
+ }
1379
+ })
1380
+ );
1381
+ }
1382
+
1383
+ return response.offer_id;
1384
+ };
1385
+
1386
+ exports.RemoveMarketplaceOffer = async function({offerId}) {
1387
+ return await this.client.authClient.MakeAuthServiceRequest({
1388
+ path: UrlJoin("as", "wlt", "mkt", "offers", offerId),
1389
+ method: "DELETE",
1390
+ headers: {
1391
+ Authorization: `Bearer ${this.AuthToken()}`
1392
+ }
1393
+ });
1394
+ };
1395
+
1396
+
1397
+ exports.AcceptMarketplaceOffer = async function({offerId}) {
1398
+ return await this.client.authClient.MakeAuthServiceRequest({
1399
+ path: UrlJoin("as", "wlt", "mkt", "offers", "accept", offerId),
1400
+ method: "PUT",
1401
+ headers: {
1402
+ Authorization: `Bearer ${this.AuthToken()}`
1403
+ }
1404
+ });
1405
+ };
1406
+
1407
+ exports.RejectMarketplaceOffer = async function({offerId}) {
1408
+ return await this.client.authClient.MakeAuthServiceRequest({
1409
+ path: UrlJoin("as", "wlt", "mkt", "offers", "decline", offerId),
1410
+ method: "PUT",
1411
+ headers: {
1412
+ Authorization: `Bearer ${this.AuthToken()}`
1413
+ }
1414
+ });
1415
+ };
@@ -44,6 +44,7 @@ class ElvWalletClient {
44
44
  this.availableMarketplaces = {};
45
45
  this.availableMarketplacesById = {};
46
46
  this.marketplaceHashes = {};
47
+ this.tenantConfigs = {};
47
48
 
48
49
  this.stateStoreUrls = Configuration[network].stateStoreUrls;
49
50
  this.stateStoreClient = new HTTPClient({uris: this.stateStoreUrls});
@@ -6,7 +6,6 @@ const ethers = require("ethers");
6
6
 
7
7
  const Test = async () => {
8
8
  try {
9
-
10
9
  const client = await ElvClient.FromNetworkName({
11
10
  networkName: "demo"
12
11
  });