@ape.swap/bonds-sdk 1.1.0-test.91 → 1.1.0-test.93

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.
@@ -2,4 +2,24 @@ import { ChainId } from '@ape.swap/apeswap-lists';
2
2
  export declare const useMonitorTxHash: (txHash?: string | null, chainId?: ChainId) => {
3
3
  isLoading: boolean;
4
4
  isSuccess: boolean;
5
+ data: {
6
+ blobGasPrice?: bigint | undefined;
7
+ blobGasUsed?: bigint | undefined;
8
+ blockHash: import("viem").Hash;
9
+ blockNumber: bigint;
10
+ contractAddress: import("abitype").Address | null | undefined;
11
+ cumulativeGasUsed: bigint;
12
+ effectiveGasPrice: bigint;
13
+ from: import("abitype").Address;
14
+ gasUsed: bigint;
15
+ logs: import("viem").Log<bigint, number, false>[];
16
+ logsBloom: import("viem").Hex;
17
+ root?: import("viem").Hash | undefined;
18
+ status: "success" | "reverted";
19
+ to: import("abitype").Address | null;
20
+ transactionHash: import("viem").Hash;
21
+ transactionIndex: number;
22
+ type: import("viem").TransactionType;
23
+ chainId: number;
24
+ } | undefined;
5
25
  };
