@ref-finance/ref-sdk 1.1.7 → 1.1.9

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,12 +1,11 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('near-api-js'), require('bn.js'), require('fs'), require('os'), require('lodash-es'), require('mathjs'), require('big.js'), require('react'), require('@react-icons/all-files/fi/FiChevronDown'), require('@react-icons/all-files/fi/FiChevronLeft'), require('@react-icons/all-files/fi/FiChevronUp'), require('@react-icons/all-files/fa/FaSearch'), require('@react-icons/all-files/ri/RiRefreshLine'), require('@react-icons/all-files/ti/TiArrowSortedUp'), require('@react-icons/all-files/ti/TiArrowSortedDown'), require('@react-icons/all-files/hi/HiOutlineExternalLink'), require('@react-icons/all-files/ai/AiFillPushpin'), require('@react-icons/all-files/ai/AiOutlinePushpin'), require('@react-icons/all-files/ri/RiExchangeFill'), require('@react-icons/all-files/io5/IoWarning'), require('@react-icons/all-files/io5/IoCloseOutline'), require('@react-icons/all-files/ti/TiWarning'), require('@react-icons/all-files/cg/CgArrowsExchangeAltV')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'near-api-js', 'bn.js', 'fs', 'os', 'lodash-es', 'mathjs', 'big.js', 'react', '@react-icons/all-files/fi/FiChevronDown', '@react-icons/all-files/fi/FiChevronLeft', '@react-icons/all-files/fi/FiChevronUp', '@react-icons/all-files/fa/FaSearch', '@react-icons/all-files/ri/RiRefreshLine', '@react-icons/all-files/ti/TiArrowSortedUp', '@react-icons/all-files/ti/TiArrowSortedDown', '@react-icons/all-files/hi/HiOutlineExternalLink', '@react-icons/all-files/ai/AiFillPushpin', '@react-icons/all-files/ai/AiOutlinePushpin', '@react-icons/all-files/ri/RiExchangeFill', '@react-icons/all-files/io5/IoWarning', '@react-icons/all-files/io5/IoCloseOutline', '@react-icons/all-files/ti/TiWarning', '@react-icons/all-files/cg/CgArrowsExchangeAltV'], factory) :
4
- (global = global || self, factory(global['@ref-finance/ref-sdk'] = {}, global.nearApiJs, global.BN, global.fs, global.os, global._, global.math, global.Big, global.React, global.FiChevronDown, global.FiChevronLeft, global.FiChevronUp, global.FaSearch, global.RiRefreshLine, global.TiArrowSortedUp, global.TiArrowSortedDown, global.HiOutlineExternalLink, global.AiFillPushpin, global.AiOutlinePushpin, global.RiExchangeFill, global.IoWarning, global.IoCloseOutline, global.TiWarning, global.CgArrowsExchangeAltV));
5
- }(this, (function (exports, nearApiJs, BN, fs, os, _, math, Big, React, FiChevronDown, FiChevronLeft, FiChevronUp, FaSearch, RiRefreshLine, TiArrowSortedUp, TiArrowSortedDown, HiOutlineExternalLink, AiFillPushpin, AiOutlinePushpin, RiExchangeFill, IoWarning, IoCloseOutline, TiWarning, CgArrowsExchangeAltV) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('near-api-js'), require('bn.js'), require('fs'), require('lodash-es'), require('mathjs'), require('big.js'), require('react'), require('@react-icons/all-files/fi/FiChevronDown'), require('@react-icons/all-files/fi/FiChevronLeft'), require('@react-icons/all-files/fi/FiChevronUp'), require('@react-icons/all-files/fa/FaSearch'), require('@react-icons/all-files/ri/RiRefreshLine'), require('@react-icons/all-files/ti/TiArrowSortedUp'), require('@react-icons/all-files/ti/TiArrowSortedDown'), require('@react-icons/all-files/hi/HiOutlineExternalLink'), require('@react-icons/all-files/ai/AiFillPushpin'), require('@react-icons/all-files/ai/AiOutlinePushpin'), require('@react-icons/all-files/ri/RiExchangeFill'), require('@react-icons/all-files/io5/IoWarning'), require('@react-icons/all-files/io5/IoCloseOutline'), require('@react-icons/all-files/ti/TiWarning'), require('@react-icons/all-files/cg/CgArrowsExchangeAltV')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'near-api-js', 'bn.js', 'fs', 'lodash-es', 'mathjs', 'big.js', 'react', '@react-icons/all-files/fi/FiChevronDown', '@react-icons/all-files/fi/FiChevronLeft', '@react-icons/all-files/fi/FiChevronUp', '@react-icons/all-files/fa/FaSearch', '@react-icons/all-files/ri/RiRefreshLine', '@react-icons/all-files/ti/TiArrowSortedUp', '@react-icons/all-files/ti/TiArrowSortedDown', '@react-icons/all-files/hi/HiOutlineExternalLink', '@react-icons/all-files/ai/AiFillPushpin', '@react-icons/all-files/ai/AiOutlinePushpin', '@react-icons/all-files/ri/RiExchangeFill', '@react-icons/all-files/io5/IoWarning', '@react-icons/all-files/io5/IoCloseOutline', '@react-icons/all-files/ti/TiWarning', '@react-icons/all-files/cg/CgArrowsExchangeAltV'], factory) :
4
+ (global = global || self, factory(global['@ref-finance/ref-sdk'] = {}, global.nearApiJs, global.BN, global.fs, global._, global.math, global.Big, global.React, global.FiChevronDown, global.FiChevronLeft, global.FiChevronUp, global.FaSearch, global.RiRefreshLine, global.TiArrowSortedUp, global.TiArrowSortedDown, global.HiOutlineExternalLink, global.AiFillPushpin, global.AiOutlinePushpin, global.RiExchangeFill, global.IoWarning, global.IoCloseOutline, global.TiWarning, global.CgArrowsExchangeAltV));
5
+ }(this, (function (exports, nearApiJs, BN, fs, _, math, Big, React, FiChevronDown, FiChevronLeft, FiChevronUp, FaSearch, RiRefreshLine, TiArrowSortedUp, TiArrowSortedDown, HiOutlineExternalLink, AiFillPushpin, AiOutlinePushpin, RiExchangeFill, IoWarning, IoCloseOutline, TiWarning, CgArrowsExchangeAltV) { 'use strict';
6
6
 
7
7
  BN = BN && Object.prototype.hasOwnProperty.call(BN, 'default') ? BN['default'] : BN;
8
8
  fs = fs && Object.prototype.hasOwnProperty.call(fs, 'default') ? fs['default'] : fs;
9
- os = os && Object.prototype.hasOwnProperty.call(os, 'default') ? os['default'] : os;
10
9
  var ___default = 'default' in _ ? _['default'] : _;
11
10
  Big = Big && Object.prototype.hasOwnProperty.call(Big, 'default') ? Big['default'] : Big;
12
11
  var React__default = 'default' in React ? React['default'] : React;
@@ -33,7 +32,7 @@
33
32
  REF_TOKEN_ID: 'token.v2.ref-finance.near',
34
33
  indexerUrl: 'https://indexer.ref.finance',
35
34
  explorerUrl: 'https://testnet.nearblocks.io',
36
- REF_DCL_SWAP_CONTRACT_ID: ''
35
+ REF_DCL_SWAP_CONTRACT_ID: 'dclv2.ref-labs.near'
37
36
  };
38
37
  case 'testnet':
39
38
  return {
@@ -45,7 +44,7 @@
45
44
  REF_FI_CONTRACT_ID: 'ref-finance-101.testnet',
46
45
  REF_TOKEN_ID: 'ref.fakes.testnet',
47
46
  explorerUrl: 'https://testnet.nearblocks.io',
48
- REF_DCL_SWAP_CONTRACT_ID: 'dcl.ref-dev.testnet'
47
+ REF_DCL_SWAP_CONTRACT_ID: 'dclv2-dev.ref-dev.testnet'
49
48
  };
50
49
  default:
51
50
  return {
@@ -57,7 +56,7 @@
57
56
  REF_TOKEN_ID: 'token.v2.ref-finance.near',
58
57
  indexerUrl: 'https://indexer.ref.finance',
59
58
  explorerUrl: 'https://nearblocks.io',
60
- REF_DCL_SWAP_CONTRACT_ID: ''
59
+ REF_DCL_SWAP_CONTRACT_ID: 'dcl.ref-labs.near'
61
60
  };
62
61
  }
63
62
  }
