udxcms 1.0.14 → 1.0.16

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,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,23 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.EventBus = exports.shareUtils = exports.getFee = exports.getWalletCoinFee = exports.commify = exports.filterL2Balance = exports.getDecimals = exports.setDecimals = exports.formatArrStringNum = exports.formatStringNum = exports.numDecimals = exports.numberFormat = exports.addZoreFormat = exports.decimalFunc = exports.formatNumber = exports.formatFiatCommify = exports.toRound = exports.formatTokenCommify = exports.getHashBlockUrl = exports.getExplorer = exports.accAddSub = exports.accDiv = exports.accMul = exports.formatAccount = exports.checkEthAddress = exports.formatDateDecimal = exports.formDataEthers = exports.getStyleObj = exports.isInIsWalletApp = exports.isMobile = exports.getTradeDefaultChainId = exports.getQueryChainId = exports.getMarketApi = exports.toUpperDataKey = exports.getChainLayer2Config = exports.getLayer1RpcUrl = exports.getChainId = exports.isPhone = exports.copyText = exports.getAreaCode = exports.getToken = exports.emitLoading = exports.refreshEvents = exports.emitEvents = exports.onEvents = exports.isUserCenter = exports.formatUTCTime = exports.getUTCTime = exports.getTimeZone = exports.AccountForm = void 0;
16
- exports.unwrapJSONStr = exports.pdf = exports.parse = exports.http = exports.connect = exports.blockies = exports.axiosRetry = exports.apiEvent = exports.Storage = exports.Session = void 0;
17
- exports.calcDotDeal = calcDotDeal;
18
- exports.loadImportCacheScript = loadImportCacheScript;
19
- exports.loadImportScript = loadImportScript;
20
- const clipboard_copy_1 = __importDefault(require("clipboard-copy"));
21
- const ethers_1 = require("ethers");
22
- const dayjs_1 = __importDefault(require("dayjs"));
23
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
24
- const index_1 = __importDefault(require("../config/index"));
25
- const parse_1 = require("./parse");
26
- Object.defineProperty(exports, "unwrapJSONStr", { enumerable: true, get: function () { return parse_1.unwrapJSONStr; } });
27
- const AccountForm = (account, accountType) => {
10
+ import copy from "clipboard-copy";
11
+ import { ethers, utils } from 'ethers';
12
+ import dayjs from 'dayjs';
13
+ import BNP from "bignumber.js";
14
+ import conf from '../config/index';
15
+ import { unwrapJSONStr } from "./parse";
16
+ export const AccountForm = (account, accountType) => {
28
17
  let AccArr = account.split("");
29
18
  if (accountType === "Phone") {
30
19
  let len = AccArr.length;
@@ -66,7 +55,6 @@ const AccountForm = (account, accountType) => {
66
55
  ;
67
56
  return AccArr.join("");
68
57
  };
69
- exports.AccountForm = AccountForm;
70
58
  /**
71
59
  * @name: calc dots repalce nums
72
60
  * @test: ●●●●●●● ●●●●●323q● 22323qw
@@ -75,7 +63,7 @@ exports.AccountForm = AccountForm;
75
63
  * @return {*}
76
64
  */
77
65
  const TEMPSAVEDATASPACE = {};
78
- function calcDotDeal(val, resVal, sign = "●") {
66
+ export function calcDotDeal(val, resVal, sign = "●") {
79
67
  let start = "";
80
68
  let replaceArr = "";
81
69
  let end = 0;
@@ -89,7 +77,7 @@ function calcDotDeal(val, resVal, sign = "●") {
89
77
  }
90
78
  return start + replaceArr + (end > 0 ? resVal.slice(-end) : "");
91
79
  }
92
- function loadImportCacheScript(src, callback, saveKey) {
80
+ export function loadImportCacheScript(src, callback, saveKey) {
93
81
  return __awaiter(this, void 0, void 0, function* () {
94
82
  return new Promise((resolve, reject) => {
95
83
  var loadScriptArr = document.getElementsByTagName('script');
@@ -119,7 +107,7 @@ function loadImportCacheScript(src, callback, saveKey) {
119
107
  });
120
108
  });
121
109
  }
122
- const getTimeZone = () => {
110
+ export const getTimeZone = () => {
123
111
  let offset = new Date().getTimezoneOffset();
124
112
  if (offset != 0) {
125
113
  let symbol = Math.abs(offset) === offset ? "-" : "+";
@@ -131,42 +119,34 @@ const getTimeZone = () => {
131
119
  return "GMT+0";
132
120
  }
133
121
  };
134
- exports.getTimeZone = getTimeZone;
135
- const getUTCTime = (d1) => {
122
+ export const getUTCTime = (d1) => {
136
123
  return new Date(d1.getUTCFullYear(), d1.getUTCMonth(), d1.getUTCDate(), d1.getUTCHours(), d1.getUTCMinutes(), d1.getUTCSeconds()).getTime();
137
124
  };
138
- exports.getUTCTime = getUTCTime;
139
- const formatUTCTime = (date) => {
125
+ export const formatUTCTime = (date) => {
140
126
  try {
141
- return dayjs_1.default.utc(date).format('YYYY-MM-DD HH:mm:ss UTC');
127
+ return dayjs.utc(date).format('YYYY-MM-DD HH:mm:ss UTC');
142
128
  }
143
129
  catch (error) {
144
130
  return null;
145
131
  }
146
132
  };
147
- exports.formatUTCTime = formatUTCTime;
148
- const isUserCenter = () => {
133
+ export const isUserCenter = () => {
149
134
  let configType = (site_config && site_config.centralization_type) || "";
150
135
  return configType == "CENTRALIZATION";
151
136
  };
152
- exports.isUserCenter = isUserCenter;
153
- const onEvents = (type, fn) => {
137
+ export const onEvents = (type, fn) => {
154
138
  $Vue.$bus.$on(type, fn);
155
139
  };
156
- exports.onEvents = onEvents;
157
- const emitEvents = (type, args) => {
140
+ export const emitEvents = (type, args) => {
158
141
  $Vue.$bus.$emit(type, args);
159
142
  };
160
- exports.emitEvents = emitEvents;
161
- const refreshEvents = (events) => {
143
+ export const refreshEvents = (events) => {
162
144
  $Vue && $Vue.$bus.$emit("refresh", events);
163
145
  };
164
- exports.refreshEvents = refreshEvents;
165
- const emitLoading = (obj) => {
146
+ export const emitLoading = (obj) => {
166
147
  $Vue && $Vue.$bus.$emit("linkLoading", obj);
167
148
  };
168
- exports.emitLoading = emitLoading;
169
- function loadImportScript(src, callback, saveKey) {
149
+ export function loadImportScript(src, callback, saveKey) {
170
150
  return __awaiter(this, void 0, void 0, function* () {
171
151
  return new Promise((resolve, reject) => {
172
152
  var loadScriptArr = document.getElementsByTagName('script');
@@ -197,36 +177,32 @@ function loadImportScript(src, callback, saveKey) {
197
177
  });
198
178
  });
199
179
  }
200
- const getToken = () => {
180
+ export const getToken = () => {
201
181
  const token = localStorage.getItem("token");
202
182
  if (token) {
203
183
  return token;
204
184
  }
205
185
  return null;
206
186
  };
207
- exports.getToken = getToken;
208
- const getAreaCode = () => {
187
+ export const getAreaCode = () => {
209
188
  const areaCode = sessionStorage.getItem("userAreaCode");
210
189
  if (areaCode) {
211
190
  return areaCode;
212
191
  }
213
192
  return null;
214
193
  };
215
- exports.getAreaCode = getAreaCode;
216
194
  /**
217
195
  *
218
196
  * @param {*} text 复制的内容
219
197
  */
220
- const copyText = (text, e) => {
221
- (0, clipboard_copy_1.default)(text);
198
+ export const copyText = (text, e) => {
199
+ copy(text);
222
200
  return true;
223
201
  };
224
- exports.copyText = copyText;
225
- const isPhone = () => {
202
+ export const isPhone = () => {
226
203
  return navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i);
227
204
  };
228
- exports.isPhone = isPhone;
229
- const getChainId = function () {
205
+ export const getChainId = function () {
230
206
  let chainId = window.ethereum && window.ethereum.chainId || localStorage.getItem('networkId') || '';
231
207
  if (!chainId) {
232
208
  if (window.site_config) {
@@ -243,7 +219,6 @@ const getChainId = function () {
243
219
  // console.log('getChainId:', chainId);
244
220
  return parseInt(chainId);
245
221
  };
246
- exports.getChainId = getChainId;
247
222
  // export const getChainLayer2Config = function(chainId = 4) {
248
223
  // let layer2Config = {}
249
224
  // if (window.site_config) {
@@ -256,7 +231,7 @@ exports.getChainId = getChainId;
256
231
  // }
257
232
  // return layer2Config
258
233
  // }
259
- const getLayer1RpcUrl = function (chainId) {
234
+ export const getLayer1RpcUrl = function (chainId) {
260
235
  let netWroks = [];
261
236
  chainId = chainId && parseInt(chainId) || '';
262
237
  if (window.site_config) {
@@ -280,14 +255,13 @@ const getLayer1RpcUrl = function (chainId) {
280
255
  return chainId && (v.sub_type + chainId == v.subkey) || !chainId;
281
256
  });
282
257
  };
283
- exports.getLayer1RpcUrl = getLayer1RpcUrl;
284
- const getChainLayer2Config = function (chainId = 4) {
258
+ export const getChainLayer2Config = function (chainId = 4) {
285
259
  let layer2Config = {};
286
260
  if (window.site_config) {
287
261
  try {
288
262
  chainId = chainId && parseInt(chainId) || '';
289
263
  let layer2_config = window.site_config['layer2_list'];
290
- let layer1_config = (0, exports.getLayer1RpcUrl)(chainId);
264
+ let layer1_config = getLayer1RpcUrl(chainId);
291
265
  let layer2ConfigArr = layer2_config && layer2_config.length && JSON.parse(layer2_config);
292
266
  layer2ConfigArr.map(v => {
293
267
  let layer2_key = Object.keys(v)[0];
@@ -303,15 +277,13 @@ const getChainLayer2Config = function (chainId = 4) {
303
277
  }
304
278
  return layer2Config;
305
279
  };
306
- exports.getChainLayer2Config = getChainLayer2Config;
307
- const toUpperDataKey = item => {
280
+ export const toUpperDataKey = item => {
308
281
  let resItem = item.replace(/\_(\w)/g, function (a, b) {
309
282
  return b.toUpperCase();
310
283
  });
311
284
  return resItem;
312
285
  };
313
- exports.toUpperDataKey = toUpperDataKey;
314
- const getMarketApi = function (chainId, connectType = "market_api", apiType) {
286
+ export const getMarketApi = function (chainId, connectType = "market_api", apiType) {
315
287
  const store = window.$Vue.$store;
316
288
  apiType = apiType || 'api';
317
289
  if (connectType == 'perpetual') {
@@ -325,7 +297,7 @@ const getMarketApi = function (chainId, connectType = "market_api", apiType) {
325
297
  }
326
298
  let marketApi = '';
327
299
  try {
328
- let config = store.state.siteConfig[connectType] || store.state.siteConfig[(0, exports.toUpperDataKey)(connectType)];
300
+ let config = store.state.siteConfig[connectType] || store.state.siteConfig[toUpperDataKey(connectType)];
329
301
  let marketSettingObj = config && config.length && typeof config == 'string' && JSON.parse(config) || config || {};
330
302
  marketApi = marketSettingObj[chainId] || marketSettingObj['0'] || '';
331
303
  }
@@ -334,27 +306,24 @@ const getMarketApi = function (chainId, connectType = "market_api", apiType) {
334
306
  }
335
307
  return marketApi;
336
308
  };
337
- exports.getMarketApi = getMarketApi;
338
- const getQueryChainId = function (isMarketType) {
309
+ export const getQueryChainId = function (isMarketType) {
339
310
  const store = window.$Vue.$store;
340
311
  let resChainId;
341
312
  let multiChainId = localStorage.getItem('isMultiChains'); // 0 isnot multiChain, !0 mutiCHain
342
313
  let isPerpetual = store.state.trade.tradeMode == 'perpetual'; // 是否是永续,永续暂时不支持多练聚合
343
- if (((0, exports.isPhone)() || multiChainId * 1) && isMarketType && !isPerpetual) {
314
+ if ((isPhone() || multiChainId * 1) && isMarketType && !isPerpetual) {
344
315
  resChainId = '0';
345
316
  }
346
317
  else {
347
- resChainId = (0, exports.getTradeDefaultChainId)();
318
+ resChainId = getTradeDefaultChainId();
348
319
  }
349
320
  return resChainId;
350
321
  };
351
- exports.getQueryChainId = getQueryChainId;
352
- const getTradeDefaultChainId = function () {
322
+ export const getTradeDefaultChainId = function () {
353
323
  const store = window.$Vue.$store;
354
324
  return store.state.chainId;
355
325
  };
356
- exports.getTradeDefaultChainId = getTradeDefaultChainId;
357
- const isMobile = () => {
326
+ export const isMobile = () => {
358
327
  let isMobile = false;
359
328
  if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
360
329
  // console.log('移动端');
@@ -365,37 +334,35 @@ const isMobile = () => {
365
334
  }
366
335
  return isMobile;
367
336
  };
368
- exports.isMobile = isMobile;
369
- const isInIsWalletApp = () => {
337
+ export const isInIsWalletApp = () => {
370
338
  return navigator.userAgent.includes('isWallet');
371
339
  };
372
- exports.isInIsWalletApp = isInIsWalletApp;
373
- const getStyleObj = (pageName, keyStr) => {
340
+ export const getStyleObj = (pageName, keyStr) => {
374
341
  // let styleArrStr = ['commonConf', 'commonHeader', 'styleConf', 'indexStyleList'].join(',')
375
342
  let resObj = {};
376
343
  theme_config.map(v => {
377
344
  v.pageList.map(component => {
378
345
  component.configList.map(config => {
379
346
  if (component.pageKey == 'common' && config.componentsKey == 'common_conf') {
380
- let commonConf = (0, parse_1.unwrapJSONStr)(config.config) || {};
347
+ let commonConf = unwrapJSONStr(config.config) || {};
381
348
  if (!!~keyStr.indexOf('commonConf')) {
382
349
  resObj['commonConf'] = commonConf;
383
350
  }
384
351
  }
385
352
  if (component.pageKey == 'common' && config.componentsKey.startsWith('header')) {
386
- let commonHeader = (0, parse_1.unwrapJSONStr)(config.config) || {};
353
+ let commonHeader = unwrapJSONStr(config.config) || {};
387
354
  if (!!~keyStr.indexOf('commonHeader')) {
388
355
  resObj['commonHeader'] = commonHeader;
389
356
  }
390
357
  }
391
358
  if (component.pageKey == pageName && pageName != 'home' && config.componentsKey.startsWith('header')) {
392
- let styleConf = (0, parse_1.unwrapJSONStr)(config.config);
359
+ let styleConf = unwrapJSONStr(config.config);
393
360
  if (!!~keyStr.indexOf('styleConf')) {
394
361
  resObj['styleConf'] = styleConf;
395
362
  }
396
363
  }
397
364
  else if (component.pageKey == pageName && pageName == 'home' && config.componentsKey == 'common_conf' && component.pageKey == 'home') {
398
- let indexStyleList = (0, parse_1.unwrapJSONStr)(config.config).headerStyleSet || [];
365
+ let indexStyleList = unwrapJSONStr(config.config).headerStyleSet || [];
399
366
  let styleConf = indexStyleList[0];
400
367
  if (!!~keyStr.indexOf('styleConf')) {
401
368
  resObj['styleConf'] = styleConf;
@@ -410,19 +377,17 @@ const getStyleObj = (pageName, keyStr) => {
410
377
  // console.log('resObj', resObj)
411
378
  return resObj;
412
379
  };
413
- exports.getStyleObj = getStyleObj;
414
- const formDataEthers = (val, decimal) => {
415
- return ethers_1.ethers.utils.formatUnits(val.toString(), decimal || 18);
380
+ export const formDataEthers = (val, decimal) => {
381
+ return ethers.utils.formatUnits(val.toString(), decimal || 18);
416
382
  };
417
- exports.formDataEthers = formDataEthers;
418
- const formatDateDecimal = (num = 0, decimal = 2, zoreFalse = 0) => {
383
+ export const formatDateDecimal = (num = 0, decimal = 2, zoreFalse = 0) => {
419
384
  if (!num && num !== 0)
420
385
  return num;
421
- let initVal = (0, exports.decimalFunc)(num, decimal);
386
+ let initVal = decimalFunc(num, decimal);
422
387
  if (!Number(initVal) && decimal < 6)
423
- initVal = (0, exports.decimalFunc)(num, 6);
388
+ initVal = decimalFunc(num, 6);
424
389
  if (!Number(initVal) && decimal < 10)
425
- initVal = (0, exports.decimalFunc)(num, 10);
390
+ initVal = decimalFunc(num, 10);
426
391
  let reg = initVal.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
427
392
  initVal = initVal.replace(reg, '$1,');
428
393
  if (!zoreFalse) {
@@ -433,14 +398,13 @@ const formatDateDecimal = (num = 0, decimal = 2, zoreFalse = 0) => {
433
398
  }
434
399
  return initVal;
435
400
  };
436
- exports.formatDateDecimal = formatDateDecimal;
437
- const checkEthAddress = function (address) {
401
+ export const checkEthAddress = function (address) {
438
402
  if (!address || (address && !address.startsWith("0x"))) {
439
403
  return "address must start with '0x'";
440
404
  }
441
405
  else {
442
406
  try {
443
- let addressBytes = ethers_1.utils.arrayify(address);
407
+ let addressBytes = utils.arrayify(address);
444
408
  if (addressBytes.length !== 20) {
445
409
  return "Address must be 20 bytes long";
446
410
  }
@@ -451,13 +415,11 @@ const checkEthAddress = function (address) {
451
415
  return "";
452
416
  }
453
417
  };
454
- exports.checkEthAddress = checkEthAddress;
455
- const formatAccount = function (value) {
456
- return exports.checkEthAddress && !(0, exports.checkEthAddress)(value) && (value.length > 10 && (value.slice(0, 4) + "******" + value.slice(-4, value.length)) || value) || value;
418
+ export const formatAccount = function (value) {
419
+ return checkEthAddress && !checkEthAddress(value) && (value.length > 10 && (value.slice(0, 4) + "******" + value.slice(-4, value.length)) || value) || value;
457
420
  };
458
- exports.formatAccount = formatAccount;
459
421
  // trade-utils ----===---
460
- const accMul = function accMul(arg1, arg2) {
422
+ export const accMul = function accMul(arg1, arg2) {
461
423
  var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
462
424
  try {
463
425
  m += s1.split(".")[1].length;
@@ -469,8 +431,7 @@ const accMul = function accMul(arg1, arg2) {
469
431
  catch (e) { }
470
432
  return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
471
433
  };
472
- exports.accMul = accMul;
473
- const accDiv = function accDiv(arg1, arg2) {
434
+ export const accDiv = function accDiv(arg1, arg2) {
474
435
  var t1 = 0, t2 = 0, r1, r2;
475
436
  try {
476
437
  t1 = arg1.toString().split(".")[1].length;
@@ -484,8 +445,7 @@ const accDiv = function accDiv(arg1, arg2) {
484
445
  r2 = Number(arg2.toString().replace(".", ""));
485
446
  return (r1 / r2) * Math.pow(10, t2 - t1);
486
447
  };
487
- exports.accDiv = accDiv;
488
- const accAddSub = function (arg1, arg2, sign) {
448
+ export const accAddSub = function (arg1, arg2, sign) {
489
449
  var r1, r2, m, n;
490
450
  try {
491
451
  r1 = arg1.toString().split(".")[1].length;
@@ -508,12 +468,10 @@ const accAddSub = function (arg1, arg2, sign) {
508
468
  return ((arg1 * m - arg2 * m) / m).toFixed(n);
509
469
  }
510
470
  };
511
- exports.accAddSub = accAddSub;
512
- const getExplorer = function (chainId) {
471
+ export const getExplorer = function (chainId) {
513
472
  return chainId == 4 ? 'rinkeby' : 'vm';
514
473
  };
515
- exports.getExplorer = getExplorer;
516
- const getHashBlockUrl = (hash = '', chainId, layer) => {
474
+ export const getHashBlockUrl = (hash = '', chainId, layer) => {
517
475
  const store = window.$Vue.$store;
518
476
  const url = store.getters.filterNetworkItem(chainId, layer).blockExplorerUrl;
519
477
  if (url) {
@@ -526,18 +484,17 @@ const getHashBlockUrl = (hash = '', chainId, layer) => {
526
484
  return blockUrl + `tx/${txid}`;
527
485
  }
528
486
  };
529
- exports.getHashBlockUrl = getHashBlockUrl;
530
487
  /**
531
488
  * 格式化Token,向下取(截取)
532
489
  * 返回示例:1,000.0, 1,000.1234
533
490
  * @param {*} value // unit:ether
534
491
  * @param {*} dp // 显示精度
535
492
  */
536
- const formatTokenCommify = (value, dp = 0, addSuffixZero = true) => {
493
+ export const formatTokenCommify = (value, dp = 0, addSuffixZero = true) => {
537
494
  if (!value)
538
495
  return value;
539
496
  const arr = value.toString().split(".");
540
- let result = ethers_1.utils.commify(arr[0]);
497
+ let result = utils.commify(arr[0]);
541
498
  result += ".";
542
499
  if (arr.length > 1 && dp > 0) {
543
500
  result += arr[1].substr(0, dp);
@@ -547,38 +504,34 @@ const formatTokenCommify = (value, dp = 0, addSuffixZero = true) => {
547
504
  }
548
505
  return result;
549
506
  };
550
- exports.formatTokenCommify = formatTokenCommify;
551
- const toRound = (value, ratio = 2) => {
507
+ export const toRound = (value, ratio = 2) => {
552
508
  if (value === null)
553
509
  return null;
554
510
  const base = Math.pow(10, ratio);
555
- return new bignumber_js_1.default(value).times(base).integerValue(bignumber_js_1.default.ROUND_HALF_UP).div(base).toString();
511
+ return new BNP(value).times(base).integerValue(BNP.ROUND_HALF_UP).div(base).toString();
556
512
  };
557
- exports.toRound = toRound;
558
513
  /**
559
514
  * 格式化法币价格/金额(四舍五入)
560
515
  * 默认是格式化为10位。
561
516
  * @param {*} value
562
517
  * @param {Number} dp 显示精度
563
518
  */
564
- const formatFiatCommify = (value, dp = 10) => {
519
+ export const formatFiatCommify = (value, dp = 10) => {
565
520
  if (!value)
566
521
  return value;
567
- let result = (0, exports.toRound)(value, dp);
522
+ let result = toRound(value, dp);
568
523
  // 格式化整数(逗号分割)
569
524
  const arr = result.toString().split(".");
570
- let integerStr = ethers_1.utils.commify(arr[0]);
525
+ let integerStr = utils.commify(arr[0]);
571
526
  let mantissa = arr[1] || '0';
572
527
  return integerStr + "." + mantissa;
573
528
  };
574
- exports.formatFiatCommify = formatFiatCommify;
575
- const formatNumber = function (val, decimal) {
529
+ export const formatNumber = function (val, decimal) {
576
530
  let reg = new RegExp(`^(\\d+)\\.(\\d{0,${decimal}}).*$`);
577
531
  val = val.toString().replace(reg, '$1.$2');
578
532
  return val;
579
533
  };
580
- exports.formatNumber = formatNumber;
581
- const decimalFunc = function (val, decimal = 2) {
534
+ export const decimalFunc = function (val, decimal = 2) {
582
535
  let sign = val * 1 < 0;
583
536
  val = Math.abs(val);
584
537
  let reg = new RegExp(`^(\\d+)\\.(\\d{0,${decimal}}).*$`);
@@ -587,17 +540,15 @@ const decimalFunc = function (val, decimal = 2) {
587
540
  let resVal = sign ? '-' + val : val;
588
541
  return resVal;
589
542
  };
590
- exports.decimalFunc = decimalFunc;
591
- const addZoreFormat = function (demical) {
543
+ export const addZoreFormat = function (demical) {
592
544
  var zoreInit = "0";
593
545
  return zoreInit + "." + zoreInit.repeat(demical);
594
546
  };
595
- exports.addZoreFormat = addZoreFormat;
596
547
  // 默认去掉0
597
- const numberFormat = function (num, demical = 0, isZero = true) {
548
+ export const numberFormat = function (num, demical = 0, isZero = true) {
598
549
  // console.log('numberFormat num, demical:',num, demical);
599
550
  if ((!num || !(num * 1)) && !isZero) {
600
- return (0, exports.addZoreFormat)(demical);
551
+ return addZoreFormat(demical);
601
552
  }
602
553
  else {
603
554
  num = (!isZero ? Number(num).toFixed(demical) + '' : Number(num).toFixed(demical) * 1) + "";
@@ -606,8 +557,7 @@ const numberFormat = function (num, demical = 0, isZero = true) {
606
557
  return num.replace(reg, "$1,");
607
558
  }
608
559
  };
609
- exports.numberFormat = numberFormat;
610
- const numDecimals = function (val, decimals, zeroDecimals = 1) {
560
+ export const numDecimals = function (val, decimals, zeroDecimals = 1) {
611
561
  let dealVal = (val * 1).toFixed(decimals) * 1;
612
562
  let zero = '0'.repeat(zeroDecimals);
613
563
  if (dealVal != val * 1) {
@@ -615,15 +565,14 @@ const numDecimals = function (val, decimals, zeroDecimals = 1) {
615
565
  }
616
566
  return !!~(dealVal + '').indexOf('.') ? dealVal : (dealVal + '.' + zero);
617
567
  };
618
- exports.numDecimals = numDecimals;
619
- const formatStringNum = (num = 0, decimal = 2, zoreFalse = 0) => {
568
+ export const formatStringNum = (num = 0, decimal = 2, zoreFalse = 0) => {
620
569
  if (!num && num !== 0)
621
570
  return num;
622
- let initVal = (0, exports.decimalFunc)(num, decimal);
571
+ let initVal = decimalFunc(num, decimal);
623
572
  if (!Number(initVal) && decimal < 6)
624
- initVal = (0, exports.decimalFunc)(num, 6);
573
+ initVal = decimalFunc(num, 6);
625
574
  if (!Number(initVal) && decimal < 10)
626
- initVal = (0, exports.decimalFunc)(num, 10);
575
+ initVal = decimalFunc(num, 10);
627
576
  let reg = initVal.indexOf('.') > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
628
577
  // let reg = /(\d)(?=(?:\d{3})+$)/g
629
578
  initVal = parseFloat(initVal) + '';
@@ -636,8 +585,7 @@ const formatStringNum = (num = 0, decimal = 2, zoreFalse = 0) => {
636
585
  }
637
586
  return initVal;
638
587
  };
639
- exports.formatStringNum = formatStringNum;
640
- const formatArrStringNum = function (num) {
588
+ export const formatArrStringNum = function (num) {
641
589
  num = num + '';
642
590
  if (num.indexOf('.') == -1) {
643
591
  return [num, 1];
@@ -646,12 +594,11 @@ const formatArrStringNum = function (num) {
646
594
  let decimal = num.split('.')[1].length;
647
595
  // return [num * Math.pow(10, decimal), 1 * Math.pow(10, decimal)]
648
596
  const a2 = Math.pow(10, decimal);
649
- const a1 = new bignumber_js_1.default(num).times(a2).toNumber();
597
+ const a1 = new BNP(num).times(a2).toNumber();
650
598
  return [a1, a2];
651
599
  }
652
600
  };
653
- exports.formatArrStringNum = formatArrStringNum;
654
- const setDecimals = function (name, value) {
601
+ export const setDecimals = function (name, value) {
655
602
  let decimalsArr = {};
656
603
  try {
657
604
  decimalsArr = JSON.parse(localStorage.getItem('decimalsArr'));
@@ -664,8 +611,7 @@ const setDecimals = function (name, value) {
664
611
  decimalsArr[name] = value;
665
612
  localStorage.setItem('decimalsArr', JSON.stringify(decimalsArr));
666
613
  };
667
- exports.setDecimals = setDecimals;
668
- const getDecimals = function (name) {
614
+ export const getDecimals = function (name) {
669
615
  let decimalsArr = {};
670
616
  try {
671
617
  decimalsArr = JSON.parse(localStorage.getItem('decimalsArr'));
@@ -675,12 +621,11 @@ const getDecimals = function (name) {
675
621
  return [];
676
622
  }
677
623
  };
678
- exports.getDecimals = getDecimals;
679
624
  /**
680
625
  * 获取金额
681
626
  * data: {committed,available,locked}
682
627
  */
683
- const filterL2Balance = (data, type, symbol) => {
628
+ export const filterL2Balance = (data, type, symbol) => {
684
629
  if (!data)
685
630
  return null;
686
631
  if (Object.prototype.toString.call(data) !== "[object Object]")
@@ -691,24 +636,22 @@ const filterL2Balance = (data, type, symbol) => {
691
636
  return null;
692
637
  return data[type]['balances'][symbol];
693
638
  };
694
- exports.filterL2Balance = filterL2Balance;
695
- const commify = (value) => {
639
+ export const commify = (value) => {
696
640
  if (value === null)
697
641
  return null;
698
642
  if (value === "+∞")
699
643
  return "+∞";
700
644
  if (value.toString().includes("e"))
701
645
  return value;
702
- return ethers_1.utils.commify(value);
646
+ return utils.commify(value);
703
647
  };
704
- exports.commify = commify;
705
648
  // trade---
706
- const getWalletCoinFee = function (transfer, fn) {
649
+ export const getWalletCoinFee = function (transfer, fn) {
707
650
  return __awaiter(this, void 0, void 0, function* () {
708
651
  let syncWallet = transfer.syncWallet || $Vue && $Vue.walletData.getSyncWallet();
709
652
  let provider = syncWallet.provider;
710
653
  if (provider) {
711
- const fullFee = yield provider.getTransactionFee('Transfer', transfer.address, index_1.default.getFeeType || transfer.token);
654
+ const fullFee = yield provider.getTransactionFee('Transfer', transfer.address, conf.getFeeType || transfer.token);
712
655
  transfer.fee = fullFee.totalFee;
713
656
  fn && fn(transfer.fee);
714
657
  }
@@ -717,12 +660,11 @@ const getWalletCoinFee = function (transfer, fn) {
717
660
  }
718
661
  });
719
662
  };
720
- exports.getWalletCoinFee = getWalletCoinFee;
721
- const getFee = function (transfer, fn) {
663
+ export const getFee = function (transfer, fn) {
722
664
  return __awaiter(this, void 0, void 0, function* () {
723
665
  let provider = $Vue && $Vue.walletData.getSyncWallet().provider;
724
666
  if (provider) {
725
- const fullFee = yield provider.getTransactionFee('Transfer', transfer.address, index_1.default.getFeeType || transfer.token);
667
+ const fullFee = yield provider.getTransactionFee('Transfer', transfer.address, conf.getFeeType || transfer.token);
726
668
  transfer.fee = fullFee.totalFee;
727
669
  fn && fn(transfer.fee);
728
670
  }
@@ -731,8 +673,7 @@ const getFee = function (transfer, fn) {
731
673
  }
732
674
  });
733
675
  };
734
- exports.getFee = getFee;
735
- const shareUtils = (type, title) => {
676
+ export const shareUtils = (type, title) => {
736
677
  let dest = {
737
678
  href: '',
738
679
  target: '_blank'
@@ -746,24 +687,14 @@ const shareUtils = (type, title) => {
746
687
  }
747
688
  window.open(dest.href, dest.target);
748
689
  };
749
- exports.shareUtils = shareUtils;
750
- var EventBus_js_1 = require("./EventBus.js");
751
- Object.defineProperty(exports, "EventBus", { enumerable: true, get: function () { return __importDefault(EventBus_js_1).default; } });
752
- var Session_js_1 = require("./Session.js");
753
- Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return __importDefault(Session_js_1).default; } });
754
- var Storage_js_1 = require("./Storage.js");
755
- Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return __importDefault(Storage_js_1).default; } });
756
- var apiEvent_js_1 = require("./apiEvent.js");
757
- Object.defineProperty(exports, "apiEvent", { enumerable: true, get: function () { return __importDefault(apiEvent_js_1).default; } });
758
- var axiosRetry_js_1 = require("./axiosRetry.js");
759
- Object.defineProperty(exports, "axiosRetry", { enumerable: true, get: function () { return __importDefault(axiosRetry_js_1).default; } });
760
- var blockies_js_1 = require("./blockies.js");
761
- Object.defineProperty(exports, "blockies", { enumerable: true, get: function () { return __importDefault(blockies_js_1).default; } });
762
- var connect_js_1 = require("./connect.js");
763
- Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return __importDefault(connect_js_1).default; } });
764
- var http_js_1 = require("./http.js");
765
- Object.defineProperty(exports, "http", { enumerable: true, get: function () { return __importDefault(http_js_1).default; } });
766
- var parse_js_1 = require("./parse.js");
767
- Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return __importDefault(parse_js_1).default; } });
768
- var pdf_js_1 = require("./pdf.js");
769
- Object.defineProperty(exports, "pdf", { enumerable: true, get: function () { return __importDefault(pdf_js_1).default; } });
690
+ export { default as EventBus } from './EventBus.js';
691
+ export { default as Session } from './Session.js';
692
+ export { default as Storage } from './Storage.js';
693
+ export { default as apiEvent } from './apiEvent.js';
694
+ export { default as axiosRetry } from './axiosRetry.js';
695
+ export { default as blockies } from './blockies.js';
696
+ export { default as connect } from './connect.js';
697
+ export { default as http } from './http.js';
698
+ export { default as parse } from './parse.js';
699
+ export { default as pdf } from './pdf.js';
700
+ export { unwrapJSONStr };
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = isMobile;
4
1
  // 判断是否为移动端
5
- function isMobile() {
2
+ export default function isMobile() {
6
3
  let isMobile = false;
7
4
  if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
8
5
  // console.log('移动端');