diff --git a/package-lock.json b/package-lock.json index 1dd681d..6c15483 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,6 +44,7 @@ "@reown/appkit-wallet-button": "^1.7.17", "@tanstack/react-query": "^5.84.1", "@waku/sdk": "^0.0.35-67a7287.0", + "bitcoinjs-message": "^2.2.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.0.0", @@ -64,6 +65,7 @@ "tailwindcss-animate": "^1.0.7", "uuid": "^11.1.0", "vaul": "^0.9.3", + "viem": "^2.37.1", "wagmi": "^2.16.1", "zod": "^3.23.8" }, @@ -8249,7 +8251,6 @@ "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", "license": "MIT", - "optional": true, "dependencies": { "file-uri-to-path": "1.0.0" } @@ -8284,7 +8285,6 @@ "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", "integrity": "sha512-nemMHz95EmS38a26XbbdxIYj5csHd3RMP3H5bwQknX0WYHF01qhpufP42mLOwVICuH2JmhIhXiWs89MfUGL7Xw==", "license": "MIT", - "optional": true, "dependencies": { "safe-buffer": "^5.0.1" } @@ -8322,7 +8322,6 @@ "resolved": "https://registry.npmjs.org/bitcoinjs-message/-/bitcoinjs-message-2.2.0.tgz", "integrity": "sha512-103Wy3xg8Y9o+pdhGP4M3/mtQQuUWs6sPuOp1mYphSUoSMHjHTlkj32K4zxU8qMH0Ckv23emfkGlFWtoWZ7YFA==", "license": "MIT", - "optional": true, "dependencies": { "bech32": "^1.1.3", "bs58check": "^2.1.2", @@ -8340,7 +8339,6 @@ "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.11.tgz", "integrity": "sha512-xz7wQ8xDhdyP7tQxwdteLYeFfS68tSMNCZ/Y37WJ4bhGfKPpqEIlmIyueQHqOyoPhE6xNUqjzRr8ra0eF9VRvA==", "license": "MIT", - "optional": true, "dependencies": { "safe-buffer": "^5.0.1" } @@ -8349,22 +8347,19 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/bitcoinjs-message/node_modules/bn.js": { "version": "4.12.2", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/bitcoinjs-message/node_modules/bs58": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", "license": "MIT", - "optional": true, "dependencies": { "base-x": "^3.0.2" } @@ -8374,7 +8369,6 @@ "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", "license": "MIT", - "optional": true, "dependencies": { "bs58": "^4.0.0", "create-hash": "^1.1.0", @@ -8387,7 +8381,6 @@ "integrity": "sha512-tArjQw2P0RTdY7QmkNehgp6TVvQXq6ulIhxv8gaH6YubKG/wxxAoNKcbuXjDhybbc+b2Ihc7e0xxiGN744UIiQ==", "hasInstallScript": true, "license": "MIT", - "optional": true, "dependencies": { "bindings": "^1.5.0", "bip66": "^1.1.5", @@ -8447,15 +8440,13 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/browserify-aes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "license": "MIT", - "optional": true, "dependencies": { "buffer-xor": "^1.0.3", "cipher-base": "^1.0.0", @@ -8561,7 +8552,6 @@ "resolved": "https://registry.npmjs.org/buffer-equals/-/buffer-equals-1.0.4.tgz", "integrity": "sha512-99MsCq0j5+RhubVEtKQgKaD6EM+UP3xJgIvQqwJ3SOLDUekzxMX1ylXBng+Wa2sh7mGT0W6RUly8ojjr1Tt6nA==", "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } @@ -8570,8 +8560,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/bufferutil": { "version": "4.0.9", @@ -8808,7 +8797,6 @@ "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.6.tgz", "integrity": "sha512-3Ek9H3X6pj5TgenXYtNWdaBon1tgYCaebd+XPg0keyjEbEfkD4KkmAxkQ/i1vYvxdcT5nscLBfq9VJRmCBcFSw==", "license": "MIT", - "optional": true, "dependencies": { "inherits": "^2.0.4", "safe-buffer": "^5.2.1" @@ -9356,7 +9344,6 @@ "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "license": "MIT", - "optional": true, "dependencies": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", @@ -9370,7 +9357,6 @@ "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "license": "MIT", - "optional": true, "dependencies": { "cipher-base": "^1.0.3", "create-hash": "^1.1.0", @@ -9827,7 +9813,6 @@ "resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz", "integrity": "sha512-F4wZ06PvqxYLFEZKkFxTDcns9oFNk34hvmJSEwdzsxVQ8YI5YaxtACgQatkYgv2VI2CFkUd2Y+xosPQnHv809g==", "license": "MIT", - "optional": true, "dependencies": { "browserify-aes": "^1.0.6", "create-hash": "^1.1.2", @@ -9942,7 +9927,6 @@ "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.1.tgz", "integrity": "sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==", "license": "MIT", - "optional": true, "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -9957,8 +9941,7 @@ "version": "4.12.2", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/embla-carousel": { "version": "8.3.0", @@ -10550,7 +10533,6 @@ "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "license": "MIT", - "optional": true, "dependencies": { "md5.js": "^1.3.4", "safe-buffer": "^5.1.1" @@ -10691,8 +10673,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/fill-range": { "version": "7.1.1", @@ -11086,7 +11067,6 @@ "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "license": "MIT", - "optional": true, "dependencies": { "inherits": "^2.0.4", "readable-stream": "^3.6.0", @@ -11101,7 +11081,6 @@ "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "license": "MIT", - "optional": true, "dependencies": { "inherits": "^2.0.3", "minimalistic-assert": "^1.0.1" @@ -11136,7 +11115,6 @@ "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", "license": "MIT", - "optional": true, "dependencies": { "hash.js": "^1.0.3", "minimalistic-assert": "^1.0.0", @@ -12178,7 +12156,6 @@ "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "license": "MIT", - "optional": true, "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1", @@ -12248,15 +12225,13 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/minimatch": { "version": "3.1.2", @@ -12348,8 +12323,7 @@ "version": "2.23.0", "resolved": "https://registry.npmjs.org/nan/-/nan-2.23.0.tgz", "integrity": "sha512-1UxuyYGdoQHcGg87Lkqm3FzefucTa0NAiOcuRsDmysep3c1LVCRK2krrUDafMWtjSG04htvAmvg96+SDknOmgQ==", - "license": "MIT", - "optional": true + "license": "MIT" }, "node_modules/nanoid": { "version": "3.3.7", @@ -13749,7 +13723,6 @@ "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "license": "MIT", - "optional": true, "dependencies": { "hash-base": "^3.0.0", "inherits": "^2.0.1" @@ -15045,9 +15018,9 @@ } }, "node_modules/viem": { - "version": "2.33.2", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.33.2.tgz", - "integrity": "sha512-/720OaM4dHWs8vXwNpyet+PRERhPaW+n/1UVSCzyb9jkmwwVfaiy/R6YfCFb4v+XXbo8s3Fapa3DM5yCRSkulA==", + "version": "2.37.1", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.37.1.tgz", + "integrity": "sha512-IzacdIXYlOvzDJwNKIVa53LP/LaP70qvBGAIoGH6R+n06S/ru/nnQxLNZ6+JImvIcxwNwgAl0jUA6FZEIQQWSw==", "funding": [ { "type": "github", @@ -15056,14 +15029,14 @@ ], "license": "MIT", "dependencies": { - "@noble/curves": "1.9.2", + "@noble/curves": "1.9.1", "@noble/hashes": "1.8.0", "@scure/bip32": "1.7.0", "@scure/bip39": "1.6.0", "abitype": "1.0.8", "isows": "1.0.7", - "ox": "0.8.6", - "ws": "8.18.2" + "ox": "0.9.3", + "ws": "8.18.3" }, "peerDependencies": { "typescript": ">=5.0.4" @@ -15074,6 +15047,21 @@ } } }, + "node_modules/viem/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/viem/node_modules/@scure/bip32": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.7.0.tgz", @@ -15108,9 +15096,9 @@ "license": "MIT" }, "node_modules/viem/node_modules/ox": { - "version": "0.8.6", - "resolved": "https://registry.npmjs.org/ox/-/ox-0.8.6.tgz", - "integrity": "sha512-eiKcgiVVEGDtEpEdFi1EGoVVI48j6icXHce9nFwCNM7CKG3uoCXKdr4TPhS00Iy1TR2aWSF1ltPD0x/YgqIL9w==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.9.3.tgz", + "integrity": "sha512-KzyJP+fPV4uhuuqrTZyok4DC7vFzi7HLUFiUNEmpbyh59htKWkOC98IONC1zgXJPbHAhQgqs6B0Z6StCGhmQvg==", "funding": [ { "type": "github", @@ -15121,11 +15109,11 @@ "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", - "@noble/curves": "^1.9.1", + "@noble/curves": "1.9.1", "@noble/hashes": "^1.8.0", "@scure/bip32": "^1.7.0", "@scure/bip39": "^1.6.0", - "abitype": "^1.0.8", + "abitype": "^1.0.9", "eventemitter3": "5.0.1" }, "peerDependencies": { @@ -15137,23 +15125,23 @@ } } }, - "node_modules/viem/node_modules/ws": { - "version": "8.18.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.2.tgz", - "integrity": "sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==", + "node_modules/viem/node_modules/ox/node_modules/abitype": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.9.tgz", + "integrity": "sha512-oN0S++TQmlwWuB+rkA6aiEefLv3SP+2l/tC5mux/TLj6qdA6rF15Vbpex4fHovLsMkwLwTIRj8/Q8vXCS3GfOg==", "license": "MIT", - "engines": { - "node": ">=10.0.0" + "funding": { + "url": "https://github.com/sponsors/wevm" }, "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" + "typescript": ">=5.0.4", + "zod": "^3 >=3.22.0" }, "peerDependenciesMeta": { - "bufferutil": { + "typescript": { "optional": true }, - "utf-8-validate": { + "zod": { "optional": true } } diff --git a/package.json b/package.json index 0260d95..b6bdeac 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "@reown/appkit-wallet-button": "^1.7.17", "@tanstack/react-query": "^5.84.1", "@waku/sdk": "^0.0.35-67a7287.0", + "bitcoinjs-message": "^2.2.0", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.0.0", @@ -71,6 +72,7 @@ "tailwindcss-animate": "^1.0.7", "uuid": "^11.1.0", "vaul": "^0.9.3", + "viem": "^2.37.1", "wagmi": "^2.16.1", "zod": "^3.23.8" }, diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 04af238..34d8411 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -27,7 +27,7 @@ import { useAppKitAccount, useDisconnect } from '@reown/appkit/react'; import { WalletWizard } from '@/components/ui/wallet-wizard'; const Header = () => { - const { currentUser, verificationStatus, isDelegationValid } = useAuth(); + const { currentUser, verificationStatus, getDelegationStatus } = useAuth(); const { isNetworkConnected, isRefreshing } = useForum(); const location = useLocation(); const { toast } = useToast(); @@ -95,9 +95,9 @@ const Header = () => { case 'verified-none': return 'Read-Only Access'; case 'verified-basic': - return isDelegationValid() ? 'Full Access' : 'Setup Key'; + return getDelegationStatus().isValid ? 'Full Access' : 'Setup Key'; case 'verified-owner': - return isDelegationValid() ? 'Premium Access' : 'Setup Key'; + return getDelegationStatus().isValid ? 'Premium Access' : 'Setup Key'; default: return 'Setup Account'; } @@ -112,13 +112,13 @@ const Header = () => { case 'verified-none': return ; case 'verified-basic': - return isDelegationValid() ? ( + return getDelegationStatus().isValid ? ( ) : ( - + ); case 'verified-owner': - return isDelegationValid() ? ( + return getDelegationStatus().isValid ? ( ) : ( @@ -137,9 +137,9 @@ const Header = () => { case 'verified-none': return 'secondary'; case 'verified-basic': - return isDelegationValid() ? 'default' : 'outline'; + return getDelegationStatus().isValid ? 'default' : 'outline'; case 'verified-owner': - return isDelegationValid() ? 'default' : 'outline'; + return getDelegationStatus().isValid ? 'default' : 'outline'; default: return 'outline'; } diff --git a/src/components/ui/delegation-step.tsx b/src/components/ui/delegation-step.tsx index 3473a01..b22085c 100644 --- a/src/components/ui/delegation-step.tsx +++ b/src/components/ui/delegation-step.tsx @@ -20,8 +20,7 @@ export function DelegationStep({ const { currentUser, delegateKey, - isDelegationValid, - delegationTimeRemaining, + getDelegationStatus, isAuthenticating, clearDelegation, } = useAuth(); @@ -162,23 +161,30 @@ export function DelegationStep({
{/* Status */}
- {isDelegationValid() ? ( + {getDelegationStatus().isValid ? ( ) : ( )} - {isDelegationValid() ? 'Delegated' : 'Required'} + {getDelegationStatus().isValid ? 'Delegated' : 'Required'} - {isDelegationValid() && ( + {getDelegationStatus().isValid && ( - {Math.floor(delegationTimeRemaining() / (1000 * 60 * 60))}h{' '} {Math.floor( - (delegationTimeRemaining() % (1000 * 60 * 60)) / (1000 * 60) + (getDelegationStatus().timeRemaining || 0) / (1000 * 60 * 60) + )} + h{' '} + {Math.floor( + ((getDelegationStatus().timeRemaining || 0) % + (1000 * 60 * 60)) / + (1000 * 60) )} m remaining @@ -186,7 +192,7 @@ export function DelegationStep({
{/* Duration Selection */} - {!isDelegationValid() && ( + {!getDelegationStatus().isValid && (