@n1xyz/wallet-widget 0.0.1 → 0.0.4

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 (100) hide show
  1. package/LICENSE +44 -0
  2. package/README.md +45 -0
  3. package/dist/Logic/utils.d.ts +1 -0
  4. package/dist/Logic/utils.js +47 -9
  5. package/dist/Modal/BackButton.js +14 -1
  6. package/dist/Modal/ConnectView.js +20 -23
  7. package/dist/Modal/CreateSessionView.js +23 -11
  8. package/dist/Modal/CreateUserView.js +1 -1
  9. package/dist/Modal/ModalHeader.js +14 -3
  10. package/dist/Modal/N1WalletModal.js +35 -30
  11. package/dist/Modal/NoWhitelistView.js +14 -1
  12. package/dist/Modal/Sidebar/N1Sidebar.js +152 -13
  13. package/dist/Modal/SigningView.js +1 -1
  14. package/dist/Provider/LazyWalletProvider.js +6 -2
  15. package/dist/Provider/N1WalletProvider.js +10 -7
  16. package/dist/Provider/types.d.ts +8 -0
  17. package/dist/components/Logo.d.ts +7 -0
  18. package/dist/components/Logo.js +118 -0
  19. package/dist/components/QRCodeLoader.d.ts +4 -0
  20. package/dist/components/QRCodeLoader.js +8 -0
  21. package/dist/components/WalletDeposit/AnimatedButton.d.ts +17 -0
  22. package/dist/components/WalletDeposit/AnimatedButton.js +29 -0
  23. package/dist/components/WalletDeposit/components/ChainButton.d.ts +7 -0
  24. package/dist/components/WalletDeposit/components/ChainButton.js +5 -0
  25. package/dist/components/WalletDeposit/components/LoadingSquares.d.ts +1 -0
  26. package/dist/components/WalletDeposit/components/LoadingSquares.js +5 -0
  27. package/dist/components/WalletDeposit/components/TransactionTable.d.ts +6 -0
  28. package/dist/components/WalletDeposit/components/TransactionTable.js +8 -0
  29. package/dist/components/WalletDeposit/components/WaitingMessage.d.ts +6 -0
  30. package/dist/components/WalletDeposit/components/WaitingMessage.js +6 -0
  31. package/dist/components/WalletDeposit/constants.d.ts +15 -0
  32. package/dist/components/WalletDeposit/constants.js +32 -0
  33. package/dist/components/WalletDeposit/hooks.d.ts +9 -0
  34. package/dist/components/WalletDeposit/hooks.js +185 -0
  35. package/dist/components/WalletDeposit/index.d.ts +1 -0
  36. package/dist/components/WalletDeposit/index.js +136 -0
  37. package/dist/components/WalletDeposit/screens/AmountInputScreen.d.ts +12 -0
  38. package/dist/components/WalletDeposit/screens/AmountInputScreen.js +18 -0
  39. package/dist/components/WalletDeposit/screens/AppsTableScreen.d.ts +8 -0
  40. package/dist/components/WalletDeposit/screens/AppsTableScreen.js +28 -0
  41. package/dist/components/WalletDeposit/screens/ChainSelectionScreen.d.ts +5 -0
  42. package/dist/components/WalletDeposit/screens/ChainSelectionScreen.js +8 -0
  43. package/dist/components/WalletDeposit/screens/InitialScreen.d.ts +9 -0
  44. package/dist/components/WalletDeposit/screens/InitialScreen.js +18 -0
  45. package/dist/components/WalletDeposit/screens/SigningScreen.d.ts +6 -0
  46. package/dist/components/WalletDeposit/screens/SigningScreen.js +6 -0
  47. package/dist/components/WalletDeposit/screens/SuccessScreen.d.ts +12 -0
  48. package/dist/components/WalletDeposit/screens/SuccessScreen.js +7 -0
  49. package/dist/components/WalletDeposit/types.d.ts +43 -0
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.js +2 -0
  52. package/dist/main.css +1 -1
  53. package/dist/utils/dynamicImports.d.ts +24 -0
  54. package/dist/utils/dynamicImports.js +41 -0
  55. package/dist/utils/shortenString.d.ts +2 -0
  56. package/dist/utils/shortenString.js +8 -0
  57. package/package.json +13 -9
  58. package/.eslintrc.js +0 -29
  59. package/dist/Common/NIcon.js +0 -7
  60. package/dist/components/AnimatedButton.d.ts +0 -9
  61. package/dist/components/AnimatedButton.js +0 -5
  62. package/postcss.config.js +0 -6
  63. package/src/Logic/getPseudoName.ts +0 -5832
  64. package/src/Logic/utils.ts +0 -162
  65. package/src/Logic/words.ts +0 -93571
  66. package/src/Modal/BackButton.tsx +0 -23
  67. package/src/Modal/ConnectView.tsx +0 -88
  68. package/src/Modal/CreateSessionView.tsx +0 -242
  69. package/src/Modal/CreateUserView.tsx +0 -195
  70. package/src/Modal/ModalHeader.tsx +0 -64
  71. package/src/Modal/N1WalletModal.tsx +0 -275
  72. package/src/Modal/NoWhitelistView.tsx +0 -61
  73. package/src/Modal/Sidebar/N1Sidebar.tsx +0 -172
  74. package/src/Modal/SigningView.tsx +0 -18
  75. package/src/Modal/SuccessView.tsx +0 -36
  76. package/src/Provider/LazyWalletProvider.tsx +0 -136
  77. package/src/Provider/N1WalletProvider.tsx +0 -208
  78. package/src/Provider/context.ts +0 -11
  79. package/src/Provider/hooks.ts +0 -22
  80. package/src/Provider/icons/CoinbaseWalletIcon.tsx +0 -27
  81. package/src/Provider/icons/ConnectionDotsSVG.tsx +0 -19
  82. package/src/Provider/icons/MetamaskIcon.tsx +0 -58
  83. package/src/Provider/icons/PhantomIcon.tsx +0 -26
  84. package/src/Provider/icons/UserIcon.tsx +0 -15
  85. package/src/Provider/icons/WalletConnectIcon.tsx +0 -15
  86. package/src/Provider/index.ts +0 -3
  87. package/src/Provider/types.ts +0 -77
  88. package/src/WidgetButton/N1ConnectButton.tsx +0 -72
  89. package/src/components/LazyLoadWrapper.tsx +0 -19
  90. package/src/config.ts +0 -2
  91. package/src/errors/types.ts +0 -49
  92. package/src/index.ts +0 -5
  93. package/src/main.css +0 -3
  94. package/src/styles/main.css +0 -3
  95. package/src/utils/lazyLoad.ts +0 -12
  96. package/src/utils/logger.ts +0 -98
  97. package/src/utils/react-shim.js +0 -8
  98. package/tailwind.config.js +0 -44
  99. package/tsconfig.json +0 -21
  100. /package/dist/{Common/NIcon.d.ts → components/WalletDeposit/types.js} +0 -0
