@b3dotfun/sdk 0.0.40-test.6 → 0.0.41-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/constants/index.d.ts +0 -1
- package/dist/cjs/anyspend/constants/index.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +22 -10
- 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 +41 -20
- 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/AnyspendDepositHype.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +10 -8
- package/dist/cjs/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +7 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +24 -23
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -8
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/cjs/anyspend/react/components/common/PaymentMethodSwitch.js +24 -0
- 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/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +14 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- 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 +51 -1
- package/dist/cjs/anyspend/utils/chain.js +1 -1
- package/dist/cjs/anyspend/utils/orderPayload.js +3 -0
- package/dist/cjs/bondkit/bondkitToken.d.ts +37 -2
- package/dist/cjs/bondkit/bondkitToken.js +268 -2
- package/dist/cjs/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/cjs/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/cjs/bondkit/components/TradingView.js +3 -4
- package/dist/cjs/bondkit/config.d.ts +1 -1
- package/dist/cjs/bondkit/config.js +5 -2
- package/dist/cjs/bondkit/constants.d.ts +4 -0
- package/dist/cjs/bondkit/constants.js +6 -1
- package/dist/cjs/bondkit/index.d.ts +1 -0
- package/dist/cjs/bondkit/index.js +4 -1
- package/dist/cjs/bondkit/swapService.d.ts +43 -0
- package/dist/cjs/bondkit/swapService.js +376 -0
- package/dist/cjs/bondkit/types.d.ts +10 -4
- package/dist/cjs/bondkit/types.js +4 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +27 -28
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +63 -3
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- 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/useAccountWallet.js +0 -12
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +2 -3
- 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/useSimBalance.js +2 -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 +28 -24
- package/dist/cjs/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/esm/anyspend/constants/index.d.ts +0 -1
- package/dist/esm/anyspend/constants/index.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +23 -11
- 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 +41 -20
- 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/AnyspendDepositHype.d.ts +8 -0
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +11 -9
- package/dist/esm/anyspend/react/components/AnyspendSignatureMint.js +1 -2
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +8 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +9 -9
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +80 -10
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +40 -37
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +25 -24
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +10 -9
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +23 -9
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +10 -6
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/esm/anyspend/react/components/common/PaymentMethodSwitch.js +21 -0
- 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/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +8 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +6 -4
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +18 -8
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- 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 +51 -1
- package/dist/esm/anyspend/utils/chain.js +1 -1
- package/dist/esm/anyspend/utils/orderPayload.js +3 -0
- package/dist/esm/bondkit/bondkitToken.d.ts +37 -2
- package/dist/esm/bondkit/bondkitToken.js +268 -2
- package/dist/esm/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/esm/bondkit/bondkitTokenFactory.js +2 -2
- package/dist/esm/bondkit/components/TradingView.js +3 -4
- package/dist/esm/bondkit/config.d.ts +1 -1
- package/dist/esm/bondkit/config.js +5 -2
- package/dist/esm/bondkit/constants.d.ts +4 -0
- package/dist/esm/bondkit/constants.js +5 -0
- package/dist/esm/bondkit/index.d.ts +1 -0
- package/dist/esm/bondkit/index.js +2 -0
- package/dist/esm/bondkit/swapService.d.ts +43 -0
- package/dist/esm/bondkit/swapService.js +372 -0
- package/dist/esm/bondkit/types.d.ts +10 -4
- package/dist/esm/bondkit/types.js +4 -5
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +27 -28
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +65 -5
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +35 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- 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/useAccountWallet.js +0 -12
- package/dist/esm/global-account/react/hooks/useAuthentication.js +2 -3
- 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/useSimBalance.js +2 -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 +29 -25
- package/dist/esm/shared/utils/fetchBalances.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +0 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +11 -1
- 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/AnyspendDepositHype.d.ts +8 -0
- package/dist/types/anyspend/react/components/common/ConnectWalletPayment.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +2 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/OrderTokenAmount.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/PaymentMethodSwitch.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsBadge.d.ts +7 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +6 -0
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +4 -1
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/services/anyspend.d.ts +1 -1
- package/dist/types/anyspend/types/api.d.ts +51 -1
- package/dist/types/bondkit/bondkitToken.d.ts +37 -2
- package/dist/types/bondkit/bondkitTokenFactory.d.ts +1 -1
- package/dist/types/bondkit/config.d.ts +1 -1
- package/dist/types/bondkit/constants.d.ts +4 -0
- package/dist/types/bondkit/index.d.ts +1 -0
- package/dist/types/bondkit/swapService.d.ts +43 -0
- package/dist/types/bondkit/types.d.ts +10 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -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 +1 -1
- package/src/anyspend/constants/index.ts +0 -2
- package/src/anyspend/react/components/AnySpend.tsx +52 -18
- 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 +82 -34
- package/src/anyspend/react/components/AnySpendNFT.tsx +3 -0
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +0 -1
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +38 -18
- package/src/anyspend/react/components/AnyspendSignatureMint.tsx +1 -2
- package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +12 -4
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +13 -8
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +170 -44
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +61 -45
- package/src/anyspend/react/components/common/OrderDetails.tsx +60 -47
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +62 -41
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +28 -8
- package/src/anyspend/react/components/common/PanelOnramp.tsx +28 -15
- package/src/anyspend/react/components/common/PaymentMethodSwitch.tsx +38 -0
- package/src/anyspend/react/components/common/PointsBadge.tsx +20 -0
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +55 -0
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +65 -43
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +18 -8
- package/src/anyspend/react/hooks/useAnyspendOrderAndTransactions.ts +1 -1
- package/src/anyspend/react/hooks/useCoinbaseOnrampOptions.ts +1 -1
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/services/anyspend.ts +3 -1
- package/src/anyspend/types/api.ts +51 -1
- package/src/anyspend/types/api_req_res.ts +6 -10
- package/src/anyspend/utils/chain.ts +1 -1
- package/src/anyspend/utils/orderPayload.ts +3 -0
- package/src/bondkit/bondkitToken.ts +323 -3
- package/src/bondkit/bondkitTokenFactory.ts +2 -2
- package/src/bondkit/components/TradingView.tsx +3 -5
- package/src/bondkit/config.ts +5 -2
- package/src/bondkit/constants.ts +7 -0
- package/src/bondkit/index.ts +3 -0
- package/src/bondkit/swapService.ts +464 -0
- package/src/bondkit/types.ts +12 -5
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +31 -32
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +106 -32
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +60 -5
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- 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/useAccountWallet.tsx +0 -13
- package/src/global-account/react/hooks/useAuthentication.ts +2 -3
- 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/useSimBalance.ts +2 -2
- 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 +30 -26
- package/src/shared/utils/fetchBalances.ts +1 -1
- package/dist/cjs/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/cjs/global-account/examples/client-selection-example.js +0 -96
- package/dist/esm/global-account/examples/client-selection-example.d.ts +0 -5
- package/dist/esm/global-account/examples/client-selection-example.js +0 -93
- package/dist/types/global-account/examples/client-selection-example.d.ts +0 -5
- package/src/global-account/docs/client-selection.md +0 -292
- package/src/global-account/examples/client-selection-example.tsx +0 -197
|
@@ -10,6 +10,7 @@ const react_1 = require("../../../../global-account/react");
|
|
|
10
10
|
const SignOutIcon_1 = require("../../../../global-account/react/components/icons/SignOutIcon");
|
|
11
11
|
const formatNumber_1 = require("../../../../shared/utils/formatNumber");
|
|
12
12
|
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
13
|
+
const truncateAddress_1 = require("../../../../shared/utils/truncateAddress");
|
|
13
14
|
const lucide_react_1 = require("lucide-react");
|
|
14
15
|
const react_2 = require("react");
|
|
15
16
|
const sonner_1 = require("sonner");
|
|
@@ -18,6 +19,21 @@ const viem_1 = require("viem");
|
|
|
18
19
|
const profileDisplay_1 = require("../../utils/profileDisplay");
|
|
19
20
|
const AccountAssets_1 = require("../AccountAssets/AccountAssets");
|
|
20
21
|
const ContentTokens_1 = require("./ContentTokens");
|
|
22
|
+
// Helper function to check if a string is a wallet address and format it
|
|
23
|
+
const formatProfileTitle = (title) => {
|
|
24
|
+
// Check if title looks like an Ethereum address (0x followed by 40 hex characters)
|
|
25
|
+
const isEthereumAddress = /^0x[a-fA-F0-9]{40}$/.test(title);
|
|
26
|
+
if (isEthereumAddress) {
|
|
27
|
+
return {
|
|
28
|
+
displayTitle: (0, truncateAddress_1.truncateAddress)(title),
|
|
29
|
+
isAddress: true,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
displayTitle: title,
|
|
34
|
+
isAddress: false,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
21
37
|
const BalanceContent_1 = require("./BalanceContent");
|
|
22
38
|
function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain, partnerId, showSwap, showDeposit, }) {
|
|
23
39
|
const [revokingSignerId, setRevokingSignerId] = (0, react_2.useState)(null);
|
|
@@ -117,7 +133,7 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
|
|
|
117
133
|
}
|
|
118
134
|
};
|
|
119
135
|
const profiles = profilesRaw
|
|
120
|
-
.filter((profile) => !["custom_auth_endpoint"
|
|
136
|
+
.filter((profile) => !["custom_auth_endpoint"].includes(profile.type))
|
|
121
137
|
.map((profile) => ({
|
|
122
138
|
...(0, profileDisplay_1.getProfileDisplayInfo)(profile),
|
|
123
139
|
originalProfile: profile,
|
|
@@ -152,7 +168,24 @@ function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit, chain
|
|
|
152
168
|
},
|
|
153
169
|
});
|
|
154
170
|
};
|
|
155
|
-
|
|
171
|
+
console.log("@@profiles", profiles);
|
|
172
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "linked-accounts-settings space-y-8", children: [(0, jsx_runtime_1.jsxs)("div", { className: "linked-accounts-section space-y-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "linked-accounts-header flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-b3-grey font-neue-montreal-semibold linked-accounts-settings-title text-xl", children: "Linked Accounts" }), (0, jsx_runtime_1.jsxs)(react_1.Button, { className: "linked-accounts-settings-button linked-accounts-link-button bg-b3-primary-wash hover:bg-b3-primary-wash/70 flex items-center gap-2 rounded-full px-4 py-2", onClick: handleOpenLinkModal, disabled: isLinking, children: [isLinking ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "linked-accounts-link-loading text-b3-primary-blue animate-spin", size: 16 })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.LinkIcon, { size: 16, className: "linked-accounts-link-icon text-b3-primary-blue" })), (0, jsx_runtime_1.jsx)("span", { className: "linked-accounts-link-text text-b3-grey font-neue-montreal-semibold", children: isLinking ? "Linking..." : "Link New Account" })] })] }), isLoadingProfiles ? ((0, jsx_runtime_1.jsx)("div", { className: "linked-accounts-loading flex justify-center py-8", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-b3-grey animate-spin" }) })) : profiles.length > 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "linked-accounts-list space-y-4", children: profiles.map(profile => ((0, jsx_runtime_1.jsxs)("div", { className: "linked-account-item bg-b3-line group flex items-center justify-between rounded-xl p-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "linked-account-info flex items-center gap-3", children: [profile.imageUrl ? ((0, jsx_runtime_1.jsx)("img", { src: profile.imageUrl, alt: profile.title, className: "linked-account-avatar linked-account-avatar-image size-10 rounded-full" })) : ((0, jsx_runtime_1.jsx)("div", { className: "linked-account-avatar linked-account-avatar-placeholder bg-b3-primary-wash flex h-10 w-10 items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("span", { className: "linked-account-initial text-b3-grey font-neue-montreal-semibold text-sm uppercase", children: profile.initial }) })), (0, jsx_runtime_1.jsxs)("div", { className: "linked-account-details", children: [(0, jsx_runtime_1.jsxs)("div", { className: "linked-account-title-row flex items-center gap-2", children: [(() => {
|
|
173
|
+
const { displayTitle, isAddress } = formatProfileTitle(profile.title);
|
|
174
|
+
const handleCopyAddress = async (e) => {
|
|
175
|
+
e.stopPropagation();
|
|
176
|
+
try {
|
|
177
|
+
await navigator.clipboard.writeText(profile.title);
|
|
178
|
+
sonner_1.toast.success("Address copied to clipboard!");
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
sonner_1.toast.error("Failed to copy address");
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)("span", { className: `linked-account-title text-b3-grey font-neue-montreal-semibold ${isAddress
|
|
185
|
+
? "font-mono text-sm" // Use monospace font for addresses
|
|
186
|
+
: "break-words" // Use break-words for emails/names (better than break-all)
|
|
187
|
+
}`, title: isAddress ? profile.title : undefined, children: displayTitle }), isAddress && ((0, jsx_runtime_1.jsx)("button", { onClick: handleCopyAddress, className: "linked-account-copy-button ml-1 rounded p-1 opacity-0 transition-opacity hover:bg-gray-100 group-hover:opacity-100", title: "Copy full address", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { size: 12, className: "text-gray-500 hover:text-gray-700" }) }))] }));
|
|
188
|
+
})(), (0, jsx_runtime_1.jsx)("span", { className: "linked-account-type text-b3-foreground-muted font-neue-montreal-medium bg-b3-primary-wash rounded px-2 py-0.5 text-xs", children: profile.type.toUpperCase() })] }), (0, jsx_runtime_1.jsx)("div", { className: "linked-account-subtitle text-b3-foreground-muted font-neue-montreal-medium text-sm", children: profile.subtitle })] })] }), (0, jsx_runtime_1.jsx)(react_1.Button, { variant: "ghost", size: "icon", className: "linked-account-unlink-button text-b3-grey hover:text-b3-negative", onClick: () => handleUnlink(profile), disabled: unlinkingAccountId === profile.title || isUnlinking, children: unlinkingAccountId === profile.title || isUnlinking ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "linked-account-unlink-loading animate-spin" })) : ((0, jsx_runtime_1.jsx)(lucide_react_1.UnlinkIcon, { size: 16, className: "linked-account-unlink-icon" })) })] }, profile.title))) })) : ((0, jsx_runtime_1.jsx)("div", { className: "linked-accounts-empty text-b3-foreground-muted py-8 text-center", children: "No linked accounts found" }))] }), showReferralInfo && (
|
|
156
189
|
/* Referral Section */
|
|
157
190
|
(0, jsx_runtime_1.jsxs)("div", { className: "referrals-section space-y-4", children: [(0, jsx_runtime_1.jsx)("h3", { className: "referrals-title text-b3-grey font-neue-montreal-semibold text-xl", children: "Referrals" }), (0, jsx_runtime_1.jsxs)("div", { className: "referral-code-container bg-b3-line rounded-xl p-4", children: [isEditingCode && ((0, jsx_runtime_1.jsxs)("div", { className: "referral-code-header-editing", children: [(0, jsx_runtime_1.jsx)("div", { className: "referral-code-title text-b3-grey font-neue-montreal-semibold", children: "Your Referral Code" }), (0, jsx_runtime_1.jsx)("div", { className: "referral-code-description text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Share this code with friends to earn rewards" })] })), (0, jsx_runtime_1.jsxs)("div", { className: "referral-code-content flex items-center justify-between", children: [!isEditingCode && ((0, jsx_runtime_1.jsxs)("div", { className: "referral-code-header", children: [(0, jsx_runtime_1.jsx)("div", { className: "referral-code-title text-b3-grey font-neue-montreal-semibold", children: "Your Referral Code" }), (0, jsx_runtime_1.jsx)("div", { className: "referral-code-description text-b3-foreground-muted font-neue-montreal-medium text-sm", children: "Share this code with friends to earn rewards" })] })), (0, jsx_runtime_1.jsx)("div", { className: "referral-code-actions flex items-center gap-2", children: isEditingCode ? ((0, jsx_runtime_1.jsxs)("div", { className: "referral-code-edit-form flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", value: newReferralCode, onChange: e => setNewReferralCode(e.target.value), className: "referral-code-input rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm", placeholder: "Enter new code", ref: referallCodeRef }), (0, jsx_runtime_1.jsx)(react_1.Button, { size: "sm", className: "referral-code-save-button", onClick: handleUpdateReferralCode, disabled: isUpdatingCode || !newReferralCode, children: isUpdatingCode ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "referral-code-save-loading h-4 w-4 animate-spin" })) : ("Save") }), (0, jsx_runtime_1.jsx)(react_1.Button, { size: "sm", variant: "ghost", className: "referral-code-cancel-button", onClick: () => {
|
|
158
191
|
setIsEditingCode(false);
|
|
@@ -8,6 +8,7 @@ const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
|
|
|
8
8
|
const react_2 = require("react");
|
|
9
9
|
const react_3 = require("thirdweb/react");
|
|
10
10
|
const wallets_1 = require("thirdweb/wallets");
|
|
11
|
+
const debug = (0, debug_1.debugB3React)("LoginStepCustom");
|
|
11
12
|
function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
12
13
|
const [isLoading, setIsLoading] = (0, react_2.useState)(false);
|
|
13
14
|
const [showAllWallets, setShowAllWallets] = (0, react_2.useState)(false);
|
|
@@ -24,7 +25,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
|
|
|
24
25
|
const handleConnect = async (strategy) => {
|
|
25
26
|
try {
|
|
26
27
|
setIsLoading(true);
|
|
27
|
-
|
|
28
|
+
debug("setIsAuthenticating:true:3");
|
|
28
29
|
setIsAuthenticating(true);
|
|
29
30
|
const options = (0, react_1.getConnectOptionsFromStrategy)(strategy);
|
|
30
31
|
let connectResult;
|
|
@@ -45,7 +46,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
|
|
|
45
46
|
connectResult = await connect(options);
|
|
46
47
|
}
|
|
47
48
|
const account = connectResult?.getAccount();
|
|
48
|
-
|
|
49
|
+
debug("@@connectResult", { connectResult, account, options });
|
|
49
50
|
if (!account)
|
|
50
51
|
throw new Error("Failed to connect");
|
|
51
52
|
await onSuccess(account);
|
|
@@ -58,7 +59,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
|
|
|
58
59
|
}
|
|
59
60
|
finally {
|
|
60
61
|
setIsLoading(false);
|
|
61
|
-
|
|
62
|
+
debug("setIsAuthenticating:false:3");
|
|
62
63
|
setIsAuthenticating(false);
|
|
63
64
|
}
|
|
64
65
|
};
|
|
@@ -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,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
|
|
17
|
+
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalance = exports.useSiwe = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfilePreference = exports.useProfile = exports.useOneBalance = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useBestTransactionPath = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = void 0;
|
|
18
18
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
19
19
|
Object.defineProperty(exports, "useAccountAssets", { enumerable: true, get: function () { return useAccountAssets_1.useAccountAssets; } });
|
|
20
20
|
var useAccountWallet_1 = require("./useAccountWallet");
|
|
@@ -46,6 +46,8 @@ var useGetAllTWSigners_1 = require("./useGetAllTWSigners");
|
|
|
46
46
|
Object.defineProperty(exports, "useGetAllTWSigners", { enumerable: true, get: function () { return useGetAllTWSigners_1.useGetAllTWSigners; } });
|
|
47
47
|
var useGetGeo_1 = require("./useGetGeo");
|
|
48
48
|
Object.defineProperty(exports, "useGetGeo", { enumerable: true, get: function () { return useGetGeo_1.useGetGeo; } });
|
|
49
|
+
var useGlobalAccount_1 = require("./useGlobalAccount");
|
|
50
|
+
Object.defineProperty(exports, "useGlobalAccount", { enumerable: true, get: function () { return useGlobalAccount_1.useGlobalAccount; } });
|
|
49
51
|
var useHandleConnectWithPrivy_1 = require("./useHandleConnectWithPrivy");
|
|
50
52
|
Object.defineProperty(exports, "useHandleConnectWithPrivy", { enumerable: true, get: function () { return useHandleConnectWithPrivy_1.useHandleConnectWithPrivy; } });
|
|
51
53
|
var useHasMounted_1 = require("./useHasMounted");
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.useAccountAssets = useAccountAssets;
|
|
4
7
|
const simplehash_1 = require("../../../shared/utils/simplehash");
|
|
5
8
|
const react_query_1 = require("@tanstack/react-query");
|
|
9
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
6
10
|
async function fetchAccountAssets(address) {
|
|
7
|
-
|
|
8
|
-
throw new Error("Address is required");
|
|
11
|
+
(0, invariant_1.default)(address, "Address is required");
|
|
9
12
|
const [nftResponse] = await Promise.all([
|
|
10
13
|
(0, simplehash_1.fetchSimpleHashData)(`/v0/nfts/owners`, {
|
|
11
14
|
chains: "b3,b3-sepolia,base",
|
|
@@ -43,18 +43,6 @@ function useAccountWallet() {
|
|
|
43
43
|
const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
|
|
44
44
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
45
45
|
const avatarUrl = user?.avatar ? (0, ipfs_1.getIpfsUrl)(user?.avatar) : profileData?.avatar;
|
|
46
|
-
console.log("@@gio:connectedWallets", connectedWallets);
|
|
47
|
-
// useEffect(() => {
|
|
48
|
-
// if (connectedWallets.length > 0) {
|
|
49
|
-
// console.log("connectedWallets:1", connectedWallets);
|
|
50
|
-
// // force autoconnect
|
|
51
|
-
// const firstWallet = connectedWallets[0];
|
|
52
|
-
// console.log("firstWallet:1", firstWallet);
|
|
53
|
-
// firstWallet.autoConnect({
|
|
54
|
-
// client: client,
|
|
55
|
-
// });
|
|
56
|
-
// }
|
|
57
|
-
// }, [connectedWallets]);
|
|
58
46
|
const res = (0, react_2.useMemo)(() => ({
|
|
59
47
|
wallet: {
|
|
60
48
|
...account,
|
|
@@ -98,7 +98,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
98
98
|
setIsAuthenticating(false);
|
|
99
99
|
}
|
|
100
100
|
useAutoConnectLoadingPrevious.current = useAutoConnectLoading;
|
|
101
|
-
}, [useAutoConnectLoading]);
|
|
101
|
+
}, [useAutoConnectLoading, hasStartedConnecting, setIsAuthenticating]);
|
|
102
102
|
// Ensure isAuthenticating stays true until we're fully ready
|
|
103
103
|
(0, react_2.useEffect)(() => {
|
|
104
104
|
if (useAutoConnectLoading) {
|
|
@@ -122,8 +122,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
|
|
|
122
122
|
if (activeWallet) {
|
|
123
123
|
debug("@@logout:activeWallet", activeWallet);
|
|
124
124
|
disconnect(activeWallet);
|
|
125
|
-
debug("@@logout:
|
|
126
|
-
console.log("@@gio:logout:activeWallet", activeWallet);
|
|
125
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
127
126
|
}
|
|
128
127
|
// Log out of each wallet
|
|
129
128
|
wallets.forEach(wallet => {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGlobalAccount = useGlobalAccount;
|
|
4
|
+
const react_1 = require("../../../global-account/react");
|
|
5
|
+
const debug_1 = require("../../../shared/utils/debug");
|
|
6
|
+
const react_2 = require("react");
|
|
7
|
+
const react_3 = require("thirdweb/react");
|
|
8
|
+
const debug = (0, debug_1.debugB3React)("useGlobalAccount");
|
|
9
|
+
function useGlobalAccount() {
|
|
10
|
+
const wallets = (0, react_3.useConnectedWallets)();
|
|
11
|
+
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
12
|
+
const [globalAccount, setGlobalAccount] = (0, react_2.useState)(undefined);
|
|
13
|
+
const [address, setAddress] = (0, react_2.useState)(undefined);
|
|
14
|
+
const walletInfo = (0, react_3.useWalletInfo)(globalAccount?.id);
|
|
15
|
+
(0, react_2.useEffect)(() => {
|
|
16
|
+
if (!isConnected) {
|
|
17
|
+
debug("Not connected");
|
|
18
|
+
setGlobalAccount(undefined);
|
|
19
|
+
setAddress(undefined);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const globalAccountWallet = wallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
23
|
+
const account = globalAccountWallet?.getAccount();
|
|
24
|
+
setGlobalAccount(globalAccountWallet);
|
|
25
|
+
setAddress(account?.address);
|
|
26
|
+
}, [isConnected, wallets]);
|
|
27
|
+
return {
|
|
28
|
+
account: globalAccount,
|
|
29
|
+
address,
|
|
30
|
+
info: walletInfo,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -30,11 +30,14 @@ fetchInitially = true) {
|
|
|
30
30
|
finally {
|
|
31
31
|
setIsLoading(false);
|
|
32
32
|
}
|
|
33
|
-
}, []);
|
|
33
|
+
}, [service, method]);
|
|
34
|
+
// Serialize params for stable comparison
|
|
35
|
+
const paramsJson = JSON.stringify(params);
|
|
34
36
|
(0, react_1.useEffect)(() => {
|
|
35
37
|
if (fetchInitially) {
|
|
36
38
|
runQuery(params);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
39
42
|
return { data, error, isLoading, runQuery };
|
|
40
43
|
}
|
|
@@ -30,11 +30,14 @@ fetchInitially = true) {
|
|
|
30
30
|
finally {
|
|
31
31
|
setIsLoading(false);
|
|
32
32
|
}
|
|
33
|
-
}, []);
|
|
33
|
+
}, [service, method]);
|
|
34
|
+
// Serialize params for stable comparison
|
|
35
|
+
const paramsJson = JSON.stringify(params);
|
|
34
36
|
(0, react_1.useEffect)(() => {
|
|
35
37
|
if (fetchInitially) {
|
|
36
38
|
runQuery(params);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, [runQuery, fetchInitially, paramsJson]);
|
|
39
42
|
return { data, error, isLoading, runQuery };
|
|
40
43
|
}
|
|
@@ -6,8 +6,8 @@ async function fetchSimBalance(address) {
|
|
|
6
6
|
if (!address)
|
|
7
7
|
throw new Error("Address is required");
|
|
8
8
|
let url = `https://simdune-api.sean-430.workers.dev/?url=https://api.sim.dune.com/v1/evm/balances/${address}?metadata=logo&chain_ids=mainnet`;
|
|
9
|
-
if (process.env.
|
|
10
|
-
url += `&localkey=${process.env.
|
|
9
|
+
if (process.env.NEXT_PUBLIC_LOCAL_KEY) {
|
|
10
|
+
url += `&localkey=${process.env.NEXT_PUBLIC_LOCAL_KEY}`;
|
|
11
11
|
}
|
|
12
12
|
const response = await fetch(url);
|
|
13
13
|
if (!response.ok) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
7
|
exports.useTokenBalancesByChain = useTokenBalancesByChain;
|
|
5
8
|
const thirdweb_insights_1 = require("../../../shared/utils/thirdweb-insights");
|
|
@@ -8,6 +11,7 @@ const b3Chain_1 = require("../../../shared/constants/chains/b3Chain");
|
|
|
8
11
|
const chains_1 = require("../../../shared/utils/chains");
|
|
9
12
|
const thirdweb_1 = require("../../../shared/utils/thirdweb");
|
|
10
13
|
const wallets_1 = require("thirdweb/wallets");
|
|
14
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
11
15
|
function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
12
16
|
// Normalize chains to array
|
|
13
17
|
const chainIds = Array.isArray(chainsIds) ? chainsIds : [chainsIds];
|
|
@@ -19,10 +23,12 @@ function useTokenBalancesByChain({ address, chainsIds, enabled = true, }) {
|
|
|
19
23
|
const [nativeTokens, fungibleResponse] = await Promise.all([
|
|
20
24
|
// Fetch native token balances
|
|
21
25
|
Promise.all(chainIds.map(async (chainId) => {
|
|
26
|
+
const chain = (0, chains_1.getChainById)(chainId);
|
|
27
|
+
(0, invariant_1.default)(chain, "Chain is required");
|
|
22
28
|
const walletBalance = await (0, wallets_1.getWalletBalance)({
|
|
23
29
|
address,
|
|
24
30
|
client: thirdweb_1.client,
|
|
25
|
-
chain: (0, b3Chain_1.viemToThirdwebChain)(
|
|
31
|
+
chain: (0, b3Chain_1.viemToThirdwebChain)(chain),
|
|
26
32
|
});
|
|
27
33
|
return {
|
|
28
34
|
...walletBalance,
|
|
@@ -38,7 +38,7 @@ function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
38
38
|
const network = chainIdParam ? (0, supported_1.getCoingeckoChainInfo)(Number(chainIdParam)).coingecko_id : "";
|
|
39
39
|
const { data: tokenInfo, isError } = (0, react_query_1.useQuery)({
|
|
40
40
|
queryKey: ["tokenInfo", network, currencyParam],
|
|
41
|
-
queryFn: () => fetchTokenInfo(network, currencyParam),
|
|
41
|
+
queryFn: () => fetchTokenInfo(network, currencyParam || ""),
|
|
42
42
|
enabled: shouldFetchToken,
|
|
43
43
|
staleTime: Infinity,
|
|
44
44
|
gcTime: Infinity,
|
|
@@ -51,7 +51,7 @@ function useTokenFromUrl({ defaultToken, prefix }) {
|
|
|
51
51
|
if (isError || !tokenInfo) {
|
|
52
52
|
return {
|
|
53
53
|
...defaultToken,
|
|
54
|
-
address: currencyParam,
|
|
54
|
+
address: currencyParam || "",
|
|
55
55
|
chainId: Number(chainIdParam),
|
|
56
56
|
};
|
|
57
57
|
}
|
|
@@ -12,50 +12,56 @@ const invariant_1 = __importDefault(require("invariant"));
|
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const sonner_1 = require("sonner");
|
|
14
14
|
const thirdweb_2 = require("thirdweb");
|
|
15
|
+
const react_2 = require("thirdweb/react");
|
|
16
|
+
const viem_1 = require("viem");
|
|
15
17
|
const wagmi_1 = require("wagmi");
|
|
16
18
|
const components_1 = require("../components");
|
|
17
19
|
const useAccountWallet_1 = require("./useAccountWallet");
|
|
18
|
-
const viem_1 = require("viem");
|
|
19
20
|
const partnerId = String(process.env.PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
20
21
|
process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID ||
|
|
21
22
|
process.env.PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID ||
|
|
22
23
|
process.env.NEXT_PUBLIC_GLOBAL_ACCOUNTS_PARTNER_ID);
|
|
23
24
|
(0, invariant_1.default)(partnerId, "Partner ID is required");
|
|
24
25
|
function useUnifiedChainSwitchAndExecute() {
|
|
25
|
-
const { data: walletClient } = (0, wagmi_1.useWalletClient)();
|
|
26
26
|
const { switchChainAsync } = (0, wagmi_1.useSwitchChain)();
|
|
27
27
|
const [isSwitchingOrExecuting, setIsSwitchingOrExecuting] = (0, react_1.useState)(false);
|
|
28
|
-
const
|
|
28
|
+
const activeWallet = (0, react_2.useActiveWallet)();
|
|
29
|
+
const { isActiveSmartWallet, isActiveEOAWallet, connectedEOAWallet } = (0, useAccountWallet_1.useAccountWallet)();
|
|
29
30
|
const { account: aaAccount } = (0, components_1.useB3)();
|
|
30
31
|
// Handle EOA wallet chain switch and execute transaction
|
|
31
32
|
const handleEOASwitchChainAndSendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
32
|
-
if (!
|
|
33
|
+
if (!connectedEOAWallet) {
|
|
33
34
|
sonner_1.toast.error("Please connect your wallet");
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
const
|
|
37
|
+
// Get target chain configuration once
|
|
38
|
+
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
39
|
+
if (!targetChain) {
|
|
40
|
+
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const currentChainId = activeWallet?.getChain()?.id;
|
|
44
|
+
const onCorrectChain = currentChainId === targetChainId;
|
|
38
45
|
// Helper function to execute the transaction
|
|
39
46
|
const executeTransaction = async () => {
|
|
40
|
-
const signer =
|
|
47
|
+
const signer = activeWallet?.getAccount();
|
|
41
48
|
if (!signer) {
|
|
42
49
|
throw new Error("No account connected");
|
|
43
50
|
}
|
|
44
|
-
//
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
|
|
51
|
+
// Coinbase Smart Wallet specific chain switching (different behavior from other wallets)
|
|
52
|
+
const walletChain = connectedEOAWallet.getChain();
|
|
53
|
+
if (walletChain?.id !== targetChainId) {
|
|
54
|
+
activeWallet?.switchChain((0, supported_1.getThirdwebChain)(targetChainId));
|
|
48
55
|
}
|
|
49
56
|
(0, invariant_1.default)((0, viem_1.isAddress)(params.to), "params.to is not a valid address");
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
chain: targetChain,
|
|
57
|
+
const result = await signer.sendTransaction({
|
|
58
|
+
chainId: targetChainId,
|
|
53
59
|
to: params.to,
|
|
54
60
|
data: params.data,
|
|
55
61
|
value: params.value,
|
|
56
62
|
});
|
|
57
|
-
sonner_1.toast.success(`Transaction sent: ${
|
|
58
|
-
return
|
|
63
|
+
sonner_1.toast.success(`Transaction sent: ${result.transactionHash.slice(0, 10)}...`);
|
|
64
|
+
return result.transactionHash;
|
|
59
65
|
};
|
|
60
66
|
try {
|
|
61
67
|
setIsSwitchingOrExecuting(true);
|
|
@@ -63,11 +69,6 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
63
69
|
return await executeTransaction();
|
|
64
70
|
}
|
|
65
71
|
const switchingToastId = sonner_1.toast.info(`Switching to ${(0, anyspend_1.getChainName)(targetChainId)}…`);
|
|
66
|
-
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
67
|
-
if (!targetChain) {
|
|
68
|
-
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
72
|
const blockExplorerUrl = targetChain.blockExplorers?.default.url;
|
|
72
73
|
(0, invariant_1.default)(blockExplorerUrl, "Block explorer URL is required");
|
|
73
74
|
const nativeCurrency = (0, anyspend_1.getNativeToken)(targetChainId);
|
|
@@ -102,7 +103,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
102
103
|
finally {
|
|
103
104
|
setIsSwitchingOrExecuting(false);
|
|
104
105
|
}
|
|
105
|
-
}, [
|
|
106
|
+
}, [connectedEOAWallet, activeWallet, switchChainAsync]);
|
|
106
107
|
// Handle AA wallet transaction (no chain switch needed for AA)
|
|
107
108
|
const handleAASendTransaction = (0, react_1.useCallback)(async (targetChainId, params) => {
|
|
108
109
|
if (!aaAccount) {
|
|
@@ -130,18 +131,21 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
130
131
|
});
|
|
131
132
|
}
|
|
132
133
|
catch (err) {
|
|
133
|
-
console.error(err);
|
|
134
|
+
console.error("Create global-accounts-intents error", err);
|
|
134
135
|
}
|
|
135
136
|
sonner_1.toast.info("Sending transaction…");
|
|
137
|
+
const start = performance.now();
|
|
136
138
|
const sendTxResponse = await (0, thirdweb_2.sendTransaction)({
|
|
137
139
|
account: aaAccount,
|
|
138
140
|
transaction,
|
|
139
141
|
});
|
|
142
|
+
const end = performance.now();
|
|
143
|
+
console.log("Time taken to send transaction", end - start);
|
|
140
144
|
sonner_1.toast.success("Transaction sent successfully");
|
|
141
145
|
return sendTxResponse.transactionHash;
|
|
142
146
|
}
|
|
143
147
|
catch (err) {
|
|
144
|
-
console.error(err);
|
|
148
|
+
console.error("Send transaction error", err);
|
|
145
149
|
sonner_1.toast.error(err?.message ?? "Transaction failed");
|
|
146
150
|
return undefined;
|
|
147
151
|
}
|
|
@@ -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[]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { components } from "../../types/api";
|
|
1
2
|
export interface RecipientOption {
|
|
2
3
|
address: string;
|
|
3
4
|
icon?: string;
|
|
@@ -12,7 +13,8 @@ export declare enum PanelView {
|
|
|
12
13
|
FIAT_PAYMENT = 4,
|
|
13
14
|
RECIPIENT_SELECTION = 5,
|
|
14
15
|
CRYPTO_PAYMENT_METHOD = 6,
|
|
15
|
-
FIAT_PAYMENT_METHOD = 7
|
|
16
|
+
FIAT_PAYMENT_METHOD = 7,
|
|
17
|
+
POINTS_DETAIL = 8
|
|
16
18
|
}
|
|
17
19
|
export declare function AnySpend(props: {
|
|
18
20
|
mode?: "page" | "modal";
|
|
@@ -22,4 +24,12 @@ export declare function AnySpend(props: {
|
|
|
22
24
|
recipientAddress?: string;
|
|
23
25
|
loadOrder?: string;
|
|
24
26
|
hideTransactionHistoryButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Called when a token is selected. Call event.preventDefault() to prevent default token selection behavior.
|
|
29
|
+
* Useful for handling special cases like B3 token selection.
|
|
30
|
+
*/
|
|
31
|
+
onTokenSelect?: (token: components["schemas"]["Token"], event: {
|
|
32
|
+
preventDefault: () => void;
|
|
33
|
+
}) => void;
|
|
34
|
+
onSuccess?: (txHash?: string) => void;
|
|
25
35
|
}): import("react/jsx-runtime").JSX.Element;
|