@ape.swap/bonds-sdk 1.0.495 → 1.0.497

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,10 @@
1
1
  /** @jsxImportSource theme-ui */
2
2
  import React from 'react';
3
+ import { UserBill } from '../../../types/yourbonds';
3
4
  import '../../../scss/YourBondsModal.scss';
4
5
  declare const YourBondsModal: ({ isOpen, onClose, bond }: {
5
6
  isOpen: boolean;
6
7
  onClose: () => void;
7
- bond: any | null;
8
+ bond: UserBill | null;
8
9
  }) => React.JSX.Element | null;
9
10
  export default YourBondsModal;
@@ -11,12 +11,21 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "theme-ui/jsx-runtime";
13
13
  /** @jsxImportSource theme-ui */
14
- import { useEffect, useState } from 'react';
15
- import { Flex } from 'theme-ui';
14
+ import React, { useState } from 'react';
15
+ import { Flex, ThemeUIProvider } from 'theme-ui';
16
16
  import { useWeb3React } from '@web3-react/core';
17
17
  import { BigNumber } from 'bignumber.js';
18
+ import { AnimatePresence, motion } from 'framer-motion';
19
+ import { NETWORK_ICONS } from '../../../config/constants/chains';
18
20
  import { getBalanceNumber } from '../../../utils/getBalanceNumber';
19
21
  import { getFirstNonZeroDigits } from '../../../utils/roundNumber';
22
+ import { defaultTheme } from '../../../theme';
23
+ import TokenImage from '../../uikit-sdk/TokenImage';
24
+ import { Button, ListTag, Skeleton, Svg, Text, TooltipBubble } from '../../uikit-sdk';
25
+ import { UserBillTooltipText } from '../../../enum/tooltips';
26
+ import { getPendingVesting } from '../../../hooks/usePendingVesting';
27
+ import { formatNumberSI } from '../../../utils/formatNumber';
28
+ import { StyledHeadingText, TraitsContentContainer } from './styles';
20
29
  import '../../../scss/YourBondsModal.scss';
