@ape.swap/bonds-sdk 3.0.63 → 3.0.64-test.1

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.
package/dist/main.js CHANGED
@@ -58329,6 +58329,38 @@ const useURLByEnvironment = (key) => {
58329
58329
  return config === null || config === void 0 ? void 0 : config.urls[key];
58330
58330
  };
58331
58331
 
58332
+ function reportError(_a) {
58333
+ return __awaiter$9(this, arguments, void 0, function* ({ apiUrl, error, extraInfo = {}, chainId, account, rpc, }) {
58334
+ const isClient = typeof window !== 'undefined';
58335
+ const url = isClient ? window.location.href : null;
58336
+ const errors = {
58337
+ message: error instanceof Error ? error.message : String(error),
58338
+ stack: error instanceof Error ? error.stack : null,
58339
+ extra: extraInfo,
58340
+ };
58341
+ const payload = {
58342
+ chainId: chainId,
58343
+ walletAddress: account,
58344
+ rpc,
58345
+ url,
58346
+ log: errors,
58347
+ };
58348
+ console.log('errorPayload', payload);
58349
+ try {
58350
+ yield fetch(`${apiUrl}/stats/log`, {
58351
+ method: 'POST',
58352
+ body: JSON.stringify(payload),
58353
+ headers: {
58354
+ 'Content-Type': 'application/json',
58355
+ },
58356
+ });
58357
+ }
58358
+ catch (err) {
58359
+ console.error('Error al reportar el error:', err);
58360
+ }
58361
+ });
58362
+ }
58363
+
58332
58364
  /**
58333
58365
  * @deprecated This map is deprecated. Boost values are now being retrieved from the Realtime API.
58334
58366
  */
@@ -58385,7 +58417,7 @@ const getUserTier = (weight) => {
58385
58417
  else
58386
58418
  return null;
58387
58419
  };
