@b3dotfun/sdk 0.0.41 → 0.0.42-alpha.0
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/cjs/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +11 -2
- package/dist/cjs/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +33 -11
- package/dist/cjs/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +4 -1
- package/dist/cjs/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PointsBadge.js +7 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +5 -3
- package/dist/cjs/anyspend/services/anyspend.d.ts +1 -1
- package/dist/cjs/anyspend/services/anyspend.js +2 -0
- package/dist/cjs/anyspend/types/api.d.ts +41 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/swapService.js +3 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +19 -13
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAccountAssets.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -1
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/cjs/global-account/react/hooks/useGlobalAccount.js +32 -0
- package/dist/cjs/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/cjs/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/cjs/global-account/react/hooks/useTokenBalancesByChain.js +7 -1
- package/dist/cjs/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +1 -2
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +11 -2
- package/dist/esm/anyspend/react/components/AnySpendBondKit.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +33 -11
- package/dist/esm/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +0 -1
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +4 -1
- package/dist/esm/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PointsBadge.js +4 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +5 -3
- package/dist/esm/anyspend/services/anyspend.d.ts +1 -1
- package/dist/esm/anyspend/services/anyspend.js +2 -0
- package/dist/esm/anyspend/types/api.d.ts +41 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/swapService.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -13
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAccountAssets.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -1
- package/dist/esm/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/esm/global-account/react/hooks/useGlobalAccount.js +29 -0
- package/dist/esm/global-account/react/hooks/useQueryB3.js +5 -2
- package/dist/esm/global-account/react/hooks/useQueryBSMNT.js +5 -2
- package/dist/esm/global-account/react/hooks/useTokenBalancesByChain.js +4 -1
- package/dist/esm/global-account/react/hooks/useTokenFromUrl.js +2 -2
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +2 -3
- package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendNFT.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +41 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useGlobalAccount.d.ts +6 -0
- package/dist/types/shared/utils/fetchBalances.d.ts +1 -1
- package/package.json +22 -23
- package/src/anyspend/react/components/AnySpend.tsx +14 -1
- package/src/anyspend/react/components/AnySpendBondKit.tsx +0 -1
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +0 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +63 -13
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +1 -1
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +6 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +10 -10
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +5 -3
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +41 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/swapService.ts +10 -7
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +21 -17
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAccountAssets.ts +4 -3
- package/src/global-account/react/hooks/useAuthentication.ts +1 -1
- package/src/global-account/react/hooks/useGlobalAccount.tsx +36 -0
- package/src/global-account/react/hooks/useOneBalance.tsx +1 -1
- package/src/global-account/react/hooks/useQueryB3.ts +22 -15
- package/src/global-account/react/hooks/useQueryBSMNT.ts +22 -15
- package/src/global-account/react/hooks/useTokenBalancesByChain.tsx +4 -1
- package/src/global-account/react/hooks/useTokenFromUrl.tsx +2 -2
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +2 -3
- package/src/shared/utils/fetchBalances.ts +1 -1
|
@@ -10,6 +10,7 @@ import { toast } from "sonner";
|
|
|
10
10
|
import { useFeatureFlags } from "../../contexts/FeatureFlagsContext.js";
|
|
11
11
|
import { FiatPaymentMethod } from "./FiatPaymentMethod.js";
|
|
12
12
|
import { OrderTokenAmountFiat } from "./OrderTokenAmountFiat.js";
|
|
13
|
+
import { PointsBadge } from "./PointsBadge.js";
|
|
13
14
|
export function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPaymentMethod, setActivePanel, _recipientAddress, destinationToken, destinationChainId, destinationAmount, onDestinationTokenChange, onDestinationChainChange, fiatPaymentMethodIndex, recipientSelectionPanelIndex, dstTokenSymbol, hideDstToken = false, anyspendQuote, onShowPointsDetail, }) {
|
|
14
15
|
const featureFlags = useFeatureFlags();
|
|
15
16
|
// Get geo-based onramp options to access fee information
|
|
@@ -75,5 +76,7 @@ export function PanelOnramp({ srcAmountOnRamp, setSrcAmountOnRamp, selectedPayme
|
|
|
75
76
|
: "bg-as-surface-secondary hover:bg-as-surface-secondary"}`, children: ["$", value] }, value))) }), destinationToken && destinationChainId && !hideDstToken && (_jsx(OrderTokenAmountFiat, { address: _recipientAddress, context: "to", inputValue: destinationAmount || "0", onChangeInput: () => { }, chainId: destinationChainId, setChainId: onDestinationChainChange || (() => { }), token: destinationToken, setToken: onDestinationTokenChange || (() => { }) }))] }), _jsxs("div", { className: "border-as-border-secondary bg-as-surface-secondary mt-4 flex w-full flex-col gap-3 rounded-xl border p-4", children: [_jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [_jsx("span", { className: "text-as-tertiarry flex items-center text-sm", children: "Recipient" }), _recipientAddress ? (_jsxs("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(recipientSelectionPanelIndex), children: [_jsx("span", { className: "text-sm", children: recipientName ? formatUsername(recipientName) : formatAddress(_recipientAddress) }), _jsx(ChevronRight, { size: 16 })] })) : (_jsxs("button", { className: "text-as-tertiarry flex h-7 items-center gap-1 text-sm transition-colors hover:text-blue-700", onClick: () => setActivePanel(5), children: [_jsx(Wallet, { className: "text-as-brand", size: 16 }), "Select recipient", _jsx(ChevronRight, { size: 16 })] }))] }), _jsx("div", { className: "divider w-full" }), _jsxs("div", { className: "flex items-center justify-between", children: [_jsx("span", { className: "text-as-tertiarry text-sm", children: "Expected to receive" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("span", { className: "text-as-primary font-semibold", children: [destinationAmount || "0", " ", dstTokenSymbol || destinationToken?.symbol || ""] }), _jsxs("span", { className: "text-as-tertiarry text-sm", children: ["on ", destinationChainId ? ALL_CHAINS[destinationChainId]?.name : ""] }), destinationToken && destinationChainId && destinationToken.metadata?.logoURI && (_jsx("img", { src: ALL_CHAINS[destinationChainId]?.logoUrl, alt: "Chain", className: "h-4 w-4 rounded-full" }))] })] }), _jsx("div", { className: "divider w-full" }), _jsx("div", { className: "", children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-as-tertiarry text-sm", children: (() => {
|
|
76
77
|
const fee = getFeeFromApi(selectedPaymentMethod || FiatPaymentMethod.NONE);
|
|
77
78
|
return fee !== null ? `Total (included $${fee.toFixed(2)} fee)` : "Total";
|
|
78
|
-
})() }), featureFlags.showPoints &&
|
|
79
|
+
})() }), featureFlags.showPoints &&
|
|
80
|
+
anyspendQuote?.data?.pointsAmount &&
|
|
81
|
+
anyspendQuote?.data?.pointsAmount > 0 && (_jsx(PointsBadge, { pointsAmount: anyspendQuote.data.pointsAmount, pointsMultiplier: anyspendQuote.data.pointsMultiplier, onClick: () => onShowPointsDetail?.() }))] }), _jsxs("span", { className: "text-as-primary font-semibold", children: ["$", getTotalAmount(selectedPaymentMethod || FiatPaymentMethod.NONE).toFixed(2)] })] }) })] })] }));
|
|
79
82
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function PointsBadge({ pointsAmount, pointsMultiplier, onClick }) {
|
|
3
|
+
return (_jsxs("button", { className: "bg-as-brand hover:scale-102 active:scale-98 relative flex cursor-pointer items-center gap-1 rounded-lg px-2 py-1 transition-all", onClick: onClick, children: [_jsx("div", { className: "pointer-events-none absolute inset-0 h-full w-full rounded-lg border border-white/10 border-t-white/20 bg-gradient-to-b from-white/10 to-white/0" }), _jsxs("span", { className: "relative text-xs text-white", children: ["+", pointsAmount.toLocaleString(), " pts", pointsMultiplier && pointsMultiplier > 1 && _jsxs("span", { className: "ml-1 opacity-80", children: ["(", pointsMultiplier, "x)"] })] })] }));
|
|
4
|
+
}
|
|
@@ -107,15 +107,17 @@ export function useAnyspendFlow({ paymentType = "crypto", recipientAddress, load
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
// Get quote
|
|
110
|
-
|
|
110
|
+
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
111
|
+
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
112
|
+
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
111
113
|
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote({
|
|
112
114
|
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
113
115
|
dstChain: isDepositMode ? base.id : selectedDstChainId, // For deposits, always Base; for swaps, use selected destination
|
|
114
116
|
srcTokenAddress: paymentType === "fiat" ? USDC_BASE.address : selectedSrcToken.address,
|
|
115
117
|
dstTokenAddress: isDepositMode ? B3_TOKEN.address : selectedSrcToken.address, // For deposits, always B3
|
|
116
|
-
type: "
|
|
117
|
-
tradeType: "EXACT_INPUT",
|
|
118
|
+
type: "hype_duel",
|
|
118
119
|
amount: activeInputAmountInWei,
|
|
120
|
+
recipientAddress: selectedRecipientAddress,
|
|
119
121
|
onrampVendor: paymentType === "fiat" ? getOnrampVendor(selectedFiatPaymentMethod) : undefined,
|
|
120
122
|
});
|
|
121
123
|
// Get geo options for fiat
|
|
@@ -28,7 +28,7 @@ export declare const anyspendService: {
|
|
|
28
28
|
}>;
|
|
29
29
|
getOrderAndTransactions: (orderId: string | undefined) => Promise<GetOrderAndTxsResponse>;
|
|
30
30
|
getOrderHistory: (creatorAddress: string | undefined, limit?: number, offset?: number) => Promise<GetOrderHistoryResponse>;
|
|
31
|
-
getCoinbaseOnrampOptions: (country: string, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
|
|
31
|
+
getCoinbaseOnrampOptions: (country: string | undefined, visitorData?: VisitorData) => Promise<GetCoinbaseOnrampOptionsResponse>;
|
|
32
32
|
checkStripeSupport: (usdAmount?: string, visitorData?: VisitorData) => Promise<{
|
|
33
33
|
stripeOnramp: boolean;
|
|
34
34
|
stripeWeb2: components["schemas"]["StripeWeb2Support"];
|
|
@@ -63,6 +63,7 @@ export const anyspendService = {
|
|
|
63
63
|
return data;
|
|
64
64
|
},
|
|
65
65
|
getOrderAndTransactions: async (orderId) => {
|
|
66
|
+
invariant(orderId, "orderId is required");
|
|
66
67
|
const response = await fetch(`${ANYSPEND_MAINNET_BASE_URL}/orders/${orderId}`);
|
|
67
68
|
const data = await response.json();
|
|
68
69
|
return data;
|
|
@@ -80,6 +81,7 @@ export const anyspendService = {
|
|
|
80
81
|
return data;
|
|
81
82
|
},
|
|
82
83
|
getCoinbaseOnrampOptions: async (country, visitorData) => {
|
|
84
|
+
invariant(country, "country is required");
|
|
83
85
|
const params = new URLSearchParams({
|
|
84
86
|
country,
|
|
85
87
|
// include fingerprintId and requestId in the query params
|
|
@@ -503,11 +503,16 @@ export interface paths {
|
|
|
503
503
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
504
504
|
*/
|
|
505
505
|
dstTokenAddress: string;
|
|
506
|
+
/**
|
|
507
|
+
* @description Recipient address
|
|
508
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
509
|
+
*/
|
|
510
|
+
recipientAddress?: string;
|
|
506
511
|
/**
|
|
507
512
|
* @description Type of trade execution
|
|
508
513
|
* @enum {string}
|
|
509
514
|
*/
|
|
510
|
-
tradeType: "EXACT_INPUT" | "
|
|
515
|
+
tradeType: "EXACT_INPUT" | "EXACT_OUTPUT";
|
|
511
516
|
/**
|
|
512
517
|
* @description Amount to quote
|
|
513
518
|
* @example 1000000000000000000
|
|
@@ -544,6 +549,11 @@ export interface paths {
|
|
|
544
549
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
545
550
|
*/
|
|
546
551
|
dstTokenAddress: string;
|
|
552
|
+
/**
|
|
553
|
+
* @description Recipient address
|
|
554
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
555
|
+
*/
|
|
556
|
+
recipientAddress?: string;
|
|
547
557
|
/** @description Custom payload for execution */
|
|
548
558
|
payload: {
|
|
549
559
|
/** @description Encoded transaction data */
|
|
@@ -567,6 +577,11 @@ export interface paths {
|
|
|
567
577
|
dstChain: number;
|
|
568
578
|
srcTokenAddress: string;
|
|
569
579
|
dstTokenAddress: string;
|
|
580
|
+
/**
|
|
581
|
+
* @description Recipient address
|
|
582
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
583
|
+
*/
|
|
584
|
+
recipientAddress?: string;
|
|
570
585
|
/** @enum {string} */
|
|
571
586
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
572
587
|
contractAddress: string;
|
|
@@ -581,6 +596,11 @@ export interface paths {
|
|
|
581
596
|
dstChain: number;
|
|
582
597
|
srcTokenAddress: string;
|
|
583
598
|
dstTokenAddress: string;
|
|
599
|
+
/**
|
|
600
|
+
* @description Recipient address
|
|
601
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
602
|
+
*/
|
|
603
|
+
recipientAddress?: string;
|
|
584
604
|
/** @enum {string} */
|
|
585
605
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
586
606
|
contractAddress: string;
|
|
@@ -592,6 +612,11 @@ export interface paths {
|
|
|
592
612
|
dstChain: number;
|
|
593
613
|
srcTokenAddress: string;
|
|
594
614
|
dstTokenAddress: string;
|
|
615
|
+
/**
|
|
616
|
+
* @description Recipient address
|
|
617
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
618
|
+
*/
|
|
619
|
+
recipientAddress?: string;
|
|
595
620
|
/** @enum {string} */
|
|
596
621
|
onrampVendor?: "coinbase" | "stripe" | "stripe-web2";
|
|
597
622
|
contractAddress: string;
|
|
@@ -622,6 +647,11 @@ export interface paths {
|
|
|
622
647
|
* @example 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
|
|
623
648
|
*/
|
|
624
649
|
dstTokenAddress: string;
|
|
650
|
+
/**
|
|
651
|
+
* @description Recipient address
|
|
652
|
+
* @example 0x55c71fca5e01cf246718748ae540473e608d0282
|
|
653
|
+
*/
|
|
654
|
+
recipientAddress?: string;
|
|
625
655
|
/**
|
|
626
656
|
* @description Amount to quote
|
|
627
657
|
* @example 1000000000000000000
|
|
@@ -1087,6 +1117,11 @@ export interface components {
|
|
|
1087
1117
|
* @example 990000
|
|
1088
1118
|
*/
|
|
1089
1119
|
actualDstAmount: string | null;
|
|
1120
|
+
/**
|
|
1121
|
+
* @description Amount in after fee
|
|
1122
|
+
* @example 990000
|
|
1123
|
+
*/
|
|
1124
|
+
amountInAfterFee: string | null;
|
|
1090
1125
|
};
|
|
1091
1126
|
/** @description HypeDuel-specific payload */
|
|
1092
1127
|
HypeDuelPayload: {
|
|
@@ -1100,6 +1135,11 @@ export interface components {
|
|
|
1100
1135
|
* @example 990000
|
|
1101
1136
|
*/
|
|
1102
1137
|
actualDstAmount: string | null;
|
|
1138
|
+
/**
|
|
1139
|
+
* @description Amount in after fee
|
|
1140
|
+
* @example 990000
|
|
1141
|
+
*/
|
|
1142
|
+
amountInAfterFee: string | null;
|
|
1103
1143
|
};
|
|
1104
1144
|
/** @description Custom execution payload */
|
|
1105
1145
|
CustomPayload: {
|
|
@@ -6,6 +6,7 @@ export const buildPayload = (orderType, params) => {
|
|
|
6
6
|
return {
|
|
7
7
|
expectedDstAmount,
|
|
8
8
|
actualDstAmount: null,
|
|
9
|
+
amountInAfterFee: null,
|
|
9
10
|
};
|
|
10
11
|
case "mint_nft":
|
|
11
12
|
if (nft?.type === "erc1155") {
|
|
@@ -20,6 +21,7 @@ export const buildPayload = (orderType, params) => {
|
|
|
20
21
|
return {
|
|
21
22
|
contractAddress: normalizeAddress(nft.contractAddress),
|
|
22
23
|
nftPrice: nft?.price || "",
|
|
24
|
+
tokenId: null,
|
|
23
25
|
contractType: nft?.type,
|
|
24
26
|
};
|
|
25
27
|
}
|
|
@@ -42,6 +44,7 @@ export const buildPayload = (orderType, params) => {
|
|
|
42
44
|
return {
|
|
43
45
|
expectedDstAmount,
|
|
44
46
|
actualDstAmount: null,
|
|
47
|
+
amountInAfterFee: null,
|
|
45
48
|
};
|
|
46
49
|
default:
|
|
47
50
|
throw new Error(`Invalid order type: ${orderType}`);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { loadScriptFromCDN } from "./utils/cdn-loader.js";
|
|
4
|
-
import { formatNumberSmall } from "./utils/format.js";
|
|
5
3
|
import { Loader2 } from "lucide-react";
|
|
6
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { loadScriptFromCDN } from "./utils/cdn-loader.js";
|
|
6
|
+
import { formatNumberSmall } from "./utils/format.js";
|
|
7
7
|
// TradingView will be available on window after loading from CDN
|
|
8
8
|
// Datafeed will be implemented inline
|
|
9
9
|
// Mock loading overlay - replace with your actual loading component
|
|
10
10
|
const GifLoadingOverlay = ({ className }) => (_jsx("div", { className: `absolute inset-0 flex items-center justify-center bg-white/50 backdrop-blur-sm ${className || ""}`, children: _jsx(Loader2, { className: "text-secondary-grey h-8 w-8 animate-spin" }) }));
|
|
11
11
|
const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
|
|
12
|
-
const theme = "light";
|
|
13
12
|
// Use token info for the current trade
|
|
14
13
|
const currentTrade = {
|
|
15
14
|
product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
|
|
@@ -245,7 +244,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }) => {
|
|
|
245
244
|
tvWidgetRef.current = null;
|
|
246
245
|
}
|
|
247
246
|
};
|
|
248
|
-
}, [
|
|
247
|
+
}, [librariesLoaded, currentTrade?.product_id, tradingViewDefaultInterval, tradingViewTimezone]);
|
|
249
248
|
useEffect(() => {
|
|
250
249
|
if (chartLoaded &&
|
|
251
250
|
currentTrade?.product_id &&
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createPublicClient, encodeAbiParameters, formatUnits, getContract, http, parseAbiParameters, parseUnits, } from "viem";
|
|
2
2
|
import { base } from "viem/chains";
|
|
3
|
-
import {
|
|
3
|
+
import { BaseMainnetRpcUrl, Permit2Address, QuoterAddress, UniversalRouterAddress } from "./constants.js";
|
|
4
4
|
// Minimal ABIs needed for swap functionality
|
|
5
5
|
const UNIVERSAL_ROUTER_ABI = [
|
|
6
6
|
{
|
|
@@ -187,6 +187,9 @@ export class BondkitSwapService {
|
|
|
187
187
|
*/
|
|
188
188
|
async getV4Config() {
|
|
189
189
|
await this.initializeV4Config();
|
|
190
|
+
if (!this.v4Config) {
|
|
191
|
+
throw new Error("Failed to initialize V4 configuration");
|
|
192
|
+
}
|
|
190
193
|
return this.v4Config;
|
|
191
194
|
}
|
|
192
195
|
/**
|
|
@@ -48,23 +48,29 @@ export function B3Provider({ theme = "light", children, accountOverride, environ
|
|
|
48
48
|
client,
|
|
49
49
|
};
|
|
50
50
|
}, [partnerId]);
|
|
51
|
+
// Stringify rpcUrls for stable comparison to prevent wagmiConfig recreation
|
|
52
|
+
// when parent component passes new object references with same content
|
|
53
|
+
const rpcUrlsString = useMemo(() => (rpcUrls ? JSON.stringify(rpcUrls) : undefined), [rpcUrls]);
|
|
51
54
|
/**
|
|
52
55
|
* Creates wagmi config with optional custom RPC URLs
|
|
53
56
|
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
54
57
|
*/
|
|
55
|
-
const wagmiConfig = useMemo(() =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
const wagmiConfig = useMemo(() => {
|
|
59
|
+
const parsedRpcUrls = rpcUrlsString ? JSON.parse(rpcUrlsString) : undefined;
|
|
60
|
+
return createConfig({
|
|
61
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
62
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(parsedRpcUrls?.[chain.id])])),
|
|
63
|
+
connectors: [
|
|
64
|
+
inAppWalletConnector({
|
|
65
|
+
...(ecocystemConfig || {}),
|
|
66
|
+
client,
|
|
67
|
+
}),
|
|
68
|
+
// injected(),
|
|
69
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
}, [ecocystemConfig, rpcUrlsString]);
|
|
73
|
+
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, children: _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" }), _jsx(Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
|
|
68
74
|
}
|
|
69
75
|
/**
|
|
70
76
|
* Inner provider component that provides the actual B3Context
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA";
|
|
15
15
|
export { useGetAllTWSigners, type TWSignerWithMetadata } from "./useGetAllTWSigners";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile";
|
|
@@ -14,6 +14,7 @@ export { useExchangeRate } from "./useExchangeRate.js";
|
|
|
14
14
|
export { useFirstEOA } from "./useFirstEOA.js";
|
|
15
15
|
export { useGetAllTWSigners } from "./useGetAllTWSigners.js";
|
|
16
16
|
export { useGetGeo } from "./useGetGeo.js";
|
|
17
|
+
export { useGlobalAccount } from "./useGlobalAccount.js";
|
|
17
18
|
export { useHandleConnectWithPrivy } from "./useHandleConnectWithPrivy.js";
|
|
18
19
|
export { useHasMounted } from "./useHasMounted.js";
|
|
19
20
|
export { useIsMobile } from "./useIsMobile.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fetchSimpleHashData } from "../../../shared/utils/simplehash.js";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import invariant from "invariant";
|
|
3
4
|
async function fetchAccountAssets(address) {
|
|
4
|
-
|
|
5
|
-
throw new Error("Address is required");
|
|
5
|
+
invariant(address, "Address is required");
|
|
6
6
|
const [nftResponse] = await Promise.all([
|
|
7
7
|
fetchSimpleHashData(`/v0/nfts/owners`, {
|
|
8
8
|
chains: "b3,b3-sepolia,base",
|
|
@@ -92,7 +92,7 @@ export function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
92
92
|
setIsAuthenticating(false);
|
|
93
93
|
}
|
|
94
94
|
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
95
|
-
}, [useAutoConnectLoading]);
|
|
95
|
+
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
96
96
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
if (useAutoConnectLoading) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useAuthStore } from "../../../global-account/react/index.js";
|
|
2
|
+
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useConnectedWallets, useWalletInfo } from "thirdweb/react";
|
|
5
|
+
const debug = debugB3React("useGlobalAccount");
|
|
6
|
+
export function useGlobalAccount() {
|
|
7
|
+
const wallets = useConnectedWallets();
|
|
8
|
+
const isConnected = useAuthStore(state => state.isConnected);
|
|
9
|
+
const [globalAccount, setGlobalAccount] = useState(undefined);
|
|
10
|
+
const [address, setAddress] = useState(undefined);
|
|
11
|
+
const walletInfo = useWalletInfo(globalAccount?.id);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!isConnected) {
|
|
14
|
+
debug("Not connected");
|
|
15
|
+
setGlobalAccount(undefined);
|
|
16
|
+
setAddress(undefined);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
20
|
+
const account = globalAccountWallet?.getAccount();
|
|
21
|
+
setGlobalAccount(globalAccountWallet);
|
|
22
|
+
setAddress(account?.address);
|
|
23
|
+
}, [isConnected, wallets]);
|
|
24
|
+
return {
|
|
25
|
+
account: globalAccount,
|
|
26
|
+
address,
|
|
27
|
+
info: walletInfo,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -24,11 +24,14 @@ fetchInitially = true) {
|
|
|
24
24
|
finally {
|
|
25
25
|
setIsLoading(false);
|
|
26
26
|
}
|
|
27
|
-
}, []);
|
|
27
|
+
}, [service, method]);
|
|
28
|
+
// Serialize params for stable comparison
|
|
29
|
+
const paramsJson = JSON.stringify(params);
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
if (fetchInitially) {
|
|
30
32
|
runQuery(params);
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
33
36
|
return { data, error, isLoading, runQuery };
|
|
34
37
|
}
|
|
@@ -24,11 +24,14 @@ fetchInitially = true) {
|
|
|
24
24
|
finally {
|
|
25
25
|
setIsLoading(false);
|
|
26
26
|
}
|
|
27
|
-
}, []);
|
|
27
|
+
}, [service, method]);
|
|
28
|
+
// Serialize params for stable comparison
|
|
29
|
+
const paramsJson = JSON.stringify(params);
|
|
28
30
|
useEffect(() => {
|
|
29
31
|
if (fetchInitially) {
|
|
30
32
|
runQuery(params);
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
33
36
|
return { data, error, isLoading, runQuery };
|
|
34
37
|
}
|
|
@@ -5,6 +5,7 @@ import { viemToThirdwebChain } from "../../../shared/constants/chains/b3Chain.js
|
|
|
5
5
|
import { getChainById } from "../../../shared/utils/chains.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
7
7
|
import { getWalletBalance } from "thirdweb/wallets";
|
|
8
|
+
import invariant from "invariant";
|
|
8
9
|
export function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
9
10
|
// Normalize chains to array
|
|
10
11
|
const chainIds = Array.isArray(chainsIds) ? chainsIds : [chainsIds];
|
|
@@ -16,10 +17,12 @@ export function useTokenBalancesByChain({ address, chainsIds, enabled = true, })
|
|
|
16
17
|
const [nativeTokens, fungibleResponse] = await Promise.all([
|
|
17
18
|
// Fetch native token balances
|
|
18
19
|
Promise.all(chainIds.map(async (chainId) => {
|
|
20
|
+
const chain = getChainById(chainId);
|
|
21
|
+
invariant(chain, "Chain is required");
|
|
19
22
|
const walletBalance = await getWalletBalance({
|
|
20
23
|
address,
|
|
21
24
|
client,
|
|
22
|
-
chain: viemToThirdwebChain(
|
|
25
|
+
chain: viemToThirdwebChain(chain),
|
|
23
26
|
});
|
|
24
27
|
return {
|
|
25
28
|
...walletBalance,
|
|
@@ -34,7 +34,7 @@ export function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
34
34
|
const network = chainIdParam ? getCoingeckoChainInfo(Number(chainIdParam)).coingecko_id : "";
|
|
35
35
|
const { data: tokenInfo, isError } = useQuery({
|
|
36
36
|
queryKey: ["tokenInfo", network, currencyParam],
|
|
37
|
-
queryFn: () => fetchTokenInfo(network, currencyParam),
|
|
37
|
+
queryFn: () => fetchTokenInfo(network, currencyParam || ""),
|
|
38
38
|
enabled: shouldFetchToken,
|
|
39
39
|
staleTime: Infinity,
|
|
40
40
|
gcTime: Infinity,
|
|
@@ -47,7 +47,7 @@ export function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
47
47
|
if (isError || !tokenInfo) {
|
|
48
48
|
return {
|
|
49
49
|
...defaultToken,
|
|
50
|
-
address: currencyParam,
|
|
50
|
+
address: currencyParam || "",
|
|
51
51
|
chainId: Number(chainIdParam),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
@@ -8,7 +8,7 @@ import { toast } from "sonner";
|
|
|
8
8
|
import { prepareTransaction, sendTransaction as twSendTransaction } from "thirdweb";
|
|
9
9
|
import { useActiveWallet } from "thirdweb/react";
|
|
10
10
|
import { isAddress } from "viem";
|
|
11
|
-
import { useSwitchChain
|
|
11
|
+
import { useSwitchChain } from "wagmi";
|
|
12
12
|
import { useB3 } from "../components/index.js";
|
|
13
13
|
import { useAccountWallet } from "./useAccountWallet.js";
|
|
14
14
|
const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
@@ -17,7 +17,6 @@ const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
|
17
17
|
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID);
|
|
18
18
|
invariant(partnerId, "Partner ID is required");
|
|
19
19
|
export function useUnifiedChainSwitchAndExecute() {
|
|
20
|
-
const { data: walletClient } = useWalletClient();
|
|
21
20
|
const { switchChainAsync } = useSwitchChain();
|
|
22
21
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = useState(false);
|
|
23
22
|
const activeWallet = useActiveWallet();
|
|
@@ -98,7 +97,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
98
97
|
finally {
|
|
99
98
|
setIsSwitchingOrExecuting(false);
|
|
100
99
|
}
|
|
101
|
-
}, [
|
|
100
|
+
}, [connectedEOAWallet, activeWallet, switchChainAsync]);
|
|
102
101
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
103
102
|
const handleAASendTransaction = useCallback(async (targetChainId, params) => {
|
|
104
103
|
if (!aaAccount) {
|
|
@@ -13,4 +13,4 @@ export interface AssetBalance {
|
|
|
13
13
|
totalBalance: string;
|
|
14
14
|
chainBalances: ChainBalance[];
|
|
15
15
|
}
|
|
16
|
-
export declare const fetchBalances: (address: string, testnet?: boolean) => Promise<AssetBalance[]>;
|
|
16
|
+
export declare const fetchBalances: (address: string | undefined, testnet?: boolean) => Promise<AssetBalance[]>;
|