@zerodev/wallet-react-ui 0.0.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.
Files changed (94) hide show
  1. package/README.md +124 -0
  2. package/dist/_types/auth/authStoreSlice.d.ts +33 -0
  3. package/dist/_types/auth/authStoreSlice.d.ts.map +1 -0
  4. package/dist/_types/auth/components/BlobAnimation/index.d.ts +4 -0
  5. package/dist/_types/auth/components/BlobAnimation/index.d.ts.map +1 -0
  6. package/dist/_types/auth/components/CodeInput/index.d.ts +11 -0
  7. package/dist/_types/auth/components/CodeInput/index.d.ts.map +1 -0
  8. package/dist/_types/auth/hooks/useAuth.d.ts +18 -0
  9. package/dist/_types/auth/hooks/useAuth.d.ts.map +1 -0
  10. package/dist/_types/auth/index.d.ts +4 -0
  11. package/dist/_types/auth/index.d.ts.map +1 -0
  12. package/dist/_types/auth/pages/EmailVerification.d.ts +2 -0
  13. package/dist/_types/auth/pages/EmailVerification.d.ts.map +1 -0
  14. package/dist/_types/auth/pages/ErrorScreen.d.ts +9 -0
  15. package/dist/_types/auth/pages/ErrorScreen.d.ts.map +1 -0
  16. package/dist/_types/auth/pages/OtpInput.d.ts +2 -0
  17. package/dist/_types/auth/pages/OtpInput.d.ts.map +1 -0
  18. package/dist/_types/auth/pages/SignUp.d.ts +2 -0
  19. package/dist/_types/auth/pages/SignUp.d.ts.map +1 -0
  20. package/dist/_types/auth/pages/Verifying.d.ts +2 -0
  21. package/dist/_types/auth/pages/Verifying.d.ts.map +1 -0
  22. package/dist/_types/auth/pages/WalletSelection.d.ts +2 -0
  23. package/dist/_types/auth/pages/WalletSelection.d.ts.map +1 -0
  24. package/dist/_types/auth/types.d.ts +12 -0
  25. package/dist/_types/auth/types.d.ts.map +1 -0
  26. package/dist/_types/auth/utils/url.d.ts +3 -0
  27. package/dist/_types/auth/utils/url.d.ts.map +1 -0
  28. package/dist/_types/connector.d.ts +17 -0
  29. package/dist/_types/connector.d.ts.map +1 -0
  30. package/dist/_types/index.d.ts +10 -0
  31. package/dist/_types/index.d.ts.map +1 -0
  32. package/dist/_types/shared/components/PoweredBy/index.d.ts +6 -0
  33. package/dist/_types/shared/components/PoweredBy/index.d.ts.map +1 -0
  34. package/dist/_types/shared/components/Screen/EllipticalRadial.d.ts +23 -0
  35. package/dist/_types/shared/components/Screen/EllipticalRadial.d.ts.map +1 -0
  36. package/dist/_types/shared/components/Screen/MultiRadialBackground.d.ts +4 -0
  37. package/dist/_types/shared/components/Screen/MultiRadialBackground.d.ts.map +1 -0
  38. package/dist/_types/shared/components/Screen/index.d.ts +9 -0
  39. package/dist/_types/shared/components/Screen/index.d.ts.map +1 -0
  40. package/dist/_types/shared/components/SignUpFooter/index.d.ts +8 -0
  41. package/dist/_types/shared/components/SignUpFooter/index.d.ts.map +1 -0
  42. package/dist/_types/shared/components/StatusScreen/index.d.ts +10 -0
  43. package/dist/_types/shared/components/StatusScreen/index.d.ts.map +1 -0
  44. package/dist/_types/shared/components/TopNav/index.d.ts +10 -0
  45. package/dist/_types/shared/components/TopNav/index.d.ts.map +1 -0
  46. package/dist/_types/shared/hooks/useKitStore.d.ts +11 -0
  47. package/dist/_types/shared/hooks/useKitStore.d.ts.map +1 -0
  48. package/dist/_types/shared/utils/common.d.ts +5 -0
  49. package/dist/_types/shared/utils/common.d.ts.map +1 -0
  50. package/dist/_types/shared/utils/store.d.ts +4 -0
  51. package/dist/_types/shared/utils/store.d.ts.map +1 -0
  52. package/dist/_types/store.d.ts +25 -0
  53. package/dist/_types/store.d.ts.map +1 -0
  54. package/dist/_types/types.d.ts +38 -0
  55. package/dist/_types/types.d.ts.map +1 -0
  56. package/dist/blob.webm +0 -0
  57. package/dist/error.webp +0 -0
  58. package/dist/index.cjs +4 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.mjs +1374 -0
  61. package/dist/index.mjs.map +1 -0
  62. package/dist/loading.webp +0 -0
  63. package/dist/send.webp +0 -0
  64. package/dist/styles.css +2 -0
  65. package/dist/success.webp +0 -0
  66. package/package.json +96 -0
  67. package/src/assets.d.ts +14 -0
  68. package/src/auth/authStoreSlice.ts +180 -0
  69. package/src/auth/components/BlobAnimation/index.tsx +24 -0
  70. package/src/auth/components/CodeInput/index.tsx +118 -0
  71. package/src/auth/hooks/useAuth.ts +32 -0
  72. package/src/auth/index.tsx +108 -0
  73. package/src/auth/pages/EmailVerification.tsx +76 -0
  74. package/src/auth/pages/ErrorScreen.tsx +53 -0
  75. package/src/auth/pages/OtpInput.tsx +124 -0
  76. package/src/auth/pages/SignUp.tsx +303 -0
  77. package/src/auth/pages/Verifying.tsx +108 -0
  78. package/src/auth/pages/WalletSelection.tsx +53 -0
  79. package/src/auth/types.ts +23 -0
  80. package/src/auth/utils/url.ts +12 -0
  81. package/src/connector.ts +182 -0
  82. package/src/index.ts +25 -0
  83. package/src/shared/components/PoweredBy/index.tsx +26 -0
  84. package/src/shared/components/Screen/EllipticalRadial.tsx +65 -0
  85. package/src/shared/components/Screen/MultiRadialBackground.tsx +323 -0
  86. package/src/shared/components/Screen/index.tsx +65 -0
  87. package/src/shared/components/SignUpFooter/index.tsx +66 -0
  88. package/src/shared/components/StatusScreen/index.tsx +49 -0
  89. package/src/shared/components/TopNav/index.tsx +45 -0
  90. package/src/shared/hooks/useKitStore.ts +20 -0
  91. package/src/shared/utils/common.ts +26 -0
  92. package/src/shared/utils/store.ts +9 -0
  93. package/src/store.ts +44 -0
  94. package/src/types.ts +48 -0
