@ref-finance/ref-sdk 1.3.2 → 1.3.3

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.
@@ -625,6 +625,7 @@
625
625
 
626
626
  var REF_WIDGET_STAR_TOKEN_LIST_KEY = 'REF_WIDGET_STAR_TOKEN_LIST_VALUE';
627
627
  var REF_WIDGET_ALL_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_TOKENS_LIST_VALUE';
628
+ var REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_LIGHT_TOKENS_LIST_VALUE';
628
629
  var REF_WIDGET_SWAP_IN_KEY = 'REF_WIDGET_SWAP_IN_VALUE';
629
630
  var REF_WIDGET_SWAP_OUT_KEY = 'REF_WIDGET_SWAP_OUT_VALUE';
630
631
  var REF_WIDGET_SWAP_DETAIL_KEY = 'REF_WIDGET_SWAP_DETAIL_VALUE';
@@ -775,13 +776,65 @@
775
776
  return _ref2.apply(this, arguments);
776
777
  };
777
778
  }();
778
- var getWhiteListTokensIndexer = /*#__PURE__*/function () {
779
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(whiteListIds) {
779
+ var getTokensTiny = /*#__PURE__*/function () {
780
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(reload) {
781
+ var storagedTokens;
780
782
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
781
783
  while (1) {
782
784
  switch (_context3.prev = _context3.next) {
783
785
  case 0:
784
- _context3.next = 2;
786
+ storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY) : null;
787
+ if (!storagedTokens) {
788
+ _context3.next = 5;
789
+ break;
790
+ }
791
+ _context3.t0 = JSON.parse(storagedTokens);
792
+ _context3.next = 8;
793
+ break;
794
+ case 5:
795
+ _context3.next = 7;
796
+ return fetch(exports.config.indexerUrl + '/list-token-v2', {
797
+ method: 'GET',
798
+ headers: {
799
+ 'Content-type': 'application/json; charset=UTF-8'
800
+ }
801
+ }).then(function (res) {
802
+ return res.json();
803
+ }).then(function (tokens) {
804
+ var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
805
+ var _extends3;
806
+ var id = Object.keys(tokens)[i];
807
+ return _extends({}, acc, (_extends3 = {}, _extends3[id] = _extends({}, cur, {
808
+ id: id
809
+ }), _extends3));
810
+ }, {});
811
+ return newTokens;
812
+ }).then(function (res) {
813
+ typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY, JSON.stringify(res));
814
+ return res;
815
+ });
816
+ case 7:
817
+ _context3.t0 = _context3.sent;
818
+ case 8:
819
+ return _context3.abrupt("return", _context3.t0);
820
+ case 9:
821
+ case "end":
822
+ return _context3.stop();
823
+ }
824
+ }
825
+ }, _callee3);
826
+ }));
827
+ return function getTokensTiny(_x2) {
828
+ return _ref3.apply(this, arguments);
829
+ };
830
+ }();
831
+ var getWhiteListTokensIndexer = /*#__PURE__*/function () {
832
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(whiteListIds) {
833
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
834
+ while (1) {
835
+ switch (_context4.prev = _context4.next) {
836
+ case 0:
837
+ _context4.next = 2;
785
838
  return fetch(exports.config.indexerUrl + '/list-token', {
786
839
  method: 'GET',
787
840
  headers: {
@@ -791,26 +844,26 @@
791
844
  return res.json();
792
845
  }).then(function (res) {
793
846
  return whiteListIds.reduce(function (acc, cur, i) {
794
- var _extends3;
847
+ var _extends4;
795
848
  if (!res[cur] || !Object.values(res[cur]) || Object.values(res[cur]).length === 0) return acc;
796
- return _extends({}, acc, (_extends3 = {}, _extends3[cur] = _extends({}, res[cur], {
849
+ return _extends({}, acc, (_extends4 = {}, _extends4[cur] = _extends({}, res[cur], {
797
850
  id: cur
798
- }), _extends3));
851
+ }), _extends4));
799
852
  }, {});
800
853
  }).then(function (res) {
801
854
  return Object.values(res);
802
855
  });
803
856
  case 2:
804
- return _context3.abrupt("return", _context3.sent);
857
+ return _context4.abrupt("return", _context4.sent);
805
858
  case 3:
806
859
  case "end":
807
- return _context3.stop();
860
+ return _context4.stop();
808
861
  }
809
862
  }
810
- }, _callee3);
863
+ }, _callee4);
811
864
  }));
812
- return function getWhiteListTokensIndexer(_x2) {
813
- return _ref3.apply(this, arguments);
865
+ return function getWhiteListTokensIndexer(_x3) {
866
+ return _ref4.apply(this, arguments);
814
867
  };
815
868
  }();
816
869
 
@@ -3081,7 +3134,7 @@
3081
3134
  return poolFormatter(p);
3082
3135
  });
3083
3136
  _context2.next = 22;
3084
- return getTokens();
3137
+ return getTokensTiny();
3085
3138
  case 22:
3086
3139
  allTokens = _context2.sent;
3087
3140
  _context2.next = 25;