@ape.swap/bonds-sdk 2.2.8 → 2.2.10

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.
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const RestrictedRegionModal: ({ onDismiss }: {
3
+ onDismiss?: () => void;
4
+ }) => React.JSX.Element;
5
+ export default RestrictedRegionModal;
@@ -33,4 +33,5 @@ export declare const QUERY_KEYS: {
33
33
  CHAIN_FILTER_OPTION: string;
34
34
  FAVORITE_TOKENS: string;
35
35
  POP_UPS: string;
36
+ GEO_FENCING: string;
36
37
  };
package/dist/main.js CHANGED
@@ -18326,6 +18326,7 @@ var types = {};
18326
18326
  (_c[LiquidityDex.PancakeSwapV2] = {
18327
18327
  factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',
18328
18328
  protocol: Protocols.V2,
18329
+ router: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
18329
18330
  }),
18330
18331
  (_c[LiquidityDex.ApeSwapV3] = {
18331
18332
  factory: '0x7Bc382DdC5928964D7af60e7e2f6299A1eA6F48d',
@@ -18841,6 +18842,7 @@ const QUERY_KEYS = {
18841
18842
  CHAIN_FILTER_OPTION: 'ApeBond-SDK-chainFilterOption',
18842
18843
  FAVORITE_TOKENS: 'ApeBond-SDK-favoriteTokens',
18843
18844
  POP_UPS: 'ApeBond-SDK-popUps',
18845
+ GEO_FENCING: 'ApeBond-SDK-geoFencing',
18844
18846
  };
18845
18847
 
18846
18848
  function useCookie(key, defaultValue) {
@@ -49034,7 +49036,7 @@ const PRICE_GETTER_ADDRESSES = {
49034
49036
  [types.ChainId.LINEA]: '0x35b1eadAbaDD0Edd26076247f3dEdF9E15De8D5D',
49035
49037
  [types.ChainId.LIGHTLINK]: '0xC22Db8dDe3A3591fFB02be868Ce2901d30671FE4',
49036
49038
  [types.ChainId.IOTA]: '0xC22Db8dDe3A3591fFB02be868Ce2901d30671FE4',
49037
- [types.ChainId.BASE]: '0x2e6AB3cc819BE64886C1bB403813cCBec0407a5b',
49039
+ [types.ChainId.BASE]: '0xE29C74B4DD05A268B5FFaadeF4fdbAa1de6FDe84',
49038
49040
  [types.ChainId.AVAX]: '0x70005Da62E17041977f7F99f91098b125CcDE1a7',
49039
49041
  };
49040
49042
  const MULTICALL_V2 = {
@@ -74111,7 +74113,6 @@ const ProjectDescription = ({ description }) => {
74111
74113
  };
74112
74114
 
74113
74115
  const BondModalHeaderAlt = ({ bondData, onDismiss, showProjectInfoButton, }) => {
74114
- var _a, _b, _c, _d, _e, _f;
74115
74116
  const [onOpenSlippageModal] = useModal(jsx$2(SlippageModal, {}));
74116
74117
  const handleClose = () => {
74117
74118
  if (typeof window !== 'undefined') {
@@ -74131,7 +74132,7 @@ const BondModalHeaderAlt = ({ bondData, onDismiss, showProjectInfoButton, }) =>
74131
74132
  // },
74132
74133
  // })
74133
74134
  // }
74134
- return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(BondInfoTooltip, { earnTokenContract: (_c = (_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) !== null && _c !== void 0 ? _c : '', earnTokenSymbol: (_e = (_d = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken) === null || _d === void 0 ? void 0 : _d.symbol) !== null && _e !== void 0 ? _e : '', bondContract: (_f = bondData.billAddress) !== null && _f !== void 0 ? _f : '', projectLink: bondData === null || bondData === void 0 ? void 0 : bondData.projectLink, twitter: bondData === null || bondData === void 0 ? void 0 : bondData.twitter, audit: bondData === null || bondData === void 0 ? void 0 : bondData.audit, chain: bondData === null || bondData === void 0 ? void 0 : bondData.chainId }), width: "205px", placement: "bottomRight", transformTip: "translate(7%, -2%)", children: jsx$2(Flex, { className: "more-icon", sx: { opacity: 0.8 }, children: jsx$2(Svg, { icon: "more", width: "25px" }) }) }), jsx$2(Flex, { sx: { pr: '10px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) }), jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose })] })) : (jsx$2(Flex, { sx: {}, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })) }) }));
74135
+ return (jsx$2(Flex, { className: "modaltable-container title-container", children: jsx$2(Flex, { className: "slipagge-close-icons", sx: { flexDirection: 'row' }, children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(Flex, { sx: { pr: '10px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) }), jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose })] })) : (jsx$2(Flex, { sx: {}, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })) }) }));
74135
74136
  };
74136
74137
 
74137
74138
  const ImageAndShortDescription = ({ bondData, onDismiss }) => {
@@ -74172,9 +74173,32 @@ const ImageAndShortDescription = ({ bondData, onDismiss }) => {
74172
74173
  }) })] }), jsxs(Flex, { sx: { alignItems: 'center', display: ['flex', 'flex', 'flex', 'none'], p: '10px', width: '100%' }, children: [jsxs(Flex, { sx: { width: ['50%', '50%', '50%', '100%'], alignItems: 'center' }, children: [jsx$2(Flex, { sx: { mr: '5px' }, children: jsx$2(TokenImage, { symbol: (_a = bondData.showcaseTokenName) !== null && _a !== void 0 ? _a : bondData.earnToken.symbol, size: 30, chain: bondData.chainId }) }), jsxs("h2", { className: "modal-tokenname-chainicon", sx: { margin: '0px' }, children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, ' '] })] }), jsx$2(Flex, { className: "modal-marketprice-header", sx: { justifyContent: 'flex-end', alignItems: 'center' }, children: jsxs("span", { className: "modal-marketprice", children: ["Market Price: $", earnTokenPrice(bondData)] }) }), jsx$2(Flex, { className: "bondmodal-header-alt", sx: { mb: '10px' }, children: jsx$2(BondModalHeaderAlt, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }) })] }), jsx$2(Flex, { className: "description-container paragraph-spaced", sx: { px: '10px', opacity: 0.7, mt: ['0', '0', '0', '10px'] }, children: jsx$2(ProjectDescription, { description: bondData === null || bondData === void 0 ? void 0 : bondData.shortDescription }) })] }));
74173
74174
  };
74174
74175
 
74176
+ // Fetch country code to check if the region is allowed
74177
+ const fetchLocation = (apiv2URL) => __awaiter$9(void 0, void 0, void 0, function* () {
74178
+ const resp = yield axios.get(`${apiv2URL}/check`);
74179
+ const { isRestrictedRegion, countryCode } = resp === null || resp === void 0 ? void 0 : resp.data;
74180
+ return { isRestrictedRegion, countryCode };
74181
+ });
74182
+ function useGeoFencing() {
74183
+ const apiv2URL = useURLByEnvironment('apiV2');
74184
+ return useQuery({
74185
+ queryKey: [QUERY_KEYS.GEO_FENCING],
74186
+ queryFn: () => fetchLocation(apiv2URL),
74187
+ staleTime: Infinity,
74188
+ refetchOnMount: false,
74189
+ refetchOnWindowFocus: false,
74190
+ });
74191
+ }
74192
+
74193
+ const RestrictedRegionModal = ({ onDismiss }) => {
74194
+ const { data: geoData } = useGeoFencing();
74195
+ return (jsxs(Modal, { className: "modal", title: "Notice", sx: { maxWidth: '200px' }, children: [jsxs(Flex, { sx: { my: '20px' }, children: ["Unfortunately, this bond is restricted for your region: ", geoData === null || geoData === void 0 ? void 0 : geoData.countryCode, "."] }), jsx$2(Button, { fullWidth: true, onClick: onDismiss, children: "Close" })] }));
74196
+ };
74197
+
74175
74198
  const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) => {
74176
74199
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
74177
74200
  const SDKConfig = useSDKConfig();
74201
+ const { data: geoData } = useGeoFencing();
74178
74202
  // State
74179
74203
  const [modalVariant, setModalVariant] = useState(SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.modalVariant);
74180
74204
  const [accordionVisible, setAccordionVisible] = useState(false);
@@ -74342,13 +74366,26 @@ const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) =
74342
74366
  }
74343
74367
  }
74344
74368
  });
