From 5bf816eba206979738010d81e5e657e4d782d891 Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:25:35 +0700 Subject: [PATCH] fully suport alby nostr-wallet-connect --- package.json | 7 +- pnpm-lock.yaml | 197 +++++++++++---------- src-tauri/Cargo.lock | 64 +++---- src-tauri/Cargo.toml | 2 +- src/app/auth/create/step-2.tsx | 2 +- src/app/auth/import/step-2.tsx | 2 +- src/app/auth/unlock.tsx | 8 +- src/app/splash.tsx | 5 +- src/app/users/components/modal.tsx | 2 +- src/index.css | 50 +++--- src/libs/storage/instance.ts | 53 ++++-- src/shared/alby.tsx | 43 ++++- src/shared/navigation.tsx | 10 +- src/shared/notes/actions.tsx | 2 +- src/shared/notes/actions/zap.tsx | 252 ++++++++++++++++----------- src/shared/widgets/local/network.tsx | 21 +-- src/stores/stronghold.ts | 6 + src/utils/hooks/useEvent.ts | 20 +-- src/utils/hooks/useNostr.ts | 28 +-- src/utils/parser.ts | 15 +- 20 files changed, 425 insertions(+), 364 deletions(-) diff --git a/package.json b/package.json index decfb07b..805a127d 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "nostr-tools": "^1.14.2", "qrcode.react": "^3.1.0", "react": "^18.2.0", + "react-currency-input-field": "^3.6.11", "react-dom": "^18.2.0", "react-hook-form": "^7.46.1", "react-hotkeys-hook": "^4.4.1", @@ -71,7 +72,7 @@ "@tauri-apps/cli": "^1.4.0", "@trivago/prettier-plugin-sort-imports": "^4.2.0", "@types/html-to-text": "^9.0.1", - "@types/node": "^20.5.9", + "@types/node": "^20.6.0", "@types/react": "^18.2.21", "@types/react-dom": "^18.2.7", "@types/youtube-player": "^5.5.7", @@ -83,7 +84,7 @@ "cross-env": "^7.0.3", "csstype": "^3.1.2", "encoding": "^0.1.13", - "eslint": "^8.48.0", + "eslint": "^8.49.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-react": "^7.33.2", @@ -98,6 +99,6 @@ "tailwindcss": "^3.3.3", "typescript": "^5.2.2", "vite": "^4.4.9", - "vite-tsconfig-paths": "^4.2.0" + "vite-tsconfig-paths": "^4.2.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 066ac444..4bda96aa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -97,6 +97,9 @@ dependencies: react: specifier: ^18.2.0 version: 18.2.0 + react-currency-input-field: + specifier: ^3.6.11 + version: 3.6.11(react@18.2.0) react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) @@ -157,8 +160,8 @@ devDependencies: specifier: ^9.0.1 version: 9.0.1 '@types/node': - specifier: ^20.5.9 - version: 20.5.9 + specifier: ^20.6.0 + version: 20.6.0 '@types/react': specifier: ^18.2.21 version: 18.2.21 @@ -170,10 +173,10 @@ devDependencies: version: 5.5.7 '@typescript-eslint/eslint-plugin': specifier: ^6.6.0 - version: 6.6.0(@typescript-eslint/parser@6.6.0)(eslint@8.48.0)(typescript@5.2.2) + version: 6.6.0(@typescript-eslint/parser@6.6.0)(eslint@8.49.0)(typescript@5.2.2) '@typescript-eslint/parser': specifier: ^6.6.0 - version: 6.6.0(eslint@8.48.0)(typescript@5.2.2) + version: 6.6.0(eslint@8.49.0)(typescript@5.2.2) '@vitejs/plugin-react-swc': specifier: ^3.3.2 version: 3.3.2(vite@4.4.9) @@ -193,20 +196,20 @@ devDependencies: specifier: ^0.1.13 version: 0.1.13 eslint: - specifier: ^8.48.0 - version: 8.48.0 + specifier: ^8.49.0 + version: 8.49.0 eslint-config-prettier: specifier: ^9.0.0 - version: 9.0.0(eslint@8.48.0) + version: 9.0.0(eslint@8.49.0) eslint-plugin-jsx-a11y: specifier: ^6.7.1 - version: 6.7.1(eslint@8.48.0) + version: 6.7.1(eslint@8.49.0) eslint-plugin-react: specifier: ^7.33.2 - version: 7.33.2(eslint@8.48.0) + version: 7.33.2(eslint@8.49.0) eslint-plugin-simple-import-sort: specifier: ^10.0.0 - version: 10.0.0(eslint@8.48.0) + version: 10.0.0(eslint@8.49.0) husky: specifier: ^8.0.3 version: 8.0.3 @@ -236,10 +239,10 @@ devDependencies: version: 5.2.2 vite: specifier: ^4.4.9 - version: 4.4.9(@types/node@20.5.9) + version: 4.4.9(@types/node@20.6.0) vite-tsconfig-paths: - specifier: ^4.2.0 - version: 4.2.0(typescript@5.2.2)(vite@4.4.9) + specifier: ^4.2.1 + version: 4.2.1(typescript@5.2.2)(vite@4.4.9) packages: @@ -278,21 +281,21 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.22.15 - '@babel/types': 7.22.15 + '@babel/types': 7.22.17 dev: true /@babel/helper-hoist-variables@7.22.5: resolution: {integrity: sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.15 + '@babel/types': 7.22.17 dev: true /@babel/helper-split-export-declaration@7.22.6: resolution: {integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.22.15 + '@babel/types': 7.22.17 dev: true /@babel/helper-string-parser@7.22.5: @@ -332,7 +335,7 @@ packages: dependencies: '@babel/code-frame': 7.22.13 '@babel/parser': 7.22.16 - '@babel/types': 7.22.15 + '@babel/types': 7.22.17 dev: true /@babel/traverse@7.17.3: @@ -361,8 +364,8 @@ packages: to-fast-properties: 2.0.0 dev: true - /@babel/types@7.22.15: - resolution: {integrity: sha512-X+NLXr0N8XXmN5ZsaQdm9U2SSC3UbIYq/doL++sueHOTisgZHoKaQtZxGuV2cUPQHMfjKEfg/g6oy7Hm6SKFtA==} + /@babel/types@7.22.17: + resolution: {integrity: sha512-YSQPHLFtQNE5xN9tHuZnzu8vPr61wVTBZdfv1meex1NBosa4iT05k/Jw06ddJugi4bk7The/oSwQGFcksmEJQg==} engines: {node: '>=6.9.0'} dependencies: '@babel/helper-string-parser': 7.22.5 @@ -778,13 +781,13 @@ packages: dev: true optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.48.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.49.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.48.0 + eslint: 8.49.0 eslint-visitor-keys: 3.4.3 /@eslint-community/regexpp@4.8.0: @@ -807,8 +810,8 @@ packages: transitivePeerDependencies: - supports-color - /@eslint/js@8.48.0: - resolution: {integrity: sha512-ZSjtmelB7IJfWD2Fvb7+Z+ChTIKWq6kjda95fLcQKNS5aheVHn4IkfgRQE3sIIzTcSLwLcLZUD9UBt+V7+h+Pw==} + /@eslint/js@8.49.0: + resolution: {integrity: sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} /@floating-ui/core@1.4.1: @@ -956,14 +959,14 @@ packages: '@noble/hashes': 1.3.2 '@noble/secp256k1': 2.0.0 '@scure/base': 1.1.3 - '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.48.0)(typescript@5.2.2) - '@typescript-eslint/parser': 5.62.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.49.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.49.0)(typescript@5.2.2) debug: 4.3.4 esbuild: 0.17.19 esbuild-plugin-alias: 0.2.1 - eslint: 8.48.0 - eslint-config-prettier: 8.10.0(eslint@8.48.0) - eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.62.0)(eslint@8.48.0) + eslint: 8.49.0 + eslint-config-prettier: 8.10.0(eslint@8.49.0) + eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.62.0)(eslint@8.49.0) esm-loader-typescript: 1.0.5 eventemitter3: 5.0.1 light-bolt11-decoder: 3.0.0 @@ -2356,8 +2359,8 @@ packages: resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==} dev: false - /@types/node@20.5.9: - resolution: {integrity: sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==} + /@types/node@20.6.0: + resolution: {integrity: sha512-najjVq5KN2vsH2U/xyh2opaSEz6cZMR2SetLIlxlj08nOcmPOemJmUK2o4kUzfLqfrWE0PIrNeE16XhYDd3nqg==} dev: true /@types/normalize-package-data@2.4.1: @@ -2405,7 +2408,7 @@ packages: resolution: {integrity: sha512-W8F4eoTIvzXeNrT3JroQPimZLXnlJA8smYygHZUKFPVoYwgs/OhJkA1VBhL3iSs57OQkuINqHlY4SmMT5wtnJg==} dev: true - /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2417,12 +2420,12 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.8.0 - '@typescript-eslint/parser': 5.62.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.49.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/type-utils': 5.62.0(eslint@8.48.0)(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.49.0)(typescript@5.2.2) + '@typescript-eslint/utils': 5.62.0(eslint@8.49.0)(typescript@5.2.2) debug: 4.3.4 - eslint: 8.48.0 + eslint: 8.49.0 graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -2433,7 +2436,7 @@ packages: - supports-color dev: false - /@typescript-eslint/eslint-plugin@6.6.0(@typescript-eslint/parser@6.6.0)(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/eslint-plugin@6.6.0(@typescript-eslint/parser@6.6.0)(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-CW9YDGTQnNYMIo5lMeuiIG08p4E0cXrXTbcZ2saT/ETE7dWUrNxlijsQeU04qAAKkILiLzdQz+cGFxCJjaZUmA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -2445,13 +2448,13 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.8.0 - '@typescript-eslint/parser': 6.6.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.6.0(eslint@8.49.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 6.6.0 - '@typescript-eslint/type-utils': 6.6.0(eslint@8.48.0)(typescript@5.2.2) - '@typescript-eslint/utils': 6.6.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/type-utils': 6.6.0(eslint@8.49.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.6.0(eslint@8.49.0)(typescript@5.2.2) '@typescript-eslint/visitor-keys': 6.6.0 debug: 4.3.4 - eslint: 8.48.0 + eslint: 8.49.0 graphemer: 1.4.0 ignore: 5.2.4 natural-compare: 1.4.0 @@ -2462,7 +2465,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.62.0(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/parser@5.62.0(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2476,13 +2479,13 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) debug: 4.3.4 - eslint: 8.48.0 + eslint: 8.49.0 typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: false - /@typescript-eslint/parser@6.6.0(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/parser@6.6.0(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-setq5aJgUwtzGrhW177/i+DMLqBaJbdwGj2CPIVFFLE0NCliy5ujIdLHd2D1ysmlmsjdL2GWW+hR85neEfc12w==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -2497,7 +2500,7 @@ packages: '@typescript-eslint/typescript-estree': 6.6.0(typescript@5.2.2) '@typescript-eslint/visitor-keys': 6.6.0 debug: 4.3.4 - eslint: 8.48.0 + eslint: 8.49.0 typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -2519,7 +2522,7 @@ packages: '@typescript-eslint/visitor-keys': 6.6.0 dev: true - /@typescript-eslint/type-utils@5.62.0(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/type-utils@5.62.0(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2530,16 +2533,16 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/utils': 5.62.0(eslint@8.49.0)(typescript@5.2.2) debug: 4.3.4 - eslint: 8.48.0 + eslint: 8.49.0 tsutils: 3.21.0(typescript@5.2.2) typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: false - /@typescript-eslint/type-utils@6.6.0(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/type-utils@6.6.0(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-8m16fwAcEnQc69IpeDyokNO+D5spo0w1jepWWY2Q6y5ZKNuj5EhVQXjtVAeDDqvW6Yg7dhclbsz6rTtOvcwpHg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: @@ -2550,9 +2553,9 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 6.6.0(typescript@5.2.2) - '@typescript-eslint/utils': 6.6.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/utils': 6.6.0(eslint@8.49.0)(typescript@5.2.2) debug: 4.3.4 - eslint: 8.48.0 + eslint: 8.49.0 ts-api-utils: 1.0.3(typescript@5.2.2) typescript: 5.2.2 transitivePeerDependencies: @@ -2611,19 +2614,19 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@5.62.0(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/utils@5.62.0(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.48.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.49.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.1 '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) - eslint: 8.48.0 + eslint: 8.49.0 eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -2631,19 +2634,19 @@ packages: - typescript dev: false - /@typescript-eslint/utils@6.6.0(eslint@8.48.0)(typescript@5.2.2): + /@typescript-eslint/utils@6.6.0(eslint@8.49.0)(typescript@5.2.2): resolution: {integrity: sha512-mPHFoNa2bPIWWglWYdR0QfY9GN0CfvvXX1Sv6DlSTive3jlMTUy+an67//Gysc+0Me9pjitrq0LJp0nGtLgftw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.48.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.49.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.1 '@typescript-eslint/scope-manager': 6.6.0 '@typescript-eslint/types': 6.6.0 '@typescript-eslint/typescript-estree': 6.6.0(typescript@5.2.2) - eslint: 8.48.0 + eslint: 8.49.0 semver: 7.5.4 transitivePeerDependencies: - supports-color @@ -2672,7 +2675,7 @@ packages: vite: ^4 dependencies: '@swc/core': 1.3.83 - vite: 4.4.9(@types/node@20.5.9) + vite: 4.4.9(@types/node@20.6.0) transitivePeerDependencies: - '@swc/helpers' dev: true @@ -2874,7 +2877,7 @@ packages: postcss: ^8.1.0 dependencies: browserslist: 4.21.10 - caniuse-lite: 1.0.30001528 + caniuse-lite: 1.0.30001532 fraction.js: 4.3.6 normalize-range: 0.1.2 picocolors: 1.0.0 @@ -2886,8 +2889,8 @@ packages: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} - /axe-core@4.8.0: - resolution: {integrity: sha512-ZtlVZobOeDQhb/y2lMK6mznDw7TJHDNcKx5/bbBkFvArIQ5CVFhSI6hWWQnMx9I8cNmNmZ30wpDyOC2E2nvgbQ==} + /axe-core@4.8.1: + resolution: {integrity: sha512-9l850jDDPnKq48nbad8SiEelCv4OrUWrKab/cPj0GScVg6cb6NbCCt/Ulk26QEq5jP9NnGr04Bit1BHyV6r5CQ==} engines: {node: '>=4'} dev: true @@ -2926,8 +2929,8 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001528 - electron-to-chromium: 1.4.511 + caniuse-lite: 1.0.30001532 + electron-to-chromium: 1.4.513 node-releases: 2.0.13 update-browserslist-db: 1.0.11(browserslist@4.21.10) dev: true @@ -2961,8 +2964,8 @@ packages: engines: {node: '>=6'} dev: false - /caniuse-lite@1.0.30001528: - resolution: {integrity: sha512-0Db4yyjR9QMNlsxh+kKWzQtkyflkG/snYheSzkjmvdEtEXB1+jt7A2HmSEiO6XIJPIbo92lHNGNySvE5pZcs5Q==} + /caniuse-lite@1.0.30001532: + resolution: {integrity: sha512-FbDFnNat3nMnrROzqrsg314zhqN5LGQ1kyyMk2opcrwGbVGpHRhgCWtAgD5YJUqNAiQ+dklreil/c3Qf1dfCTw==} dev: true /case-anything@2.1.13: @@ -3286,8 +3289,8 @@ packages: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true - /electron-to-chromium@1.4.511: - resolution: {integrity: sha512-udHyLfdy390CObLy3uFQitCBvK+WxWu6WZWQMBzO/npNiRy6tanDKR1c/F6OImfAiSt1ylgNszPJBxix2c0w3w==} + /electron-to-chromium@1.4.513: + resolution: {integrity: sha512-cOB0xcInjm+E5qIssHeXJ29BaUyWpMyFKT5RB3bsLENDheCja0wMkHJyiPl0NBE/VzDI7JDuNEQWhe6RitEUcw==} dev: true /emoji-regex@8.0.0: @@ -3486,22 +3489,22 @@ packages: engines: {node: '>=12'} dev: false - /eslint-config-prettier@8.10.0(eslint@8.48.0): + /eslint-config-prettier@8.10.0(eslint@8.49.0): resolution: {integrity: sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.48.0 + eslint: 8.49.0 dev: false - /eslint-config-prettier@9.0.0(eslint@8.48.0): + /eslint-config-prettier@9.0.0(eslint@8.49.0): resolution: {integrity: sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.48.0 + eslint: 8.49.0 dev: true /eslint-formatter-pretty@4.1.0: @@ -3528,7 +3531,7 @@ packages: - supports-color dev: false - /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint@8.48.0): + /eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint@8.49.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} engines: {node: '>=4'} peerDependencies: @@ -3549,15 +3552,15 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.49.0)(typescript@5.2.2) debug: 3.2.7 - eslint: 8.48.0 + eslint: 8.49.0 eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: - supports-color dev: false - /eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0)(eslint@8.48.0): + /eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0)(eslint@8.49.0): resolution: {integrity: sha512-9I9hFlITvOV55alzoKBI+K9q74kv0iKMeY6av5+umsNwayt59fz692daGyjR+oStBQgx6nwR9rXldDev3Clw+A==} engines: {node: '>=4'} peerDependencies: @@ -3567,16 +3570,16 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.62.0(eslint@8.48.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.49.0)(typescript@5.2.2) array-includes: 3.1.7 array.prototype.findlastindex: 1.2.3 array.prototype.flat: 1.3.2 array.prototype.flatmap: 1.3.2 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.48.0 + eslint: 8.49.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint@8.48.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0)(eslint-import-resolver-node@0.3.9)(eslint@8.49.0) has: 1.0.3 is-core-module: 2.13.0 is-glob: 4.0.3 @@ -3592,7 +3595,7 @@ packages: - supports-color dev: false - /eslint-plugin-jsx-a11y@6.7.1(eslint@8.48.0): + /eslint-plugin-jsx-a11y@6.7.1(eslint@8.49.0): resolution: {integrity: sha512-63Bog4iIethyo8smBklORknVjB0T2dwB8Mr/hIC+fBS0uyHdYYpzM/Ed+YC8VxTjlXHEWFOdmgwcDn1U2L9VCA==} engines: {node: '>=4.0'} peerDependencies: @@ -3603,11 +3606,11 @@ packages: array-includes: 3.1.7 array.prototype.flatmap: 1.3.2 ast-types-flow: 0.0.7 - axe-core: 4.8.0 + axe-core: 4.8.1 axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - eslint: 8.48.0 + eslint: 8.49.0 has: 1.0.3 jsx-ast-utils: 3.3.5 language-tags: 1.0.5 @@ -3617,7 +3620,7 @@ packages: semver: 6.3.1 dev: true - /eslint-plugin-react@7.33.2(eslint@8.48.0): + /eslint-plugin-react@7.33.2(eslint@8.49.0): resolution: {integrity: sha512-73QQMKALArI8/7xGLNI/3LylrEYrlKZSb5C9+q3OtOewTnMQi5cT+aE9E41sLCmli3I9PGGmD1yiZydyo4FEPw==} engines: {node: '>=4'} peerDependencies: @@ -3628,7 +3631,7 @@ packages: array.prototype.tosorted: 1.1.2 doctrine: 2.1.0 es-iterator-helpers: 1.0.14 - eslint: 8.48.0 + eslint: 8.49.0 estraverse: 5.3.0 jsx-ast-utils: 3.3.5 minimatch: 3.1.2 @@ -3642,12 +3645,12 @@ packages: string.prototype.matchall: 4.0.9 dev: true - /eslint-plugin-simple-import-sort@10.0.0(eslint@8.48.0): + /eslint-plugin-simple-import-sort@10.0.0(eslint@8.49.0): resolution: {integrity: sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==} peerDependencies: eslint: '>=5.0.0' dependencies: - eslint: 8.48.0 + eslint: 8.49.0 dev: true /eslint-rule-docs@1.1.235: @@ -3673,15 +3676,15 @@ packages: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - /eslint@8.48.0: - resolution: {integrity: sha512-sb6DLeIuRXxeM1YljSe1KEx9/YYeZFQWcV8Rq9HfigmdDEugjLEVEa1ozDjL6YDjBpQHPJxJzze+alxi4T3OLg==} + /eslint@8.49.0: + resolution: {integrity: sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.48.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.49.0) '@eslint-community/regexpp': 4.8.0 '@eslint/eslintrc': 2.1.2 - '@eslint/js': 8.48.0 + '@eslint/js': 8.49.0 '@humanwhocodes/config-array': 0.11.11 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 @@ -5852,6 +5855,14 @@ packages: engines: {node: '>=8'} dev: false + /react-currency-input-field@3.6.11(react@18.2.0): + resolution: {integrity: sha512-M9vOx1eaioSaYWirm7W2WSBi4bpLg+LK4Gf7C1kNhy6MvoSoOzd0mYZPxA78OC9UBIQ2nM080Wu9D1CwTY6n3w==} + peerDependencies: + react: ^16.9.0 || ^17.0.0 || ^18.0.0 + dependencies: + react: 18.2.0 + dev: false + /react-dom@18.2.0(react@18.2.0): resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==} peerDependencies: @@ -6954,8 +6965,8 @@ packages: vfile-message: 3.1.4 dev: false - /vite-tsconfig-paths@4.2.0(typescript@5.2.2)(vite@4.4.9): - resolution: {integrity: sha512-jGpus0eUy5qbbMVGiTxCL1iB9ZGN6Bd37VGLJU39kTDD6ZfULTTb1bcc5IeTWqWJKiWV5YihCaibeASPiGi8kw==} + /vite-tsconfig-paths@4.2.1(typescript@5.2.2)(vite@4.4.9): + resolution: {integrity: sha512-GNUI6ZgPqT3oervkvzU+qtys83+75N/OuDaQl7HmOqFTb0pjZsuARrRipsyJhJ3enqV8beI1xhGbToR4o78nSQ==} peerDependencies: vite: '*' peerDependenciesMeta: @@ -6965,13 +6976,13 @@ packages: debug: 4.3.4 globrex: 0.1.2 tsconfck: 2.1.2(typescript@5.2.2) - vite: 4.4.9(@types/node@20.5.9) + vite: 4.4.9(@types/node@20.6.0) transitivePeerDependencies: - supports-color - typescript dev: true - /vite@4.4.9(@types/node@20.5.9): + /vite@4.4.9(@types/node@20.6.0): resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -6999,7 +7010,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.5.9 + '@types/node': 20.6.0 esbuild: 0.18.20 postcss: 8.4.29 rollup: 3.29.0 diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 2286069e..0e80e80e 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -401,9 +401,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -614,7 +614,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "599aa35200ffff8f04c1925aa1acc92fa2e08874379ef42e210a80e527e60838" dependencies = [ "serde", - "toml 0.7.6", + "toml 0.7.8", ] [[package]] @@ -654,9 +654,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.4" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" dependencies = [ "smallvec", "target-lexicon", @@ -1330,7 +1330,7 @@ checksum = "fd0a2c9b742a980060d22545a7a83b573acd6b73045b9de6370c9530ce652f27" dependencies = [ "cc", "rustc_version", - "toml 0.7.6", + "toml 0.7.8", "vswhom", "winreg 0.51.0", ] @@ -1459,7 +1459,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.11", + "rustix 0.38.12", "windows-sys 0.48.0", ] @@ -2590,9 +2590,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -3444,7 +3444,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "indexmap 1.9.3", "line-wrap", "quick-xml 0.29.0", @@ -3823,7 +3823,7 @@ version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -3936,7 +3936,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e71971821b3ae0e769e4a4328dbcb517607b434db7697e9aba17203ec14e46a" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "blake2b_simd", "constant_time_eq 0.3.0", ] @@ -3972,14 +3972,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "bdf14a7a466ce88b5eac3da815b53aefc208ce7e74d1c263aabb04d88c4abeb1" dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.7", "windows-sys 0.48.0", ] @@ -4000,7 +4000,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", ] [[package]] @@ -4169,9 +4169,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +checksum = "2cc66a619ed80bf7a0f6b17dd063a84b88f6dea1813737cf469aef1d081142c2" dependencies = [ "itoa 1.0.9", "ryu", @@ -4216,7 +4216,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "chrono", "hex", "indexmap 1.9.3", @@ -4584,7 +4584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482" dependencies = [ "atoi", - "base64 0.21.3", + "base64 0.21.4", "bitflags 2.4.0", "byteorder", "bytes", @@ -4627,7 +4627,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e" dependencies = [ "atoi", - "base64 0.21.3", + "base64 0.21.4", "bitflags 2.4.0", "byteorder", "crc", @@ -4871,10 +4871,10 @@ version = "6.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30c2de8a4d8f4b823d634affc9cd2a74ec98c53a756f317e529a48046cbf71f3" dependencies = [ - "cfg-expr 0.15.4", + "cfg-expr 0.15.5", "heck 0.4.1", "pkg-config", - "toml 0.7.6", + "toml 0.7.8", "version-compare 0.1.1", ] @@ -5029,7 +5029,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54ad2d49fdeab4a08717f5b49a163bdc72efc3b1950b6758245fcde79b645e1a" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "brotli", "ico", "json-patch", @@ -5231,7 +5231,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5993dc129e544393574288923d1ec447c857f3f644187f4fbf7d9a875fbfc4fb" dependencies = [ "embed-resource", - "toml 0.7.6", + "toml 0.7.8", ] [[package]] @@ -5253,7 +5253,7 @@ dependencies = [ "cfg-if", "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.38.11", + "rustix 0.38.12", "windows-sys 0.48.0", ] @@ -5421,9 +5421,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -5442,9 +5442,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.0.0", "serde", @@ -5972,8 +5972,8 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "window-vibrancy" -version = "0.4.0" -source = "git+https://github.com/tauri-apps/window-vibrancy?branch=dev#84b45368cb9aa8ce5107ae3d508092720226da22" +version = "0.4.1" +source = "git+https://github.com/tauri-apps/window-vibrancy?branch=dev#ce6e299a3bc98bd1d0f322c3b922fe8634f09e8e" dependencies = [ "cocoa 0.25.0", "objc", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index c0a8137b..a06434e5 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -16,7 +16,7 @@ tauri-build = { version = "1.4", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "1.4", features = [ "window-create", +tauri = { version = "1.4", features = [ "window-close", "window-print", "window-create", "macos-private-api", "fs-read-dir", "fs-read-file", diff --git a/src/app/auth/create/step-2.tsx b/src/app/auth/create/step-2.tsx index a33f7174..34586420 100644 --- a/src/app/auth/create/step-2.tsx +++ b/src/app/auth/create/step-2.tsx @@ -61,7 +61,7 @@ export function CreateStep2Screen() { setLoading(true); if (data.password.length > 3) { const dir = await appConfigDir(); - const stronghold = await Stronghold.load(`${dir}/lume.stronghold`, data.password); + const stronghold = await Stronghold.load(`${dir}lume.stronghold`, data.password); if (!db.secureDB) db.secureDB = stronghold; diff --git a/src/app/auth/import/step-2.tsx b/src/app/auth/import/step-2.tsx index 7fe5dbe7..040c922b 100644 --- a/src/app/auth/import/step-2.tsx +++ b/src/app/auth/import/step-2.tsx @@ -61,7 +61,7 @@ export function ImportStep2Screen() { setLoading(true); if (data.password.length > 3) { const dir = await appConfigDir(); - const stronghold = await Stronghold.load(`${dir}/lume.stronghold`, data.password); + const stronghold = await Stronghold.load(`${dir}lume.stronghold`, data.password); if (!db.secureDB) db.secureDB = stronghold; diff --git a/src/app/auth/unlock.tsx b/src/app/auth/unlock.tsx index 3f4cfd88..b9248d8e 100644 --- a/src/app/auth/unlock.tsx +++ b/src/app/auth/unlock.tsx @@ -33,6 +33,7 @@ const resolver: Resolver = async (values) => { export function UnlockScreen() { const navigate = useNavigate(); const setPrivkey = useStronghold((state) => state.setPrivkey); + const setWalletConnectURL = useStronghold((state) => state.setWalletConnectURL); const [showPassword, setShowPassword] = useState(false); const [loading, setLoading] = useState(false); @@ -55,8 +56,13 @@ export function UnlockScreen() { if (!db.secureDB) db.secureDB = stronghold; const privkey = await db.secureLoad(db.account.pubkey); + const uri = await db.secureLoad('walletConnectURL', 'alby'); - setPrivkey(privkey); + console.log('found privkey: ', privkey); + console.log('found wallet conenct url: ', uri); + + if (privkey) setPrivkey(privkey); + if (uri) setWalletConnectURL(uri); // redirect to home navigate('/', { replace: true }); } catch (e) { diff --git a/src/app/splash.tsx b/src/app/splash.tsx index c1b76ff2..30019d04 100644 --- a/src/app/splash.tsx +++ b/src/app/splash.tsx @@ -22,10 +22,9 @@ export function SplashScreen() { const prefetch = async () => { try { - const user = await fetchUserData(); - const data = await prefetchEvents(); + const [user, events] = await Promise.all([fetchUserData(), prefetchEvents()]); - if (user.status === 'ok' && data.status === 'ok') { + if (user.status === 'ok' && events.status === 'ok') { // update last login = current time await db.updateLastLogin(); // close splash screen and open main app screen diff --git a/src/app/users/components/modal.tsx b/src/app/users/components/modal.tsx index 78f7b8d2..8ba979e6 100644 --- a/src/app/users/components/modal.tsx +++ b/src/app/users/components/modal.tsx @@ -289,7 +289,7 @@ export function EditProfileModal() { - - + - + - + - + + + -
- +
+ setZapMessage(e.target.value)} + spellCheck={false} + autoComplete="off" + autoCorrect="off" + autoCapitalize="off" + placeholder="Enter message (optional)" + className="relative min-h-[56px] w-full resize-none rounded-lg bg-white/10 px-3 py-2 !outline-none backdrop-blur-xl placeholder:text-white/50" + /> +
+ {walletConnectURL ? ( + + ) : ( + + )} + + The recipient receives 100% of the amount that you send. Lume does + not take any commission, and you cannot get refund + +
) : ( diff --git a/src/shared/widgets/local/network.tsx b/src/shared/widgets/local/network.tsx index 9ef29d39..68aa833e 100644 --- a/src/shared/widgets/local/network.tsx +++ b/src/shared/widgets/local/network.tsx @@ -130,27 +130,8 @@ export function LocalNetworkWidget() { sub( filter, async (event) => { - let root: string; - let reply: string; - - if (event.tags?.[0]?.[0] === 'e' && !event.tags?.[0]?.[3]) { - root = event.tags[0][1]; - } else { - root = event.tags.find((el) => el[3] === 'root')?.[1]; - reply = event.tags.find((el) => el[3] === 'reply')?.[1]; - } - const rawEvent = toRawEvent(event); - - await db.createEvent( - event.id, - JSON.stringify(rawEvent), - event.pubkey, - event.kind, - root, - reply, - event.created_at - ); + await db.createEvent(rawEvent); }, false // don't close sub on eose ); diff --git a/src/stores/stronghold.ts b/src/stores/stronghold.ts index ca681474..b319c0ec 100644 --- a/src/stores/stronghold.ts +++ b/src/stores/stronghold.ts @@ -3,7 +3,9 @@ import { createJSONStorage, persist } from 'zustand/middleware'; interface StrongholdState { privkey: null | string; + walletConnectURL: null | string; setPrivkey: (privkey: string) => void; + setWalletConnectURL: (uri: string) => void; clearPrivkey: () => void; } @@ -11,9 +13,13 @@ export const useStronghold = create()( persist( (set) => ({ privkey: null, + walletConnectURL: null, setPrivkey: (privkey: string) => { set({ privkey: privkey }); }, + setWalletConnectURL: (uri: string) => { + set({ walletConnectURL: uri }); + }, clearPrivkey: () => { set({ privkey: null }); }, diff --git a/src/utils/hooks/useEvent.ts b/src/utils/hooks/useEvent.ts index 6b796574..1e952b19 100644 --- a/src/utils/hooks/useEvent.ts +++ b/src/utils/hooks/useEvent.ts @@ -25,26 +25,8 @@ export function useEvent(id: string, embed?: string) { const event = await ndk.fetchEvent(id); if (!event) throw new Error(`Event not found: ${id.toString()}`); - let root: string; - let reply: string; - - if (event.tags?.[0]?.[0] === 'e' && !event.tags?.[0]?.[3]) { - root = event.tags[0][1]; - } else { - root = event.tags.find((el) => el[3] === 'root')?.[1]; - reply = event.tags.find((el) => el[3] === 'reply')?.[1]; - } - const rawEvent = toRawEvent(event); - await db.createEvent( - event.id, - JSON.stringify(rawEvent), - event.pubkey, - event.kind, - root, - reply, - event.created_at - ); + await db.createEvent(rawEvent); return event; }, diff --git a/src/utils/hooks/useNostr.ts b/src/utils/hooks/useNostr.ts index c7fdaf33..57ce9438 100644 --- a/src/utils/hooks/useNostr.ts +++ b/src/utils/hooks/useNostr.ts @@ -134,37 +134,21 @@ export function useNostr() { console.log("prefetching events with user's network: ", db.account.network.length); console.log('prefetching events since: ', since); - const events = await fetcher.fetchAllEvents( + const events = (await fetcher.fetchAllEvents( relayUrls, { kinds: [NDKKind.Text, NDKKind.Repost, 1063, NDKKind.Article], authors: db.account.network, }, { since: since } - ); + )) as unknown as NDKEvent[]; // save all events to database - for (const event of events) { - let root: string; - let reply: string; - if (event.tags?.[0]?.[0] === 'e' && !event.tags?.[0]?.[3]) { - root = event.tags[0][1]; - } else { - root = event.tags.find((el) => el[3] === 'root')?.[1]; - reply = event.tags.find((el) => el[3] === 'reply')?.[1]; - } - await db.createEvent( - event.id, - JSON.stringify(event), - event.pubkey, - event.kind, - root, - reply, - event.created_at - ); - } + const promises = await Promise.all( + events.map(async (event) => await db.createEvent(event)) + ); - return { status: 'ok', message: 'prefetch completed' }; + if (promises) return { status: 'ok', message: 'prefetch completed' }; } catch (e) { console.error('prefetch events failed, error: ', e); return { status: 'failed', message: e }; diff --git a/src/utils/parser.ts b/src/utils/parser.ts index a80cac1d..9ded8551 100644 --- a/src/utils/parser.ts +++ b/src/utils/parser.ts @@ -1,5 +1,5 @@ import { nip19 } from 'nostr-tools'; -import { EventPointer } from 'nostr-tools/lib/nip19'; +import { EventPointer, ProfilePointer } from 'nostr-tools/lib/nip19'; import { RichContent } from '@utils/types'; @@ -58,20 +58,27 @@ export function parser(eventContent: string) { } // nostr account references - if (word.startsWith('nostr:npub1')) { + if (word.startsWith('nostr:npub1') || word.startsWith('npub1')) { const npub = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, ''); return word.replace(word, `~pub-${nip19.decode(npub).data}~`); } + // nostr profile references + if (word.startsWith('nostr:nprofile1') || word.startsWith('nprofile1')) { + const nprofile = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, ''); + const decoded = nip19.decode(nprofile).data as ProfilePointer; + return word.replace(word, `~pub-${decoded.pubkey}~`); + } + // nostr account references - if (word.startsWith('nostr:note1')) { + if (word.startsWith('nostr:note1') || word.startsWith('noté')) { const note = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, ''); content.notes.push(nip19.decode(note).data as string); return word.replace(word, ''); } // nostr event references - if (word.startsWith('nostr:nevent1')) { + if (word.startsWith('nostr:nevent1') || word.startsWith('nevent1')) { const nevent = word.replace('nostr:', '').replace(/[^a-zA-Z0-9 ]/g, ''); const decoded = nip19.decode(nevent).data as EventPointer; content.notes.push(decoded.id);