58388
- const fetchUserPoints = (account, useTiers) => __awaiter$9(void 0, void 0, void 0, function* () {
58420
+ const fetchUserPoints = (account, useTiers, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
58389
58421
  const lensContractAddress = LENS_CONTRACT[types.ChainId.BSC];
58390
58422
  if (account && useTiers) {
58391
58423
  try {
@@ -58400,6 +58432,12 @@ const fetchUserPoints = (account, useTiers) => __awaiter$9(void 0, void 0, void
58400
58432
  }
58401
58433
  catch (e) {
58402
58434
  console.error(e);
58435
+ reportError({
58436
+ apiUrl,
58437
+ error: e,
58438
+ extraInfo: { type: 'fetchUserPoints', e },
58439
+ account,
58440
+ });
58403
58441
  return '0';
58404
58442
  }
58405
58443
  }
@@ -58407,11 +58445,13 @@ const fetchUserPoints = (account, useTiers) => __awaiter$9(void 0, void 0, void
58407
58445
  return '0';
58408
58446
  });
58409
58447
  function useTierPoints() {
58448
+ var _a;
58410
58449
  const { address: account } = useAccount();
58411
58450
  const SDKConfig = useSDKConfig();
58451
+ const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
58412
58452
  return useQuery({
58413
58453
  queryKey: [QUERY_KEYS.TIERS, account],
58414
- queryFn: () => fetchUserPoints(account, SDKConfig.useTiers),
58454
+ queryFn: () => fetchUserPoints(account, SDKConfig.useTiers, apiUrl),
58415
58455
  staleTime: 60000,
58416
58456
  refetchInterval: 30000, // i.e. 30 secs
58417
58457
  refetchOnWindowFocus: false,
@@ -61037,6 +61077,12 @@ const getBillNftBatchData = (apiV2URL, billNftIds, billNftAddress, chainId) => _
61037
61077
  }
61038
61078
  catch (e) {
61039
61079
  console.error(e);
61080
+ reportError({
61081
+ apiUrl: apiV2URL,
61082
+ error: e,
61083
+ extraInfo: { type: 'getBillNftBatchData', billNftIds, billNftAddress, e },
61084
+ chainId,
61085
+ });
61040
61086
  // If an error occurs, return null
61041
61087
  return null;
61042
61088
  }
@@ -61061,6 +61107,12 @@ const getBondNFTData = (apiV2URL, id, billNftAddress, chainId) => __awaiter$9(vo
61061
61107
  }
61062
61108
  catch (e) {
61063
61109
  console.error(e);
61110
+ reportError({
61111
+ apiUrl: apiV2URL,
61112
+ error: e,
61113
+ extraInfo: { type: 'getBondNFTData', billNftAddress, e },
61114
+ chainId,
61115
+ });
61064
61116
  }
61065
61117
  });
61066
61118
 
@@ -62343,6 +62395,7 @@ const useMonitorTxHash = (txHash, chainId) => {
62343
62395
  const TransferAction = ({ userBill, toAddress, disabled, }) => {
62344
62396
  var _a, _b, _c;
62345
62397
  // Hooks
62398
+ const SDKConfig = useSDKConfig();
62346
62399
  const userChainId = useChainId();
62347
62400
  const { address: account } = useAccount();
62348
62401
  const { switchChain } = useSwitchChain();
@@ -62354,7 +62407,7 @@ const TransferAction = ({ userBill, toAddress, disabled, }) => {
62354
62407
  const { addToastError } = usePopups();
62355
62408
  const load = loadingTx || (isLoading && !isConfirmed);
62356
62409
  const handleTransfer = () => __awaiter$9(void 0, void 0, void 0, function* () {
62357
- var _a;
62410
+ var _a, _b;
62358
62411
  const address = userBill === null || userBill === void 0 ? void 0 : userBill.billNftAddress;
62359
62412
  try {
62360
62413
  setLoadingTx(true);
@@ -62387,6 +62440,13 @@ const TransferAction = ({ userBill, toAddress, disabled, }) => {
62387
62440
  console.error('Transfer failed:', error);
62388
62441
  setLoadingTx(false);
62389
62442
  addToastError(error.shortMessage);
62443
+ reportError({
62444
+ apiUrl: (_b = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _b === void 0 ? void 0 : _b.apiV2,
62445
+ error,
62446
+ extraInfo: { type: 'transfer', userBill, error },
62447
+ chainId: userChainId,
62448
+ account,
62449
+ });
62390
62450
  }
62391
62451
  });
62392
62452
  return (jsx$2(Fragment$1, { children: userChainId !== ((_b = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _b === void 0 ? void 0 : _b.chainId) ? (jsxs(Button, { onClick: () => { var _a; return switchChain({ chainId: (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId }); }, children: ["Switch to ", NETWORK_LABEL[(_c = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _c === void 0 ? void 0 : _c.chainId]] })) : (jsx$2(Button, { onClick: handleTransfer, load: load, disabled: load || disabled, fullWidth: true, children: "transfer" })) }));
@@ -69688,28 +69748,35 @@ var PRICE_GETTER_V3_ABI = [
69688
69748
  ];
69689
69749
 
69690
69750
  function useTokenPrices() {
69751
+ var _a;
69691
69752
  const realTime = useURLByEnvironment('realTimeApi');
69692
69753
  const SDKConfig = useSDKConfig();
69754
+ const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
69693
69755
  return useQuery({
69694
69756
  queryKey: [QUERY_KEYS.TOKEN_PRICES],
69695
- queryFn: () => getTokenPrices(realTime, SDKConfig.chains),
69757
+ queryFn: () => getTokenPrices(realTime, SDKConfig.chains, apiUrl),
69696
69758
  refetchInterval: 60000, // 60 sec
69697
69759
  refetchOnMount: false,
69698
69760
  refetchOnWindowFocus: false,
69699
69761
  enabled: !!SDKConfig.chains && SDKConfig.chains.length > 0,
69700
69762
  });
69701
69763
  }
69702
- const getTokenPrices = (apiURL, chains) => __awaiter$9(void 0, void 0, void 0, function* () {
69764
+ const getTokenPrices = (realTimeApiURL, chains, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
69703
69765
  try {
69704
- const response = yield axios.get(`${apiURL}/utils/tokens`);
69766
+ const response = yield axios.get(`${realTimeApiURL}/utils/tokens`);
69705
69767
  const tokenList = response.data;
69706
69768
  const promises = chains.map((chain) => __awaiter$9(void 0, void 0, void 0, function* () {
69707
69769
  try {
69708
69770
  // Directly return the result of fetching prices, or handle any exceptions here
69709
- return yield getAllTokenPrices(+chain, tokenList);
69771
+ return yield getAllTokenPrices(+chain, tokenList, apiUrl);
69710
69772
  }
69711
69773
  catch (error) {
69712
69774
  console.error(`Failed to fetch prices for chain ${chain}:`, error);
69775
+ reportError({
69776
+ apiUrl,
69777
+ error,
69778
+ extraInfo: { type: 'getAllTokenPrices', chains, error },
69779
+ });
69713
69780
  return null;
69714
69781
  }
69715
69782
  }));
@@ -69723,11 +69790,16 @@ const getTokenPrices = (apiURL, chains) => __awaiter$9(void 0, void 0, void 0, f
69723
69790
  }, []);
69724
69791
  return flattenedPrices;
69725
69792
  }
69726
- catch (_a) {
69793
+ catch (error) {
69794
+ reportError({
69795
+ apiUrl,
69796
+ error,
69797
+ extraInfo: { type: 'getTokenPrices', chains, error },
69798
+ });
69727
69799
  return [];
69728
69800
  }
69729
69801
  });
69730
- const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void 0, function* () {
69802
+ const getAllTokenPrices = (chainId, tokens, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
69731
69803
  const { externalTokens, filterTokensToCall, arrayFilterTokens } = Object.keys(tokens).reduce((acc, key) => {
69732
69804
  var _a, _b, _c, _d, _e, _f, _g;
69733
69805
  const token = tokens[key];
@@ -69762,7 +69834,7 @@ const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void
69762
69834
  };
69763
69835
  });
69764
69836
  }
69765
- const externalResults = yield getBatchTokensExternal({ chainId, tokens: externalTokens });
69837
+ const externalResults = yield getBatchTokensExternal({ chainId, tokens: externalTokens, apiUrl });
69766
69838
  const tokenResults = yield getTokenPricesV3FromPriceGetter(filterTokensToCall, chainId);
69767
69839
  const parsedTokenResults = arrayFilterTokens.map((token, i) => {
69768
69840
  var _a, _b, _c;
@@ -69778,7 +69850,7 @@ const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void
69778
69850
  return [...parsedTokenResults, ...externalResults];
69779
69851
  });
69780
69852
  const getBatchTokensExternal = (params) => __awaiter$9(void 0, void 0, void 0, function* () {
69781
- const { chainId, tokens } = params;
69853
+ const { chainId, tokens, apiUrl } = params;
69782
69854
  try {
69783
69855
  const baseURL = 'https://price-api.ape.bond/prices';
69784
69856
  const tokensToCall = tokens.map((token) => token.address);
@@ -69798,8 +69870,14 @@ const getBatchTokensExternal = (params) => __awaiter$9(void 0, void 0, void 0, f
69798
69870
  };
69799
69871
  });
69800
69872
  }
69801
- catch (_a) {
69873
+ catch (error) {
69802
69874
  console.log(`Failed to get price from api for chain ${chainId}.`);
69875
+ reportError({
69876
+ apiUrl,
69877
+ error,
69878
+ extraInfo: { type: 'getBatchTokensExternal', tokens, error },
69879
+ chainId,
69880
+ });
69803
69881
  return [];
69804
69882
  }
69805
69883
  });
@@ -69888,6 +69966,7 @@ const SafeHTMLComponent = ({ html }) => {
69888
69966
  const YourBondsModal = ({ onDismiss, userBill }) => {
69889
69967
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
69890
69968
  // Hooks
69969
+ const SDKConfig = useSDKConfig();
69891
69970
  const chainId = useChainId();
69892
69971
  const { switchChain } = useSwitchChain();
69893
69972
  const { data: bondNFTData } = useBondNFTData(userBill === null || userBill === void 0 ? void 0 : userBill.id, userBill === null || userBill === void 0 ? void 0 : userBill.billNftAddress, (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId);
@@ -69908,6 +69987,7 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
69908
69987
  const isPendingCliff = vestingCliff ? currentTime - lastBlockTimestamp < vestingCliff : false;
69909
69988
  const cliffCountdown = getTimePeriods(lastBlockTimestamp + (vestingCliff !== null && vestingCliff !== void 0 ? vestingCliff : 0) - currentTime, true);
69910
69989
  const handleClaim = (billId, billAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
69990
+ var _a;
69911
69991
  const address = billAddress;
69912
69992
  try {
69913
69993
  setLoadingTx(true);
@@ -69938,6 +70018,13 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
69938
70018
  console.error('Claim Failed:', error);
69939
70019
  setLoadingTx(false);
69940
70020
  addToastError(error.message);
70021
+ reportError({
70022
+ apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
70023
+ error,
70024
+ extraInfo: { type: 'redeem', userBill, error },
70025
+ chainId,
70026
+ account,
70027
+ });
69941
70028
  }
69942
70029
  });
69943
70030
  // Functions to calculate display values for modal
@@ -70092,6 +70179,7 @@ const BondInfoTooltip = ({ earnTokenContract, earnTokenSymbol, bondContract, pro
70092
70179
  const UserBondRow = ({ bill }) => {
70093
70180
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
70094
70181
  const userChainId = useChainId();
70182
+ const SDKConfig = useSDKConfig();
70095
70183
  const { address: account } = useAccount();
70096
70184
  const { switchChain } = useSwitchChain();
70097
70185
  const { writeContractAsync } = useWriteContract();
@@ -70102,6 +70190,7 @@ const UserBondRow = ({ bill }) => {
70102
70190
  const load = loadingTx || (isConfirming && !isConfirmed);
70103
70191
  const [onOpenPurchasedBond] = useModal(jsx$2(YourBondsModal, { userBill: bill }));
70104
70192
  const handleClaim = (billId, billAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
70193
+ var _a;
70105
70194
  const address = billAddress;
70106
70195
  try {
70107
70196
  setLoadingTx(true);
@@ -70132,6 +70221,13 @@ const UserBondRow = ({ bill }) => {
70132
70221
  setLoadingTx(false);
70133
70222
  console.error('Claim failed:', error);
70134
70223
  addToastError(error.message);
70224
+ reportError({
70225
+ apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
70226
+ error,
70227
+ extraInfo: { type: 'claim', bill, error },
70228
+ chainId: bill.bond.chainId,
70229
+ account,
70230
+ });
70135
70231
  }
70136
70232
  });
70137
70233
  // Display Info
@@ -70157,19 +70253,25 @@ const UserBondRow = ({ bill }) => {
70157
70253
 
70158
70254
  function useBondsList() {
70159
70255
  const realTime = useURLByEnvironment('realTimeApi');
70256
+ const apiUrl = useURLByEnvironment('apiV2');
70160
70257
  return useQuery({
70161
70258
  queryKey: [QUERY_KEYS.BONDS_LIST],
70162
- queryFn: () => getBondsList(realTime),
70259
+ queryFn: () => getBondsList(realTime, apiUrl),
70163
70260
  staleTime: Infinity,
70164
70261
  refetchOnWindowFocus: false,
70165
70262
  });
70166
70263
  }
70167
- const getBondsList = (apiURL) => __awaiter$9(void 0, void 0, void 0, function* () {
70264
+ const getBondsList = (realTimeapiURL, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
70168
70265
  try {
70169
- const response = yield axios.get(`${apiURL}/utils/bonds`);
70266
+ const response = yield axios.get(`${realTimeapiURL}/utils/bonds`);
70170
70267
  return response.data;
70171
70268
  }
70172
- catch (_a) {
70269
+ catch (e) {
70270
+ reportError({
70271
+ apiUrl,
70272
+ error: e,
70273
+ extraInfo: { type: 'getBondsList', e },
70274
+ });
70173
70275
  return [];
70174
70276
  }
70175
70277
  });
@@ -70274,22 +70376,24 @@ const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$
70274
70376
  });
70275
70377
 
70276
70378
  function useUserBonds() {
70379
+ var _a;
70277
70380
  // First fetch the full list of bonds
70278
70381
  const { data: bondList } = useBondsList();
70279
70382
  const { address } = useAccount();
70280
70383
  const SDKConfig = useSDKConfig();
70281
70384
  const { data: tokenPrices } = useTokenPrices();
70282
70385
  const chains = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.chains;
70386
+ const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
70283
70387
  // Once the full list is fetched, fetch user's purchased bonds
70284
70388
  return useQuery({
70285
70389
  queryKey: [QUERY_KEYS.USER_BONDS, address],
70286
- queryFn: () => getUserBonds(address, bondList, chains, tokenPrices),
70390
+ queryFn: () => getUserBonds(address, bondList, chains, tokenPrices, apiUrl),
70287
70391
  refetchOnWindowFocus: false,
70288
70392
  refetchInterval: 60000,
70289
70393
  enabled: !!bondList && !!address && !!tokenPrices,
70290
70394
  });
70291
70395
  }
70292
- const getUserBonds = (account, bondList, chains, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
70396
+ const getUserBonds = (account, bondList, chains, tokenPrices, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
70293
70397
  try {
70294
70398
  const bondsByChain = bondList.reduce((acc, bond) => {
70295
70399
  var _a;
@@ -70319,7 +70423,13 @@ const getUserBonds = (account, bondList, chains, tokenPrices) => __awaiter$9(voi
70319
70423
  .map((result) => result.value);
70320
70424
  return fulfilledResults.flat().flatMap((result) => result.userOwnedBills);
70321
70425
  }
70322
- catch (_a) {
70426
+ catch (e) {
70427
+ reportError({
70428
+ apiUrl,
70429
+ error: e,
70430
+ extraInfo: { type: 'getUserBonds', bondList, chains, e },
70431
+ account,
70432
+ });
70323
70433
  return [];
70324
70434
  }
70325
70435
  });
@@ -70661,6 +70771,7 @@ const ClaimAllModal = () => {
70661
70771
  const { addToastError } = usePopups();
70662
70772
  const { writeContractAsync } = useWriteContract();
70663
70773
  const handleClaim = () => __awaiter$9(void 0, void 0, void 0, function* () {
70774
+ var _a;
70664
70775
  try {
70665
70776
  bondsOfSelectedChain === null || bondsOfSelectedChain === void 0 ? void 0 : bondsOfSelectedChain.map((purchasedBond) => __awaiter$9(void 0, void 0, void 0, function* () {
70666
70777
  const address = purchasedBond.bond.contractAddress[purchasedBond.bond.chainId];
@@ -70686,6 +70797,13 @@ const ClaimAllModal = () => {
70686
70797
  catch (error) {
70687
70798
  console.error('Claim All failed:', error);
70688
70799
  addToastError(error.message);
70800
+ reportError({
70801
+ apiUrl: (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2,
70802
+ error,
70803
+ extraInfo: { type: 'claimAll', bondsOfSelectedChain, error },
70804
+ chainId,
70805
+ account,
70806
+ });
70689
70807
  }
70690
70808
  });
70691
70809
  const purchasedBillsChains = (_a = groupedBills === null || groupedBills === void 0 ? void 0 : groupedBills.reduce((acc, bill) => {
@@ -73096,37 +73214,46 @@ var launchBondsABI_V2_2_0 = [
73096
73214
  ];
73097
73215
 
73098
73216
  function usePreTGEList() {
73099
- const realTime = useURLByEnvironment('realTimeApi');
73217
+ var _a, _b;
73218
+ const SDKConfig = useSDKConfig();
73219
+ const realTime = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.realTimeApi;
73220
+ const apiUrl = (_b = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _b === void 0 ? void 0 : _b.apiV2;
73100
73221
  return useQuery({
73101
73222
  queryKey: [QUERY_KEYS.PRE_TGE_LIST],
73102
- queryFn: () => getPreTGEList(realTime),
73223
+ queryFn: () => getPreTGEList(realTime, apiUrl),
73103
73224
  staleTime: Infinity,
73104
73225
  refetchOnWindowFocus: false,
73105
73226
  });
73106
73227
  }
73107
- const getPreTGEList = (apiURL) => __awaiter$9(void 0, void 0, void 0, function* () {
73228
+ const getPreTGEList = (apiRealTimeURL, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
73108
73229
  try {
73109
- const response = yield axios.get(`${apiURL}/utils/pre-tge-bonds`);
73230
+ const response = yield axios.get(`${apiRealTimeURL}/utils/pre-tge-bonds`);
73110
73231
  return response.data;
73111
73232
  }
73112
- catch (_a) {
73233
+ catch (e) {
73234
+ reportError({
73235
+ apiUrl,
73236
+ error: e,
73237
+ extraInfo: { type: 'getPreTGEList', e },
73238
+ });
73113
73239
  return [];
73114
73240
  }
73115
73241
  });
73116
73242
 
73117
73243
  function usePreTGEBondsData() {
73118
- var _a;
73244
+ var _a, _b;
73119
73245
  const { data: preTGEList } = usePreTGEList();
73120
73246
  const SDKConfig = useSDKConfig();
73247
+ const apiUrl = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
73121
73248
  return useQuery({
73122
- queryKey: [QUERY_KEYS.PRE_TGE_BONDS, (_a = preTGEList === null || preTGEList === void 0 ? void 0 : preTGEList.length) !== null && _a !== void 0 ? _a : ''],
73123
- queryFn: () => getLaunchBondsPublicData(preTGEList, SDKConfig.chains),
73249
+ queryKey: [QUERY_KEYS.PRE_TGE_BONDS, (_b = preTGEList === null || preTGEList === void 0 ? void 0 : preTGEList.length) !== null && _b !== void 0 ? _b : ''],
73250
+ queryFn: () => getLaunchBondsPublicData(preTGEList, SDKConfig.chains, apiUrl),
73124
73251
  staleTime: 60000,
73125
73252
  refetchOnWindowFocus: false,
73126
73253
  enabled: !!preTGEList && preTGEList.length > 0,
73127
73254
  });
73128
73255
  }
73129
- const getLaunchBondsPublicData = (preTGEBonds, chains) => __awaiter$9(void 0, void 0, void 0, function* () {
73256
+ const getLaunchBondsPublicData = (preTGEBonds, chains, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
73130
73257
  try {
73131
73258
  if (!(preTGEBonds === null || preTGEBonds === void 0 ? void 0 : preTGEBonds.length))
73132
73259
  return null;
@@ -73189,7 +73316,12 @@ const getLaunchBondsPublicData = (preTGEBonds, chains) => __awaiter$9(void 0, vo
73189
73316
  }
73190
73317
  return data.flat();
73191
73318
  }
73192
- catch (_a) {
73319
+ catch (e) {
73320
+ reportError({
73321
+ apiUrl,
73322
+ error: e,
73323
+ extraInfo: { type: 'getLaunchBondsPublicData', preTGEBonds, chains, e },
73324
+ });
73193
73325
  return [];
73194
73326
  }
73195
73327
  });
@@ -73198,15 +73330,16 @@ function usePreTGEUserBonds() {
73198
73330
  var _a;
73199
73331
  const { data: preTGEBonds } = usePreTGEBondsData();
73200
73332
  const { address } = useAccount();
73333
+ const apiUrl = useURLByEnvironment('apiV2');
73201
73334
  return useQuery({
73202
73335
  queryKey: [QUERY_KEYS.PRE_TGE_BONDS, (_a = preTGEBonds === null || preTGEBonds === void 0 ? void 0 : preTGEBonds.length) !== null && _a !== void 0 ? _a : '', address],
73203
- queryFn: () => fetchPreTGEUserBonds(preTGEBonds, address),
73336
+ queryFn: () => fetchPreTGEUserBonds(preTGEBonds, address, apiUrl),
73204
73337
  staleTime: 30000,
73205
73338
  refetchOnWindowFocus: false,
73206
73339
  enabled: !!preTGEBonds && preTGEBonds.length > 0 && !!address,
73207
73340
  });
73208
73341
  }
73209
- const fetchPreTGEUserBonds = (preTGEBonds, account) => __awaiter$9(void 0, void 0, void 0, function* () {
73342
+ const fetchPreTGEUserBonds = (preTGEBonds, account, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
73210
73343
  try {
73211
73344
  const res = yield Promise.all(preTGEBonds.map((bond) => __awaiter$9(void 0, void 0, void 0, function* () {
73212
73345
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
@@ -73288,6 +73421,12 @@ const fetchPreTGEUserBonds = (preTGEBonds, account) => __awaiter$9(void 0, void
73288
73421
  }
73289
73422
  catch (e) {
73290
73423
  console.log(e);
73424
+ reportError({
73425
+ apiUrl,
73426
+ error: e,
73427
+ extraInfo: { type: 'fetchPreTGEUserBonds', preTGEBonds, e },
73428
+ account,
73429
+ });
73291
73430
  return [];
73292
73431
  }
73293
73432
  });
@@ -75960,10 +76099,11 @@ function useBondsData() {
75960
76099
  const { data: tokenPrices } = useTokenPrices();
75961
76100
  const { data: bondList } = useBondsList();
75962
76101
  const SDKConfig = useSDKConfig();
76102
+ const apiUrl = useURLByEnvironment('apiV2');
75963
76103
  const realTimeApiURL = useURLByEnvironment('realTimeApi');
75964
76104
  return useQuery({
75965
76105
  queryKey: [QUERY_KEYS.BONDS_DATA],
75966
- queryFn: () => getBondsData(SDKConfig.chains, realTimeApiURL, tokenPrices, bondList),
76106
+ queryFn: () => getBondsData(SDKConfig.chains, realTimeApiURL, tokenPrices, bondList, apiUrl),
75967
76107
  refetchInterval: 20000, // i.e. 20 sec
75968
76108
  refetchOnWindowFocus: false,
75969
76109
  retry: 0,
@@ -75971,12 +76111,12 @@ function useBondsData() {
75971
76111
  enabled: !!SDKConfig.chains && SDKConfig.chains.length > 0,
75972
76112
  });
75973
76113
  }
75974
- const getBondsData = (chains, realTimeApiURL, tokenPrices, bondList) => __awaiter$9(void 0, void 0, void 0, function* () {
76114
+ const getBondsData = (chains, realTimeApiURL, tokenPrices, bondList, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
75975
76115
  try {
75976
76116
  const response = yield axios.get(`${realTimeApiURL}/bonds`);
75977
76117
  return response.data.bonds;
75978
76118
  }
75979
- catch (_a) {
76119
+ catch (e) {
75980
76120
  console.time('Fallback'); // Start debug timer
75981
76121
  const billData = [];
75982
76122
  if (tokenPrices && bondList) {
@@ -75993,6 +76133,11 @@ const getBondsData = (chains, realTimeApiURL, tokenPrices, bondList) => __awaite
75993
76133
  })));
75994
76134
  }
75995
76135
  console.timeEnd(`Fallback`); // End chain-specific timer
76136
+ reportError({
76137
+ apiUrl,
76138
+ error: e,
76139
+ extraInfo: { type: 'getBondsData', e },
76140
+ });
75996
76141
  return billData === null || billData === void 0 ? void 0 : billData.flat();
75997
76142
  }
75998
76143
  });
@@ -76447,15 +76592,16 @@ var ERC_20_ABI = [
76447
76592
  function useUserTokensBalance(tokens, chainId) {
76448
76593
  const keys = tokens.map((token) => (token === 'NATIVE' ? 'NATIVE' : token.address[chainId]));
76449
76594
  const { address: account } = useAccount();
76595
+ const apiUrl = useURLByEnvironment('apiV2');
76450
76596
  return useQuery({
76451
76597
  queryKey: [`${QUERY_KEYS.USER_TOKENS_BALANCES}-${keys}-${account}`],
76452
- queryFn: () => getTokensBalance(account, tokens, chainId),
76598
+ queryFn: () => getTokensBalance(account, tokens, chainId, apiUrl),
76453
76599
  staleTime: 60000,
76454
76600
  refetchOnWindowFocus: false,
76455
76601
  enabled: !!account,
76456
76602
  });
76457
76603
  }
76458
- const getTokensBalance = (account, tokens, chainId) => __awaiter$9(void 0, void 0, void 0, function* () {
76604
+ const getTokensBalance = (account, tokens, chainId, apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
76459
76605
  try {
76460
76606
  const callsToken = tokens
76461
76607
  .filter((token) => token !== 'NATIVE')
@@ -76497,7 +76643,14 @@ const getTokensBalance = (account, tokens, chainId) => __awaiter$9(void 0, void
76497
76643
  });
76498
76644
  return [...balancesToken, ...balancesNative];
76499
76645
  }
76500
- catch (_a) {
76646
+ catch (e) {
76647
+ reportError({
76648
+ apiUrl,
76649
+ error: e,
76650
+ extraInfo: { type: 'getTokensBalance', tokens, e },
76651
+ account,
76652
+ chainId,
76653
+ });
76501
76654
  return [];
76502
76655
  }
76503
76656
  });
@@ -77590,6 +77743,7 @@ const getTokenAllowance = (currency, spender, account, chainId) => __awaiter$9(v
77590
77743
  return value.toNumber();
77591
77744
  });
77592
77745
  const useApproval = (amount, currency, spender, account, chainId) => {
77746
+ const apiUrl = useURLByEnvironment('apiV2');
77593
77747
  const [confirmingTxOnWallet, setConfirmingTxOnWallet] = useState(false);
77594
77748
  const [txHash, setTxHash] = useState('');
77595
77749
  const { data: allowance, refetch } = useAllowance(currency, spender, account, chainId);
@@ -77631,6 +77785,13 @@ const useApproval = (amount, currency, spender, account, chainId) => {
77631
77785
  setConfirmingTxOnWallet(false);
77632
77786
  console.error('Approval failed:', error);
77633
77787
  addToastError(error.message);
77788
+ reportError({
77789
+ apiUrl,
77790
+ error,
77791
+ extraInfo: { type: 'approval', tokenAddress: tokenAddress, spenderAddress: spender, error },
77792
+ chainId,
77793
+ account,
77794
+ });
77634
77795
  }
77635
77796
  }), [amount, currency, chainId]);
77636
77797
  let approvalState = ApprovalState.NOT_APPROVED;
@@ -77879,6 +78040,7 @@ const ZapModal = ({ onDismiss, outputToken, account, chainId }) => {
77879
78040
  const [typedValue, setTypedValue] = useState('');
77880
78041
  const [inputTokenString, setInputTokenString] = useState('NATIVE');
77881
78042
  // Hooks
78043
+ const SDKConfig = useSDKConfig();
77882
78044
  const userChainId = useChainId();
77883
78045
  const { switchChain } = useSwitchChain();
77884
78046
  const inputToken = useTokenFromZapList(inputTokenString, chainId, null);
@@ -77907,7 +78069,7 @@ const ZapModal = ({ onDismiss, outputToken, account, chainId }) => {
77907
78069
  setTypedValue(inputTokenBalance !== null && inputTokenBalance !== void 0 ? inputTokenBalance : '');
77908
78070
  }, [inputTokenBalance]);
77909
78071
  const soulZapCallback = useCallback(() => __awaiter$9(void 0, void 0, void 0, function* () {
77910
- var _a, _b;
78072
+ var _a, _b, _c;
77911
78073
  if (zapData && ((_a = zapData === null || zapData === void 0 ? void 0 : zapData.txData) === null || _a === void 0 ? void 0 : _a.to) && ((_b = zapData === null || zapData === void 0 ? void 0 : zapData.txData) === null || _b === void 0 ? void 0 : _b.data)) {
77912
78074
  try {
77913
78075
  console.log(zapData);
@@ -77940,6 +78102,13 @@ const ZapModal = ({ onDismiss, outputToken, account, chainId }) => {
77940
78102
  console.error(e);
77941
78103
  setPendingTx(false);
77942
78104
  addToastError(e.shortMessage);
78105
+ reportError({
78106
+ apiUrl: (_c = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _c === void 0 ? void 0 : _c.apiV2,
78107
+ error: e,
78108
+ extraInfo: { type: 'zap-lp', zapData, e },
78109
+ chainId,
78110
+ account,
78111
+ });
77943
78112
  }
77944
78113
  }
77945
78114
  }), [zapData, (_f = zapData === null || zapData === void 0 ? void 0 : zapData.txData) === null || _f === void 0 ? void 0 : _f.to, (_g = zapData === null || zapData === void 0 ? void 0 : zapData.txData) === null || _g === void 0 ? void 0 : _g.data]);
@@ -78478,7 +78647,14 @@ const getTierProofSig = (apiAddress, account, bondAddress, chainId) => __awaiter
78478
78647
  const response = yield axios.post(`${apiAddress}/tier-signature`, requestBody);
78479
78648
  return response.data.tierProofSignature;
78480
78649
  }
78481
- catch (_a) {
78650
+ catch (e) {
78651
+ reportError({
78652
+ apiUrl: apiAddress,
78653
+ error: e,
78654
+ extraInfo: { type: 'getTierProofSig', bondAddress, e },
78655
+ chainId,
78656
+ account,
78657
+ });
78482
78658
  return null;
78483
78659
  }
78484
78660
  });
@@ -78607,7 +78783,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
78607
78783
  };
78608
78784
  // This is the regular buy bond interaction (a.k.a. write method called "deposit" in smartcontract)
78609
78785
  const handleBuyCallback = () => __awaiter$9(void 0, void 0, void 0, function* () {
78610
- var _a, _b, _c, _d, _e;
78786
+ var _a, _b, _c, _d, _e, _f;
78611
78787
  const billAddress = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress;
78612
78788
  const decimals = (_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.decimals) === null || _a === void 0 ? void 0 : _a[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) !== null && _b !== void 0 ? _b : 18;
78613
78789
  track({
@@ -78654,12 +78830,19 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
78654
78830
  }
78655
78831
  catch (error) {
78656
78832
  console.error('Buy error', error);
78833
+ reportError({
78834
+ apiUrl: (_f = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _f === void 0 ? void 0 : _f.apiV2,
78835
+ error,
78836
+ extraInfo: { type: 'buyBond', bondData, error },
78837
+ chainId: bondChain,
78838
+ account,
78839
+ });
78657
78840
  addToastError(error.shortMessage);
78658
78841
  }
78659
78842
  });
78660
78843
  // ignore this for SOL migration
78661
78844
  const handleZapCallback = () => __awaiter$9(void 0, void 0, void 0, function* () {
78662
- var _a, _b, _c, _d, _e, _f, _g, _h;
78845
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
78663
78846
  if (zapData && ((_a = zapData === null || zapData === void 0 ? void 0 : zapData.txData) === null || _a === void 0 ? void 0 : _a.to) && ((_b = zapData === null || zapData === void 0 ? void 0 : zapData.txData) === null || _b === void 0 ? void 0 : _b.data)) {
78664
78847
  console.log('Attempting zap tx');
78665
78848
  track({
@@ -78712,6 +78895,13 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
78712
78895
  catch (e) {
78713
78896
  console.log(e);
78714
78897
  addToastError(e.shortMessage);
78898
+ reportError({
78899
+ apiUrl: (_j = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _j === void 0 ? void 0 : _j.apiV2,
78900
+ error: e,
78901
+ extraInfo: { type: 'zapBuyBond', bondData, zapData, e },
78902
+ chainId: bondChain,
78903
+ account,
78904
+ });
78715
78905
  }
78716
78906
  }
78717
78907
  });
@@ -79302,9 +79492,10 @@ const HotBondCard = ({ bond }) => {
79302
79492
  };
79303
79493
 
79304
79494
  function useHotBondContracts() {
79495
+ const apiUrl = useURLByEnvironment('apiV2');
79305
79496
  return useQuery({
79306
79497
  queryKey: [QUERY_KEYS.HOT_BONDS_CONTRACTS],
79307
- queryFn: getHotBondsContracts,
79498
+ queryFn: () => getHotBondsContracts(apiUrl),
79308
79499
  staleTime: Infinity,
79309
79500
  refetchOnWindowFocus: false,
79310
79501
  refetchOnMount: false,
@@ -79323,13 +79514,18 @@ function useHotBonds() {
79323
79514
  retry: 0,
79324
79515
  });
79325
79516
  }
79326
- const getHotBondsContracts = () => __awaiter$9(void 0, void 0, void 0, function* () {
79517
+ const getHotBondsContracts = (apiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
79327
79518
  try {
79328
79519
  console.log('call!');
79329
79520
  const response = yield axios.get(`${STRAPI_URL}/hot-bonds`);
79330
79521
  return response.data.map((bond) => bond.BondAddress.toLowerCase());
79331
79522
  }
79332
- catch (_a) {
79523
+ catch (e) {
79524
+ reportError({
79525
+ apiUrl,
79526
+ error: e,
79527
+ extraInfo: { type: 'getHotBondsContracts', e },
79528
+ });
79333
79529
  return [];
79334
79530
  }
79335
79531
  });
@@ -4,6 +4,6 @@ import { TokenPrices } from '../tokenPrices/useTokenPrices';
4
4
  import { BillsConfig } from '@ape.swap/apeswap-lists';
5
5
  import BigNumber from 'bignumber.js';
6
6
  export default function useBondsData(): UseQueryResult<BondsData[]>;
7
- export declare const getBondsData: (chains: number[], realTimeApiURL: string, tokenPrices?: TokenPrices[], bondList?: BillsConfig[]) => Promise<BondsData[]>;
7
+ export declare const getBondsData: (chains: number[], realTimeApiURL: string, tokenPrices?: TokenPrices[], bondList?: BillsConfig[], apiUrl?: string) => Promise<BondsData[]>;
8
8
  export declare const getBonusWithFee: (feeInPayout: number, trueBillPrice: BigNumber, lpPrice: number, earnTokenPrice: number) => number;
9
9
  export declare const getRawBonus: (trueBillPrice: any, lpPrice: number, earnTokenPrice: number) => number;
@@ -1,4 +1,4 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
2
  import { BillsConfig } from '@ape.swap/apeswap-lists';
3
3
  export default function useBondsList(): UseQueryResult<BillsConfig[]>;
4
- export declare const getBondsList: (apiURL: string) => Promise<BillsConfig[][]>;
4
+ export declare const getBondsList: (realTimeapiURL: string, apiUrl: string) => Promise<BillsConfig[][]>;
@@ -2,5 +2,5 @@ import { UseQueryResult } from '@tanstack/react-query';
2
2
  import { BondsData } from '../../types/bonds';
3
3
  export declare function useHotBondContracts(): UseQueryResult<string[], Error>;
4
4
  export default function useHotBonds(): UseQueryResult<BondsData[]>;
5
- export declare const getHotBondsContracts: () => Promise<string[]>;
5
+ export declare const getHotBondsContracts: (apiUrl: string) => Promise<string[]>;
6
6
  export declare const getHotBonds: (bondData: BondsData[], hotBondContracts: string[]) => Promise<BondsData[]>;
@@ -3,4 +3,4 @@ import { BillsConfig } from '@ape.swap/apeswap-lists';
3
3
  import { UserBill } from '../../types/yourbonds';
4
4
  import { TokenPrices } from '../tokenPrices/useTokenPrices';
5
5
  export default function useUserBonds(): UseQueryResult<UserBill[]>;
6
- export declare const getUserBonds: (account: string, bondList: BillsConfig[], chains: number[], tokenPrices: TokenPrices[]) => Promise<UserBill[]>;
6
+ export declare const getUserBonds: (account: string, bondList: BillsConfig[], chains: number[], tokenPrices: TokenPrices[], apiUrl?: string) => Promise<UserBill[]>;
@@ -4,7 +4,7 @@ export default function useUserTokensBalance(tokens: ('NATIVE' | Token)[], chain
4
4
  address: string;
5
5
  balance: string;
6
6
  }[]>;
7
- export declare const getTokensBalance: (account: string, tokens: ("NATIVE" | Token)[], chainId: number) => Promise<{
7
+ export declare const getTokensBalance: (account: string, tokens: ("NATIVE" | Token)[], chainId: number, apiUrl?: string) => Promise<{
8
8
  address: string;
9
9
  balance: string;
10
10
  }[]>;
@@ -16,4 +16,4 @@ export interface PreTGEBondData extends PreTGEBond {
16
16
  vestingTerm: string;
17
17
  }
18
18
  export default function usePreTGEBondsData(): UseQueryResult<PreTGEBondData[]>;
19
- export declare const getLaunchBondsPublicData: (preTGEBonds: PreTGEBond[], chains?: number[]) => Promise<PreTGEBondData[]>;
19
+ export declare const getLaunchBondsPublicData: (preTGEBonds: PreTGEBond[], chains?: number[], apiUrl?: string) => Promise<PreTGEBondData[]>;
@@ -1,4 +1,4 @@
1
1
  import { UseQueryResult } from '@tanstack/react-query';
2
2
  import { PreTGEBond } from '@ape.swap/apeswap-lists';
3
3
  export default function usePreTGEList(): UseQueryResult<PreTGEBond[]>;
4
- export declare const getPreTGEList: (apiURL: string) => Promise<PreTGEBond[]>;
4
+ export declare const getPreTGEList: (apiRealTimeURL: string, apiUrl: string) => Promise<PreTGEBond[]>;
@@ -30,4 +30,4 @@ export interface PreTGEUserBonds extends PreTGEBond {
30
30
  vestingTerm: string;
31
31
  }
32
32
  export default function usePreTGEUserBonds(): UseQueryResult<PreTGEUserBonds[]>;
33
- export declare const fetchPreTGEUserBonds: (preTGEBonds: PreTGEBondData[], account: string) => Promise<PreTGEUserBonds[]>;
33
+ export declare const fetchPreTGEUserBonds: (preTGEBonds: PreTGEBondData[], account: string, apiUrl: string) => Promise<PreTGEUserBonds[]>;
@@ -31,5 +31,5 @@ export declare const TIERS_NAMES: {
31
31
  4: string;
32
32
  };
33
33
  export declare const getUserTier: (weight: string) => LaunchBondTiers | null;
34
- export declare const fetchUserPoints: (account?: string, useTiers?: boolean) => Promise<string | null>;
34
+ export declare const fetchUserPoints: (account?: string, useTiers?: boolean, apiUrl?: string) => Promise<string | null>;
35
35
  export default function useTierPoints(): import("@tanstack/react-query").UseQueryResult<string, Error>;
@@ -7,5 +7,5 @@ export interface TokenPrices {
7
7
  chainId: ChainId | undefined;
8
8
  }
9
9
  export default function useTokenPrices(): UseQueryResult<TokenPrices[]>;
10
- export declare const getTokenPrices: (apiURL: string, chains: number[]) => Promise<TokenPrices[]>;
10
+ export declare const getTokenPrices: (realTimeApiURL: string, chains: number[], apiUrl?: string) => Promise<TokenPrices[]>;
11
11
  export declare function getTokenPricesV3FromPriceGetter(tokensToCall: Record<string, Token>, chain: ChainId): Promise<any>;
@@ -0,0 +1,8 @@
1
+ export declare function reportError({ apiUrl, error, extraInfo, chainId, account, rpc, }: {
2
+ apiUrl: string;
3
+ error: unknown;
4
+ extraInfo?: Record<string, any>;
5
+ chainId?: number;
6
+ account?: string;
7
+ rpc?: string;
8
+ }): Promise<void>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "3.0.63",
6
+ "version": "3.0.64-test.1",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",