@ape.swap/bonds-sdk 5.1.21 → 5.1.23
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,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'theme-ui/jsx-runtime';
|
|
2
|
-
import { useEffect } from 'react';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
3
|
import useBondsData from '../../../../state/bonds/useBondsData.js';
|
|
4
4
|
import useModal from '../../../../hooks/useModal.js';
|
|
5
5
|
import ModalHandler from '../BondRows/ModalHandler.js';
|
|
@@ -8,34 +8,66 @@ import ModalHandlerPreTGE from '../BondRows/ModalHandlerPreTGE.js';
|
|
|
8
8
|
|
|
9
9
|
/** CheckURL purpose is to open the buy bond modal ONLY IF a user has opened the site with a custom URL */
|
|
10
10
|
const CheckUrl = () => {
|
|
11
|
+
const hasRun = useRef(false);
|
|
11
12
|
const { data: bonds } = useBondsData();
|
|
12
13
|
const asPath = typeof window !== 'undefined' ? window.location.search : '';
|
|
13
14
|
const urlParams = typeof window !== 'undefined' ? new URLSearchParams(new URL(asPath, window.location.origin).search) : undefined;
|
|
14
15
|
const bondAddress = urlParams?.get('bondAddress') ?? '';
|
|
15
16
|
const bondChain = urlParams?.get('bondChain') ?? '';
|
|
17
|
+
const c = Boolean(urlParams?.get('c'));
|
|
16
18
|
const [onPresentBuyBillsModal] = useModal(jsx(ModalHandler, { bondAddress: bondAddress, bondChain: parseInt(bondChain) }), true, true, `buyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`);
|
|
17
19
|
const [onPresentPreTGEBondModal] = useModal(jsx(ModalHandlerPreTGE, { bondAddress: bondAddress, bondChain: parseInt(bondChain) }), true, true, `preTGEBuyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`);
|
|
18
20
|
useEffect(() => {
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// This useEffect triggers only once bonds data is loaded and if there is bond data on the URL params the buy modal would open.
|
|
22
|
+
if (!hasRun.current && bonds && bonds?.length > 0) {
|
|
23
|
+
hasRun.current = true;
|
|
24
|
+
const bond = bonds?.find((bond) => bond?.contractAddress?.[bond?.chainId]?.toLowerCase() === bondAddress?.toLowerCase() &&
|
|
25
|
+
Number(bondChain) === bond.chainId);
|
|
26
|
+
if (bond) {
|
|
27
|
+
if (bond.billType === 'fcfs') {
|
|
28
|
+
onPresentPreTGEBondModal();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
onPresentBuyBillsModal();
|
|
32
|
+
}
|
|
33
|
+
track({
|
|
34
|
+
event: 'buyModalOpen',
|
|
35
|
+
chain: bondChain,
|
|
36
|
+
data: {
|
|
37
|
+
cat: 'customURL',
|
|
38
|
+
bond: bond.earnToken.symbol,
|
|
39
|
+
bondChain: bondChain,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
23
42
|
}
|
|
24
|
-
else {
|
|
25
|
-
onPresentBuyBillsModal();
|
|
26
|
-
}
|
|
27
|
-
track({
|
|
28
|
-
event: 'buyModalOpen',
|
|
29
|
-
chain: bondChain,
|
|
30
|
-
data: {
|
|
31
|
-
cat: 'customURL',
|
|
32
|
-
bond: bond.earnToken.symbol,
|
|
33
|
-
bondChain: bondChain,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
43
|
}
|
|
37
44
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
38
45
|
}, [bonds?.length]);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
// This useEffect triggers only if the "c" flag is passed on the URL. The "c" flag stands for Custom behavior on opening the buy modal
|
|
48
|
+
if (c && bonds && bonds?.length > 0) {
|
|
49
|
+
const bond = bonds?.find((bond) => bond?.contractAddress?.[bond?.chainId]?.toLowerCase() === bondAddress?.toLowerCase() &&
|
|
50
|
+
Number(bondChain) === bond.chainId);
|
|
51
|
+
if (bond) {
|
|
52
|
+
if (bond.billType === 'fcfs') {
|
|
53
|
+
onPresentPreTGEBondModal();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
onPresentBuyBillsModal();
|
|
57
|
+
}
|
|
58
|
+
track({
|
|
59
|
+
event: 'buyModalOpen',
|
|
60
|
+
chain: bondChain,
|
|
61
|
+
data: {
|
|
62
|
+
cat: 'customURL',
|
|
63
|
+
bond: bond.earnToken.symbol,
|
|
64
|
+
bondChain: bondChain,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
70
|
+
}, [c]);
|
|
39
71
|
return jsx(Fragment, {});
|
|
40
72
|
};
|
|
41
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../src/views/Bonds/components/CheckURL/index.tsx"],"sourcesContent":["import React, { useEffect } from 'react'\nimport useBondsData from '../../../../state/bonds/useBondsData'\nimport useModal from '../../../../hooks/useModal'\nimport ModalHandler from '../BondRows/ModalHandler'\nimport track from '../../../../utils/track'\nimport ModalHandlerPreTGE from '../BondRows/ModalHandlerPreTGE'\n\n/** CheckURL purpose is to open the buy bond modal ONLY IF a user has opened the site with a custom URL */\n\nconst CheckUrl = () => {\n const { data: bonds } = useBondsData()\n\n const asPath = typeof window !== 'undefined' ? window.location.search : ''\n const urlParams =\n typeof window !== 'undefined' ? new URLSearchParams(new URL(asPath, window.location.origin).search) : undefined\n\n const bondAddress = urlParams?.get('bondAddress') ?? ''\n const bondChain = urlParams?.get('bondChain') ?? ''\n\n const [onPresentBuyBillsModal] = useModal(\n <ModalHandler bondAddress={bondAddress} bondChain={parseInt(bondChain)} />,\n true,\n true,\n `buyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`,\n )\n const [onPresentPreTGEBondModal] = useModal(\n <ModalHandlerPreTGE bondAddress={bondAddress} bondChain={parseInt(bondChain)} />,\n true,\n true,\n `preTGEBuyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`,\n )\n\n useEffect(() => {\n const bond = bonds?.find(\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/views/Bonds/components/CheckURL/index.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react'\nimport useBondsData from '../../../../state/bonds/useBondsData'\nimport useModal from '../../../../hooks/useModal'\nimport ModalHandler from '../BondRows/ModalHandler'\nimport track from '../../../../utils/track'\nimport ModalHandlerPreTGE from '../BondRows/ModalHandlerPreTGE'\n\n/** CheckURL purpose is to open the buy bond modal ONLY IF a user has opened the site with a custom URL */\n\nconst CheckUrl = () => {\n const hasRun = useRef(false)\n const { data: bonds } = useBondsData()\n\n const asPath = typeof window !== 'undefined' ? window.location.search : ''\n const urlParams =\n typeof window !== 'undefined' ? new URLSearchParams(new URL(asPath, window.location.origin).search) : undefined\n\n const bondAddress = urlParams?.get('bondAddress') ?? ''\n const bondChain = urlParams?.get('bondChain') ?? ''\n const c = Boolean(urlParams?.get('c'))\n\n const [onPresentBuyBillsModal] = useModal(\n <ModalHandler bondAddress={bondAddress} bondChain={parseInt(bondChain)} />,\n true,\n true,\n `buyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`,\n )\n const [onPresentPreTGEBondModal] = useModal(\n <ModalHandlerPreTGE bondAddress={bondAddress} bondChain={parseInt(bondChain)} />,\n true,\n true,\n `preTGEBuyBondModal:${bondAddress.toLowerCase()}-${bondChain}}`,\n )\n\n useEffect(() => {\n // This useEffect triggers only once bonds data is loaded and if there is bond data on the URL params the buy modal would open.\n if (!hasRun.current && bonds && bonds?.length > 0) {\n hasRun.current = true\n const bond = bonds?.find(\n (bond) =>\n bond?.contractAddress?.[bond?.chainId]?.toLowerCase() === bondAddress?.toLowerCase() &&\n Number(bondChain) === bond.chainId,\n )\n if (bond) {\n if (bond.billType === 'fcfs') {\n onPresentPreTGEBondModal()\n } else {\n onPresentBuyBillsModal()\n }\n track({\n event: 'buyModalOpen',\n chain: bondChain,\n data: {\n cat: 'customURL',\n bond: bond.earnToken.symbol,\n bondChain: bondChain,\n },\n })\n }\n }\n /* eslint-disable react-hooks/exhaustive-deps */\n }, [bonds?.length])\n\n useEffect(() => {\n // This useEffect triggers only if the \"c\" flag is passed on the URL. The \"c\" flag stands for Custom behavior on opening the buy modal\n if (c && bonds && bonds?.length > 0) {\n const bond = bonds?.find(\n (bond) =>\n bond?.contractAddress?.[bond?.chainId]?.toLowerCase() === bondAddress?.toLowerCase() &&\n Number(bondChain) === bond.chainId,\n )\n if (bond) {\n if (bond.billType === 'fcfs') {\n onPresentPreTGEBondModal()\n } else {\n onPresentBuyBillsModal()\n }\n track({\n event: 'buyModalOpen',\n chain: bondChain,\n data: {\n cat: 'customURL',\n bond: bond.earnToken.symbol,\n bondChain: bondChain,\n },\n })\n }\n }\n /* eslint-disable react-hooks/exhaustive-deps */\n }, [c])\n\n return <></>\n}\n\nexport default CheckUrl\n"],"names":["_jsx"],"mappings":";;;;;;;;AAOA;AAEA,MAAM,QAAQ,GAAG,MAAK;AACpB,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;IAC5B,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE;AAEtC,IAAA,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,EAAE;AAC1E,IAAA,MAAM,SAAS,GACb,OAAO,MAAM,KAAK,WAAW,GAAG,IAAI,eAAe,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS;IAEjH,MAAM,WAAW,GAAG,SAAS,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE;IACvD,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE;IACnD,MAAM,CAAC,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AAEtC,IAAA,M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