@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.
- package/dist/ElvClient-min.js +12 -11
- package/dist/ElvClient-node-min.js +12 -17
- package/dist/ElvFrameClient-min.js +12 -11
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +11 -10
- package/dist/ElvWalletClient-node-min.js +12 -17
- package/dist/src/AuthorizationClient.js +1556 -2077
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +225 -322
- package/dist/src/ElvClient.js +823 -1117
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +222 -318
- package/dist/src/HttpClient.js +112 -154
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +160 -302
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +772 -942
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3263 -4132
- package/dist/src/client/ContentManagement.js +1811 -2283
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1505 -1845
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1412 -1551
- package/dist/src/walletClient/Configuration.js +4 -2
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1169 -1493
- package/package.json +3 -2
- package/src/Crypto.js +1 -1
- package/src/ElvClient.js +1 -3
- package/src/Utils.js +1 -1
- package/src/walletClient/ClientMethods.js +133 -11
- package/src/walletClient/index.js +1 -0
- package/testScripts/Test.js +0 -1
- package/utilities/NFTIngest.js +527 -0
- 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.
|
|
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.
|
|
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
package/src/ElvClient.js
CHANGED
package/src/Utils.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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});
|