@@ -3642,42 +3641,42 @@
3642
3641
  });
3643
3642
  var getMemorySigner = /*#__PURE__*/function () {
3644
3643
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
3645
- var AccountId, keyPath, homedir, credentials, credentialAccountId, myKeyStore, signer;
3644
+ var AccountId, keyPath, credentials, credentialAccountId, myKeyStore, signer;
3646
3645
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3647
3646
  while (1) {
3648
3647
  switch (_context.prev = _context.next) {
3649
3648
  case 0:
3650
3649
  AccountId = _ref.AccountId, keyPath = _ref.keyPath;
3651
3650
  _context.prev = 1;
3652
- homedir = os.homedir();
3653
- credentials = JSON.parse(fs.readFileSync(homedir + keyPath).toString());
3651
+ // const homedir = os.homedir();
3652
+ credentials = JSON.parse(fs.readFileSync(keyPath).toString());
3654
3653
  credentialAccountId = credentials == null ? void 0 : credentials.account_id;
3655
3654
  if (credentialAccountId) {
3656
- _context.next = 7;
3655
+ _context.next = 6;
3657
3656
  break;
3658
3657
  }
3659
3658
  throw NoCredential;
3660
- case 7:
3659
+ case 6:
3661
3660
  if (!(credentialAccountId !== AccountId)) {
3662
- _context.next = 9;
3661
+ _context.next = 8;
3663
3662
  break;
3664
3663
  }
3665
3664
  throw AccountIdMisMatch;
3666
- case 9:
3665
+ case 8:
3667
3666
  myKeyStore = new nearApiJs.keyStores.InMemoryKeyStore();
3668
3667
  myKeyStore.setKey(getConfig().networkId, AccountId, nearApiJs.KeyPair.fromString(credentials.private_key));
3669
3668
  signer = new nearApiJs.InMemorySigner(myKeyStore);
3670
3669
  return _context.abrupt("return", signer);
3671
- case 15:
3672
- _context.prev = 15;
3670
+ case 14:
3671
+ _context.prev = 14;
3673
3672
  _context.t0 = _context["catch"](1);
3674
3673
  throw _context.t0;
3675
- case 18:
3674
+ case 17:
3676
3675
  case "end":
3677
3676
  return _context.stop();
3678
3677
  }
3679
3678
  }
3680
- }, _callee, null, [[1, 15]]);
3679
+ }, _callee, null, [[1, 14]]);
3681
3680
  }));
