@goodaofi/bonds-sdk 3.0.145 → 3.0.148

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/main.js CHANGED
@@ -99954,75 +99954,8 @@ const ProgressBar = ({ saleInfo }) => {
99954
99954
  } }) }) })] }));
99955
99955
  };
99956
99956
 
99957
- function useYourGoo(userAddress) {
99958
- var _a;
99959
- const SDKConfig = useSDKConfig();
99960
- const apiAddress = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
99961
- return useQuery({
99962
- queryKey: [QUERY_KEYS.USER_GOO_DATA, userAddress],
99963
- queryFn: () => (userAddress ? getUserGooData(userAddress, apiAddress) : Promise.resolve(null)),
99964
- staleTime: 60000, // 1 min
99965
- refetchInterval: 60000, // 1 min
99966
- refetchOnWindowFocus: true,
99967
- refetchOnMount: 'always', // Always refetch when component mounts
99968
- enabled: !!userAddress,
99969
- });
99970
- }
99971
- const adjustDecimals = (value, decimals = 10) => {
99972
- const num = BigInt(value);
99973
- const divisor = BigInt(Math.pow(10, decimals));
99974
- const integerPart = num / divisor;
99975
- const remainder = num % divisor;
99976
- // Convert to decimal string with proper precision
99977
- const remainderStr = remainder.toString().padStart(decimals, '0');
99978
- const decimalPart = remainderStr.replace(/0+$/, ''); // Remove trailing zeros
99979
- if (decimalPart) {
99980
- return `${integerPart}.${decimalPart}`;
99981
- }
99982
- return integerPart.toString();
99983
- };
99984
- const transformUserGooData = (rawData) => {
99985
- return {
99986
- user: rawData.user,
99987
- stages: rawData.stages.map((stage) => ({
99988
- key: stage.key,
99989
- depositToGooBond: stage.depositToGooBond,
99990
- depositToSGooBond: stage.depositToSGooBond,
99991
- gooPayout: adjustDecimals(stage.gooPayout),
99992
- sGooPayout: adjustDecimals(stage.sGooPayout),
99993
- })),
99994
- depositToGooBond: rawData.depositToGooBond,
99995
- depositToSGooBond: rawData.depositToSGooBond,
99996
- gooPayout: adjustDecimals(rawData.gooPayout),
99997
- sGooPayout: adjustDecimals(rawData.sGooPayout),
99998
- };
99999
- };
100000
- const getUserGooData = (userAddress, apiAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
100001
- var _a;
100002
- try {
100003
- const response = yield axios.get(`${apiAddress}/genesis/snapshot/${userAddress}`);
100004
- if (!response.data) {
100005
- return null;
100006
- }
100007
- return transformUserGooData(response.data);
100008
- }
100009
- catch (e) {
100010
- // If user is not found or endpoint fails, return null
100011
- if (((_a = e.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
100012
- return null;
100013
- }
100014
- reportError$1({
100015
- error: e,
100016
- extraInfo: { type: 'getUserGooData', userAddress, e },
100017
- });
100018
- return null;
100019
- }
100020
- });
100021
-
100022
- const YourGoo = () => {
99957
+ const YourGoo = ({ yourGoo, isLoading, isFetching, }) => {
100023
99958
  var _a, _b, _c;
100024
- const { address: account } = useAccount();
100025
- const { data: yourGoo, isLoading, isFetching } = useYourGoo(account);
100026
99959
  const { data: saleInfo } = useSaleInfo();
100027
99960
  const gooAmountTotal = formatNumber$1((_a = yourGoo === null || yourGoo === void 0 ? void 0 : yourGoo.gooPayout) !== null && _a !== void 0 ? _a : '0');
100028
99961
  const sGooAmountTotal = formatNumber$1((_b = yourGoo === null || yourGoo === void 0 ? void 0 : yourGoo.sGooPayout) !== null && _b !== void 0 ? _b : '0');
@@ -100314,6 +100247,71 @@ function useGooEligibility() {
100314
100247
  checkCbBTCBalance, addToWhitelist: addToWhitelistMutation.mutate, isAddingToWhitelist: addToWhitelistMutation.isPending, addToWhitelistSuccess: addToWhitelistMutation.isSuccess, addToWhitelistError: addToWhitelistMutation.isError });
100315
100248
  }
100316
100249
 
100250
+ function useYourGoo(userAddress) {
100251
+ var _a;
100252
+ const SDKConfig = useSDKConfig();
100253
+ const apiAddress = (_a = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _a === void 0 ? void 0 : _a.apiV2;
100254
+ return useQuery({
100255
+ queryKey: [QUERY_KEYS.USER_GOO_DATA, userAddress],
100256
+ queryFn: () => (userAddress ? getUserGooData(userAddress, apiAddress) : Promise.resolve(null)),
100257
+ staleTime: 60000, // 1 min
100258
+ refetchInterval: 60000, // 1 min
100259
+ refetchOnWindowFocus: true,
100260
+ refetchOnMount: 'always', // Always refetch when component mounts
100261
+ enabled: !!userAddress,
100262
+ });
100263
+ }
100264
+ const adjustDecimals = (value, decimals = 10) => {
100265
+ const num = BigInt(value);
100266
+ const divisor = BigInt(Math.pow(10, decimals));
100267
+ const integerPart = num / divisor;
100268
+ const remainder = num % divisor;
100269
+ // Convert to decimal string with proper precision
100270
+ const remainderStr = remainder.toString().padStart(decimals, '0');
100271
+ const decimalPart = remainderStr.replace(/0+$/, ''); // Remove trailing zeros
100272
+ if (decimalPart) {
100273
+ return `${integerPart}.${decimalPart}`;
100274
+ }
100275
+ return integerPart.toString();
100276
+ };
100277
+ const transformUserGooData = (rawData) => {
100278
+ return {
100279
+ user: rawData.user,
100280
+ stages: rawData.stages.map((stage) => ({
100281
+ key: stage.key,
100282
+ depositToGooBond: stage.depositToGooBond,
100283
+ depositToSGooBond: stage.depositToSGooBond,
100284
+ gooPayout: adjustDecimals(stage.gooPayout),
100285
+ sGooPayout: adjustDecimals(stage.sGooPayout),
100286
+ })),
100287
+ depositToGooBond: rawData.depositToGooBond,
100288
+ depositToSGooBond: rawData.depositToSGooBond,
100289
+ gooPayout: adjustDecimals(rawData.gooPayout),
100290
+ sGooPayout: adjustDecimals(rawData.sGooPayout),
100291
+ };
100292
+ };
100293
+ const getUserGooData = (userAddress, apiAddress) => __awaiter$9(void 0, void 0, void 0, function* () {
100294
+ var _a;
100295
+ try {
100296
+ const response = yield axios.get(`${apiAddress}/genesis/snapshot/${userAddress}`);
100297
+ if (!response.data) {
100298
+ return null;
100299
+ }
100300
+ return transformUserGooData(response.data);
100301
+ }
100302
+ catch (e) {
100303
+ // If user is not found or endpoint fails, return null
100304
+ if (((_a = e.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
100305
+ return null;
100306
+ }
100307
+ reportError$1({
100308
+ error: e,
100309
+ extraInfo: { type: 'getUserGooData', userAddress, e },
100310
+ });
100311
+ return null;
100312
+ }
100313
+ });
100314
+
100317
100315
  var BondsViewOptions;
100318
100316
  (function (BondsViewOptions) {
100319
100317
  BondsViewOptions["BONDSMARKET"] = "Bonds Market";
@@ -100329,6 +100327,8 @@ const GooSale = () => {
100329
100327
  : ((_b = saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.currentStage) === null || _b === void 0 ? void 0 : _b.stageNumber) || 1;
100330
100328
  const { activeView, handleToogle } = useActiveView(true);
100331
100329
  const { address } = useAccount();
100330
+ const { data: yourGoo, isLoading, isFetching } = useYourGoo(address);
100331
+ const userParticipated = address && !isLoading && !isFetching && ((yourGoo === null || yourGoo === void 0 ? void 0 : yourGoo.depositToGooBond) !== '0' || (yourGoo === null || yourGoo === void 0 ? void 0 : yourGoo.depositToSGooBond) !== '0');
100332
100332
  const chainId = useChainId();
100333
100333
  const { switchChain } = useSwitchChain();
100334
100334
  const { data: elegibleForSale, cbBTCBalance, isCbBTCBalanceLoading, cbBTCBalanceChecked, checkCbBTCBalance, addToWhitelist, isAddingToWhitelist, addToWhitelistSuccess, addToWhitelistError, } = useGooEligibility();
@@ -100384,7 +100384,7 @@ const GooSale = () => {
100384
100384
  : ((_f = saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.nextStage) === null || _f === void 0 ? void 0 : _f.stageNumber) === 5
100385
100385
  ? 'TGE '
100386
100386
  : 'Stage ' + ((_g = saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.nextStage) === null || _g === void 0 ? void 0 : _g.stageNumber) + ' ', "starts in:"] }), jsx$2(Svg, { icon: "comingSoon", width: "350" }), !(((_h = saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.nextStage) === null || _h === void 0 ? void 0 : _h.stageNumber) === 4 || ((_j = saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.nextStage) === null || _j === void 0 ? void 0 : _j.stageNumber) === 5) ? (jsxs(Fragment$1, { children: [jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center' }, children: [jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', mt: '30px' }, children: [address && (jsxs(Flex, { sx: { mr: '1rem', p: '10px', borderRadius: 'normal', background: 'white3', alignItems: 'center' }, children: [jsx$2(Flex, { sx: { mr: '10px' }, children: jsx$2(Svg, { icon: "wallet" }) }), jsxs(Text, { sx: { fontSize: '14px', fontWeight: 400 }, children: [address === null || address === void 0 ? void 0 : address.slice(0, 4), "...", address === null || address === void 0 ? void 0 : address.slice((address === null || address === void 0 ? void 0 : address.length) - 4, address === null || address === void 0 ? void 0 : address.length)] })] })), jsx$2(Flex, { sx: { fontSize: '18px', fontWeight: 500 }, children: "Are You Eligible?" })] }), !address ? (jsx$2(Flex, { sx: { my: '20px', width: '100%' }, children: jsx$2(ConnectButton, {}) })) : (whitelisted === null ||
100387
- (whitelisted === undefined && !cbBTCBalanceChecked && (jsx$2(Button, { sx: { m: '20px', width: '100%' }, onClick: handleCheckEligibility, children: "CHECK ELIGIBILITY" }))))] }), whitelisted !== null && whitelisted !== undefined && (jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', mt: '20px' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You are whitelisted for Stage ", whitelisted, " and beyond!"] }), jsxs(Text, { color: "primaryButton", sx: { fontSize: '12px', fontWeight: 400, pl: '1rem' }, children: ["Tier ", whitelisted, " Access"] })] })), whitelisted === null && (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px' }, children: [cbBTCBalanceChecked && (jsx$2(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px', mt: '10px' }, children: isCbBTCBalanceLoading ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Checking BTC balance across all chains..." })) : cbBTCBalance ? (jsxs(Fragment$1, { children: [cbBTCBalance.isEligible ? (addToWhitelistSuccess ? (jsx$2(Text, { color: "primaryButton", sx: { fontSize: '12px', fontWeight: 700 }, children: "\u2713 Successfully added to whitelist! Please refresh to see your tier." })) : addToWhitelistError ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "Failed to add to whitelist. Please try again." })) : (jsx$2(Fragment$1, { children: jsx$2(Flex, { sx: { flexDirection: 'row', alignItems: 'center' }, children: jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You ", jsx$2("span", { sx: { fontWeight: 700 }, children: "ARE" }), " eligible for the sale"] }) }) }))) : (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You are ", jsx$2("span", { sx: { fontWeight: 700 }, children: "NOT" }), " eligible for the sale"] }), jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "You need at least 0.001 BTC to be whitelisted" })] })), jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["Total BTC Balance: ", cbBTCBalance.balance] }), cbBTCBalance.chainsWithBalance && cbBTCBalance.chainsWithBalance.length > 0 && (jsx$2(Flex, { sx: { flexDirection: 'column', gap: '5px', mt: '5px' }, children: cbBTCBalance.chainsWithBalance.map((chain) => (jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', gap: '10px' }, children: [jsx$2(TokenImage, { symbol: chain.symbol, size: 25, chain: chain.chainId }), jsxs(Text, { sx: { fontSize: '10px', fontWeight: 400, opacity: 0.7 }, children: [chain.balance, " ", chain.symbol] })] }, chain.chainId))) })), cbBTCBalance.isEligible && (jsx$2(Button, { sx: { width: '100%' }, onClick: () => addToWhitelist(), disabled: isAddingToWhitelist, children: isAddingToWhitelist ? 'ADDING TO WHITELIST...' : 'ADD ME TO WHITELIST' }))] })) : (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Unable to fetch BTC balance. Please try again." })) })), jsxs(Link, { href: "https://gmoney.site/whitelist", target: "_blank", color: "primaryButton", sx: { fontSize: '12px', fontWeight: 400, mt: '10px', mb: '20px' }, children: ["Go to whitelist campaign ", '>'] })] }))] })) : (jsx$2(Fragment$1, {}))] })), jsxs(Flex, { sx: { width: '100%', alignItems: 'center', px: '12%', py: '4rem' }, children: [jsx$2(StepBubble, { number: 1, title: 'STAGE 1', currentStep: currentStageNumber, loading: false }), jsx$2(StepBubble, { number: 2, title: 'STAGE 2', currentStep: currentStageNumber, loading: false }), jsx$2(StepBubble, { number: 3, title: 'STAGE 3', currentStep: currentStageNumber, loading: false }), jsx$2(StepBubble, { number: 5, title: 'TGE', currentStep: currentStageNumber, loading: false, hideBar: true })] }), jsx$2(Divider, { sx: { width: '100%', height: '2px', backgroundColor: 'white2' } }), jsx$2(ProgressBar, { saleInfo: saleInfo }), !(saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.isInBreakPeriod) && !currentStageSoldOut && (jsxs(Fragment$1, { children: [jsx$2(BondsMenu, { setChainFilterOption: handleChainFilterChange, chainFilterOption: chainFilterOption, handleToogle: handleToogle }), activeView === BondsViewOptions.BONDSMARKET && filteredContractsByChain && !isLoadingSaleInfo ? (jsx$2(BondRowsByChain, { contractsByChain: filteredContractsByChain })) : activeView === BondsViewOptions.YOURBONDS && !isLoadingSaleInfo ? (jsx$2(YourGoo, {})) : (jsx$2(Fragment$1, {}))] }))] }));
100387
+ (whitelisted === undefined && !cbBTCBalanceChecked && (jsx$2(Button, { sx: { m: '20px', width: '100%' }, onClick: handleCheckEligibility, children: "CHECK ELIGIBILITY" }))))] }), whitelisted !== null && whitelisted !== undefined && (jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', mt: '20px' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You are whitelisted for Stage ", whitelisted, " and beyond!"] }), jsxs(Text, { color: "primaryButton", sx: { fontSize: '12px', fontWeight: 400, pl: '1rem' }, children: ["Tier ", whitelisted, " Access"] })] })), whitelisted === null && (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px' }, children: [cbBTCBalanceChecked && (jsx$2(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px', mt: '10px' }, children: isCbBTCBalanceLoading ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Checking BTC balance across all chains..." })) : cbBTCBalance ? (jsxs(Fragment$1, { children: [cbBTCBalance.isEligible ? (addToWhitelistSuccess ? (jsx$2(Text, { color: "primaryButton", sx: { fontSize: '12px', fontWeight: 700 }, children: "\u2713 Successfully added to whitelist! Please refresh to see your tier." })) : addToWhitelistError ? (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "Failed to add to whitelist. Please try again." })) : (jsx$2(Fragment$1, { children: jsx$2(Flex, { sx: { flexDirection: 'row', alignItems: 'center' }, children: jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You ", jsx$2("span", { sx: { fontWeight: 700 }, children: "ARE" }), " eligible for the sale"] }) }) }))) : (jsxs(Flex, { sx: { flexDirection: 'column', alignItems: 'center', gap: '10px' }, children: [jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["You are ", jsx$2("span", { sx: { fontWeight: 700 }, children: "NOT" }), " eligible for the sale"] }), jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, color: 'error' }, children: "You need at least 0.001 BTC to be whitelisted" })] })), jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: ["Total BTC Balance: ", cbBTCBalance.balance] }), cbBTCBalance.chainsWithBalance && cbBTCBalance.chainsWithBalance.length > 0 && (jsx$2(Flex, { sx: { flexDirection: 'column', gap: '5px', mt: '5px' }, children: cbBTCBalance.chainsWithBalance.map((chain) => (jsxs(Flex, { sx: { flexDirection: 'row', alignItems: 'center', gap: '10px' }, children: [jsx$2(TokenImage, { symbol: chain.symbol, size: 25, chain: chain.chainId }), jsxs(Text, { sx: { fontSize: '10px', fontWeight: 400, opacity: 0.7 }, children: [chain.balance, " ", chain.symbol] })] }, chain.chainId))) })), cbBTCBalance.isEligible && (jsx$2(Button, { sx: { width: '100%' }, onClick: () => addToWhitelist(), disabled: isAddingToWhitelist, children: isAddingToWhitelist ? 'ADDING TO WHITELIST...' : 'ADD ME TO WHITELIST' }))] })) : (jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400 }, children: "Unable to fetch BTC balance. Please try again." })) })), jsxs(Link, { href: "https://gmoney.site/whitelist", target: "_blank", color: "primaryButton", sx: { fontSize: '12px', fontWeight: 400, mt: '10px', mb: '20px' }, children: ["Go to whitelist campaign ", '>'] })] }))] })) : (jsx$2(Fragment$1, {}))] })), jsxs(Flex, { sx: { width: '100%', alignItems: 'center', px: '12%', py: '4rem' }, children: [jsx$2(StepBubble, { number: 1, title: 'STAGE 1', currentStep: currentStageNumber, loading: false }), jsx$2(StepBubble, { number: 2, title: 'STAGE 2', currentStep: currentStageNumber, loading: false }), jsx$2(StepBubble, { number: 3, title: 'STAGE 3', currentStep: currentStageNumber, loading: false }), jsx$2(StepBubble, { number: 5, title: 'TGE', currentStep: currentStageNumber, loading: false, hideBar: true })] }), jsx$2(Divider, { sx: { width: '100%', height: '2px', backgroundColor: 'white2' } }), jsx$2(ProgressBar, { saleInfo: saleInfo }), !(saleInfo === null || saleInfo === void 0 ? void 0 : saleInfo.isInBreakPeriod) && !currentStageSoldOut ? (jsxs(Fragment$1, { children: [jsx$2(BondsMenu, { setChainFilterOption: handleChainFilterChange, chainFilterOption: chainFilterOption, handleToogle: handleToogle }), activeView === BondsViewOptions.BONDSMARKET && filteredContractsByChain && !isLoadingSaleInfo ? (jsx$2(BondRowsByChain, { contractsByChain: filteredContractsByChain })) : activeView === BondsViewOptions.YOURBONDS && !isLoadingSaleInfo ? (jsx$2(YourGoo, { yourGoo: yourGoo, isLoading: isLoading, isFetching: isFetching })) : (jsx$2(Fragment$1, {}))] })) : userParticipated ? (jsxs(Fragment$1, { children: [jsx$2(Divider, { sx: { width: '100%', height: '2px', backgroundColor: 'white2', my: '1rem' } }), jsx$2(YourGoo, { yourGoo: yourGoo, isLoading: isLoading, isFetching: isFetching })] })) : (jsx$2(Fragment$1, {}))] }));
100388
100388
  };
100389
100389
 
100390
100390
  const GooSaleWithProviders = (props) => {
@@ -1 +1,6 @@
1
- export declare const YourGoo: () => import("react").JSX.Element;
1
+ import { UserGooData } from '../../hooks/useYourGoo';
2
+ export declare const YourGoo: ({ yourGoo, isLoading, isFetching, }: {
3
+ yourGoo: UserGooData | null | undefined;
4
+ isLoading: boolean;
5
+ isFetching: boolean;
6
+ }) => import("react").JSX.Element;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Goo Money Bond SDK",
4
4
  "author": "Goo Money",
5
5
  "license": "MIT",
6
- "version": "3.0.145",
6
+ "version": "3.0.148",
7
7
  "proxy": "https://realtime-api-pr-99.herokuapp.com",
8
8
  "module": "dist/main.js",
9
9
  "type": "module",