@@ -1,208 +0,0 @@
1
- 'use client';
2
-
3
- import React, { Suspense, useCallback, useEffect, useState } from 'react';
4
- import { N1WalletModal } from '../Modal/N1WalletModal';
5
- import { WalletError, WalletErrorCode } from '../errors/types';
6
- import { N1InternalWalletContext, N1WalletContext } from './context';
7
- import { N1ModalViewMode, N1SessionMode, N1WalletProviderProps } from './types';
8
-
9
- const LazyWalletProvider = React.lazy(() =>
10
- import('./LazyWalletProvider').then((mod) => ({
11
- default: mod.LazyWalletProvider,
12
- }))
13
- );
14
-
15
- // Error boundary to catch WalletErrors
16
- class WalletErrorBoundary extends React.Component<{
17
- children: React.ReactNode;
18
- onError: (error: WalletError) => void;
19
- }> {
20
- componentDidCatch(error: Error) {
21
- if (error instanceof WalletError) {
22
- this.props.onError(error);
23
- } else {
24
- // Convert unknown errors to WalletError
25
- this.props.onError(
26
- new WalletError(
27
- WalletErrorCode.UNKNOWN,
28
- error.message || 'An unexpected error occurred',
29
- { originalError: error }
30
- )
31
- );
32
- }
33
- }
34
-
35
- render() {
36
- return this.props.children;
37
- }
38
- }
39
-
40
- export function N1WalletProvider({
41
- children,
42
- providedSessionMode,
43
- appId,
44
- darkMode = true,
45
- onError,
46
- }: N1WalletProviderProps) {
47
- const [isConnected, setIsConnected] = useState<boolean>(false);
48
- const [ntsInterface, setNtsInterface] = useState<any>(null);
49
- const [showLogin, setShowLogin] = useState<boolean>(false);
50
- const [sessionPubKey, setSessionPubKey] = useState<Uint8Array | null>(null);
51
- const [walletPubKey, setWalletPubKey] = useState<Uint8Array | null>(null);
52
- const [userChain, setUserChain] = useState<string | null>(null);
53
- const [username, setUsername] = useState<string>('');
54
- const [signMessageWithSessionKey, setSignMessageWithSessionKey] = useState<
55
- ((message: any) => Promise<any>) | null
56
- >(null);
57
- const [signMessageWithWalletKey, setSignMessageWithWalletKey] = useState<
58
- ((message: any) => Promise<any>) | null
59
- >(null);
60
- const [showSidebar, setShowSidebar] = useState<boolean>(false);
61
- const [startClosingLogin, setStartClosingLogin] = useState<boolean>(false);
62
- const [loading, setLoading] = useState<boolean>(false);
63
- const [viewMode, setViewMode] = useState<N1ModalViewMode>(
64
- N1ModalViewMode.Connect
65
- );
66
-
67
- // Log initialization only once on mount
68
- useEffect(() => {
69
- // eslint-disable-next-line no-console
70
- console.log('N1WalletProvider initializing');
71
- }, []);
72
-
73
- // dynamic
74
- const [address, setAddress] = useState<string>('');
75
- const [chain, setChain] = useState<string>('');
76
- const [dynamicSdkHasLoaded, setDynamicSdkHasLoaded] = useState<any>(null);
77
- const [dynamicHandleLogOut, setDynamicHandleLogOut] = useState<any>(null);
78
- const [sessionMode, setSessionMode] = useState<N1SessionMode | null>(null);
79
- const [dynamicWallet, setDynamicWallet] = useState<any>(null);
80
- const [showDynamicWidget, setShowDynamicWidget] = useState<any>(null);
81
-
82
- // Combine SDK loading and initialization into a single effect
83
- useEffect(() => {
84
- let mounted = true;
85
-
86
- const loadNTSSDK = async () => {
87
- // eslint-disable-next-line no-console
88
- console.log('Loading NTS SDK');
89
-
90
- if (providedSessionMode === N1SessionMode.Nord) {
91
- // eslint-disable-next-line no-console
92
- console.log('Nord mode, skipping NTS SDK load');
93
- return;
94
- }
95
-
96
- try {
97
- const { NTSInterface } = await import('@n1xyz/nts-sdk');
98
- if (mounted) {
99
- // eslint-disable-next-line no-console
100
- console.log('NTS SDK loaded successfully');
101
- setNtsInterface(new NTSInterface(process.env.NTS_URL!));
102
- }
103
- } catch (error) {
104
- if (mounted) {
105
- // eslint-disable-next-line no-console
106
- console.error('Error loading NTS SDK:', error);
107
- }
108
- }
109
- };
110
-
111
- loadNTSSDK();
112
-
113
- return () => {
114
- mounted = false;
115
- };
116
- }, [providedSessionMode]);
117
-
118
- // Separate effect to handle loading state based on both SDKs
119
- useEffect(() => {
120
- const isDynamicReady =
121
- dynamicSdkHasLoaded || providedSessionMode === N1SessionMode.Nord;
122
- const isNtsReady =
123
- ntsInterface || providedSessionMode === N1SessionMode.Nord;
124
-
125
- setLoading(!isDynamicReady || !isNtsReady);
126
- }, [dynamicSdkHasLoaded, ntsInterface, providedSessionMode]);
127
-
128
- const handleError = useCallback(
129
- (error: WalletError) => {
130
- onError?.(error);
131
- },
132
- [onError]
133
- );
134
-
135
- // Simple function to test error handler
136
- const throwTestError = async () => {
137
- handleError(
138
- new WalletError(
139
- WalletErrorCode.WALLET_NOT_FOUND,
140
- 'Test error: No compatible wallet was found'
141
- )
142
- );
143
- };
144
-
145
- return (
146
- <WalletErrorBoundary onError={handleError}>
147
- <N1WalletContext.Provider
148
- value={{
149
- address,
150
- appId,
151
- chain,
152
- isConnected,
153
- ntsInterface,
154
- sessionMode,
155
- sessionPubKey,
156
- setShowLogin,
157
- showLogin,
158
- signMessageWithSessionKey,
159
- signMessageWithWalletKey,
160
- userChain,
161
- username,
162
- viewMode,
163
- walletPubKey,
164
- throwTestError,
165
- }}
166
- >
167
- <N1InternalWalletContext.Provider
168
- value={{
169
- dynamicHandleLogOut,
170
- dynamicWallet,
171
- loading,
172
- dynamicSdkHasLoaded,
173
- handleError,
174
- setDynamicSdkHasLoaded,
175
- setAddress,
176
- setChain,
177
- setDynamicHandleLogOut,
178
- setDynamicWallet,
179
- setIsConnected,
180
- setLoading,
181
- setNtsInterface,
182
- setSessionMode,
183
- setSessionPubKey,
184
- setShowSidebar,
185
- setSignMessageWithSessionKey,
186
- setSignMessageWithWalletKey,
187
- setStartClosingLogin,
188
- setUsername,
189
- setUserChain,
190
- setViewMode,
191
- setWalletPubKey,
192
- showSidebar,
193
- startClosingLogin,
194
- showDynamicWidget,
195
- setShowDynamicWidget,
196
- darkMode,
197
- }}
198
- >
199
- {children}
200
- <N1WalletModal />
201
- <Suspense fallback={null}>
202
- <LazyWalletProvider />
203
- </Suspense>
204
- </N1InternalWalletContext.Provider>
205
- </N1WalletContext.Provider>
206
- </WalletErrorBoundary>
207
- );
208
- }
@@ -1,11 +0,0 @@
1
- import { N1WalletState } from './types';
2
-
3
- import { createContext } from 'react';
4
- import { N1InternalWalletState } from './types';
5
-
6
- const N1WalletContext = createContext<N1WalletState>({} as N1WalletState);
7
- const N1InternalWalletContext = createContext<N1InternalWalletState>(
8
- {} as N1InternalWalletState
9
- );
10
-
11
- export { N1WalletContext, N1InternalWalletContext };
@@ -1,22 +0,0 @@
1
- import { useContext } from 'react';
2
- import { N1WalletContext, N1InternalWalletContext } from './context';
3
-
4
- export function useN1WalletContext() {
5
- const context = useContext(N1WalletContext);
6
- if (context === undefined) {
7
- throw new Error(
8
- 'useN1WalletContext must be used within a N1WalletProvider'
9
- );
10
- }
11
- return context;
12
- }
13
-
14
- export function useN1WalletInternalContext() {
15
- const context = useContext(N1InternalWalletContext);
16
- if (context === undefined) {
17
- throw new Error(
18
- 'useN1WalletInternalContext must be used within a N1WalletProvider'
19
- );
20
- }
21
- return context;
22
- }
@@ -1,27 +0,0 @@
1
- export function CoinbaseWalletIcon() {
2
- return (
3
- <svg
4
- width="1.5em"
5
- height="1.5em"
6
- xmlns="http://www.w3.org/2000/svg"
7
- xmlnsXlink="http://www.w3.org/1999/xlink"
8
- version="1.2"
9
- baseProfile="tiny"
10
- id="Layer_1"
11
- x="0px"
12
- y="0px"
13
- viewBox="0 0 1024 1024"
14
- overflow="visible"
15
- xmlSpace="preserve"
16
- >
17
- <path
18
- fill="#0052FF"
19
- d="M512,0L512,0c282.8,0,512,229.2,512,512l0,0c0,282.8-229.2,512-512,512l0,0C229.2,1024,0,794.8,0,512l0,0 C0,229.2,229.2,0,512,0z"
20
- />
21
- <path
22
- fill="#FFFFFF"
23
- d="M512.1,692c-99.4,0-180-80.5-180-180s80.6-180,180-180c89.1,0,163.1,65,177.3,150h181.3 c-15.3-184.8-170-330-358.7-330c-198.8,0-360,161.2-360,360s161.2,360,360,360c188.7,0,343.4-145.2,358.7-330H689.3 C675,627,601.2,692,512.1,692z"
24
- />
25
- </svg>
26
- );
27
- }
@@ -1,19 +0,0 @@
1
- export function ConnectionDotsSVG() {
2
- return (
3
- <svg
4
- width="56"
5
- height="12"
6
- viewBox="0 0 56 12"
7
- fill="none"
8
- xmlns="http://www.w3.org/2000/svg"
9
- >
10
- <circle cx="19.5" cy="2.5" r="2.5" fill="#6e6e6e"></circle>
11
- <circle cx="36.5" cy="2.5" r="2.5" fill="#6e6e6e"></circle>
12
- <circle cx="2.5" cy="2.5" r="2.5" fill="#6e6e6e"></circle>
13
- <circle cx="53.5" cy="2.5" r="2.5" fill="#6e6e6e"></circle>
14
- <circle cx="12.5" cy="9.5" r="2.5" fill="#6e6e6e"></circle>
15
- <circle cx="29.5" cy="9.5" r="2.5" fill="#6e6e6e"></circle>
16
- <circle cx="46.5" cy="9.5" r="2.5" fill="#6e6e6e"></circle>
17
- </svg>
18
- );
19
- }
@@ -1,58 +0,0 @@
1
- export function MetamaskIcon() {
2
- return (
3
- <>
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width="1.5em"
7
- height="1.5em"
8
- viewBox="0 0 256 240"
9
- >
10
- <path fill="#e17726" d="M250.066 0L140.219 81.279l20.427-47.9z" />
11
- <path
12
- fill="#e27625"
13
- d="m6.191.096l89.181 33.289l19.396 48.528zM205.86 172.858l48.551.924l-16.968 57.642l-59.243-16.311zm-155.721 0l27.557 42.255l-59.143 16.312l-16.865-57.643z"
14
- />
15
- <path
16
- fill="#e27625"
17
- d="m112.131 69.552l1.984 64.083l-59.371-2.701l16.888-25.478l.214-.245zm31.123-.715l40.9 36.376l.212.244l16.888 25.478l-59.358 2.7zM79.435 173.044l32.418 25.259l-37.658 18.181zm97.136-.004l5.131 43.445l-37.553-18.184z"
18
- />
19
- <path
20
- fill="#d5bfb2"
21
- d="m144.978 195.922l38.107 18.452l-35.447 16.846l.368-11.134zm-33.967.008l-2.909 23.974l.239 11.303l-35.53-16.833z"
22
- />
23
- <path
24
- fill="#233447"
25
- d="m100.007 141.999l9.958 20.928l-33.903-9.932zm55.985.002l24.058 10.994l-34.014 9.929z"
26
- />
27
- <path
28
- fill="#cc6228"
29
- d="m82.026 172.83l-5.48 45.04l-29.373-44.055zm91.95.001l34.854.984l-29.483 44.057zm28.136-44.444l-25.365 25.851l-19.557-8.937l-9.363 19.684l-6.138-33.849zm-148.237 0l60.435 2.749l-6.139 33.849l-9.365-19.681l-19.453 8.935z"
30
- />
31
- <path
32
- fill="#e27525"
33
- d="m52.166 123.082l28.698 29.121l.994 28.749zm151.697-.052l-29.746 57.973l1.12-28.8zm-90.956 1.826l1.155 7.27l2.854 18.111l-1.835 55.625l-8.675-44.685l-.003-.462zm30.171-.101l6.521 35.96l-.003.462l-8.697 44.797l-.344-11.205l-1.357-44.862z"
34
- />
35
- <path
36
- fill="#f5841f"
37
- d="m177.788 151.046l-.971 24.978l-30.274 23.587l-6.12-4.324l6.86-35.335zm-99.471 0l30.399 8.906l6.86 35.335l-6.12 4.324l-30.275-23.589z"
38
- />
39
- <path
40
- fill="#c0ac9d"
41
- d="m67.018 208.858l38.732 18.352l-.164-7.837l3.241-2.845h38.334l3.358 2.835l-.248 7.831l38.487-18.29l-18.728 15.476l-22.645 15.553h-38.869l-22.63-15.617z"
42
- />
43
- <path
44
- fill="#161616"
45
- d="m142.204 193.479l5.476 3.869l3.209 25.604l-4.644-3.921h-36.476l-4.556 4l3.104-25.681l5.478-3.871z"
46
- />
47
- <path
48
- fill="#763e1a"
49
- d="M242.814 2.25L256 41.807l-8.235 39.997l5.864 4.523l-7.935 6.054l5.964 4.606l-7.897 7.191l4.848 3.511l-12.866 15.026l-52.77-15.365l-.457-.245l-38.027-32.078zm-229.628 0l98.326 72.777l-38.028 32.078l-.457.245l-52.77 15.365l-12.866-15.026l4.844-3.508l-7.892-7.194l5.952-4.601l-8.054-6.071l6.085-4.526L0 41.809z"
50
- />
51
- <path
52
- fill="#f5841f"
53
- d="m180.392 103.99l55.913 16.279l18.165 55.986h-47.924l-33.02.416l24.014-46.808zm-104.784 0l-17.151 25.873l24.017 46.808l-33.005-.416H1.631l18.063-55.985zm87.776-70.878l-15.639 42.239l-3.319 57.06l-1.27 17.885l-.101 45.688h-30.111l-.098-45.602l-1.274-17.986l-3.32-57.045l-15.637-42.239z"
54
- />
55
- </svg>
56
- </>
57
- );
58
- }
@@ -1,26 +0,0 @@
1
- export function PhantomIcon() {
2
- return (
3
- <svg
4
- xmlns="http://www.w3.org/2000/svg"
5
- width="1.5em"
6
- height="1.5em"
7
- viewBox="0 0 1200 1200"
8
- fill="none"
9
- >
10
- <g clipPath="url(#clip0_2800_140397)">
11
- <rect width="1200" height="1200" fill="#9886E5" />
12
- <path
13
- fillRule="evenodd"
14
- clipRule="evenodd"
15
- d="M516.641 777.604C466.226 854.856 381.747 952.618 269.335 952.618C216.194 952.618 165.098 930.741 165.098 835.714C165.098 593.704 495.521 219.066 802.1 219.066C976.509 219.066 1046 340.071 1046 477.484C1046 653.865 931.544 855.54 817.77 855.54C781.661 855.54 763.948 835.714 763.948 804.267C763.948 796.063 765.311 787.175 768.036 777.604C729.202 843.918 654.261 905.446 584.089 905.446C532.992 905.446 507.103 873.315 507.103 828.194C507.103 811.787 510.51 794.696 516.641 777.604ZM930.877 472.714C930.877 512.755 907.253 532.776 880.826 532.776C853.998 532.776 830.775 512.755 830.775 472.714C830.775 432.673 853.998 412.653 880.826 412.653C907.253 412.653 930.877 432.673 930.877 472.714ZM780.73 472.714C780.73 512.755 757.105 532.776 730.678 532.776C703.851 532.776 680.627 512.755 680.627 472.714C680.627 432.673 703.851 412.653 730.678 412.653C757.105 412.653 780.73 432.673 780.73 472.714Z"
16
- fill="#FFFDF8"
17
- />
18
- </g>
19
- <defs>
20
- <clipPath id="clip0_2800_140397">
21
- <rect width="1200" height="1200" fill="white" />
22
- </clipPath>
23
- </defs>
24
- </svg>
25
- );
26
- }
@@ -1,15 +0,0 @@
1
- export function UserIcon() {
2
- return (
3
- <svg
4
- xmlns="http://www.w3.org/2000/svg"
5
- viewBox="0 0 24 24"
6
- fill="currentColor"
7
- >
8
- <path
9
- fillRule="evenodd"
10
- d="M18.685 19.097A9.723 9.723 0 0 0 21.75 12c0-5.385-4.365-9.75-9.75-9.75S2.25 6.615 2.25 12a9.723 9.723 0 0 0 3.065 7.097A9.716 9.716 0 0 0 12 20.25a9.716 9.716 0 0 0 6.685-2.653Zm-12.54-1.285A7.486 7.486 0 0 1 12 15a7.486 7.486 0 0 1 5.855 2.812A8.224 8.224 0 0 1 12 20.25a8.224 8.224 0 0 1-5.855-2.438ZM15.75 9a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"
11
- clipRule="evenodd"
12
- />
13
- </svg>
14
- );
15
- }
@@ -1,15 +0,0 @@
1
- export function WalletConnectIcon() {
2
- return (
3
- <svg
4
- xmlns="http://www.w3.org/2000/svg"
5
- width="1.5em"
6
- height="1.5em"
7
- viewBox="0 0 24 24"
8
- >
9
- <path
10
- fill="#388eff"
11
- d="M4.913 7.519c3.915-3.831 10.26-3.831 14.174 0l.471.461a.483.483 0 0 1 0 .694l-1.611 1.577a.252.252 0 0 1-.354 0l-.649-.634c-2.73-2.673-7.157-2.673-9.887 0l-.694.68a.255.255 0 0 1-.355 0L4.397 8.719a.482.482 0 0 1 0-.693l.516-.507Zm17.506 3.263l1.434 1.404a.483.483 0 0 1 0 .694l-6.466 6.331a.508.508 0 0 1-.709 0l-4.588-4.493a.126.126 0 0 0-.178 0l-4.589 4.493a.508.508 0 0 1-.709 0L.147 12.88a.483.483 0 0 1 0-.694l1.434-1.404a.508.508 0 0 1 .709 0l4.589 4.493c.05.048.129.048.178 0l4.589-4.493a.508.508 0 0 1 .709 0l4.589 4.493c.05.048.128.048.178 0l4.589-4.493a.507.507 0 0 1 .708 0Z"
12
- />
13
- </svg>
14
- );
15
- }
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export { N1WalletProvider } from './N1WalletProvider';
3
- export { useN1WalletContext, useN1WalletInternalContext } from './hooks';
@@ -1,77 +0,0 @@
1
- import type { WalletError } from '../errors/types';
2
-
3
- export enum N1ModalViewMode {
4
- Connect,
5
- CreateSession,
6
- Signing,
7
- CreatingUser,
8
- Success,
9
- NoWhitelist,
10
- }
11
-
12
- export enum N1SessionMode {
13
- Nord,
14
- NTS,
15
- }
16
-
17
- export interface N1WalletProviderProps {
18
- children: React.ReactNode;
19
- providedSessionMode: N1SessionMode;
20
- appId: string;
21
- darkMode?: boolean;
22
- onError?: (error: WalletError) => void;
23
- }
24
-
25
- export interface N1WalletState {
26
- address: string;
27
- appId: string | null;
28
- chain: string;
29
- isConnected: boolean;
30
- ntsInterface: any;
31
- sessionMode: N1SessionMode | null;
32
- sessionPubKey: Uint8Array | null;
33
- setShowLogin: (show: boolean) => void;
34
- showLogin: boolean;
35
- signMessageWithSessionKey: ((message: any) => Promise<any>) | null;
36
- signMessageWithWalletKey: ((message: any) => Promise<any>) | null;
37
- userChain: string | null;
38
- username: string;
39
- viewMode: N1ModalViewMode;
40
- walletPubKey: Uint8Array | null;
41
- throwTestError: () => Promise<void>;
42
- }
43
-
44
- export interface N1InternalWalletState {
45
- dynamicHandleLogOut: any;
46
- dynamicWallet: any;
47
- loading: boolean;
48
- dynamicSdkHasLoaded: any;
49
- handleError: (error: WalletError) => void;
50
- setDynamicSdkHasLoaded: (loaded: any) => void;
51
- setAddress: (address: string) => void;
52
- setChain: (chain: string) => void;
53
- setDynamicHandleLogOut: (handler: any) => void;
54
- setDynamicWallet: (wallet: any) => void;
55
- setIsConnected: (connected: boolean) => void;
56
- setLoading: (loading: boolean) => void;
57
- setNtsInterface: (nts: any) => void;
58
- setSessionMode: (mode: N1SessionMode | null) => void;
59
- setSessionPubKey: (key: Uint8Array) => void;
60
- setShowSidebar: (show: boolean) => void;
61
- setSignMessageWithSessionKey: React.Dispatch<
62
- React.SetStateAction<((message: any) => Promise<any>) | null>
63
- >;
64
- setSignMessageWithWalletKey: React.Dispatch<
65
- React.SetStateAction<((message: any) => Promise<any>) | null>
66
- >;
67
- setStartClosingLogin: (closing: boolean) => void;
68
- setUsername: (username: string) => void;
69
- setUserChain: (chain: string) => void;
70
- setViewMode: (mode: N1ModalViewMode) => void;
71
- setWalletPubKey: (key: Uint8Array) => void;
72
- showSidebar: boolean;
73
- startClosingLogin: boolean;
74
- showDynamicWidget: any;
75
- setShowDynamicWidget: (show: any) => void;
76
- darkMode: boolean;
77
- }
@@ -1,72 +0,0 @@
1
- import BlockiesSvg from 'blockies-react-svg';
2
- import React, { useEffect, useState } from 'react';
3
- import {
4
- useN1WalletContext,
5
- useN1WalletInternalContext,
6
- } from '../Provider/hooks';
7
- import { logger } from '../utils/logger';
8
-
9
- export function N1ConnectButton(_props: {
10
- label: string;
11
- children?: React.ReactNode;
12
- }) {
13
- const { isConnected, setShowLogin, address } = useN1WalletContext();
14
- const [toOpen, setToOpen] = useState(false);
15
- const { setShowSidebar, loading, darkMode, showSidebar } =
16
- useN1WalletInternalContext();
17
- const addressText =
18
- isConnected && address.substring(0, 9) + '...' + address.slice(-3);
19
-
20
- const showLoginFn = () => {
21
- setShowLogin(true);
22
- };
23
-
24
- useEffect(() => {
25
- if (!loading && toOpen) {
26
- showLoginFn();
27
- setToOpen(false);
28
- }
29
- }, [loading]);
30
-
31
- return (
32
- <div className={darkMode ? 'dark' : ''}>
33
- <div className="flex">
34
- {!isConnected && !loading && (
35
- <div
36
- className="rounded-xl shadow cursor-pointer px-3 py-2 duration-300 hover:bg-stone-100 text-sm flex items-center justify-center h-10 min-w-24 group-hover:opacity-80 bg-white dark:bg-neutral-900 text-neutral-900 dark:text-stone-200 border border-neutral-200 dark:border-neutral-700"
37
- onClick={showLoginFn}
38
- >
39
- <span className="font-bold mr-0.5">Connect</span>
40
- </div>
41
- )}
42
- {loading && !isConnected && (
43
- <div
44
- className="rounded-xl shadow cursor-pointer px-3 py-2 duration-300 hover:opacity-80 text-sm flex items-center justify-center h-10 min-w-24 group-hover:opacity-80 bg-white dark:bg-neutral-900 text-neutral-900 dark:text-stone-200 border border-neutral-200 dark:border-neutral-700"
45
- onClick={() => setToOpen(true)}
46
- >
47
- <span className="font-bold mr-0.5">Connect</span>
48
- </div>
49
- )}
50
- {isConnected && (
51
- <div className="relative group">
52
- <div
53
- className="rounded-xl shadow cursor-pointer px-3 py-2 duration-300 hover:opacity-80 text-sm flex items-center justify-start h-10 min-w-24 group-hover:opacity-80 bg-white dark:bg-neutral-900 text-neutral-900 dark:text-stone-200 border border-neutral-200 dark:border-neutral-700"
54
- onClick={() => {
55
- logger.debug('ShowSidebar');
56
- setShowSidebar(true);
57
- }}
58
- >
59
- <div className="h-6 w-6 rounded-full">
60
- <BlockiesSvg
61
- address={address}
62
- className="drop-shadow w-full h-full rounded-full"
63
- />
64
- </div>
65
- <div className="ml-2">{addressText}</div>
66
- </div>
67
- </div>
68
- )}
69
- </div>
70
- </div>
71
- );
72
- }
@@ -1,19 +0,0 @@
1
- import React, { Suspense, ComponentType } from 'react';
2
-
3
- interface LazyLoadWrapperProps {
4
- component: ComponentType<any>;
5
- fallback?: React.ReactNode;
6
- props?: Record<string, any>;
7
- }
8
-
9
- export function LazyLoadWrapper({
10
- component: Component,
11
- fallback = <></>,
12
- props = {},
13
- }: LazyLoadWrapperProps) {
14
- return (
15
- <Suspense fallback={fallback}>
16
- <Component {...props} />
17
- </Suspense>
18
- );
19
- }
package/src/config.ts DELETED
@@ -1,2 +0,0 @@
1
- export const PUBLIC_DISCORD_CLIENT_ID = '1197692401939136573';
2
- export const PUBLIC_DISCORD_APP_URI = 'jSUqXiay1C2PM3hzSY8KdXnX8aEKiISn';
@@ -1,49 +0,0 @@
1
- export enum WalletErrorCode {
2
- CONNECTION_FAILED = 'CONNECTION_FAILED',
3
- WALLET_NOT_FOUND = 'WALLET_NOT_FOUND',
4
- USER_REJECTED = 'USER_REJECTED',
5
- NETWORK_ERROR = 'NETWORK_ERROR',
6
- INVALID_CHAIN = 'INVALID_CHAIN',
7
- UNKNOWN = 'UNKNOWN',
8
- TRANSACTION_FAILED = 'TRANSACTION_FAILED',
9
- }
10
-
11
- export class WalletError extends Error {
12
- constructor(
13
- public code: WalletErrorCode,
14
- message: string,
15
- public details?: Record<string, any>
16
- ) {
17
- super(message);
18
- this.name = 'WalletError';
19
- }
20
-
21
- // Helper method to convert to a format that can be easily displayed
22
- toDisplayFormat() {
23
- return {
24
- title: this.getErrorTitle(),
25
- message: this.message,
26
- code: this.code,
27
- details: this.details ? JSON.stringify(this.details, null, 2) : undefined,
28
- };
29
- }
30
-
31
- private getErrorTitle(): string {
32
- switch (this.code) {
33
- case WalletErrorCode.CONNECTION_FAILED:
34
- return 'Connection Failed';
35
- case WalletErrorCode.WALLET_NOT_FOUND:
36
- return 'Wallet Not Found';
37
- case WalletErrorCode.USER_REJECTED:
38
- return 'Action Rejected';
39
- case WalletErrorCode.NETWORK_ERROR:
40
- return 'Network Error';
41
- case WalletErrorCode.INVALID_CHAIN:
42
- return 'Invalid Chain';
43
- case WalletErrorCode.TRANSACTION_FAILED:
44
- return 'Transaction Failed';
45
- default:
46
- return 'Wallet Error';
47
- }
48
- }
49
- }
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import './main.css';
2
- export { N1WalletProvider } from './Provider/N1WalletProvider';
3
- export { N1ModalViewMode } from './Provider/types';
4
- export { N1ConnectButton } from './WidgetButton/N1ConnectButton';
5
- export { useN1WalletContext } from './Provider/hooks';
package/src/main.css DELETED
@@ -1,3 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
@@ -1,3 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
@@ -1,12 +0,0 @@
1
- import { lazy } from 'react';
2
-
3
- export function lazyLoad(
4
- importFunc: () => Promise<{ [key: string]: any }>,
5
- name = 'default'
6
- ) {
7
- return lazy(() =>
8
- importFunc().then((module) => ({
9
- default: module[name],
10
- }))
11
- );
12
- }