package/dist/main.js CHANGED
@@ -42839,11 +42839,12 @@ const usePopups = () => {
42839
42839
 
42840
42840
  const useMonitorTxHash = (txHash, chainId) => {
42841
42841
  const { addToastError, addToastSuccess } = usePopups();
42842
- const { isLoading, isSuccess: isConfirmed, error, isError, } = useWaitForTransactionReceipt({
42842
+ const transactionReceipt = useWaitForTransactionReceipt({
42843
42843
  confirmations: 0,
42844
42844
  chainId: chainId,
42845
42845
  hash: txHash,
42846
42846
  });
42847
+ const { isLoading, isSuccess: isConfirmed, error, isError, data } = transactionReceipt !== null && transactionReceipt !== void 0 ? transactionReceipt : {};
42847
42848
  useEffect(() => {
42848
42849
  if (txHash && isError) {
42849
42850
  addToastError(error.message, txHash, chainId);
@@ -42852,7 +42853,7 @@ const useMonitorTxHash = (txHash, chainId) => {
42852
42853
  addToastSuccess(txHash, chainId);
42853
42854
  }
42854
42855
  }, [txHash, isError, isConfirmed, isLoading]);
42855
- return { isLoading, isSuccess: isConfirmed };
42856
+ return { isLoading, isSuccess: isConfirmed, data };
42856
42857
  };
42857
42858
 
42858
42859
  const TransferAction = ({ userBill, toAddress, disabled, }) => {
@@ -70771,7 +70772,7 @@ function useCurrencyPrice(currency, chainId) {
70771
70772
  }
70772
70773
 
70773
70774
  const YourBondsModal = ({ onDismiss, userBill }) => {
70774
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
70775
+ 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;
70775
70776
  // Hooks
70776
70777
  const chainId = useChainId();
70777
70778
  const { switchChain } = useSwitchChain();
@@ -70808,12 +70809,12 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
70808
70809
  });
70809
70810
  // Functions to calculate display values for modal
70810
70811
  const totalPending = (userBill) => {
70811
- var _a, _b, _c, _d;
70812
- return getBalanceNumber(new BigNumber$1((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_d = (_c = (_b = userBill.bond.earnToken) === null || _b === void 0 ? void 0 : _b.decimals) === null || _c === void 0 ? void 0 : _c[userBill.bond.chainId]) !== null && _d !== void 0 ? _d : 18);
70812
+ var _a, _b, _c, _d, _e, _f;
70813
+ return getBalanceNumber(new BigNumber$1((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_f = (_d = (_c = (_b = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _b === void 0 ? void 0 : _b.earnToken) === null || _c === void 0 ? void 0 : _c.decimals) === null || _d === void 0 ? void 0 : _d[(_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _e === void 0 ? void 0 : _e.chainId]) !== null && _f !== void 0 ? _f : 18);
70813
70814
  };
70814
70815
  const claimable = (userBill) => {
70815
- var _a, _b, _c;
70816
- return getBalanceNumber(new BigNumber$1(userBill.pendingRewards), (_c = (_b = (_a = userBill.bond.earnToken) === null || _a === void 0 ? void 0 : _a.decimals) === null || _b === void 0 ? void 0 : _b[userBill.bond.chainId]) !== null && _c !== void 0 ? _c : 18);
70816
+ var _a, _b, _c, _d, _e, _f;
70817
+ return getBalanceNumber(new BigNumber$1((_a = userBill === null || userBill === void 0 ? void 0 : userBill.pendingRewards) !== null && _a !== void 0 ? _a : '0'), (_f = (_d = (_c = (_b = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _b === void 0 ? void 0 : _b.earnToken) === null || _c === void 0 ? void 0 : _c.decimals) === null || _d === void 0 ? void 0 : _d[(_e = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _e === void 0 ? void 0 : _e.chainId]) !== null && _f !== void 0 ? _f : 18);
70817
70818
  };
70818
70819
  const earnTokenPrice = useCurrencyPrice((_c = userBill === null || userBill === void 0 ? void 0 : userBill.bond.earnToken) !== null && _c !== void 0 ? _c : null, (_e = (_d = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _d === void 0 ? void 0 : _d.chainId) !== null && _e !== void 0 ? _e : null);
70819
70820
  const BILL_ATTRIBUTES = ['The Legend', 'The Location', 'The Moment', 'The Trend', 'The Innovation'];
@@ -70829,29 +70830,30 @@ const YourBondsModal = ({ onDismiss, userBill }) => {
70829
70830
  justifyContent: 'center',
70830
70831
  alignItems: 'center',
70831
70832
  zIndex: 1,
70832
- }, children: jsx$2(Spinner, { width: 100 }) }))] }), jsxs(Flex$1, { className: "yourbondsmodal yourbondinfo", children: [jsxs(Flex$1, { className: "yourbondinfo title-container", children: [jsx$2(Flex$1, { className: "title-container bondicon", children: jsx$2(TokenImage, { symbol: (_g = userBill.bond.showcaseTokenName) !== null && _g !== void 0 ? _g : userBill.bond.earnToken.symbol, size: 40, chain: userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId }) }), jsx$2(Flex$1, { className: "title-container tokenname", children: (_j = (_h = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _h === void 0 ? void 0 : _h.showcaseTokenName) !== null && _j !== void 0 ? _j : userBill === null || userBill === void 0 ? void 0 : userBill.bond.earnToken.symbol }), jsx$2(Flex$1, { className: "title-container tokentags", children: (_k = userBill.bond.tags) === null || _k === void 0 ? void 0 : _k.slice(0, 1).map((tag) => {
70833
+ }, children: jsx$2(Spinner, { width: 100 }) }))] }), jsxs(Flex$1, { className: "yourbondsmodal yourbondinfo", children: [jsxs(Flex$1, { className: "yourbondinfo title-container", children: [jsx$2(Flex$1, { className: "title-container bondicon", children: userBill && (jsx$2(TokenImage, { symbol: (_h = (_g = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _g === void 0 ? void 0 : _g.showcaseTokenName) !== null && _h !== void 0 ? _h : (_k = (_j = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _j === void 0 ? void 0 : _j.earnToken) === null || _k === void 0 ? void 0 : _k.symbol, size: 40, chain: userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId })) }), jsx$2(Flex$1, { className: "title-container tokenname", children: (_m = (_l = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _l === void 0 ? void 0 : _l.showcaseTokenName) !== null && _m !== void 0 ? _m : userBill === null || userBill === void 0 ? void 0 : userBill.bond.earnToken.symbol }), jsx$2(Flex$1, { className: "title-container tokentags", children: (_p = (_o = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _o === void 0 ? void 0 : _o.tags) === null || _p === void 0 ? void 0 : _p.slice(0, 1).map((tag) => {
70833
70834
  return (jsx$2(Flex$1, { sx: { marginRight: '10px' }, children: jsx$2(ListTag, { text: tag === null || tag === void 0 ? void 0 : tag.toUpperCase() }) }, tag));
70834
- }) }), jsxs(Text, { sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] }, children: ["#", userBill.id] })] }), jsxs(Flex$1, { className: "yourbondinfo blocks-container", children: [jsxs(Flex$1, { className: "attributes-container", children: [jsxs(Flex$1, { className: "attributes-header", sx: {
70835
+ }) }), jsxs(Text, { sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] }, children: ["#", userBill === null || userBill === void 0 ? void 0 : userBill.id] })] }), jsxs(Flex$1, { className: "yourbondinfo blocks-container", children: [jsxs(Flex$1, { className: "attributes-container", children: [jsxs(Flex$1, { className: "attributes-header", sx: {
70835
70836
  borderRadius: `${isOpenTraits ? '6px 6px 0px 0px' : 'normal'}`,
70836
70837
  }, onClick: () => setIsOpenTraits(!isOpenTraits), children: [jsxs(Flex$1, { sx: { gap: '10px', alignItems: 'center' }, children: [jsx$2(Svg, { icon: "tag", direction: "down" }), jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'text', opacity: '0.6' }, children: "Traits" })] }), jsx$2(Svg, { icon: "caret", direction: isOpenTraits ? 'up' : 'down' })] }), jsx$2(AnimatePresence, { children: isOpenTraits && (jsx$2(motion.div, { initial: { height: 0 }, animate: { height: 'fit-content' }, transition: { opacity: { duration: 0.2 } }, exit: { height: 0 }, sx: { overflow: 'hidden', width: '100%' }, children: jsx$2(Flex$1, { sx: { flexDirection: 'column', gap: '1px' }, children: attributes
70837
70838
  ? attributes.map((a) => (jsxs(Flex$1, { sx: { background: 'white4', width: '100%', padding: '2px 8px' }, children: [jsx$2(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: a === null || a === void 0 ? void 0 : a.trait_type }), jsx$2(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: a === null || a === void 0 ? void 0 : a.value })] }, a.value)))
70838
70839
  : BILL_ATTRIBUTES.map((attrib) => {
70839
70840
  return (jsxs(Flex$1, { sx: { background: 'white4', width: '100%', padding: '2px 8px' }, children: [jsx$2(Text, { sx: { fontSize: '10px', fontWeight: 500 }, children: attrib }), jsx$2(Skeleton, { width: "150px" })] }, attrib));
70840
- }) }) })) })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon" }), jsx$2(Flex$1, { className: "block-info text", children: jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: getPendingVesting((_l = userBill.lastBlockTimestamp) !== null && _l !== void 0 ? _l : '', (_m = userBill.vesting) !== null && _m !== void 0 ? _m : '') }) })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-pending", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Pending" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: jsx$2(TokenImage, { symbol: (_o = userBill.bond.showcaseTokenName) !== null && _o !== void 0 ? _o : userBill.bond.earnToken.symbol, size: 25, chain: (_p = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _p === void 0 ? void 0 : _p.chainId }) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
70841
+ }) }) })) })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-vested", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Fully Vested" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon" }), jsx$2(Flex$1, { className: "block-info text", children: jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: getPendingVesting((_q = userBill === null || userBill === void 0 ? void 0 : userBill.lastBlockTimestamp) !== null && _q !== void 0 ? _q : '', (_r = userBill === null || userBill === void 0 ? void 0 : userBill.vesting) !== null && _r !== void 0 ? _r : '') }) })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-pending", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Pending" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_t = (_s = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _s === void 0 ? void 0 : _s.showcaseTokenName) !== null && _t !== void 0 ? _t : (_v = (_u = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _u === void 0 ? void 0 : _u.earnToken) === null || _v === void 0 ? void 0 : _v.symbol, size: 25, chain: (_w = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _w === void 0 ? void 0 : _w.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
70841
70842
  fontSize: ['10px', '10px', '10px', '12px'],
70842
70843
  fontWeight: [500, 500, 500, 400],
70843
70844
  paddingLeft: '10px',
70844
- }, children: `($${(totalPending(userBill) * ((_q = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _q !== void 0 ? _q : 0)).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-claimable", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimable" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: jsx$2(TokenImage, { symbol: (_r = userBill.bond.showcaseTokenName) !== null && _r !== void 0 ? _r : userBill.bond.earnToken.symbol, size: 25, chain: (_s = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _s === void 0 ? void 0 : _s.chainId }) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
70845
+ }, children: `($${(totalPending(userBill) * ((_x = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _x !== void 0 ? _x : 0)).toFixed(2)})` })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo-block row-claimable", children: [jsxs(Flex$1, { className: "yourbondinfo-block header", children: [jsx$2(Flex$1, { className: "yourbondinfo-block header-title", children: "Claimable" }), jsx$2(Flex$1, { className: "yourbondinfo-block header-tooltip", children: jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Flex$1, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)", children: jsx$2(Flex$1, { className: "block-header icon", children: jsx$2(Svg, { icon: "questionCircle", width: "12px" }) }) }) })] }), jsxs(Flex$1, { className: "yourbondinfo-block info", children: [jsx$2(Flex$1, { className: "block-info icon", children: userBill && (jsx$2(TokenImage, { symbol: (_z = (_y = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _y === void 0 ? void 0 : _y.showcaseTokenName) !== null && _z !== void 0 ? _z : (_1 = (_0 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _0 === void 0 ? void 0 : _0.earnToken) === null || _1 === void 0 ? void 0 : _1.symbol, size: 25, chain: (_2 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _2 === void 0 ? void 0 : _2.chainId })) }), jsxs(Flex$1, { className: "block-info text", children: [jsx$2(Text, { sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 }, children: formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4) }), jsx$2(Text, { sx: {
70845
70846
  fontSize: ['10px', '10px', '10px', '12px'],
70846
70847
  fontWeight: [500, 500, 500, 400],
70847
70848
  paddingLeft: '10px',
70848
- }, children: `($${(claimable(userBill) * ((_t = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _t !== void 0 ? _t : 0)).toFixed(2)})` })] })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo button-container", children: [jsx$2(Flex$1, { className: "button-container claim", children: chainId !== (userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId) ? (jsxs(Button, { className: "switch-button", disabled: claimable(userBill) === 0 || load, onClick: (event) => {
70849
+ }, children: `($${(claimable(userBill) * ((_3 = earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.price) !== null && _3 !== void 0 ? _3 : 0)).toFixed(2)})` })] })] })] })] }), jsxs(Flex$1, { className: "yourbondinfo button-container", children: [jsx$2(Flex$1, { className: "button-container claim", children: userBill && chainId !== (userBill === null || userBill === void 0 ? void 0 : userBill.bond.chainId) ? (jsxs(Button, { className: "switch-button", disabled: claimable(userBill) === 0 || load, onClick: (event) => {
70850
+ var _a;
70849
70851
  event.stopPropagation();
70850
- switchChain({ chainId: userBill.bond.chainId });
70851
- }, children: ["Switch to ", NETWORK_LABEL[userBill.bond.chainId]] })) : (jsx$2(Button, { className: "claim-button", disabled: claimable(userBill) === 0 || load, load: load, onClick: (event) => {
70852
+ switchChain({ chainId: (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.chainId });
70853
+ }, children: ["Switch to ", NETWORK_LABEL[(_4 = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _4 === void 0 ? void 0 : _4.chainId]] })) : (jsx$2(Button, { className: "claim-button", disabled: claimable(userBill) === 0 || load || !userBill, load: load, onClick: (event) => {
70852
70854
  event.stopPropagation();
70853
- handleClaim(userBill.id, userBill.address);
70854
- }, children: "Claim" })) }), jsx$2(Flex$1, { className: "button-container transfer", children: jsx$2(Button, { className: "transfer-button", variant: "secondary", onClick: onTransferBondModal, children: "TRANSFER" }) })] })] })] }), jsx$2(Recommendations, { onDismiss: onDismiss, billAddress: userBill === null || userBill === void 0 ? void 0 : userBill.address })] }) }));
70855
+ handleClaim(userBill === null || userBill === void 0 ? void 0 : userBill.id, userBill === null || userBill === void 0 ? void 0 : userBill.address);
70856
+ }, children: "Claim" })) }), jsx$2(Flex$1, { className: "button-container transfer", children: jsx$2(Button, { className: "transfer-button", variant: "secondary", onClick: onTransferBondModal, disabled: !userBill, children: "TRANSFER" }) })] })] })] }), jsx$2(Recommendations, { onDismiss: onDismiss, billAddress: userBill === null || userBill === void 0 ? void 0 : userBill.address })] }) }));
70855
70857
  };
70856
70858
 
70857
70859
  const styles$4 = {
@@ -71381,7 +71383,8 @@ const YourBondsMenu = ({ chainFilterOption, setChainFilterOption, filterOptions,
71381
71383
  const YourBonds = () => {
71382
71384
  // Hooks
71383
71385
  const { address: account } = useAccount();
71384
- const { data: userBonds } = useUserBonds();
71386
+ const { favTokens } = useFavoriteTokens();
71387
+ const { data: userBonds, isFetched: userBondsFetched } = useUserBonds();
71385
71388
  const { data: chainFilterOption, setChainFilterOption } = useChainFilterOption();
71386
71389
  useTokenPrices();
71387
71390
  // State
@@ -71477,9 +71480,12 @@ const YourBonds = () => {
71477
71480
  return bond.pendingRewards !== '0';
71478
71481
  });
71479
71482
  }
71483
+ if (filterOption === 'FAVORITES') {
71484
+ filtered = filtered === null || filtered === void 0 ? void 0 : filtered.filter((userBill) => { var _a, _b, _c; return favTokens.includes((_c = (_b = (_a = userBill === null || userBill === void 0 ? void 0 : userBill.bond) === null || _a === void 0 ? void 0 : _a.earnToken) === null || _b === void 0 ? void 0 : _b.symbol) === null || _c === void 0 ? void 0 : _c.toLowerCase()); });
71485
+ }
71480
71486
  setFilteredBonds(filtered);
71481
71487
  }, [inputValue, sortedBonds, chainFilterOption, filterOption]);
71482
- return (jsxs(Flex$1, { className: "yourbonds table-container", children: [jsx$2(YourBondsMenu, { chainFilterOption: chainFilterOption, setChainFilterOption: setChainFilterOption, filterOptions: filterOptions, filterOption: filterOption, setFilterOption: setFilterOption, setInputValue: setInputValue, inputValue: inputValue, handleSort: handleSort }), !account ? (jsx$2(PlaceholderMonkey, { text: 'You are not connected' })) : filteredBonds && (filteredBonds === null || filteredBonds === void 0 ? void 0 : filteredBonds.length) > 0 ? (filteredBonds === null || filteredBonds === void 0 ? void 0 : filteredBonds.map((bill) => jsx$2(UserBondRow, { bill: bill }, bill.id))) : inputValue !== '' || !chainFilterOption.includes('All Chains') ? (jsx$2(PlaceholderMonkey, { text: 'No results, change filters!' })) : (jsx$2(Flex$1, { className: "yourbonds-spinner", children: jsx$2(Spinner, { size: 100 }) }))] }));
71488
+ return (jsxs(Flex$1, { className: "yourbonds table-container", children: [jsx$2(YourBondsMenu, { chainFilterOption: chainFilterOption, setChainFilterOption: setChainFilterOption, filterOptions: filterOptions, filterOption: filterOption, setFilterOption: setFilterOption, setInputValue: setInputValue, inputValue: inputValue, handleSort: handleSort }), !account ? (jsx$2(PlaceholderMonkey, { text: 'You are not connected' })) : filteredBonds && (filteredBonds === null || filteredBonds === void 0 ? void 0 : filteredBonds.length) > 0 ? (filteredBonds === null || filteredBonds === void 0 ? void 0 : filteredBonds.map((bill) => jsx$2(UserBondRow, { bill: bill }, bill.id))) : inputValue !== '' || !chainFilterOption.includes('All Chains') ? (jsx$2(PlaceholderMonkey, { text: 'No results, change filters!' })) : userBondsFetched && (userBonds === null || userBonds === void 0 ? void 0 : userBonds.length) === 0 ? (jsx$2(Fragment$1, { children: "No bonds" })) : (jsx$2(Flex$1, { className: "yourbonds-spinner", children: jsx$2(Spinner, { size: 100 }) }))] }));
71483
71489
  };
71484
71490
 
71485
71491
  // This basically returns the 2 tags with the higher active bond count
@@ -72830,7 +72836,7 @@ const BondModalHeader = ({ bondData, onDismiss }) => {
72830
72836
  }
72831
72837
  onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
72832
72838
  };
72833
- return (jsxs(Flex, { className: "modaltable-container title-container", children: [jsx$2(Flex, { className: "title-container bondicon", children: jsx$2(TokenImage, { symbol: (_a = bondData.showcaseTokenName) !== null && _a !== void 0 ? _a : bondData.earnToken.symbol, size: 50, chain: bondData.chainId }) }), jsxs(Flex, { className: "title-container bondname", children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, jsx$2(ListTag, { text: (_b = bondData === null || bondData === void 0 ? void 0 : bondData.tags) === null || _b === void 0 ? void 0 : _b[0] })] }), jsxs(Flex, { className: "title-container price-container", children: [jsxs(Flex, { className: "price-container price", children: ["$", earnTokenPrice(bondData)] }), jsxs(Flex, { className: "price-container discounted", children: ["$", discountEarnTokenPrice(bondData)] })] }), jsx$2(Flex, { className: "slipagge-close-icons", children: onDismiss ? (jsxs(Fragment$1, { children: [jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose }), jsx$2(Flex, { sx: { py: '3px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })] })) : (jsx$2(Flex, { sx: { py: '3px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })) })] }));
72839
+ return (jsxs(Flex, { className: "modaltable-container title-container", children: [jsx$2(Flex, { className: "title-container bondicon", children: jsx$2(TokenImage, { symbol: (_a = bondData.showcaseTokenName) !== null && _a !== void 0 ? _a : bondData.earnToken.symbol, size: 50, chain: bondData.chainId }) }), jsxs(Flex, { className: "title-container bondname", children: [bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName, jsx$2(ListTag, { text: (_b = bondData === null || bondData === void 0 ? void 0 : bondData.tags) === null || _b === void 0 ? void 0 : _b[0] })] }), jsxs(Flex, { className: "title-container price-container", children: [jsxs(Flex, { className: "price-container price", children: ["$", earnTokenPrice(bondData)] }), jsxs(Flex, { className: "price-container discounted", children: ["$", discountEarnTokenPrice(bondData)] })] }), jsx$2(Flex, { className: "slipagge-close-icons", children: jsxs(Fragment$1, { children: [jsx$2(IconButton, { icon: "close", color: "text", variant: "transparent", onClick: handleClose }), jsx$2(Flex, { sx: { py: '3px' }, onClick: onOpenSlippageModal, children: jsx$2(Svg, { icon: "cog", width: "16px" }) })] }) })] }));
72834
72840
  };
72835
72841
 
72836
72842
  const BondCards = ({ bondData }) => {
@@ -72893,7 +72899,7 @@ const ProjectDescription = ({ description }) => {
72893
72899
  }, onClick: () => setIsOpen(true), children: ["View More ", '>'] }))] }), jsx$2(Flex, { sx: { display: ['none', 'none', 'none', 'flex'] }, children: jsx$2(SafeHTMLComponent, { html: description !== null && description !== void 0 ? description : '' }) })] }));
72894
72900
  };
72895
72901
 
72896
- const BondModal = ({ onDismiss, bondAddress, bondChain,
72902
+ const BondModal = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
72897
72903
  // ??
72898
72904
  accordionTitle = 'What are Bonds?', accordionBody = 'Body', accordionVisible = false, }) => {
72899
72905
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
@@ -72953,6 +72959,7 @@ accordionTitle = 'What are Bonds?', accordionBody = 'Body', accordionVisible = f
72953
72959
  if (hash) {
72954
72960
  setBuyTxHash(hash);
72955
72961
  yield sendReferenceId(billAddress, userChainId, hash);
72962
+ handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
72956
72963
  }
72957
72964
  }
72958
72965
  catch (error) {
@@ -72976,6 +72983,7 @@ accordionTitle = 'What are Bonds?', accordionBody = 'Body', accordionVisible = f
72976
72983
  if (hash) {
72977
72984
  setBuyTxHash(hash);
72978
72985
  yield sendReferenceId((_c = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _c !== void 0 ? _c : '', userChainId, hash);
72986
+ handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
72979
72987
  }
72980
72988
  }
72981
72989
  catch (e) {
@@ -73025,6 +73033,45 @@ accordionTitle = 'What are Bonds?', accordionBody = 'Body', accordionVisible = f
73025
73033
  parseFloat(inputValue) === 0, onClick: approveCallback, children: ["approve ", isZap ? 'zap' : 'normal'] })) })] }), jsx$2(Flex, { sx: { width: '100%', marginTop: '10px', marginBottom: '10px' }, children: jsx$2("hr", { className: "fading-hr" }) }), jsxs(Flex, { sx: { width: '100%' }, children: [jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["Market Price: $", formatUSDNumber((youGet(bondData, inputValue) * lodashExports.toNumber(earnTokenPrice(bondData))).toString()), jsx$2("hr", { className: "fading-hr" }), jsx$2("span", { className: "text-highlight flex-inline", children: "Our price: " }), jsxs("span", { className: "flex-inline", children: ["$", formatUSDNumber((lodashExports.toNumber(inputValue) * lodashExports.toNumber(bondData.principalTokenPrice)).toString()), ' '] }), jsxs("span", { className: "text-highlight flex-inline", children: ["(discount rate ", bondData === null || bondData === void 0 ? void 0 : bondData.discount.toFixed(2), "%)"] })] }), jsx$2(Flex, { sx: { width: '50px', alignItems: 'center', justifyContent: 'center' }, children: "vs." }), jsxs(Flex, { sx: { width: '50%', flexDirection: 'column' }, children: ["If purchased from market:", ' ', (lodashExports.toNumber(inputValue) / lodashExports.toNumber(earnTokenPrice(bondData))).toFixed(0), ' ', bondData.earnToken.symbol, jsx$2("hr", { className: "fading-hr" }), jsx$2("span", { className: "text-highlight flex-inline", children: "Amount you will get:" }), ' ', youGet(bondData, inputValue).toFixed(0), ' ', jsx$2("span", { className: "flex-inline", children: bondData.earnToken.symbol })] })] })] })] })] }), jsxs(Flex, { className: "footer-details", children: [jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: ["Vesting start date:", ' ', new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }).format(new Date())] }), jsxs(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: ["Vesting end date:", ' ', new Intl.DateTimeFormat('en-GB', { day: '2-digit', month: 'short', year: 'numeric' }).format(new Date(Date.now() + vestingTime((_o = bondData === null || bondData === void 0 ? void 0 : bondData.vestingTerm) !== null && _o !== void 0 ? _o : 0).days * 86400000))] }), jsx$2(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: "Vesting type: Linear" }), jsx$2(Flex, { sx: { width: '25%', justifyContent: 'center' }, children: "What are bonds?" })] }), accordionVisible && (jsx$2(Flex, { className: "modaltable-container accordion-container", children: jsx$2(AccordionText, { title: accordionTitle, body: accordionBody, isVisible: accordionVisible }) }))] })) })) }));
73026
73034
  };
73027
73035
 
73036
+ /*
73037
+ * Basically this is a handler that controls which Modal is displayed to the user.
73038
+ * It will start by showing the buy modal and if a user purchases a bond, a hash will be set, this will initially trigger
73039
+ * a monitor of the txhash and the search for a bill Id. Finally, if a billId is found the YourBondModal will be shown.
73040
+ * */
73041
+ const ModalHandler = ({ onDismiss, bondAddress, bondChain, }) => {
73042
+ var _a;
73043
+ const [billId, setBillId] = useState('');
73044
+ const [buyTxHash, setBuyTxHash] = useState('');
73045
+ const { data: txReceipt } = useMonitorTxHash(buyTxHash, bondChain);
73046
+ const { data: bondsData } = useBondsData();
73047
+ const billNftAddress = txReceipt
73048
+ ? (_a = bondsData === null || bondsData === void 0 ? void 0 : bondsData.find((bond) => { var _a; return ((_a = bond === null || bond === void 0 ? void 0 : bond.billAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase()) && bond.chainId === bondChain; })) === null || _a === void 0 ? void 0 : _a.billNftAddress
73049
+ : '';
73050
+ if (txReceipt && billNftAddress) {
73051
+ try {
73052
+ const { logs } = txReceipt;
73053
+ const findBillNftLog = logs.find((log) => log.address.toLowerCase() === billNftAddress.toLowerCase());
73054
+ const getBillNftIndex = findBillNftLog === null || findBillNftLog === void 0 ? void 0 : findBillNftLog.topics[findBillNftLog.topics.length - 1];
73055
+ const convertHexId = parseInt(getBillNftIndex, 16);
73056
+ if (!billId) {
73057
+ console.log('set Bill id: ' + convertHexId.toString());
73058
+ setBillId(convertHexId.toString());
73059
+ }
73060
+ }
73061
+ catch (e) { }
73062
+ }
73063
+ const { data: userBonds, refetch } = useUserBonds();
73064
+ const userBill = userBonds === null || userBonds === void 0 ? void 0 : userBonds.find((bond) => bond.id === billId);
73065
+ useEffect(() => {
73066
+ console.log(billId);
73067
+ if (billId) {
73068
+ console.log('BillId detected, Refetching user bonds');
73069
+ refetch();
73070
+ }
73071
+ }, [billId]);
73072
+ return billId ? (jsx$2(YourBondsModal, { userBill: userBill, onDismiss: onDismiss })) : (jsx$2(BondModal, { bondAddress: bondAddress, bondChain: bondChain, handlePurchasedBond: setBuyTxHash, onDismiss: onDismiss }));
73073
+ };
73074
+
73028
73075
  /** CheckURL purpose is to open the buy bond modal ONLY IF a user has opened the site with a custom URL */
73029
73076
  const CheckUrl = () => {
73030
73077
  var _a, _b;
@@ -73040,7 +73087,7 @@ const CheckUrl = () => {
73040
73087
  return undefined;
73041
73088
  return bonds === null || bonds === void 0 ? void 0 : bonds.find((bond) => { var _a; return ((_a = bond === null || bond === void 0 ? void 0 : bond.billAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase()); });
73042
73089
  }, [bonds === null || bonds === void 0 ? void 0 : bonds.length]);
73043
- const [onPresentBuyBillsModal] = useModal(jsx$2(BondModal, { bondAddress: bondAddress, bondChain: parseInt(bondChain) }), true, true, `BuyBondModal:${bondAddress.toLowerCase()}-${bondChain}-${bond === null || bond === void 0 ? void 0 : bond.index}`);
73090
+ const [onPresentBuyBillsModal] = useModal(jsx$2(ModalHandler, { bondAddress: bondAddress, bondChain: parseInt(bondChain) }), true, true, `BuyBondModal:${bondAddress.toLowerCase()}-${bondChain}-${bond === null || bond === void 0 ? void 0 : bond.index}`);
73044
73091
  useEffect(() => {
73045
73092
  if (bond && bondChain && bondAddress) {
73046
73093
  onPresentBuyBillsModal();
@@ -73171,7 +73218,7 @@ const BondRow = ({ bond }) => {
73171
73218
  const billAddress = 'billAddress' in bond ? bond.billAddress : undefined;
73172
73219
  const discount = 'discount' in bond ? bond.discount : undefined;
73173
73220
  // Modal
73174
- const [openBuyModal] = useModal(jsx$2(BondModal, { bondAddress: billAddress, bondChain: bond.chainId }), true, true, `buyBondModal-${billAddress}-${bond.chainId}`);
73221
+ const [openBuyModal] = useModal(jsx$2(ModalHandler, { bondAddress: billAddress, bondChain: bond.chainId }), true, true, `buyBondModal-${billAddress}-${bond.chainId}`);
73175
73222
  const handleOpenModal = () => {
73176
73223
  openBuyModal();
73177
73224
  if (typeof window !== 'undefined') {
@@ -73468,7 +73515,7 @@ const Bonds = ({ chains = [] }) => {
73468
73515
  const { data: allBonds } = useBondsList();
73469
73516
  const { data: chainFilterOption, setChainFilterOption } = useChainFilterOption();
73470
73517
  // State
73471
- const [sortConfig, setSortConfig] = useState();
73518
+ const [sortConfig, setSortConfig] = useState({ key: 'discount', direction: 'desc' });
73472
73519
  const [searchQuery, setSearchQuery] = useState('');
73473
73520
  const [filterOption, setFilterOption] = useState('ALL');
73474
73521
  const sortedBonds = sortBonds(sortConfig, bondData);
@@ -73506,7 +73553,16 @@ const Bonds = ({ chains = [] }) => {
73506
73553
  const handleChangeFilterOption = useCallback((newOption) => {
73507
73554
  setFilterOption(newOption);
73508
73555
  }, []);
73509
- return (jsxs(Flex$1, { className: "bonds-container", children: [jsx$2(CheckUrl, {}), jsx$2(BondsMenu, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, setChainFilterOption: setChainFilterOption, chainFilterOption: chainFilterOption !== null && chainFilterOption !== void 0 ? chainFilterOption : ['All Chains'], filterOptions: filterOptions, filterOption: filterOption, setFilterOption: handleChangeFilterOption, onSort: handleSortOptions }), jsx$2(BuyAgainRow, {}), (billsToRender === null || billsToRender === void 0 ? void 0 : billsToRender.length) > 0 ? (jsxs(Fragment$1, { children: [jsx$2(BondRowsByChain, { chains: chains, bonds: billsToRender, hideTitles: searchQuery !== '' }), jsx$2(RecommendationCards, {})] })) : searchQuery ? (jsx$2(PlaceholderMonkey, { text: 'No results' })) : (jsx$2(Flex$1, { className: "bonds-spinner", children: jsx$2(Spinner, { size: 100 }) }))] }));
73556
+ return (jsxs(Flex$1, { className: "bonds-container", children: [jsx$2(CheckUrl, {}), jsx$2(BondsMenu, { searchQuery: searchQuery, setSearchQuery: setSearchQuery, setChainFilterOption: setChainFilterOption, chainFilterOption: chainFilterOption !== null && chainFilterOption !== void 0 ? chainFilterOption : ['All Chains'], filterOptions: filterOptions, filterOption: filterOption, setFilterOption: handleChangeFilterOption, onSort: handleSortOptions }), jsx$2(BuyAgainRow, {}), (billsToRender === null || billsToRender === void 0 ? void 0 : billsToRender.length) > 0 ? (jsx$2(BondRowsByChain, { chains: chains, bonds: billsToRender, hideTitles: searchQuery !== '' })) : searchQuery ? (jsx$2(PlaceholderMonkey, { text: 'No results' })) : filterOption === 'FAVORITES' ? (jsxs(Flex$1, { sx: {
73557
+ width: '100%',
73558
+ height: '300px',
73559
+ background: 'white2',
73560
+ borderRadius: 'normal',
73561
+ justifyContent: 'center',
73562
+ alignItems: 'center',
73563
+ flexDirection: 'column',
73564
+ mt: '10px',
73565
+ }, children: [jsx$2(Svg, { icon: "StarFilled", width: 75, height: 75 }), jsx$2(Flex$1, { sx: { mt: '10px' }, children: `You don't have any Favorite Bonds yet!` }), jsx$2(Flex$1, { sx: { fontSize: '12px', fontWeight: 400, color: 'textDisabledButton', mt: '10px' }, children: `Click on the 'star' or 'fire' icon to add Bonds to the list.` })] })) : (jsx$2(Flex$1, { className: "bonds-spinner", children: jsx$2(Spinner, { size: 100 }) })), jsx$2(RecommendationCards, {})] }));
73510
73566
  };
73511
73567
 
73512
73568
  var BondsViewOptions;
package/dist/styles.css CHANGED
@@ -47,7 +47,7 @@
47
47
  color: var(--theme-ui-colors-textDisabledButton);
48
48
  font-size: 14px;
49
49
  background: var(--theme-ui-colors-white2);
50
- border-radius: 15px;
50
+ border-radius: 10px;
51
51
  padding: 8px 16px;
52
52
  justify-content: center;
53
53
  font-weight: 500;
@@ -3,6 +3,7 @@ export interface BondModalProps {
3
3
  onDismiss?: () => void;
4
4
  bondAddress?: string;
5
5
  bondChain?: number;
6
+ handlePurchasedBond?: (hash: string) => void;
6
7
  accordionTitle?: string;
7
8
  accordionBody?: string;
8
9
  accordionVisible?: boolean;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ declare const ModalHandler: ({ onDismiss, bondAddress, bondChain, }: {
3
+ onDismiss?: () => void;
4
+ bondAddress?: string;
5
+ bondChain?: number;
6
+ }) => React.JSX.Element;
7
+ export default ModalHandler;
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": "1.1.0-test.91",
6
+ "version": "1.1.0-test.93",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",