74369
+ const [openGeofencingModal] = useModal(jsx$2(RestrictedRegionModal, {}));
74370
+ const blockedBondsForAE = [
74371
+ '0x0719CCaF2f07f59b23DB7d80E3d2791A0836bdfD'.toLowerCase(),
74372
+ '0xBc48794a04777E7170bD5633E8b728f8a0945971'.toLowerCase(),
74373
+ '0x94A283756B70c2A77bc58Ae0E2615Caf14310186'.toLowerCase(),
74374
+ '0x6639D4acAe77967c253C75cBfEd7C612682E2704'.toLowerCase(),
74375
+ ];
74345
74376
  const handleBothPurchases = () => {
74346
- setLoadingTx(true);
74347
- if (isZap) {
74348
- handleZapCallback().finally(() => setLoadingTx(false));
74377
+ var _a, _b;
74378
+ if ((geoData === null || geoData === void 0 ? void 0 : geoData.countryCode) === 'AE' && blockedBondsForAE.includes((_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '')) {
74379
+ openGeofencingModal();
74349
74380
  }
74350
74381
  else {
74351
- handleBuyCallback().finally(() => setLoadingTx(false));
74382
+ setLoadingTx(true);
74383
+ if (isZap) {
74384
+ handleZapCallback().finally(() => setLoadingTx(false));
74385
+ }
74386
+ else {
74387
+ handleBuyCallback().finally(() => setLoadingTx(false));
74388
+ }
74352
74389
  }
74353
74390
  };
74354
74391
  const openExternal = () => {
@@ -74448,7 +74485,6 @@ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
74448
74485
  const { data: userBonds, refetch } = useUserBonds();
74449
74486
  const userBill = userBonds === null || userBonds === void 0 ? void 0 : userBonds.find((bond) => bond.id === billId);
74450
74487
  useEffect(() => {
74451
- console.log(billId);
74452
74488
  if (billId) {
74453
74489
  console.log('BillId detected, Refetching user bonds');
74454
74490
  refetch();
@@ -74775,7 +74811,7 @@ const BondRowsByChain = ({ bonds, hideTitles }) => {
74775
74811
  const SDKConfig = useSDKConfig();
74776
74812
  const validatedChains = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.chains) === null || _a === void 0 ? void 0 : _a.filter((chain) => MAINNET_CHAINS.includes(chain));
74777
74813
  return (jsx$2(Flex$1, { className: "bondrowsbychain", children: validatedChains === null || validatedChains === void 0 ? void 0 : validatedChains.map((chain) => {
74778
- return (jsx$2(BondRowsWithTitle, { chain: chain, bonds: bonds, hideTitles: hideTitles, showHotBonds: SDKConfig.useHotBonds ? chain === types.ChainId.BASE || chain === types.ChainId.MAINNET : false }, chain));
74814
+ return (jsx$2(BondRowsWithTitle, { chain: chain, bonds: bonds, hideTitles: hideTitles, showHotBonds: hideTitles ? false : SDKConfig.useHotBonds ? chain === types.ChainId.BASE || chain === types.ChainId.MAINNET : false }, chain));
74779
74815
  }) }));
74780
74816
  };
74781
74817
 
@@ -74949,6 +74985,7 @@ const BondsMenu = ({ searchQuery, setSearchQuery, setChainFilterOption, chainFil
74949
74985
  const Bonds = () => {
74950
74986
  // Fetch data
74951
74987
  useHotBonds();
74988
+ useGeoFencing();
74952
74989
  const { favTokens } = useFavoriteTokens();
74953
74990
  const { data: bondData, refetch: refetchBondsData } = useBondsData();
74954
74991
  const { data: allBonds } = useBondsList();
@@ -90717,6 +90754,7 @@ const SalesTable = ({ allSales }) => {
90717
90754
  const receivedUsdAmount = ((_a = sale === null || sale === void 0 ? void 0 : sale.payout) !== null && _a !== void 0 ? _a : 0) * (sale === null || sale === void 0 ? void 0 : sale.payoutTokenPrice);
90718
90755
  const discount = 100 - (sale.dollarValue * 100) / receivedUsdAmount;
90719
90756
  const isUserTheBuyer = (buyer === null || buyer === void 0 ? void 0 : buyer.toLowerCase()) === (account === null || account === void 0 ? void 0 : account.toLowerCase());
90757
+ const payoutToken = sale.payoutToken === 'LL.e' ? 'LL' : sale.payoutToken;
90720
90758
  return (jsxs(Flex, { sx: {
90721
90759
  width: '100%',
90722
90760
  background: 'white3',
@@ -90727,7 +90765,7 @@ const SalesTable = ({ allSales }) => {
90727
90765
  alignItems: 'center',
90728
90766
  justifyContent: 'space-between',
90729
90767
  fontSize: '12px',
90730
- }, children: [jsxs(Flex, { sx: { width: '170px', alignItems: 'center' }, children: [jsx$2(Flex, { sx: { width: '30px', justifyContent: 'center' }, children: index + 4 }), jsx$2(TokenImage, { symbol: sale.payoutToken, chain: sale.chainId, size: 28 }), jsx$2(Flex, { sx: { ml: '10px' }, children: sale.payoutToken })] }), jsx$2(Flex, { sx: { width: '120px', justifyContent: 'center' }, children: formatUTCDate(new Date(sale.createdAt * 1000)) }), jsx$2(Flex, { sx: { width: '160px', justifyContent: 'center', position: 'relative' }, children: jsxs(Flex, { sx: { position: 'relative' }, children: [buyer === null || buyer === void 0 ? void 0 : buyer.slice(0, 4), "...", buyer === null || buyer === void 0 ? void 0 : buyer.slice((buyer === null || buyer === void 0 ? void 0 : buyer.length) - 4, buyer === null || buyer === void 0 ? void 0 : buyer.length), isUserTheBuyer && jsx$2(Flex, { sx: styles$1.youCard, children: "You" })] }) }), jsxs(Flex, { sx: { width: '110px', justifyContent: 'center' }, children: ["$", sale.dollarValue.toFixed(2)] }), jsxs(Flex, { sx: { width: '110px', justifyContent: 'center' }, children: ["$", receivedUsdAmount === null || receivedUsdAmount === void 0 ? void 0 : receivedUsdAmount.toFixed(2)] }), jsxs(Flex, { sx: { width: '85px', justifyContent: 'center', color: discount > 0 ? 'success' : 'error' }, children: [discount.toFixed(2), "%"] })] }, sale.transactionHash));
90768
+ }, children: [jsxs(Flex, { sx: { width: '170px', alignItems: 'center' }, children: [jsx$2(Flex, { sx: { width: '30px', justifyContent: 'center' }, children: index + 4 }), jsx$2(TokenImage, { symbol: payoutToken, chain: sale.chainId, size: 28 }), jsx$2(Flex, { sx: { ml: '10px' }, children: sale.payoutToken })] }), jsx$2(Flex, { sx: { width: '120px', justifyContent: 'center' }, children: formatUTCDate(new Date(sale.createdAt * 1000)) }), jsx$2(Flex, { sx: { width: '160px', justifyContent: 'center', position: 'relative' }, children: jsxs(Flex, { sx: { position: 'relative' }, children: [buyer === null || buyer === void 0 ? void 0 : buyer.slice(0, 4), "...", buyer === null || buyer === void 0 ? void 0 : buyer.slice((buyer === null || buyer === void 0 ? void 0 : buyer.length) - 4, buyer === null || buyer === void 0 ? void 0 : buyer.length), isUserTheBuyer && jsx$2(Flex, { sx: styles$1.youCard, children: "You" })] }) }), jsxs(Flex, { sx: { width: '110px', justifyContent: 'center' }, children: ["$", sale.dollarValue.toFixed(2)] }), jsxs(Flex, { sx: { width: '110px', justifyContent: 'center' }, children: ["$", receivedUsdAmount === null || receivedUsdAmount === void 0 ? void 0 : receivedUsdAmount.toFixed(2)] }), jsxs(Flex, { sx: { width: '85px', justifyContent: 'center', color: discount > 0 ? 'success' : 'error' }, children: [discount.toFixed(2), "%"] })] }, sale.transactionHash));
90731
90769
  }) })] }));
90732
90770
  };
90733
90771
 
@@ -0,0 +1,5 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ export default function useGeoFencing(): UseQueryResult<{
3
+ isRestrictedRegion: boolean;
4
+ countryCode: string;
5
+ }>;
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": "2.2.8",
6
+ "version": "2.2.10",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",