diff --git a/packages/nextjs/components/Header.tsx b/packages/nextjs/components/Header.tsx index 970f5fc..3b36d0b 100644 --- a/packages/nextjs/components/Header.tsx +++ b/packages/nextjs/components/Header.tsx @@ -96,7 +96,7 @@ export const Header = () => { SE2 logo */}
- NOSTR3 + NOSTR3 Link Web3 to nostr
diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 1d58c4e..82c094b 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -84,7 +84,7 @@ "tailwindcss": "^3.3.3", "type-fest": "^4.6.0", "typescript": "^5.1.6", - "vercel": "^32.5.5" + "vercel": "latest" }, "engines": { "node": ">=14.0.0" diff --git a/packages/nextjs/pages/login.tsx b/packages/nextjs/pages/login.tsx index 833f16a..76841e3 100644 --- a/packages/nextjs/pages/login.tsx +++ b/packages/nextjs/pages/login.tsx @@ -150,8 +150,8 @@ const Login: NextPage = () => { - -
+ +
    {publicKey && ( @@ -259,6 +259,52 @@ const Login: NextPage = () => { await relay?.publish(signedEvent); }; + const handleTipNotRegisterd = async () => { + const key = generateRandomPassword(); + if (!isExtension) { + console.log("Not Extension"); + const nostr3 = new Nostr3(privateKey); + const message = `Tip ${amountToTip} OPETH to ${pubKeyReceiver}. Go to https://nostr3.vercel.app/claim and use this key to retrive your tip: ${key}`; + const decodedPubKey = await nip19.decode(pubKeyReceiver); + const encrypted = await nostr3.encryptDM(message, String(decodedPubKey.data)); + + // Send message with key encryted to the npub + const newEvent = { + kind: 4, + created_at: Math.floor(Date.now() / 1000), + tags: [["p", String(decodedPubKey.data)]], + content: String(encrypted), + pubkey: publicKey, + }; + + const encoded = encodeAbiParameters(parseAbiParameters("string"), [key]); + + // Deposit on the contract with HASH + const hash = keccak256(encoded); + + await nostr3ctx?.write?.deposit([hash], { value: parseEther(String(amountToTip)) }); + const publish = await publishEvent(newEvent as UnsignedEvent, privateKey); + console.log(publish); + } else { + const message = `Tip ${amountToTip} ETH to ${pubKeyReceiver}. Use this key to retrive your tip: ${key}`; + const decodedPubKey = nip19.decode(pubKeyReceiver); + const encrypted = await window.nostr.nip04.encrypt(decodedPubKey, message); + const newEvent = { + kind: 4, + created_at: Math.floor(Date.now() / 1000), + tags: [["p", pubKeyReceiver]], + content: encrypted, + pubkey: publicKey, + }; + + const hash = keccak256(String(key) as any); + await nostr3ctx?.write?.deposit([hash], { value: parseEther(String(amountToTip)) }); + + const signedEvent = await window.nostr.signEvent(newEvent); + await relay?.publish(signedEvent); + } + }; + const handleTip = async (receiver: any) => { let message; let newEvent; @@ -923,7 +969,7 @@ const Login: NextPage = () => { Relay -
    +

    RELAY

    )}
    - -
    + +
    TIP
    { + {consoleMessage}
    {/* if there is a button in form, it will close the modal */} diff --git a/yarn.lock b/yarn.lock index 9569e4d..39fb63f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2383,7 +2383,7 @@ __metadata: url: ^0.11.3 use-debounce: ^8.0.4 usehooks-ts: ^2.7.2 - vercel: ^32.5.5 + vercel: latest viem: ^1.16.6 wagmi: 1.4.4 web3: ^4.2.2 @@ -3586,10 +3586,10 @@ __metadata: languageName: node linkType: hard -"@vercel/build-utils@npm:7.2.5": - version: 7.2.5 - resolution: "@vercel/build-utils@npm:7.2.5" - checksum: e230d91de45b82e13a62d5fa0bbe505f12c0888945c07f7515cfeaf67938961a4934b028b8f3bdbc226046273ddd26c152f432d2a5db10c0fd6d6aae9c526b6e +"@vercel/build-utils@npm:7.3.0": + version: 7.3.0 + resolution: "@vercel/build-utils@npm:7.3.0" + checksum: 84985548f074d15edc1ad41024c510888f6059a7830fdfdb21db989fd7de32dc035f9ad13cbacca97fb40c1d6c9ae01c65eedc113621f310a230ab22603896d9 languageName: node linkType: hard @@ -3637,24 +3637,24 @@ __metadata: languageName: node linkType: hard -"@vercel/gatsby-plugin-vercel-builder@npm:2.0.11": - version: 2.0.11 - resolution: "@vercel/gatsby-plugin-vercel-builder@npm:2.0.11" +"@vercel/gatsby-plugin-vercel-builder@npm:2.0.12": + version: 2.0.12 + resolution: "@vercel/gatsby-plugin-vercel-builder@npm:2.0.12" dependencies: "@sinclair/typebox": 0.25.24 - "@vercel/build-utils": 7.2.5 + "@vercel/build-utils": 7.3.0 "@vercel/routing-utils": 3.1.0 esbuild: 0.14.47 etag: 1.8.1 fs-extra: 11.1.0 - checksum: 2b5e51d74e3a67d32520c22155e7c132efc882702fb15f99888ab09c2099f6d39f23ae4208a7d30d45edf45aa4534dbe807bf6690ac10e53677a2e7a6880eaa7 + checksum: 600d83127ba61f1dc639eedf915d54e45d232bfd63fba21e7d24c93db0f0ee304a6082045f6b520de03d0ebb0e941a8317e9f21aa7295483bad9ffe0e83bf0bd languageName: node linkType: hard -"@vercel/go@npm:3.0.3": - version: 3.0.3 - resolution: "@vercel/go@npm:3.0.3" - checksum: cf9fa10e00f8bba70c520c9371d4ba7e2d4e6e1970ae74c44b0db86f626c2a294eff7cc36e0f76112084a8bffc35569eca38abc8b3912b59e1081bcfdc2134a3 +"@vercel/go@npm:3.0.4": + version: 3.0.4 + resolution: "@vercel/go@npm:3.0.4" + checksum: b8a8f4b7ad0c78bc53c6e3366bafd26cdc9a50a733bc3bec9021ecfdfb22e6281bb9c7bca6acd1fd5d68c142924f1720e963c9f428619706e9467c7e798c82c1 languageName: node linkType: hard @@ -3698,15 +3698,15 @@ __metadata: languageName: node linkType: hard -"@vercel/node@npm:3.0.11": - version: 3.0.11 - resolution: "@vercel/node@npm:3.0.11" +"@vercel/node@npm:3.0.12": + version: 3.0.12 + resolution: "@vercel/node@npm:3.0.12" dependencies: "@edge-runtime/node-utils": 2.2.1 "@edge-runtime/primitives": 4.0.5 "@edge-runtime/vm": 3.1.7 "@types/node": 14.18.33 - "@vercel/build-utils": 7.2.5 + "@vercel/build-utils": 7.3.0 "@vercel/error-utils": 2.0.2 "@vercel/nft": 0.24.2 "@vercel/static-config": 3.0.0 @@ -3721,7 +3721,7 @@ __metadata: ts-node: 10.9.1 typescript: 4.9.5 undici: 5.26.5 - checksum: 8f35c7b05b385d04e987346bc2d339d7175960adde4ee802d27b7002eccfc9712c906652709ef7a88e2630d4514f7c2729c4763d327edca1821281f1a18af3ed + checksum: a8cb14266af1fe98ca29bea7adcb108d1a6ec8d8518e0615a36e28aafd70a92e9a0397b46a8b52d0b5220529ed37c8a093a6b74e28357b4bbbcbb2595c0d3f2d languageName: node linkType: hard @@ -3743,14 +3743,14 @@ __metadata: languageName: node linkType: hard -"@vercel/remix-builder@npm:2.0.11": - version: 2.0.11 - resolution: "@vercel/remix-builder@npm:2.0.11" +"@vercel/remix-builder@npm:2.0.14": + version: 2.0.14 + resolution: "@vercel/remix-builder@npm:2.0.14" dependencies: "@vercel/nft": 0.24.2 "@vercel/static-config": 3.0.0 ts-morph: 12.0.0 - checksum: 10ada155ab297d705010117d4bfda20f29c30eb6731db59bfc79f43ec05cc025051435fb4c55023bbcb4051be540150ddec863d016f3710b746df15a80f4380a + checksum: c66bf19c930426dcd79330843a78197023b935e879ee0c708226c08819f4b981d15b71b3ea3f48621473bbe81af5cbeeed1b97e63110aa6ee5a8a7657c846c86 languageName: node linkType: hard @@ -3767,22 +3767,22 @@ __metadata: languageName: node linkType: hard -"@vercel/ruby@npm:2.0.3": - version: 2.0.3 - resolution: "@vercel/ruby@npm:2.0.3" - checksum: f15852b857e03ec37a58a42effb333a0012f921dd3ef55ce61fe74efc2cd5ca5cf923c4e089fffc068b33ffb4a8ce244944d6d4d1188cfb07eb23494cd28cdbe +"@vercel/ruby@npm:2.0.4": + version: 2.0.4 + resolution: "@vercel/ruby@npm:2.0.4" + checksum: c549aaa07a2ec7a9d9a2f5730a7fe14309a8109abf4b3d5be1200e3085cf3392c274e30b75c7a1b35f24d447b60aec9c58274093011f1f5db024217bfc256683 languageName: node linkType: hard -"@vercel/static-build@npm:2.0.12": - version: 2.0.12 - resolution: "@vercel/static-build@npm:2.0.12" +"@vercel/static-build@npm:2.0.14": + version: 2.0.14 + resolution: "@vercel/static-build@npm:2.0.14" dependencies: "@vercel/gatsby-plugin-vercel-analytics": 1.0.11 - "@vercel/gatsby-plugin-vercel-builder": 2.0.11 + "@vercel/gatsby-plugin-vercel-builder": 2.0.12 "@vercel/static-config": 3.0.0 ts-morph: 12.0.0 - checksum: bfcae7bebe4a04b731bb1685bbee07c96be049052c17f8dd571122930921da15dd531af4548fbd1f4889978e5207cc515f0e37bb3a59e10816820e8257c6e4c1 + checksum: c1e74d816e89a7dace10bd6495d53a70feda7cb1c9cefba5ac227264bde49615c101ea660f8927d66f1ae2b0cd326762898b6553bbe28341bae2583eb429e457 languageName: node linkType: hard @@ -16952,26 +16952,26 @@ __metadata: languageName: node linkType: hard -"vercel@npm:^32.5.5": - version: 32.5.6 - resolution: "vercel@npm:32.5.6" +"vercel@npm:latest": + version: 32.7.2 + resolution: "vercel@npm:32.7.2" dependencies: - "@vercel/build-utils": 7.2.5 + "@vercel/build-utils": 7.3.0 "@vercel/fun": 1.1.0 - "@vercel/go": 3.0.3 + "@vercel/go": 3.0.4 "@vercel/hydrogen": 1.0.1 "@vercel/next": 4.0.15 - "@vercel/node": 3.0.11 + "@vercel/node": 3.0.12 "@vercel/python": 4.1.0 "@vercel/redwood": 2.0.5 - "@vercel/remix-builder": 2.0.11 - "@vercel/ruby": 2.0.3 - "@vercel/static-build": 2.0.12 + "@vercel/remix-builder": 2.0.14 + "@vercel/ruby": 2.0.4 + "@vercel/static-build": 2.0.14 chokidar: 3.3.1 bin: vc: dist/index.js vercel: dist/index.js - checksum: 092fec20e39c7f2ca56edfbfb0314ec5a8102627c37e977f6d301164afab83762f9e8f4cb818c7548e100676e6e598c3223cd8d70f5203027fe05cb0bba79be9 + checksum: 0f0b4f03ac182a5beaa62040ebc762d8f510ec5872874497a813b1d2ac8a15fde74213e9729e7edad1dbcb4535cac66c218e6e591518f556e43ae0fcb886bd0e languageName: node linkType: hard