3682
3681
  return function getMemorySigner(_x) {
3683
3682
  return _ref2.apply(this, arguments);
@@ -4276,12 +4275,12 @@
4276
4275
  var instantSwap = /*#__PURE__*/function () {
4277
4276
  var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
4278
4277
  var _swapTodos;
4279
- var tokenIn, tokenOut, amountIn, slippageTolerance, swapTodos, AccountId, transactions, registerToken, registered, actionsList, allSwapsTokens, i, swapTokens;
4278
+ var tokenIn, tokenOut, amountIn, slippageTolerance, swapTodos, AccountId, referralId, transactions, registerToken, registered, actionsList, allSwapsTokens, i, swapTokens;
4280
4279
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4281
4280
  while (1) {
4282
4281
  switch (_context2.prev = _context2.next) {
4283
4282
  case 0:
4284
- tokenIn = _ref.tokenIn, tokenOut = _ref.tokenOut, amountIn = _ref.amountIn, slippageTolerance = _ref.slippageTolerance, swapTodos = _ref.swapTodos, AccountId = _ref.AccountId;
4283
+ tokenIn = _ref.tokenIn, tokenOut = _ref.tokenOut, amountIn = _ref.amountIn, slippageTolerance = _ref.slippageTolerance, swapTodos = _ref.swapTodos, AccountId = _ref.AccountId, referralId = _ref.referralId;
4285
4284
  transactions = [];
4286
4285
  if (!((swapTodos == null ? void 0 : (_swapTodos = swapTodos[(swapTodos == null ? void 0 : swapTodos.length) - 1]) == null ? void 0 : _swapTodos.outputToken) !== tokenOut.id)) {
4287
4286
  _context2.next = 4;
@@ -4388,7 +4387,11 @@
4388
4387
  args: {
4389
4388
  receiver_id: exports.REF_FI_CONTRACT_ID,
4390
4389
  amount: toNonDivisibleNumber(tokenIn.decimals, amountIn),
4391
- msg: JSON.stringify({
4390
+ msg: !!referralId ? JSON.stringify({
4391
+ force: 0,
4392
+ actions: actionsList,
4393
+ referral_id: referralId
4394
+ }) : JSON.stringify({
4392
4395
  force: 0,
4393
4396
  actions: actionsList
4394
4397
  })
@@ -4638,7 +4641,7 @@
4638
4641
  };
4639
4642
  }();
4640
4643
 
4641
- var _excluded = ["slippageTolerance", "refreshTrigger", "onSwap", "AccountId", "poolFetchingState"];
4644
+ var _excluded = ["slippageTolerance", "refreshTrigger", "onSwap", "AccountId", "poolFetchingState", "referralId"];
4642
4645
  var ThemeContext = /*#__PURE__*/React.createContext(defaultTheme);
4643
4646
  var ThemeContextProvider = function ThemeContextProvider(_ref) {
4644
4647
  var customTheme = _ref.customTheme,
@@ -4816,6 +4819,7 @@
4816
4819
  onSwap = params.onSwap,
4817
4820
  AccountId = params.AccountId,
4818
4821
  poolFetchingState = params.poolFetchingState,
4822
+ referralId = params.referralId,
4819
4823
  swapParams = _objectWithoutPropertiesLoose(params, _excluded);
4820
4824
  var tokenIn = params.tokenIn,
4821
4825
  tokenOut = params.tokenOut,
@@ -4861,7 +4865,8 @@
4861
4865
  amountIn: params.amountIn,
4862
4866
  swapTodos: estimates,
4863
4867
  slippageTolerance: slippageTolerance,
4864
- AccountId: AccountId || ''
4868
+ AccountId: AccountId || '',
4869
+ referralId: referralId
4865
4870
  });
4866
4871
  case 4:
4867
4872
  transactionsRef = _context3.sent;
@@ -6272,7 +6277,8 @@
6272
6277
  defaultTokenIn = props.defaultTokenIn,
6273
6278
  defaultTokenOut = props.defaultTokenOut,
6274
6279
  onDisConnect = props.onDisConnect,
6275
- darkMode = props.darkMode;
6280
+ darkMode = props.darkMode,
6281
+ referralId = props.referralId;
6276
6282
  var curTheme = theme || (darkMode ? defaultDarkModeTheme : defaultTheme);
6277
6283
  var STORAGED_TOKEN_IN = localStorage.getItem(REF_WIDGET_SWAP_IN_KEY);
6278
6284
  var STORAGED_TOKEN_OUT = localStorage.getItem(REF_WIDGET_SWAP_OUT_KEY);
@@ -6425,7 +6431,8 @@
6425
6431
  onSwap: onSwap,
6426
6432
  AccountId: AccountId,
6427
6433
  refreshTrigger: refreshTrigger,
6428
- poolFetchingState: poolFetchingState
6434
+ poolFetchingState: poolFetchingState,
6435
+ referralId: referralId
6429
6436
  }),
6430
6437
  amountOut = _useSwap.amountOut,
6431
6438
  minAmountOut = _useSwap.minAmountOut,