@@ -0,0 +1,26 @@
1
+ export function capitalizeFirst(str?: string | null): string {
2
+ if (!str) return ''
3
+ const first = str.at(0) ?? ''
4
+ return first.toUpperCase() + str.slice(1)
5
+ }
6
+
7
+ export function shortenHex(hex: string, length = 4) {
8
+ return `${hex.slice(0, length + 2)}...${hex.slice(-length)}`
9
+ }
10
+
11
+ export function camelCaseToTitle(str: string): string {
12
+ if (str.length === 0 || str.at(0) === str.at(0)?.toUpperCase()) {
13
+ return str
14
+ }
15
+
16
+ const words = str.replace(/([a-z])([A-Z])/g, '$1 $2').trim()
17
+ return words
18
+ .split(' ')
19
+ .map((word) => capitalizeFirst(word))
20
+ .join(' ')
21
+ }
22
+
23
+ const EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
24
+ export function isValidEmailAddress(email: string): boolean {
25
+ return EMAIL_REGEX.test(email.trim())
26
+ }
@@ -0,0 +1,9 @@
1
+ import type { useConfig } from 'wagmi'
2
+ import type { Store } from '../../types.js'
3
+
4
+ export function getStore(config: ReturnType<typeof useConfig>): Store | null {
5
+ const connector = config.connectors.find((c) => c.id === 'zerodev-wallet')
6
+ if (!connector || !('getKitStore' in connector)) return null
7
+ // @ts-expect-error - getKitStore is a custom method on the kit connector
8
+ return connector.getKitStore()
9
+ }
package/src/store.ts ADDED
@@ -0,0 +1,44 @@
1
+ import type { ReactNode } from 'react'
2
+ import { create } from 'zustand'
3
+ import { subscribeWithSelector } from 'zustand/middleware'
4
+ import {
5
+ type AuthStoreSlice,
6
+ createAuthStoreSlice,
7
+ } from './auth/authStoreSlice'
8
+ import type { PendingRequest } from './types.js'
9
+
10
+ export type State = {
11
+ pendingRequests: PendingRequest[]
12
+ userConfirmationListenerActive: boolean
13
+ logo: ReactNode | null
14
+ addPendingRequest: (request: PendingRequest) => void
15
+ removePendingRequest: (id: string) => void
16
+ clearPendingRequests: () => void
17
+ setUserConfirmationListenerActive: (active: boolean) => void
18
+ } & AuthStoreSlice
19
+
20
+ export type CreateStoreOptions = {
21
+ logo?: ReactNode
22
+ }
23
+
24
+ export const createStore = (options: CreateStoreOptions = {}) =>
25
+ create<State>()(
26
+ subscribeWithSelector((set, get, store) => ({
27
+ pendingRequests: [],
28
+ userConfirmationListenerActive: false,
29
+ logo: options.logo ?? null,
30
+ addPendingRequest: (request) =>
31
+ set((state) => ({
32
+ pendingRequests: [...state.pendingRequests, request],
33
+ })),
34
+ removePendingRequest: (id) =>
35
+ set((state) => ({
36
+ pendingRequests: state.pendingRequests.filter((r) => r.id !== id),
37
+ })),
38
+ clearPendingRequests: () => set({ pendingRequests: [] }),
39
+ setUserConfirmationListenerActive: (active) =>
40
+ set({ userConfirmationListenerActive: active }),
41
+
42
+ ...createAuthStoreSlice(set, get, store),
43
+ })),
44
+ )
package/src/types.ts ADDED
@@ -0,0 +1,48 @@
1
+ import type { Address, Hex, RpcTransactionRequest } from 'viem'
2
+ import type { createStore } from './store.js'
3
+
4
+ export type Store = ReturnType<typeof createStore>
5
+
6
+ export type BatchCall = {
7
+ to?: Address
8
+ data?: Hex
9
+ value?: Hex
10
+ }
11
+
12
+ // todo: these should be moved to core package and exported from there
13
+ export type Request =
14
+ | {
15
+ method: 'eth_sendTransaction'
16
+ params: [transaction: RpcTransactionRequest]
17
+ }
18
+ | {
19
+ method: 'wallet_sendTransaction'
20
+ params: [transaction: RpcTransactionRequest]
21
+ }
22
+ | {
23
+ method: 'wallet_sendCalls'
24
+ params: [
25
+ {
26
+ version: string
27
+ chainId: Hex
28
+ from: Address
29
+ calls: BatchCall[]
30
+ },
31
+ ]
32
+ }
33
+ | {
34
+ method: 'personal_sign'
35
+ params: [data: Hex, address: Hex]
36
+ }
37
+ | {
38
+ method: 'eth_signTypedData_v4'
39
+ params: [address: Hex, typedData: string]
40
+ }
41
+
42
+ export type RequestMethod = Request['method']
43
+
44
+ export type PendingRequest = {
45
+ id: string
46
+ resolve: () => void
47
+ reject: (reason?: unknown) => void
48
+ } & Request