@eluvio/elv-client-js 3.2.2 → 3.2.4

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.
@@ -1,29 +0,0 @@
1
- var WalletConfiguration = {
2
- demo: {
3
- configUrl: "https://demov3.net955210.contentfabric.io/config",
4
- staging: {
5
- siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
6
- purchaseMode: "develop",
7
- appUrl: "https://core.test.contentfabric.io/wallet-demo"
8
- }
9
- },
10
- main: {
11
- configUrl: "https://main.net955305.contentfabric.io/config",
12
- staging: {
13
- siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
14
- purchaseMode: "production",
15
- appUrl: "https://core.test.contentfabric.io/wallet"
16
- },
17
- production: {
18
- siteId: "iq__suqRJUt2vmXsyiWS5ZaSGwtFU9R",
19
- purchaseMode: "production",
20
- appUrl: "https://wallet.contentfabric.io"
21
- }
22
- },
23
- __MARKETPLACE_ORDER: ["dolly-marketplace", "oc-marketplace", "maskverse-marketplace", "emp-marketplace", "microsoft", "indieflix-marketplace", "angels-airwaves-marketplace"]
24
- }; // No production environment on demo
25
-
26
- WalletConfiguration.demo.production = WalletConfiguration.demo.staging; // Allow demo to be referred to as demov3
27
-
28
- WalletConfiguration.demov3 = WalletConfiguration.demo;
29
- module.exports = WalletConfiguration;
@@ -1,290 +0,0 @@
1
- var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
-
3
- var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
-
5
- var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
6
-
7
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
8
-
9
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
10
-
11
- var Utils = require("../Utils");
12
-
13
- var RarityToPercentage = function RarityToPercentage(rarity) {
14
- if (!rarity) {
15
- return "";
16
- }
17
-
18
- rarity = rarity.toString();
19
-
20
- if (!rarity.includes("/")) {
21
- return rarity;
22
- }
23
-
24
- var _rarity$split = rarity.split("/"),
25
- _rarity$split2 = _slicedToArray(_rarity$split, 2),
26
- numerator = _rarity$split2[0],
27
- denominator = _rarity$split2[1];
28
-
29
- var percentage = 100 * parseInt(numerator) / parseInt(denominator);
30
-
31
- if (percentage < 1) {
32
- percentage = percentage.toFixed(2);
33
- } else {
34
- percentage = percentage.toFixed(1).toString().replace(".0", "");
35
- }
36
-
37
- return percentage;
38
- }; // Format NFT or listing result into consistent format
39
-
40
-
41
- var FormatNFTDetails = function FormatNFTDetails(entry) {
42
- var isListing = !!entry.id;
43
- var metadata = (isListing ? entry.nft : entry.meta) || {};
44
- var info = isListing ? entry.info : entry;
45
- var details = {
46
- USDCAccepted: !!(entry.accepts || []).find(function (entry) {
47
- return entry.type === "sol";
48
- }),
49
- USDCOnly: ((entry.accepts || []).find(function (entry) {
50
- return entry.type === "sol";
51
- }) || {}).preferred,
52
- TenantId: entry.tenant || entry.tenant_id,
53
- ContractAddr: info.contract_addr,
54
- ContractId: "ictr".concat(Utils.AddressToHash(info.contract_addr)),
55
- ContractName: info.contract_name,
56
- Cap: info.cap,
57
- TokenIdStr: info.token_id_str,
58
- TokenUri: info.token_uri,
59
- TokenOrdinal: info.ordinal,
60
- TokenHold: info.hold,
61
- TokenHoldDate: info.hold ? new Date(parseInt(info.hold) * 1000) : undefined,
62
- TokenOwner: info.token_owner ? Utils.FormatAddress(info.token_owner) : "",
63
- VersionHash: (info.token_uri || "").split("/").find(function (s) {
64
- return (s || "").startsWith("hq__");
65
- })
66
- };
67
-
68
- if (isListing) {
69
- details = _objectSpread({}, details, {
70
- // Listing specific fields
71
- ListingId: entry.id,
72
- CreatedAt: entry.created * 1000,
73
- UpdatedAt: entry.updated * 1000,
74
- CheckoutLockedUntil: entry.checkout ? entry.checkout * 1000 : undefined,
75
- SellerAddress: Utils.FormatAddress(entry.seller),
76
- Price: entry.price,
77
- Fee: entry.fee
78
- });
79
- }
80
-
81
- return {
82
- metadata: metadata,
83
- details: details
84
- };
85
- };
86
-
87
- exports.FormatNFTDetails = FormatNFTDetails;
88
-
89
- var FormatNFTMetadata = function FormatNFTMetadata(nft) {
90
- nft.formatted = true; // Surface relevant details to top level
91
-
92
- nft.contractAddress = nft.details.ContractAddr;
93
- nft.contractId = nft.details.ContractId;
94
- nft.tokenId = nft.details.TokenIdStr;
95
- nft.name = nft.metadata.display_name;
96
-
97
- if (nft.details.ListingId) {
98
- nft.listingId = nft.details.ListingId;
99
- } // Format traits
100
-
101
-
102
- var FILTERED_ATTRIBUTES = ["Content Fabric Hash", "Creator", "Total Minted Supply"];
103
- nft.metadata.attributes = (nft.metadata.attributes || []).filter(function (attribute) {
104
- return attribute && !FILTERED_ATTRIBUTES.includes(attribute.trait_type);
105
- }).map(function (trait) {
106
- return _objectSpread({}, trait, {
107
- name: trait.trait_type,
108
- rarity_percent: RarityToPercentage(trait.rarity)
109
- });
110
- }); // Generate embed URLs for additional media
111
-
112
- if (nft.metadata.additional_media) {
113
- nft.metadata.additional_media = nft.metadata.additional_media.map(function (media) {
114
- try {
115
- // Generate embed URLs for additional media
116
- var mediaType = (media.media_type || "").toLowerCase();
117
-
118
- if (mediaType === "image") {
119
- return _objectSpread({}, media, {
120
- embed_url: media.media_file.url
121
- });
122
- }
123
-
124
- var embedUrl = new URL("https://embed.v3.contentfabric.io");
125
- embedUrl.searchParams.set("p", "");
126
- embedUrl.searchParams.set("net", rootStore.network === "demo" ? "demo" : "main");
127
- embedUrl.searchParams.set("ath", rootStore.authToken);
128
-
129
- if (mediaType === "video") {
130
- embedUrl.searchParams.set("vid", LinkTargetHash(media.media_link));
131
- embedUrl.searchParams.set("ct", "h");
132
- embedUrl.searchParams.set("ap", "");
133
- } else if (mediaType === "ebook") {
134
- embedUrl.searchParams.set("type", "ebook");
135
- embedUrl.searchParams.set("vid", media.media_file["."].container);
136
- embedUrl.searchParams.set("murl", btoa(media.media_file.url));
137
- }
138
-
139
- return _objectSpread({}, media, {
140
- embed_url: embedUrl.toString()
141
- });
142
- } catch (error) {
143
- return media;
144
- }
145
- });
146
- } // Generate embed URLs for pack opening animations
147
-
148
-
149
- ["open_animation", "open_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
150
- try {
151
- if (nft.metadata.pack_options && nft.metadata.pack_options[key]) {
152
- var embedUrl = new URL("https://embed.v3.contentfabric.io");
153
- embedUrl.searchParams.set("p", "");
154
- embedUrl.searchParams.set("net", rootStore.network === "demo" ? "demo" : "main");
155
- embedUrl.searchParams.set("ath", rootStore.authToken || rootStore.staticToken);
156
- embedUrl.searchParams.set("vid", LinkTargetHash(nft.metadata.pack_options[key]));
157
- embedUrl.searchParams.set("ap", "");
158
-
159
- if (!key.startsWith("reveal")) {
160
- embedUrl.searchParams.set("m", "");
161
- embedUrl.searchParams.set("lp", "");
162
- }
163
-
164
- nft.metadata.pack_options["".concat(key, "_embed_url")] = embedUrl.toString();
165
- } // eslint-disable-next-line no-empty
166
-
167
- } catch (error) {}
168
- });
169
- return nft;
170
- };
171
-
172
- exports.FormatNFTMetadata = FormatNFTMetadata;
173
-
174
- exports.FormatNFT = function (item) {
175
- return FormatNFTMetadata(FormatNFTDetails(item));
176
- };
177
-
178
- exports.LinkTargetHash = function (link) {
179
- if (!link) {
180
- return;
181
- }
182
-
183
- if (link["."] && link["."].source) {
184
- return link["."].source;
185
- }
186
-
187
- if (link["/"] && link["/"].startsWith("/qfab/")) {
188
- return link["/"].split("/").find(function (segment) {
189
- return segment.startsWith("hq__");
190
- });
191
- }
192
-
193
- if (link["."] && link["."].container) {
194
- return link["."].container;
195
- }
196
- }; // https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
197
-
198
-
199
- var Popup = function Popup(_ref) {
200
- var url = _ref.url,
201
- title = _ref.title,
202
- w = _ref.w,
203
- h = _ref.h;
204
- // Fixes dual-screen position
205
- var dualScreenLeft = window.screenLeft || window.screenX;
206
- var dualScreenTop = window.screenTop || window.screenY;
207
- var width = window.innerWidth || document.documentElement.clientWidth || screen.width;
208
- var height = window.innerHeight || document.documentElement.clientHeight || screen.height;
209
- var systemZoom = width / window.screen.availWidth;
210
- var left = (width - w) / 2 / systemZoom + dualScreenLeft;
211
- var top = (height - h) / 2 / systemZoom + dualScreenTop;
212
- var newWindow = window.open(url, title, "\n width=".concat(w / systemZoom, ",\n height=").concat(h / systemZoom, ",\n top=").concat(top, ",\n left=").concat(left, "\n "));
213
- if (window.focus) newWindow.focus();
214
- return newWindow;
215
- };
216
-
217
- exports.ActionPopup = function _callee3(_ref2) {
218
- var _ref2$mode, mode, url, onMessage, onCancel;
219
-
220
- return _regeneratorRuntime.async(function _callee3$(_context3) {
221
- while (1) {
222
- switch (_context3.prev = _context3.next) {
223
- case 0:
224
- _ref2$mode = _ref2.mode, mode = _ref2$mode === void 0 ? "tab" : _ref2$mode, url = _ref2.url, onMessage = _ref2.onMessage, onCancel = _ref2.onCancel;
225
- _context3.next = 3;
226
- return _regeneratorRuntime.awrap(new Promise(function (resolve) {
227
- var newWindow = mode === "popup" ? Popup({
228
- url: url,
229
- title: "Eluvio Media Wallet",
230
- w: 500,
231
- h: 850
232
- }) : window.open(url);
233
- var closeCheck = setInterval(function _callee() {
234
- return _regeneratorRuntime.async(function _callee$(_context) {
235
- while (1) {
236
- switch (_context.prev = _context.next) {
237
- case 0:
238
- if (!newWindow.closed) {
239
- _context.next = 6;
240
- break;
241
- }
242
-
243
- clearInterval(closeCheck);
244
-
245
- if (!onCancel) {
246
- _context.next = 5;
247
- break;
248
- }
249
-
250
- _context.next = 5;
251
- return _regeneratorRuntime.awrap(onCancel());
252
-
253
- case 5:
254
- resolve();
255
-
256
- case 6:
257
- case "end":
258
- return _context.stop();
259
- }
260
- }
261
- });
262
- }, 500);
263
- window.addEventListener("message", function _callee2(event) {
264
- return _regeneratorRuntime.async(function _callee2$(_context2) {
265
- while (1) {
266
- switch (_context2.prev = _context2.next) {
267
- case 0:
268
- _context2.next = 2;
269
- return _regeneratorRuntime.awrap(onMessage(event, function () {
270
- clearInterval(closeCheck);
271
- newWindow.close();
272
- resolve();
273
- }));
274
-
275
- case 2:
276
- case "end":
277
- return _context2.stop();
278
- }
279
- }
280
- });
281
- });
282
- }));
283
-
284
- case 3:
285
- case "end":
286
- return _context3.stop();
287
- }
288
- }
289
- });
290
- };