@b3dotfun/sdk 0.0.83-test.0 → 0.0.84-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/constants/index.d.ts +1 -1
- package/dist/cjs/anyspend/constants/index.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpend.js +21 -12
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -6
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +2 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +47 -177
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +28 -0
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +5 -4
- package/dist/cjs/anyspend/react/components/common/OrderToken.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmountFiat.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmountNew.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +4 -6
- package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.js +41 -2
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +0 -3
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +5 -8
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
- package/dist/cjs/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
- package/dist/cjs/anyspend/react/hooks/useHyperliquidTransfer.js +133 -0
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +1 -13
- package/dist/cjs/anyspend/types/chain.d.ts +10 -2
- package/dist/cjs/anyspend/types/chain.js +1 -0
- package/dist/cjs/anyspend/utils/address.d.ts +11 -0
- package/dist/cjs/anyspend/utils/address.js +15 -0
- package/dist/cjs/anyspend/utils/chain.d.ts +58 -1
- package/dist/cjs/anyspend/utils/chain.js +94 -4
- package/dist/cjs/anyspend/utils/token.d.ts +4 -0
- package/dist/cjs/anyspend/utils/token.js +35 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +3 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -57
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
- package/dist/cjs/global-account/react/hooks/index.js +1 -5
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +63 -72
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +24 -54
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/cjs/shared/utils/payment.utils.d.ts +1 -0
- package/dist/cjs/shared/utils/payment.utils.js +9 -0
- package/dist/esm/anyspend/constants/index.d.ts +1 -1
- package/dist/esm/anyspend/constants/index.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +22 -13
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -7
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -175
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +25 -0
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -5
- package/dist/esm/anyspend/react/components/common/OrderToken.js +3 -3
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmountFiat.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmountNew.js +3 -3
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -4
- package/dist/esm/anyspend/react/components/common/PaymentVendorUI.js +9 -3
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +3 -4
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +0 -3
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +6 -9
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
- package/dist/esm/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
- package/dist/esm/anyspend/react/hooks/useHyperliquidTransfer.js +127 -0
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +1 -13
- package/dist/esm/anyspend/types/chain.d.ts +10 -2
- package/dist/esm/anyspend/types/chain.js +1 -0
- package/dist/esm/anyspend/utils/address.d.ts +11 -0
- package/dist/esm/anyspend/utils/address.js +14 -0
- package/dist/esm/anyspend/utils/chain.d.ts +58 -1
- package/dist/esm/anyspend/utils/chain.js +91 -4
- package/dist/esm/anyspend/utils/token.d.ts +4 -0
- package/dist/esm/anyspend/utils/token.js +32 -6
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -5
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +12 -57
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
- package/dist/esm/global-account/react/hooks/index.js +0 -2
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +63 -72
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +24 -54
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/shared/utils/payment.utils.d.ts +1 -0
- package/dist/esm/shared/utils/payment.utils.js +9 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/constants/index.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/types/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
- package/dist/types/anyspend/types/chain.d.ts +10 -2
- package/dist/types/anyspend/utils/address.d.ts +11 -0
- package/dist/types/anyspend/utils/chain.d.ts +58 -1
- package/dist/types/anyspend/utils/token.d.ts +4 -0
- package/dist/types/global-account/react/hooks/index.d.ts +0 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/types/shared/utils/payment.utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +31 -13
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +9 -29
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +7 -30
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +22 -253
- package/src/anyspend/react/components/common/CryptoPaymentMethodDisplay.tsx +64 -0
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +6 -5
- package/src/anyspend/react/components/common/OrderToken.tsx +5 -5
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +3 -3
- package/src/anyspend/react/components/common/OrderTokenAmountFiat.tsx +3 -3
- package/src/anyspend/react/components/common/OrderTokenAmountNew.tsx +6 -6
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -5
- package/src/anyspend/react/components/common/PaymentVendorUI.tsx +26 -2
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +3 -5
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +0 -4
- package/src/anyspend/react/hooks/useConnectedUserProfile.ts +7 -10
- package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +2 -15
- package/src/anyspend/react/hooks/useHyperliquidTransfer.ts +152 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +7 -22
- package/src/anyspend/types/chain.ts +10 -1
- package/src/anyspend/utils/address.ts +15 -0
- package/src/anyspend/utils/chain.ts +115 -5
- package/src/anyspend/utils/token.ts +36 -7
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -2
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +4 -6
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +22 -77
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +1 -1
- package/src/global-account/react/hooks/index.ts +0 -2
- package/src/global-account/react/hooks/useAccountWallet.tsx +12 -11
- package/src/global-account/react/hooks/useAuthentication.ts +85 -88
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -10
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +26 -59
- package/src/shared/utils/payment.utils.ts +10 -1
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -73
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/cjs/global-account/react/hooks/useAuth.js +0 -338
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.js +0 -148
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -70
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/esm/global-account/react/hooks/useAuth.js +0 -332
- package/dist/esm/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/dist/esm/global-account/react/hooks/useBestTransactionPath.js +0 -145
- package/dist/types/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/types/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/types/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +0 -80
- package/src/global-account/react/hooks/useAuth.ts +0 -380
- package/src/global-account/react/hooks/useBestTransactionPath.tsx +0 -201
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.
|
|
17
|
+
exports.useURLParams = exports.useUnifiedChainSwitchAndExecute = exports.useTurnkeyAuth = exports.useTokensFromAddress = exports.useTokenPriceWithFallback = exports.useTokenPrice = exports.useTokenFromUrl = exports.useTokenData = exports.useTokenBalancesByChain = exports.useTokenBalanceDirect = exports.useTokenBalance = exports.useSiwe = exports.useSimSvmBalance = exports.useSimBalance = exports.useSearchParamsSSR = exports.useRouter = exports.useRemoveSessionKey = exports.useQueryBSMNT = exports.useQueryB3 = exports.useProfileSettings = exports.useProfilePreference = exports.useProfile = exports.useDisplayName = exports.useOneBalance = exports.useNotifications = exports.useNativeBalanceFromRPC = exports.useNativeBalance = exports.useMediaQuery = exports.useIsomorphicLayoutEffect = exports.useIsMobile = exports.useHasMounted = exports.useHandleConnectWithPrivy = exports.useGlobalAccount = exports.useGetGeo = exports.useGetAllTWSigners = exports.useFirstEOA = exports.useExchangeRate = exports.useConnect = exports.useClient = exports.useChainSwitchWithAction = exports.useB3EnsName = exports.useB3BalanceFromAddresses = exports.useAuthentication = exports.useAnalytics = exports.useAddTWSessionKey = exports.useAccountWallet = exports.useAccountAssets = exports.createWagmiConfig = void 0;
|
|
18
18
|
var createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
19
19
|
Object.defineProperty(exports, "createWagmiConfig", { enumerable: true, get: function () { return createWagmiConfig_1.createWagmiConfig; } });
|
|
20
20
|
var useAccountAssets_1 = require("./useAccountAssets");
|
|
@@ -25,16 +25,12 @@ var useAddTWSessionKey_1 = require("./useAddTWSessionKey");
|
|
|
25
25
|
Object.defineProperty(exports, "useAddTWSessionKey", { enumerable: true, get: function () { return useAddTWSessionKey_1.useAddTWSessionKey; } });
|
|
26
26
|
var useAnalytics_1 = require("./useAnalytics");
|
|
27
27
|
Object.defineProperty(exports, "useAnalytics", { enumerable: true, get: function () { return useAnalytics_1.useAnalytics; } });
|
|
28
|
-
var useAuth_1 = require("./useAuth");
|
|
29
|
-
Object.defineProperty(exports, "useAuth", { enumerable: true, get: function () { return useAuth_1.useAuth; } });
|
|
30
28
|
var useAuthentication_1 = require("./useAuthentication");
|
|
31
29
|
Object.defineProperty(exports, "useAuthentication", { enumerable: true, get: function () { return useAuthentication_1.useAuthentication; } });
|
|
32
30
|
var useB3BalanceFromAddresses_1 = require("./useB3BalanceFromAddresses");
|
|
33
31
|
Object.defineProperty(exports, "useB3BalanceFromAddresses", { enumerable: true, get: function () { return useB3BalanceFromAddresses_1.useB3BalanceFromAddresses; } });
|
|
34
32
|
var useB3EnsName_1 = require("./useB3EnsName");
|
|
35
33
|
Object.defineProperty(exports, "useB3EnsName", { enumerable: true, get: function () { return useB3EnsName_1.useB3EnsName; } });
|
|
36
|
-
var useBestTransactionPath_1 = require("./useBestTransactionPath");
|
|
37
|
-
Object.defineProperty(exports, "useBestTransactionPath", { enumerable: true, get: function () { return useBestTransactionPath_1.useBestTransactionPath; } });
|
|
38
34
|
var useChainSwitchWithAction_1 = require("./useChainSwitchWithAction");
|
|
39
35
|
Object.defineProperty(exports, "useChainSwitchWithAction", { enumerable: true, get: function () { return useChainSwitchWithAction_1.useChainSwitchWithAction; } });
|
|
40
36
|
__exportStar(require("./useClaim"), exports);
|
|
@@ -5,7 +5,6 @@ exports.useAccountWalletImage = useAccountWalletImage;
|
|
|
5
5
|
const react_1 = require("../../../global-account/react");
|
|
6
6
|
const constants_1 = require("../../../shared/constants");
|
|
7
7
|
const debug_1 = require("../../../shared/utils/debug");
|
|
8
|
-
const ipfs_1 = require("../../../shared/utils/ipfs");
|
|
9
8
|
const react_2 = require("react");
|
|
10
9
|
const react_3 = require("thirdweb/react");
|
|
11
10
|
const in_app_1 = require("thirdweb/wallets/in-app");
|
|
@@ -22,7 +21,13 @@ function useLastAuthProvider() {
|
|
|
22
21
|
return lastAuthProvider;
|
|
23
22
|
}
|
|
24
23
|
function useAccountWallet() {
|
|
25
|
-
|
|
24
|
+
// WOJ: --------------------
|
|
25
|
+
// values from in useB3:
|
|
26
|
+
// const activeAccount = useActiveAccount();
|
|
27
|
+
// const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
28
|
+
// can we possibly just use useActiveAccount here?
|
|
29
|
+
// --------------------
|
|
30
|
+
const { account } = (0, react_1.useB3)();
|
|
26
31
|
const activeWallet = (0, react_3.useActiveWallet)();
|
|
27
32
|
const connectedWallets = (0, react_3.useConnectedWallets)();
|
|
28
33
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === constants_1.ecosystemWalletId);
|
|
@@ -35,7 +40,6 @@ function useAccountWallet() {
|
|
|
35
40
|
debug("connectedEOAWallet", connectedEOAWallet);
|
|
36
41
|
debug("isActiveSmartWallet", isActiveSmartWallet);
|
|
37
42
|
debug("isActiveEOAWallet", isActiveEOAWallet);
|
|
38
|
-
const { data: walletImage } = (0, react_3.useWalletImage)(connectedEOAWallet?.id);
|
|
39
43
|
// If not EOA sign in, then we need to show the smart wallet icon
|
|
40
44
|
const lastAuthProvider = useLastAuthProvider();
|
|
41
45
|
const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
|
|
@@ -43,13 +47,12 @@ function useAccountWallet() {
|
|
|
43
47
|
: "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
|
|
44
48
|
const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
|
|
45
49
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
46
|
-
const avatarUrl = user?.avatar ? (0, ipfs_1.getIpfsUrl)(user?.avatar) : profileData?.avatar;
|
|
47
50
|
const res = (0, react_2.useMemo)(() => ({
|
|
48
51
|
wallet: {
|
|
49
52
|
...account,
|
|
50
53
|
ensName,
|
|
51
54
|
meta: {
|
|
52
|
-
icon:
|
|
55
|
+
icon: "", // deprecated
|
|
53
56
|
},
|
|
54
57
|
},
|
|
55
58
|
address: account?.address,
|
|
@@ -59,22 +62,20 @@ function useAccountWallet() {
|
|
|
59
62
|
isActiveSmartWallet: isActiveSmartWallet,
|
|
60
63
|
isActiveEOAWallet: isActiveEOAWallet,
|
|
61
64
|
smartWalletIcon: smartWalletIcon,
|
|
62
|
-
eoaWalletIcon:
|
|
65
|
+
eoaWalletIcon: "", // deprecated
|
|
63
66
|
}), [
|
|
64
67
|
account,
|
|
65
|
-
avatarUrl,
|
|
66
68
|
connectedEOAWallet,
|
|
67
69
|
connectedSmartWallet,
|
|
68
70
|
ensName,
|
|
69
71
|
isActiveEOAWallet,
|
|
70
72
|
isActiveSmartWallet,
|
|
71
73
|
smartWalletIcon,
|
|
72
|
-
walletImage,
|
|
73
74
|
]);
|
|
74
75
|
return res;
|
|
75
76
|
}
|
|
76
77
|
function useAccountWalletImage() {
|
|
77
|
-
const { account
|
|
78
|
+
const { account } = (0, react_1.useB3)();
|
|
78
79
|
const activeWallet = (0, react_3.useActiveWallet)();
|
|
79
80
|
const connectedWallets = (0, react_3.useConnectedWallets)();
|
|
80
81
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === constants_1.ecosystemWalletId);
|
|
@@ -87,6 +88,6 @@ function useAccountWalletImage() {
|
|
|
87
88
|
? in_app_1.socialIcons[lastAuthProvider]
|
|
88
89
|
: "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
|
|
89
90
|
const { data: profileData } = (0, react_1.useProfile)({ address: account?.address });
|
|
90
|
-
const avatarUrl =
|
|
91
|
+
const avatarUrl = profileData?.avatar;
|
|
91
92
|
return avatarUrl || (isActiveSmartWallet ? smartWalletIcon : walletImage) || "";
|
|
92
93
|
}
|
|
@@ -41,8 +41,8 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
41
41
|
name?: string | undefined;
|
|
42
42
|
address?: string | undefined;
|
|
43
43
|
email?: string | undefined;
|
|
44
|
-
phone?: string | undefined;
|
|
45
44
|
username?: string | undefined;
|
|
45
|
+
phone?: string | undefined;
|
|
46
46
|
fid?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
}[] | undefined;
|
|
@@ -63,6 +63,6 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
63
63
|
turnkeyOtpId?: string | undefined;
|
|
64
64
|
};
|
|
65
65
|
} | undefined;
|
|
66
|
-
refetchUser: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
66
|
+
refetchUser: (wallet?: Wallet) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
67
67
|
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
68
68
|
};
|
|
@@ -18,7 +18,7 @@ const in_app_1 = require("thirdweb/wallets/in-app");
|
|
|
18
18
|
const wagmi_1 = require("wagmi");
|
|
19
19
|
const LocalSDKProvider_1 = require("../components/B3Provider/LocalSDKProvider");
|
|
20
20
|
const createWagmiConfig_1 = require("../utils/createWagmiConfig");
|
|
21
|
-
const
|
|
21
|
+
const useTWAuth_1 = require("./useTWAuth");
|
|
22
22
|
const useUserQuery_1 = require("./useUserQuery");
|
|
23
23
|
const debug = (0, debug_1.debugB3React)("useAuthentication");
|
|
24
24
|
function useAuthentication(partnerId) {
|
|
@@ -36,7 +36,7 @@ function useAuthentication(partnerId) {
|
|
|
36
36
|
const setHasStartedConnecting = (0, react_1.useAuthStore)(state => state.setHasStartedConnecting);
|
|
37
37
|
const setActiveWallet = (0, react_3.useSetActiveWallet)();
|
|
38
38
|
const hasStartedConnecting = (0, react_1.useAuthStore)(state => state.hasStartedConnecting);
|
|
39
|
-
const {
|
|
39
|
+
const { authenticate } = (0, useTWAuth_1.useTWAuth)();
|
|
40
40
|
const { user, setUser } = (0, useUserQuery_1.useUserQuery)();
|
|
41
41
|
const useAutoConnectLoadingPrevious = (0, react_2.useRef)(false);
|
|
42
42
|
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId });
|
|
@@ -96,19 +96,18 @@ function useAuthentication(partnerId) {
|
|
|
96
96
|
(0, react_2.useEffect)(() => {
|
|
97
97
|
syncWagmi();
|
|
98
98
|
}, [wallets, syncWagmi]);
|
|
99
|
-
|
|
100
|
-
* Authenticate user using Turnkey
|
|
101
|
-
* Note: This no longer requires a wallet for authentication.
|
|
102
|
-
* Wallets are still used for signing transactions, but authentication is done via Turnkey email OTP.
|
|
103
|
-
*
|
|
104
|
-
* For backward compatibility, this function still accepts a wallet parameter,
|
|
105
|
-
* but it's not used for authentication anymore.
|
|
106
|
-
*/
|
|
107
|
-
const authenticateUser = (0, react_2.useCallback)(async () => {
|
|
99
|
+
const authenticateUser = (0, react_2.useCallback)(async (wallet) => {
|
|
108
100
|
setHasStartedConnecting(true);
|
|
101
|
+
if (!wallet) {
|
|
102
|
+
throw new Error("No wallet found during auto-connect");
|
|
103
|
+
}
|
|
104
|
+
const account = wallet ? wallet.getAccount() : activeWallet?.getAccount();
|
|
105
|
+
if (!account) {
|
|
106
|
+
throw new Error("No account found during auto-connect");
|
|
107
|
+
}
|
|
109
108
|
// Try to re-authenticate first
|
|
110
109
|
try {
|
|
111
|
-
const userAuth = await reAuthenticate();
|
|
110
|
+
const userAuth = await app_1.default.reAuthenticate();
|
|
112
111
|
setUser(userAuth.user);
|
|
113
112
|
setIsAuthenticated(true);
|
|
114
113
|
setIsAuthenticating(false);
|
|
@@ -119,50 +118,67 @@ function useAuthentication(partnerId) {
|
|
|
119
118
|
return userAuth;
|
|
120
119
|
}
|
|
121
120
|
catch (error) {
|
|
122
|
-
// If re-authentication fails,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
// If re-authentication fails, try fresh authentication
|
|
122
|
+
debug("Re-authentication failed, attempting fresh authentication");
|
|
123
|
+
const userAuth = await authenticate(wallet, partnerId);
|
|
124
|
+
setUser(userAuth.user);
|
|
125
|
+
setIsAuthenticated(true);
|
|
126
126
|
setIsAuthenticating(false);
|
|
127
|
-
|
|
127
|
+
debug("Fresh authentication successful", { userAuth });
|
|
128
|
+
// Authenticate on BSMNT with B3 JWT
|
|
129
|
+
const b3Jwt = await (0, bsmnt_1.authenticateWithB3JWT)(userAuth.accessToken);
|
|
130
|
+
debug("@@b3Jwt", b3Jwt);
|
|
131
|
+
return userAuth;
|
|
128
132
|
}
|
|
129
|
-
}, [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
}, [activeWallet, partnerId, authenticate, setIsAuthenticated, setIsAuthenticating, setUser, setHasStartedConnecting]);
|
|
134
|
+
const logout = (0, react_2.useCallback)(async (callback) => {
|
|
135
|
+
if (activeWallet) {
|
|
136
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
137
|
+
disconnect(activeWallet);
|
|
138
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
139
|
+
}
|
|
140
|
+
// Log out of each wallet
|
|
141
|
+
wallets.forEach(wallet => {
|
|
142
|
+
console.log("@@logging out", wallet);
|
|
143
|
+
disconnect(wallet);
|
|
144
|
+
});
|
|
145
|
+
// Delete localStorage thirdweb:connected-wallet-ids
|
|
146
|
+
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
147
|
+
if (typeof localStorage !== "undefined") {
|
|
148
|
+
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
149
|
+
localStorage.removeItem("wagmi.store");
|
|
150
|
+
localStorage.removeItem("lastAuthProvider");
|
|
151
|
+
localStorage.removeItem("b3-user");
|
|
152
|
+
}
|
|
153
|
+
app_1.default.logout();
|
|
154
|
+
debug("@@logout:loggedOut");
|
|
155
|
+
setIsAuthenticated(false);
|
|
156
|
+
setIsConnected(false);
|
|
157
|
+
setUser();
|
|
158
|
+
callback?.();
|
|
159
|
+
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
135
160
|
const onConnect = (0, react_2.useCallback)(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
136
161
|
debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
|
|
137
|
-
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
138
|
-
if (!wallet) {
|
|
139
|
-
throw new Error("No smart wallet found during auto-connect");
|
|
140
|
-
}
|
|
141
|
-
debug("@@useAuthentication:onConnect", { wallet });
|
|
142
162
|
try {
|
|
163
|
+
const wallet = allConnectedWallets.find(wallet => wallet.id.startsWith("ecosystem."));
|
|
164
|
+
if (!wallet) {
|
|
165
|
+
throw new Error("No smart wallet found during auto-connect");
|
|
166
|
+
}
|
|
167
|
+
debug("@@useAuthentication:onConnect", { wallet });
|
|
143
168
|
setHasStartedConnecting(true);
|
|
144
169
|
setIsConnected(true);
|
|
145
170
|
setIsAuthenticating(true);
|
|
146
171
|
await setActiveWallet(wallet);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const userAuth = await authenticateUser();
|
|
151
|
-
if (userAuth && onConnectCallback) {
|
|
152
|
-
await onConnectCallback(wallet, userAuth.accessToken);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (authError) {
|
|
156
|
-
// Authentication failed - this is expected if user hasn't authenticated via Turnkey yet
|
|
157
|
-
// The Turnkey auth modal should handle this
|
|
158
|
-
debug("@@useAuthentication:onConnect:authFailed", { authError });
|
|
159
|
-
// Don't set isAuthenticated to false here - let the Turnkey flow handle it
|
|
172
|
+
const userAuth = await authenticateUser(wallet);
|
|
173
|
+
if (userAuth && onConnectCallback) {
|
|
174
|
+
await onConnectCallback(wallet, userAuth.accessToken);
|
|
160
175
|
}
|
|
161
176
|
}
|
|
162
177
|
catch (error) {
|
|
163
178
|
debug("@@useAuthentication:onConnect:failed", { error });
|
|
164
179
|
setIsAuthenticated(false);
|
|
165
180
|
setUser(undefined);
|
|
181
|
+
await logout();
|
|
166
182
|
}
|
|
167
183
|
finally {
|
|
168
184
|
setIsAuthenticating(false);
|
|
@@ -173,44 +189,19 @@ function useAuthentication(partnerId) {
|
|
|
173
189
|
isConnected,
|
|
174
190
|
});
|
|
175
191
|
}, [
|
|
176
|
-
onConnectCallback,
|
|
177
|
-
authenticateUser,
|
|
178
192
|
isAuthenticated,
|
|
179
193
|
isAuthenticating,
|
|
180
194
|
isConnected,
|
|
181
|
-
setActiveWallet,
|
|
182
195
|
setHasStartedConnecting,
|
|
183
|
-
setIsAuthenticated,
|
|
184
|
-
setIsAuthenticating,
|
|
185
196
|
setIsConnected,
|
|
197
|
+
setIsAuthenticating,
|
|
198
|
+
setActiveWallet,
|
|
199
|
+
authenticateUser,
|
|
200
|
+
onConnectCallback,
|
|
201
|
+
setIsAuthenticated,
|
|
186
202
|
setUser,
|
|
203
|
+
logout,
|
|
187
204
|
]);
|
|
188
|
-
const logout = (0, react_2.useCallback)(async (callback) => {
|
|
189
|
-
if (activeWallet) {
|
|
190
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
191
|
-
disconnect(activeWallet);
|
|
192
|
-
debug("@@logout:activeWallet", activeWallet);
|
|
193
|
-
}
|
|
194
|
-
// Log out of each wallet
|
|
195
|
-
wallets.forEach(wallet => {
|
|
196
|
-
console.log("@@logging out", wallet);
|
|
197
|
-
disconnect(wallet);
|
|
198
|
-
});
|
|
199
|
-
// Delete localStorage thirdweb:connected-wallet-ids
|
|
200
|
-
// https://npc-labs.slack.com/archives/C070E6HNG85/p1750185115273099
|
|
201
|
-
if (typeof localStorage !== "undefined") {
|
|
202
|
-
localStorage.removeItem("thirdweb:connected-wallet-ids");
|
|
203
|
-
localStorage.removeItem("wagmi.store");
|
|
204
|
-
localStorage.removeItem("lastAuthProvider");
|
|
205
|
-
localStorage.removeItem("b3-user");
|
|
206
|
-
}
|
|
207
|
-
app_1.default.logout();
|
|
208
|
-
debug("@@logout:loggedOut");
|
|
209
|
-
setIsAuthenticated(false);
|
|
210
|
-
setIsConnected(false);
|
|
211
|
-
setUser();
|
|
212
|
-
callback?.();
|
|
213
|
-
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
214
205
|
const { isLoading: useAutoConnectLoading } = (0, react_3.useAutoConnect)({
|
|
215
206
|
client: thirdweb_1.client,
|
|
216
207
|
wallets: [wallet],
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { Wallet } from "thirdweb/wallets";
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated Use useAuth() with Turnkey authentication instead
|
|
4
|
-
*/
|
|
5
2
|
export declare function useTWAuth(): {
|
|
6
3
|
authenticate: (wallet: Wallet, partnerId: string) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
7
4
|
};
|
|
@@ -4,19 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useTWAuth = useTWAuth;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated This hook is deprecated. Use useAuth() with Turnkey authentication instead.
|
|
9
|
-
* This file is kept for backward compatibility but should not be used in new code.
|
|
10
|
-
*/
|
|
11
7
|
const app_1 = __importDefault(require("../../../global-account/app"));
|
|
12
8
|
const debug_1 = __importDefault(require("../../../shared/utils/debug"));
|
|
13
9
|
const react_1 = require("react");
|
|
14
10
|
const useSearchParamsSSR_1 = require("./useSearchParamsSSR");
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated Use useAuth() with Turnkey authentication instead
|
|
17
|
-
*/
|
|
18
11
|
function useTWAuth() {
|
|
19
|
-
console.warn("useTWAuth is deprecated. Please migrate to useAuth() with Turnkey authentication. See useTurnkeyAuth.ts for the new implementation.");
|
|
20
12
|
const referralCode = (0, useSearchParamsSSR_1.useSearchParam)("referralCode");
|
|
21
13
|
const authenticate = (0, react_1.useCallback)(async (wallet, partnerId) => {
|
|
22
14
|
if (!wallet || !wallet?.getAuthToken?.())
|
|
@@ -4,12 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useTurnkeyAuth = useTurnkeyAuth;
|
|
7
|
-
const debug_1 = require("../../../shared/utils/debug");
|
|
8
|
-
const react_1 = require("react");
|
|
9
7
|
const app_1 = __importDefault(require("../../app"));
|
|
10
|
-
const useB3_1 = require("../components/B3Provider/useB3");
|
|
11
8
|
const stores_1 = require("../stores");
|
|
12
|
-
const
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const useB3_1 = require("../components/B3Provider/useB3");
|
|
11
|
+
const debug_1 = require("../../../shared/utils/debug");
|
|
13
12
|
const debug = (0, debug_1.debugB3React)("useTurnkeyAuth");
|
|
14
13
|
/**
|
|
15
14
|
* Hook for Turnkey email-based OTP authentication
|
|
@@ -24,55 +23,29 @@ function useTurnkeyAuth() {
|
|
|
24
23
|
const [error, setError] = (0, react_1.useState)(null);
|
|
25
24
|
const setIsAuthenticating = (0, stores_1.useAuthStore)(state => state.setIsAuthenticating);
|
|
26
25
|
const setIsAuthenticated = (0, stores_1.useAuthStore)(state => state.setIsAuthenticated);
|
|
27
|
-
const {
|
|
28
|
-
const { authenticate } = (0, useAuth_1.useAuth)();
|
|
26
|
+
const { user } = (0, useB3_1.useB3)();
|
|
29
27
|
/**
|
|
30
28
|
* Step 1: Initiate login with email
|
|
31
|
-
* - Calls backend
|
|
29
|
+
* - Calls backend to create sub-org (if needed) and send OTP
|
|
32
30
|
* - Returns otpId to use in verification step
|
|
33
|
-
*
|
|
34
|
-
* Note: Uses the turnkey-jwt authentication strategy, not the service directly.
|
|
35
|
-
* The turnkey-jwt strategy handles both OTP flow (init/verify) and final authentication.
|
|
36
31
|
*/
|
|
37
32
|
const initiateLogin = (0, react_1.useCallback)(async (email) => {
|
|
38
33
|
setIsLoading(true);
|
|
39
34
|
setError(null);
|
|
40
35
|
setIsAuthenticating(true);
|
|
41
36
|
try {
|
|
37
|
+
if (!user?.userId) {
|
|
38
|
+
throw new Error("User ID is required to initiate Turnkey login.");
|
|
39
|
+
}
|
|
42
40
|
debug(`Initiating login for: ${email}`);
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
// Backend will get userId from _params.user?.userId if authenticated, or handle unauthenticated case
|
|
46
|
-
// So we only need to send email
|
|
47
|
-
debug(`Calling app.authenticate with turnkey-jwt strategy (init action)`, { email });
|
|
48
|
-
const response = await app_1.default.authenticate({
|
|
49
|
-
strategy: "turnkey-jwt",
|
|
50
|
-
action: "init",
|
|
51
|
-
email,
|
|
52
|
-
});
|
|
53
|
-
// The strategy returns the TurnkeyAuthInitResponse directly
|
|
54
|
-
const data = response;
|
|
41
|
+
// Call FeathersJS service to initialize OTP
|
|
42
|
+
const data = await app_1.default.service("turnkey-auth").init({ email, userId: user.userId });
|
|
55
43
|
debug(`OTP initialized successfully. OtpId: ${data.otpId}`);
|
|
56
44
|
return data;
|
|
57
45
|
}
|
|
58
46
|
catch (err) {
|
|
59
47
|
debug("Error initiating login:", err);
|
|
60
|
-
|
|
61
|
-
let errorMessage = "Failed to send OTP email. Please try again.";
|
|
62
|
-
if (err.message) {
|
|
63
|
-
errorMessage = err.message;
|
|
64
|
-
}
|
|
65
|
-
else if (err.name === "TypeError" && err.message?.includes("fetch")) {
|
|
66
|
-
errorMessage = "Network error: Unable to reach the server. Please check your connection and try again.";
|
|
67
|
-
}
|
|
68
|
-
else if (err.code === "ECONNREFUSED" || err.code === "ENOTFOUND") {
|
|
69
|
-
errorMessage = "Connection error: Unable to reach the server. Please check your internet connection.";
|
|
70
|
-
}
|
|
71
|
-
else if (err.response) {
|
|
72
|
-
// FeathersJS error response
|
|
73
|
-
errorMessage = err.response.message || err.message || errorMessage;
|
|
74
|
-
debug("FeathersJS error response:", err.response);
|
|
75
|
-
}
|
|
48
|
+
const errorMessage = err.message || "Failed to send OTP email. Please try again.";
|
|
76
49
|
setError(errorMessage);
|
|
77
50
|
throw err;
|
|
78
51
|
}
|
|
@@ -80,11 +53,11 @@ function useTurnkeyAuth() {
|
|
|
80
53
|
setIsLoading(false);
|
|
81
54
|
setIsAuthenticating(false);
|
|
82
55
|
}
|
|
83
|
-
}, [setIsAuthenticating]);
|
|
56
|
+
}, [user, setIsAuthenticating]);
|
|
84
57
|
/**
|
|
85
58
|
* Step 2: Verify OTP and authenticate
|
|
86
|
-
* - Verifies OTP with backend
|
|
87
|
-
* - Gets Turnkey session JWT
|
|
59
|
+
* - Verifies OTP with backend
|
|
60
|
+
* - Gets Turnkey session JWT
|
|
88
61
|
* - Authenticates with b3-api using "turnkey-jwt" strategy
|
|
89
62
|
* - JWT automatically stored in cookies by SDK
|
|
90
63
|
*/
|
|
@@ -93,22 +66,19 @@ function useTurnkeyAuth() {
|
|
|
93
66
|
setError(null);
|
|
94
67
|
setIsAuthenticating(true);
|
|
95
68
|
try {
|
|
96
|
-
debug(`Verifying OTP...`, {
|
|
97
|
-
// Step 1: Verify OTP
|
|
98
|
-
|
|
99
|
-
const response = await app_1.default.authenticate({
|
|
100
|
-
strategy: "turnkey-jwt",
|
|
101
|
-
action: "verify",
|
|
69
|
+
debug(`Verifying OTP...`, { userId: user?.userId });
|
|
70
|
+
// Step 1: Verify OTP and get Turnkey session JWT
|
|
71
|
+
const { turnkeySessionJwt } = await app_1.default.service("turnkey-auth").verify({
|
|
102
72
|
otpId,
|
|
103
73
|
otpCode,
|
|
104
74
|
});
|
|
105
|
-
|
|
106
|
-
const verifyResult = response;
|
|
107
|
-
const { turnkeySessionJwt } = verifyResult;
|
|
108
|
-
debug(`OTP verified! Got Turnkey session JWT. Authenticating with b3-api...`);
|
|
75
|
+
debug(`OTP verified! Authenticating with b3-api...`);
|
|
109
76
|
// Step 2: Authenticate with b3-api using Turnkey JWT
|
|
110
|
-
//
|
|
111
|
-
const authResult = await authenticate(
|
|
77
|
+
// The SDK will automatically store the b3-api JWT in cookies
|
|
78
|
+
const authResult = await app_1.default.authenticate({
|
|
79
|
+
strategy: "turnkey-jwt",
|
|
80
|
+
accessToken: turnkeySessionJwt,
|
|
81
|
+
});
|
|
112
82
|
debug(`Successfully authenticated with b3-api!`, authResult);
|
|
113
83
|
// Update auth store to reflect authenticated state
|
|
114
84
|
setIsAuthenticated(true);
|
|
@@ -128,7 +98,7 @@ function useTurnkeyAuth() {
|
|
|
128
98
|
setIsLoading(false);
|
|
129
99
|
setIsAuthenticating(false);
|
|
130
100
|
}
|
|
131
|
-
}, [
|
|
101
|
+
}, [user, setIsAuthenticating, setIsAuthenticated]);
|
|
132
102
|
const clearError = (0, react_1.useCallback)(() => {
|
|
133
103
|
setError(null);
|
|
134
104
|
}, []);
|
|
@@ -36,8 +36,8 @@ export declare function useUserQuery(): {
|
|
|
36
36
|
name?: string | undefined;
|
|
37
37
|
address?: string | undefined;
|
|
38
38
|
email?: string | undefined;
|
|
39
|
-
phone?: string | undefined;
|
|
40
39
|
username?: string | undefined;
|
|
40
|
+
phone?: string | undefined;
|
|
41
41
|
fid?: string | undefined;
|
|
42
42
|
};
|
|
43
43
|
}[] | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
|
+
export declare function getStripePromise(): Promise<import("@stripe/stripe-js").Stripe | null>;
|
|
2
3
|
export declare function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
3
4
|
export declare function getPaymentMethodDescription(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
4
5
|
export declare function formatStripeAmount(amount: number): string;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStripePromise = getStripePromise;
|
|
3
4
|
exports.getVendorDisplayName = getVendorDisplayName;
|
|
4
5
|
exports.getPaymentMethodDescription = getPaymentMethodDescription;
|
|
5
6
|
exports.formatStripeAmount = formatStripeAmount;
|
|
6
7
|
exports.generateReturnUrl = generateReturnUrl;
|
|
7
8
|
const constants_1 = require("../../anyspend/constants");
|
|
9
|
+
const stripe_js_1 = require("@stripe/stripe-js");
|
|
10
|
+
let stripePromise = null;
|
|
11
|
+
function getStripePromise() {
|
|
12
|
+
if (!stripePromise) {
|
|
13
|
+
stripePromise = (0, stripe_js_1.loadStripe)(constants_1.STRIPE_CONFIG.publishableKey);
|
|
14
|
+
}
|
|
15
|
+
return stripePromise;
|
|
16
|
+
}
|
|
8
17
|
function getVendorDisplayName(vendor) {
|
|
9
18
|
switch (vendor) {
|
|
10
19
|
case "coinbase":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { components } from "../types/api";
|
|
2
2
|
export declare const ANYSPEND_MAINNET_BASE_URL: string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
4
4
|
export declare const RELAY_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
5
5
|
export declare const RELAY_SOLANA_MAINNET_CHAIN_ID = 792703809;
|
|
6
6
|
export declare const SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { base } from "viem/chains";
|
|
2
2
|
export const ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
3
|
-
export const
|
|
3
|
+
export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
4
4
|
export const RELAY_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
5
5
|
export const RELAY_SOLANA_MAINNET_CHAIN_ID = 792703809;
|
|
6
6
|
export const SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { getDefaultToken, USDC_BASE } from "../../../anyspend/index.js";
|
|
3
|
+
import { eqci, getDefaultToken, getHyperliquidUSDCToken, HYPERLIQUID_CHAIN_ID, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
5
|
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet, useB3, useModalStore, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
6
6
|
import BottomNavigation from "../../../global-account/react/components/ManageAccount/BottomNavigation.js";
|
|
@@ -15,7 +15,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
15
15
|
import { parseUnits } from "viem";
|
|
16
16
|
import { base, mainnet } from "viem/chains";
|
|
17
17
|
import { useAutoSelectCryptoPaymentMethod } from "../hooks/useAutoSelectCryptoPaymentMethod.js";
|
|
18
|
-
import { useAutoSetActiveWalletFromWagmi } from "../hooks/useAutoSetActiveWalletFromWagmi.js";
|
|
19
18
|
import { useConnectedWalletDisplay } from "../hooks/useConnectedWalletDisplay.js";
|
|
20
19
|
import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodState.js";
|
|
21
20
|
import { useRecipientAddressState } from "../hooks/useRecipientAddressState.js";
|
|
@@ -108,14 +107,17 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
108
107
|
// State for destination chain/token selection
|
|
109
108
|
const [selectedDstChainId, setSelectedDstChainId] = useState(initialDstChainId);
|
|
110
109
|
const defaultDstToken = isBuyMode
|
|
111
|
-
?
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
? // Special case: Hyperliquid uses zero address for USDC
|
|
111
|
+
destinationTokenChainId === HYPERLIQUID_CHAIN_ID && eqci(destinationTokenAddress, ZERO_ADDRESS)
|
|
112
|
+
? getHyperliquidUSDCToken()
|
|
113
|
+
: {
|
|
114
|
+
symbol: "",
|
|
115
|
+
chainId: destinationTokenChainId,
|
|
116
|
+
address: destinationTokenAddress,
|
|
117
|
+
name: "",
|
|
118
|
+
decimals: 18,
|
|
119
|
+
metadata: {},
|
|
120
|
+
}
|
|
119
121
|
: getDefaultToken(selectedDstChainId);
|
|
120
122
|
const dstTokenFromUrl = useTokenFromUrl({
|
|
121
123
|
defaultToken: defaultDstToken,
|
|
@@ -153,6 +155,11 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
153
155
|
// Update destination token with metadata
|
|
154
156
|
useEffect(() => {
|
|
155
157
|
if (selectedDstToken && dstTokenMetadata && !appliedDstMetadataRef.current) {
|
|
158
|
+
// Skip metadata enhancement for Hyperliquid USDC - we already have correct metadata from getHyperliquidUSDCToken()
|
|
159
|
+
if (selectedDstToken.chainId === HYPERLIQUID_CHAIN_ID && eqci(selectedDstToken.address, ZERO_ADDRESS)) {
|
|
160
|
+
appliedDstMetadataRef.current = true;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
156
163
|
// Mark as applied
|
|
157
164
|
appliedDstMetadataRef.current = true;
|
|
158
165
|
const enhancedToken = {
|
|
@@ -313,8 +320,6 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
313
320
|
// );
|
|
314
321
|
const { address: globalAddress, wallet: globalWallet, connectedEOAWallet } = useAccountWallet();
|
|
315
322
|
const globalWalletImage = useAccountWalletImage();
|
|
316
|
-
// Auto-set active wallet from wagmi
|
|
317
|
-
useAutoSetActiveWalletFromWagmi();
|
|
318
323
|
// Get wallet address based on selected payment method
|
|
319
324
|
const { walletAddress } = useConnectedWalletDisplay(effectiveCryptoPaymentMethod);
|
|
320
325
|
// Recipient address state with dual-state system (auto + explicit user selection)
|
|
@@ -818,10 +823,14 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
818
823
|
else {
|
|
819
824
|
setActivePanel(panelIndex);
|
|
820
825
|
}
|
|
821
|
-
}, _recipientAddress: effectiveRecipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward"), onShowFeeDetail: () => navigateToPanel(PanelView.FEE_DETAIL, "forward"), customUsdInputValues: customUsdInputValues }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden"), onClick: () => {
|
|
826
|
+
}, _recipientAddress: effectiveRecipientAddress, destinationToken: selectedDstToken, destinationChainId: selectedDstChainId, destinationAmount: dstAmount, onDestinationTokenChange: setSelectedDstToken, onDestinationChainChange: setSelectedDstChainId, fiatPaymentMethodIndex: PanelView.FIAT_PAYMENT_METHOD, recipientSelectionPanelIndex: PanelView.RECIPIENT_SELECTION, hideDstToken: isBuyMode, anyspendQuote: anyspendQuote, onShowPointsDetail: () => navigateToPanel(PanelView.POINTS_DETAIL, "forward"), onShowFeeDetail: () => navigateToPanel(PanelView.FEE_DETAIL, "forward"), customUsdInputValues: customUsdInputValues }) })), _jsx(Button, { variant: "ghost", className: cn("border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl", isBuyMode && "top-[calc(50%+56px)] cursor-default", activeTab === "fiat" && "hidden", selectedDstChainId === HYPERLIQUID_CHAIN_ID && "cursor-not-allowed opacity-50"), onClick: () => {
|
|
822
827
|
if (activeTab === "fiat" || isBuyMode) {
|
|
823
828
|
return;
|
|
824
829
|
}
|
|
830
|
+
// Prevent swapping if destination is Hyperliquid (only supported as destination, not source)
|
|
831
|
+
if (selectedDstChainId === HYPERLIQUID_CHAIN_ID) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
825
834
|
// Swap chain selections
|
|
826
835
|
const tempSrcChainId = selectedSrcChainId;
|
|
827
836
|
const tempDstChainId = selectedDstChainId;
|
|
@@ -31,7 +31,7 @@ import { useMemo } from "react";
|
|
|
31
31
|
import { encodeFunctionData } from "viem";
|
|
32
32
|
import { AnySpendCustom } from "./AnySpendCustom.js";
|
|
33
33
|
// Collector Club Shop contract on Base
|
|
34
|
-
const CC_SHOP_ADDRESS = "
|
|
34
|
+
const CC_SHOP_ADDRESS = "0x47366E64E4917dd4DdC04Fb9DC507c1dD2b87294";
|
|
35
35
|
const BASE_CHAIN_ID = 8453;
|
|
36
36
|
// ABI for buyPacksFor function only
|
|
37
37
|
const BUY_PACKS_FOR_ABI = {
|