@b3dotfun/sdk 0.0.47 → 0.0.48-alpha.1
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 +225 -6
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +5 -3
- package/dist/cjs/anyspend/types/chain.d.ts +2 -1
- package/dist/cjs/anyspend/utils/chain.js +4 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +15 -64
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +26 -21
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +2 -0
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +6 -22
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +10 -45
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -1
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +141 -81
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -1
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +86 -0
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +42 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/cjs/notifications/index.d.ts +3 -0
- package/dist/cjs/notifications/index.js +25 -0
- package/dist/cjs/notifications/react/hooks/index.d.ts +1 -0
- package/dist/cjs/notifications/react/hooks/index.js +17 -0
- package/dist/cjs/notifications/react/hooks/useNotifications.d.ts +42 -0
- package/dist/cjs/notifications/react/hooks/useNotifications.js +148 -0
- package/dist/cjs/notifications/react/index.d.ts +1 -0
- package/dist/cjs/notifications/react/index.js +17 -0
- package/dist/cjs/notifications/services/api.d.ts +67 -0
- package/dist/cjs/notifications/services/api.js +184 -0
- package/dist/cjs/notifications/services/index.d.ts +1 -0
- package/dist/cjs/notifications/services/index.js +17 -0
- package/dist/cjs/notifications/types/index.d.ts +51 -0
- package/dist/cjs/notifications/types/index.js +2 -0
- package/dist/cjs/shared/utils/auth-token.d.ts +7 -0
- package/dist/cjs/shared/utils/auth-token.js +17 -0
- package/dist/cjs/shared/utils/index.d.ts +1 -0
- package/dist/cjs/shared/utils/index.js +1 -0
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -3
- package/dist/esm/anyspend/types/chain.d.ts +2 -1
- package/dist/esm/anyspend/utils/chain.js +4 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +19 -68
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +24 -19
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +2 -0
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +7 -23
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +4 -3
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +11 -46
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +144 -84
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +3 -2
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.js +83 -0
- package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/esm/global-account/react/hooks/useWagmiConfig.js +39 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/esm/notifications/index.d.ts +3 -0
- package/dist/esm/notifications/index.js +7 -0
- package/dist/esm/notifications/react/hooks/index.d.ts +1 -0
- package/dist/esm/notifications/react/hooks/index.js +1 -0
- package/dist/esm/notifications/react/hooks/useNotifications.d.ts +42 -0
- package/dist/esm/notifications/react/hooks/useNotifications.js +145 -0
- package/dist/esm/notifications/react/index.d.ts +1 -0
- package/dist/esm/notifications/react/index.js +1 -0
- package/dist/esm/notifications/services/api.d.ts +67 -0
- package/dist/esm/notifications/services/api.js +179 -0
- package/dist/esm/notifications/services/index.d.ts +1 -0
- package/dist/esm/notifications/services/index.js +1 -0
- package/dist/esm/notifications/types/index.d.ts +51 -0
- package/dist/esm/shared/utils/auth-token.d.ts +7 -0
- package/dist/esm/shared/utils/auth-token.js +11 -0
- package/dist/esm/shared/utils/index.d.ts +1 -0
- package/dist/esm/shared/utils/index.js +1 -0
- package/dist/types/anyspend/types/chain.d.ts +2 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -2
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +2 -0
- package/dist/types/global-account/react/components/ManageAccount/BalanceContent.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +1 -2
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +1 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +51 -2
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +58 -0
- package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +13 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/types/notifications/index.d.ts +3 -0
- package/dist/types/notifications/react/hooks/index.d.ts +1 -0
- package/dist/types/notifications/react/hooks/useNotifications.d.ts +42 -0
- package/dist/types/notifications/react/index.d.ts +1 -0
- package/dist/types/notifications/services/api.d.ts +67 -0
- package/dist/types/notifications/services/index.d.ts +1 -0
- package/dist/types/notifications/types/index.d.ts +51 -0
- package/dist/types/shared/utils/auth-token.d.ts +7 -0
- package/dist/types/shared/utils/index.d.ts +1 -0
- package/package.json +23 -3
- package/src/anyspend/react/components/AnySpendCustom.tsx +5 -3
- package/src/anyspend/types/chain.ts +2 -1
- package/src/anyspend/utils/chain.ts +4 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +51 -35
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +28 -72
- package/src/global-account/react/components/B3Provider/types.ts +4 -0
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +2 -3
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +4 -23
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +4 -3
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +8 -46
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
- package/src/global-account/react/hooks/useAuthentication.ts +170 -89
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +3 -2
- package/src/global-account/react/hooks/useUserQuery.ts +95 -0
- package/src/global-account/react/hooks/useWagmiConfig.tsx +44 -0
- package/src/global-account/react/stores/useModalStore.ts +0 -2
- package/src/notifications/index.ts +9 -0
- package/src/notifications/react/hooks/index.ts +1 -0
- package/src/notifications/react/hooks/useNotifications.ts +153 -0
- package/src/notifications/react/index.ts +1 -0
- package/src/notifications/services/api.ts +217 -0
- package/src/notifications/services/index.ts +1 -0
- package/src/notifications/types/index.ts +58 -0
- package/src/shared/utils/auth-token.ts +13 -0
- package/src/shared/utils/index.ts +1 -0
- package/dist/cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -245
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
- package/dist/esm/shared/react/hooks/__tests__/useCurrencyConversion.test.js +0 -243
- package/dist/types/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts +0 -1
- /package/dist/{cjs/shared/react/hooks/__tests__/useCurrencyConversion.test.d.ts → esm/notifications/types/index.js} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Wallet } from "thirdweb/wallets";
|
|
1
2
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
2
|
-
export declare function useAuthentication(partnerId: string
|
|
3
|
+
export declare function useAuthentication(partnerId: string): {
|
|
3
4
|
logout: (callback?: () => void) => Promise<void>;
|
|
4
5
|
isAuthenticated: boolean;
|
|
5
6
|
isReady: boolean;
|
|
@@ -7,6 +8,54 @@ export declare function useAuthentication(partnerId: string, loginWithSiwe?: boo
|
|
|
7
8
|
isConnected: boolean;
|
|
8
9
|
wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
|
|
9
10
|
preAuthenticate: typeof preAuthenticate;
|
|
10
|
-
connect: (
|
|
11
|
+
connect: (wallet: Wallet) => Promise<void>;
|
|
11
12
|
isAuthenticating: boolean;
|
|
13
|
+
onConnect: (wallet: Wallet) => Promise<void>;
|
|
14
|
+
user: {
|
|
15
|
+
email?: string | undefined;
|
|
16
|
+
username?: string | undefined;
|
|
17
|
+
telNumber?: string | undefined;
|
|
18
|
+
ens?: string | undefined;
|
|
19
|
+
avatar?: string | undefined;
|
|
20
|
+
preferences?: {} | undefined;
|
|
21
|
+
referredBy?: string | {} | undefined;
|
|
22
|
+
sourceApp?: string | undefined;
|
|
23
|
+
referralCode?: string | undefined;
|
|
24
|
+
userGroups?: number[] | undefined;
|
|
25
|
+
isMigratedFromBSMNT?: boolean | undefined;
|
|
26
|
+
privyLinkedAccounts?: {
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
address?: string | undefined;
|
|
29
|
+
email?: string | undefined;
|
|
30
|
+
chain_type?: string | undefined;
|
|
31
|
+
lv?: number | undefined;
|
|
32
|
+
wallet_client_type?: string | undefined;
|
|
33
|
+
smart_wallet_type?: string | undefined;
|
|
34
|
+
subject?: string | undefined;
|
|
35
|
+
type: string;
|
|
36
|
+
}[] | undefined;
|
|
37
|
+
twProfiles?: {
|
|
38
|
+
type: string;
|
|
39
|
+
details: {
|
|
40
|
+
id?: string | undefined;
|
|
41
|
+
name?: string | undefined;
|
|
42
|
+
address?: string | undefined;
|
|
43
|
+
email?: string | undefined;
|
|
44
|
+
phone?: string | undefined;
|
|
45
|
+
username?: string | undefined;
|
|
46
|
+
fid?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
}[] | undefined;
|
|
49
|
+
_id: string | {};
|
|
50
|
+
userId: string;
|
|
51
|
+
smartAccountAddress: string;
|
|
52
|
+
createdAt: number;
|
|
53
|
+
updatedAt: number;
|
|
54
|
+
partnerIds: {
|
|
55
|
+
privyId?: string | undefined;
|
|
56
|
+
thirdwebId?: string | undefined;
|
|
57
|
+
};
|
|
58
|
+
} | undefined;
|
|
59
|
+
refetchUser: (wallet?: Wallet) => Promise<void>;
|
|
60
|
+
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
12
61
|
};
|
|
@@ -4,7 +4,7 @@ import { Account } from "thirdweb/wallets";
|
|
|
4
4
|
* This essentially wraps our useConnect hook to handle the Privy auth flow.
|
|
5
5
|
* Currently, this is for the basement-privy strategy
|
|
6
6
|
*/
|
|
7
|
-
export declare function useHandleConnectWithPrivy(
|
|
7
|
+
export declare function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void): {
|
|
8
8
|
connectTw: () => Promise<import("thirdweb/wallets").Wallet | null | undefined>;
|
|
9
9
|
isLoading: boolean;
|
|
10
10
|
fullToken: string | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
2
|
+
/**
|
|
3
|
+
* NOTE: THIS IS ONLY MEANT FOR INTERNAL USE, from useOnConnect
|
|
4
|
+
*
|
|
5
|
+
* Custom hook to manage user state with react-query
|
|
6
|
+
* This allows for invalidation and refetching of user data
|
|
7
|
+
*/
|
|
8
|
+
export declare function useUserQuery(): {
|
|
9
|
+
user: {
|
|
10
|
+
email?: string | undefined;
|
|
11
|
+
username?: string | undefined;
|
|
12
|
+
telNumber?: string | undefined;
|
|
13
|
+
ens?: string | undefined;
|
|
14
|
+
avatar?: string | undefined;
|
|
15
|
+
preferences?: {} | undefined;
|
|
16
|
+
referredBy?: string | {} | undefined;
|
|
17
|
+
sourceApp?: string | undefined;
|
|
18
|
+
referralCode?: string | undefined;
|
|
19
|
+
userGroups?: number[] | undefined;
|
|
20
|
+
isMigratedFromBSMNT?: boolean | undefined;
|
|
21
|
+
privyLinkedAccounts?: {
|
|
22
|
+
name?: string | undefined;
|
|
23
|
+
address?: string | undefined;
|
|
24
|
+
email?: string | undefined;
|
|
25
|
+
chain_type?: string | undefined;
|
|
26
|
+
lv?: number | undefined;
|
|
27
|
+
wallet_client_type?: string | undefined;
|
|
28
|
+
smart_wallet_type?: string | undefined;
|
|
29
|
+
subject?: string | undefined;
|
|
30
|
+
type: string;
|
|
31
|
+
}[] | undefined;
|
|
32
|
+
twProfiles?: {
|
|
33
|
+
type: string;
|
|
34
|
+
details: {
|
|
35
|
+
id?: string | undefined;
|
|
36
|
+
name?: string | undefined;
|
|
37
|
+
address?: string | undefined;
|
|
38
|
+
email?: string | undefined;
|
|
39
|
+
phone?: string | undefined;
|
|
40
|
+
username?: string | undefined;
|
|
41
|
+
fid?: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
}[] | undefined;
|
|
44
|
+
_id: string | {};
|
|
45
|
+
userId: string;
|
|
46
|
+
smartAccountAddress: string;
|
|
47
|
+
createdAt: number;
|
|
48
|
+
updatedAt: number;
|
|
49
|
+
partnerIds: {
|
|
50
|
+
privyId?: string | undefined;
|
|
51
|
+
thirdwebId?: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
} | undefined;
|
|
54
|
+
setUser: (newUser?: Users) => void;
|
|
55
|
+
refetchUser: () => Promise<void>;
|
|
56
|
+
clearUser: () => void;
|
|
57
|
+
queryKey: string[];
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function useWagmiConfig(partnerId: string, rpcUrls?: Record<number, string>): import("wagmi").Config<readonly [import("viem").Chain, ...import("viem").Chain[]], {
|
|
2
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
3
|
+
}, readonly [import("wagmi").CreateConnectorFn<import("thirdweb/dist/types/adapters/eip1193").EIP1193Provider | undefined, {
|
|
4
|
+
connect<withCapabilities extends boolean = false>(parameters?: import("@thirdweb-dev/wagmi-adapter").ConnectionOptions<withCapabilities> | undefined): Promise<{
|
|
5
|
+
accounts: withCapabilities extends true ? readonly {
|
|
6
|
+
address: `0x${string}`;
|
|
7
|
+
capabilities: Record<string, unknown>;
|
|
8
|
+
}[] : readonly `0x${string}`[];
|
|
9
|
+
chainId: number;
|
|
10
|
+
}>;
|
|
11
|
+
}, {
|
|
12
|
+
"thirdweb:lastChainId": number;
|
|
13
|
+
}>]>;
|
|
@@ -32,8 +32,6 @@ export interface SignInWithB3ModalProps extends BaseModalProps {
|
|
|
32
32
|
sessionKeyAddress?: Address;
|
|
33
33
|
/** Unique identifier for the partner application */
|
|
34
34
|
partnerId: string;
|
|
35
|
-
/** Whether to authenticate with Sign In With Ethereum */
|
|
36
|
-
loginWithSiwe?: boolean;
|
|
37
35
|
/** Whether to close the modal after successful login */
|
|
38
36
|
closeAfterLogin?: boolean;
|
|
39
37
|
/** Source of the sign-in request */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useNotifications";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { UserData } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* React hook for managing B3 notifications
|
|
4
|
+
* Automatically uses the authenticated user's ID from JWT
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { useNotifications } from '@b3dotfun/sdk/notifications/react';
|
|
9
|
+
*
|
|
10
|
+
* function NotificationSettings() {
|
|
11
|
+
* const { user, loading, connectEmail, connectTelegram, isEmailConnected } = useNotifications();
|
|
12
|
+
*
|
|
13
|
+
* if (loading) return <div>Loading...</div>;
|
|
14
|
+
*
|
|
15
|
+
* return (
|
|
16
|
+
* <div>
|
|
17
|
+
* {!isEmailConnected && (
|
|
18
|
+
* <button onClick={() => connectEmail('user@example.com')}>
|
|
19
|
+
* Connect Email
|
|
20
|
+
* </button>
|
|
21
|
+
* )}
|
|
22
|
+
* <button onClick={connectTelegram}>Connect Telegram</button>
|
|
23
|
+
* </div>
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useNotifications(): {
|
|
29
|
+
user: UserData | null;
|
|
30
|
+
loading: boolean;
|
|
31
|
+
error: Error | null;
|
|
32
|
+
refresh: () => Promise<void>;
|
|
33
|
+
connectEmail: (email: string) => Promise<void>;
|
|
34
|
+
connectTelegram: () => Promise<void>;
|
|
35
|
+
updateChannel: (channelId: string, updates: {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
deleteChannel: (channelId: string) => Promise<void>;
|
|
39
|
+
isEmailConnected: boolean;
|
|
40
|
+
isTelegramConnected: boolean;
|
|
41
|
+
isDiscordConnected: boolean;
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./hooks";
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { NotificationHistory, NotificationPreferences, SendNotificationRequest, TelegramLinkResponse, TelegramStatusResponse, UserData } from "../types";
|
|
2
|
+
export declare function setApiUrl(url: string): void;
|
|
3
|
+
export declare function getApiUrl(): string;
|
|
4
|
+
export declare const notificationsAPI: {
|
|
5
|
+
/**
|
|
6
|
+
* Register the current user (userId extracted from JWT)
|
|
7
|
+
*/
|
|
8
|
+
registerUser(): Promise<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Get current user's profile and preferences
|
|
11
|
+
*/
|
|
12
|
+
getUser(): Promise<UserData>;
|
|
13
|
+
/**
|
|
14
|
+
* Get current user's notification history
|
|
15
|
+
*/
|
|
16
|
+
getHistory(appId?: string, limit?: number): Promise<NotificationHistory[]>;
|
|
17
|
+
/**
|
|
18
|
+
* Add a notification channel for current user
|
|
19
|
+
*/
|
|
20
|
+
addChannel(channelType: string, channelIdentifier: string, metadata?: Record<string, any>): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Connect email for current user
|
|
23
|
+
*/
|
|
24
|
+
connectEmail(email: string): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Update a notification channel
|
|
27
|
+
*/
|
|
28
|
+
updateChannel(channelId: string, updates: {
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
channelIdentifier?: string;
|
|
31
|
+
metadata?: Record<string, any>;
|
|
32
|
+
}): Promise<any>;
|
|
33
|
+
/**
|
|
34
|
+
* Delete a notification channel
|
|
35
|
+
*/
|
|
36
|
+
deleteChannel(channelId: string): Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* Get Telegram deep link for current user
|
|
39
|
+
*/
|
|
40
|
+
getTelegramLink(): Promise<TelegramLinkResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Check current user's Telegram connection status
|
|
43
|
+
*/
|
|
44
|
+
checkTelegramStatus(): Promise<TelegramStatusResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Save notification preferences for an app
|
|
47
|
+
* @param appId - The application ID
|
|
48
|
+
* @param settings - Notification preferences including channels, type, and enabled status (defaults to true)
|
|
49
|
+
*/
|
|
50
|
+
savePreferences(appId: string, settings: NotificationPreferences): Promise<any>;
|
|
51
|
+
/**
|
|
52
|
+
* Get notification settings for an app
|
|
53
|
+
*/
|
|
54
|
+
getAppSettings(appId: string): Promise<any>;
|
|
55
|
+
/**
|
|
56
|
+
* Get current user's in-app notifications
|
|
57
|
+
*/
|
|
58
|
+
getInAppNotifications(): Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* Mark a notification as read
|
|
61
|
+
*/
|
|
62
|
+
markNotificationAsRead(notificationId: string): Promise<any>;
|
|
63
|
+
/**
|
|
64
|
+
* Send a notification (requires auth)
|
|
65
|
+
*/
|
|
66
|
+
sendNotification(data: SendNotificationRequest): Promise<any>;
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./api";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type ChannelType = "email" | "telegram" | "discord" | "sms" | "whatsapp" | "in_app";
|
|
2
|
+
export interface NotificationChannel {
|
|
3
|
+
id: number;
|
|
4
|
+
channel_type: ChannelType;
|
|
5
|
+
enabled: number;
|
|
6
|
+
channel_identifier: string;
|
|
7
|
+
}
|
|
8
|
+
export interface UserData {
|
|
9
|
+
user: {
|
|
10
|
+
id: number;
|
|
11
|
+
user_id: string;
|
|
12
|
+
};
|
|
13
|
+
channels: NotificationChannel[];
|
|
14
|
+
appSettings: Array<{
|
|
15
|
+
app_id: string;
|
|
16
|
+
notification_type: string;
|
|
17
|
+
enabled: number;
|
|
18
|
+
channels: string;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
export interface NotificationHistory {
|
|
22
|
+
id: string;
|
|
23
|
+
app_id: string;
|
|
24
|
+
notification_type: string;
|
|
25
|
+
title: string;
|
|
26
|
+
message: string;
|
|
27
|
+
created_at: string;
|
|
28
|
+
read: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface TelegramLinkResponse {
|
|
31
|
+
deepLink: string;
|
|
32
|
+
verificationCode: string;
|
|
33
|
+
botUsername: string;
|
|
34
|
+
}
|
|
35
|
+
export interface TelegramStatusResponse {
|
|
36
|
+
connected: boolean;
|
|
37
|
+
chatId?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface NotificationPreferences {
|
|
40
|
+
notificationType: string;
|
|
41
|
+
channels: string[];
|
|
42
|
+
enabled?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface SendNotificationRequest {
|
|
45
|
+
userId: string;
|
|
46
|
+
appId: string;
|
|
47
|
+
notificationType: string;
|
|
48
|
+
message: string;
|
|
49
|
+
title?: string;
|
|
50
|
+
data?: Record<string, any>;
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b3dotfun/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.48-alpha.1",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"react-native": "./dist/cjs/index.native.js",
|
|
@@ -170,6 +170,26 @@
|
|
|
170
170
|
"import": "./dist/esm/global-account/server.js",
|
|
171
171
|
"require": "./dist/cjs/global-account/server.js"
|
|
172
172
|
},
|
|
173
|
+
"./notifications": {
|
|
174
|
+
"types": "./dist/types/notifications/index.d.ts",
|
|
175
|
+
"import": "./dist/esm/notifications/index.js",
|
|
176
|
+
"require": "./dist/cjs/notifications/index.js"
|
|
177
|
+
},
|
|
178
|
+
"./notifications/react": {
|
|
179
|
+
"types": "./dist/types/notifications/react/index.d.ts",
|
|
180
|
+
"import": "./dist/esm/notifications/react/index.js",
|
|
181
|
+
"require": "./dist/cjs/notifications/react/index.js"
|
|
182
|
+
},
|
|
183
|
+
"./notifications/services": {
|
|
184
|
+
"types": "./dist/types/notifications/services/index.d.ts",
|
|
185
|
+
"import": "./dist/esm/notifications/services/index.js",
|
|
186
|
+
"require": "./dist/cjs/notifications/services/index.js"
|
|
187
|
+
},
|
|
188
|
+
"./notifications/types": {
|
|
189
|
+
"types": "./dist/types/notifications/types/index.d.ts",
|
|
190
|
+
"import": "./dist/esm/notifications/types/index.js",
|
|
191
|
+
"require": "./dist/cjs/notifications/types/index.js"
|
|
192
|
+
},
|
|
173
193
|
"./shared/utils": {
|
|
174
194
|
"types": "./dist/types/shared/utils/index.d.ts",
|
|
175
195
|
"import": "./dist/esm/shared/utils/index.js",
|
|
@@ -281,7 +301,7 @@
|
|
|
281
301
|
"@solana/web3.js": "^1.98.2",
|
|
282
302
|
"@stripe/react-stripe-js": "^3.7.0",
|
|
283
303
|
"@stripe/stripe-js": "^7.3.1",
|
|
284
|
-
"@thirdweb-dev/wagmi-adapter": "
|
|
304
|
+
"@thirdweb-dev/wagmi-adapter": "0.2.159",
|
|
285
305
|
"@web3icons/react": "3.16.0",
|
|
286
306
|
"big.js": "^7.0.1",
|
|
287
307
|
"class-variance-authority": "0.7.0",
|
|
@@ -354,7 +374,7 @@
|
|
|
354
374
|
"react": "^18.0.0 || ^19.0.0",
|
|
355
375
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
356
376
|
"react-native-mmkv": "^3.2.0",
|
|
357
|
-
"thirdweb": "5.
|
|
377
|
+
"thirdweb": "5.108.9",
|
|
358
378
|
"three": "^0.175.0",
|
|
359
379
|
"viem": "^2.28.1",
|
|
360
380
|
"wagmi": "^2.14.15"
|
|
@@ -395,11 +395,13 @@ function AnySpendCustomInner({
|
|
|
395
395
|
useEffect(() => {
|
|
396
396
|
if (oat?.data?.order.status === "executed" && !onSuccessCalled.current) {
|
|
397
397
|
console.log("Calling onSuccess");
|
|
398
|
-
const
|
|
398
|
+
const relayTxs = oat?.data?.relayTxs;
|
|
399
|
+
const lastRelayTxHash = relayTxs?.[relayTxs.length - 1]?.txHash;
|
|
400
|
+
const txHash = oat?.data?.executeTx?.txHash || lastRelayTxHash;
|
|
399
401
|
onSuccess?.(txHash);
|
|
400
402
|
onSuccessCalled.current = true;
|
|
401
403
|
}
|
|
402
|
-
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, onSuccess]);
|
|
404
|
+
}, [oat?.data?.order.status, oat?.data?.executeTx?.txHash, oat?.data?.relayTxs, onSuccess]);
|
|
403
405
|
|
|
404
406
|
// Reset flag when orderId changes
|
|
405
407
|
useEffect(() => {
|
|
@@ -665,7 +667,7 @@ function AnySpendCustomInner({
|
|
|
665
667
|
const orderDetailsView = (
|
|
666
668
|
<div
|
|
667
669
|
className={cn(
|
|
668
|
-
"mx-auto flex w-full flex-col items-center gap-4",
|
|
670
|
+
"mx-auto flex w-full flex-col items-center gap-4 p-5",
|
|
669
671
|
mode === "modal" && "bg-b3-react-background rounded-xl",
|
|
670
672
|
)}
|
|
671
673
|
>
|
|
@@ -22,9 +22,10 @@ export interface IEVMChain extends IBaseChain {
|
|
|
22
22
|
viem: Chain;
|
|
23
23
|
pollingInterval: number;
|
|
24
24
|
zapperEnum?: string;
|
|
25
|
-
coingeckoName
|
|
25
|
+
coingeckoName: string | null;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface ISolanaChain extends IBaseChain {
|
|
29
29
|
type: ChainType.SOLANA;
|
|
30
|
+
coingeckoName: string;
|
|
30
31
|
}
|
|
@@ -186,6 +186,7 @@ export const EVM_TESTNET: Record<number, IEVMChain> = {
|
|
|
186
186
|
nativeToken: getEthToken(sepolia.id),
|
|
187
187
|
viem: sepolia,
|
|
188
188
|
pollingInterval: 1000, // 1 second for Sepolia
|
|
189
|
+
coingeckoName: "sepolia-testnet",
|
|
189
190
|
},
|
|
190
191
|
[baseSepolia.id]: {
|
|
191
192
|
id: baseSepolia.id,
|
|
@@ -198,6 +199,7 @@ export const EVM_TESTNET: Record<number, IEVMChain> = {
|
|
|
198
199
|
nativeToken: getEthToken(baseSepolia.id),
|
|
199
200
|
viem: baseSepolia,
|
|
200
201
|
pollingInterval: 1000, // 1 second for Base Sepolia
|
|
202
|
+
coingeckoName: null,
|
|
201
203
|
},
|
|
202
204
|
[b3Sepolia.id]: {
|
|
203
205
|
id: b3Sepolia.id,
|
|
@@ -210,6 +212,7 @@ export const EVM_TESTNET: Record<number, IEVMChain> = {
|
|
|
210
212
|
nativeToken: getEthToken(b3Sepolia.id),
|
|
211
213
|
viem: b3Sepolia,
|
|
212
214
|
pollingInterval: 1000, // 1 second for B3 Sepolia
|
|
215
|
+
coingeckoName: null,
|
|
213
216
|
},
|
|
214
217
|
// [b4testnet.id]: {
|
|
215
218
|
// id: b4testnet.id,
|
|
@@ -230,6 +233,7 @@ export const SOLANA_MAINNET: ISolanaChain = {
|
|
|
230
233
|
canDepositNative: true,
|
|
231
234
|
defaultToken: getSolanaToken(),
|
|
232
235
|
nativeToken: getSolanaToken(),
|
|
236
|
+
coingeckoName: "solana",
|
|
233
237
|
};
|
|
234
238
|
|
|
235
239
|
export const EVM_CHAINS: Record<number, IEVMChain> = { ...EVM_MAINNET, ...EVM_TESTNET };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import { useState } from "react";
|
|
4
3
|
import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
|
|
5
4
|
import { Account } from "thirdweb/wallets";
|
|
6
5
|
|
|
7
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
8
6
|
import { ClientType } from "../../../client-manager";
|
|
9
7
|
|
|
8
|
+
import { WagmiProvider } from "wagmi";
|
|
9
|
+
import { useAuthentication } from "../../hooks/useAuthentication";
|
|
10
|
+
import { useWagmiConfig } from "../../hooks/useWagmiConfig";
|
|
10
11
|
import { B3Context, B3ContextType } from "./types";
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -31,28 +32,32 @@ export function B3Provider({
|
|
|
31
32
|
accountOverride,
|
|
32
33
|
environment,
|
|
33
34
|
clientType = "socket",
|
|
35
|
+
partnerId,
|
|
36
|
+
rpcUrls,
|
|
34
37
|
}: {
|
|
35
38
|
theme: "light" | "dark";
|
|
36
39
|
children: React.ReactNode;
|
|
37
40
|
accountOverride?: Account;
|
|
38
41
|
environment: B3ContextType["environment"];
|
|
39
42
|
clientType?: ClientType;
|
|
43
|
+
partnerId: string;
|
|
44
|
+
rpcUrls?: Record<number, string>;
|
|
40
45
|
}) {
|
|
41
46
|
return (
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</
|
|
54
|
-
</
|
|
55
|
-
</
|
|
47
|
+
<ThirdwebProvider>
|
|
48
|
+
<InnerProvider
|
|
49
|
+
accountOverride={accountOverride}
|
|
50
|
+
environment={environment}
|
|
51
|
+
theme={theme}
|
|
52
|
+
clientType={clientType}
|
|
53
|
+
partnerId={partnerId}
|
|
54
|
+
rpcUrls={rpcUrls}
|
|
55
|
+
>
|
|
56
|
+
{/* <RelayKitProviderWrapper> */}
|
|
57
|
+
{children}
|
|
58
|
+
{/* </RelayKitProviderWrapper> */}
|
|
59
|
+
</InnerProvider>
|
|
60
|
+
</ThirdwebProvider>
|
|
56
61
|
);
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -66,6 +71,8 @@ export function InnerProvider({
|
|
|
66
71
|
defaultPermissions = DEFAULT_PERMISSIONS,
|
|
67
72
|
theme = "light",
|
|
68
73
|
clientType = "socket",
|
|
74
|
+
partnerId,
|
|
75
|
+
rpcUrls,
|
|
69
76
|
}: {
|
|
70
77
|
children: React.ReactNode;
|
|
71
78
|
accountOverride?: Account;
|
|
@@ -73,31 +80,40 @@ export function InnerProvider({
|
|
|
73
80
|
defaultPermissions?: PermissionsConfig;
|
|
74
81
|
theme: "light" | "dark";
|
|
75
82
|
clientType?: ClientType;
|
|
83
|
+
partnerId: string;
|
|
84
|
+
rpcUrls?: Record<number, string>;
|
|
76
85
|
}) {
|
|
77
86
|
const activeAccount = useActiveAccount();
|
|
78
|
-
const
|
|
87
|
+
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
88
|
+
const wagmiConfig = useWagmiConfig(partnerId, rpcUrls);
|
|
79
89
|
|
|
80
90
|
// Use given accountOverride or activeAccount from thirdweb
|
|
81
91
|
const effectiveAccount = accountOverride || activeAccount;
|
|
82
92
|
|
|
83
93
|
return (
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
<WagmiProvider config={wagmiConfig}>
|
|
95
|
+
<QueryClientProvider client={queryClient}>
|
|
96
|
+
<B3Context.Provider
|
|
97
|
+
value={{
|
|
98
|
+
account: effectiveAccount,
|
|
99
|
+
automaticallySetFirstEoa: false,
|
|
100
|
+
setWallet: () => {},
|
|
101
|
+
wallet: undefined,
|
|
102
|
+
user,
|
|
103
|
+
setUser,
|
|
104
|
+
initialized: true,
|
|
105
|
+
ready: !!effectiveAccount,
|
|
106
|
+
environment,
|
|
107
|
+
defaultPermissions,
|
|
108
|
+
theme,
|
|
109
|
+
clientType,
|
|
110
|
+
partnerId,
|
|
111
|
+
refetchUser,
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{children}
|
|
115
|
+
</B3Context.Provider>
|
|
116
|
+
</QueryClientProvider>
|
|
117
|
+
</WagmiProvider>
|
|
102
118
|
);
|
|
103
119
|
}
|