@b3dotfun/sdk 0.0.65-alpha.0 → 0.0.65-test.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +77 -35
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +1 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +0 -6
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +5 -3
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderHistory.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +7 -3
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/global-account/react/components/AccountAssets/AccountAssets.js +38 -2
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +184 -35
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +23 -12
- package/dist/cjs/global-account/react/components/Deposit/Deposit.d.ts +1 -0
- package/dist/cjs/global-account/react/components/Deposit/Deposit.js +65 -0
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +39 -0
- package/dist/cjs/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +37 -0
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.d.ts +6 -4
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +113 -279
- package/dist/cjs/global-account/react/components/LinkAccount/LinkNewAccount.d.ts +4 -0
- package/dist/cjs/global-account/react/components/LinkAccount/LinkNewAccount.js +331 -0
- package/dist/cjs/global-account/react/components/ManageAccount/AppsContent.d.ts +6 -0
- package/dist/cjs/global-account/react/components/ManageAccount/AppsContent.js +34 -0
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +6 -5
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/BottomNavigation.js +23 -0
- package/dist/cjs/global-account/react/components/ManageAccount/Header.d.ts +3 -0
- package/dist/cjs/global-account/react/components/ManageAccount/Header.js +120 -0
- package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.d.ts +5 -0
- package/dist/cjs/global-account/react/components/ManageAccount/HomeActions.js +43 -0
- package/dist/cjs/global-account/react/components/ManageAccount/HomeContent.d.ts +6 -0
- package/dist/cjs/global-account/react/components/ManageAccount/HomeContent.js +16 -0
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +24 -193
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +15 -0
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +47 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.d.ts +7 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +50 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsMenuItem.d.ts +9 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsMenuItem.js +8 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +106 -0
- package/dist/cjs/global-account/react/components/ManageAccount/TokenContent.d.ts +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/TokenContent.js +22 -0
- package/dist/cjs/global-account/react/components/ModalHeader/ModalHeader.d.ts +10 -0
- package/dist/cjs/global-account/react/components/ModalHeader/ModalHeader.js +12 -0
- package/dist/cjs/global-account/react/components/Send/Send.d.ts +5 -0
- package/dist/cjs/global-account/react/components/Send/Send.js +187 -0
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +3 -1
- package/dist/cjs/global-account/react/components/icons/BellIcon.d.ts +3 -0
- package/dist/cjs/global-account/react/components/icons/BellIcon.js +5 -0
- package/dist/cjs/global-account/react/components/icons/ChevronDownIcon.d.ts +2 -0
- package/dist/cjs/global-account/react/components/icons/ChevronDownIcon.js +7 -0
- package/dist/cjs/global-account/react/components/icons/CopyIcon.d.ts +2 -0
- package/dist/cjs/global-account/react/components/icons/CopyIcon.js +7 -0
- package/dist/cjs/global-account/react/components/icons/LinkIcon.d.ts +3 -0
- package/dist/cjs/global-account/react/components/icons/LinkIcon.js +5 -0
- package/dist/cjs/global-account/react/components/icons/LockIcon.d.ts +3 -0
- package/dist/cjs/global-account/react/components/icons/LockIcon.js +5 -0
- package/dist/cjs/global-account/react/components/icons/WalletIcon.d.ts +2 -0
- package/dist/cjs/global-account/react/components/icons/WalletIcon.js +7 -0
- package/dist/cjs/global-account/react/components/index.d.ts +5 -4
- package/dist/cjs/global-account/react/components/index.js +14 -9
- package/dist/cjs/global-account/react/components/ui/Tabs.js +2 -2
- package/dist/cjs/global-account/react/components/ui/dialog.js +2 -2
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAccountWallet.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +18 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useB3BalanceFromAddresses.js +1 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +2 -2
- package/dist/cjs/global-account/react/stores/index.d.ts +1 -0
- package/dist/cjs/global-account/react/stores/index.js +3 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +31 -6
- package/dist/cjs/global-account/react/stores/useRecentAddressesStore.d.ts +25 -0
- package/dist/cjs/global-account/react/stores/useRecentAddressesStore.js +36 -0
- package/dist/cjs/global-account/react/utils/profileDisplay.d.ts +2 -0
- package/dist/cjs/global-account/react/utils/profileDisplay.js +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +3 -3
- package/dist/cjs/shared/utils/ipfs.js +10 -3
- package/dist/esm/anyspend/react/components/AnySpend.js +78 -36
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +2 -2
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +0 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +5 -3
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderHistory.d.ts +1 -1
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +6 -5
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +1 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +1 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +1 -1
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/global-account/react/components/AccountAssets/AccountAssets.js +38 -2
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +186 -37
- package/dist/esm/global-account/react/components/B3DynamicModal.js +23 -12
- package/dist/esm/global-account/react/components/Deposit/Deposit.d.ts +1 -0
- package/dist/esm/global-account/react/components/Deposit/Deposit.js +59 -0
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +39 -0
- package/dist/esm/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.js +34 -0
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.d.ts +6 -4
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +113 -280
- package/dist/esm/global-account/react/components/LinkAccount/LinkNewAccount.d.ts +4 -0
- package/dist/esm/global-account/react/components/LinkAccount/LinkNewAccount.js +325 -0
- package/dist/esm/global-account/react/components/ManageAccount/AppsContent.d.ts +6 -0
- package/dist/esm/global-account/react/components/ManageAccount/AppsContent.js +32 -0
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +6 -5
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.d.ts +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/BottomNavigation.js +21 -0
- package/dist/esm/global-account/react/components/ManageAccount/Header.d.ts +3 -0
- package/dist/esm/global-account/react/components/ManageAccount/Header.js +81 -0
- package/dist/esm/global-account/react/components/ManageAccount/HomeActions.d.ts +5 -0
- package/dist/esm/global-account/react/components/ManageAccount/HomeActions.js +41 -0
- package/dist/esm/global-account/react/components/ManageAccount/HomeContent.d.ts +6 -0
- package/dist/esm/global-account/react/components/ManageAccount/HomeContent.js +10 -0
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +26 -195
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.d.ts +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +13 -0
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.d.ts +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +45 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.d.ts +7 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +45 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsMenuItem.d.ts +9 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsMenuItem.js +6 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.d.ts +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +101 -0
- package/dist/esm/global-account/react/components/ManageAccount/TokenContent.d.ts +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/TokenContent.js +20 -0
- package/dist/esm/global-account/react/components/ModalHeader/ModalHeader.d.ts +10 -0
- package/dist/esm/global-account/react/components/ModalHeader/ModalHeader.js +10 -0
- package/dist/esm/global-account/react/components/Send/Send.d.ts +5 -0
- package/dist/esm/global-account/react/components/Send/Send.js +181 -0
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -2
- package/dist/esm/global-account/react/components/icons/BellIcon.d.ts +3 -0
- package/dist/esm/global-account/react/components/icons/BellIcon.js +3 -0
- package/dist/esm/global-account/react/components/icons/ChevronDownIcon.d.ts +2 -0
- package/dist/esm/global-account/react/components/icons/ChevronDownIcon.js +4 -0
- package/dist/esm/global-account/react/components/icons/CopyIcon.d.ts +2 -0
- package/dist/esm/global-account/react/components/icons/CopyIcon.js +4 -0
- package/dist/esm/global-account/react/components/icons/LinkIcon.d.ts +3 -0
- package/dist/esm/global-account/react/components/icons/LinkIcon.js +3 -0
- package/dist/esm/global-account/react/components/icons/LockIcon.d.ts +3 -0
- package/dist/esm/global-account/react/components/icons/LockIcon.js +3 -0
- package/dist/esm/global-account/react/components/icons/WalletIcon.d.ts +2 -0
- package/dist/esm/global-account/react/components/icons/WalletIcon.js +4 -0
- package/dist/esm/global-account/react/components/index.d.ts +5 -4
- package/dist/esm/global-account/react/components/index.js +9 -5
- package/dist/esm/global-account/react/components/ui/Tabs.js +2 -2
- package/dist/esm/global-account/react/components/ui/dialog.js +2 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/index.js +1 -1
- package/dist/esm/global-account/react/hooks/useAccountWallet.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +17 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useB3BalanceFromAddresses.js +1 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +2 -2
- package/dist/esm/global-account/react/stores/index.d.ts +1 -0
- package/dist/esm/global-account/react/stores/index.js +1 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +31 -6
- package/dist/esm/global-account/react/stores/useRecentAddressesStore.d.ts +25 -0
- package/dist/esm/global-account/react/stores/useRecentAddressesStore.js +33 -0
- package/dist/esm/global-account/react/utils/profileDisplay.d.ts +2 -0
- package/dist/esm/global-account/react/utils/profileDisplay.js +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +3 -3
- package/dist/esm/shared/utils/ipfs.js +10 -3
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +0 -6
- package/dist/types/anyspend/react/components/common/OrderHistory.d.ts +1 -1
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/global-account/react/components/Deposit/Deposit.d.ts +1 -0
- package/dist/types/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.d.ts +39 -0
- package/dist/types/global-account/react/components/LinkAccount/LinkAccount.d.ts +6 -4
- package/dist/types/global-account/react/components/LinkAccount/LinkNewAccount.d.ts +4 -0
- package/dist/types/global-account/react/components/ManageAccount/AppsContent.d.ts +6 -0
- package/dist/types/global-account/react/components/ManageAccount/BottomNavigation.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/Header.d.ts +3 -0
- package/dist/types/global-account/react/components/ManageAccount/HomeActions.d.ts +5 -0
- package/dist/types/global-account/react/components/ManageAccount/HomeContent.d.ts +6 -0
- package/dist/types/global-account/react/components/ManageAccount/NFTContent.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/ProfileSection.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/SettingsContent.d.ts +7 -0
- package/dist/types/global-account/react/components/ManageAccount/SettingsMenuItem.d.ts +9 -0
- package/dist/types/global-account/react/components/ManageAccount/SettingsProfileCard.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/TokenContent.d.ts +2 -0
- package/dist/types/global-account/react/components/ModalHeader/ModalHeader.d.ts +10 -0
- package/dist/types/global-account/react/components/Send/Send.d.ts +5 -0
- package/dist/types/global-account/react/components/icons/BellIcon.d.ts +3 -0
- package/dist/types/global-account/react/components/icons/ChevronDownIcon.d.ts +2 -0
- package/dist/types/global-account/react/components/icons/CopyIcon.d.ts +2 -0
- package/dist/types/global-account/react/components/icons/LinkIcon.d.ts +3 -0
- package/dist/types/global-account/react/components/icons/LockIcon.d.ts +3 -0
- package/dist/types/global-account/react/components/icons/WalletIcon.d.ts +2 -0
- package/dist/types/global-account/react/components/index.d.ts +5 -4
- package/dist/types/global-account/react/hooks/index.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAccountWallet.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +2 -2
- package/dist/types/global-account/react/stores/index.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +31 -6
- package/dist/types/global-account/react/stores/useRecentAddressesStore.d.ts +25 -0
- package/dist/types/global-account/react/utils/profileDisplay.d.ts +2 -0
- package/dist/types/shared/constants/chains/supported.d.ts +3 -3
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +229 -170
- package/src/anyspend/react/components/AnySpendCustom.tsx +1 -3
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +0 -2
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +0 -2
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +7 -14
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +2 -2
- package/src/anyspend/react/components/common/OrderHistory.tsx +8 -13
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +1 -1
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +1 -1
- package/src/anyspend/react/components/common/RecipientSelection.tsx +1 -1
- package/src/global-account/react/components/AccountAssets/AccountAssets.tsx +115 -25
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +360 -128
- package/src/global-account/react/components/B3DynamicModal.tsx +28 -14
- package/src/global-account/react/components/Deposit/Deposit.tsx +211 -0
- package/src/global-account/react/components/IPFSMediaRenderer/IPFSMediaRenderer.tsx +84 -0
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +332 -433
- package/src/global-account/react/components/LinkAccount/LinkNewAccount.tsx +490 -0
- package/src/global-account/react/components/ManageAccount/AppsContent.tsx +79 -0
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +6 -10
- package/src/global-account/react/components/ManageAccount/BottomNavigation.tsx +83 -0
- package/src/global-account/react/components/ManageAccount/Header.tsx +230 -0
- package/src/global-account/react/components/ManageAccount/HomeActions.tsx +118 -0
- package/src/global-account/react/components/ManageAccount/HomeContent.tsx +42 -0
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +73 -589
- package/src/global-account/react/components/ManageAccount/NFTContent.tsx +24 -0
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +72 -0
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +87 -0
- package/src/global-account/react/components/ManageAccount/SettingsMenuItem.tsx +31 -0
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +180 -0
- package/src/global-account/react/components/ManageAccount/TokenContent.tsx +41 -0
- package/src/global-account/react/components/ModalHeader/ModalHeader.tsx +50 -0
- package/src/global-account/react/components/Send/Send.tsx +585 -0
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +11 -7
- package/src/global-account/react/components/icons/BellIcon.tsx +15 -0
- package/src/global-account/react/components/icons/ChevronDownIcon.tsx +17 -0
- package/src/global-account/react/components/icons/CopyIcon.tsx +22 -0
- package/src/global-account/react/components/icons/LinkIcon.tsx +15 -0
- package/src/global-account/react/components/icons/LockIcon.tsx +15 -0
- package/src/global-account/react/components/icons/WalletIcon.tsx +21 -0
- package/src/global-account/react/components/index.ts +11 -5
- package/src/global-account/react/components/ui/Tabs.tsx +5 -13
- package/src/global-account/react/components/ui/dialog.tsx +32 -14
- package/src/global-account/react/hooks/index.ts +3 -0
- package/src/global-account/react/hooks/useAccountWallet.tsx +26 -0
- package/src/global-account/react/hooks/useB3BalanceFromAddresses.ts +1 -0
- package/src/global-account/react/stores/index.ts +1 -0
- package/src/global-account/react/stores/useModalStore.ts +35 -6
- package/src/global-account/react/stores/useRecentAddressesStore.ts +55 -0
- package/src/global-account/react/utils/profileDisplay.ts +4 -2
- package/src/shared/utils/ipfs.ts +10 -3
- package/src/styles/index.css +6 -1
- package/dist/cjs/global-account/react/components/ProfileEditor/ProfileEditor.d.ts +0 -6
- package/dist/cjs/global-account/react/components/ProfileEditor/ProfileEditor.js +0 -141
- package/dist/esm/global-account/react/components/ProfileEditor/ProfileEditor.d.ts +0 -6
- package/dist/esm/global-account/react/components/ProfileEditor/ProfileEditor.js +0 -135
- package/dist/types/global-account/react/components/ProfileEditor/ProfileEditor.d.ts +0 -6
- package/src/global-account/react/components/ProfileEditor/ProfileEditor.tsx +0 -265
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
|
+
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
3
|
+
import { thirdwebB3Mainnet } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
4
|
+
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
5
|
+
import { Loader2, Mail, Phone, WalletIcon } from "lucide-react";
|
|
6
|
+
import { useCallback, useEffect, useState } from "react";
|
|
7
|
+
import { toast } from "sonner";
|
|
8
|
+
import { useLinkProfile, useProfiles } from "thirdweb/react";
|
|
9
|
+
import { createWallet, preAuthenticate, WalletId } from "thirdweb/wallets";
|
|
10
|
+
import { WalletRow } from "../..";
|
|
11
|
+
import { LinkNewAccountModalProps, useModalStore } from "../../stores/useModalStore";
|
|
12
|
+
import { getProfileDisplayInfo } from "../../utils/profileDisplay";
|
|
13
|
+
import { useB3 } from "../B3Provider/useB3";
|
|
14
|
+
import { AppleIcon } from "../icons/AppleIcon";
|
|
15
|
+
import { DiscordIcon } from "../icons/DiscordIcon";
|
|
16
|
+
import { FarcasterIcon } from "../icons/FarcasterIcon";
|
|
17
|
+
import { GoogleIcon } from "../icons/GoogleIcon";
|
|
18
|
+
import { XIcon } from "../icons/XIcon";
|
|
19
|
+
import ModalHeader from "../ModalHeader/ModalHeader";
|
|
20
|
+
import { Button } from "../ui/button";
|
|
21
|
+
type OTPStrategy = "email" | "phone";
|
|
22
|
+
type SocialStrategy = "google" | "x" | "discord" | "apple" | "farcaster";
|
|
23
|
+
type Strategy = OTPStrategy | SocialStrategy | "wallet";
|
|
24
|
+
|
|
25
|
+
interface AuthMethod {
|
|
26
|
+
id: Strategy;
|
|
27
|
+
label: string;
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
icon: React.ReactNode;
|
|
30
|
+
walletType?: WalletId;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const AUTH_METHODS: AuthMethod[] = [
|
|
34
|
+
{ id: "email", label: "Email", enabled: true, icon: <Mail className="text-b3-primary-blue size-6" /> },
|
|
35
|
+
{ id: "phone", label: "Phone", enabled: true, icon: <Phone className="text-b3-primary-blue size-6" /> },
|
|
36
|
+
{ id: "google", label: "Google", enabled: true, icon: <GoogleIcon className="size-6" /> },
|
|
37
|
+
{ id: "x", label: "X (Twitter)", enabled: true, icon: <XIcon className="size-6" /> },
|
|
38
|
+
{ id: "discord", label: "Discord", enabled: true, icon: <DiscordIcon className="size-6" /> },
|
|
39
|
+
{ id: "apple", label: "Apple", enabled: true, icon: <AppleIcon className="size-6" /> },
|
|
40
|
+
{
|
|
41
|
+
id: "farcaster",
|
|
42
|
+
label: "Farcaster",
|
|
43
|
+
enabled: true,
|
|
44
|
+
icon: <FarcasterIcon className="size-6" />,
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const WALLET_METHODS: AuthMethod[] = [
|
|
49
|
+
{
|
|
50
|
+
id: "wallet",
|
|
51
|
+
label: "Wallet",
|
|
52
|
+
enabled: true,
|
|
53
|
+
icon: <WalletIcon className="size-6" />,
|
|
54
|
+
walletType: "com.coinbase.wallet",
|
|
55
|
+
},
|
|
56
|
+
{ id: "wallet", label: "Wallet", enabled: true, icon: <WalletIcon className="size-6" />, walletType: "io.metamask" },
|
|
57
|
+
{
|
|
58
|
+
id: "wallet",
|
|
59
|
+
label: "Wallet",
|
|
60
|
+
enabled: true,
|
|
61
|
+
icon: <WalletIcon className="size-6" />,
|
|
62
|
+
walletType: "me.rainbow",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "wallet",
|
|
66
|
+
label: "Wallet",
|
|
67
|
+
enabled: true,
|
|
68
|
+
icon: <WalletIcon className="size-6" />,
|
|
69
|
+
walletType: "app.phantom",
|
|
70
|
+
},
|
|
71
|
+
{ id: "wallet", label: "Wallet", enabled: true, icon: <WalletIcon className="size-6" />, walletType: "io.rabby" },
|
|
72
|
+
{
|
|
73
|
+
id: "wallet",
|
|
74
|
+
label: "Wallet",
|
|
75
|
+
enabled: true,
|
|
76
|
+
icon: <WalletIcon className="size-6" />,
|
|
77
|
+
walletType: "walletConnect",
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
export function LinkNewAccount({
|
|
82
|
+
onSuccess: onSuccessCallback,
|
|
83
|
+
onError,
|
|
84
|
+
onClose,
|
|
85
|
+
chain,
|
|
86
|
+
partnerId,
|
|
87
|
+
className,
|
|
88
|
+
}: LinkNewAccountModalProps & { className?: string }) {
|
|
89
|
+
const isLinking = useModalStore(state => state.isLinking);
|
|
90
|
+
const linkingMethod = useModalStore(state => state.linkingMethod);
|
|
91
|
+
const setLinkingState = useModalStore(state => state.setLinkingState);
|
|
92
|
+
const navigateBack = useModalStore(state => state.navigateBack);
|
|
93
|
+
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
94
|
+
const [selectedMethod, setSelectedMethod] = useState<Strategy | null>(null);
|
|
95
|
+
const [email, setEmail] = useState("");
|
|
96
|
+
const [phone, setPhone] = useState("");
|
|
97
|
+
const [otp, setOtp] = useState("");
|
|
98
|
+
const [otpSent, setOtpSent] = useState(false);
|
|
99
|
+
const [error, setError] = useState<string | null>(null);
|
|
100
|
+
const { data: profilesRaw = [] } = useProfiles({ client });
|
|
101
|
+
|
|
102
|
+
// Get connected auth methods
|
|
103
|
+
const connectedAuthMethods = profilesRaw
|
|
104
|
+
.filter((profile: any) => !["custom_auth_endpoint"].includes(profile.type))
|
|
105
|
+
.map((profile: any) => profile.type as Strategy);
|
|
106
|
+
|
|
107
|
+
// Filter available auth methods
|
|
108
|
+
const availableAuthMethods = AUTH_METHODS.filter(
|
|
109
|
+
method => !connectedAuthMethods.includes(method.id) && method.enabled,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const profiles = profilesRaw
|
|
113
|
+
.filter((profile: any) => !["custom_auth_endpoint"].includes(profile.type))
|
|
114
|
+
.map((profile: any) => ({
|
|
115
|
+
...getProfileDisplayInfo(profile),
|
|
116
|
+
originalProfile: profile,
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
const { account } = useB3();
|
|
120
|
+
const { mutate: linkProfile } = useLinkProfile();
|
|
121
|
+
|
|
122
|
+
const onSuccess = useCallback(async () => {
|
|
123
|
+
await onSuccessCallback?.();
|
|
124
|
+
}, [onSuccessCallback]);
|
|
125
|
+
|
|
126
|
+
// Reset linking state when component unmounts
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
return () => {
|
|
129
|
+
if (isLinking) {
|
|
130
|
+
setLinkingState(false);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}, [isLinking, setLinkingState]);
|
|
134
|
+
|
|
135
|
+
const mutationOptions = {
|
|
136
|
+
onError: (error: Error) => {
|
|
137
|
+
console.error("Error linking account:", error);
|
|
138
|
+
toast.error(error.message);
|
|
139
|
+
setLinkingState(false);
|
|
140
|
+
onError?.(error);
|
|
141
|
+
},
|
|
142
|
+
onSuccess: async (data: any) => {
|
|
143
|
+
console.log("Raw Link Account Data:", data);
|
|
144
|
+
try {
|
|
145
|
+
console.log("Sync user data...");
|
|
146
|
+
await app.service("users").syncTwProfiles({});
|
|
147
|
+
} catch (refreshError) {
|
|
148
|
+
console.warn("⚠️ Could not sync user data:", refreshError);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const validateInput = () => {
|
|
154
|
+
if (selectedMethod === "email") {
|
|
155
|
+
if (!email) {
|
|
156
|
+
setError("Please enter your email address");
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
|
160
|
+
setError("Please enter a valid email address");
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
} else if (selectedMethod === "phone") {
|
|
164
|
+
if (!phone) {
|
|
165
|
+
setError("Please enter your phone number");
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
if (!/^\+?[\d\s-]{10,}$/.test(phone)) {
|
|
169
|
+
setError("Please enter a valid phone number");
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
setError(null);
|
|
174
|
+
return true;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const handleSendOTP = async () => {
|
|
178
|
+
if (!validateInput()) return;
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
setLinkingState(true, selectedMethod);
|
|
182
|
+
setError(null);
|
|
183
|
+
|
|
184
|
+
if (selectedMethod === "email") {
|
|
185
|
+
await preAuthenticate({
|
|
186
|
+
client,
|
|
187
|
+
strategy: "email",
|
|
188
|
+
email,
|
|
189
|
+
ecosystem: {
|
|
190
|
+
id: ecosystemWalletId,
|
|
191
|
+
partnerId: partnerId,
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
} else if (selectedMethod === "phone") {
|
|
195
|
+
await preAuthenticate({
|
|
196
|
+
client,
|
|
197
|
+
strategy: "phone",
|
|
198
|
+
phoneNumber: phone,
|
|
199
|
+
ecosystem: {
|
|
200
|
+
id: ecosystemWalletId,
|
|
201
|
+
partnerId: partnerId,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setOtpSent(true);
|
|
207
|
+
} catch (error) {
|
|
208
|
+
console.error("Error sending OTP:", error);
|
|
209
|
+
setError(error instanceof Error ? error.message : "Failed to send OTP");
|
|
210
|
+
onError?.(error as Error);
|
|
211
|
+
setLinkingState(false);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const handleLinkAccount = async () => {
|
|
216
|
+
if (!otp) {
|
|
217
|
+
console.error("No OTP entered");
|
|
218
|
+
setError("Please enter the verification code");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
setOtpSent(false);
|
|
224
|
+
setLinkingState(true, selectedMethod);
|
|
225
|
+
setError(null);
|
|
226
|
+
|
|
227
|
+
if (selectedMethod === "email") {
|
|
228
|
+
await linkProfile(
|
|
229
|
+
{
|
|
230
|
+
client,
|
|
231
|
+
strategy: "email",
|
|
232
|
+
email,
|
|
233
|
+
verificationCode: otp,
|
|
234
|
+
},
|
|
235
|
+
mutationOptions,
|
|
236
|
+
);
|
|
237
|
+
} else if (selectedMethod === "phone") {
|
|
238
|
+
await linkProfile(
|
|
239
|
+
{
|
|
240
|
+
client,
|
|
241
|
+
strategy: "phone",
|
|
242
|
+
phoneNumber: phone,
|
|
243
|
+
verificationCode: otp,
|
|
244
|
+
},
|
|
245
|
+
mutationOptions,
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.error("Error linking account:", error);
|
|
250
|
+
setError(error instanceof Error ? error.message : "Failed to link account");
|
|
251
|
+
onError?.(error as Error);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const handleLinkWallet = async (walletType: WalletId) => {
|
|
256
|
+
setLinkingState(true, "wallet");
|
|
257
|
+
console.log("selectedMethod", walletType);
|
|
258
|
+
try {
|
|
259
|
+
if (!walletType) {
|
|
260
|
+
throw new Error("Wallet type not found");
|
|
261
|
+
}
|
|
262
|
+
await linkProfile(
|
|
263
|
+
{
|
|
264
|
+
client,
|
|
265
|
+
strategy: "wallet",
|
|
266
|
+
wallet: createWallet(walletType),
|
|
267
|
+
chain: thirdwebB3Mainnet,
|
|
268
|
+
},
|
|
269
|
+
mutationOptions,
|
|
270
|
+
);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.error("Error linking account:", error);
|
|
273
|
+
setError(error instanceof Error ? error.message : "Failed to link account");
|
|
274
|
+
onError?.(error as Error);
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const handleSocialLink = async (strategy: SocialStrategy) => {
|
|
279
|
+
try {
|
|
280
|
+
console.log("handleSocialLink", strategy);
|
|
281
|
+
setLinkingState(true, strategy);
|
|
282
|
+
setError(null);
|
|
283
|
+
|
|
284
|
+
const result = await linkProfile(
|
|
285
|
+
{
|
|
286
|
+
client,
|
|
287
|
+
strategy,
|
|
288
|
+
},
|
|
289
|
+
mutationOptions,
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
console.log("result", result);
|
|
293
|
+
|
|
294
|
+
// Don't close the modal yet, wait for auth to complete
|
|
295
|
+
onSuccess?.();
|
|
296
|
+
} catch (error) {
|
|
297
|
+
console.error("Error linking with social:", error);
|
|
298
|
+
setError(error instanceof Error ? error.message : "Failed to link social account");
|
|
299
|
+
onError?.(error as Error);
|
|
300
|
+
setLinkingState(false);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// Add effect to handle social auth completion
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
if (isLinking && linkingMethod && !selectedMethod) {
|
|
307
|
+
// This means we're in a social auth flow
|
|
308
|
+
const checkAuthStatus = async () => {
|
|
309
|
+
try {
|
|
310
|
+
// Wait a bit to ensure auth is complete
|
|
311
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
312
|
+
onClose?.();
|
|
313
|
+
} catch (error) {
|
|
314
|
+
console.error("Error checking auth status:", error);
|
|
315
|
+
setLinkingState(false);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
checkAuthStatus();
|
|
320
|
+
}
|
|
321
|
+
}, [isLinking, linkingMethod, selectedMethod, onClose, setLinkingState]);
|
|
322
|
+
|
|
323
|
+
const handleBack = useCallback(() => {
|
|
324
|
+
if (isLinking) return;
|
|
325
|
+
setSelectedMethod(null);
|
|
326
|
+
setEmail("");
|
|
327
|
+
setPhone("");
|
|
328
|
+
setOtp("");
|
|
329
|
+
setOtpSent(false);
|
|
330
|
+
setError(null);
|
|
331
|
+
setLinkingState(false);
|
|
332
|
+
}, [isLinking, setSelectedMethod, setEmail, setPhone, setOtp, setOtpSent, setError, setLinkingState]);
|
|
333
|
+
|
|
334
|
+
const handleFinishedLinking = useCallback(
|
|
335
|
+
(success: boolean) => {
|
|
336
|
+
if (success) {
|
|
337
|
+
onSuccess?.();
|
|
338
|
+
onClose?.();
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
setLinkingState(false);
|
|
342
|
+
navigateBack();
|
|
343
|
+
setB3ModalContentType({
|
|
344
|
+
type: "manageAccount",
|
|
345
|
+
activeTab: "settings",
|
|
346
|
+
setActiveTab: () => {},
|
|
347
|
+
chain,
|
|
348
|
+
partnerId,
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
[chain, navigateBack, partnerId, setB3ModalContentType, setLinkingState, onSuccess, onClose],
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
useEffect(() => {
|
|
355
|
+
if (isLinking) {
|
|
356
|
+
handleFinishedLinking(true);
|
|
357
|
+
}
|
|
358
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
359
|
+
}, [profiles.length]);
|
|
360
|
+
|
|
361
|
+
if (!account) {
|
|
362
|
+
return <div className="text-b3-foreground-muted py-8 text-center">Please connect your account first</div>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<div className={`b3-link-account space-y-6 ${className || ""}`} data-testid="link-account">
|
|
367
|
+
<ModalHeader title="Link New Account" />
|
|
368
|
+
|
|
369
|
+
{!selectedMethod ? (
|
|
370
|
+
<div className="b3-link-account-methods grid gap-3 px-5">
|
|
371
|
+
{availableAuthMethods.map(method => (
|
|
372
|
+
<Button
|
|
373
|
+
key={method.id}
|
|
374
|
+
variant="outline"
|
|
375
|
+
className="b3-link-account-method-button border-b3-line hover:border-b3-primary-blue/30 hover:bg-b3-primary-blue/5 text-b3-grey font-neue-montreal-medium h-14 justify-start bg-transparent px-6 text-base transition-all duration-200"
|
|
376
|
+
data-method={method.id}
|
|
377
|
+
onClick={() => {
|
|
378
|
+
if (method.id === "email" || method.id === "phone") {
|
|
379
|
+
setSelectedMethod(method.id);
|
|
380
|
+
} else {
|
|
381
|
+
handleSocialLink(method.id as SocialStrategy);
|
|
382
|
+
}
|
|
383
|
+
}}
|
|
384
|
+
disabled={linkingMethod === method.id}
|
|
385
|
+
>
|
|
386
|
+
{isLinking && linkingMethod === method.id ? (
|
|
387
|
+
<Loader2 className="h-5 w-5 animate-spin" />
|
|
388
|
+
) : (
|
|
389
|
+
<div className="b3-link-account-method-content flex items-center gap-4">
|
|
390
|
+
<div className="b3-link-account-method-icon flex items-center justify-center rounded-full">
|
|
391
|
+
{method.icon}
|
|
392
|
+
</div>
|
|
393
|
+
<span className="b3-link-account-method-label font-medium">{method.label}</span>
|
|
394
|
+
</div>
|
|
395
|
+
)}
|
|
396
|
+
</Button>
|
|
397
|
+
))}
|
|
398
|
+
{WALLET_METHODS.map(method => {
|
|
399
|
+
if (!method.walletType) {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return (
|
|
404
|
+
<WalletRow
|
|
405
|
+
key={method.walletType}
|
|
406
|
+
walletId={method.walletType as WalletId}
|
|
407
|
+
onClick={() => handleLinkWallet(method.walletType as WalletId)}
|
|
408
|
+
isLoading={isLinking}
|
|
409
|
+
/>
|
|
410
|
+
);
|
|
411
|
+
})}
|
|
412
|
+
{availableAuthMethods.length === 0 && (
|
|
413
|
+
<div className="text-b3-foreground-muted py-8 text-center">
|
|
414
|
+
All available authentication methods have been connected
|
|
415
|
+
</div>
|
|
416
|
+
)}
|
|
417
|
+
</div>
|
|
418
|
+
) : (
|
|
419
|
+
<div className="b3-link-account-form space-y-4 px-5">
|
|
420
|
+
{selectedMethod === "email" && (
|
|
421
|
+
<div className="space-y-2">
|
|
422
|
+
<label className="text-b3-grey font-neue-montreal-medium text-sm">Email Address</label>
|
|
423
|
+
<input
|
|
424
|
+
type="email"
|
|
425
|
+
placeholder="Enter your email"
|
|
426
|
+
className="bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2"
|
|
427
|
+
value={email}
|
|
428
|
+
onChange={e => setEmail(e.target.value)}
|
|
429
|
+
disabled={otpSent || (isLinking && linkingMethod === "email")}
|
|
430
|
+
/>
|
|
431
|
+
</div>
|
|
432
|
+
)}
|
|
433
|
+
|
|
434
|
+
{selectedMethod === "phone" && (
|
|
435
|
+
<div className="space-y-2">
|
|
436
|
+
<label className="text-b3-grey font-neue-montreal-medium text-sm">Phone Number</label>
|
|
437
|
+
<input
|
|
438
|
+
type="tel"
|
|
439
|
+
placeholder="Enter your phone number"
|
|
440
|
+
className="bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2"
|
|
441
|
+
value={phone}
|
|
442
|
+
onChange={e => setPhone(e.target.value)}
|
|
443
|
+
disabled={otpSent || (isLinking && linkingMethod === "phone")}
|
|
444
|
+
/>
|
|
445
|
+
<p className="text-b3-foreground-muted font-neue-montreal-medium text-sm">
|
|
446
|
+
Include country code (e.g., +1 for US)
|
|
447
|
+
</p>
|
|
448
|
+
</div>
|
|
449
|
+
)}
|
|
450
|
+
|
|
451
|
+
{error && <div className="text-b3-negative font-neue-montreal-medium py-2 text-sm">{error}</div>}
|
|
452
|
+
|
|
453
|
+
{(selectedMethod === "email" || selectedMethod === "phone") &&
|
|
454
|
+
(otpSent ? (
|
|
455
|
+
<div className="space-y-4">
|
|
456
|
+
<div className="space-y-2">
|
|
457
|
+
<label className="text-b3-grey font-neue-montreal-medium text-sm">Verification Code</label>
|
|
458
|
+
<input
|
|
459
|
+
type="text"
|
|
460
|
+
placeholder="Enter verification code"
|
|
461
|
+
className="bg-b3-line text-b3-grey font-neue-montreal-medium focus:ring-b3-primary-blue/20 w-full rounded-xl p-4 focus:outline-none focus:ring-2"
|
|
462
|
+
value={otp}
|
|
463
|
+
onChange={e => setOtp(e.target.value)}
|
|
464
|
+
/>
|
|
465
|
+
</div>
|
|
466
|
+
<Button
|
|
467
|
+
className="bg-b3-primary-blue hover:bg-b3-primary-blue/90 font-neue-montreal-semibold h-12 w-full text-white"
|
|
468
|
+
onClick={handleLinkAccount}
|
|
469
|
+
>
|
|
470
|
+
Link Account
|
|
471
|
+
</Button>
|
|
472
|
+
</div>
|
|
473
|
+
) : (
|
|
474
|
+
<Button
|
|
475
|
+
className="bg-b3-primary-blue hover:bg-b3-primary-blue/90 font-neue-montreal-semibold h-12 w-full text-white"
|
|
476
|
+
onClick={handleSendOTP}
|
|
477
|
+
disabled={(!email && !phone) || (isLinking && linkingMethod === selectedMethod)}
|
|
478
|
+
>
|
|
479
|
+
{isLinking && linkingMethod === selectedMethod ? (
|
|
480
|
+
<Loader2 className="animate-spin" />
|
|
481
|
+
) : (
|
|
482
|
+
"Send Verification Code"
|
|
483
|
+
)}
|
|
484
|
+
</Button>
|
|
485
|
+
))}
|
|
486
|
+
</div>
|
|
487
|
+
)}
|
|
488
|
+
</div>
|
|
489
|
+
);
|
|
490
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
TWSignerWithMetadata,
|
|
4
|
+
useGetAllTWSigners,
|
|
5
|
+
useRemoveSessionKey,
|
|
6
|
+
} from "@b3dotfun/sdk/global-account/react";
|
|
7
|
+
import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
|
|
8
|
+
import { useState } from "react";
|
|
9
|
+
import { Chain } from "thirdweb";
|
|
10
|
+
import { useActiveAccount } from "thirdweb/react";
|
|
11
|
+
import { formatUnits } from "viem";
|
|
12
|
+
|
|
13
|
+
const AppsContent = ({ chain, partnerId }: { chain: Chain; partnerId: string }) => {
|
|
14
|
+
const [revokingSignerId, setRevokingSignerId] = useState<string | null>(null);
|
|
15
|
+
const account = useActiveAccount();
|
|
16
|
+
|
|
17
|
+
const { data: signers, refetch: refetchSigners } = useGetAllTWSigners({
|
|
18
|
+
chain,
|
|
19
|
+
accountAddress: account?.address,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const { removeSessionKey } = useRemoveSessionKey({
|
|
23
|
+
chain,
|
|
24
|
+
onSuccess: tx => {
|
|
25
|
+
console.log("@@removeSessionKey:tx", tx);
|
|
26
|
+
setRevokingSignerId(null);
|
|
27
|
+
},
|
|
28
|
+
onError: error => {
|
|
29
|
+
console.error("Error revoking access:", error);
|
|
30
|
+
setRevokingSignerId(null);
|
|
31
|
+
},
|
|
32
|
+
refetchSigners: () => refetchSigners(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const handleRevoke = async (signer: TWSignerWithMetadata) => {
|
|
36
|
+
setRevokingSignerId(signer.id);
|
|
37
|
+
await removeSessionKey(signer);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="space-y-4">
|
|
42
|
+
{signers?.map((signer: TWSignerWithMetadata) => (
|
|
43
|
+
<div key={signer.id} className="rounded-xl border border-gray-200 p-4 dark:border-gray-800">
|
|
44
|
+
<div className="flex items-start justify-between">
|
|
45
|
+
<div className="flex items-start gap-4">
|
|
46
|
+
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-gray-100 dark:bg-gray-800">
|
|
47
|
+
<span className="text-xs font-medium text-gray-600 dark:text-gray-400">App</span>
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<h3 className="font-medium text-gray-900 dark:text-white">{signer.partner.name}</h3>
|
|
51
|
+
<div className="mt-2 space-y-1">
|
|
52
|
+
<p className="text-xs text-gray-500">Added {new Date(signer.createdAt).toLocaleDateString()}</p>
|
|
53
|
+
<p className="text-xs text-gray-500">
|
|
54
|
+
Expires {new Date(Number(signer.endTimestamp) * 1000).toLocaleDateString()}
|
|
55
|
+
</p>
|
|
56
|
+
<p className="text-xs text-gray-500">
|
|
57
|
+
Max spend: {formatNumber(Number(formatUnits(signer.nativeTokenLimitPerTransaction, 18)))} ETH
|
|
58
|
+
</p>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
<Button
|
|
63
|
+
variant="outline"
|
|
64
|
+
size="sm"
|
|
65
|
+
className="border-red-200 text-red-500 hover:border-red-300 hover:text-red-600"
|
|
66
|
+
onClick={() => handleRevoke(signer)}
|
|
67
|
+
disabled={revokingSignerId === signer.id}
|
|
68
|
+
>
|
|
69
|
+
{revokingSignerId === signer.id ? "Revoking..." : "Revoke"}
|
|
70
|
+
</Button>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
))}
|
|
74
|
+
|
|
75
|
+
{!signers?.length && <div className="py-12 text-center text-gray-500">No connected apps</div>}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
export default AppsContent;
|
|
@@ -13,11 +13,11 @@ import { BankIcon } from "@b3dotfun/sdk/global-account/react/components/icons/Ba
|
|
|
13
13
|
import { SignOutIcon } from "@b3dotfun/sdk/global-account/react/components/icons/SignOutIcon";
|
|
14
14
|
import { SwapIcon } from "@b3dotfun/sdk/global-account/react/components/icons/SwapIcon";
|
|
15
15
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
16
|
-
import { getIpfsUrl } from "@b3dotfun/sdk/shared/utils/ipfs";
|
|
17
16
|
import { Loader2, Pencil } from "lucide-react";
|
|
18
17
|
import { useEffect, useRef, useState } from "react";
|
|
19
18
|
import { useActiveAccount } from "thirdweb/react";
|
|
20
19
|
import { useFirstEOA } from "../../hooks/useFirstEOA";
|
|
20
|
+
import { IPFSMediaRenderer } from "../IPFSMediaRenderer/IPFSMediaRenderer";
|
|
21
21
|
import { B3TokenIcon, EthereumTokenIcon } from "../TokenIcon";
|
|
22
22
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion";
|
|
23
23
|
import { TokenBalanceRow } from "./TokenBalanceRow";
|
|
@@ -32,7 +32,7 @@ function centerTruncate(str: string, length = 4) {
|
|
|
32
32
|
if (str.length <= length * 2) return str;
|
|
33
33
|
return `${str.slice(0, length)}...${str.slice(-length)}`;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
// Deprecated
|
|
36
36
|
export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }: BalanceContentProps) {
|
|
37
37
|
const account = useActiveAccount();
|
|
38
38
|
const globalAccount = useGlobalAccount();
|
|
@@ -48,13 +48,13 @@ export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }
|
|
|
48
48
|
const [openAccordions, setOpenAccordions] = useState<string[]>([]);
|
|
49
49
|
const hasExpandedRef = useRef(false);
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
// IPFSMediaRenderer will handle IPFS URL conversion and validation
|
|
52
|
+
const avatarSrc = user?.avatar || profile?.avatar;
|
|
52
53
|
|
|
53
54
|
const handleEditProfile = () => {
|
|
54
55
|
setB3ModalOpen(true);
|
|
55
56
|
setB3ModalContentType({
|
|
56
|
-
type: "
|
|
57
|
-
showBackButton: true,
|
|
57
|
+
type: "avatarEditor",
|
|
58
58
|
onSuccess: () => {
|
|
59
59
|
// navigate back on success
|
|
60
60
|
navigateBack();
|
|
@@ -119,11 +119,7 @@ export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }
|
|
|
119
119
|
<div className="flex items-center justify-between">
|
|
120
120
|
<div className="global-account-profile flex items-center gap-4">
|
|
121
121
|
<div className="global-account-profile-avatar relative">
|
|
122
|
-
{
|
|
123
|
-
<img src={avatarUrl} alt="Profile" className="size-24 rounded-full" />
|
|
124
|
-
) : (
|
|
125
|
-
<div className="bg-b3-primary-wash size-24 rounded-full" />
|
|
126
|
-
)}
|
|
122
|
+
<IPFSMediaRenderer src={avatarSrc} alt="Profile" className="size-24 rounded-full" />
|
|
127
123
|
<button
|
|
128
124
|
onClick={handleEditProfile}
|
|
129
125
|
className="bg-b3-grey border-b3-background hover:bg-b3-grey/80 absolute -bottom-1 -right-1 flex size-8 items-center justify-center rounded-full border-4 transition-colors"
|