@eluvio/elv-client-js 4.0.4 → 4.0.5
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 +7 -7
- package/dist/ElvFrameClient-min.js +6 -6
- package/dist/ElvWalletClient-min.js +7 -7
- package/dist/ElvWalletClient-node-min.js +7 -7
- package/dist/src/walletClient/ClientMethods.js +263 -15
- package/dist/src/walletClient/index.js +1 -0
- package/package.json +2 -1
- package/src/walletClient/ClientMethods.js +133 -11
- package/src/walletClient/index.js +1 -0
|
@@ -89,11 +89,13 @@ exports.UserWalletBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regene
|
|
|
89
89
|
balance,
|
|
90
90
|
usage_hold,
|
|
91
91
|
payout_hold,
|
|
92
|
+
locked_offer_balance,
|
|
92
93
|
stripe_id,
|
|
93
94
|
stripe_payouts_enabled,
|
|
94
95
|
userStripeId,
|
|
95
96
|
userStripeEnabled,
|
|
96
97
|
totalWalletBalance,
|
|
98
|
+
lockedWalletBalance,
|
|
97
99
|
availableWalletBalance,
|
|
98
100
|
pendingWalletBalance,
|
|
99
101
|
withdrawableWalletBalance,
|
|
@@ -135,23 +137,25 @@ exports.UserWalletBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regene
|
|
|
135
137
|
balance = _yield$this$client$ut.balance;
|
|
136
138
|
usage_hold = _yield$this$client$ut.usage_hold;
|
|
137
139
|
payout_hold = _yield$this$client$ut.payout_hold;
|
|
140
|
+
locked_offer_balance = _yield$this$client$ut.locked_offer_balance;
|
|
138
141
|
stripe_id = _yield$this$client$ut.stripe_id;
|
|
139
142
|
stripe_payouts_enabled = _yield$this$client$ut.stripe_payouts_enabled;
|
|
140
143
|
userStripeId = stripe_id;
|
|
141
144
|
userStripeEnabled = stripe_payouts_enabled;
|
|
142
145
|
totalWalletBalance = parseFloat(balance || 0);
|
|
143
|
-
|
|
146
|
+
lockedWalletBalance = parseFloat(locked_offer_balance || 0);
|
|
147
|
+
availableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(usage_hold || 0) - lockedWalletBalance);
|
|
144
148
|
pendingWalletBalance = Math.max(0, totalWalletBalance - availableWalletBalance);
|
|
145
|
-
withdrawableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(payout_hold || 0));
|
|
149
|
+
withdrawableWalletBalance = Math.max(0, totalWalletBalance - parseFloat(Math.max(payout_hold, lockedWalletBalance) || 0));
|
|
146
150
|
|
|
147
151
|
if (!(checkOnboard && stripe_id && !stripe_payouts_enabled)) {
|
|
148
|
-
_context.next =
|
|
152
|
+
_context.next = 30;
|
|
149
153
|
break;
|
|
150
154
|
}
|
|
151
155
|
|
|
152
156
|
// Refresh stripe enabled flag
|
|
153
157
|
rootUrl = new URL(UrlJoin(window.location.origin, window.location.pathname)).toString();
|
|
154
|
-
_context.next =
|
|
158
|
+
_context.next = 27;
|
|
155
159
|
return this.client.authClient.MakeAuthServiceRequest({
|
|
156
160
|
path: UrlJoin("as", "wlt", "onb", "stripe"),
|
|
157
161
|
method: "POST",
|
|
@@ -166,17 +170,18 @@ exports.UserWalletBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regene
|
|
|
166
170
|
}
|
|
167
171
|
});
|
|
168
172
|
|
|
169
|
-
case
|
|
170
|
-
_context.next =
|
|
173
|
+
case 27:
|
|
174
|
+
_context.next = 29;
|
|
171
175
|
return this.UserWalletBalance(false);
|
|
172
176
|
|
|
173
|
-
case
|
|
177
|
+
case 29:
|
|
174
178
|
return _context.abrupt("return", _context.sent);
|
|
175
179
|
|
|
176
|
-
case
|
|
180
|
+
case 30:
|
|
177
181
|
balances = {
|
|
178
182
|
totalWalletBalance: totalWalletBalance,
|
|
179
183
|
availableWalletBalance: availableWalletBalance,
|
|
184
|
+
lockedWalletBalance: lockedWalletBalance,
|
|
180
185
|
pendingWalletBalance: pendingWalletBalance,
|
|
181
186
|
withdrawableWalletBalance: withdrawableWalletBalance
|
|
182
187
|
};
|
|
@@ -195,7 +200,7 @@ exports.UserWalletBalance = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regene
|
|
|
195
200
|
|
|
196
201
|
return _context.abrupt("return", balances);
|
|
197
202
|
|
|
198
|
-
case
|
|
203
|
+
case 33:
|
|
199
204
|
case "end":
|
|
200
205
|
return _context.stop();
|
|
201
206
|
}
|
|
@@ -657,27 +662,37 @@ exports.TenantConfiguration = /*#__PURE__*/function () {
|
|
|
657
662
|
case 0:
|
|
658
663
|
tenantId = _ref18.tenantId, contractAddress = _ref18.contractAddress;
|
|
659
664
|
_context9.prev = 1;
|
|
660
|
-
|
|
665
|
+
contractAddress = contractAddress ? Utils.FormatAddress(contractAddress) : undefined;
|
|
666
|
+
|
|
667
|
+
if (this.tenantConfigs[contractAddress || tenantId]) {
|
|
668
|
+
_context9.next = 7;
|
|
669
|
+
break;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
_context9.next = 6;
|
|
661
673
|
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
662
674
|
path: contractAddress ? UrlJoin("as", "config", "nft", contractAddress) : UrlJoin("as", "config", "tnt", tenantId),
|
|
663
675
|
method: "GET"
|
|
664
676
|
}));
|
|
665
677
|
|
|
666
|
-
case
|
|
667
|
-
|
|
678
|
+
case 6:
|
|
679
|
+
this.tenantConfigs[contractAddress || tenantId] = _context9.sent;
|
|
668
680
|
|
|
669
681
|
case 7:
|
|
670
|
-
_context9.
|
|
682
|
+
return _context9.abrupt("return", this.tenantConfigs[contractAddress || tenantId]);
|
|
683
|
+
|
|
684
|
+
case 10:
|
|
685
|
+
_context9.prev = 10;
|
|
671
686
|
_context9.t0 = _context9["catch"](1);
|
|
672
687
|
this.Log("Failed to load tenant configuration", true, _context9.t0);
|
|
673
688
|
return _context9.abrupt("return", {});
|
|
674
689
|
|
|
675
|
-
case
|
|
690
|
+
case 14:
|
|
676
691
|
case "end":
|
|
677
692
|
return _context9.stop();
|
|
678
693
|
}
|
|
679
694
|
}
|
|
680
|
-
}, _callee9, this, [[1,
|
|
695
|
+
}, _callee9, this, [[1, 10]]);
|
|
681
696
|
}));
|
|
682
697
|
|
|
683
698
|
return function (_x2) {
|
|
@@ -2540,4 +2555,237 @@ exports.DropStatus = /*#__PURE__*/function () {
|
|
|
2540
2555
|
return function (_x26) {
|
|
2541
2556
|
return _ref80.apply(this, arguments);
|
|
2542
2557
|
};
|
|
2558
|
+
}();
|
|
2559
|
+
/* OFFERS */
|
|
2560
|
+
// TODO: Document
|
|
2561
|
+
|
|
2562
|
+
|
|
2563
|
+
exports.MarketplaceOffers = /*#__PURE__*/function () {
|
|
2564
|
+
var _ref82 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41(_ref81) {
|
|
2565
|
+
var contractAddress, tokenId, buyerAddress, sellerAddress, statuses, _ref81$start, start, _ref81$limit, limit, path, queryParams, offers;
|
|
2566
|
+
|
|
2567
|
+
return _regeneratorRuntime.wrap(function _callee41$(_context41) {
|
|
2568
|
+
while (1) {
|
|
2569
|
+
switch (_context41.prev = _context41.next) {
|
|
2570
|
+
case 0:
|
|
2571
|
+
contractAddress = _ref81.contractAddress, tokenId = _ref81.tokenId, buyerAddress = _ref81.buyerAddress, sellerAddress = _ref81.sellerAddress, statuses = _ref81.statuses, _ref81$start = _ref81.start, start = _ref81$start === void 0 ? 0 : _ref81$start, _ref81$limit = _ref81.limit, limit = _ref81$limit === void 0 ? 10 : _ref81$limit;
|
|
2572
|
+
path = UrlJoin("as", "mkt", "offers", "ls");
|
|
2573
|
+
|
|
2574
|
+
if (buyerAddress) {
|
|
2575
|
+
path = UrlJoin(path, "b", Utils.FormatAddress(buyerAddress));
|
|
2576
|
+
} else if (sellerAddress) {
|
|
2577
|
+
path = UrlJoin(path, "s", Utils.FormatAddress(sellerAddress));
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
if (contractAddress) {
|
|
2581
|
+
path = UrlJoin(path, "c", Utils.FormatAddress(contractAddress));
|
|
2582
|
+
|
|
2583
|
+
if (tokenId) {
|
|
2584
|
+
path = UrlJoin(path, "t", tokenId);
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
queryParams = {
|
|
2589
|
+
start: start,
|
|
2590
|
+
limit: limit
|
|
2591
|
+
};
|
|
2592
|
+
|
|
2593
|
+
if (statuses && statuses.length > 0) {
|
|
2594
|
+
queryParams.include = statuses.join(",");
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
_context41.next = 8;
|
|
2598
|
+
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
2599
|
+
path: path,
|
|
2600
|
+
method: "GET",
|
|
2601
|
+
queryParams: queryParams
|
|
2602
|
+
}));
|
|
2603
|
+
|
|
2604
|
+
case 8:
|
|
2605
|
+
offers = _context41.sent;
|
|
2606
|
+
return _context41.abrupt("return", offers.map(function (offer) {
|
|
2607
|
+
return _objectSpread(_objectSpread({}, offer), {}, {
|
|
2608
|
+
created: offer.created * 1000,
|
|
2609
|
+
updated: offer.updated * 1000,
|
|
2610
|
+
expiration: offer.expiration * 1000
|
|
2611
|
+
});
|
|
2612
|
+
}));
|
|
2613
|
+
|
|
2614
|
+
case 10:
|
|
2615
|
+
case "end":
|
|
2616
|
+
return _context41.stop();
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}, _callee41, this);
|
|
2620
|
+
}));
|
|
2621
|
+
|
|
2622
|
+
return function (_x27) {
|
|
2623
|
+
return _ref82.apply(this, arguments);
|
|
2624
|
+
};
|
|
2625
|
+
}();
|
|
2626
|
+
|
|
2627
|
+
exports.CreateMarketplaceOffer = /*#__PURE__*/function () {
|
|
2628
|
+
var _ref84 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42(_ref83) {
|
|
2629
|
+
var contractAddress, tokenId, offerId, price, expiresAt, response;
|
|
2630
|
+
return _regeneratorRuntime.wrap(function _callee42$(_context42) {
|
|
2631
|
+
while (1) {
|
|
2632
|
+
switch (_context42.prev = _context42.next) {
|
|
2633
|
+
case 0:
|
|
2634
|
+
contractAddress = _ref83.contractAddress, tokenId = _ref83.tokenId, offerId = _ref83.offerId, price = _ref83.price, expiresAt = _ref83.expiresAt;
|
|
2635
|
+
|
|
2636
|
+
if (!offerId) {
|
|
2637
|
+
_context42.next = 7;
|
|
2638
|
+
break;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2641
|
+
_context42.next = 4;
|
|
2642
|
+
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
2643
|
+
path: UrlJoin("as", "wlt", "mkt", "offers", offerId),
|
|
2644
|
+
method: "PUT",
|
|
2645
|
+
body: {
|
|
2646
|
+
price: price,
|
|
2647
|
+
expiration: Math.floor(expiresAt / 1000)
|
|
2648
|
+
},
|
|
2649
|
+
headers: {
|
|
2650
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
2651
|
+
}
|
|
2652
|
+
}));
|
|
2653
|
+
|
|
2654
|
+
case 4:
|
|
2655
|
+
response = _context42.sent;
|
|
2656
|
+
_context42.next = 10;
|
|
2657
|
+
break;
|
|
2658
|
+
|
|
2659
|
+
case 7:
|
|
2660
|
+
_context42.next = 9;
|
|
2661
|
+
return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
|
|
2662
|
+
path: UrlJoin("as", "wlt", "mkt", "offers", contractAddress, tokenId),
|
|
2663
|
+
method: "POST",
|
|
2664
|
+
body: {
|
|
2665
|
+
contract: contractAddress,
|
|
2666
|
+
token: tokenId,
|
|
2667
|
+
price: price,
|
|
2668
|
+
expiration: Math.floor(expiresAt / 1000)
|
|
2669
|
+
},
|
|
2670
|
+
headers: {
|
|
2671
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
2672
|
+
}
|
|
2673
|
+
}));
|
|
2674
|
+
|
|
2675
|
+
case 9:
|
|
2676
|
+
response = _context42.sent;
|
|
2677
|
+
|
|
2678
|
+
case 10:
|
|
2679
|
+
return _context42.abrupt("return", response.offer_id);
|
|
2680
|
+
|
|
2681
|
+
case 11:
|
|
2682
|
+
case "end":
|
|
2683
|
+
return _context42.stop();
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
}, _callee42, this);
|
|
2687
|
+
}));
|
|
2688
|
+
|
|
2689
|
+
return function (_x28) {
|
|
2690
|
+
return _ref84.apply(this, arguments);
|
|
2691
|
+
};
|
|
2692
|
+
}();
|
|
2693
|
+
|
|
2694
|
+
exports.RemoveMarketplaceOffer = /*#__PURE__*/function () {
|
|
2695
|
+
var _ref86 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(_ref85) {
|
|
2696
|
+
var offerId;
|
|
2697
|
+
return _regeneratorRuntime.wrap(function _callee43$(_context43) {
|
|
2698
|
+
while (1) {
|
|
2699
|
+
switch (_context43.prev = _context43.next) {
|
|
2700
|
+
case 0:
|
|
2701
|
+
offerId = _ref85.offerId;
|
|
2702
|
+
_context43.next = 3;
|
|
2703
|
+
return this.client.authClient.MakeAuthServiceRequest({
|
|
2704
|
+
path: UrlJoin("as", "wlt", "mkt", "offers", offerId),
|
|
2705
|
+
method: "DELETE",
|
|
2706
|
+
headers: {
|
|
2707
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
2708
|
+
}
|
|
2709
|
+
});
|
|
2710
|
+
|
|
2711
|
+
case 3:
|
|
2712
|
+
return _context43.abrupt("return", _context43.sent);
|
|
2713
|
+
|
|
2714
|
+
case 4:
|
|
2715
|
+
case "end":
|
|
2716
|
+
return _context43.stop();
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
}, _callee43, this);
|
|
2720
|
+
}));
|
|
2721
|
+
|
|
2722
|
+
return function (_x29) {
|
|
2723
|
+
return _ref86.apply(this, arguments);
|
|
2724
|
+
};
|
|
2725
|
+
}();
|
|
2726
|
+
|
|
2727
|
+
exports.AcceptMarketplaceOffer = /*#__PURE__*/function () {
|
|
2728
|
+
var _ref88 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(_ref87) {
|
|
2729
|
+
var offerId;
|
|
2730
|
+
return _regeneratorRuntime.wrap(function _callee44$(_context44) {
|
|
2731
|
+
while (1) {
|
|
2732
|
+
switch (_context44.prev = _context44.next) {
|
|
2733
|
+
case 0:
|
|
2734
|
+
offerId = _ref87.offerId;
|
|
2735
|
+
_context44.next = 3;
|
|
2736
|
+
return this.client.authClient.MakeAuthServiceRequest({
|
|
2737
|
+
path: UrlJoin("as", "wlt", "mkt", "offers", "accept", offerId),
|
|
2738
|
+
method: "PUT",
|
|
2739
|
+
headers: {
|
|
2740
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
2741
|
+
}
|
|
2742
|
+
});
|
|
2743
|
+
|
|
2744
|
+
case 3:
|
|
2745
|
+
return _context44.abrupt("return", _context44.sent);
|
|
2746
|
+
|
|
2747
|
+
case 4:
|
|
2748
|
+
case "end":
|
|
2749
|
+
return _context44.stop();
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
}, _callee44, this);
|
|
2753
|
+
}));
|
|
2754
|
+
|
|
2755
|
+
return function (_x30) {
|
|
2756
|
+
return _ref88.apply(this, arguments);
|
|
2757
|
+
};
|
|
2758
|
+
}();
|
|
2759
|
+
|
|
2760
|
+
exports.RejectMarketplaceOffer = /*#__PURE__*/function () {
|
|
2761
|
+
var _ref90 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45(_ref89) {
|
|
2762
|
+
var offerId;
|
|
2763
|
+
return _regeneratorRuntime.wrap(function _callee45$(_context45) {
|
|
2764
|
+
while (1) {
|
|
2765
|
+
switch (_context45.prev = _context45.next) {
|
|
2766
|
+
case 0:
|
|
2767
|
+
offerId = _ref89.offerId;
|
|
2768
|
+
_context45.next = 3;
|
|
2769
|
+
return this.client.authClient.MakeAuthServiceRequest({
|
|
2770
|
+
path: UrlJoin("as", "wlt", "mkt", "offers", "decline", offerId),
|
|
2771
|
+
method: "PUT",
|
|
2772
|
+
headers: {
|
|
2773
|
+
Authorization: "Bearer ".concat(this.AuthToken())
|
|
2774
|
+
}
|
|
2775
|
+
});
|
|
2776
|
+
|
|
2777
|
+
case 3:
|
|
2778
|
+
return _context45.abrupt("return", _context45.sent);
|
|
2779
|
+
|
|
2780
|
+
case 4:
|
|
2781
|
+
case "end":
|
|
2782
|
+
return _context45.stop();
|
|
2783
|
+
}
|
|
2784
|
+
}
|
|
2785
|
+
}, _callee45, this);
|
|
2786
|
+
}));
|
|
2787
|
+
|
|
2788
|
+
return function (_x31) {
|
|
2789
|
+
return _ref90.apply(this, arguments);
|
|
2790
|
+
};
|
|
2543
2791
|
}();
|
|
@@ -80,6 +80,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
80
80
|
this.availableMarketplaces = {};
|
|
81
81
|
this.availableMarketplacesById = {};
|
|
82
82
|
this.marketplaceHashes = {};
|
|
83
|
+
this.tenantConfigs = {};
|
|
83
84
|
this.stateStoreUrls = Configuration[network].stateStoreUrls;
|
|
84
85
|
this.stateStoreClient = new HTTPClient({
|
|
85
86
|
uris: this.stateStoreUrls
|
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.5",
|
|
4
4
|
"description": "Javascript client for the Eluvio Content Fabric",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Kevin Talmadge",
|
|
@@ -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",
|
|
@@ -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});
|