@b3dotfun/sdk 0.1.69-alpha.9 → 0.1.69-test.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/rpc.d.ts +1 -1
- package/dist/cjs/anyspend/constants/rpc.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/checkout/AnySpendCheckout.js +10 -2
- package/dist/cjs/anyspend/react/components/checkout/CheckoutSuccess.js +3 -3
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +43 -23
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +10 -9
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/cjs/anyspend/utils/chain.js +8 -7
- package/dist/cjs/global-account/better-auth-client.d.ts +1883 -0
- package/dist/cjs/global-account/better-auth-client.js +17 -0
- package/dist/cjs/global-account/bsmnt.d.ts +0 -1
- package/dist/cjs/global-account/bsmnt.js +0 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +9 -12
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -9
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/cjs/global-account/react/components/B3Provider/BetterAuthProvider.js +120 -0
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/cjs/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +15 -6
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/cjs/global-account/react/components/Send/Send.js +5 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +67 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +163 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +138 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/utils/signInUtils.js +5 -1
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/cjs/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/cjs/global-account/react/components/index.d.ts +3 -0
- package/dist/cjs/global-account/react/components/index.js +7 -3
- package/dist/cjs/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +5 -2
- package/dist/cjs/global-account/react/hooks/useAuth.js +24 -11
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +21 -8
- package/dist/cjs/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/cjs/global-account/react/hooks/useBetterAuth.js +157 -0
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/cjs/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/cjs/global-account/react/utils/index.d.ts +0 -1
- package/dist/cjs/global-account/react/utils/index.js +0 -1
- package/dist/cjs/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/cjs/shared/constants/chains/b3Chain.js +4 -4
- package/dist/cjs/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/cjs/shared/constants/chains/b3Viem.js +19 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +1 -1
- package/dist/cjs/shared/generated/chain-networks.json +2 -2
- package/dist/cjs/shared/utils/chains.d.ts +1 -1
- package/dist/cjs/shared/utils/chains.js +2 -2
- package/dist/cjs/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/cjs/wallet/react/components/ConnectWallet.js +467 -0
- package/dist/cjs/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/cjs/wallet/react/components/WalletProvider.js +20 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/cjs/wallet/react/hooks/useWalletDisconnect.js +22 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/cjs/wallet/react/hooks/useWalletState.js +63 -0
- package/dist/cjs/wallet/react/index.d.ts +5 -0
- package/dist/cjs/wallet/react/index.js +16 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/cjs/wallet/utils/createWalletConfig.js +24 -0
- package/dist/esm/anyspend/constants/rpc.d.ts +1 -1
- package/dist/esm/anyspend/constants/rpc.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendNFT.js +2 -2
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/esm/anyspend/react/components/checkout/AnySpendCheckout.js +10 -2
- package/dist/esm/anyspend/react/components/checkout/CheckoutSuccess.js +3 -3
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +44 -24
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +9 -8
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +2 -2
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/esm/anyspend/utils/chain.js +10 -9
- package/dist/esm/global-account/better-auth-client.d.ts +1883 -0
- package/dist/esm/global-account/better-auth-client.js +13 -0
- package/dist/esm/global-account/bsmnt.d.ts +0 -1
- package/dist/esm/global-account/bsmnt.js +0 -5
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +2 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +4 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +2 -5
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/esm/global-account/react/components/B3Provider/BetterAuthProvider.js +115 -0
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +4 -2
- package/dist/esm/global-account/react/components/LinkAccount/LinkedAccountItem.js +2 -1
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +13 -7
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/esm/global-account/react/components/Send/Send.js +5 -2
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthResetPassword.js +64 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/esm/global-account/react/components/SignInWithB3/BetterAuthSignIn.js +160 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +13 -4
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.js +135 -0
- package/dist/esm/global-account/react/components/SignInWithB3/utils/signInUtils.js +5 -1
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +2 -1
- package/dist/esm/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +3 -0
- package/dist/esm/global-account/react/components/index.js +2 -0
- package/dist/esm/global-account/react/components/ui/button.d.ts +1 -1
- 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/useAuth.js +24 -11
- package/dist/esm/global-account/react/hooks/useAuthentication.js +21 -8
- package/dist/esm/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/esm/global-account/react/hooks/useBetterAuth.js +149 -0
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/esm/global-account/react/utils/createWagmiConfig.js +5 -7
- package/dist/esm/global-account/react/utils/index.d.ts +0 -1
- package/dist/esm/global-account/react/utils/index.js +0 -1
- package/dist/esm/global-account/react/utils/profileDisplay.js +17 -18
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/esm/shared/constants/chains/b3Chain.js +4 -4
- package/dist/esm/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/esm/shared/constants/chains/b3Viem.js +16 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +1 -1
- package/dist/esm/shared/generated/chain-networks.json +2 -2
- package/dist/esm/shared/utils/chains.d.ts +1 -1
- package/dist/esm/shared/utils/chains.js +2 -2
- package/dist/esm/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/esm/wallet/react/components/ConnectWallet.js +431 -0
- package/dist/esm/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/esm/wallet/react/components/WalletProvider.js +17 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/esm/wallet/react/hooks/useWalletDisconnect.js +19 -0
- package/dist/esm/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/esm/wallet/react/hooks/useWalletState.js +60 -0
- package/dist/esm/wallet/react/index.d.ts +5 -0
- package/dist/esm/wallet/react/index.js +8 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +21 -0
- package/dist/esm/wallet/utils/createWalletConfig.js +21 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/rpc.d.ts +1 -1
- package/dist/types/anyspend/react/components/checkout/AnySpendCheckout.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +8 -0
- package/dist/types/global-account/better-auth-client.d.ts +1883 -0
- package/dist/types/global-account/bsmnt.d.ts +0 -1
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +4 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +8 -1
- package/dist/types/global-account/react/components/B3Provider/BetterAuthProvider.d.ts +16 -0
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +3 -1
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthResetPassword.d.ts +21 -0
- package/dist/types/global-account/react/components/SignInWithB3/BetterAuthSignIn.d.ts +34 -0
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.d.ts +6 -0
- package/dist/types/global-account/react/components/custom/Button.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +3 -0
- package/dist/types/global-account/react/components/ui/button.d.ts +1 -1
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useBetterAuth.d.ts +973 -0
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +4 -13
- package/dist/types/global-account/react/utils/index.d.ts +0 -1
- package/dist/types/shared/constants/chains/b3Chain.d.ts +7 -7
- package/dist/types/shared/constants/chains/b3Viem.d.ts +6 -0
- package/dist/types/shared/constants/chains/supported.d.ts +1 -1
- package/dist/types/shared/utils/chains.d.ts +1 -1
- package/dist/types/wallet/react/components/ConnectWallet.d.ts +11 -0
- package/dist/types/wallet/react/components/WalletProvider.d.ts +35 -0
- package/dist/types/wallet/react/hooks/useWalletDisconnect.d.ts +13 -0
- package/dist/types/wallet/react/hooks/useWalletState.d.ts +31 -0
- package/dist/types/wallet/react/index.d.ts +5 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +21 -0
- package/package.json +14 -6
- package/src/anyspend/constants/rpc.ts +2 -1
- package/src/anyspend/react/components/AnySpendNFT.tsx +2 -2
- package/src/anyspend/react/components/checkout/AnySpendCheckout.tsx +15 -1
- package/src/anyspend/react/components/checkout/CheckoutSuccess.tsx +3 -3
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +45 -27
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +10 -8
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +4 -4
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- package/src/anyspend/utils/chain.ts +9 -9
- package/src/global-account/better-auth-client.ts +17 -0
- package/src/global-account/bsmnt.ts +0 -6
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +6 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +14 -20
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +52 -40
- package/src/global-account/react/components/B3Provider/BetterAuthProvider.tsx +127 -0
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.tsx +17 -10
- package/src/global-account/react/components/LinkAccount/LinkedAccountItem.tsx +2 -1
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +29 -11
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
- package/src/global-account/react/components/Send/Send.tsx +8 -5
- package/src/global-account/react/components/SignInWithB3/BetterAuthResetPassword.tsx +146 -0
- package/src/global-account/react/components/SignInWithB3/BetterAuthSignIn.tsx +426 -0
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +13 -4
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepBetterAuth.tsx +308 -0
- package/src/global-account/react/components/SignInWithB3/utils/signInUtils.ts +5 -1
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +2 -1
- package/src/global-account/react/components/index.ts +3 -0
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +24 -11
- package/src/global-account/react/hooks/useAuthentication.ts +21 -8
- package/src/global-account/react/hooks/useBetterAuth.ts +191 -0
- package/src/global-account/react/utils/createWagmiConfig.tsx +6 -7
- package/src/global-account/react/utils/index.ts +0 -1
- package/src/global-account/react/utils/profileDisplay.ts +21 -19
- package/src/shared/constants/chains/b3Chain.ts +5 -5
- package/src/shared/constants/chains/b3Viem.ts +18 -0
- package/src/shared/generated/chain-networks.json +2 -2
- package/src/shared/utils/chains.ts +3 -2
- package/src/wallet/__tests__/createWalletConfig.test.ts +39 -0
- package/src/wallet/react/components/ConnectWallet.tsx +665 -0
- package/src/wallet/react/components/WalletProvider.tsx +64 -0
- package/src/wallet/react/hooks/useWalletDisconnect.ts +22 -0
- package/src/wallet/react/hooks/useWalletState.ts +93 -0
- package/src/wallet/react/index.ts +10 -0
- package/src/wallet/utils/createWalletConfig.ts +39 -0
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/cjs/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -54
- package/dist/cjs/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/cjs/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/cjs/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/cjs/global-account/react/hooks/useRPMToken.js +0 -11
- package/dist/cjs/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/cjs/global-account/react/utils/updateAvatar.js +0 -54
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/esm/global-account/react/components/AvatarCreator/AvatarCreator.js +0 -51
- package/dist/esm/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/esm/global-account/react/components/ProfileAvatar.js +0 -127
- package/dist/esm/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/esm/global-account/react/hooks/useRPMToken.js +0 -8
- package/dist/esm/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/dist/esm/global-account/react/utils/updateAvatar.js +0 -18
- package/dist/types/global-account/react/components/AvatarCreator/AvatarCreator.d.ts +0 -6
- package/dist/types/global-account/react/components/ProfileAvatar.d.ts +0 -0
- package/dist/types/global-account/react/hooks/useRPMToken.d.ts +0 -7
- package/dist/types/global-account/react/utils/updateAvatar.d.ts +0 -4
- package/src/global-account/react/components/AvatarCreator/AvatarCreator.tsx +0 -90
- package/src/global-account/react/components/ProfileAvatar.tsx +0 -138
- package/src/global-account/react/hooks/useRPMToken.ts +0 -17
- package/src/global-account/react/utils/updateAvatar.ts +0 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CreateConnectorFn } from "wagmi";
|
|
2
2
|
export interface CreateWagmiConfigOptions {
|
|
3
3
|
partnerId: string;
|
|
4
4
|
rpcUrls?: Record<number, string>;
|
|
@@ -6,7 +6,8 @@ export interface CreateWagmiConfigOptions {
|
|
|
6
6
|
overrideDefaultConnectors?: boolean;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Creates a wagmi config with
|
|
9
|
+
* Creates a wagmi config with the B3 ecosystem wallet connector.
|
|
10
|
+
* Delegates to createWalletConfig and adds the ecosystem connector on top.
|
|
10
11
|
* @param options.partnerId - Partner ID for the ecosystem wallet
|
|
11
12
|
* @param options.rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
12
13
|
* @param options.connectors - Additional connectors to include
|
|
@@ -14,14 +15,4 @@ export interface CreateWagmiConfigOptions {
|
|
|
14
15
|
*/
|
|
15
16
|
export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
|
|
16
17
|
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
17
|
-
},
|
|
18
|
-
connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
|
|
19
|
-
accounts: withCapabilities extends true ? readonly {
|
|
20
|
-
address: `0x${string}`;
|
|
21
|
-
capabilities: Record<string, unknown>;
|
|
22
|
-
}[] : readonly `0x${string}`[];
|
|
23
|
-
chainId: number;
|
|
24
|
-
}>;
|
|
25
|
-
}, {
|
|
26
|
-
"thirdweb:lastChainId": number;
|
|
27
|
-
}>)[]>;
|
|
18
|
+
}, CreateConnectorFn[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ChainNetworks } from "@b3dotfun/sdk/global-account/types/chain-networks";
|
|
1
2
|
import { Chain as ThirdwebChain } from "thirdweb";
|
|
2
3
|
import { Chain } from "viem";
|
|
3
|
-
import { ChainNetworks } from "@b3dotfun/sdk/global-account/types/chain-networks";
|
|
4
4
|
export declare const nullAddress = "0x0000000000000000000000000000000000000000";
|
|
5
5
|
export declare const avatarsNFTCollectionAddress = "0x658E2F67D3121A0eA81e5854be0b7539be27Aeb0";
|
|
6
6
|
export declare const viemToThirdwebChain: (chain: Chain) => ThirdwebChain;
|
|
@@ -33,8 +33,8 @@ export declare const b3Mainnet: {
|
|
|
33
33
|
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
34
34
|
rpcUrls: {
|
|
35
35
|
readonly default: {
|
|
36
|
-
readonly http: readonly ["https://
|
|
37
|
-
readonly ws: readonly ["wss://
|
|
36
|
+
readonly http: readonly ["https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"];
|
|
37
|
+
readonly ws: readonly ["wss://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"];
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
sourceId?: number | undefined | undefined;
|
|
@@ -43,7 +43,7 @@ export declare const b3Mainnet: {
|
|
|
43
43
|
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
44
44
|
formatters?: undefined;
|
|
45
45
|
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
46
|
-
readonly rpc: "https://
|
|
46
|
+
readonly rpc: "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2";
|
|
47
47
|
readonly icon: {
|
|
48
48
|
readonly url: "https://cdn.b3.fun/b3_logo.svg";
|
|
49
49
|
readonly width: 32;
|
|
@@ -128,8 +128,8 @@ export declare const b3Chain: Chain | {
|
|
|
128
128
|
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
129
129
|
rpcUrls: {
|
|
130
130
|
readonly default: {
|
|
131
|
-
readonly http: readonly ["https://
|
|
132
|
-
readonly ws: readonly ["wss://
|
|
131
|
+
readonly http: readonly ["https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"];
|
|
132
|
+
readonly ws: readonly ["wss://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2"];
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
sourceId?: number | undefined | undefined;
|
|
@@ -138,7 +138,7 @@ export declare const b3Chain: Chain | {
|
|
|
138
138
|
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
139
139
|
formatters?: undefined;
|
|
140
140
|
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
141
|
-
readonly rpc: "https://
|
|
141
|
+
readonly rpc: "https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2";
|
|
142
142
|
readonly icon: {
|
|
143
143
|
readonly url: "https://cdn.b3.fun/b3_logo.svg";
|
|
144
144
|
readonly width: 32;
|
|
@@ -2,6 +2,7 @@ import type { Chain as ThirdwebChain } from "thirdweb";
|
|
|
2
2
|
export declare const supportedChains: import("viem").Chain[];
|
|
3
3
|
export declare const supportedChainsTW: ThirdwebChain[];
|
|
4
4
|
export declare const supportedChainNetworks: {
|
|
5
|
+
formatters?: Record<string, any> | undefined;
|
|
5
6
|
contracts?: Record<string, {
|
|
6
7
|
blockCreated?: number | undefined;
|
|
7
8
|
address: string;
|
|
@@ -9,7 +10,6 @@ export declare const supportedChainNetworks: {
|
|
|
9
10
|
sourceId?: number | undefined;
|
|
10
11
|
testnet?: boolean | undefined;
|
|
11
12
|
fees?: Record<string, any> | undefined;
|
|
12
|
-
formatters?: Record<string, any> | undefined;
|
|
13
13
|
color?: string | undefined;
|
|
14
14
|
testnetConfigID?: number | undefined;
|
|
15
15
|
badge?: string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain } from "viem
|
|
1
|
+
import type { Chain } from "viem";
|
|
2
2
|
export declare function getChainById(id: number): Chain | undefined;
|
|
3
3
|
export declare function chainIdToName(id: number): string | undefined;
|
|
4
4
|
export declare function getExplorerUrl(chain: Chain, txHash: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ConnectWalletProps {
|
|
2
|
+
/** Theme for the modal and button. Defaults to "light". */
|
|
3
|
+
theme?: "light" | "dark";
|
|
4
|
+
/** Label for the connect button. Defaults to "Connect Wallet". */
|
|
5
|
+
buttonLabel?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Drop-in wallet connection component styled to match the B3 design system.
|
|
9
|
+
* Uses inline styles — works in any app without tailwind configuration.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ConnectWallet({ theme: themeProp, buttonLabel }: ConnectWalletProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { type Config, type CreateConnectorFn } from "wagmi";
|
|
3
|
+
import type { Chain } from "viem";
|
|
4
|
+
export interface WalletProviderProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Chains to support. Defaults to SDK's supportedChains.
|
|
8
|
+
* Must be memoized or defined outside the component — inline arrays cause the
|
|
9
|
+
* wagmi config to rebuild on every render, losing wallet connection state.
|
|
10
|
+
*/
|
|
11
|
+
chains?: Chain[];
|
|
12
|
+
/**
|
|
13
|
+
* Wagmi connectors. Must be memoized or defined outside the component — inline
|
|
14
|
+
* arrays cause the wagmi config to rebuild on every render, losing wallet connection state.
|
|
15
|
+
*/
|
|
16
|
+
connectors?: CreateConnectorFn[];
|
|
17
|
+
/**
|
|
18
|
+
* Optional RPC URL overrides per chain ID.
|
|
19
|
+
* Must be memoized or defined outside the component — inline objects cause the
|
|
20
|
+
* wagmi config to rebuild on every render, losing wallet connection state.
|
|
21
|
+
*/
|
|
22
|
+
rpcUrls?: Record<number, string>;
|
|
23
|
+
/** Escape hatch: pass a fully custom wagmi config. Overrides chains/connectors/rpcUrls. */
|
|
24
|
+
wagmiConfig?: Config;
|
|
25
|
+
/** Provide your own QueryClient for React Query. Defaults to an internal instance. */
|
|
26
|
+
queryClient?: QueryClient;
|
|
27
|
+
/** Whether to auto-reconnect the last wallet on mount. Defaults to false. */
|
|
28
|
+
reconnectOnMount?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Standalone wallet connection provider.
|
|
32
|
+
* Wraps ThirdwebProvider, WagmiProvider, and QueryClientProvider.
|
|
33
|
+
* Use wagmi hooks (useAccount, useConnect, useDisconnect) directly inside.
|
|
34
|
+
*/
|
|
35
|
+
export declare function WalletProvider({ children, chains, connectors, rpcUrls, wagmiConfig: wagmiConfigProp, queryClient: queryClientProp, reconnectOnMount, }: WalletProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disconnect the current wallet via wagmi.
|
|
3
|
+
* Consumers should use this instead of wagmi's useDisconnect directly
|
|
4
|
+
* to ensure a consistent disconnect API across the wallet module.
|
|
5
|
+
*
|
|
6
|
+
* Note: this only disconnects the wagmi layer. When used inside B3Provider,
|
|
7
|
+
* the thirdweb auth session is managed separately by B3Provider's own logout
|
|
8
|
+
* flow (useAuthentication). ConnectWallet is intended for standalone
|
|
9
|
+
* WalletProvider usage where thirdweb auth is not involved.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useWalletDisconnect(): {
|
|
12
|
+
disconnect: () => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Chain } from "viem";
|
|
2
|
+
import type { Connector } from "wagmi";
|
|
3
|
+
export interface WalletConnector {
|
|
4
|
+
/** Display name of the wallet */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Unique identifier for this connector instance */
|
|
7
|
+
uid: string;
|
|
8
|
+
/** Whether the wallet extension/app is detected in the browser */
|
|
9
|
+
isInstalled: boolean;
|
|
10
|
+
/** Connect using this connector. Returns a promise that resolves on success or rejects on failure/rejection. */
|
|
11
|
+
connect: () => Promise<void>;
|
|
12
|
+
/** Raw wagmi connector for advanced use */
|
|
13
|
+
connector: Connector;
|
|
14
|
+
}
|
|
15
|
+
export interface WalletState {
|
|
16
|
+
/** Connected wallet address, or undefined if not connected */
|
|
17
|
+
address: string | undefined;
|
|
18
|
+
/** Whether a wallet is currently connected */
|
|
19
|
+
isConnected: boolean;
|
|
20
|
+
/** Current chain the wallet is connected to */
|
|
21
|
+
chain: Chain | undefined;
|
|
22
|
+
/** Whether a connection attempt is in progress */
|
|
23
|
+
isPending: boolean;
|
|
24
|
+
/** Available wallet connectors, deduplicated by name */
|
|
25
|
+
connectors: WalletConnector[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Unified wallet state from both thirdweb and wagmi layers.
|
|
29
|
+
* Provides available connectors with install status and connect functions.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useWalletState(): WalletState;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { WalletProvider, type WalletProviderProps } from "./components/WalletProvider";
|
|
2
|
+
export { createWalletConfig, type CreateWalletConfigOptions } from "../utils/createWalletConfig";
|
|
3
|
+
export { useWalletDisconnect } from "./hooks/useWalletDisconnect";
|
|
4
|
+
export { useWalletState, type WalletConnector, type WalletState } from "./hooks/useWalletState";
|
|
5
|
+
export { ConnectWallet, type ConnectWalletProps } from "./components/ConnectWallet";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CreateConnectorFn } from "wagmi";
|
|
2
|
+
import type { Chain } from "viem";
|
|
3
|
+
export interface CreateWalletConfigOptions {
|
|
4
|
+
/** Chains to support. Defaults to SDK's supportedChains. Must be non-empty. */
|
|
5
|
+
chains?: Chain[];
|
|
6
|
+
/**
|
|
7
|
+
* Wagmi connectors. Defaults to injected + Coinbase Wallet.
|
|
8
|
+
* Must be memoized if passed to WalletProvider — inline arrays
|
|
9
|
+
* will cause the config to rebuild on every render, losing wallet connection state.
|
|
10
|
+
*/
|
|
11
|
+
connectors?: CreateConnectorFn[];
|
|
12
|
+
/** Optional RPC URL overrides per chain ID. */
|
|
13
|
+
rpcUrls?: Record<number, string>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a generic wagmi config with sensible defaults.
|
|
17
|
+
* No ecosystem wallet, no B3-specific concerns.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [Chain, ...Chain[]], {
|
|
20
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
21
|
+
}, CreateConnectorFn[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.1.69-
|
|
3
|
+
"version": "0.1.69-test.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -205,6 +205,16 @@
|
|
|
205
205
|
"import": "./dist/esm/notifications/types/index.js",
|
|
206
206
|
"require": "./dist/cjs/notifications/types/index.js"
|
|
207
207
|
},
|
|
208
|
+
"./wallet/react": {
|
|
209
|
+
"types": "./dist/types/wallet/react/index.d.ts",
|
|
210
|
+
"import": "./dist/esm/wallet/react/index.js",
|
|
211
|
+
"require": "./dist/cjs/wallet/react/index.js"
|
|
212
|
+
},
|
|
213
|
+
"./wallet/utils/*": {
|
|
214
|
+
"types": "./dist/types/wallet/utils/*.d.ts",
|
|
215
|
+
"import": "./dist/esm/wallet/utils/*.js",
|
|
216
|
+
"require": "./dist/cjs/wallet/utils/*.js"
|
|
217
|
+
},
|
|
208
218
|
"./shared/utils": {
|
|
209
219
|
"types": "./dist/types/shared/utils/index.d.ts",
|
|
210
220
|
"import": "./dist/esm/shared/utils/index.js",
|
|
@@ -319,7 +329,9 @@
|
|
|
319
329
|
"@stripe/stripe-js": "^7.3.1",
|
|
320
330
|
"@thirdweb-dev/wagmi-adapter": "0.2.165",
|
|
321
331
|
"@web3icons/react": "3.16.0",
|
|
332
|
+
"better-auth": "^1.5.6",
|
|
322
333
|
"big.js": "^7.0.1",
|
|
334
|
+
"boring-avatars": "^2.0.4",
|
|
323
335
|
"class-variance-authority": "0.7.0",
|
|
324
336
|
"clsx": "2.0.0",
|
|
325
337
|
"cmdk": "1.0.0",
|
|
@@ -375,6 +387,7 @@
|
|
|
375
387
|
"thirdweb": "5.116.1",
|
|
376
388
|
"tsc-alias": "^1.8.16",
|
|
377
389
|
"tsc-watch": "^7.1.1",
|
|
390
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
378
391
|
"vitest": "^3.2.4"
|
|
379
392
|
},
|
|
380
393
|
"typesVersions": {
|
|
@@ -388,8 +401,6 @@
|
|
|
388
401
|
"@fingerprintjs/fingerprintjs-pro-react": "^2.7.0",
|
|
389
402
|
"@privy-io/react-auth": "^2.8.0",
|
|
390
403
|
"@react-three/postprocessing": "2.16.6",
|
|
391
|
-
"@readyplayerme/react-avatar-creator": "0.5.0",
|
|
392
|
-
"@readyplayerme/visage": "6.10.0",
|
|
393
404
|
"@tanstack/react-query": "5.55.0",
|
|
394
405
|
"@wagmi/core": "2.20.3",
|
|
395
406
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -404,9 +415,6 @@
|
|
|
404
415
|
"@react-three/postprocessing": {
|
|
405
416
|
"optional": true
|
|
406
417
|
},
|
|
407
|
-
"@readyplayerme/visage": {
|
|
408
|
-
"optional": true
|
|
409
|
-
},
|
|
410
418
|
"react-native-mmkv": {
|
|
411
419
|
"optional": true
|
|
412
420
|
},
|
|
@@ -17,7 +17,8 @@ export const AVALANCHE_PUBLIC_RPC = "https://avalanche-c-chain-rpc.publicnode.co
|
|
|
17
17
|
export const BSC_PUBLIC_RPC = "https://bsc-rpc.publicnode.com";
|
|
18
18
|
|
|
19
19
|
// Chain-specific public endpoints
|
|
20
|
-
export const B3_PUBLIC_RPC =
|
|
20
|
+
export const B3_PUBLIC_RPC =
|
|
21
|
+
"https://late-dimensional-yard.b3-mainnet.quiknode.pro/461dbdbd44158cd7a7a764a58ffb01a67eef77f2/";
|
|
21
22
|
export const ABSTRACT_PUBLIC_RPC = "https://api.mainnet.abs.xyz";
|
|
22
23
|
export const HYPEREVM_PUBLIC_RPC = "https://rpc.hyperliquid.xyz/evm";
|
|
23
24
|
|
|
@@ -8,7 +8,7 @@ import { formatDisplayNumber, formatTokenAmount } from "@b3dotfun/sdk/shared/uti
|
|
|
8
8
|
import { MoreVertical } from "lucide-react";
|
|
9
9
|
import { AnimatePresence } from "motion/react";
|
|
10
10
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
11
|
-
import {
|
|
11
|
+
import { b3Viem } from "@b3dotfun/sdk/shared/constants/chains/b3Viem";
|
|
12
12
|
import { GetQuoteResponse } from "../../types/api_req_res";
|
|
13
13
|
import { AnySpendCustom } from "./AnySpendCustom";
|
|
14
14
|
import type { AnySpendContent, AnySpendSlots, AnySpendTheme } from "./types/customization";
|
|
@@ -215,7 +215,7 @@ function DropdownMenu({ nftContract }: { nftContract: components["schemas"]["Nft
|
|
|
215
215
|
</div>
|
|
216
216
|
|
|
217
217
|
<div className="hover:bg-as-on-surface-3 flex cursor-default items-center gap-2 rounded px-2">
|
|
218
|
-
<img src={chain?.logoUrl} className={cn("h-5 w-5", nftContract.chainId !==
|
|
218
|
+
<img src={chain?.logoUrl} className={cn("h-5 w-5", nftContract.chainId !== b3Viem.id && "rounded-full")} />
|
|
219
219
|
<span className="text-sm">
|
|
220
220
|
Minted on <span className="font-semibold">{chain ? getChainName(nftContract.chainId) : "Unknown"}</span>
|
|
221
221
|
</span>
|
|
@@ -138,6 +138,8 @@ export interface AnySpendCheckoutProps {
|
|
|
138
138
|
feeOnTop?: boolean;
|
|
139
139
|
/** When true, identity verification (KYC) is required before card payment. Defaults to false. */
|
|
140
140
|
kycEnabled?: boolean;
|
|
141
|
+
/** Extra metadata included under the 'callbackMetadata' key in the order's callbackMetadata (e.g. workflowId, orgId from checkout session) */
|
|
142
|
+
callbackMetadata?: Record<string, unknown>;
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
const emptyAddress: AddressData = { street: "", city: "", state: "", zip: "", country: "" };
|
|
@@ -187,6 +189,7 @@ export function AnySpendCheckout({
|
|
|
187
189
|
variablePricing,
|
|
188
190
|
feeOnTop,
|
|
189
191
|
kycEnabled = false,
|
|
192
|
+
callbackMetadata: callbackMetadataProp,
|
|
190
193
|
}: AnySpendCheckoutProps) {
|
|
191
194
|
// ===== Variable pricing state =====
|
|
192
195
|
const [variablePricingAmount, setVariablePricingAmount] = useState<string>("0");
|
|
@@ -342,8 +345,11 @@ export function AnySpendCheckout({
|
|
|
342
345
|
if (isVariablePricingActive && variablePricingAmount !== "0") {
|
|
343
346
|
meta.variablePricingAmount = variablePricingAmount;
|
|
344
347
|
}
|
|
348
|
+
// Namespace caller-supplied metadata to avoid collisions with internal keys
|
|
349
|
+
if (callbackMetadataProp) meta.callbackMetadata = callbackMetadataProp;
|
|
345
350
|
return Object.keys(meta).length > 0 ? meta : undefined;
|
|
346
351
|
}, [
|
|
352
|
+
callbackMetadataProp,
|
|
347
353
|
formData,
|
|
348
354
|
selectedShipping,
|
|
349
355
|
shippingAddress,
|
|
@@ -371,7 +377,15 @@ export function AnySpendCheckout({
|
|
|
371
377
|
|
|
372
378
|
return (
|
|
373
379
|
<AnySpendFingerprintWrapper fingerprint={fingerprint}>
|
|
374
|
-
<AnySpendCustomizationProvider
|
|
380
|
+
<AnySpendCustomizationProvider
|
|
381
|
+
slots={slots}
|
|
382
|
+
content={{
|
|
383
|
+
successTitle: "Payment Successful",
|
|
384
|
+
successDescription: "Your payment has been processed successfully.",
|
|
385
|
+
...content,
|
|
386
|
+
}}
|
|
387
|
+
theme={theme}
|
|
388
|
+
>
|
|
375
389
|
<CheckoutLayout
|
|
376
390
|
mode={mode}
|
|
377
391
|
paymentPanel={
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { getExplorerTxUrl } from "@b3dotfun/sdk/anyspend";
|
|
4
|
-
import {
|
|
4
|
+
import { b3Viem } from "@b3dotfun/sdk/shared/constants/chains/b3Viem";
|
|
5
5
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
6
6
|
import { ExternalLink } from "lucide-react";
|
|
7
7
|
import { motion } from "motion/react";
|
|
@@ -39,7 +39,7 @@ export function CheckoutSuccess({
|
|
|
39
39
|
: "Your payment has been processed successfully.",
|
|
40
40
|
txHash,
|
|
41
41
|
orderId,
|
|
42
|
-
explorerUrl: txHash ? getExplorerTxUrl(dstChainId ??
|
|
42
|
+
explorerUrl: txHash ? getExplorerTxUrl(dstChainId ?? b3Viem.id, txHash) : undefined,
|
|
43
43
|
onDone: () => {
|
|
44
44
|
if (returnUrl) window.location.href = returnUrl;
|
|
45
45
|
},
|
|
@@ -79,7 +79,7 @@ export function CheckoutSuccess({
|
|
|
79
79
|
initial={{ opacity: 0 }}
|
|
80
80
|
animate={{ opacity: 1 }}
|
|
81
81
|
transition={{ duration: 0.3, delay: 0.5, ease: "easeOut" }}
|
|
82
|
-
href={getExplorerTxUrl(dstChainId ??
|
|
82
|
+
href={getExplorerTxUrl(dstChainId ?? b3Viem.id, txHash)}
|
|
83
83
|
target="_blank"
|
|
84
84
|
rel="noopener noreferrer"
|
|
85
85
|
className="anyspend-success-tx-link mt-4 flex items-center gap-1.5 text-sm text-blue-600 hover:underline dark:text-blue-400"
|
|
@@ -11,15 +11,12 @@ import { getPaymentUrl } from "@b3dotfun/sdk/anyspend/utils/chain";
|
|
|
11
11
|
import { isNativeToken } from "@b3dotfun/sdk/anyspend/utils/token";
|
|
12
12
|
import {
|
|
13
13
|
useAccountWallet,
|
|
14
|
-
useB3Config,
|
|
15
14
|
useIsMobile,
|
|
16
|
-
useModalStore,
|
|
17
15
|
useSimTokenBalance,
|
|
18
16
|
useTokenData,
|
|
19
17
|
useUnifiedChainSwitchAndExecute,
|
|
20
18
|
} from "@b3dotfun/sdk/global-account/react";
|
|
21
19
|
import { ShinyButton, TextShimmer } from "@b3dotfun/sdk/global-account/react";
|
|
22
|
-
import { thirdwebB3Chain } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
23
20
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
24
21
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
25
22
|
import { Check, ChevronDown, ChevronsUpDown, Copy, Loader2, QrCode } from "lucide-react";
|
|
@@ -27,8 +24,10 @@ import { QRCodeSVG } from "qrcode.react";
|
|
|
27
24
|
import { encodeFunctionData, erc20Abi } from "viem";
|
|
28
25
|
import { AnimatePresence, motion } from "motion/react";
|
|
29
26
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
27
|
+
import { useConnectModal } from "thirdweb/react";
|
|
30
28
|
import { TokenSelector } from "@relayprotocol/relay-kit-ui";
|
|
31
29
|
import { ChainTokenIcon } from "../common/ChainTokenIcon";
|
|
30
|
+
import { connectModalConfig } from "../common/CryptoPaymentMethod";
|
|
32
31
|
import type { AnySpendCheckoutClasses } from "./AnySpendCheckout";
|
|
33
32
|
|
|
34
33
|
interface CryptoPayPanelProps {
|
|
@@ -76,11 +75,10 @@ export function CryptoPayPanel({
|
|
|
76
75
|
const [selectedSrcToken, setSelectedSrcToken] = useState<components["schemas"]["Token"] | null>(null);
|
|
77
76
|
const [copied, setCopied] = useState(false);
|
|
78
77
|
|
|
79
|
-
const { address: walletAddress } = useAccountWallet();
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
78
|
+
const { address: walletAddress, connectedEOAWallet } = useAccountWallet();
|
|
79
|
+
const connectedAddress = walletAddress || connectedEOAWallet?.getAccount()?.address;
|
|
80
|
+
const effectiveAddress = connectedAddress || senderAddress;
|
|
81
|
+
const { connect: openConnectModal } = useConnectModal();
|
|
84
82
|
|
|
85
83
|
const { data: dstTokenData } = useTokenData(destinationTokenChainId, destinationTokenAddress);
|
|
86
84
|
|
|
@@ -235,9 +233,8 @@ export function CryptoPayPanel({
|
|
|
235
233
|
/* ------------------------------------------------------------------ */
|
|
236
234
|
const [walletOrderId, setWalletOrderId] = useState<string | undefined>();
|
|
237
235
|
const [isSendingDeposit, setIsSendingDeposit] = useState(false);
|
|
238
|
-
const [depositRejected, setDepositRejected] = useState(false);
|
|
239
236
|
const depositSentRef = useRef(false);
|
|
240
|
-
const {
|
|
237
|
+
const { switchChainAndExecuteWithEOA } = useUnifiedChainSwitchAndExecute();
|
|
241
238
|
|
|
242
239
|
const { createOrder: createSwapOrder, isCreatingOrder: isCreatingSwapOrder } = useAnyspendCreateOrder({
|
|
243
240
|
onSuccess: data => {
|
|
@@ -254,7 +251,7 @@ export function CryptoPayPanel({
|
|
|
254
251
|
|
|
255
252
|
// Auto-send deposit tx once swap order is ready
|
|
256
253
|
useEffect(() => {
|
|
257
|
-
if (!walletOat?.data?.order || depositSentRef.current
|
|
254
|
+
if (!walletOat?.data?.order || depositSentRef.current) return;
|
|
258
255
|
const order = walletOat.data.order;
|
|
259
256
|
if (order.status !== "scanning_deposit_transaction") return;
|
|
260
257
|
if (walletOat.data.depositTxs?.length) return;
|
|
@@ -264,8 +261,9 @@ export function CryptoPayPanel({
|
|
|
264
261
|
try {
|
|
265
262
|
setIsSendingDeposit(true);
|
|
266
263
|
const amount = BigInt(order.srcAmount);
|
|
264
|
+
let txHash: string | undefined;
|
|
267
265
|
if (isNativeToken(order.srcTokenAddress)) {
|
|
268
|
-
await
|
|
266
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, {
|
|
269
267
|
to: order.globalAddress as `0x${string}`,
|
|
270
268
|
value: amount,
|
|
271
269
|
});
|
|
@@ -275,30 +273,33 @@ export function CryptoPayPanel({
|
|
|
275
273
|
functionName: "transfer",
|
|
276
274
|
args: [order.globalAddress as `0x${string}`, amount],
|
|
277
275
|
});
|
|
278
|
-
await
|
|
276
|
+
txHash = await switchChainAndExecuteWithEOA(order.srcChain, {
|
|
279
277
|
to: order.srcTokenAddress as `0x${string}`,
|
|
280
278
|
data,
|
|
281
279
|
value: BigInt(0),
|
|
282
280
|
});
|
|
283
281
|
}
|
|
282
|
+
if (!txHash) {
|
|
283
|
+
// User cancelled or tx failed — reset so they can retry
|
|
284
|
+
depositSentRef.current = false;
|
|
285
|
+
setWalletOrderId(undefined);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
284
288
|
// Deposit sent — notify parent to transition to order lifecycle tracking
|
|
285
289
|
if (walletOrderId) {
|
|
286
290
|
onOrderCreatedRef.current?.(walletOrderId);
|
|
287
291
|
}
|
|
288
292
|
} catch (error: any) {
|
|
289
293
|
depositSentRef.current = false;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (isUserRejection) {
|
|
293
|
-
setDepositRejected(true);
|
|
294
|
-
}
|
|
294
|
+
// Reset order so user can retry
|
|
295
|
+
setWalletOrderId(undefined);
|
|
295
296
|
onErrorRef.current?.(error instanceof Error ? error : new Error(error?.message || "Transaction rejected"));
|
|
296
297
|
} finally {
|
|
297
298
|
setIsSendingDeposit(false);
|
|
298
299
|
}
|
|
299
300
|
};
|
|
300
301
|
sendDeposit();
|
|
301
|
-
}, [walletOat,
|
|
302
|
+
}, [walletOat, switchChainAndExecuteWithEOA, walletOrderId]);
|
|
302
303
|
|
|
303
304
|
useOnOrderSuccess({
|
|
304
305
|
orderData: walletOat,
|
|
@@ -309,8 +310,9 @@ export function CryptoPayPanel({
|
|
|
309
310
|
const isWaitingForExecution = !!walletOrderId && walletOat?.data?.order.status !== "executed";
|
|
310
311
|
|
|
311
312
|
const handleWalletPay = useCallback(() => {
|
|
312
|
-
if (!selectedSrcToken || !
|
|
313
|
+
if (!selectedSrcToken || !connectedAddress) return;
|
|
313
314
|
depositSentRef.current = false;
|
|
315
|
+
setWalletOrderId(undefined);
|
|
314
316
|
createSwapOrder({
|
|
315
317
|
recipientAddress,
|
|
316
318
|
orderType: "swap",
|
|
@@ -325,7 +327,7 @@ export function CryptoPayPanel({
|
|
|
325
327
|
});
|
|
326
328
|
}, [
|
|
327
329
|
selectedSrcToken,
|
|
328
|
-
|
|
330
|
+
connectedAddress,
|
|
329
331
|
effectiveAddress,
|
|
330
332
|
recipientAddress,
|
|
331
333
|
selectedSrcChainId,
|
|
@@ -360,14 +362,30 @@ export function CryptoPayPanel({
|
|
|
360
362
|
}
|
|
361
363
|
};
|
|
362
364
|
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
365
|
+
const [shouldAutoPay, setShouldAutoPay] = useState(false);
|
|
366
|
+
|
|
367
|
+
const handleConnectWallet = async () => {
|
|
368
|
+
try {
|
|
369
|
+
const wallet = await openConnectModal(connectModalConfig);
|
|
370
|
+
if (wallet) {
|
|
371
|
+
setShouldAutoPay(true);
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error("Failed to connect wallet:", error);
|
|
375
|
+
}
|
|
366
376
|
};
|
|
367
377
|
|
|
378
|
+
// Auto-trigger payment after wallet connect
|
|
379
|
+
useEffect(() => {
|
|
380
|
+
if (shouldAutoPay && connectedAddress && selectedSrcToken && hasEnoughBalance && !isLoadingAnyspendQuote) {
|
|
381
|
+
setShouldAutoPay(false);
|
|
382
|
+
handleWalletPay();
|
|
383
|
+
}
|
|
384
|
+
}, [shouldAutoPay, connectedAddress, selectedSrcToken, hasEnoughBalance, isLoadingAnyspendQuote, handleWalletPay]);
|
|
385
|
+
|
|
368
386
|
const isLoading = isLoadingAnyspendQuote;
|
|
369
387
|
const isPending = isCreatingSwapOrder || isSendingDeposit || isWaitingForExecution;
|
|
370
|
-
const canPay =
|
|
388
|
+
const canPay = connectedAddress && selectedSrcToken && hasEnoughBalance && !isLoading && !isPending;
|
|
371
389
|
|
|
372
390
|
const chainName = ALL_CHAINS[selectedSrcChainId]?.name || "the specified chain";
|
|
373
391
|
const chainLogoUrl = ALL_CHAINS[selectedSrcChainId]?.logoUrl;
|
|
@@ -478,7 +496,7 @@ export function CryptoPayPanel({
|
|
|
478
496
|
|
|
479
497
|
{/* ---- Insufficient balance warning ---- */}
|
|
480
498
|
<AnimatePresence>
|
|
481
|
-
{
|
|
499
|
+
{connectedAddress && selectedSrcToken && !hasEnoughBalance && !isLoading && (
|
|
482
500
|
<motion.p
|
|
483
501
|
key="balance-warning"
|
|
484
502
|
initial={{ opacity: 0, height: 0 }}
|
|
@@ -493,7 +511,7 @@ export function CryptoPayPanel({
|
|
|
493
511
|
</AnimatePresence>
|
|
494
512
|
|
|
495
513
|
{/* ---- Wallet Pay Button ---- */}
|
|
496
|
-
{!
|
|
514
|
+
{!connectedAddress ? (
|
|
497
515
|
<ShinyButton
|
|
498
516
|
accentColor={themeColor || "hsl(var(--as-brand))"}
|
|
499
517
|
onClick={handleConnectWallet}
|
|
@@ -17,13 +17,21 @@ export enum CryptoPaymentMethodType {
|
|
|
17
17
|
TRANSFER_CRYPTO = "transfer_crypto",
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const recommendWallets = [
|
|
20
|
+
export const recommendWallets = [
|
|
21
21
|
createWallet("io.metamask"),
|
|
22
22
|
createWallet("com.coinbase.wallet"),
|
|
23
23
|
createWallet("me.rainbow"),
|
|
24
24
|
createWallet("io.rabby"),
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
+
export const connectModalConfig = {
|
|
28
|
+
client,
|
|
29
|
+
setActive: false as const,
|
|
30
|
+
size: "compact" as const,
|
|
31
|
+
showThirdwebBranding: false,
|
|
32
|
+
wallets: recommendWallets,
|
|
33
|
+
};
|
|
34
|
+
|
|
27
35
|
interface CryptoPaymentMethodProps {
|
|
28
36
|
selectedPaymentMethod: CryptoPaymentMethodType;
|
|
29
37
|
setSelectedPaymentMethod: (method: CryptoPaymentMethodType) => void;
|
|
@@ -65,13 +73,7 @@ export function CryptoPaymentMethod({
|
|
|
65
73
|
disconnect(connectedEOAWallet);
|
|
66
74
|
}
|
|
67
75
|
|
|
68
|
-
const wallet = await openConnectModal(
|
|
69
|
-
client,
|
|
70
|
-
setActive: false,
|
|
71
|
-
size: "compact",
|
|
72
|
-
showThirdwebBranding: false,
|
|
73
|
-
wallets: recommendWallets,
|
|
74
|
-
});
|
|
76
|
+
const wallet = await openConnectModal(connectModalConfig);
|
|
75
77
|
|
|
76
78
|
if (wallet) {
|
|
77
79
|
setSelectedPaymentMethod(CryptoPaymentMethodType.CONNECT_WALLET);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
11
11
|
import { Badge, CopyToClipboard, ShinyButton, TextLoop } from "@b3dotfun/sdk/global-account/react";
|
|
12
12
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
13
|
-
import {
|
|
13
|
+
import { b3Viem } from "@b3dotfun/sdk/shared/constants/chains/b3Viem";
|
|
14
14
|
|
|
15
15
|
import { toast } from "@b3dotfun/sdk/global-account/react";
|
|
16
16
|
import { formatUnits } from "@b3dotfun/sdk/shared/utils/number";
|
|
@@ -63,7 +63,7 @@ export function InsufficientDepositPayment({
|
|
|
63
63
|
<img
|
|
64
64
|
src={ALL_CHAINS[order.srcChain].logoUrl}
|
|
65
65
|
alt={getChainName(order.srcChain)}
|
|
66
|
-
className={cn("h-6 rounded-full", order.srcChain ===
|
|
66
|
+
className={cn("h-6 rounded-full", order.srcChain === b3Viem.id && "h-5 rounded-none")}
|
|
67
67
|
/>
|
|
68
68
|
</Badge>
|
|
69
69
|
</div>
|