@b3dotfun/sdk 0.0.1-alpha.2 → 0.0.1-alpha.21
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/README.md +328 -230
- package/dist/cjs/anyspend/index.native.d.ts +13 -0
- package/dist/cjs/anyspend/index.native.js +35 -0
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendBuySpin.js +123 -50
- package/dist/cjs/anyspend/react/components/common/OrderHistoryItem.js +5 -1
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/cjs/anyspend/utils/chain.js +3 -0
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +2 -2
- package/dist/cjs/global-account/react/components/{B3Provider.d.ts → B3Provider/B3Provider.d.ts} +3 -29
- package/dist/cjs/global-account/react/components/{B3Provider.js → B3Provider/B3Provider.js} +6 -34
- package/dist/cjs/global-account/react/components/{B3Provider.native.d.ts → B3Provider/B3Provider.native.d.ts} +2 -25
- package/dist/cjs/global-account/react/components/{B3Provider.native.js → B3Provider/B3Provider.native.js} +5 -28
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +25 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +20 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +5 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +17 -0
- package/dist/cjs/global-account/react/components/StyleRoot.js +2 -2
- package/dist/cjs/global-account/react/components/index.d.ts +8 -6
- package/dist/cjs/global-account/react/components/index.js +18 -16
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/index.js +2 -1
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.js +3 -3
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +1 -1
- package/dist/cjs/global-account/react/index.native.d.ts +7 -0
- package/dist/cjs/global-account/react/index.native.js +21 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/cjs/global-account/types/chain-networks.d.ts +34 -34
- package/dist/cjs/global-account/types/feature-flags.d.ts +5 -5
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/cjs/shared/constants/chains/supported.d.ts +8 -7
- package/dist/cjs/shared/constants/chains/supported.js +8 -1
- package/dist/cjs/shared/utils/chains.js +4 -0
- package/dist/cjs/shared/utils/number.js +1 -1
- package/dist/esm/anyspend/index.native.d.ts +13 -0
- package/dist/esm/anyspend/index.native.js +19 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendBuySpin.js +123 -50
- package/dist/esm/anyspend/react/components/common/OrderHistoryItem.js +5 -1
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +1 -1
- package/dist/esm/anyspend/utils/chain.js +3 -0
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -1
- package/dist/esm/global-account/react/components/{B3Provider.d.ts → B3Provider/B3Provider.d.ts} +3 -29
- package/dist/esm/global-account/react/components/{B3Provider.js → B3Provider/B3Provider.js} +5 -32
- package/dist/esm/global-account/react/components/{B3Provider.native.d.ts → B3Provider/B3Provider.native.d.ts} +2 -25
- package/dist/esm/global-account/react/components/{B3Provider.native.js → B3Provider/B3Provider.native.js} +5 -26
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +25 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +17 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +5 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +14 -0
- package/dist/esm/global-account/react/components/StyleRoot.js +1 -1
- package/dist/esm/global-account/react/components/index.d.ts +8 -6
- package/dist/esm/global-account/react/components/index.js +7 -5
- 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/useBestTransactionPath.js +3 -3
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +1 -1
- package/dist/esm/global-account/react/index.native.d.ts +7 -0
- package/dist/esm/global-account/react/index.native.js +11 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/global-account/types/chain-networks.d.ts +34 -34
- package/dist/esm/global-account/types/feature-flags.d.ts +5 -5
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/esm/shared/constants/chains/supported.d.ts +8 -7
- package/dist/esm/shared/constants/chains/supported.js +7 -0
- package/dist/esm/shared/utils/chains.js +4 -0
- package/dist/esm/shared/utils/number.js +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/index.native.d.ts +13 -0
- package/dist/types/anyspend/react/components/AnySpend.d.ts +2 -1
- package/dist/types/anyspend/react/components/AnySpendBuySpin.d.ts +2 -1
- package/dist/types/global-account/react/components/{B3Provider.d.ts → B3Provider/B3Provider.d.ts} +2 -28
- package/dist/types/global-account/react/components/{B3Provider.native.d.ts → B3Provider/B3Provider.native.d.ts} +1 -24
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +25 -0
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +5 -0
- package/dist/types/global-account/react/components/index.d.ts +8 -6
- package/dist/types/global-account/react/hooks/index.d.ts +1 -1
- package/dist/types/global-account/react/index.native.d.ts +7 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/types/global-account/types/chain-networks.d.ts +34 -34
- package/dist/types/global-account/types/feature-flags.d.ts +5 -5
- package/dist/types/shared/constants/chains/b3Chain.d.ts +1 -1
- package/dist/types/shared/constants/chains/supported.d.ts +8 -7
- package/package.json +26 -24
- package/src/anyspend/index.native.ts +24 -0
- package/src/anyspend/react/components/AnySpend.tsx +6 -5
- package/src/anyspend/react/components/AnySpendBuySpin.tsx +232 -179
- package/src/anyspend/react/components/common/OrderHistoryItem.tsx +5 -1
- package/src/anyspend/react/components/common/TokenBalance.tsx +1 -1
- package/src/anyspend/utils/chain.ts +3 -0
- package/src/global-account/react/components/B3DynamicModal.tsx +1 -1
- package/src/global-account/react/components/{B3Provider.native.tsx → B3Provider/B3Provider.native.tsx} +4 -45
- package/src/global-account/react/components/{B3Provider.tsx → B3Provider/B3Provider.tsx} +4 -53
- package/src/global-account/react/components/B3Provider/types.ts +40 -0
- package/src/global-account/react/components/B3Provider/useB3.ts +17 -0
- package/src/global-account/react/components/StyleRoot.tsx +1 -1
- package/src/global-account/react/components/index.ts +8 -6
- package/src/global-account/react/hooks/index.ts +1 -1
- package/src/global-account/react/hooks/useBestTransactionPath.tsx +3 -3
- package/src/global-account/react/hooks/useTokenBalance.tsx +1 -1
- package/src/global-account/react/index.native.ts +14 -0
- package/src/global-account/react/stores/useModalStore.ts +2 -0
- package/src/shared/constants/chains/supported.ts +12 -4
- package/src/shared/utils/chains.ts +4 -1
- package/src/shared/utils/number.ts +1 -1
- package/dist/cjs/styles/index.d.ts +0 -20
- package/dist/cjs/styles/index.js +0 -22
- package/dist/esm/styles/index.d.ts +0 -20
- package/dist/esm/styles/index.js +0 -20
- package/dist/types/styles/index.d.ts +0 -20
- package/src/styles/index.ts +0 -24
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import {
|
|
3
|
+
import { useState } from "react";
|
|
4
4
|
import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
|
|
5
|
+
import { B3Context } from "./types";
|
|
5
6
|
/**
|
|
6
7
|
* Default permissions configuration for B3 provider
|
|
7
8
|
*/
|
|
@@ -11,31 +12,6 @@ const DEFAULT_PERMISSIONS = {
|
|
|
11
12
|
startDate: new Date(),
|
|
12
13
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365) // 1 year from now
|
|
13
14
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Context for B3 provider
|
|
16
|
-
*/
|
|
17
|
-
export const B3Context = createContext({
|
|
18
|
-
account: undefined,
|
|
19
|
-
user: undefined,
|
|
20
|
-
setAccount: () => { },
|
|
21
|
-
setUser: () => { },
|
|
22
|
-
initialized: false,
|
|
23
|
-
ready: false,
|
|
24
|
-
environment: "development",
|
|
25
|
-
theme: "light"
|
|
26
|
-
});
|
|
27
|
-
/**
|
|
28
|
-
* Hook to access the B3 context
|
|
29
|
-
* @throws Error if used outside a B3Provider
|
|
30
|
-
*/
|
|
31
|
-
export function useB3() {
|
|
32
|
-
const context = useContext(B3Context);
|
|
33
|
-
if (!context.initialized) {
|
|
34
|
-
throw new Error("useB3 must be used within a B3Provider");
|
|
35
|
-
}
|
|
36
|
-
// Return a stable reference
|
|
37
|
-
return useMemo(() => context, [context]);
|
|
38
|
-
}
|
|
39
15
|
// Create queryClient instance
|
|
40
16
|
const queryClient = new QueryClient();
|
|
41
17
|
/**
|
|
@@ -58,6 +34,9 @@ export function InnerProvider({ children, accountOverride, environment, defaultP
|
|
|
58
34
|
};
|
|
59
35
|
return (_jsx(B3Context.Provider, { value: {
|
|
60
36
|
account: effectiveAccount,
|
|
37
|
+
automaticallySetFirstEoa: false,
|
|
38
|
+
setWallet: () => { },
|
|
39
|
+
wallet: undefined,
|
|
61
40
|
setAccount,
|
|
62
41
|
user,
|
|
63
42
|
setUser,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Account } from "thirdweb/wallets";
|
|
2
|
+
import { User } from "../../../../global-account/types/b3-api.types";
|
|
3
|
+
import { Wallet } from "thirdweb/wallets";
|
|
4
|
+
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
5
|
+
/**
|
|
6
|
+
* Context type for B3Provider
|
|
7
|
+
*/
|
|
8
|
+
export interface B3ContextType {
|
|
9
|
+
account?: Account;
|
|
10
|
+
automaticallySetFirstEoa: boolean;
|
|
11
|
+
user?: User;
|
|
12
|
+
setAccount: (account: Account) => void;
|
|
13
|
+
setWallet: (wallet: Wallet) => void;
|
|
14
|
+
wallet?: Wallet;
|
|
15
|
+
setUser: (user?: User) => void;
|
|
16
|
+
initialized: boolean;
|
|
17
|
+
ready: boolean;
|
|
18
|
+
environment?: "development" | "production";
|
|
19
|
+
defaultPermissions?: PermissionsConfig;
|
|
20
|
+
theme: "light" | "dark";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Context for B3 provider
|
|
24
|
+
*/
|
|
25
|
+
export declare const B3Context: import("react").Context<B3ContextType>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Context for B3 provider
|
|
4
|
+
*/
|
|
5
|
+
export const B3Context = createContext({
|
|
6
|
+
account: undefined,
|
|
7
|
+
automaticallySetFirstEoa: false,
|
|
8
|
+
user: undefined,
|
|
9
|
+
setAccount: () => { },
|
|
10
|
+
setWallet: () => { },
|
|
11
|
+
wallet: undefined,
|
|
12
|
+
setUser: () => { },
|
|
13
|
+
initialized: false,
|
|
14
|
+
ready: false,
|
|
15
|
+
environment: "development",
|
|
16
|
+
theme: "light"
|
|
17
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useContext, useMemo } from "react";
|
|
2
|
+
import { B3Context } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access the B3 context
|
|
5
|
+
* @throws Error if used outside a B3Provider
|
|
6
|
+
*/
|
|
7
|
+
export function useB3() {
|
|
8
|
+
const context = useContext(B3Context);
|
|
9
|
+
if (!context.initialized) {
|
|
10
|
+
throw new Error("useB3 must be used within a B3Provider");
|
|
11
|
+
}
|
|
12
|
+
// Return a stable reference
|
|
13
|
+
return useMemo(() => context, [context]);
|
|
14
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useB3 } from "./B3Provider";
|
|
2
|
+
import { useB3 } from "./B3Provider/useB3";
|
|
3
3
|
export function StyleRoot({ children, id }) {
|
|
4
4
|
const { theme: b3Theme } = useB3();
|
|
5
5
|
// eslint-disable-next-line tailwindcss/no-custom-classname
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export { B3DynamicModal } from "./B3DynamicModal";
|
|
2
|
-
export {
|
|
2
|
+
export { B3Provider, InnerProvider } from "./B3Provider/B3Provider";
|
|
3
|
+
export { useB3 } from "./B3Provider/useB3";
|
|
4
|
+
export { B3Context, type B3ContextType } from "./B3Provider/types";
|
|
3
5
|
export { RelayKitProviderWrapper } from "./RelayKitProviderWrapper";
|
|
4
6
|
export { StyleRoot } from "./StyleRoot";
|
|
7
|
+
export { AuthButton } from "./SignInWithB3/components/AuthButton";
|
|
8
|
+
export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
9
|
+
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
5
10
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
6
11
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
7
12
|
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
8
|
-
export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
9
|
-
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
10
|
-
export { AuthButton } from "./SignInWithB3/components/AuthButton";
|
|
11
13
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
12
|
-
export {
|
|
14
|
+
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
13
15
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
14
16
|
export { RequestPermissions } from "./RequestPermissions/RequestPermissions";
|
|
15
17
|
export { RequestPermissionsButton } from "./RequestPermissions/RequestPermissionsButton";
|
|
@@ -34,8 +36,8 @@ export { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
|
|
|
34
36
|
export { ScrollArea, ScrollBar } from "./ui/scroll-area";
|
|
35
37
|
export { ShinyButton } from "./ui/ShinyButton";
|
|
36
38
|
export { Skeleton } from "./ui/skeleton";
|
|
37
|
-
export { Tabs, TabsContent, TabsList, TabsTransitionWrapper, TabTrigger } from "./ui/TabSystem";
|
|
38
39
|
export { TabsContent as TabsContentPrimitive, TabsList as TabsListPrimitive, Tabs as TabsPrimitive, TabTrigger as TabTriggerPrimitive } from "./ui/Tabs";
|
|
40
|
+
export { Tabs, TabsContent, TabsList, TabsTransitionWrapper, TabTrigger } from "./ui/TabSystem";
|
|
39
41
|
export { TextLoop } from "./ui/text-loop";
|
|
40
42
|
export { TextShimmer } from "./ui/text-shimmer";
|
|
41
43
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
// Core Components
|
|
2
2
|
export { B3DynamicModal } from "./B3DynamicModal";
|
|
3
|
-
export {
|
|
3
|
+
export { B3Provider, InnerProvider } from "./B3Provider/B3Provider";
|
|
4
|
+
export { useB3 } from "./B3Provider/useB3";
|
|
5
|
+
export { B3Context } from "./B3Provider/types";
|
|
4
6
|
export { RelayKitProviderWrapper } from "./RelayKitProviderWrapper";
|
|
5
7
|
export { StyleRoot } from "./StyleRoot";
|
|
6
8
|
// SignInWithB3 Components
|
|
9
|
+
export { AuthButton } from "./SignInWithB3/components/AuthButton";
|
|
10
|
+
export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
11
|
+
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
7
12
|
export { SignInWithB3 } from "./SignInWithB3/SignInWithB3";
|
|
8
13
|
export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
9
14
|
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
10
|
-
export { PermissionItem } from "./SignInWithB3/components/PermissionItem";
|
|
11
|
-
export { WalletRow } from "./SignInWithB3/components/WalletRow";
|
|
12
|
-
export { AuthButton } from "./SignInWithB3/components/AuthButton";
|
|
13
15
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
14
16
|
export { getConnectOptionsFromStrategy, isWalletType } from "./SignInWithB3/utils/signInUtils";
|
|
15
17
|
// ManageAccount Components
|
|
@@ -43,8 +45,8 @@ export { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
|
|
|
43
45
|
export { ScrollArea, ScrollBar } from "./ui/scroll-area";
|
|
44
46
|
export { ShinyButton } from "./ui/ShinyButton";
|
|
45
47
|
export { Skeleton } from "./ui/skeleton";
|
|
46
|
-
export { Tabs, TabsContent, TabsList, TabsTransitionWrapper, TabTrigger } from "./ui/TabSystem";
|
|
47
48
|
export { TabsContent as TabsContentPrimitive, TabsList as TabsListPrimitive, Tabs as TabsPrimitive, TabTrigger as TabTriggerPrimitive } from "./ui/Tabs";
|
|
49
|
+
export { Tabs, TabsContent, TabsList, TabsTransitionWrapper, TabTrigger } from "./ui/TabSystem";
|
|
48
50
|
export { TextLoop } from "./ui/text-loop";
|
|
49
51
|
export { TextShimmer } from "./ui/text-shimmer";
|
|
50
52
|
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip";
|
|
@@ -16,7 +16,7 @@ export { useHasMounted } from "./useHasMounted";
|
|
|
16
16
|
export { useIsMobile } from "./useIsMobile";
|
|
17
17
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
18
18
|
export { useMediaQuery } from "./useMediaQuery";
|
|
19
|
-
export { useNativeBalance } from "./useNativeBalance";
|
|
19
|
+
export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
|
|
20
20
|
export { useOnchainName } from "./useOnchainName";
|
|
21
21
|
export { useOneBalance } from "./useOneBalance";
|
|
22
22
|
export { useQueryB3 } from "./useQueryB3";
|
|
@@ -16,7 +16,7 @@ export { useHasMounted } from "./useHasMounted";
|
|
|
16
16
|
export { useIsMobile } from "./useIsMobile";
|
|
17
17
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
|
|
18
18
|
export { useMediaQuery } from "./useMediaQuery";
|
|
19
|
-
export { useNativeBalance } from "./useNativeBalance";
|
|
19
|
+
export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
|
|
20
20
|
export { useOnchainName } from "./useOnchainName";
|
|
21
21
|
export { useOneBalance } from "./useOneBalance";
|
|
22
22
|
export { useQueryB3 } from "./useQueryB3";
|
|
@@ -39,7 +39,7 @@ export function useBestTransactionPath({ amount, token, address, transactionType
|
|
|
39
39
|
// Calculate non-native token balance using the same logic as hasNativeBalance
|
|
40
40
|
const nonNativeTokenBalance = useMemo(() => {
|
|
41
41
|
if (isNativeToken(token.address))
|
|
42
|
-
return
|
|
42
|
+
return BigInt(0);
|
|
43
43
|
// For sprinter supported tokens, use aggregated balances
|
|
44
44
|
if (isSupportedSprinterToken && !oneBalanceLoading && aggregatedBalances) {
|
|
45
45
|
const asset = aggregatedBalances.find(asset => asset.symbol === token.symbol);
|
|
@@ -49,7 +49,7 @@ export function useBestTransactionPath({ amount, token, address, transactionType
|
|
|
49
49
|
return BigInt(chainBalance.balance);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return BigInt(0);
|
|
53
53
|
}
|
|
54
54
|
// For non-sprinter tokens, use token balance from our new hook
|
|
55
55
|
return rawBalance;
|
|
@@ -95,7 +95,7 @@ export function useBestTransactionPath({ amount, token, address, transactionType
|
|
|
95
95
|
}, [isSupportedSprinterToken, oneBalanceLoading, aggregatedBalances, token.symbol, token.chainId, amount]);
|
|
96
96
|
// Determine the best path
|
|
97
97
|
const path = useMemo(() => {
|
|
98
|
-
const availableBalance = (isNativeToken(token.address) ? rawBalance : nonNativeTokenBalance) ||
|
|
98
|
+
const availableBalance = (isNativeToken(token.address) ? rawBalance : nonNativeTokenBalance) || BigInt(0);
|
|
99
99
|
// Case 1: Native path if available
|
|
100
100
|
if (hasNativeBalance) {
|
|
101
101
|
return {
|
|
@@ -53,7 +53,7 @@ export function useTokenBalance({ token, address }) {
|
|
|
53
53
|
// Determine if we're actually loading
|
|
54
54
|
const isActuallyLoading = !ready || !effectiveAddress || isLoading || (isFetching && !tokenBalance);
|
|
55
55
|
return {
|
|
56
|
-
rawBalance: tokenBalance?.raw ||
|
|
56
|
+
rawBalance: tokenBalance?.raw || BigInt(0),
|
|
57
57
|
formattedBalance: tokenBalance?.formatted || "0",
|
|
58
58
|
isLoading: isActuallyLoading
|
|
59
59
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { B3Provider } from "./components/B3Provider/B3Provider.native";
|
|
2
|
+
export { useB3 } from "./components/B3Provider/useB3";
|
|
3
|
+
export { B3Context, type B3ContextType } from "./components/B3Provider/types";
|
|
4
|
+
export { useAccountWallet } from "./hooks/useAccountWallet";
|
|
5
|
+
export { useAuthentication } from "./hooks/useAuthentication";
|
|
6
|
+
export { useSiwe } from "./hooks/useSiwe";
|
|
7
|
+
export { useAuthStore } from "./stores/useAuthStore";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// export * from "./components";
|
|
2
|
+
// export * from "./hooks";
|
|
3
|
+
// export * from "./stores";
|
|
4
|
+
// We only export the components and hooks that are needed for the native app
|
|
5
|
+
export { B3Provider } from "./components/B3Provider/B3Provider.native";
|
|
6
|
+
export { useB3 } from "./components/B3Provider/useB3";
|
|
7
|
+
export { B3Context } from "./components/B3Provider/types";
|
|
8
|
+
export { useAccountWallet } from "./hooks/useAccountWallet";
|
|
9
|
+
export { useAuthentication } from "./hooks/useAuthentication";
|
|
10
|
+
export { useSiwe } from "./hooks/useSiwe";
|
|
11
|
+
export { useAuthStore } from "./stores/useAuthStore";
|
|
@@ -231,6 +231,8 @@ export interface AnySpendBuySpinProps extends BaseModalProps {
|
|
|
231
231
|
recipientAddress: string;
|
|
232
232
|
/** Callback function called when the spin purchase is successful */
|
|
233
233
|
onSuccess?: (txHash?: string) => void;
|
|
234
|
+
/** Prefill quantity of spins to purchase */
|
|
235
|
+
prefillQuantity?: string;
|
|
234
236
|
}
|
|
235
237
|
/**
|
|
236
238
|
* Union type of all possible modal content types
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { Static } from "@feathersjs/typebox";
|
|
2
|
-
export declare const chainNetworksSchema: import("@
|
|
3
|
-
_id: import("@
|
|
4
|
-
id: import("@
|
|
5
|
-
name: import("@
|
|
6
|
-
rpcUrls: import("@
|
|
7
|
-
default: import("@
|
|
8
|
-
http: import("@
|
|
9
|
-
ws: import("@
|
|
2
|
+
export declare const chainNetworksSchema: import("@feathersjs/typebox").TObject<{
|
|
3
|
+
_id: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{}>]>;
|
|
4
|
+
id: import("@feathersjs/typebox").TInteger;
|
|
5
|
+
name: import("@feathersjs/typebox").TString<string>;
|
|
6
|
+
rpcUrls: import("@feathersjs/typebox").TObject<{
|
|
7
|
+
default: import("@feathersjs/typebox").TObject<{
|
|
8
|
+
http: import("@feathersjs/typebox").TString<"uri">;
|
|
9
|
+
ws: import("@feathersjs/typebox").TString<"uri">;
|
|
10
10
|
}>;
|
|
11
|
-
backups: import("@
|
|
12
|
-
type: import("@
|
|
13
|
-
uri: import("@
|
|
11
|
+
backups: import("@feathersjs/typebox").TArray<import("@feathersjs/typebox").TObject<{
|
|
12
|
+
type: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TLiteral<"http">, import("@feathersjs/typebox").TLiteral<"ws">]>;
|
|
13
|
+
uri: import("@feathersjs/typebox").TString<string>;
|
|
14
14
|
}>>;
|
|
15
15
|
}>;
|
|
16
|
-
icon: import("@
|
|
17
|
-
url: import("@
|
|
18
|
-
width: import("@
|
|
19
|
-
height: import("@
|
|
20
|
-
format: import("@
|
|
16
|
+
icon: import("@feathersjs/typebox").TObject<{
|
|
17
|
+
url: import("@feathersjs/typebox").TString<"uri">;
|
|
18
|
+
width: import("@feathersjs/typebox").TInteger;
|
|
19
|
+
height: import("@feathersjs/typebox").TInteger;
|
|
20
|
+
format: import("@feathersjs/typebox").TString<string>;
|
|
21
21
|
}>;
|
|
22
|
-
blockExplorers: import("@
|
|
23
|
-
explorerTitle: import("@
|
|
24
|
-
default: import("@
|
|
22
|
+
blockExplorers: import("@feathersjs/typebox").TObject<{
|
|
23
|
+
explorerTitle: import("@feathersjs/typebox").TString<string>;
|
|
24
|
+
default: import("@feathersjs/typebox").TString<"uri">;
|
|
25
25
|
}>;
|
|
26
|
-
nativeCurrency: import("@
|
|
27
|
-
name: import("@
|
|
28
|
-
symbol: import("@
|
|
29
|
-
decimals: import("@
|
|
26
|
+
nativeCurrency: import("@feathersjs/typebox").TObject<{
|
|
27
|
+
name: import("@feathersjs/typebox").TString<string>;
|
|
28
|
+
symbol: import("@feathersjs/typebox").TString<string>;
|
|
29
|
+
decimals: import("@feathersjs/typebox").TInteger;
|
|
30
30
|
}>;
|
|
31
|
-
testnet: import("@
|
|
32
|
-
testnetConfigID: import("@
|
|
33
|
-
sourceId: import("@
|
|
34
|
-
contracts: import("@
|
|
35
|
-
address: import("@
|
|
36
|
-
blockCreated: import("@
|
|
31
|
+
testnet: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TBoolean>;
|
|
32
|
+
testnetConfigID: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
|
|
33
|
+
sourceId: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
|
|
34
|
+
contracts: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{
|
|
35
|
+
address: import("@feathersjs/typebox").TString<string>;
|
|
36
|
+
blockCreated: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TInteger>;
|
|
37
37
|
}>>>;
|
|
38
|
-
formatters: import("@
|
|
39
|
-
fees: import("@
|
|
40
|
-
badge: import("@
|
|
41
|
-
color: import("@
|
|
42
|
-
enabledFeatures: import("@
|
|
38
|
+
formatters: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TAny>>;
|
|
39
|
+
fees: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TRecord<import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TAny>>;
|
|
40
|
+
badge: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TString<"uri">>;
|
|
41
|
+
color: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TString<string>>;
|
|
42
|
+
enabledFeatures: import("@feathersjs/typebox").TOptional<import("@feathersjs/typebox").TArray<import("@feathersjs/typebox").TString<string>>>;
|
|
43
43
|
}>;
|
|
44
44
|
export type ChainNetworks = Static<typeof chainNetworksSchema>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Static } from "@feathersjs/typebox";
|
|
2
|
-
export declare const featureFlagsSchema: import("@
|
|
3
|
-
_id: import("@
|
|
4
|
-
id: import("@
|
|
5
|
-
enabled: import("@
|
|
6
|
-
description: import("@
|
|
2
|
+
export declare const featureFlagsSchema: import("@feathersjs/typebox").TObject<{
|
|
3
|
+
_id: import("@feathersjs/typebox").TUnion<[import("@feathersjs/typebox").TString<string>, import("@feathersjs/typebox").TObject<{}>]>;
|
|
4
|
+
id: import("@feathersjs/typebox").TString<string>;
|
|
5
|
+
enabled: import("@feathersjs/typebox").TBoolean;
|
|
6
|
+
description: import("@feathersjs/typebox").TString<string>;
|
|
7
7
|
}>;
|
|
8
8
|
export type FeatureFlags = Static<typeof featureFlagsSchema>;
|
|
@@ -10,9 +10,9 @@ export declare const supportedChainNetworks: {
|
|
|
10
10
|
testnet?: boolean | undefined;
|
|
11
11
|
fees?: Record<string, any> | undefined;
|
|
12
12
|
formatters?: Record<string, any> | undefined;
|
|
13
|
+
color?: string | undefined;
|
|
13
14
|
testnetConfigID?: number | undefined;
|
|
14
15
|
badge?: string | undefined;
|
|
15
|
-
color?: string | undefined;
|
|
16
16
|
enabledFeatures?: string[] | undefined;
|
|
17
17
|
name: string;
|
|
18
18
|
id: number;
|
|
@@ -35,19 +35,20 @@ export declare const supportedChainNetworks: {
|
|
|
35
35
|
uri: string;
|
|
36
36
|
}[];
|
|
37
37
|
};
|
|
38
|
-
_id: string | {};
|
|
39
38
|
icon: {
|
|
40
39
|
format: string;
|
|
41
40
|
url: string;
|
|
42
|
-
width: number;
|
|
43
41
|
height: number;
|
|
42
|
+
width: number;
|
|
44
43
|
};
|
|
44
|
+
_id: string | {};
|
|
45
45
|
}[];
|
|
46
|
-
export declare const b3Mainnet: import("viem").Chain
|
|
47
|
-
export declare const b3Testnet: import("viem").Chain
|
|
46
|
+
export declare const b3Mainnet: import("viem").Chain;
|
|
47
|
+
export declare const b3Testnet: import("viem").Chain;
|
|
48
|
+
export declare const baseMainnet: import("viem").Chain | undefined;
|
|
48
49
|
export declare const b3MainnetThirdWeb: Readonly<import("thirdweb/dist/types/chains/types").ChainOptions & {
|
|
49
50
|
rpc: string;
|
|
50
|
-
}
|
|
51
|
+
}>;
|
|
51
52
|
export declare const b3TestnetThirdWeb: Readonly<import("thirdweb/dist/types/chains/types").ChainOptions & {
|
|
52
53
|
rpc: string;
|
|
53
|
-
}
|
|
54
|
+
}>;
|
|
@@ -2,6 +2,7 @@ import { toThirdwebChain, toViemChain } from "../../../shared/utils/chain-transf
|
|
|
2
2
|
// Import the JSON directly
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import chainNetworksJSON from "../../../generated/chain-networks.json" with { type: "json" };
|
|
5
|
+
import invariant from "invariant";
|
|
5
6
|
const chainNetworks = chainNetworksJSON;
|
|
6
7
|
// Convert custom chains to Viem format
|
|
7
8
|
const viemChains = chainNetworks.map(toViemChain);
|
|
@@ -20,6 +21,12 @@ export const supportedChainsTW = [
|
|
|
20
21
|
// Original format from chain-networks.json
|
|
21
22
|
export const supportedChainNetworks = chainNetworks;
|
|
22
23
|
export const b3Mainnet = supportedChains.find(chain => chain.id === 8333);
|
|
24
|
+
invariant(b3Mainnet, "B3 mainnet chain not found in supported chains");
|
|
23
25
|
export const b3Testnet = supportedChains.find(chain => chain.id === 1993);
|
|
26
|
+
invariant(b3Testnet, "B3 testnet chain not found in supported chains");
|
|
27
|
+
export const baseMainnet = supportedChains.find(chain => chain.id === 8453);
|
|
28
|
+
invariant(baseMainnet, "Base mainnet chain not found in supported chains");
|
|
24
29
|
export const b3MainnetThirdWeb = supportedChainsTW.find(chain => chain.id === 8333);
|
|
30
|
+
invariant(b3MainnetThirdWeb, "B3 mainnet chain not found in supported chains TW");
|
|
25
31
|
export const b3TestnetThirdWeb = supportedChainsTW.find(chain => chain.id === 1993);
|
|
32
|
+
invariant(b3TestnetThirdWeb, "B3 testnet chain not found in supported chains TW");
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { supportedChains } from "../../shared/constants/chains/supported";
|
|
2
|
+
import { b3 } from "viem/chains";
|
|
2
3
|
const baseChainBaseUrl = "https://basescan.org";
|
|
3
4
|
export function getChainById(id) {
|
|
4
5
|
return Object.values(supportedChains).find(chain => chain.id === id);
|
|
@@ -8,6 +9,9 @@ export function chainIdToName(id) {
|
|
|
8
9
|
return name === "Base Mainnet" ? "Base" : name === "The Open Network" ? "Open Network" : name;
|
|
9
10
|
}
|
|
10
11
|
export function getExplorerUrl(chain, txHash) {
|
|
12
|
+
if (chain.id === b3.id) {
|
|
13
|
+
return "https://explorer.b3.fun/b3/tx/" + txHash;
|
|
14
|
+
}
|
|
11
15
|
let baseUrl = chain.blockExplorers?.default.url;
|
|
12
16
|
if (chain.id === 8453) {
|
|
13
17
|
baseUrl = baseChainBaseUrl;
|
|
@@ -18,7 +18,7 @@ export function divideBigIntToString(numerator, denominator, decimalPlaces) {
|
|
|
18
18
|
let remainder = numerator % denominator;
|
|
19
19
|
let decimalStr = "";
|
|
20
20
|
for (let i = 0; i < decimalPlaces; i++) {
|
|
21
|
-
remainder *=
|
|
21
|
+
remainder *= BigInt(10);
|
|
22
22
|
const digit = remainder / denominator;
|
|
23
23
|
decimalStr += digit.toString();
|
|
24
24
|
remainder %= denominator;
|