@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.
- package/LICENSE +44 -0
- package/README.md +45 -0
- package/dist/Logic/utils.d.ts +1 -0
- package/dist/Logic/utils.js +47 -9
- package/dist/Modal/BackButton.js +14 -1
- package/dist/Modal/ConnectView.js +20 -23
- package/dist/Modal/CreateSessionView.js +23 -11
- package/dist/Modal/CreateUserView.js +1 -1
- package/dist/Modal/ModalHeader.js +14 -3
- package/dist/Modal/N1WalletModal.js +35 -30
- package/dist/Modal/NoWhitelistView.js +14 -1
- package/dist/Modal/Sidebar/N1Sidebar.js +152 -13
- package/dist/Modal/SigningView.js +1 -1
- package/dist/Provider/LazyWalletProvider.js +6 -2
- package/dist/Provider/N1WalletProvider.js +10 -7
- package/dist/Provider/types.d.ts +8 -0
- package/dist/components/Logo.d.ts +7 -0
- package/dist/components/Logo.js +118 -0
- package/dist/components/QRCodeLoader.d.ts +4 -0
- package/dist/components/QRCodeLoader.js +8 -0
- package/dist/components/WalletDeposit/AnimatedButton.d.ts +17 -0
- package/dist/components/WalletDeposit/AnimatedButton.js +29 -0
- package/dist/components/WalletDeposit/components/ChainButton.d.ts +7 -0
- package/dist/components/WalletDeposit/components/ChainButton.js +5 -0
- package/dist/components/WalletDeposit/components/LoadingSquares.d.ts +1 -0
- package/dist/components/WalletDeposit/components/LoadingSquares.js +5 -0
- package/dist/components/WalletDeposit/components/TransactionTable.d.ts +6 -0
- package/dist/components/WalletDeposit/components/TransactionTable.js +8 -0
- package/dist/components/WalletDeposit/components/WaitingMessage.d.ts +6 -0
- package/dist/components/WalletDeposit/components/WaitingMessage.js +6 -0
- package/dist/components/WalletDeposit/constants.d.ts +15 -0
- package/dist/components/WalletDeposit/constants.js +32 -0
- package/dist/components/WalletDeposit/hooks.d.ts +9 -0
- package/dist/components/WalletDeposit/hooks.js +185 -0
- package/dist/components/WalletDeposit/index.d.ts +1 -0
- package/dist/components/WalletDeposit/index.js +136 -0
- package/dist/components/WalletDeposit/screens/AmountInputScreen.d.ts +12 -0
- package/dist/components/WalletDeposit/screens/AmountInputScreen.js +18 -0
- package/dist/components/WalletDeposit/screens/AppsTableScreen.d.ts +8 -0
- package/dist/components/WalletDeposit/screens/AppsTableScreen.js +28 -0
- package/dist/components/WalletDeposit/screens/ChainSelectionScreen.d.ts +5 -0
- package/dist/components/WalletDeposit/screens/ChainSelectionScreen.js +8 -0
- package/dist/components/WalletDeposit/screens/InitialScreen.d.ts +9 -0
- package/dist/components/WalletDeposit/screens/InitialScreen.js +18 -0
- package/dist/components/WalletDeposit/screens/SigningScreen.d.ts +6 -0
- package/dist/components/WalletDeposit/screens/SigningScreen.js +6 -0
- package/dist/components/WalletDeposit/screens/SuccessScreen.d.ts +12 -0
- package/dist/components/WalletDeposit/screens/SuccessScreen.js +7 -0
- package/dist/components/WalletDeposit/types.d.ts +43 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/main.css +1 -1
- package/dist/utils/dynamicImports.d.ts +24 -0
- package/dist/utils/dynamicImports.js +41 -0
- package/dist/utils/shortenString.d.ts +2 -0
- package/dist/utils/shortenString.js +8 -0
- package/package.json +13 -9
- package/.eslintrc.js +0 -29
- package/dist/Common/NIcon.js +0 -7
- package/dist/components/AnimatedButton.d.ts +0 -9
- package/dist/components/AnimatedButton.js +0 -5
- package/postcss.config.js +0 -6
- package/src/Logic/getPseudoName.ts +0 -5832
- package/src/Logic/utils.ts +0 -162
- package/src/Logic/words.ts +0 -93571
- package/src/Modal/BackButton.tsx +0 -23
- package/src/Modal/ConnectView.tsx +0 -88
- package/src/Modal/CreateSessionView.tsx +0 -242
- package/src/Modal/CreateUserView.tsx +0 -195
- package/src/Modal/ModalHeader.tsx +0 -64
- package/src/Modal/N1WalletModal.tsx +0 -275
- package/src/Modal/NoWhitelistView.tsx +0 -61
- package/src/Modal/Sidebar/N1Sidebar.tsx +0 -172
- package/src/Modal/SigningView.tsx +0 -18
- package/src/Modal/SuccessView.tsx +0 -36
- package/src/Provider/LazyWalletProvider.tsx +0 -136
- package/src/Provider/N1WalletProvider.tsx +0 -208
- package/src/Provider/context.ts +0 -11
- package/src/Provider/hooks.ts +0 -22
- package/src/Provider/icons/CoinbaseWalletIcon.tsx +0 -27
- package/src/Provider/icons/ConnectionDotsSVG.tsx +0 -19
- package/src/Provider/icons/MetamaskIcon.tsx +0 -58
- package/src/Provider/icons/PhantomIcon.tsx +0 -26
- package/src/Provider/icons/UserIcon.tsx +0 -15
- package/src/Provider/icons/WalletConnectIcon.tsx +0 -15
- package/src/Provider/index.ts +0 -3
- package/src/Provider/types.ts +0 -77
- package/src/WidgetButton/N1ConnectButton.tsx +0 -72
- package/src/components/LazyLoadWrapper.tsx +0 -19
- package/src/config.ts +0 -2
- package/src/errors/types.ts +0 -49
- package/src/index.ts +0 -5
- package/src/main.css +0 -3
- package/src/styles/main.css +0 -3
- package/src/utils/lazyLoad.ts +0 -12
- package/src/utils/logger.ts +0 -98
- package/src/utils/react-shim.js +0 -8
- package/tailwind.config.js +0 -44
- package/tsconfig.json +0 -21
- /package/dist/{Common/NIcon.d.ts → components/WalletDeposit/types.js} +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
SOFTWARE LICENSE AGREEMENT
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 N1 Labs. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are protected by copyright laws
|
|
6
|
+
and international treaties. The following terms govern your use of the Software:
|
|
7
|
+
|
|
8
|
+
1. PERMISSIONS
|
|
9
|
+
You are permitted to:
|
|
10
|
+
a) Install and use the Software through official npm packages
|
|
11
|
+
b) Use the Software as part of your applications
|
|
12
|
+
c) Create and distribute applications that use the Software as a dependency
|
|
13
|
+
|
|
14
|
+
2. RESTRICTIONS
|
|
15
|
+
You may not:
|
|
16
|
+
a) Modify, adapt, or create derivative works of the Software
|
|
17
|
+
b) Reverse engineer, decompile, or disassemble the Software
|
|
18
|
+
c) Remove or modify any copyright or proprietary notices
|
|
19
|
+
d) Redistribute the Software except through official npm package dependencies
|
|
20
|
+
e) Fork or create alternate distributions of the Software
|
|
21
|
+
|
|
22
|
+
3. OWNERSHIP
|
|
23
|
+
The Software is owned by N1 Labs and is protected by copyright laws and international treaty
|
|
24
|
+
provisions. N1 Labs retains all rights not expressly granted to you in this Agreement.
|
|
25
|
+
|
|
26
|
+
4. DISTRIBUTION
|
|
27
|
+
The Software may only be distributed through the official npm registry as a package dependency.
|
|
28
|
+
You may list this package as a dependency in your package.json, but may not include its source
|
|
29
|
+
code in your projects.
|
|
30
|
+
|
|
31
|
+
5. NO WARRANTIES
|
|
32
|
+
The Software is provided "AS IS" without warranty of any kind. N1 Labs disclaims all
|
|
33
|
+
warranties, expressed or implied, including but not limited to the implied warranties
|
|
34
|
+
of merchantability and fitness for a particular purpose.
|
|
35
|
+
|
|
36
|
+
6. LIMITATION OF LIABILITY
|
|
37
|
+
In no event shall N1 Labs be liable for any damages whatsoever arising out of the use
|
|
38
|
+
of or inability to use the Software.
|
|
39
|
+
|
|
40
|
+
7. TERMINATION
|
|
41
|
+
This license will terminate automatically if you fail to comply with any of the terms
|
|
42
|
+
and conditions of this Agreement. Upon termination, you must cease all use of the Software.
|
|
43
|
+
|
|
44
|
+
For licensing inquiries, please contact: legal@n1.xyz
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @n1xyz/wallet-widget
|
|
2
|
+
|
|
3
|
+
A React wallet widget component for N1 applications that provides a seamless integration for wallet connections and management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @n1xyz/wallet-widget
|
|
9
|
+
# or
|
|
10
|
+
yarn add @n1xyz/wallet-widget
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @n1xyz/wallet-widget
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { WalletWidget } from '@n1xyz/wallet-widget';
|
|
19
|
+
import '@n1xyz/wallet-widget/dist/main.css';
|
|
20
|
+
|
|
21
|
+
function App() {
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<WalletWidget />
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Features
|
|
31
|
+
|
|
32
|
+
- Seamless wallet connection
|
|
33
|
+
- Support for multiple wallet providers
|
|
34
|
+
- Built-in styling with Tailwind CSS
|
|
35
|
+
- TypeScript support
|
|
36
|
+
- Customizable appearance
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- React 18 or higher
|
|
41
|
+
- React DOM 18 or higher
|
|
42
|
+
|
|
43
|
+
## License
|
|
44
|
+
|
|
45
|
+
See [LICENSE](./LICENSE) file for details.
|
package/dist/Logic/utils.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export declare function hexToUint8Array(hex: string): Uint8Array<ArrayBuffer>;
|
|
|
18
18
|
export declare function createWebSession(signMessageWithSessionKey: any, sessionPubKey: any, walletPubKey: any): Promise<void>;
|
|
19
19
|
export declare function createUser(username: any): Promise<void>;
|
|
20
20
|
export declare function getUser(): Promise<any>;
|
|
21
|
+
export declare function getUserBalances(address: string): Promise<any>;
|
package/dist/Logic/utils.js
CHANGED
|
@@ -115,6 +115,9 @@ export function createWebSession(signMessageWithSessionKey, sessionPubKey, walle
|
|
|
115
115
|
return [4 /*yield*/, signMessageWithSessionKey(msg)];
|
|
116
116
|
case 1:
|
|
117
117
|
signature = _c.sent();
|
|
118
|
+
if (process.env.SKIP_ARGUS) {
|
|
119
|
+
return [2 /*return*/];
|
|
120
|
+
}
|
|
118
121
|
return [4 /*yield*/, fetch("".concat(process.env.ARGUS_URL, "/api/auth/login"), {
|
|
119
122
|
method: 'POST',
|
|
120
123
|
headers: {
|
|
@@ -170,7 +173,12 @@ export function getUser() {
|
|
|
170
173
|
return __generator(this, function (_a) {
|
|
171
174
|
switch (_a.label) {
|
|
172
175
|
case 0:
|
|
173
|
-
|
|
176
|
+
if (process.env.SKIP_ARGUS) {
|
|
177
|
+
return [2 /*return*/, { name: 'test' }];
|
|
178
|
+
}
|
|
179
|
+
_a.label = 1;
|
|
180
|
+
case 1:
|
|
181
|
+
_a.trys.push([1, 6, , 7]);
|
|
174
182
|
return [4 /*yield*/, fetch("".concat(process.env.ARGUS_URL, "/api/db/getUser"), {
|
|
175
183
|
method: 'GET',
|
|
176
184
|
headers: {
|
|
@@ -178,21 +186,51 @@ export function getUser() {
|
|
|
178
186
|
},
|
|
179
187
|
credentials: 'include', // Include cookies in requests
|
|
180
188
|
})];
|
|
181
|
-
case
|
|
189
|
+
case 2:
|
|
182
190
|
response = _a.sent();
|
|
183
|
-
if (!(response.status === 200)) return [3 /*break*/,
|
|
191
|
+
if (!(response.status === 200)) return [3 /*break*/, 4];
|
|
184
192
|
return [4 /*yield*/, response.json()];
|
|
185
|
-
case
|
|
186
|
-
case
|
|
193
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
194
|
+
case 4:
|
|
187
195
|
if (response.status === 404) {
|
|
188
196
|
return [2 /*return*/, null];
|
|
189
197
|
}
|
|
190
|
-
_a.label =
|
|
191
|
-
case
|
|
192
|
-
case
|
|
198
|
+
_a.label = 5;
|
|
199
|
+
case 5: return [3 /*break*/, 7];
|
|
200
|
+
case 6:
|
|
193
201
|
error_1 = _a.sent();
|
|
194
202
|
throw new Error('failed to get user!');
|
|
195
|
-
case
|
|
203
|
+
case 7: return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
export function getUserBalances(address) {
|
|
209
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
210
|
+
var response, data;
|
|
211
|
+
return __generator(this, function (_a) {
|
|
212
|
+
switch (_a.label) {
|
|
213
|
+
case 0: return [4 /*yield*/, fetch("https://n1ts.n1.xyz/app/data?tag=user_balance_".concat(address.toLowerCase()), {
|
|
214
|
+
method: 'GET',
|
|
215
|
+
headers: {
|
|
216
|
+
'Content-Type': 'application/json',
|
|
217
|
+
},
|
|
218
|
+
})];
|
|
219
|
+
case 1:
|
|
220
|
+
response = _a.sent();
|
|
221
|
+
if (!(response.status === 200)) return [3 /*break*/, 3];
|
|
222
|
+
return [4 /*yield*/, response.json()];
|
|
223
|
+
case 2:
|
|
224
|
+
data = _a.sent();
|
|
225
|
+
return [2 /*return*/, data.data.map(function (item) {
|
|
226
|
+
return {
|
|
227
|
+
mint: item.field_id.split('_')[2],
|
|
228
|
+
balance: item.value,
|
|
229
|
+
appId: item.app_id,
|
|
230
|
+
symbol: item.symbol,
|
|
231
|
+
};
|
|
232
|
+
})];
|
|
233
|
+
case 3: return [2 /*return*/, null];
|
|
196
234
|
}
|
|
197
235
|
});
|
|
198
236
|
});
|
package/dist/Modal/BackButton.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useN1WalletInternalContext } from '../Provider/hooks';
|
|
3
|
+
import { useState } from 'react';
|
|
3
4
|
import { N1ModalViewMode } from '../Provider/types';
|
|
5
|
+
import { ANIMATION_EASE } from '../components/WalletDeposit/constants';
|
|
4
6
|
export function BackButton(props) {
|
|
5
7
|
var _a = useN1WalletInternalContext(), setViewMode = _a.setViewMode, dynamicHandleLogOut = _a.dynamicHandleLogOut;
|
|
8
|
+
var _b = useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
9
|
+
var _c = useState(false), isPressed = _c[0], setIsPressed = _c[1];
|
|
6
10
|
function back() {
|
|
7
11
|
// todo: disconnect
|
|
8
12
|
console.log('back');
|
|
9
13
|
dynamicHandleLogOut();
|
|
10
14
|
setViewMode(N1ModalViewMode.Connect);
|
|
11
15
|
}
|
|
12
|
-
return (_jsx("button", {
|
|
16
|
+
return (_jsx("button", { onClick: props.onClick || back, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () {
|
|
17
|
+
setIsHovered(false);
|
|
18
|
+
setIsPressed(false);
|
|
19
|
+
}, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60\n "), style: {
|
|
20
|
+
transform: isPressed
|
|
21
|
+
? 'scale(0.98)'
|
|
22
|
+
: isHovered
|
|
23
|
+
? 'scale(0.99)'
|
|
24
|
+
: 'scale(1)',
|
|
25
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center", children: _jsx("span", { className: "\n text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Back" }) }) }) }));
|
|
13
26
|
}
|
|
@@ -35,37 +35,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
|
+
import { IoMdWallet } from 'react-icons/io';
|
|
38
39
|
import { useN1WalletInternalContext } from '../Provider/hooks';
|
|
39
40
|
import { ModalHeader } from './ModalHeader';
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import clsx from 'clsx';
|
|
41
|
+
import { ANIMATION_EASE, } from '../components/WalletDeposit/constants';
|
|
42
|
+
import { useState } from 'react';
|
|
43
43
|
export function ConnectView() {
|
|
44
44
|
var _this = this;
|
|
45
45
|
var _a = useN1WalletInternalContext(), showDynamicWidget = _a.showDynamicWidget, handleError = _a.handleError;
|
|
46
|
+
var _b = useState(null), isHovered = _b[0], setIsHovered = _b[1];
|
|
46
47
|
var handleConnect = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
48
|
+
var error_1;
|
|
47
49
|
return __generator(this, function (_a) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return [
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
_a.trys.push([0, 2, , 3]);
|
|
53
|
+
return [4 /*yield*/, showDynamicWidget(true)];
|
|
54
|
+
case 1:
|
|
55
|
+
_a.sent();
|
|
56
|
+
return [3 /*break*/, 3];
|
|
57
|
+
case 2:
|
|
58
|
+
error_1 = _a.sent();
|
|
59
|
+
handleError(error_1);
|
|
60
|
+
return [3 /*break*/, 3];
|
|
61
|
+
case 3: return [2 /*return*/];
|
|
54
62
|
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (error instanceof WalletError) {
|
|
57
|
-
handleError(error);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
handleError(new WalletError(WalletErrorCode.CONNECTION_FAILED, 'Failed to connect to wallet', { originalError: error }));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return [2 /*return*/];
|
|
64
63
|
});
|
|
65
64
|
}); };
|
|
66
|
-
return (_jsxs("div", { className: "rounded-[
|
|
67
|
-
|
|
68
|
-
function
|
|
69
|
-
var children = _a.children, onClick = _a.onClick, buttonClassName = _a.buttonClassName;
|
|
70
|
-
return (_jsxs("button", { className: clsx(buttonClassName, 'flex flex-row'), onClick: onClick, children: [children, _jsx("span", { className: "ml-4 opacity-0 transform translate-x-[-10px] transition-all duration-200 group-hover:opacity-100 group-hover:translate-x-0", children: "\u2192" })] }));
|
|
65
|
+
return (_jsxs("div", { className: "bg-gray-50 dark:bg-gray-950 relative border border-gray-200 dark:border-gray-800 rounded-md transition-[max-width,transform,opacity] duration-[3000ms] ease-[cubic-bezier(0.16,1,0.3,1)] w-full max-w-sm m-4 origin-center will-change-[max-width,transform,opacity]", children: [_jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-800", children: _jsx(ModalHeader, {}) }), _jsx("div", { className: "p-6 overflow-hidden relative", children: _jsxs("div", { className: "space-y-4", children: [_jsx("button", { onClick: handleConnect, onMouseEnter: function () { return setIsHovered('wallet'); }, onMouseLeave: function () { return setIsHovered(null); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60\n "), style: {
|
|
66
|
+
transform: isHovered === 'wallet' ? 'scale(0.99)' : 'scale(1)',
|
|
67
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsxs("div", { className: "flex items-center", children: [_jsx(IoMdWallet, { className: "w-5 h-5 text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white transition-colors duration-300" }), _jsx("span", { className: "\n ml-2 text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Continue with Wallet" })] }) }) }), _jsx("button", { disabled: true, onMouseEnter: function () { return setIsHovered('google'); }, onMouseLeave: function () { return setIsHovered(null); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-not-allowed border-gray-200 dark:border-gray-800 opacity-50\n "), children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center", children: _jsx("span", { className: "text-base font-medium tracking-wide text-gray-500 dark:text-neutral-400", children: "Continue with Google (soon)" }) }) }) }), _jsx("button", { disabled: true, onMouseEnter: function () { return setIsHovered('email'); }, onMouseLeave: function () { return setIsHovered(null); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-not-allowed border-gray-200 dark:border-gray-800 opacity-50\n "), children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center", children: _jsx("span", { className: "text-base font-medium tracking-wide text-gray-500 dark:text-neutral-400", children: "Continue with Email (soon)" }) }) }) })] }) })] }));
|
|
71
68
|
}
|
|
@@ -36,20 +36,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
38
|
import { useEffect, useState } from 'react';
|
|
39
|
+
import { ANIMATION_EASE } from '../components/WalletDeposit/constants';
|
|
40
|
+
import { WalletError, WalletErrorCode } from '../errors/types';
|
|
41
|
+
import { createWebSession, generateSessionKeyPair, getUser, storeSessionKeysInLocalStorage, } from '../Logic/utils';
|
|
39
42
|
import { useN1WalletContext, useN1WalletInternalContext, } from '../Provider/hooks';
|
|
40
|
-
import { ModalHeader } from './ModalHeader';
|
|
41
43
|
import { N1ModalViewMode } from '../Provider/types';
|
|
44
|
+
import { logger } from '../utils/logger';
|
|
42
45
|
import { BackButton } from './BackButton';
|
|
43
|
-
import {
|
|
46
|
+
import { ModalHeader } from './ModalHeader';
|
|
44
47
|
import { signEd25519 } from '@n1xyz/nts-sdk';
|
|
45
|
-
import { logger } from '../utils/logger';
|
|
46
|
-
import { WalletError, WalletErrorCode } from '../errors/types';
|
|
47
48
|
export function CreateSessionView() {
|
|
48
49
|
var _this = this;
|
|
49
|
-
var _a = useState(
|
|
50
|
-
var _b = useState(
|
|
51
|
-
var _c =
|
|
52
|
-
var _d =
|
|
50
|
+
var _a = useState(false), isHovered = _a[0], setIsHovered = _a[1];
|
|
51
|
+
var _b = useState(false), isPressed = _b[0], setIsPressed = _b[1];
|
|
52
|
+
var _c = useState(null), NTSComponents = _c[0], setNTSComponents = _c[1];
|
|
53
|
+
var _d = useState(null), keyPair = _d[0], setKeyPair = _d[1];
|
|
54
|
+
var _e = useN1WalletInternalContext(), setViewMode = _e.setViewMode, setUsername = _e.setUsername, setStartClosingLogin = _e.setStartClosingLogin, setIsConnected = _e.setIsConnected, dynamicWallet = _e.dynamicWallet, handleError = _e.handleError, setSessionPubKey = _e.setSessionPubKey, setSignMessageWithSessionKey = _e.setSignMessageWithSessionKey, dynamicHandleLogOut = _e.dynamicHandleLogOut, setDynamicWallet = _e.setDynamicWallet, setAddress = _e.setAddress, setSignMessageWithWalletKey = _e.setSignMessageWithWalletKey;
|
|
55
|
+
var _f = useN1WalletContext(), ntsInterface = _f.ntsInterface, walletPubKey = _f.walletPubKey, address = _f.address;
|
|
53
56
|
// Initialize NTS SDK and generate key pair
|
|
54
57
|
useEffect(function () {
|
|
55
58
|
var loadNTSSDK = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -224,13 +227,22 @@ export function CreateSessionView() {
|
|
|
224
227
|
}
|
|
225
228
|
});
|
|
226
229
|
}); };
|
|
227
|
-
return (_jsxs("div", { className: "
|
|
230
|
+
return (_jsxs("div", { className: "bg-gray-50 dark:bg-gray-950 relative border border-gray-200 dark:border-gray-800 rounded-md transition-[max-width,transform,opacity] duration-[3000ms] ease-[cubic-bezier(0.16,1,0.3,1)] w-full max-w-sm m-4 origin-center will-change-[max-width,transform,opacity]", children: [_jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-800", children: _jsx(ModalHeader, {}) }), _jsx("div", { className: "p-6 overflow-hidden relative", children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "text-center", children: [_jsx("h3", { className: "text-xl font-medium text-gray-900 dark:text-white mb-2", children: "Create Session" }), _jsx("p", { className: "text-gray-500 dark:text-gray-400", children: "Please authenticate to create a new session." })] }), _jsx("button", { onClick: handleSign, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () {
|
|
231
|
+
setIsHovered(false);
|
|
232
|
+
setIsPressed(false);
|
|
233
|
+
}, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, disabled: !NTSComponents || !keyPair, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-left\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n ").concat(!NTSComponents || !keyPair
|
|
234
|
+
? 'cursor-not-allowed border-gray-200 dark:border-gray-800 opacity-50'
|
|
235
|
+
: 'cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60', "\n "), style: {
|
|
236
|
+
transform: isPressed && (!NTSComponents || !keyPair)
|
|
237
|
+
? 'scale(0.98)'
|
|
238
|
+
: isHovered && (!NTSComponents || !keyPair)
|
|
239
|
+
? 'scale(0.99)'
|
|
240
|
+
: 'scale(1)',
|
|
241
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center justify-start", children: _jsx("span", { className: "\n text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Authenticate" }) }) }) }), _jsx(BackButton, { onClick: function () {
|
|
228
242
|
logger.debug('BackButton clicked');
|
|
229
|
-
// Log out wallet
|
|
230
243
|
setDynamicWallet(null);
|
|
231
244
|
setAddress('');
|
|
232
245
|
dynamicHandleLogOut();
|
|
233
|
-
// Set view mode to connect
|
|
234
246
|
setViewMode(N1ModalViewMode.Connect);
|
|
235
247
|
} })] }) })] }));
|
|
236
248
|
}
|
|
@@ -156,5 +156,5 @@ export function CreateUserView() {
|
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
-
return (_jsxs("div", { className: "rounded-[25px] shadow-lg p-5 m-4 bg-white dark:bg-neutral-900 text-neutral-900 dark:text-stone-200", children: [_jsx(ModalHeader, {}), _jsx("div", { className: "flex flex-col items-center justify-center", children: _jsxs("div", { className: "flex mb-2 justify-center sm:justify-between w-full flex-wrap max-w-screen", children: [_jsxs("div", { className: "flex flex-col", children: [_jsx("div", { className: "w-80 h-80 sm:w-48 sm:h-48 rounded-[25px] flex items-center justify-center relative bg-neutral-100 dark:bg-neutral-800", children: _jsx("div", { className: "overflow-hidden rounded-lg w-80 h-80 sm:w-48 sm:h-48 p-2", children: _jsx(BlockiesSvg, { address: address, className: "drop-shadow w-full h-full rounded-[20px]" }) }) }), _jsx("div", { className: "my-4 w-80 sm:w-48 p-2 border rounded-[15px] text-sm duration-300 bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 border-neutral-200 dark:border-neutral-700", children: "You are creating an account that you can use across all N1." })] }), _jsxs("div", { className: "w-80 flex flex-col items-center sm:items-end justify-between h-full my-2", children: [_jsxs("div", { className: "flex flex-col relative bg-neutral-100 dark:bg-neutral-800 border-neutral-200 dark:border-neutral-700 rounded-[15px] border w-72", children: [_jsx("input", { type: "text", id: "username", placeholder: "Enter your username", value: usernameLocal, onChange: function (e) { return setUsernameLocalLocal(e.target.value); }, className: "p-3 py-4 outline-none focus:ring focus:ring-orange-200 bg-neutral-100 dark:bg-neutral-800 text-neutral-900 dark:text-stone-200 rounded-[15px] border ".concat(error ? 'border-
|
|
159
|
+
return (_jsxs("div", { className: "rounded-[25px] shadow-lg p-5 m-4 bg-white dark:bg-neutral-900 text-neutral-900 dark:text-stone-200", children: [_jsx(ModalHeader, {}), _jsx("div", { className: "flex flex-col items-center justify-center", children: _jsxs("div", { className: "flex mb-2 justify-center sm:justify-between w-full flex-wrap max-w-screen", children: [_jsxs("div", { className: "flex flex-col", children: [_jsx("div", { className: "w-80 h-80 sm:w-48 sm:h-48 rounded-[25px] flex items-center justify-center relative bg-neutral-100 dark:bg-neutral-800", children: _jsx("div", { className: "overflow-hidden rounded-lg w-80 h-80 sm:w-48 sm:h-48 p-2", children: _jsx(BlockiesSvg, { address: address, className: "drop-shadow w-full h-full rounded-[20px]" }) }) }), _jsx("div", { className: "my-4 w-80 sm:w-48 p-2 border rounded-[15px] text-sm duration-300 bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 border-neutral-200 dark:border-neutral-700", children: "You are creating an account that you can use across all N1." })] }), _jsxs("div", { className: "w-80 flex flex-col items-center sm:items-end justify-between h-full my-2", children: [_jsxs("div", { className: "flex flex-col relative bg-neutral-100 dark:bg-neutral-800 border-neutral-200 dark:border-neutral-700 rounded-[15px] border w-72", children: [_jsx("input", { type: "text", id: "username", placeholder: "Enter your username", value: usernameLocal, onChange: function (e) { return setUsernameLocalLocal(e.target.value); }, className: "p-3 py-4 outline-none focus:ring focus:ring-orange-200 bg-neutral-100 dark:bg-neutral-800 text-neutral-900 dark:text-stone-200 rounded-[15px] border ".concat(error ? 'border-main' : 'border-neutral-200 dark:border-neutral-700') }), _jsxs("div", { className: "p-2 flex w-full justify-between text-xs text-neutral-500 dark:text-neutral-400", children: [_jsx("span", { className: "font-bold", children: "Username:" }), " ", usernameLocal] }), _jsxs("div", { className: "px-2 pb-2 flex w-full justify-between text-xs text-neutral-500 dark:text-neutral-400", children: [_jsx("span", { className: "font-bold", children: "Wallet:" }), ' ', address.substring(0, 9) + '...' + address.slice(-3)] })] }), error && (_jsx("div", { className: "mt-2 w-72 p-2 text-main bg-main/5 dark:bg-main/20 border border-main/40 rounded-[15px] text-center", children: error })), _jsx("button", { className: "my-4 w-72 py-4 border rounded-[15px] text-white bg-neutral-900 dark:bg-white dark:text-black cursor-pointer duration-300 hover:opacity-80", onClick: handleCreate, children: "Create" }), _jsx("div", { className: "w-72", children: _jsx("button", { className: "w-full py-4 border rounded-[18px] cursor-pointer duration-300 hover:opacity-80 bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 border-neutral-200 dark:border-neutral-700 hover:opacity-80", onClick: close, children: "Close" }) })] })] }) })] }));
|
|
160
160
|
}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useN1WalletInternalContext } from '../Provider/hooks';
|
|
2
|
+
import { useN1WalletContext, useN1WalletInternalContext, } from '../Provider/hooks';
|
|
3
|
+
import { N1ModalViewMode } from '../Provider/types';
|
|
4
|
+
import { X } from 'lucide-react';
|
|
5
|
+
import Logo from '../components/Logo';
|
|
6
|
+
import { ANIMATION_EASE } from '../components/WalletDeposit/constants';
|
|
3
7
|
export function ModalHeader() {
|
|
4
|
-
var
|
|
8
|
+
var _a = useN1WalletInternalContext(), setViewMode = _a.setViewMode, setStartClosingLogin = _a.setStartClosingLogin, setDynamicWallet = _a.setDynamicWallet, setAddress = _a.setAddress, dynamicHandleLogOut = _a.dynamicHandleLogOut;
|
|
9
|
+
var viewMode = useN1WalletContext().viewMode;
|
|
5
10
|
var close = function () {
|
|
6
11
|
setStartClosingLogin(true);
|
|
12
|
+
if (viewMode === N1ModalViewMode.CreateSession) {
|
|
13
|
+
setDynamicWallet(null);
|
|
14
|
+
setAddress('');
|
|
15
|
+
dynamicHandleLogOut();
|
|
16
|
+
setViewMode(N1ModalViewMode.Connect);
|
|
17
|
+
}
|
|
7
18
|
};
|
|
8
|
-
return (_jsxs("div", { className: "flex items-center justify-between
|
|
19
|
+
return (_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx("div", { className: "w-6 h-6 text-gray-50", children: _jsx(Logo, { size: 24 }) }), _jsxs("h2", { className: "text-xl text-gray-400 flex items-center gap-2", children: ["Connect", viewMode === N1ModalViewMode.CreateSession && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Session" })), viewMode === N1ModalViewMode.Signing && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Sign" })), viewMode === N1ModalViewMode.CreatingUser && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Create User" })), viewMode === N1ModalViewMode.Success && (_jsx("span", { className: "text-gray-700 dark:text-gray-300 font-normal", children: "/ / Success" }))] })] }), _jsx("button", { onClick: close, className: "\n text-neutral-400 hover:text-gray-900 dark:hover:text-white \n transition-colors duration-300 ".concat(ANIMATION_EASE, "\n h-10 w-10 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800\n flex items-center justify-center\n "), children: _jsx(X, { size: 20 }) })] }));
|
|
9
20
|
}
|
|
@@ -37,11 +37,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
38
38
|
import { useEffect, useState, lazy, Suspense } from 'react';
|
|
39
39
|
import { useN1WalletContext, useN1WalletInternalContext, } from '../Provider/hooks';
|
|
40
|
-
import { createWebSession, getSessionKeysFromLocalStorage, getUser, } from '../Logic/utils';
|
|
40
|
+
import { createWebSession, getSessionKeysFromLocalStorage, getUser, getUserBalances, } from '../Logic/utils';
|
|
41
41
|
import { getEd25519PublicKey, signEd25519, bs58Decode } from '@n1xyz/nts-sdk';
|
|
42
42
|
import { N1ModalViewMode } from '../Provider/types';
|
|
43
43
|
import { logger } from '../utils/logger';
|
|
44
44
|
import { WalletError, WalletErrorCode } from '../errors/types';
|
|
45
|
+
import { ANIMATION_EASE, } from '../components/WalletDeposit/constants';
|
|
45
46
|
// Lazy load components
|
|
46
47
|
var ConnectView = lazy(function () {
|
|
47
48
|
return import('./ConnectView').then(function (mod) { return ({ default: mod.ConnectView }); });
|
|
@@ -66,11 +67,11 @@ var N1Sidebar = lazy(function () {
|
|
|
66
67
|
var NoWhitelistView = lazy(function () {
|
|
67
68
|
return import('./NoWhitelistView').then(function (mod) { return ({ default: mod.NoWhitelistView }); });
|
|
68
69
|
});
|
|
69
|
-
var LoadingFallback = function () { return (_jsx("div", { className: "flex items-center justify-center w-full h-full", children: _jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-
|
|
70
|
+
var LoadingFallback = function () { return (_jsx("div", { className: "flex items-center justify-center w-full h-full", children: _jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-gray-200 dark:border-gray-800" }) })); };
|
|
70
71
|
export function N1WalletModal() {
|
|
71
72
|
var _this = this;
|
|
72
73
|
var _a = useN1WalletContext(), showLogin = _a.showLogin, setShowLogin = _a.setShowLogin, viewMode = _a.viewMode;
|
|
73
|
-
var _b = useN1WalletInternalContext(), setViewMode = _b.setViewMode, setUsername = _b.setUsername, setSessionPubKey = _b.setSessionPubKey, setSignMessageWithSessionKey = _b.setSignMessageWithSessionKey, setIsConnected = _b.setIsConnected, setWalletPubKey = _b.setWalletPubKey, setStartClosingLogin = _b.setStartClosingLogin, startClosingLogin = _b.startClosingLogin, setLoading = _b.setLoading, setAddress = _b.setAddress, dynamicWallet = _b.dynamicWallet, dynamicSdkHasLoaded = _b.dynamicSdkHasLoaded, darkMode = _b.darkMode, handleError = _b.handleError, showSidebar = _b.showSidebar;
|
|
74
|
+
var _b = useN1WalletInternalContext(), setBalances = _b.setBalances, setViewMode = _b.setViewMode, setUsername = _b.setUsername, setSessionPubKey = _b.setSessionPubKey, setSignMessageWithSessionKey = _b.setSignMessageWithSessionKey, setIsConnected = _b.setIsConnected, setWalletPubKey = _b.setWalletPubKey, setStartClosingLogin = _b.setStartClosingLogin, startClosingLogin = _b.startClosingLogin, setLoading = _b.setLoading, setAddress = _b.setAddress, dynamicWallet = _b.dynamicWallet, dynamicSdkHasLoaded = _b.dynamicSdkHasLoaded, darkMode = _b.darkMode, handleError = _b.handleError, showSidebar = _b.showSidebar;
|
|
74
75
|
var _c = useState(false), showLoginAnimation = _c[0], setShowLoginAnimation = _c[1];
|
|
75
76
|
// Handle loading state
|
|
76
77
|
useEffect(function () {
|
|
@@ -82,7 +83,7 @@ export function N1WalletModal() {
|
|
|
82
83
|
useEffect(function () {
|
|
83
84
|
logger.debug('N1WalletModal attempt to call initializeSession...');
|
|
84
85
|
var initializeSession = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
85
|
-
var response, whitelistData, walletPubKey, sessionData_1, sessionPubKey, signFn_1, user, storedUsername, username, error_1, error_2;
|
|
86
|
+
var response, whitelistData, walletPubKey, sessionData_1, sessionPubKey, signFn_1, user, storedUsername, username, balances, error_1, error_2;
|
|
86
87
|
var _this = this;
|
|
87
88
|
return __generator(this, function (_a) {
|
|
88
89
|
switch (_a.label) {
|
|
@@ -93,7 +94,7 @@ export function N1WalletModal() {
|
|
|
93
94
|
}
|
|
94
95
|
_a.label = 1;
|
|
95
96
|
case 1:
|
|
96
|
-
_a.trys.push([1,
|
|
97
|
+
_a.trys.push([1, 15, , 16]);
|
|
97
98
|
logger.debug('Initialize Session...');
|
|
98
99
|
if (!dynamicWallet) return [3 /*break*/, 4];
|
|
99
100
|
return [4 /*yield*/, fetch('https://argus-1g4n.onrender.com/api/db/verifyWhitelist', {
|
|
@@ -119,7 +120,7 @@ export function N1WalletModal() {
|
|
|
119
120
|
console.log('Session Initialization started');
|
|
120
121
|
_a.label = 5;
|
|
121
122
|
case 5:
|
|
122
|
-
_a.trys.push([5,
|
|
123
|
+
_a.trys.push([5, 12, 13, 14]);
|
|
123
124
|
walletPubKey = dynamicWallet.chain === 'SOL'
|
|
124
125
|
? bs58Decode(dynamicWallet.address)
|
|
125
126
|
: Uint8Array.from(Buffer.from(dynamicWallet.address.slice(2), 'hex'));
|
|
@@ -172,34 +173,42 @@ export function N1WalletModal() {
|
|
|
172
173
|
case 8:
|
|
173
174
|
user = _a.sent();
|
|
174
175
|
storedUsername = localStorage.getItem("n1_".concat(dynamicWallet.address, "_username"));
|
|
175
|
-
if ((user === null || user === void 0 ? void 0 : user.name) || storedUsername)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
logger.info('No user found, transitioning to CreateUser');
|
|
185
|
-
setViewMode(N1ModalViewMode.CreatingUser);
|
|
186
|
-
}
|
|
187
|
-
return [3 /*break*/, 11];
|
|
176
|
+
if (!((user === null || user === void 0 ? void 0 : user.name) || storedUsername)) return [3 /*break*/, 10];
|
|
177
|
+
logger.info('User found, completing login');
|
|
178
|
+
username = (user === null || user === void 0 ? void 0 : user.name) || storedUsername;
|
|
179
|
+
setIsConnected(true);
|
|
180
|
+
setUsername(username);
|
|
181
|
+
localStorage.setItem("n1_".concat(dynamicWallet.address, "_username"), username);
|
|
182
|
+
//fetch balances
|
|
183
|
+
logger.info('fetching balances');
|
|
184
|
+
return [4 /*yield*/, getUserBalances(dynamicWallet.address)];
|
|
188
185
|
case 9:
|
|
186
|
+
balances = _a.sent();
|
|
187
|
+
setBalances(balances);
|
|
188
|
+
logger.info('balances fetched', balances);
|
|
189
|
+
//finish login
|
|
190
|
+
setStartClosingLogin(true);
|
|
191
|
+
return [3 /*break*/, 11];
|
|
192
|
+
case 10:
|
|
193
|
+
logger.info('No user found, transitioning to CreateUser');
|
|
194
|
+
setViewMode(N1ModalViewMode.CreatingUser);
|
|
195
|
+
_a.label = 11;
|
|
196
|
+
case 11: return [3 /*break*/, 14];
|
|
197
|
+
case 12:
|
|
189
198
|
error_1 = _a.sent();
|
|
190
199
|
logger.error('Session initialization failed:', error_1);
|
|
191
200
|
handleError(new WalletError(WalletErrorCode.CONNECTION_FAILED, 'Failed to initialize session', { originalError: error_1 }));
|
|
192
|
-
return [3 /*break*/,
|
|
193
|
-
case
|
|
201
|
+
return [3 /*break*/, 14];
|
|
202
|
+
case 13:
|
|
194
203
|
logger.groupEnd();
|
|
195
204
|
return [7 /*endfinally*/];
|
|
196
|
-
case
|
|
197
|
-
case
|
|
205
|
+
case 14: return [3 /*break*/, 16];
|
|
206
|
+
case 15:
|
|
198
207
|
error_2 = _a.sent();
|
|
199
208
|
logger.error('Whitelist check failed:', error_2);
|
|
200
209
|
handleError(new WalletError(WalletErrorCode.CONNECTION_FAILED, 'Failed to check whitelist', { originalError: error_2 }));
|
|
201
|
-
return [3 /*break*/,
|
|
202
|
-
case
|
|
210
|
+
return [3 /*break*/, 16];
|
|
211
|
+
case 16: return [2 /*return*/];
|
|
203
212
|
}
|
|
204
213
|
});
|
|
205
214
|
}); };
|
|
@@ -224,9 +233,5 @@ export function N1WalletModal() {
|
|
|
224
233
|
}, [startClosingLogin, setShowLogin, setStartClosingLogin]);
|
|
225
234
|
if (!showLogin && !showSidebar)
|
|
226
235
|
return null;
|
|
227
|
-
|
|
228
|
-
return (_jsxs("div", { className: darkMode ? 'dark' : '', children: [showLogin && (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: _jsx("div", { className: "duration-500 ease-in-out font-monument w-screen h-screen fixed top-0 left-0 flex items-center justify-center z-100 ".concat(showLoginAnimation ? 'opacity-100' : 'opacity-0'), style: {
|
|
229
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
230
|
-
backdropFilter: 'blur(4px)',
|
|
231
|
-
}, children: _jsxs(Suspense, { fallback: _jsx(LoadingFallback, {}), children: [viewMode === N1ModalViewMode.Connect && _jsx(ConnectView, {}), viewMode === N1ModalViewMode.CreateSession && (_jsx(CreateSessionView, {})), viewMode === N1ModalViewMode.Signing && _jsx(SigningView, {}), viewMode === N1ModalViewMode.CreatingUser && _jsx(CreateUserView, {}), viewMode === N1ModalViewMode.Success && _jsx(SuccessView, {}), viewMode === N1ModalViewMode.NoWhitelist && _jsx(NoWhitelistView, {})] }) }) })), _jsx(Suspense, { fallback: _jsx(LoadingFallback, {}), children: _jsx(N1Sidebar, {}) })] }));
|
|
236
|
+
return (_jsxs("div", { className: darkMode ? 'dark' : '', children: [showLogin && (_jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [_jsx("div", { className: "\n fixed inset-0 bg-black/20 dark:bg-black/40 backdrop-blur-sm\n transition-all duration-500 ".concat(ANIMATION_EASE, "\n ").concat(showLoginAnimation ? 'opacity-100' : 'opacity-0', "\n "), onClick: function () { return setStartClosingLogin(true); } }), _jsx("div", { className: "\n relative z-50 transition-all duration-500 ".concat(ANIMATION_EASE, "\n ").concat(showLoginAnimation ? 'opacity-100 scale-100' : 'opacity-0 scale-95', "\n "), children: _jsxs(Suspense, { fallback: _jsx(LoadingFallback, {}), children: [viewMode === N1ModalViewMode.Connect && _jsx(ConnectView, {}), viewMode === N1ModalViewMode.CreateSession && (_jsx(CreateSessionView, {})), viewMode === N1ModalViewMode.Signing && _jsx(SigningView, {}), viewMode === N1ModalViewMode.CreatingUser && _jsx(CreateUserView, {}), viewMode === N1ModalViewMode.Success && _jsx(SuccessView, {}), viewMode === N1ModalViewMode.NoWhitelist && _jsx(NoWhitelistView, {})] }) })] })), _jsx(Suspense, { fallback: _jsx(LoadingFallback, {}), children: _jsx(N1Sidebar, {}) })] }));
|
|
232
237
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { useN1WalletInternalContext, useN1WalletContext, } from '../Provider/hooks';
|
|
3
4
|
import { N1ModalViewMode } from '../Provider/types';
|
|
4
5
|
import { ModalHeader } from './ModalHeader';
|
|
6
|
+
import { ANIMATION_EASE } from '../components/WalletDeposit/constants';
|
|
5
7
|
export function NoWhitelistView() {
|
|
6
8
|
var _a = useN1WalletInternalContext(), setViewMode = _a.setViewMode, dynamicHandleLogOut = _a.dynamicHandleLogOut, setIsConnected = _a.setIsConnected;
|
|
7
9
|
var address = useN1WalletContext().address;
|
|
10
|
+
var _b = useState(false), isHovered = _b[0], setIsHovered = _b[1];
|
|
11
|
+
var _c = useState(false), isPressed = _c[0], setIsPressed = _c[1];
|
|
8
12
|
function disconnect() {
|
|
9
13
|
// TODO: create a util function for disconnecting and clearing local storage
|
|
10
14
|
dynamicHandleLogOut();
|
|
@@ -25,5 +29,14 @@ export function NoWhitelistView() {
|
|
|
25
29
|
var addressText = address
|
|
26
30
|
? "".concat(address.substring(0, 6), "...").concat(address.slice(-4))
|
|
27
31
|
: '';
|
|
28
|
-
return (_jsxs("div", { className: "rounded-[
|
|
32
|
+
return (_jsxs("div", { className: "bg-gray-50 dark:bg-gray-950 relative border border-gray-200 dark:border-gray-800 rounded-md transition-[max-width,transform,opacity] duration-[3000ms] ease-[cubic-bezier(0.16,1,0.3,1)] w-full max-w-sm m-4 origin-center will-change-[max-width,transform,opacity]", children: [_jsx("div", { className: "p-6 border-b border-gray-200 dark:border-gray-800", children: _jsx(ModalHeader, {}) }), _jsx("div", { className: "p-6 overflow-hidden relative", children: _jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "text-center", children: [_jsx("h3", { className: "text-xl font-medium text-gray-900 dark:text-white mb-2", children: "Not Whitelisted" }), _jsxs("p", { className: "text-gray-500 dark:text-gray-400", children: ["The wallet address ", addressText, " is not whitelisted for access."] })] }), _jsx("button", { onClick: disconnect, onMouseEnter: function () { return setIsHovered(true); }, onMouseLeave: function () {
|
|
33
|
+
setIsHovered(false);
|
|
34
|
+
setIsPressed(false);
|
|
35
|
+
}, onMouseDown: function () { return setIsPressed(true); }, onMouseUp: function () { return setIsPressed(false); }, className: "\n group relative w-full overflow-hidden rounded-md border-2 bg-gray-100 dark:bg-neutral-950 py-4 text-center\n transition-all duration-300 ".concat(ANIMATION_EASE, "\n cursor-pointer border-gray-200 dark:border-gray-800 hover:border-gray-400 dark:hover:border-white/60\n "), style: {
|
|
36
|
+
transform: isPressed
|
|
37
|
+
? 'scale(0.98)'
|
|
38
|
+
: isHovered
|
|
39
|
+
? 'scale(0.99)'
|
|
40
|
+
: 'scale(1)',
|
|
41
|
+
}, children: _jsx("div", { className: "relative z-[200] pl-4 isolate", children: _jsx("div", { className: "flex items-center justify-center", children: _jsx("span", { className: "\n text-base font-medium tracking-wide transition-colors duration-300 ".concat(ANIMATION_EASE, "\n text-gray-500 dark:text-neutral-400 group-hover:text-gray-900 dark:group-hover:text-white\n "), children: "Disconnect" }) }) }) })] }) })] }));
|
|
29
42
|
}
|