@goodaofi/bonds-sdk 3.0.133 → 3.0.135
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.
- package/dist/config/constants/queryKeys.d.ts +1 -0
- package/dist/config/constants/tokens.d.ts +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.js +414 -61
- package/dist/state/useSDKConfig.d.ts +2 -0
- package/dist/views/GooPrivatePartners/GooPrivatePartners.d.ts +6 -0
- package/dist/views/GooPrivatePartners/TransactionModal.d.ts +19 -0
- package/dist/views/GooPrivatePartners/index.d.ts +7 -0
- package/dist/views/GooPrivatePartners/usePrivatePartnerInfo.d.ts +15 -0
- package/package.json +1 -1
|
@@ -2,4 +2,5 @@ import { Token, ChainId } from '@ape.swap/apeswap-lists';
|
|
|
2
2
|
export declare const WNATIVE: Partial<Record<ChainId, Token>>;
|
|
3
3
|
export declare const zapInputTokens: Partial<Record<ChainId, Token[]>>;
|
|
4
4
|
export declare const BTC_TOKENS: Partial<Record<ChainId, Token>>;
|
|
5
|
+
export declare const PRIVATE_PARTNERS_BTC_TOKENS: Partial<Record<ChainId, Token[]>>;
|
|
5
6
|
export declare const FAKE_BTC_TOKENS: Partial<Record<ChainId, Token>>;
|
package/dist/main.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ import { generateImageFromTemplate } from './views/YourBondsModal/components/Lin
|
|
|
7
7
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
8
8
|
import SingleBond from './views/SingleBond';
|
|
9
9
|
import GooSale from './views/GooSale';
|
|
10
|
-
|
|
10
|
+
import GooPrivatePartners from './views/GooPrivatePartners';
|
|
11
|
+
export { Bonds, BuyBondModal, YourBonds, FullBondsView, ProjectView, generateImageFromTemplate, ChainId, SingleBond, GooSale, GooPrivatePartners, };
|
package/dist/main.js
CHANGED
|
@@ -18879,7 +18879,7 @@ const APEBOND = `https://ape.bond`;
|
|
|
18879
18879
|
|
|
18880
18880
|
const TokenImage = ({ symbol, symbol2, size, chain, }) => {
|
|
18881
18881
|
var _a, _b;
|
|
18882
|
-
const isLocal = (symbol === null || symbol === void 0 ? void 0 : symbol.toLowerCase()) === 'goo' || (symbol === null || symbol === void 0 ? void 0 : symbol.toLowerCase()) === 'sgoo';
|
|
18882
|
+
const isLocal = (symbol === null || symbol === void 0 ? void 0 : symbol.toLowerCase()) === 'goo' || (symbol === null || symbol === void 0 ? void 0 : symbol.toLowerCase()) === 'sgoo' || (symbol === null || symbol === void 0 ? void 0 : symbol.toLowerCase()) === 'enzobtc';
|
|
18883
18883
|
const token1 = symbol === 'USDC.e' ? 'USDC' : symbol;
|
|
18884
18884
|
const token2 = symbol2 === 'USDC.e' ? 'USDC' : symbol2;
|
|
18885
18885
|
const token1Url = isLocal ? `/images/tokens/${token1}.png` : `${APEBOND}/tokenImages/${token1 === null || token1 === void 0 ? void 0 : token1.toUpperCase()}.png`;
|
|
@@ -58248,6 +58248,7 @@ const QUERY_KEYS = {
|
|
|
58248
58248
|
SALE_INFO: 'Goomoney-SDK-saleInfo',
|
|
58249
58249
|
USER_INFO: 'Goomoney-SDK-userInfo',
|
|
58250
58250
|
USER_GOO_DATA: 'Goomoney-SDK-userGooData',
|
|
58251
|
+
PRIVATE_PARTNER_INFO: 'Goomoney-SDK-privatePartnerInfo',
|
|
58251
58252
|
GOO_ELIGIBILITY: 'Goomoney-SDK-gooEligibility',
|
|
58252
58253
|
CBBTC_BALANCE: 'Goomoney-SDK-cbBTCBalance',
|
|
58253
58254
|
// used values on SDK
|
|
@@ -58290,7 +58291,7 @@ const stagingUrls = {
|
|
|
58290
58291
|
};
|
|
58291
58292
|
const useSDKConfig = (config) => {
|
|
58292
58293
|
const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls;
|
|
58293
|
-
const initialData = Object.assign(Object.assign({ referenceId: '', chains: [], hotBondChains: [types.ChainId.BSC, types.ChainId.MATIC], useHotBonds: true, useRainbowKit: false, useTiers: false, useTGEBonds: false, showLowValueBonds: false, bondPartner: undefined, namingPreference: 'Bonus' }, config), { urls: Object.assign(Object.assign({}, urls), config === null || config === void 0 ? void 0 : config.urls), highestCompatibleVersion: '2.1.3' });
|
|
58294
|
+
const initialData = Object.assign(Object.assign({ referenceId: '', chains: [], hotBondChains: [types.ChainId.BSC, types.ChainId.MATIC], useHotBonds: true, useRainbowKit: false, useTiers: false, useTGEBonds: false, showLowValueBonds: false, bondPartner: undefined, namingPreference: 'Bonus', privatePartnerName: '' }, config), { urls: Object.assign(Object.assign({}, urls), config === null || config === void 0 ? void 0 : config.urls), highestCompatibleVersion: '2.1.3' });
|
|
58294
58295
|
const { data } = useQuery({
|
|
58295
58296
|
queryKey: [QUERY_KEYS.SDK_CONFIG],
|
|
58296
58297
|
queryFn: () => {
|
|
@@ -64184,6 +64185,20 @@ const BTC_TOKENS = {
|
|
|
64184
64185
|
active: true,
|
|
64185
64186
|
},
|
|
64186
64187
|
};
|
|
64188
|
+
const PRIVATE_PARTNERS_BTC_TOKENS = {
|
|
64189
|
+
[types.ChainId.BASE]: [
|
|
64190
|
+
{
|
|
64191
|
+
symbol: 'enzoBTC',
|
|
64192
|
+
address: {
|
|
64193
|
+
[types.ChainId.BASE]: '0x6A9A65B84843F5fD4aC9a0471C4fc11AFfFBce4a',
|
|
64194
|
+
},
|
|
64195
|
+
decimals: {
|
|
64196
|
+
[types.ChainId.BASE]: 8,
|
|
64197
|
+
},
|
|
64198
|
+
active: true,
|
|
64199
|
+
},
|
|
64200
|
+
],
|
|
64201
|
+
};
|
|
64187
64202
|
const FAKE_BTC_TOKENS = {
|
|
64188
64203
|
[types.ChainId.BASE]: {
|
|
64189
64204
|
symbol: 'fBTC',
|
|
@@ -74522,8 +74537,8 @@ const LoadingSpinner = ({ isLoading, size }) => {
|
|
|
74522
74537
|
return jsx$2(Flex, { sx: isLoading ? stylesLoading : styles });
|
|
74523
74538
|
};
|
|
74524
74539
|
|
|
74525
|
-
const stepDelay$
|
|
74526
|
-
const TransactionModal$
|
|
74540
|
+
const stepDelay$2 = 1000;
|
|
74541
|
+
const TransactionModal$2 = ({ onDismiss, txChain, approvalState, approveCallback, loadingTx, txCallback, bondData, inputToken, inputValue, depositAmount, buyTxHash, rateChanged, }) => {
|
|
74527
74542
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
74528
74543
|
// Hooks
|
|
74529
74544
|
const { chain } = useAccount();
|
|
@@ -74572,7 +74587,7 @@ const TransactionModal$1 = ({ onDismiss, txChain, approvalState, approveCallback
|
|
|
74572
74587
|
const delay = setTimeout(() => {
|
|
74573
74588
|
hasTriggeredSwitch.current = true;
|
|
74574
74589
|
handleSwitchChain();
|
|
74575
|
-
}, stepDelay$
|
|
74590
|
+
}, stepDelay$2);
|
|
74576
74591
|
return () => clearTimeout(delay);
|
|
74577
74592
|
}
|
|
74578
74593
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
@@ -74586,7 +74601,7 @@ const TransactionModal$1 = ({ onDismiss, txChain, approvalState, approveCallback
|
|
|
74586
74601
|
const delay = setTimeout(() => {
|
|
74587
74602
|
setApproveLoading(false);
|
|
74588
74603
|
setHasToApprove(false);
|
|
74589
|
-
}, stepDelay$
|
|
74604
|
+
}, stepDelay$2);
|
|
74590
74605
|
return () => clearTimeout(delay);
|
|
74591
74606
|
}
|
|
74592
74607
|
else if (!hasTriggeredApproval.current && approvalState !== ApprovalState.PENDING) {
|
|
@@ -74910,7 +74925,7 @@ const BuyBond$1 = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isP
|
|
|
74910
74925
|
};
|
|
74911
74926
|
// Modals
|
|
74912
74927
|
const [openNewRateModal] = useModal(jsx$2(NewRateModal$1, { bond: bondData, zapTrueBondPrice: zapTrueBondPrice, depositAmount: depositAmount, youSpendString: youSpendString, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), true, false, 'newRateModal');
|
|
74913
|
-
const [openTxModal] = useModal(jsx$2(TransactionModal$
|
|
74928
|
+
const [openTxModal] = useModal(jsx$2(TransactionModal$2, { txChain: bondChain, approvalState: approvalState, approveCallback: handleApprove, loadingTx: loadingTx, txCallback: handleBothPurchases, bondData: bondData, inputToken: inputToken, inputValue: inputValue, depositAmount: depositAmount, buyTxHash: buyTxHash, rateChanged: rateChanged }), false, true, 'transactionModal');
|
|
74914
74929
|
const [onOpenZapModal] = useModal(jsx$2(ZapModal, { outputToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, account: account, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId }), true, true, 'zapModal');
|
|
74915
74930
|
const [openNoBonusModal] = useModal(jsx$2(NoBonusModal, { onAcknowledge: openTxModal, showcaseTokenName: bondData === null || bondData === void 0 ? void 0 : bondData.showcaseTokenName }), true, true, 'NoBonusModal');
|
|
74916
74931
|
// Effects
|
|
@@ -75188,7 +75203,7 @@ const PreTGEBuyComponent = ({ bondAddress, bondChain, onDismiss, handlePurchased
|
|
|
75188
75203
|
setLoading(false);
|
|
75189
75204
|
});
|
|
75190
75205
|
});
|
|
75191
|
-
const [openTxModal] = useModal(jsx$2(TransactionModal$
|
|
75206
|
+
const [openTxModal] = useModal(jsx$2(TransactionModal$2, { txChain: bondChain, approvalState: approvalState, approveCallback: handleApprove, loadingTx: loading, txCallback: onBuyBill, bondData: bond, inputToken: bond.lpToken, inputValue: inputValue, depositAmount: inputValue, buyTxHash: buyTxHash, rateChanged: false }), false, true, 'transactionModal');
|
|
75192
75207
|
const { data: currencyBalanceString } = useCurrencyBalance(bond.lpToken, address, bond.chainId);
|
|
75193
75208
|
const exceedsBalance = parseFloat(inputValue) > parseFloat(currencyBalanceString !== null && currencyBalanceString !== void 0 ? currencyBalanceString : '0');
|
|
75194
75209
|
const saleStartTime = ((_g = (_f = bond === null || bond === void 0 ? void 0 : bond.initTime) === null || _f === void 0 ? void 0 : _f[bond.chainId]) !== null && _g !== void 0 ? _g : 0) * 1000;
|
|
@@ -93856,8 +93871,8 @@ const transformUserData = (rawData) => {
|
|
|
93856
93871
|
};
|
|
93857
93872
|
};
|
|
93858
93873
|
|
|
93859
|
-
const stepDelay = 1000;
|
|
93860
|
-
const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback, loadingTx, txCallback, bondData, inputToken, inputValue, depositAmount, buyTxHash, rateChanged, }) => {
|
|
93874
|
+
const stepDelay$1 = 1000;
|
|
93875
|
+
const TransactionModal$1 = ({ onDismiss, txChain, approvalState, approveCallback, loadingTx, txCallback, bondData, inputToken, inputValue, depositAmount, buyTxHash, rateChanged, }) => {
|
|
93861
93876
|
var _a, _b, _c;
|
|
93862
93877
|
// Hooks
|
|
93863
93878
|
const { chain } = useAccount();
|
|
@@ -93901,7 +93916,7 @@ const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback,
|
|
|
93901
93916
|
const delay = setTimeout(() => {
|
|
93902
93917
|
hasTriggeredSwitch.current = true;
|
|
93903
93918
|
handleSwitchChain();
|
|
93904
|
-
}, stepDelay);
|
|
93919
|
+
}, stepDelay$1);
|
|
93905
93920
|
return () => clearTimeout(delay);
|
|
93906
93921
|
}
|
|
93907
93922
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
@@ -93915,7 +93930,7 @@ const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback,
|
|
|
93915
93930
|
const delay = setTimeout(() => {
|
|
93916
93931
|
setApproveLoading(false);
|
|
93917
93932
|
setHasToApprove(false);
|
|
93918
|
-
}, stepDelay);
|
|
93933
|
+
}, stepDelay$1);
|
|
93919
93934
|
return () => clearTimeout(delay);
|
|
93920
93935
|
}
|
|
93921
93936
|
else if (!hasTriggeredApproval.current && approvalState !== ApprovalState.PENDING) {
|
|
@@ -94205,7 +94220,7 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
94205
94220
|
};
|
|
94206
94221
|
// Modals
|
|
94207
94222
|
useModal(jsx$2(NewRateModal, { bond: bondData, zapTrueBondPrice: zapTrueBondPrice, depositAmount: depositAmount, youSpendString: youSpendString, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), true, false, 'newRateModal');
|
|
94208
|
-
const [openTxModal] = useModal(jsx$2(TransactionModal, { txChain: bondChain, approvalState: approvalState, approveCallback: handleApprove, loadingTx: loadingTx, txCallback: handleBothPurchases, bondData: bondData, inputToken: inputToken, inputValue: inputValue, depositAmount: depositAmount, buyTxHash: buyTxHash, rateChanged: rateChanged, onDismiss: onDismiss }), false, true, 'transactionModal');
|
|
94223
|
+
const [openTxModal] = useModal(jsx$2(TransactionModal$1, { txChain: bondChain, approvalState: approvalState, approveCallback: handleApprove, loadingTx: loadingTx, txCallback: handleBothPurchases, bondData: bondData, inputToken: inputToken, inputValue: inputValue, depositAmount: depositAmount, buyTxHash: buyTxHash, rateChanged: rateChanged, onDismiss: onDismiss }), false, true, 'transactionModal');
|
|
94209
94224
|
useModal(jsx$2(ZapModal, { outputToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, account: account, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId }), true, true, 'zapModal');
|
|
94210
94225
|
// Effects
|
|
94211
94226
|
const [hasChecked, setHasChecked] = useState(false);
|
|
@@ -94582,53 +94597,45 @@ const ProgressBar = ({ saleInfo }) => {
|
|
|
94582
94597
|
currency: 'USD',
|
|
94583
94598
|
maximumFractionDigits: 0,
|
|
94584
94599
|
});
|
|
94585
|
-
const endTime = useMemo(() => {
|
|
94586
|
-
|
|
94587
|
-
|
|
94588
|
-
|
|
94589
|
-
|
|
94590
|
-
|
|
94591
|
-
|
|
94592
|
-
|
|
94593
|
-
|
|
94594
|
-
|
|
94595
|
-
|
|
94596
|
-
|
|
94597
|
-
|
|
94598
|
-
|
|
94599
|
-
|
|
94600
|
-
|
|
94601
|
-
|
|
94602
|
-
|
|
94603
|
-
|
|
94604
|
-
|
|
94605
|
-
|
|
94606
|
-
|
|
94607
|
-
|
|
94608
|
-
|
|
94609
|
-
|
|
94610
|
-
|
|
94611
|
-
|
|
94612
|
-
return (jsxs(Fragment$1, { children: [
|
|
94613
|
-
|
|
94614
|
-
|
|
94615
|
-
|
|
94616
|
-
|
|
94617
|
-
|
|
94618
|
-
|
|
94619
|
-
|
|
94620
|
-
|
|
94621
|
-
|
|
94622
|
-
|
|
94623
|
-
|
|
94624
|
-
fontSize: '12px',
|
|
94625
|
-
fontWeight: '400',
|
|
94626
|
-
textAlign: 'right',
|
|
94627
|
-
ml: '10px',
|
|
94628
|
-
color: 'var(--theme-ui-colors-textDisabledButton)',
|
|
94629
|
-
}, children: (stage === null || stage === void 0 ? void 0 : stage.hasEnded)
|
|
94630
|
-
? 'Stage ' + nextStageNumber + ' starts: ' + nextStageStartTime + ' UTC'
|
|
94631
|
-
: 'Stage ' + stageNumber + ' Ends: ' + endTime + ' UTC' })] }), jsx$2(Flex$1, { sx: { width: ['100%'], alignItems: 'center', flexDirection: 'row', my: '1rem' }, children: jsx$2(Box$1, { style: {
|
|
94600
|
+
// const endTime = useMemo(() => {
|
|
94601
|
+
// const timestamp = stage?.endTime
|
|
94602
|
+
// if (!timestamp) return 'N/A'
|
|
94603
|
+
// // endTime is a Unix timestamp in seconds, multiply by 1000 for milliseconds
|
|
94604
|
+
// return new Date(timestamp * 1000).toLocaleString('en-US', {
|
|
94605
|
+
// timeZone: 'UTC',
|
|
94606
|
+
// hour12: false,
|
|
94607
|
+
// month: 'long',
|
|
94608
|
+
// day: 'numeric',
|
|
94609
|
+
// hour: '2-digit',
|
|
94610
|
+
// minute: '2-digit',
|
|
94611
|
+
// })
|
|
94612
|
+
// }, [stage])
|
|
94613
|
+
// const nextStageStartTime = useMemo(
|
|
94614
|
+
// () =>
|
|
94615
|
+
// saleInfo?.nextStage?.startTime
|
|
94616
|
+
// ? new Date(saleInfo?.nextStage?.startTime * 1000).toLocaleString('en-US', {
|
|
94617
|
+
// timeZone: 'UTC',
|
|
94618
|
+
// hour12: false,
|
|
94619
|
+
// month: 'long',
|
|
94620
|
+
// day: 'numeric',
|
|
94621
|
+
// hour: '2-digit',
|
|
94622
|
+
// minute: '2-digit',
|
|
94623
|
+
// })
|
|
94624
|
+
// : 'N/A',
|
|
94625
|
+
// [saleInfo],
|
|
94626
|
+
// )
|
|
94627
|
+
return (jsxs(Fragment$1, { children: [jsx$2(Flex$1, { sx: { alignItems: 'end', justifyContent: 'space-between', flexDirection: 'row', mt: '1rem' }, children: jsxs(Flex$1, { sx: { flexDirection: 'column', width: '200px', alignItems: 'start' }, children: [jsx$2(Text, { sx: {
|
|
94628
|
+
fontSize: '14px',
|
|
94629
|
+
fontWeight: '700',
|
|
94630
|
+
color: 'var(--theme-ui-colors-textDisabledButton)',
|
|
94631
|
+
mb: '0.2rem',
|
|
94632
|
+
}, children: "Total Raised" }), jsxs(Flex$1, { sx: { flexDirection: 'row', alignItems: 'center' }, children: [jsx$2(Text, { sx: { fontSize: '22px', fontWeight: '700' }, children: `${totalBilledBTC.toFixed(0)} BTC` }), jsx$2(Text, { sx: { fontSize: '14px', fontWeight: '400', ml: '10px' }, children: `(${totalBilledUSD})` })] }), jsx$2(Text, { sx: {
|
|
94633
|
+
fontSize: '14px',
|
|
94634
|
+
fontWeight: '700',
|
|
94635
|
+
color: 'var(--theme-ui-colors-textDisabledButton)',
|
|
94636
|
+
mb: '0.2rem',
|
|
94637
|
+
mt: '1rem',
|
|
94638
|
+
}, children: stageSoldOut ? 'Stage ' + stageNumber + ' Completed!' : 'Stage ' + stageNumber + ' Progress' }), jsx$2(Text, { sx: { fontSize: '22px', fontWeight: '700' }, children: `${billed.toFixed(2)} BTC/ ${hardCap} BTC` })] }) }), jsx$2(Flex$1, { sx: { width: ['100%'], alignItems: 'center', flexDirection: 'row', my: '1rem' }, children: jsx$2(Box$1, { style: {
|
|
94632
94639
|
width: '100%',
|
|
94633
94640
|
height: '11px',
|
|
94634
94641
|
backgroundColor: 'var(--theme-ui-colors-white4)',
|
|
@@ -95080,5 +95087,351 @@ const GooSaleWithProviders = (props) => {
|
|
|
95080
95087
|
return (jsx$2(Providers, { theme: props === null || props === void 0 ? void 0 : props.theme, children: jsx$2(GooSale, {}) }));
|
|
95081
95088
|
};
|
|
95082
95089
|
|
|
95090
|
+
function usePrivatePartnerInfo() {
|
|
95091
|
+
var _a, _b;
|
|
95092
|
+
const SDKConfig = useSDKConfig();
|
|
95093
|
+
const apiAddress = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
|
|
95094
|
+
const isFake = (_b = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.isFakeBTC) !== null && _b !== void 0 ? _b : false;
|
|
95095
|
+
const privatePartnerName = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.privatePartnerName;
|
|
95096
|
+
return useQuery({
|
|
95097
|
+
queryKey: [QUERY_KEYS.PRIVATE_PARTNER_INFO, privatePartnerName],
|
|
95098
|
+
queryFn: () => getPrivatePartnerInfo(privatePartnerName, isFake, apiAddress),
|
|
95099
|
+
staleTime: Infinity,
|
|
95100
|
+
refetchInterval: 300000, // 5 min
|
|
95101
|
+
refetchOnWindowFocus: false,
|
|
95102
|
+
enabled: !!privatePartnerName && !!apiAddress,
|
|
95103
|
+
});
|
|
95104
|
+
}
|
|
95105
|
+
const getPrivatePartnerInfo = (partnerName, isFake, apiAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
95106
|
+
try {
|
|
95107
|
+
const response = yield axios.get(`${apiAddress}/genesis/private?partner=${partnerName}`);
|
|
95108
|
+
return transformPrivatePartnerData(response.data, isFake);
|
|
95109
|
+
}
|
|
95110
|
+
catch (e) {
|
|
95111
|
+
reportError$1({
|
|
95112
|
+
error: e,
|
|
95113
|
+
extraInfo: { type: 'getPrivatePartnerInfo', partnerName, e },
|
|
95114
|
+
});
|
|
95115
|
+
return null;
|
|
95116
|
+
}
|
|
95117
|
+
});
|
|
95118
|
+
const transformPrivatePartnerData = (rawData, isFake) => {
|
|
95119
|
+
// Find the chain with a non-zero address contract
|
|
95120
|
+
let selectedChainId = null;
|
|
95121
|
+
let selectedContract = null;
|
|
95122
|
+
for (const [chainId, contracts] of Object.entries(rawData.contractsByChain)) {
|
|
95123
|
+
const nonZeroContract = contracts.find((contract) => contract.address !== '0x0000000000000000000000000000000000000000');
|
|
95124
|
+
if (nonZeroContract) {
|
|
95125
|
+
selectedChainId = parseInt(chainId);
|
|
95126
|
+
selectedContract = nonZeroContract;
|
|
95127
|
+
break;
|
|
95128
|
+
}
|
|
95129
|
+
}
|
|
95130
|
+
// If no valid contract found, return null
|
|
95131
|
+
if (!selectedChainId || !selectedContract) {
|
|
95132
|
+
return null;
|
|
95133
|
+
}
|
|
95134
|
+
// Get the appropriate BTC token for the chain
|
|
95135
|
+
let principalToken;
|
|
95136
|
+
if (isFake) {
|
|
95137
|
+
principalToken = FAKE_BTC_TOKENS[selectedChainId];
|
|
95138
|
+
}
|
|
95139
|
+
else {
|
|
95140
|
+
const tokensForChain = PRIVATE_PARTNERS_BTC_TOKENS[selectedChainId];
|
|
95141
|
+
if (tokensForChain) {
|
|
95142
|
+
principalToken = tokensForChain.find((token) => { var _a; return ((_a = token.address[selectedChainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === selectedContract.principalToken.toLowerCase(); });
|
|
95143
|
+
}
|
|
95144
|
+
}
|
|
95145
|
+
// If no matching token found, return null
|
|
95146
|
+
if (!principalToken) {
|
|
95147
|
+
return null;
|
|
95148
|
+
}
|
|
95149
|
+
return {
|
|
95150
|
+
partnerName: rawData.partnerName,
|
|
95151
|
+
hardCapSats: parseInt(rawData.hardCapSats),
|
|
95152
|
+
totalBilledSats: parseInt(rawData.totalBilledSats),
|
|
95153
|
+
chainId: selectedChainId,
|
|
95154
|
+
contract: {
|
|
95155
|
+
address: selectedContract.address,
|
|
95156
|
+
principalToken,
|
|
95157
|
+
},
|
|
95158
|
+
};
|
|
95159
|
+
};
|
|
95160
|
+
|
|
95161
|
+
const stepDelay = 1000;
|
|
95162
|
+
const TransactionModal = ({ onDismiss, txChain, approvalState, approveCallback, loadingTx, txCallback, bondData, inputToken, inputValue, depositAmount, buyTxHash, rateChanged, }) => {
|
|
95163
|
+
var _a, _b, _c;
|
|
95164
|
+
// Hooks
|
|
95165
|
+
const { chain } = useAccount();
|
|
95166
|
+
const inputTokenPrice = useCurrencyPrice(inputToken !== null && inputToken !== void 0 ? inputToken : null, txChain);
|
|
95167
|
+
const { switchChainAsync } = useSwitchChain();
|
|
95168
|
+
// Flow
|
|
95169
|
+
const initialChain = useMemo(() => chain === null || chain === void 0 ? void 0 : chain.id,
|
|
95170
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
95171
|
+
[]);
|
|
95172
|
+
const showSwitchChainFlow = txChain !== initialChain;
|
|
95173
|
+
// const showSwitchChainFlow = true
|
|
95174
|
+
const [hasToSwitchChain, setHasToSwitchChain] = useState(showSwitchChainFlow);
|
|
95175
|
+
const [hasToApprove, setHasToApprove] = useState(true);
|
|
95176
|
+
// Loading state
|
|
95177
|
+
const [loadingSwitchChain, setLoadingSwitchChain] = useState(false);
|
|
95178
|
+
const [approveLoading, setApproveLoading] = useState(false);
|
|
95179
|
+
// Values for regular bonds
|
|
95180
|
+
getGooSaleOutputAmount(depositAmount, Number((_a = bondData === null || bondData === void 0 ? void 0 : bondData.initPrice) !== null && _a !== void 0 ? _a : 0));
|
|
95181
|
+
const handleSwitchChain = () => {
|
|
95182
|
+
setLoadingSwitchChain(true);
|
|
95183
|
+
switchChainAsync({ chainId: txChain })
|
|
95184
|
+
.then(() => {
|
|
95185
|
+
setHasToSwitchChain(false);
|
|
95186
|
+
setApproveLoading(true);
|
|
95187
|
+
})
|
|
95188
|
+
.finally(() => {
|
|
95189
|
+
setLoadingSwitchChain(false);
|
|
95190
|
+
});
|
|
95191
|
+
};
|
|
95192
|
+
const handleApprove = () => {
|
|
95193
|
+
setApproveLoading(true);
|
|
95194
|
+
approveCallback === null || approveCallback === void 0 ? void 0 : approveCallback().catch(() => {
|
|
95195
|
+
setApproveLoading(false);
|
|
95196
|
+
});
|
|
95197
|
+
};
|
|
95198
|
+
// Switch Chain Step #1
|
|
95199
|
+
const hasTriggeredSwitch = useRef(false);
|
|
95200
|
+
useEffect(() => {
|
|
95201
|
+
if (hasToSwitchChain && !hasTriggeredSwitch.current) {
|
|
95202
|
+
setLoadingSwitchChain(true);
|
|
95203
|
+
const delay = setTimeout(() => {
|
|
95204
|
+
hasTriggeredSwitch.current = true;
|
|
95205
|
+
handleSwitchChain();
|
|
95206
|
+
}, stepDelay);
|
|
95207
|
+
return () => clearTimeout(delay);
|
|
95208
|
+
}
|
|
95209
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
95210
|
+
}, [hasToSwitchChain]);
|
|
95211
|
+
// Trigger approve Step #2
|
|
95212
|
+
const hasTriggeredApproval = useRef(false);
|
|
95213
|
+
useEffect(() => {
|
|
95214
|
+
if (!hasToSwitchChain || !showSwitchChainFlow) {
|
|
95215
|
+
if (approvalState === ApprovalState.APPROVED) {
|
|
95216
|
+
setApproveLoading(true);
|
|
95217
|
+
const delay = setTimeout(() => {
|
|
95218
|
+
setApproveLoading(false);
|
|
95219
|
+
setHasToApprove(false);
|
|
95220
|
+
}, stepDelay);
|
|
95221
|
+
return () => clearTimeout(delay);
|
|
95222
|
+
}
|
|
95223
|
+
else if (!hasTriggeredApproval.current && approvalState !== ApprovalState.PENDING) {
|
|
95224
|
+
setApproveLoading(true);
|
|
95225
|
+
hasTriggeredApproval.current = true;
|
|
95226
|
+
handleApprove();
|
|
95227
|
+
}
|
|
95228
|
+
}
|
|
95229
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
95230
|
+
}, [hasToSwitchChain, approvalState]);
|
|
95231
|
+
// Execute main tx Step #3
|
|
95232
|
+
const hasTriggeredTx = useRef(false);
|
|
95233
|
+
useEffect(() => {
|
|
95234
|
+
if (!hasToSwitchChain && !hasToApprove && !hasTriggeredTx.current) {
|
|
95235
|
+
hasTriggeredTx.current = true;
|
|
95236
|
+
if (rateChanged) {
|
|
95237
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
95238
|
+
}
|
|
95239
|
+
else {
|
|
95240
|
+
setApproveLoading(false);
|
|
95241
|
+
txCallback === null || txCallback === void 0 ? void 0 : txCallback();
|
|
95242
|
+
}
|
|
95243
|
+
}
|
|
95244
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
95245
|
+
}, [hasToSwitchChain, hasToApprove, txCallback]);
|
|
95246
|
+
// Close modal if a hash is found. Final Step
|
|
95247
|
+
const { data: txReceipt, isSuccess, isLoading: verifyingTx } = useMonitorTxHash(buyTxHash, txChain);
|
|
95248
|
+
useEffect(() => {
|
|
95249
|
+
if (buyTxHash && txReceipt) {
|
|
95250
|
+
if (isSuccess) {
|
|
95251
|
+
onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
|
|
95252
|
+
}
|
|
95253
|
+
}
|
|
95254
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
95255
|
+
}, [buyTxHash, txReceipt, isSuccess]);
|
|
95256
|
+
const currentStep = showSwitchChainFlow ? (hasToSwitchChain ? 1 : hasToApprove ? 2 : 3) : hasToApprove ? 1 : 2;
|
|
95257
|
+
typeof inputToken !== 'string' ? (_b = inputToken === null || inputToken === void 0 ? void 0 : inputToken.symbol) === null || _b === void 0 ? void 0 : _b.split('-') : undefined;
|
|
95258
|
+
return (jsxs(Modal, { children: [jsx$2(ModalHeader, { onDismiss: onDismiss, hideDivider: true }), jsxs(Flex, { sx: { flexDirection: 'column', width: '100%' }, children: [jsxs(Flex, { sx: { width: '100%', alignItems: 'center', p: '10px' }, children: [showSwitchChainFlow && (jsx$2(StepBubble, { number: 1, title: 'Switch Chain', currentStep: currentStep, loading: loadingSwitchChain })), jsx$2(StepBubble, { number: showSwitchChainFlow ? 2 : 1, title: 'Approve', currentStep: currentStep, loading: approveLoading || approvalState === ApprovalState.PENDING }), jsx$2(StepBubble, { number: showSwitchChainFlow ? 3 : 2, title: 'Deposit', currentStep: currentStep, loading: loadingTx || verifyingTx, hideBar: true })] }), jsx$2(Flex, { sx: { width: '100%', mt: '40px', justifyContent: 'center' }, children: jsx$2(LoadingSpinner, { isLoading: loadingSwitchChain ||
|
|
95259
|
+
approveLoading ||
|
|
95260
|
+
loadingTx ||
|
|
95261
|
+
verifyingTx ||
|
|
95262
|
+
approvalState === ApprovalState.PENDING, size: 100 }) }), jsx$2(Flex, { sx: { width: '100%', justifyContent: 'center', mt: '10px' }, children: hasToSwitchChain
|
|
95263
|
+
? loadingSwitchChain
|
|
95264
|
+
? 'Switching Chain...'
|
|
95265
|
+
: 'Switch Chain'
|
|
95266
|
+
: hasToApprove
|
|
95267
|
+
? approveLoading || approvalState === ApprovalState.PENDING
|
|
95268
|
+
? 'Approving...'
|
|
95269
|
+
: 'Approve Contract'
|
|
95270
|
+
: loadingTx || verifyingTx
|
|
95271
|
+
? 'Depositing...'
|
|
95272
|
+
: 'Deposit' }), jsx$2(Flex, { sx: { width: '100%', flexDirection: 'column', alignItems: 'center', mt: '20px' }, children: jsxs(Flex, { sx: { p: '10px', borderRadius: 'normal', background: 'white3', alignItems: 'center', width: '45%' }, children: [jsx$2(TokenImage, { symbol: getSymbol(inputToken, txChain), size: 20, chain: txChain }), jsx$2(Flex, { sx: { fontSize: '14px', fontWeight: 600, mx: '5px' }, children: (_c = formatNumber$1(inputValue)) !== null && _c !== void 0 ? _c : '0' }), jsxs(Flex, { sx: { color: 'textDisabledButton', fontSize: '12px', fontWeight: 400 }, children: ["(", (inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price) && inputValue
|
|
95273
|
+
? `$${formatUSDNumber(((inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price) * parseFloat(inputValue)).toFixed(2))}`
|
|
95274
|
+
: '0.00', ")"] })] }) }), jsx$2(Flex, { sx: { mt: '20px' }, children: hasToSwitchChain ? (jsxs(Button, { load: loadingSwitchChain, disabled: loadingSwitchChain, onClick: handleSwitchChain, fullWidth: true, children: ["switch to ", NETWORK_LABEL[txChain]] })) : !hasToApprove ? (jsx$2(Button, { load: loadingTx || verifyingTx, disabled: loadingTx || verifyingTx, onClick: txCallback, fullWidth: true, children: "Deposit" })) : (jsx$2(Button, { className: "action-button", load: approvalState === ApprovalState.PENDING || approveLoading, disabled: approvalState === ApprovalState.PENDING || approveLoading, onClick: handleApprove, fullWidth: true, children: "Approve" })) })] })] }));
|
|
95275
|
+
};
|
|
95276
|
+
|
|
95277
|
+
const GooPrivatePartners = ({ tokenSymbol }) => {
|
|
95278
|
+
var _a;
|
|
95279
|
+
const { address: account } = useAccount();
|
|
95280
|
+
const currentChainId = useChainId();
|
|
95281
|
+
const { writeContractAsync } = useWriteContract();
|
|
95282
|
+
const { addToastError, addToastSuccess } = usePopups();
|
|
95283
|
+
const { data: privatePartnerInfo, isLoading, error, refetch } = usePrivatePartnerInfo();
|
|
95284
|
+
const { switchChain } = useSwitchChain();
|
|
95285
|
+
const chainId = (privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.chainId) || currentChainId;
|
|
95286
|
+
const depositToken = privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.contract.principalToken;
|
|
95287
|
+
const depositContract = privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.contract.address;
|
|
95288
|
+
const totalDeposited = (privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.totalBilledSats) ? privatePartnerInfo.totalBilledSats / 100000000 : 0;
|
|
95289
|
+
let partnerName = privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.partnerName;
|
|
95290
|
+
if ((privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.partnerName) === 'enzo') {
|
|
95291
|
+
partnerName = 'Lorenzo';
|
|
95292
|
+
}
|
|
95293
|
+
// Capitalize partner name
|
|
95294
|
+
partnerName = partnerName === null || partnerName === void 0 ? void 0 : partnerName.split(' ').map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
|
|
95295
|
+
const [inputValue, setInputValue] = useState('0');
|
|
95296
|
+
const [loadingTx, setLoadingTx] = useState(false);
|
|
95297
|
+
const [buyTxHash, setBuyTxHash] = useState('');
|
|
95298
|
+
// Automatically switch to the required chain when privatePartnerInfo is ready
|
|
95299
|
+
useEffect(() => {
|
|
95300
|
+
if ((privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.chainId) && currentChainId !== privatePartnerInfo.chainId && account) {
|
|
95301
|
+
switchChain({ chainId: privatePartnerInfo.chainId });
|
|
95302
|
+
}
|
|
95303
|
+
}, [privatePartnerInfo === null || privatePartnerInfo === void 0 ? void 0 : privatePartnerInfo.chainId, currentChainId, account, switchChain]);
|
|
95304
|
+
// Fetch token balance
|
|
95305
|
+
const shouldFetchBalance = !!depositToken && !!chainId && !!account;
|
|
95306
|
+
const { data: tokenBalances } = useUserTokensBalance(shouldFetchBalance ? [depositToken] : [], chainId || currentChainId);
|
|
95307
|
+
const tokenBalance = ((_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances[0]) === null || _a === void 0 ? void 0 : _a.balance) || '0';
|
|
95308
|
+
// Create bond data for the transaction modal
|
|
95309
|
+
const bondData = privatePartnerInfo && depositToken
|
|
95310
|
+
? {
|
|
95311
|
+
address: depositContract,
|
|
95312
|
+
type: 'goo',
|
|
95313
|
+
principalToken: depositToken,
|
|
95314
|
+
chainId: chainId,
|
|
95315
|
+
initPrice: 1,
|
|
95316
|
+
lpToken: depositToken,
|
|
95317
|
+
contractAddress: { [chainId]: depositContract },
|
|
95318
|
+
}
|
|
95319
|
+
: undefined;
|
|
95320
|
+
// Approval state
|
|
95321
|
+
const [approvalState, approveCallback] = useApproval(inputValue, depositToken !== null && depositToken !== void 0 ? depositToken : null, depositContract !== null && depositContract !== void 0 ? depositContract : null, account !== null && account !== void 0 ? account : null, chainId !== null && chainId !== void 0 ? chainId : null);
|
|
95322
|
+
const handleApprove = () => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
95323
|
+
yield approveCallback();
|
|
95324
|
+
});
|
|
95325
|
+
const handleInputChange = (event) => {
|
|
95326
|
+
setInputValue(event.target.value);
|
|
95327
|
+
};
|
|
95328
|
+
const handleMaxClick = () => {
|
|
95329
|
+
setInputValue(tokenBalance);
|
|
95330
|
+
};
|
|
95331
|
+
const handleDeposit = () => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
95332
|
+
var _a, _b, _c;
|
|
95333
|
+
if (!account || !inputValue || parseFloat(inputValue) === 0 || !depositContract)
|
|
95334
|
+
return;
|
|
95335
|
+
setLoadingTx(true);
|
|
95336
|
+
try {
|
|
95337
|
+
const rawAmount = adjustDecimals$1(inputValue);
|
|
95338
|
+
const decimals = (_b = (_a = depositToken === null || depositToken === void 0 ? void 0 : depositToken.decimals) === null || _a === void 0 ? void 0 : _a[chainId]) !== null && _b !== void 0 ? _b : 8;
|
|
95339
|
+
const amount = new BigNumber$1(rawAmount).times(new BigNumber$1(10).pow(decimals)).toString();
|
|
95340
|
+
// Calculate maxPrice with 2% slippage
|
|
95341
|
+
// Assuming initPrice is in SATS, convert to wei per token
|
|
95342
|
+
const pricePerToken = new BigNumber$1((_c = bondData === null || bondData === void 0 ? void 0 : bondData.initPrice) !== null && _c !== void 0 ? _c : 0)
|
|
95343
|
+
.times(new BigNumber$1(10).pow(8)) // Convert to wei (8 decimals for BTC)
|
|
95344
|
+
.times(102) // Add 2% slippage
|
|
95345
|
+
.div(100)
|
|
95346
|
+
.toFixed(0);
|
|
95347
|
+
const maxPrice = pricePerToken;
|
|
95348
|
+
const hash = yield writeContractAsync({
|
|
95349
|
+
address: depositContract,
|
|
95350
|
+
abi: ABI_DEPOSIT,
|
|
95351
|
+
functionName: 'deposit',
|
|
95352
|
+
args: [amount, maxPrice, account],
|
|
95353
|
+
chain: chainId,
|
|
95354
|
+
account,
|
|
95355
|
+
});
|
|
95356
|
+
if (hash) {
|
|
95357
|
+
setBuyTxHash(hash);
|
|
95358
|
+
addToastSuccess('Deposit successful!');
|
|
95359
|
+
setInputValue('0');
|
|
95360
|
+
refetch();
|
|
95361
|
+
}
|
|
95362
|
+
}
|
|
95363
|
+
catch (error) {
|
|
95364
|
+
console.error('Deposit error', error);
|
|
95365
|
+
addToastError(error.shortMessage || 'Deposit failed');
|
|
95366
|
+
}
|
|
95367
|
+
finally {
|
|
95368
|
+
setLoadingTx(false);
|
|
95369
|
+
}
|
|
95370
|
+
});
|
|
95371
|
+
const depositAmount = inputValue ? inputValue : '0';
|
|
95372
|
+
const [openTxModal] = useModal(jsx$2(TransactionModal, { txChain: chainId, approvalState: approvalState, approveCallback: handleApprove, loadingTx: loadingTx, txCallback: handleDeposit, bondData: bondData, inputToken: depositToken, inputValue: inputValue, depositAmount: depositAmount, buyTxHash: buyTxHash, rateChanged: false, onDismiss: () => { } }), false, true, 'transactionModal');
|
|
95373
|
+
const exceedsBalance = new BigNumber$1(tokenBalance).lt(inputValue);
|
|
95374
|
+
const isValidAmount = inputValue && parseFloat(inputValue) > 0;
|
|
95375
|
+
return (jsx$2(Flex, { sx: { width: '100%', justifyContent: 'center', alignItems: 'center' }, children: jsxs(Flex, { sx: {
|
|
95376
|
+
width: '500px',
|
|
95377
|
+
minHeight: '500px',
|
|
95378
|
+
padding: '3rem',
|
|
95379
|
+
gap: '2rem',
|
|
95380
|
+
flexDirection: 'column',
|
|
95381
|
+
justifyContent: 'center',
|
|
95382
|
+
alignItems: 'center',
|
|
95383
|
+
borderRadius: '12px',
|
|
95384
|
+
background: 'white3',
|
|
95385
|
+
}, children: [jsx$2(Text, { sx: { fontSize: '24px', fontWeight: 700, opacity: '0.9' }, children: partnerName }), isLoading && (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '1rem' }, children: [jsx$2(LoadingSpinner, { isLoading: true, size: 60 }), jsx$2(Text, { sx: { fontSize: '14px', opacity: 0.7 }, children: "Loading partner information..." })] })), error && !isLoading && (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '1rem', textAlign: 'center' }, children: [jsx$2(Svg, { icon: "error", width: "48px", color: "error" }), jsx$2(Text, { sx: { fontSize: '16px', fontWeight: 600, color: 'error' }, children: "Failed to load partner data" }), jsx$2(Text, { sx: { fontSize: '14px', opacity: 0.7, maxWidth: '300px' }, children: (error === null || error === void 0 ? void 0 : error.message) || 'An error occurred while fetching partner information' }), jsx$2(Button, { onClick: () => refetch(), variant: "secondary", sx: { mt: '0.5rem' }, children: "Try Again" })] })), !isLoading && !error && account && (jsxs(Flex, { sx: { flexDirection: 'column', width: '100%', gap: '1rem' }, children: [privatePartnerInfo && (jsxs(Flex, { sx: {
|
|
95386
|
+
flexDirection: 'column',
|
|
95387
|
+
background: 'white4',
|
|
95388
|
+
borderRadius: '8px',
|
|
95389
|
+
padding: '1rem',
|
|
95390
|
+
gap: '0.5rem',
|
|
95391
|
+
alignItems: 'center',
|
|
95392
|
+
}, children: [jsx$2(Text, { sx: { fontSize: '12px', opacity: 0.6, textTransform: 'uppercase', letterSpacing: '0.5px' }, children: "Total Deposited" }), jsxs(Flex, { sx: { alignItems: 'center', gap: '0.5rem' }, children: [jsx$2(TokenImage, { symbol: depositToken === null || depositToken === void 0 ? void 0 : depositToken.symbol, size: 20, chain: chainId }), jsx$2(Text, { sx: { fontSize: '24px', fontWeight: 700 }, children: totalDeposited.toFixed(2) }), jsx$2(Text, { sx: { fontSize: '16px', fontWeight: 600, opacity: 0.7 }, children: depositToken === null || depositToken === void 0 ? void 0 : depositToken.symbol })] })] })), jsxs(Flex, { sx: {
|
|
95393
|
+
flexDirection: 'column',
|
|
95394
|
+
background: 'white4',
|
|
95395
|
+
borderRadius: '8px',
|
|
95396
|
+
padding: '1rem',
|
|
95397
|
+
gap: '0.5rem',
|
|
95398
|
+
}, children: [jsx$2(Text, { sx: { fontSize: '12px', opacity: 0.6, textTransform: 'uppercase', letterSpacing: '0.5px' }, children: "Deposit" }), jsxs(Flex, { sx: { justifyContent: 'space-between', alignItems: 'center' }, children: [jsx$2(Input$1, { placeholder: "0.0", value: inputValue, onChange: handleInputChange, disabled: !depositToken || isLoading, onInput: (v) => {
|
|
95399
|
+
if (v.currentTarget.value.includes(',')) {
|
|
95400
|
+
v.currentTarget.value = v.currentTarget.value.replace(/,/g, '.');
|
|
95401
|
+
}
|
|
95402
|
+
if (v.currentTarget.value === '.') {
|
|
95403
|
+
v.currentTarget.value = '0.';
|
|
95404
|
+
}
|
|
95405
|
+
v.currentTarget.value =
|
|
95406
|
+
!!v.currentTarget.value &&
|
|
95407
|
+
isNumber$1(v.currentTarget.value) &&
|
|
95408
|
+
parseFloat(v.currentTarget.value) >= 0
|
|
95409
|
+
? v.currentTarget.value
|
|
95410
|
+
: v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
|
|
95411
|
+
}, sx: {
|
|
95412
|
+
border: 'none',
|
|
95413
|
+
outline: 'none',
|
|
95414
|
+
fontSize: '20px',
|
|
95415
|
+
fontWeight: 600,
|
|
95416
|
+
background: 'transparent',
|
|
95417
|
+
padding: 0,
|
|
95418
|
+
flex: 1,
|
|
95419
|
+
opacity: !depositToken || isLoading ? 0.5 : 1,
|
|
95420
|
+
} }), jsxs(Flex, { sx: { alignItems: 'center', gap: '0.5rem' }, children: [jsx$2(TokenImage, { symbol: depositToken === null || depositToken === void 0 ? void 0 : depositToken.symbol, size: 24, chain: chainId }), jsx$2(Text, { sx: { fontSize: '16px', fontWeight: 600 }, children: depositToken === null || depositToken === void 0 ? void 0 : depositToken.symbol })] })] }), jsxs(Flex, { sx: { justifyContent: 'space-between', alignItems: 'center' }, children: [jsxs(Text, { sx: { fontSize: '12px', opacity: 0.6 }, children: ["Balance: ", tokenBalance] }), jsx$2(Button, { onClick: handleMaxClick, variant: "text", disabled: !depositToken || isLoading, sx: { fontSize: '12px', padding: '4px 8px', height: 'auto' }, children: "MAX" })] })] }), jsx$2(Button, { onClick: openTxModal, load: loadingTx || isLoading, disabled: loadingTx || isLoading || !isValidAmount || exceedsBalance || !depositContract, fullWidth: true, children: isLoading
|
|
95421
|
+
? 'Loading...'
|
|
95422
|
+
: exceedsBalance
|
|
95423
|
+
? 'Exceeds Balance'
|
|
95424
|
+
: !isValidAmount
|
|
95425
|
+
? 'Enter Amount'
|
|
95426
|
+
: !depositContract
|
|
95427
|
+
? 'Contract Not Available'
|
|
95428
|
+
: 'Deposit' })] })), !isLoading && !error && !account && jsx$2(ConnectButton, {})] }) }));
|
|
95429
|
+
};
|
|
95430
|
+
|
|
95431
|
+
const GooPrivatePartnersWithProviders = (props) => {
|
|
95432
|
+
useSDKConfig(props);
|
|
95433
|
+
return (jsx$2(Providers, { theme: props.theme, children: jsx$2(GooPrivatePartners, Object.assign({}, props)) }));
|
|
95434
|
+
};
|
|
95435
|
+
|
|
95083
95436
|
var ChainId = types.ChainId;
|
|
95084
|
-
export { BondsWithProviders as Bonds, BuyBondModalWithProviders as BuyBondModal, ChainId, FullBondsViewWithProviders as FullBondsView, GooSaleWithProviders as GooSale, ProjectViewWithProviders as ProjectView, SingleBondWithProviders as SingleBond, YourBondsWithProviders as YourBonds, generateImageFromTemplate };
|
|
95437
|
+
export { BondsWithProviders as Bonds, BuyBondModalWithProviders as BuyBondModal, ChainId, FullBondsViewWithProviders as FullBondsView, GooPrivatePartnersWithProviders as GooPrivatePartners, GooSaleWithProviders as GooSale, ProjectViewWithProviders as ProjectView, SingleBondWithProviders as SingleBond, YourBondsWithProviders as YourBonds, generateImageFromTemplate };
|
|
@@ -13,6 +13,7 @@ export interface SDKPropsDTO {
|
|
|
13
13
|
theme?: any;
|
|
14
14
|
highestCompatibleVersion?: string;
|
|
15
15
|
isFakeBTC?: boolean;
|
|
16
|
+
privatePartnerName?: string;
|
|
16
17
|
}
|
|
17
18
|
export interface SDKProps {
|
|
18
19
|
referenceId: string;
|
|
@@ -29,6 +30,7 @@ export interface SDKProps {
|
|
|
29
30
|
theme?: any;
|
|
30
31
|
highestCompatibleVersion?: string;
|
|
31
32
|
isFakeBTC?: boolean;
|
|
33
|
+
privatePartnerName?: string;
|
|
32
34
|
}
|
|
33
35
|
export declare const useSDKConfig: (config?: SDKPropsDTO) => SDKProps;
|
|
34
36
|
export type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ApprovalState } from '../../state/allowance/useAllowance';
|
|
3
|
+
import { Token } from '@ape.swap/apeswap-lists';
|
|
4
|
+
import { GooSaleBondData } from '../GooSale/components/BuyBond/BuyBond';
|
|
5
|
+
declare const TransactionModal: ({ onDismiss, txChain, approvalState, approveCallback, loadingTx, txCallback, bondData, inputToken, inputValue, depositAmount, buyTxHash, rateChanged, }: {
|
|
6
|
+
onDismiss?: () => void;
|
|
7
|
+
txChain?: number;
|
|
8
|
+
approvalState?: ApprovalState;
|
|
9
|
+
approveCallback?: () => Promise<void>;
|
|
10
|
+
loadingTx?: boolean;
|
|
11
|
+
txCallback?: () => void;
|
|
12
|
+
bondData: GooSaleBondData | undefined;
|
|
13
|
+
inputToken: Token | "NATIVE" | undefined;
|
|
14
|
+
inputValue: string;
|
|
15
|
+
depositAmount: string;
|
|
16
|
+
buyTxHash?: string;
|
|
17
|
+
rateChanged: boolean;
|
|
18
|
+
}) => React.JSX.Element;
|
|
19
|
+
export default TransactionModal;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SDKPropsDTO } from '../../state/useSDKConfig';
|
|
3
|
+
import { GooPrivatePartnersProps } from './GooPrivatePartners';
|
|
4
|
+
interface Props extends SDKPropsDTO, GooPrivatePartnersProps {
|
|
5
|
+
}
|
|
6
|
+
declare const GooPrivatePartnersWithProviders: React.FC<Props>;
|
|
7
|
+
export default GooPrivatePartnersWithProviders;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import { ChainId, Token } from '@ape.swap/apeswap-lists';
|
|
3
|
+
export interface PrivatePartnerContract {
|
|
4
|
+
address: string;
|
|
5
|
+
principalToken: Token;
|
|
6
|
+
}
|
|
7
|
+
export interface PrivatePartnerInfo {
|
|
8
|
+
partnerName: string;
|
|
9
|
+
hardCapSats: number;
|
|
10
|
+
totalBilledSats: number;
|
|
11
|
+
chainId: ChainId;
|
|
12
|
+
contract: PrivatePartnerContract;
|
|
13
|
+
}
|
|
14
|
+
export default function usePrivatePartnerInfo(): UseQueryResult<PrivatePartnerInfo | null>;
|
|
15
|
+
export declare const getPrivatePartnerInfo: (partnerName: string, isFake: boolean, apiAddress: string) => Promise<PrivatePartnerInfo | null>;
|