@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.
@@ -637,6 +637,7 @@ var getSwappedAmount = function getSwappedAmount(tokenInId, tokenOutId, amountIn
637
637
 
638
638
  var REF_WIDGET_STAR_TOKEN_LIST_KEY = 'REF_WIDGET_STAR_TOKEN_LIST_VALUE';
639
639
  var REF_WIDGET_ALL_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_TOKENS_LIST_VALUE';
640
+ var REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY = 'REF_WIDGET_ALL_LIGHT_TOKENS_LIST_VALUE';
640
641
  var REF_WIDGET_SWAP_IN_KEY = 'REF_WIDGET_SWAP_IN_VALUE';
641
642
  var REF_WIDGET_SWAP_OUT_KEY = 'REF_WIDGET_SWAP_OUT_VALUE';
642
643
  var REF_WIDGET_SWAP_DETAIL_KEY = 'REF_WIDGET_SWAP_DETAIL_VALUE';
@@ -787,13 +788,65 @@ var getTokens = /*#__PURE__*/function () {
787
788
  return _ref2.apply(this, arguments);
788
789
  };
789
790
  }();
790
- var getWhiteListTokensIndexer = /*#__PURE__*/function () {
791
- var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(whiteListIds) {
791
+ var getTokensTiny = /*#__PURE__*/function () {
792
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(reload) {
793
+ var storagedTokens;
792
794
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
793
795
  while (1) {
794
796
  switch (_context3.prev = _context3.next) {
795
797
  case 0:
796
- _context3.next = 2;
798
+ storagedTokens = typeof window !== 'undefined' && !reload ? localStorage.getItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY) : null;
799
+ if (!storagedTokens) {
800
+ _context3.next = 5;
801
+ break;
802
+ }
803
+ _context3.t0 = JSON.parse(storagedTokens);
804
+ _context3.next = 8;
805
+ break;
806
+ case 5:
807
+ _context3.next = 7;
808
+ return fetch(config.indexerUrl + '/list-token-v2', {
809
+ method: 'GET',
810
+ headers: {
811
+ 'Content-type': 'application/json; charset=UTF-8'
812
+ }
813
+ }).then(function (res) {
814
+ return res.json();
815
+ }).then(function (tokens) {
816
+ var newTokens = Object.values(tokens).reduce(function (acc, cur, i) {
817
+ var _extends3;
818
+ var id = Object.keys(tokens)[i];
819
+ return _extends({}, acc, (_extends3 = {}, _extends3[id] = _extends({}, cur, {
820
+ id: id
821
+ }), _extends3));
822
+ }, {});
823
+ return newTokens;
824
+ }).then(function (res) {
825
+ typeof window !== 'undefined' && !reload && localStorage.setItem(REF_WIDGET_ALL_LIGHT_TOKENS_LIST_KEY, JSON.stringify(res));
826
+ return res;
827
+ });
828
+ case 7:
829
+ _context3.t0 = _context3.sent;
830
+ case 8:
831
+ return _context3.abrupt("return", _context3.t0);
832
+ case 9:
833
+ case "end":
834
+ return _context3.stop();
835
+ }
836
+ }
837
+ }, _callee3);
838
+ }));
839
+ return function getTokensTiny(_x2) {
840
+ return _ref3.apply(this, arguments);
841
+ };
842
+ }();
843
+ var getWhiteListTokensIndexer = /*#__PURE__*/function () {
844
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(whiteListIds) {
845
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
846
+ while (1) {
847
+ switch (_context4.prev = _context4.next) {
848
+ case 0:
849
+ _context4.next = 2;
797
850
  return fetch(config.indexerUrl + '/list-token', {
798
851
  method: 'GET',
799
852
  headers: {
@@ -803,26 +856,26 @@ var getWhiteListTokensIndexer = /*#__PURE__*/function () {
803
856
  return res.json();
804
857
  }).then(function (res) {
805
858
  return whiteListIds.reduce(function (acc, cur, i) {
806
- var _extends3;
859
+ var _extends4;
807
860
  if (!res[cur] || !Object.values(res[cur]) || Object.values(res[cur]).length === 0) return acc;
808
- return _extends({}, acc, (_extends3 = {}, _extends3[cur] = _extends({}, res[cur], {
861
+ return _extends({}, acc, (_extends4 = {}, _extends4[cur] = _extends({}, res[cur], {
809
862
  id: cur
810
- }), _extends3));
863
+ }), _extends4));
811
864
  }, {});
812
865
  }).then(function (res) {
813
866
  return Object.values(res);
814
867
  });
815
868
  case 2:
816
- return _context3.abrupt("return", _context3.sent);
869
+ return _context4.abrupt("return", _context4.sent);
817
870
  case 3:
818
871
  case "end":
819
- return _context3.stop();
872
+ return _context4.stop();
820
873
  }
821
874
  }
822
- }, _callee3);
875
+ }, _callee4);
823
876
  }));
824
- return function getWhiteListTokensIndexer(_x2) {
825
- return _ref3.apply(this, arguments);
877
+ return function getWhiteListTokensIndexer(_x3) {
878
+ return _ref4.apply(this, arguments);
826
879
  };
827
880
  }();
828
881
 
@@ -3094,7 +3147,7 @@ var estimateSwap = /*#__PURE__*/function () {
3094
3147
  return poolFormatter(p);
3095
3148
  });
3096
3149
  _context2.next = 22;
3097
- return getTokens();
3150
+ return getTokensTiny();
3098
3151
  case 22:
3099
3152
  allTokens = _context2.sent;
3100
3153
  _context2.next = 25;