@ape.swap/bonds-sdk 3.0.14 → 3.0.15

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,2 +1,2 @@
1
1
  import { ChainId } from '@ape.swap/apeswap-lists';
2
- export declare const useSendReferenceId: () => (billContract: string, chainId: ChainId, hash: string) => Promise<void>;
2
+ export declare const useSendReferenceId: () => (billContract: string, chainId: ChainId, hash: string, reason?: string) => Promise<void>;
package/dist/main.js CHANGED
@@ -18779,6 +18779,7 @@ const TokenImage = ({ symbol, symbol2, size, chain, }) => {
18779
18779
 
18780
18780
  const QUERY_KEYS = {
18781
18781
  TIERS: 'tiers',
18782
+ AB_TEST_VALUE: 'ABTestValue',
18782
18783
  // used values on SDK
18783
18784
  BOND_API_STATS: 'ApeBond-SDK-bondApiStats',
18784
18785
  SDK_CONFIG: 'ApeBond-SDK-sdkConfig',
@@ -18803,10 +18804,18 @@ const QUERY_KEYS = {
18803
18804
 
18804
18805
  function useCookie(key, defaultValue) {
18805
18806
  const getCookie = () => {
18806
- const cookie = typeof window !== 'undefined' ? window.document.cookie.split('; ').find((row) => row.startsWith(key)) : null;
18807
- if (cookie)
18808
- return JSON.parse(cookie.slice(key.length + 1));
18809
- return defaultValue;
18807
+ if (typeof window === 'undefined')
18808
+ return defaultValue;
18809
+ try {
18810
+ const cookie = window.document.cookie.split('; ').find((row) => row.startsWith(key));
18811
+ if (!cookie)
18812
+ return defaultValue;
18813
+ const cookieValue = cookie.slice(key.length + 1);
18814
+ return JSON.parse(cookieValue);
18815
+ }
18816
+ catch (error) {
18817
+ return defaultValue;
18818
+ }
18810
18819
  };
18811
18820
  const [cookie, setCookieState] = useState(getCookie);
18812
18821
  const updateCookie = useCallback((value) => {
@@ -73265,12 +73274,13 @@ const useSoulZapBondQuote = (typedValue, inputCurrency, bond, account) => {
73265
73274
  const useSendReferenceId = () => {
73266
73275
  const config = useSDKConfig();
73267
73276
  const apiV2URL = useURLByEnvironment('apiV2');
73268
- return useCallback((billContract, chainId, hash) => __awaiter$9(void 0, void 0, void 0, function* () {
73277
+ return useCallback((billContract, chainId, hash, reason) => __awaiter$9(void 0, void 0, void 0, function* () {
73269
73278
  const data = {
73270
73279
  chainId,
73271
73280
  transactionHash: hash,
73272
73281
  referenceId: config === null || config === void 0 ? void 0 : config.referenceId,
73273
73282
  billContract,
73283
+ reason,
73274
73284
  };
73275
73285
  const response = yield axios.post(`${apiV2URL}/bills/widget`, data);
73276
73286
  console.log(response);
@@ -73806,22 +73816,45 @@ const SafeHTMLComponent = ({ html }) => {
73806
73816
  return jsx$2("div", { dangerouslySetInnerHTML: { __html: sanitizedHTML } });
73807
73817
  };
73808
73818
 
73819
+ var ABTestKeys;
73820
+ (function (ABTestKeys) {
73821
+ ABTestKeys["BOND_DESCRIPTION"] = "bondDescription";
73822
+ })(ABTestKeys || (ABTestKeys = {}));
73823
+ function useABTesting({ key, defaultValue = (Math.random() < 0.5).toString(), }) {
73824
+ const { cookie, updateCookie } = useCookie(QUERY_KEYS.AB_TEST_VALUE, null);
73825
+ let abTestValue = '';
73826
+ let parseCookie = null;
73827
+ if (cookie === null || cookie === undefined || cookie[key] === undefined) {
73828
+ parseCookie = Object.assign(Object.assign({}, cookie), { [key]: defaultValue.toString() });
73829
+ abTestValue = defaultValue.toString();
73830
+ updateCookie(parseCookie);
73831
+ }
73832
+ if (cookie) {
73833
+ parseCookie = cookie;
73834
+ if (parseCookie && parseCookie[key]) {
73835
+ abTestValue = parseCookie[key].toString();
73836
+ }
73837
+ }
73838
+ return { abTestValue };
73839
+ }
73840
+
73809
73841
  const ProjectDescription = ({ description }) => {
73810
73842
  const [isOpen, setIsOpen] = useState(false);
73811
- return (jsxs(Flex, { className: "description-container", children: [jsxs(Flex, { sx: { display: ['flex', 'flex', 'flex', 'none'], flexDirection: 'column' }, children: [jsx$2(Text, { sx: {
73812
- fontSize: ['12px', '12px', '12px', '14px'],
73813
- mt: '10px',
73814
- lineHeight: ['18px', '18px', '18px', '21px'],
73815
- fontWeight: 400,
73816
- overflow: 'hidden',
73817
- maxHeight: isOpen ? 'unset' : '54px',
73818
- }, children: description && jsx$2(SafeHTMLComponent, { html: description }) }), !isOpen && (jsxs(Text, { sx: {
73819
- color: 'primaryButton',
73820
- fontSize: '12px',
73821
- lineHeight: '18px',
73822
- fontWeight: 400,
73823
- cursor: 'pointer',
73824
- }, 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 : '' }) })] }));
73843
+ const { abTestValue } = useABTesting({ key: ABTestKeys.BOND_DESCRIPTION });
73844
+ return (jsx$2(Flex, { className: "description-container", children: abTestValue === 'true' && (jsxs(Fragment$1, { children: [jsxs(Flex, { sx: { display: ['flex', 'flex', 'flex', 'none'], flexDirection: 'column' }, children: [jsx$2(Text, { sx: {
73845
+ fontSize: ['12px', '12px', '12px', '14px'],
73846
+ mt: '10px',
73847
+ lineHeight: ['18px', '18px', '18px', '21px'],
73848
+ fontWeight: 400,
73849
+ overflow: 'hidden',
73850
+ maxHeight: isOpen ? 'unset' : '54px',
73851
+ }, children: description && jsx$2(SafeHTMLComponent, { html: description }) }), !isOpen && (jsxs(Text, { sx: {
73852
+ color: 'primaryButton',
73853
+ fontSize: '12px',
73854
+ lineHeight: '18px',
73855
+ fontWeight: 400,
73856
+ cursor: 'pointer',
73857
+ }, 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 : '' }) })] })) }));
73825
73858
  };
73826
73859
 
73827
73860
  // Fetch country code to check if the region is allowed
@@ -73920,6 +73953,8 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) =>
73920
73953
  const sendReferenceId = useSendReferenceId();
73921
73954
  const { data: userEscrowWeight } = useGetUserEscrowWeight(account);
73922
73955
  const userTier = getUserTier(userEscrowWeight !== null && userEscrowWeight !== void 0 ? userEscrowWeight : '0');
73956
+ const { abTestValue } = useABTesting({ key: ABTestKeys.BOND_DESCRIPTION });
73957
+ const reason = abTestValue === 'true' ? 'bondDescription' : 'noBondDescription';
73923
73958
  // State
73924
73959
  const bondData = 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()); });
73925
73960
  const minTier = (bondData === null || bondData === void 0 ? void 0 : bondData.minTier) !== undefined ? bondData.minTier : null;
@@ -73999,7 +74034,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) =>
73999
74034
  });
74000
74035
  if (hash) {
74001
74036
  setBuyTxHash(hash);
74002
- yield sendReferenceId(billAddress, userChainId, hash);
74037
+ yield sendReferenceId(billAddress, userChainId, hash, reason);
74003
74038
  handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
74004
74039
  track({
74005
74040
  event: 'bond',
@@ -74045,7 +74080,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond }) =>
74045
74080
  });
74046
74081
  if (hash) {
74047
74082
  setBuyTxHash(hash);
74048
- yield sendReferenceId((_d = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _d !== void 0 ? _d : '', userChainId, hash);
74083
+ yield sendReferenceId((_d = bondData === null || bondData === void 0 ? void 0 : bondData.billAddress) !== null && _d !== void 0 ? _d : '', userChainId, hash, reason);
74049
74084
  handlePurchasedBond === null || handlePurchasedBond === void 0 ? void 0 : handlePurchasedBond(hash);
74050
74085
  track({
74051
74086
  event: 'zap',
@@ -0,0 +1,9 @@
1
+ export declare enum ABTestKeys {
2
+ BOND_DESCRIPTION = "bondDescription"
3
+ }
4
+ export default function useABTesting({ key, defaultValue, }: {
5
+ key: ABTestKeys;
6
+ defaultValue?: string;
7
+ }): {
8
+ abTestValue: string;
9
+ };
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.14",
6
+ "version": "3.0.15",
7
7
  "module": "dist/main.js",
8
8
  "type": "module",
9
9
  "types": "dist/main.d.ts",
File without changes