21
30
  var YourBondsModal = function (_a) {
22
31
  var isOpen = _a.isOpen, onClose = _a.onClose, bond = _a.bond;
@@ -26,32 +35,6 @@ var YourBondsModal = function (_a) {
26
35
  // Fetch data for user owned bill
27
36
  var _c = useState([]), bondData = _c[0], setBondData = _c[1];
28
37
  var _d = useState([]), userOwnedBillsData = _d[0], setUserOwnedBillsData = _d[1];
29
- // useEffect(() => {
30
- // console.log('HIT BOND ADDRESS')
31
- // axios.get('https://realtime-api.ape.bond/bonds').then(response => {
32
- // const bond = response.data.bonds.filter((x: any) =>
33
- // x.billAddress.toLowerCase() === bondAddress?.toLowerCase()
34
- // );
35
- // setBondData(bond);
36
- // });
37
- // }, [bondAddress]);
38
- // useEffect(() => {
39
- // const fetchData = async () => {
40
- // if (account) {
41
- // try {
42
- // const results = await Promise.all(
43
- // MAINNET_CHAINS.map((chain) => fetchUserOwnedBillsDataAsync(chain as number, account, bondData))
44
- // );
45
- // setUserOwnedBillsData(results);
46
- // } catch (error) {
47
- // console.error('Error fetching user owned bills data:', error);
48
- // }
49
- // }
50
- // };
51
- //
52
- // fetchData();
53
- //
54
- // }, [account]);
55
38
  // Functions to calculate display values for modal
56
39
  var totalPending = function (userBill) {
57
40
  var _a, _b, _c, _d;
@@ -68,12 +51,24 @@ var YourBondsModal = function (_a) {
68
51
  var BILL_ATTRIBUTES = ['The Legend', 'The Location', 'The Moment', 'The Trend', 'The Innovation'];
69
52
  var _e = useState(false), isOpenTraits = _e[0], setIsOpenTraits = _e[1];
70
53
  var _f = useState(false), billRendered = _f[0], setBillRendered = _f[1];
71
- useEffect(function () {
72
- console.log('BILL RENDER CHANGE');
73
- if (userOwnedBillsData.length > 0) {
74
- setBillRendered(true);
75
- }
76
- }, [userOwnedBillsData]);
77
- return (_jsxs(_Fragment, { children: [" ", _jsx(Flex, __assign({ className: "modal modal-backdrop" }, { children: _jsxs(Flex, __assign({ className: "modal modal-content" }, { children: [_jsx(Flex, __assign({ className: "modal modal-header" }, { children: "AA" })), _jsx(Flex, __assign({ className: "modal-container table-container" }, { children: "SCOTT TEST" }))] })) }))] }));
54
+ return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: _jsx(_Fragment, { children: userOwnedBillsData.flat().map(function (data) {
55
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
56
+ var userBill = data.userOwnedBills.find(function (bill) { var _a; return bill.bond.billAddress.toLowerCase() === ((_a = bond === null || bond === void 0 ? void 0 : bond.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
57
+ var attributes = (_b = (_a = userBill === null || userBill === void 0 ? void 0 : userBill.nftData) === null || _a === void 0 ? void 0 : _a.data.attributes) === null || _b === void 0 ? void 0 : _b.filter(function (attrib) { return BILL_ATTRIBUTES.includes(attrib.trait_type); });
58
+ return userBill ? (_jsx(React.Fragment, { children: _jsx(Flex, __assign({ className: "yourbondsmodal backdrop" }, { children: _jsxs(Flex, __assign({ className: "yourbondsmodal content" }, { children: [_jsx(Flex, __assign({ className: "yourbondsmodal header" }, { children: _jsx(Flex, __assign({ className: "svg-close", onClick: onClose }, { children: _jsx(Svg, { icon: "close" }) })) })), _jsxs(Flex, __assign({ className: "yourbondsmodal table-container" }, { children: [_jsx(Flex, __assign({ className: "yourbondsmodal bondimage" }, { children: _jsx("img", { src: (_c = userBill.nftData) === null || _c === void 0 ? void 0 : _c.data.image }) })), _jsxs(Flex, __assign({ className: "yourbondsmodal yourbondinfo" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo title-container" }, { children: [_jsx(Flex, __assign({ className: "title-container bondicon" }, { children: _jsxs("div", __assign({ className: "icon-container" }, { children: [_jsx(Svg, { width: 18, height: 18, icon: (_d = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _d !== void 0 ? _d : 'question' }), _jsx(TokenImage, { symbol: (_e = userBill.bond.showcaseTokenName) !== null && _e !== void 0 ? _e : userBill.bond.payoutTokenName, size: 40 })] })) })), _jsx(Flex, __assign({ className: "title-container tokenname" }, { children: _jsx(StyledHeadingText, { children: (_f = userBill.bond) === null || _f === void 0 ? void 0 : _f.showcaseTokenName }) })), _jsx(Flex, __assign({ className: "title-container tokentags" }, { children: (_g = userBill.bond.tags) === null || _g === void 0 ? void 0 : _g.slice(0, 1).map(function (tag) {
59
+ return (_jsx(Flex, __assign({ sx: { marginRight: '10px' } }, { children: _jsx(ListTag, { variant: tag === 'Cex Fund' ? 'cex_fund' : 'liquidity', text: tag === null || tag === void 0 ? void 0 : tag.toUpperCase() }) }), tag));
60
+ }) })), _jsxs(Text, __assign({ sx: { color: 'text', opacity: '0.6', fontSize: ['12px', '12px', '12px', '16px'] } }, { children: ["#", userBill.id] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo blocks-container" }, { children: [_jsx(Flex, __assign({ className: "yourbondinfo-block attributes" }, { children: _jsxs(Flex, __assign({ sx: { flexDirection: 'column', width: '100%' } }, { children: [_jsxs(Flex, __assign({ sx: {
61
+ justifyContent: 'space-between',
62
+ height: '24px',
63
+ background: 'white3',
64
+ px: '15px',
65
+ borderRadius: "".concat(isOpenTraits ? '6px 6px 0px 0px' : 'normal'),
66
+ display: ['none', 'none', 'none', 'flex'],
67
+ }, onClick: function () { return setIsOpenTraits(!isOpenTraits); } }, { children: [_jsxs(Flex, __assign({ sx: { gap: '10px', alignItems: 'center' } }, { children: [_jsx(Svg, { icon: "tag", direction: "down" }), _jsx(Text, __assign({ sx: { fontSize: '12px', fontWeight: 400, color: 'text', opacity: '0.6' } }, { children: "Traits" }))] })), _jsx(Svg, { icon: "caret", direction: isOpenTraits ? 'up' : 'down' })] })), _jsx(AnimatePresence, { children: isOpenTraits && (_jsx(motion.div, __assign({ initial: { height: 0 }, animate: { height: 'fit-content' }, transition: { opacity: { duration: 0.2 } }, exit: { height: 0 }, sx: { overflow: 'hidden', width: '100%' } }, { children: _jsx(Flex, __assign({ sx: { flexDirection: 'column', gap: '1px' } }, { children: attributes
68
+ ? attributes.map(function (a) { return (_jsxs(TraitsContentContainer, { children: [_jsx(Text, __assign({ sx: { fontSize: '10px', fontWeight: 500 } }, { children: a === null || a === void 0 ? void 0 : a.trait_type })), _jsx(Text, __assign({ sx: { fontSize: '10px', fontWeight: 500 } }, { children: a === null || a === void 0 ? void 0 : a.value }))] }, a.value)); })
69
+ : BILL_ATTRIBUTES.map(function (attrib) {
70
+ return (_jsxs(TraitsContentContainer, { children: [_jsx(Text, __assign({ sx: { fontSize: '10px', fontWeight: 500 } }, { children: attrib })), _jsx(Skeleton, { width: "150px" })] }, attrib));
71
+ }) })) }))) })] })) })), _jsxs(Flex, __assign({ className: "yourbondinfo-block row-vested" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo-block header" }, { children: [_jsx(Flex, __assign({ className: "yourbondinfo-block header-title" }, { children: "Fully Vested" })), _jsx(Flex, __assign({ className: "yourbondinfo-block header-tooltip" }, { children: _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) })) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block info" }, { children: [_jsx(Flex, { className: "block-info icon" }), _jsx(Flex, __assign({ className: "block-info text" }, { children: _jsx(Text, __assign({ sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 } }, { children: getPendingVesting(userBill.lastBlockTimestamp, userBill.vesting) })) }))] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block row-pending" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo-block header" }, { children: [_jsx(Flex, __assign({ className: "yourbondinfo-block header-title" }, { children: "Pending" })), _jsx(Flex, __assign({ className: "yourbondinfo-block header-tooltip" }, { children: _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) })) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block info" }, { children: [_jsx(Flex, __assign({ className: "block-info icon" }, { children: _jsxs("div", __assign({ className: "icon-container-small" }, { children: [_jsx(Svg, { width: 10, height: 10, icon: (_h = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _h !== void 0 ? _h : 'question' }), _jsx(TokenImage, { symbol: (_j = userBill.bond.showcaseTokenName) !== null && _j !== void 0 ? _j : userBill.bond.payoutTokenName, size: 25 })] })) })), _jsxs(Flex, __assign({ className: "block-info text" }, { children: [_jsx(Text, __assign({ sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 } }, { children: formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4) })), _jsx(Text, __assign({ sx: { fontSize: ['10px', '10px', '10px', '12px'], fontWeight: [500, 500, 500, 400], paddingLeft: '10px' } }, { children: "($".concat((totalPending(userBill) * ((_k = parseFloat(earnTokenPrice(userBill.bond))) !== null && _k !== void 0 ? _k : 0)).toFixed(2), ")") }))] }))] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block row-claimable" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo-block header" }, { children: [_jsx(Flex, __assign({ className: "yourbondinfo-block header-title" }, { children: "Claimable" })), _jsx(Flex, __assign({ className: "yourbondinfo-block header-tooltip" }, { children: _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) })) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block info" }, { children: [_jsx(Flex, __assign({ className: "block-info icon" }, { children: _jsxs("div", __assign({ className: "icon-container-small" }, { children: [_jsx(Svg, { width: 10, height: 10, icon: (_l = NETWORK_ICONS === null || NETWORK_ICONS === void 0 ? void 0 : NETWORK_ICONS[userBill.bond.chainId]) !== null && _l !== void 0 ? _l : 'question' }), _jsx(TokenImage, { symbol: (_m = userBill.bond.showcaseTokenName) !== null && _m !== void 0 ? _m : userBill.bond.payoutTokenName, size: 25 })] })) })), _jsxs(Flex, __assign({ className: "block-info text" }, { children: [_jsx(Text, __assign({ sx: { fontSize: ['12px', '12px', '12px', '19px'], fontWeight: 700 } }, { children: formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4) })), _jsx(Text, __assign({ sx: { fontSize: ['10px', '10px', '10px', '12px'], fontWeight: [500, 500, 500, 400], paddingLeft: '10px' } }, { children: "($".concat((claimable(userBill) * ((_o = parseFloat(earnTokenPrice(userBill.bond))) !== null && _o !== void 0 ? _o : 0)).toFixed(2), ")") }))] }))] }))] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo button-container" }, { children: [_jsx(Flex, __assign({ className: "button-container claim" }, { children: _jsx(Button, { children: "CLAIM" }) })), _jsx(Flex, __assign({ className: "button-container transfer" }, { children: _jsx(Button, __assign({ variant: "secondary" }, { children: "TRANSFER" })) }))] }))] }))] }))] })) })) }, userBill.bond.billAddress)) : null;
72
+ }) }) })));
78
73
  };
79
74
  export default YourBondsModal;
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.0.495",
6
+ "version": "1.0.497",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",