From c5931f176a4431779a573757da3d0f098bc2c1ad Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Mon, 15 Jan 2024 09:59:00 +0330 Subject: [PATCH 01/16] replace nostr-hooks with ndk --- package.json | 2 +- yarn.lock | 230 +++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 217 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index f34ea00..f9cfcfb 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "@getalby/bitcoin-connect-react": "^3.2.0-beta.0", "@getalby/lightning-tools": "^5.0.0", "@getalby/sdk": "^3.2.2", + "@nostr-dev-kit/ndk": "^2.3.2", "@popicons/react": "^0.0.8", - "nostr-hooks": "^1.8.2", "nostr-tools": "1.17.0", "qrcode.react": "^3.1.0", "react": "^18.2.0", diff --git a/yarn.lock b/yarn.lock index da96672..250d6e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1232,11 +1232,16 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA== -"@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1": +"@noble/hashes@^1.3.1", "@noble/hashes@~1.3.0", "@noble/hashes@~1.3.1": version "1.3.3" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.3.tgz#39908da56a4adc270147bb07968bf3b16cfe1699" integrity sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA== +"@noble/secp256k1@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-2.0.0.tgz#c214269d45e0233ad6a8ae5104655453636e253d" + integrity sha512-rUGBd95e2a45rlmFTqQJYEFA4/gdIARFfuTuTqLglz0PZ6AKyzyXsEZZq7UZn8hZsvaBgpCzKKBJizT2cJERXw== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1258,6 +1263,23 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@nostr-dev-kit/ndk@^2.3.2": + version "2.3.2" + resolved "https://registry.yarnpkg.com/@nostr-dev-kit/ndk/-/ndk-2.3.2.tgz#5d838954a624e9f36d7bb33dadb1dec5ac539c14" + integrity sha512-k3/C2RtCRl8Pb3McaQkUiTxH7gs7U7agSqK6J7xdZSJZIO46qhz2zu6USco9eGAg67Ytz3VAmSI8sHQEi1f3fA== + dependencies: + "@noble/hashes" "^1.3.1" + "@noble/secp256k1" "^2.0.0" + "@scure/base" "^1.1.1" + debug "^4.3.4" + light-bolt11-decoder "^3.0.0" + node-fetch "^3.3.1" + nostr-tools "^1.15.0" + tseep "^1.1.1" + typescript-lru-cache "^2.0.0" + utf8-buffer "^1.0.0" + websocket-polyfill "^0.0.3" + "@popicons/react@^0.0.8": version "0.0.8" resolved "https://registry.yarnpkg.com/@popicons/react/-/react-0.0.8.tgz#b329abf0f0f12da76e6eb1a1824f075cac23eb2d" @@ -1375,7 +1397,7 @@ resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938" integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA== -"@scure/base@~1.1.0": +"@scure/base@^1.1.1", "@scure/base@~1.1.0": version "1.1.5" resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157" integrity sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ== @@ -1838,6 +1860,13 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +bufferutil@^4.0.1: + version "4.0.8" + resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.8.tgz#1de6a71092d65d7766c4d8a522b261a6e787e8ea" + integrity sha512-4T53u4PdgsXqKaIctwF8ifXlRTTmEPJ8iEPWFdGZvcf7sbwYo6FKFEX9eNNAnzFZ7EzJAQ3CJeOtCRA4rDp7Pw== + dependencies: + node-gyp-build "^4.3.0" + builtin-modules@^3.1.0: version "3.3.0" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.3.0.tgz#cae62812b89801e9656336e46223e030386be7b6" @@ -1997,6 +2026,14 @@ culori@^3: resolved "https://registry.yarnpkg.com/culori/-/culori-3.3.0.tgz#e33530adbd124d53bd6550394397e695eaaed739" integrity sha512-pHJg+jbuFsCjz9iclQBqyL3B2HLCBF71BwVNujUYEvCeQMvV97R59MNK3R2+jgJ3a1fcZgI9B3vYgz8lzr/BFQ== +d@1, d@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.1.tgz#8698095372d58dbee346ffd0c7093f99f8f9eb5a" + integrity sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA== + dependencies: + es5-ext "^0.10.50" + type "^1.0.1" + daisyui@^4.4.20: version "4.4.20" resolved "https://registry.yarnpkg.com/daisyui/-/daisyui-4.4.20.tgz#3f010eb3d1fc7b4b5824524d27a07adea6e4578d" @@ -2007,6 +2044,18 @@ daisyui@^4.4.20: picocolors "^1" postcss-js "^4" +data-uri-to-buffer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" + integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== + +debug@^2.2.0: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" @@ -2141,6 +2190,32 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +es5-ext@^0.10.35, es5-ext@^0.10.50: + version "0.10.62" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.62.tgz#5e6adc19a6da524bf3d1e02bbc8960e5eb49a9a5" + integrity sha512-BHLqn0klhEpnOKSrzn/Xsz2UIW8j+cGmo9JLzr8BiUapV8hPL9+FliFqjwr9ngW7jWdnxv6eO+/LqyhJVqgrjA== + dependencies: + es6-iterator "^2.0.3" + es6-symbol "^3.1.3" + next-tick "^1.1.0" + +es6-iterator@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha512-zw4SRzoUkd+cl+ZoE15A9o1oQd920Bb0iOJMQkQhl3jNc03YqVjAhG7scf9C5KWRU/R13Orf588uCC6525o02g== + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-symbol@^3.1.1, es6-symbol@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.3.tgz#bad5d3c1bcdac28269f4cb331e431c78ac705d18" + integrity sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA== + dependencies: + d "^1.0.1" + ext "^1.1.2" + esbuild@^0.19.3: version "0.19.9" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.9.tgz#423a8f35153beb22c0b695da1cd1e6c0c8cdd490" @@ -2294,6 +2369,13 @@ events@^3.3.0: resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== +ext@^1.1.2: + version "1.7.0" + resolved "https://registry.yarnpkg.com/ext/-/ext-1.7.0.tgz#0ea4383c0103d60e70be99e9a7f11027a33c4f5f" + integrity sha512-6hxeJYaL110a9b5TEJSj0gojyHQAmA2ch5Os+ySCiA1QGdS697XWY1pzsrSjqA9LDEEgdB/KypIlR59RcLuHYw== + dependencies: + type "^2.7.2" + fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" @@ -2332,6 +2414,14 @@ fastq@^1.6.0: dependencies: reusify "^1.0.4" +fetch-blob@^3.1.2, fetch-blob@^3.1.4: + version "3.2.0" + resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" + integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== + dependencies: + node-domexception "^1.0.0" + web-streams-polyfill "^3.0.3" + file-entry-cache@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz#211b2dd9659cb0394b073e7323ac3c933d522027" @@ -2382,6 +2472,13 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +formdata-polyfill@^4.0.10: + version "4.0.10" + resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" + integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== + dependencies: + fetch-blob "^3.1.2" + fraction.js@^4.3.6: version "4.3.7" resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7" @@ -2772,6 +2869,11 @@ is-typed-array@^1.1.10, is-typed-array@^1.1.12, is-typed-array@^1.1.9: dependencies: which-typed-array "^1.1.11" +is-typedarray@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== + is-weakref@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" @@ -2899,6 +3001,13 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +light-bolt11-decoder@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/light-bolt11-decoder/-/light-bolt11-decoder-3.0.0.tgz#f644576120426c9ef65621bde254f11016055044" + integrity sha512-AKvOigD2pmC8ktnn2TIqdJu0K0qk6ukUmTvHwF3JNkm8uWCqt18Ijn33A/a7gaRZ4PghJ59X+8+MXrzLKdBTmQ== + dependencies: + "@scure/base" "1.1.1" + lilconfig@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" @@ -2936,7 +3045,7 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== -lodash@^4.17.20, lodash@^4.17.21: +lodash@^4.17.20: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -3001,6 +3110,11 @@ minimatch@^5.0.1: dependencies: brace-expansion "^2.0.1" +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== + ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" @@ -3025,6 +3139,30 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== +next-tick@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" + integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== + +node-domexception@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" + integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== + +node-fetch@^3.3.1: + version "3.3.2" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.2.tgz#d1e889bacdf733b4ff3b2b243eb7a12866a0b78b" + integrity sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA== + dependencies: + data-uri-to-buffer "^4.0.0" + fetch-blob "^3.1.4" + formdata-polyfill "^4.0.10" + +node-gyp-build@^4.3.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.8.0.tgz#3fee9c1731df4581a3f9ead74664369ff00d26dd" + integrity sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og== + node-releases@^2.0.14: version "2.0.14" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" @@ -3040,17 +3178,7 @@ normalize-range@^0.1.2: resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA== -nostr-hooks@^1.8.2: - version "1.8.2" - resolved "https://registry.yarnpkg.com/nostr-hooks/-/nostr-hooks-1.8.2.tgz#6a761098c8c7482b6ab46b31dd50c6309d292102" - integrity sha512-VEnn1xlmHgxNyBZe66VpigX4d1NcF7GveDu5MjOGfKkYAZl47+GmIs2LLzthVA0Lf3DVSrdAwfZ6ld6lBtCpHQ== - dependencies: - lodash "^4.17.21" - nostr-tools "^1.17.0" - react "^18.2.0" - zustand "^4.4.7" - -nostr-tools@1.17.0, nostr-tools@^1.17.0: +nostr-tools@1.17.0, nostr-tools@^1.15.0, nostr-tools@^1.17.0: version "1.17.0" resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.17.0.tgz#b6f62e32fedfd9e68ec0a7ce57f74c44fc768e8c" integrity sha512-LZmR8GEWKZeElbFV5Xte75dOeE9EFUW/QLI1Ncn3JKn0kFddDKEfBbFN8Mu4TMs+L4HR/WTPha2l+PPuRnJcMw== @@ -3769,6 +3897,16 @@ ts-interface-checker@^0.1.9: resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== +tseep@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/tseep/-/tseep-1.1.3.tgz#7cf81b83680403af9d10829be6a04bd134bee8c5" + integrity sha512-deBIcIlXUMlr3xaN0UEochqjU/zXGaZGPqHPd1rxo4w6DklBdRM6WQQtsk7bekIF+qY6QTeen3nE6OA7BxL9rg== + +tstl@^2.0.7: + version "2.5.13" + resolved "https://registry.yarnpkg.com/tstl/-/tstl-2.5.13.tgz#a5a5d27b79a12767e46a08525b3e045c5cdb1180" + integrity sha512-h9wayHHFI5+yqt8iau0vqH96cTNhezhZ/Fk/hrIdpfkiMu3lg9nzyvMfs5bIdX51IVzZO6DudLqhkL/rVXpT6g== + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" @@ -3786,6 +3924,16 @@ type-fest@^0.20.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== +type@^1.0.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/type/-/type-1.2.0.tgz#848dd7698dafa3e54a6c479e759c4bc3f18847a0" + integrity sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg== + +type@^2.7.2: + version "2.7.2" + resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0" + integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== + typed-array-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" @@ -3825,6 +3973,18 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" +typedarray-to-buffer@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" + integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q== + dependencies: + is-typedarray "^1.0.0" + +typescript-lru-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/typescript-lru-cache/-/typescript-lru-cache-2.0.0.tgz#d4ad0f071ab51987b088a57c3c502d7dd62dee07" + integrity sha512-Jp57Qyy8wXeMkdNuZiglE6v2Cypg13eDA1chHwDG6kq51X7gk4K7P7HaDdzZKCxkegXkVHNcPD0n5aW6OZH3aA== + typescript@^5.2.2: version "5.3.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.3.3.tgz#b3ce6ba258e72e6305ba66f5c9b452aaee3ffe37" @@ -3905,6 +4065,18 @@ use-sync-external-store@1.2.0: resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== +utf-8-validate@^5.0.2: + version "5.0.10" + resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2" + integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ== + dependencies: + node-gyp-build "^4.3.0" + +utf8-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/utf8-buffer/-/utf8-buffer-1.0.0.tgz#457e7d848d4d9cd873772b710d150565f6e543d9" + integrity sha512-ueuhzvWnp5JU5CiGSY4WdKbiN/PO2AZ/lpeLiz2l38qwdLy/cW40XobgyuIWucNyum0B33bVB0owjFCeGBSLqg== + util-deprecate@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -3932,11 +4104,36 @@ vite@^5.0.10: optionalDependencies: fsevents "~2.3.3" +web-streams-polyfill@^3.0.3: + version "3.3.2" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.3.2.tgz#32e26522e05128203a7de59519be3c648004343b" + integrity sha512-3pRGuxRF5gpuZc0W+EpwQRmCD7gRqcDOMt688KmdlDAgAyaB1XlN0zq2njfDNm44XVdIouE7pZ6GzbdyH47uIQ== + webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== +websocket-polyfill@^0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/websocket-polyfill/-/websocket-polyfill-0.0.3.tgz#7321ada0f5f17516290ba1cb587ac111b74ce6a5" + integrity sha512-pF3kR8Uaoau78MpUmFfzbIRxXj9PeQrCuPepGE6JIsfsJ/o/iXr07Q2iQNzKSSblQJ0FiGWlS64N4pVSm+O3Dg== + dependencies: + tstl "^2.0.7" + websocket "^1.0.28" + +websocket@^1.0.28: + version "1.0.34" + resolved "https://registry.yarnpkg.com/websocket/-/websocket-1.0.34.tgz#2bdc2602c08bf2c82253b730655c0ef7dcab3111" + integrity sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ== + dependencies: + bufferutil "^4.0.1" + debug "^2.2.0" + es5-ext "^0.10.50" + typedarray-to-buffer "^3.1.5" + utf-8-validate "^5.0.2" + yaeti "^0.0.6" + whatwg-url@^7.0.0: version "7.1.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06" @@ -4138,6 +4335,11 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== +yaeti@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/yaeti/-/yaeti-0.0.6.tgz#f26f484d72684cf42bedfb76970aa1608fbf9577" + integrity sha512-MvQa//+KcZCUkBTIC9blM+CU9J2GzuTytsOUwf2lidtvkx/6gnEp1QvJv34t9vdjhFmha/mUiNDbN0D0mJWdug== + yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" From dd012655b907f9188fe6a107d2fe65a11b7eff44 Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Mon, 15 Jan 2024 10:21:20 +0330 Subject: [PATCH 02/16] add ndk-cache-dexie --- package.json | 1 + yarn.lock | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f9cfcfb..eace4c4 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@getalby/lightning-tools": "^5.0.0", "@getalby/sdk": "^3.2.2", "@nostr-dev-kit/ndk": "^2.3.2", + "@nostr-dev-kit/ndk-cache-dexie": "^2.2.3", "@popicons/react": "^0.0.8", "nostr-tools": "1.17.0", "qrcode.react": "^3.1.0", diff --git a/yarn.lock b/yarn.lock index 250d6e2..1ca8790 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1263,7 +1263,18 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@nostr-dev-kit/ndk@^2.3.2": +"@nostr-dev-kit/ndk-cache-dexie@^2.2.3": + version "2.2.3" + resolved "https://registry.yarnpkg.com/@nostr-dev-kit/ndk-cache-dexie/-/ndk-cache-dexie-2.2.3.tgz#67241b4b97ac3f0e7071c4aa98283349503f83df" + integrity sha512-Ywx01PFn4ddvdWLCHn2xsMcmdgtLpcX1IJztDtdQs8KNbOKUQmjQRql422DRKKZ/XX7u5NeUmzCa8xBnc6OXew== + dependencies: + "@nostr-dev-kit/ndk" "2.3.2" + debug "^4.3.4" + dexie "^3.2.4" + nostr-tools "^1.14.0" + typescript-lru-cache "^2.0.0" + +"@nostr-dev-kit/ndk@2.3.2", "@nostr-dev-kit/ndk@^2.3.2": version "2.3.2" resolved "https://registry.yarnpkg.com/@nostr-dev-kit/ndk/-/ndk-2.3.2.tgz#5d838954a624e9f36d7bb33dadb1dec5ac539c14" integrity sha512-k3/C2RtCRl8Pb3McaQkUiTxH7gs7U7agSqK6J7xdZSJZIO46qhz2zu6USco9eGAg67Ytz3VAmSI8sHQEi1f3fA== @@ -2091,6 +2102,11 @@ define-properties@^1.1.3, define-properties@^1.2.0, define-properties@^1.2.1: has-property-descriptors "^1.0.0" object-keys "^1.1.1" +dexie@^3.2.4: + version "3.2.4" + resolved "https://registry.yarnpkg.com/dexie/-/dexie-3.2.4.tgz#b22a9729be1102acb2eee16102ea6e2bc76454cf" + integrity sha512-VKoTQRSv7+RnffpOJ3Dh6ozknBqzWw/F3iqMdsZg958R0AS8AnY9x9d1lbwENr0gzeGJHXKcGhAMRaqys6SxqA== + didyoumean@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037" @@ -3178,7 +3194,7 @@ normalize-range@^0.1.2: resolved "https://registry.yarnpkg.com/normalize-range/-/normalize-range-0.1.2.tgz#2d10c06bdfd312ea9777695a4d28439456b75942" integrity sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA== -nostr-tools@1.17.0, nostr-tools@^1.15.0, nostr-tools@^1.17.0: +nostr-tools@1.17.0, nostr-tools@^1.14.0, nostr-tools@^1.15.0, nostr-tools@^1.17.0: version "1.17.0" resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.17.0.tgz#b6f62e32fedfd9e68ec0a7ce57f74c44fc768e8c" integrity sha512-LZmR8GEWKZeElbFV5Xte75dOeE9EFUW/QLI1Ncn3JKn0kFddDKEfBbFN8Mu4TMs+L4HR/WTPha2l+PPuRnJcMw== From 8f1384fef77683fdf90c1ae4b165dfe418e5e1fa Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Mon, 15 Jan 2024 10:24:52 +0330 Subject: [PATCH 03/16] add prettier config file --- .prettierrc.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..9d7b2b3 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,14 @@ +{ + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "useTabs": false, + "endOfLine": "lf", + "printWidth": 100, + "trailingComma": "es5", + "singleAttributePerLine": false, + "jsxSingleQuote": false, + "arrowParens": "always", + "bracketSameLine": false, + "bracketSpacing": true +} From 8cec17571dfc6ba961613b8eba4b1258e172d8cd Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Mon, 15 Jan 2024 10:26:03 +0330 Subject: [PATCH 04/16] move relays from constants to store --- src/constants.ts | 10 ++++------ src/state/store.ts | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index a72d0b4..89d1c64 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,13 +1,11 @@ export const localStorageKeys = { - nwcUrl: "pos:nwcUrl", + nwcUrl: 'pos:nwcUrl', }; -// TODO: allow dynamic list of relays -export const RELAYS = ["wss://relay.damus.io", "wss://relay.shitforce.one"]; -export const appCustomDataTag = "buzzpay"; +export const appCustomDataTag = 'buzzpay'; export const appCustomDataValues = { - profilePubkey: "profilePubkey", - item: "item", + profilePubkey: 'profilePubkey', + item: 'item', }; // https://bitcoin.stackexchange.com/questions/85951/whats-the-maximum-size-of-the-memo-in-a-ln-payment-request diff --git a/src/state/store.ts b/src/state/store.ts index 3fa519a..17f86ec 100644 --- a/src/state/store.ts +++ b/src/state/store.ts @@ -1,28 +1,34 @@ -import { webln } from "@getalby/sdk"; -import { create } from "zustand"; -import { CartItem, Item } from "../types"; +import { webln } from '@getalby/sdk'; +import { create } from 'zustand'; -interface Store { +import { CartItem, Item } from '../types'; + +interface State { readonly provider: webln.NostrWebLNProvider | undefined; readonly cart: CartItem[]; + relays: string[]; +} +interface Actions { setProvider(provider: webln.NostrWebLNProvider | undefined): void; addItemToCart(item: Item): void; removeItemFromCart(item: Item): void; clearCart(): void; + addRelay(relay: string): void; + removeRelay(relay: string): void; } -const useStore = create((set, get) => ({ +const useStore = create((set, get) => ({ provider: undefined, cart: [], + relays: ['wss://relay.damus.io', 'wss://relay.shitforce.one'], + setProvider: (provider) => { set({ provider }); }, addItemToCart: (item) => { const currentCart = get().cart; - const existingItem = currentCart.find( - (existing) => existing.name === item.name - ); + const existingItem = currentCart.find((existing) => existing.name === item.name); if (existingItem) { const existingItemIndex = currentCart.indexOf(existingItem); set({ @@ -40,9 +46,7 @@ const useStore = create((set, get) => ({ }, removeItemFromCart: (item) => { const currentCart = get().cart; - const existingItem = currentCart.find( - (existing) => existing.name === item.name - ); + const existingItem = currentCart.find((existing) => existing.name === item.name); if (!existingItem) { return; } @@ -66,6 +70,22 @@ const useStore = create((set, get) => ({ cart: [], }); }, + addRelay: (relay) => { + const relays = get().relays; + + if (relays.includes(relay)) { + return; + } + + set({ + relays: [...relays, relay], + }); + }, + removeRelay: (relay) => { + set({ + relays: get().relays.filter((r) => r != relay), + }); + }, })); export default useStore; From 9230124fb755986a36c23fd6a603bc28613f9743 Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Mon, 15 Jan 2024 10:28:09 +0330 Subject: [PATCH 05/16] install prettier --- .prettierrc.json | 24 ++++++++++++------------ package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 9d7b2b3..20e697e 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,14 +1,14 @@ { - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "useTabs": false, - "endOfLine": "lf", - "printWidth": 100, - "trailingComma": "es5", - "singleAttributePerLine": false, - "jsxSingleQuote": false, - "arrowParens": "always", - "bracketSameLine": false, - "bracketSpacing": true + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "useTabs": false, + "endOfLine": "lf", + "printWidth": 100, + "trailingComma": "es5", + "singleAttributePerLine": false, + "jsxSingleQuote": false, + "arrowParens": "always", + "bracketSameLine": false, + "bracketSpacing": true } diff --git a/package.json b/package.json index eace4c4..26460cf 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.5", "postcss": "^8.4.32", + "prettier": "3.2.2", "tailwindcss": "^3.3.6", "typescript": "^5.2.2", "vite": "^5.0.10", diff --git a/yarn.lock b/yarn.lock index 1ca8790..274ccf0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3379,6 +3379,11 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier@3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.2.tgz#96e580f7ca9c96090ad054616c0c4597e2844b65" + integrity sha512-HTByuKZzw7utPiDO523Tt2pLtEyK7OibUD9suEJQrPUCYQqrHr74GGX6VidMrovbf/I50mPqr8j/II6oBAuc5A== + pretty-bytes@^5.3.0: version "5.6.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb" From 6faad557a72702fe249a55a04219fa2f2086b8fd Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Mon, 15 Jan 2024 10:29:53 +0330 Subject: [PATCH 06/16] format all files with prettier --- .eslintrc.cjs | 7 ++--- .github/workflows/pages.yml | 8 ++--- .prettierignore | 3 ++ index.html | 2 +- postcss.config.js | 2 +- src/App.tsx | 22 +++++++------- src/components/Backbar.tsx | 6 ++-- src/components/Footer.tsx | 2 +- src/components/Navbar.tsx | 19 +++++------- src/components/icons/AlbyLogo.tsx | 37 ++++------------------- src/hooks/useItems.ts | 13 ++++---- src/hooks/useProfileMetadata.ts | 4 +-- src/hooks/useProfilePubkey.ts | 12 ++++---- src/index.css | 2 +- src/main.tsx | 12 ++++---- src/pages/About.tsx | 30 ++++++------------- src/pages/Home.tsx | 49 ++++++++++++------------------- src/pages/Wallet.tsx | 16 +++++----- src/pages/wallet/Items.tsx | 35 ++++++++++------------ src/pages/wallet/New.tsx | 36 +++++++++++------------ src/pages/wallet/Paid.tsx | 4 +-- src/pages/wallet/Pay.tsx | 28 ++++++++---------- src/pages/wallet/Profile.tsx | 30 +++++++++---------- src/pages/wallet/Share.tsx | 10 +++---- tailwind.config.js | 10 +++---- vite.config.ts | 30 +++++++++---------- 26 files changed, 181 insertions(+), 248 deletions(-) create mode 100644 .prettierignore diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d6c9537..b1e978d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -10,9 +10,6 @@ module.exports = { parser: '@typescript-eslint/parser', plugins: ['react-refresh'], rules: { - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, - ], + 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }], }, -} +}; diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index db13d55..2b5116c 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -4,7 +4,7 @@ name: Deploy static content to Pages on: # Runs on pushes targeting the default branch push: - branches: ["master", "feat/restore-wallet-from-start-url"] + branches: ['master', 'feat/restore-wallet-from-start-url'] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -17,7 +17,7 @@ permissions: # Allow one concurrent deployment concurrency: - group: "pages" + group: 'pages' cancel-in-progress: true jobs: @@ -34,7 +34,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 - cache: "yarn" + cache: 'yarn' - name: Install dependencies run: yarn install - name: Build @@ -45,7 +45,7 @@ jobs: uses: actions/upload-pages-artifact@v2 with: # Upload dist repository - path: "./dist" + path: './dist' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1b07c39 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage \ No newline at end of file diff --git a/index.html b/index.html index abc796b..2807b2c 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + diff --git a/postcss.config.js b/postcss.config.js index 2e7af2b..2aa7205 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -3,4 +3,4 @@ export default { tailwindcss: {}, autoprefixer: {}, }, -} +}; diff --git a/src/App.tsx b/src/App.tsx index daba202..bd378bc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,14 +1,14 @@ -import { HashRouter, Route, Routes } from "react-router-dom"; -import { Home } from "./pages/Home"; -import { Wallet } from "./pages/Wallet"; -import { NotFound } from "./pages/NotFound"; -import { New } from "./pages/wallet/New"; -import { Pay } from "./pages/wallet/Pay"; -import { Paid } from "./pages/wallet/Paid"; -import { Share } from "./pages/wallet/Share"; -import { About } from "./pages/About"; -import { Profile } from "./pages/wallet/Profile"; -import { Items } from "./pages/wallet/Items"; +import { HashRouter, Route, Routes } from 'react-router-dom'; +import { Home } from './pages/Home'; +import { Wallet } from './pages/Wallet'; +import { NotFound } from './pages/NotFound'; +import { New } from './pages/wallet/New'; +import { Pay } from './pages/wallet/Pay'; +import { Paid } from './pages/wallet/Paid'; +import { Share } from './pages/wallet/Share'; +import { About } from './pages/About'; +import { Profile } from './pages/wallet/Profile'; +import { Items } from './pages/wallet/Items'; function App() { return ( diff --git a/src/components/Backbar.tsx b/src/components/Backbar.tsx index c882cfd..e7983ac 100644 --- a/src/components/Backbar.tsx +++ b/src/components/Backbar.tsx @@ -1,5 +1,5 @@ -import { PopiconsArrowLeftDuotone } from "@popicons/react"; -import { To, useNavigate } from "react-router-dom"; +import { PopiconsArrowLeftDuotone } from '@popicons/react'; +import { To, useNavigate } from 'react-router-dom'; type BackbarProps = { navigateTo?: string | -1; @@ -12,7 +12,7 @@ export function Backbar({ navigateTo }: BackbarProps) {
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 8795f24..618a873 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,4 +1,4 @@ -import { AlbyLogo } from "../components/icons/AlbyLogo"; +import { AlbyLogo } from '../components/icons/AlbyLogo'; export function Footer() { return ( diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index e97d540..745556b 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,5 +1,5 @@ -import { Link } from "react-router-dom"; -import { BuzzPay } from "./icons/BuzzPay"; +import { Link } from 'react-router-dom'; +import { BuzzPay } from './icons/BuzzPay'; import { PopiconsCartDuotone, PopiconsShareDuotone, @@ -7,9 +7,9 @@ import { PopiconsLogoutDuotone, PopiconsBulbDuotone, PopiconsFaceSmileDuotone, -} from "@popicons/react"; -import { localStorageKeys } from "../constants"; -import useStore from "../state/store"; +} from '@popicons/react'; +import { localStorageKeys } from '../constants'; +import useStore from '../state/store'; type NavbarProps = { onOpenCart?: () => void; @@ -35,8 +35,7 @@ export function Navbar({ onOpenCart }: NavbarProps) {
  • - Share with a - co-worker + Share with a co-worker
  • @@ -53,11 +52,7 @@ export function Navbar({ onOpenCart }: NavbarProps) { { - if ( - !confirm( - "Are you sure you wish to log out? your wallet will be lost." - ) - ) { + if (!confirm('Are you sure you wish to log out? your wallet will be lost.')) { e.preventDefault(); return; } diff --git a/src/components/icons/AlbyLogo.tsx b/src/components/icons/AlbyLogo.tsx index 06a6e9e..1234f11 100644 --- a/src/components/icons/AlbyLogo.tsx +++ b/src/components/icons/AlbyLogo.tsx @@ -12,14 +12,7 @@ export function AlbyLogo({ className }: Props) { xmlns="http://www.w3.org/2000/svg" className={className} > - + - + - + - - + + - event.tags.some( - (t) => - t[0] === appCustomDataTag && t[1] === appCustomDataValues.item - ) + event.tags.some((t) => t[0] === appCustomDataTag && t[1] === appCustomDataValues.item) ) .map((event) => JSON.parse(event.content) as Item), [events] diff --git a/src/hooks/useProfileMetadata.ts b/src/hooks/useProfileMetadata.ts index c0df18c..21fdf36 100644 --- a/src/hooks/useProfileMetadata.ts +++ b/src/hooks/useProfileMetadata.ts @@ -1,5 +1,5 @@ -import { useSubscribe } from "nostr-hooks"; -import { RELAYS } from "../constants"; +import { useSubscribe } from 'nostr-hooks'; +import { RELAYS } from '../constants'; export function useProfileMetadata(profilePubkeyHex: string | undefined) { // console.log("Profile pubkey hex:", profilePubkeyHex); diff --git a/src/hooks/useProfilePubkey.ts b/src/hooks/useProfilePubkey.ts index 309c856..02e1c11 100644 --- a/src/hooks/useProfilePubkey.ts +++ b/src/hooks/useProfilePubkey.ts @@ -1,7 +1,7 @@ -import { useSubscribe } from "nostr-hooks"; -import React from "react"; -import { RELAYS, appCustomDataTag, appCustomDataValues } from "../constants"; -import { nip19 } from "nostr-tools"; +import { useSubscribe } from 'nostr-hooks'; +import React from 'react'; +import { RELAYS, appCustomDataTag, appCustomDataValues } from '../constants'; +import { nip19 } from 'nostr-tools'; export function useProfilePubkey(walletPubkey?: string) { const { events, invalidate, eose } = useSubscribe({ @@ -27,9 +27,7 @@ export function useProfilePubkey(walletPubkey?: string) { // TODO: remove filter when above relay filter works events.filter((event) => event.tags.some( - (t) => - t[0] === appCustomDataTag && - t[1] === appCustomDataValues.profilePubkey + (t) => t[0] === appCustomDataTag && t[1] === appCustomDataValues.profilePubkey ) )[0]?.content, [events] diff --git a/src/index.css b/src/index.css index d8e32a3..0cf3d35 100644 --- a/src/index.css +++ b/src/index.css @@ -1,4 +1,4 @@ -@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"); +@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap'); @tailwind base; @tailwind components; diff --git a/src/main.tsx b/src/main.tsx index 3d7150d..93db379 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,10 +1,10 @@ -import React from 'react' -import ReactDOM from 'react-dom/client' -import App from './App.tsx' -import './index.css' +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import App from './App.tsx'; +import './index.css'; ReactDOM.createRoot(document.getElementById('root')!).render( - , -) + +); diff --git a/src/pages/About.tsx b/src/pages/About.tsx index 4f3b56b..9f2611d 100644 --- a/src/pages/About.tsx +++ b/src/pages/About.tsx @@ -1,5 +1,5 @@ -import { Backbar } from "../components/Backbar"; -import { Footer } from "../components/Footer"; +import { Backbar } from '../components/Backbar'; +import { Footer } from '../components/Footer'; export function About() { return ( @@ -8,27 +8,15 @@ export function About() {

    About

    - BuzzPay is a simple PoS powered by Nostr Wallet Connect. It has only - limited access to your wallet: It can receive payments but not send - them. Once you've connected your wallet can easily share your PoS link - with your co-workers. + BuzzPay is a simple PoS powered by Nostr Wallet Connect. It has only limited access to + your wallet: It can receive payments but not send them. Once you've connected your wallet + can easily share your PoS link with your co-workers.

    +

    BuzzPay also works great as a PWA. Try it out by saving it to your homescreen!

    +

    After connecting to your wallet, bookmark the page to make sure you don't lose it.

    - BuzzPay also works great as a PWA. Try it out by saving it to your - homescreen! -

    -

    - After connecting to your wallet, bookmark the page to make sure you - don't lose it. -

    -

    - Do you have any feature requests, issues or would like to - contribute?  - + Do you have any feature requests, issues or would like to contribute?  + visit BuzzPay on Github . diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 95154f3..c7b3016 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -4,29 +4,29 @@ import { disconnect, init, WebLNProviders, -} from "@getalby/bitcoin-connect-react"; -import React from "react"; -import { useNavigate } from "react-router-dom"; -import { BuzzPay } from "../components/icons/BuzzPay"; -import { localStorageKeys } from "../constants"; -import { Footer } from "../components/Footer"; +} from '@getalby/bitcoin-connect-react'; +import React from 'react'; +import { useNavigate } from 'react-router-dom'; +import { BuzzPay } from '../components/icons/BuzzPay'; +import { localStorageKeys } from '../constants'; +import { Footer } from '../components/Footer'; export function Home() { const navigate = useNavigate(); React.useEffect(() => { const nwcUrl = window.localStorage.getItem(localStorageKeys.nwcUrl); if (nwcUrl) { - console.log("Restoring wallet URL", nwcUrl); + console.log('Restoring wallet URL', nwcUrl); navigate(`/wallet/${encodeURIComponent(nwcUrl)}/new`); } init({ - filters: ["nwc"], + filters: ['nwc'], showBalance: false, providerConfig: { nwc: { authorizationUrlOptions: { - requestMethods: ["get_info", "make_invoice", "lookup_invoice"], + requestMethods: ['get_info', 'make_invoice', 'lookup_invoice'], }, }, }, @@ -40,46 +40,35 @@ export function Home() {

    -

    - Point-of-Sale for bitcoin lightning payments -

    +

    Point-of-Sale for bitcoin lightning payments

    @@ -92,7 +81,7 @@ export function Home() { // Needed on iOS because PWA localStorage is not shared with Safari. // PWA can only be installed with a static URL (e.g. "/pos/"). function importWallet() { - const url = prompt("Copy wallet URL from your browser"); + const url = prompt('Copy wallet URL from your browser'); if (url) { window.location.href = url; } diff --git a/src/pages/Wallet.tsx b/src/pages/Wallet.tsx index 15f8518..aba5daa 100644 --- a/src/pages/Wallet.tsx +++ b/src/pages/Wallet.tsx @@ -1,8 +1,8 @@ -import { webln } from "@getalby/sdk"; -import React from "react"; -import { Outlet, useNavigate, useParams } from "react-router-dom"; -import { localStorageKeys } from "../constants"; -import useStore from "../state/store"; +import { webln } from '@getalby/sdk'; +import React from 'react'; +import { Outlet, useNavigate, useParams } from 'react-router-dom'; +import { localStorageKeys } from '../constants'; +import useStore from '../state/store'; export function Wallet() { const { nwcUrl } = useParams(); @@ -13,7 +13,7 @@ export function Wallet() { (async () => { if (nwcUrl) { try { - console.log("Enabling provider"); + console.log('Enabling provider'); const _provider = new webln.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl, }); @@ -25,14 +25,14 @@ export function Wallet() { window.localStorage.setItem(localStorageKeys.nwcUrl, nwcUrl); } catch (error) { console.error(error); - alert("Failed to load wallet: " + error); + alert('Failed to load wallet: ' + error); } } })(); }, [nwcUrl]); if (!nwcUrl) { - navigate("/"); + navigate('/'); return null; } diff --git a/src/pages/wallet/Items.tsx b/src/pages/wallet/Items.tsx index e9b6bff..48301d9 100644 --- a/src/pages/wallet/Items.tsx +++ b/src/pages/wallet/Items.tsx @@ -1,15 +1,15 @@ -import React, { FormEvent } from "react"; -import { Backbar } from "../../components/Backbar"; -import { usePublish } from "nostr-hooks"; -import { RELAYS, appCustomDataTag, appCustomDataValues } from "../../constants"; -import { useItems } from "../../hooks/useItems"; -import { Item } from "../../types"; -import useStore from "../../state/store"; +import React, { FormEvent } from 'react'; +import { Backbar } from '../../components/Backbar'; +import { usePublish } from 'nostr-hooks'; +import { RELAYS, appCustomDataTag, appCustomDataValues } from '../../constants'; +import { useItems } from '../../hooks/useItems'; +import { Item } from '../../types'; +import useStore from '../../state/store'; export function Items() { const { cart, addItemToCart, removeItemFromCart, clearCart } = useStore(); - const [itemName, setItemName] = React.useState(""); - const [itemPrice, setItemPrice] = React.useState(""); + const [itemName, setItemName] = React.useState(''); + const [itemPrice, setItemPrice] = React.useState(''); const [isSaving, setSaving] = React.useState(false); const provider = useStore((store) => store.provider); const publish = usePublish(RELAYS, provider?.secret); @@ -31,21 +31,21 @@ export function Items() { }; if (isNaN(item.price) || item.price < 1) { - throw new Error("Invalid item price"); + throw new Error('Invalid item price'); } const result = await publish({ kind: 30078, content: JSON.stringify(item), tags: [ [appCustomDataTag, appCustomDataValues.item], - ["d", "BuzzPay item - " + item.name], + ['d', 'BuzzPay item - ' + item.name], ], }); - console.log("Published", result); + console.log('Published', result); itemsData.invalidate(); } catch (error) { console.error(error); - alert("Failed to update profile: " + error); + alert('Failed to update profile: ' + error); } finally { setSaving(false); } @@ -57,10 +57,7 @@ export function Items() {

    Cart

    {cart.map((item) => ( -
    +

    {item.name} - {item.price} sats ({item.quantity})

    @@ -102,9 +99,7 @@ export function Items() { className="btn btn-primary" > {item.name} - {item.price} sats ( - {cart.find((cartItem) => cartItem.name === item.name)?.quantity || - 0} - ) + {cart.find((cartItem) => cartItem.name === item.name)?.quantity || 0}) ))} diff --git a/src/pages/wallet/New.tsx b/src/pages/wallet/New.tsx index 810f3cc..d2918c6 100644 --- a/src/pages/wallet/New.tsx +++ b/src/pages/wallet/New.tsx @@ -1,12 +1,12 @@ -import React, { FormEvent } from "react"; -import { useNavigate } from "react-router-dom"; -import { Navbar } from "../../components/Navbar"; -import useStore from "../../state/store"; -import { MAX_MEMO_LENGTH } from "../../constants"; +import React, { FormEvent } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { Navbar } from '../../components/Navbar'; +import useStore from '../../state/store'; +import { MAX_MEMO_LENGTH } from '../../constants'; export function New() { - const [amount, setAmount] = React.useState(""); - const [label, setLabel] = React.useState(""); + const [amount, setAmount] = React.useState(''); + const [label, setLabel] = React.useState(''); const { cart, addItemToCart } = useStore(); const [isLoading, setLoading] = React.useState(false); const navigate = useNavigate(); @@ -15,7 +15,7 @@ export function New() { function convertCurrentEntryToCartItem() { if (amount) { const findFreeLabel = () => { - const labelPrefix = "Item "; + const labelPrefix = 'Item '; let index = 0; let freeLabel: string; do { @@ -40,15 +40,15 @@ export function New() { const finalCart = useStore.getState().cart; if (!finalCart.length) { - throw new Error("Empty cart"); + throw new Error('Empty cart'); } - let memo = ""; + let memo = ''; // TODO: group cart items - memo += finalCart.map((item) => item.name).join(", "); - memo += " - "; + memo += finalCart.map((item) => item.name).join(', '); + memo += ' - '; - memo += "BuzzPay"; + memo += 'BuzzPay'; const totalAmount = finalCart .map((cart) => cart.price * cart.quantity) @@ -61,7 +61,7 @@ export function New() { navigate(`../pay/${invoice.paymentRequest}`); } catch (error) { console.error(error); - alert("Failed to create invoice: " + error); + alert('Failed to create invoice: ' + error); setLoading(false); } } @@ -90,13 +90,13 @@ export function New() {
    diff --git a/src/pages/wallet/Paid.tsx b/src/pages/wallet/Paid.tsx index ec368ac..7a16f3e 100644 --- a/src/pages/wallet/Paid.tsx +++ b/src/pages/wallet/Paid.tsx @@ -1,5 +1,5 @@ -import { PopiconsCircleCheckDuotone } from "@popicons/react"; -import { Link } from "react-router-dom"; +import { PopiconsCircleCheckDuotone } from '@popicons/react'; +import { Link } from 'react-router-dom'; export function Paid() { return ( diff --git a/src/pages/wallet/Pay.tsx b/src/pages/wallet/Pay.tsx index 6f8befd..4b885c1 100644 --- a/src/pages/wallet/Pay.tsx +++ b/src/pages/wallet/Pay.tsx @@ -1,11 +1,11 @@ -import { Invoice } from "@getalby/lightning-tools"; -import { QRCodeSVG } from "qrcode.react"; -import { useEffect, useState } from "react"; -import { useNavigate, useParams } from "react-router-dom"; -import { Backbar } from "../../components/Backbar"; -import { useProfileMetadata } from "../../hooks/useProfileMetadata"; -import { useProfilePubkey } from "../../hooks/useProfilePubkey"; -import useStore from "../../state/store"; +import { Invoice } from '@getalby/lightning-tools'; +import { QRCodeSVG } from 'qrcode.react'; +import { useEffect, useState } from 'react'; +import { useNavigate, useParams } from 'react-router-dom'; +import { Backbar } from '../../components/Backbar'; +import { useProfileMetadata } from '../../hooks/useProfileMetadata'; +import { useProfilePubkey } from '../../hooks/useProfilePubkey'; +import useStore from '../../state/store'; export function Pay() { const { clearCart } = useStore(); @@ -26,13 +26,13 @@ export function Pay() { setAmount(satoshi); const interval = setInterval(async () => { - console.log("Checking invoice", invoice); + console.log('Checking invoice', invoice); const response = await provider.lookupInvoice({ paymentRequest: invoice, }); if (response.paid) { useStore.getState().clearCart(); - navigate("../paid"); + navigate('../paid'); } }, 3000); return () => { @@ -50,12 +50,10 @@ export function Pay() {
    {amount} sats - {metadata?.name && ( - to {metadata?.name} - )} + {metadata?.name && to {metadata?.name}} {cart && ( // TODO: group cart items -

    {cart.map((item) => item.name).join(", ")}

    +

    {cart.map((item) => item.name).join(', ')}

    )}
    @@ -73,7 +71,7 @@ export function Pay() { diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 618a873..8795f24 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,4 +1,4 @@ -import { AlbyLogo } from '../components/icons/AlbyLogo'; +import { AlbyLogo } from "../components/icons/AlbyLogo"; export function Footer() { return ( diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 745556b..c2181d8 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,5 +1,5 @@ -import { Link } from 'react-router-dom'; -import { BuzzPay } from './icons/BuzzPay'; +import { Link } from "react-router-dom"; +import { BuzzPay } from "./icons/BuzzPay"; import { PopiconsCartDuotone, PopiconsShareDuotone, @@ -7,9 +7,9 @@ import { PopiconsLogoutDuotone, PopiconsBulbDuotone, PopiconsFaceSmileDuotone, -} from '@popicons/react'; -import { localStorageKeys } from '../constants'; -import useStore from '../state/store'; +} from "@popicons/react"; +import { localStorageKeys } from "../constants"; +import useStore from "../state/store"; type NavbarProps = { onOpenCart?: () => void; @@ -52,7 +52,7 @@ export function Navbar({ onOpenCart }: NavbarProps) { { - if (!confirm('Are you sure you wish to log out? your wallet will be lost.')) { + if (!confirm("Are you sure you wish to log out? your wallet will be lost.")) { e.preventDefault(); return; } diff --git a/src/constants.ts b/src/constants.ts index 89d1c64..6a26bb8 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,11 +1,11 @@ export const localStorageKeys = { - nwcUrl: 'pos:nwcUrl', + nwcUrl: "pos:nwcUrl", }; -export const appCustomDataTag = 'buzzpay'; +export const appCustomDataTag = "buzzpay"; export const appCustomDataValues = { - profilePubkey: 'profilePubkey', - item: 'item', + profilePubkey: "profilePubkey", + item: "item", }; // https://bitcoin.stackexchange.com/questions/85951/whats-the-maximum-size-of-the-memo-in-a-ln-payment-request diff --git a/src/hooks/useItems.ts b/src/hooks/useItems.ts index 187fe7d..fb6363c 100644 --- a/src/hooks/useItems.ts +++ b/src/hooks/useItems.ts @@ -1,9 +1,9 @@ -import { NDKEvent, NDKFilter } from '@nostr-dev-kit/ndk'; -import { useEffect, useMemo, useState } from 'react'; +import { NDKEvent, NDKFilter } from "@nostr-dev-kit/ndk"; +import { useEffect, useMemo, useState } from "react"; -import { appCustomDataTag, appCustomDataValues } from '../constants'; -import useStore from '../state/store'; -import { Item } from '../types'; +import { appCustomDataTag, appCustomDataValues } from "../constants"; +import useStore from "../state/store"; +import { Item } from "../types"; export function useItems() { const [events, setEvents] = useState([]); @@ -31,7 +31,7 @@ export function useItems() { const subscription = ndk.subscribe(filters); - subscription.on('event', (event) => { + subscription.on("event", (event) => { setEvents((prevEvents) => prevEvents.some((existingEvent) => existingEvent.id === event.id) ? prevEvents @@ -39,7 +39,7 @@ export function useItems() { ); }); - subscription.on('eose', () => { + subscription.on("eose", () => { setEose(true); }); }, [ndk, walletPubkey, setEvents]); diff --git a/src/hooks/useProfileMetadata.ts b/src/hooks/useProfileMetadata.ts index 73cba74..58bcdc7 100644 --- a/src/hooks/useProfileMetadata.ts +++ b/src/hooks/useProfileMetadata.ts @@ -1,7 +1,7 @@ -import { NDKUserProfile } from '@nostr-dev-kit/ndk'; -import { useEffect, useState } from 'react'; +import { NDKUserProfile } from "@nostr-dev-kit/ndk"; +import { useEffect, useState } from "react"; -import useStore from '../state/store'; +import useStore from "../state/store"; export function useProfileMetadata(pubkey: string | undefined) { const [metadata, setMetadata] = useState(undefined); diff --git a/src/hooks/useProfilePubkey.ts b/src/hooks/useProfilePubkey.ts index e6047ef..bc4f54f 100644 --- a/src/hooks/useProfilePubkey.ts +++ b/src/hooks/useProfilePubkey.ts @@ -1,9 +1,9 @@ -import { NDKEvent, NDKFilter } from '@nostr-dev-kit/ndk'; -import { nip19 } from 'nostr-tools'; -import { useEffect, useMemo, useState } from 'react'; +import { NDKEvent, NDKFilter } from "@nostr-dev-kit/ndk"; +import { nip19 } from "nostr-tools"; +import { useEffect, useMemo, useState } from "react"; -import { appCustomDataTag, appCustomDataValues } from '../constants'; -import useStore from '../state/store'; +import { appCustomDataTag, appCustomDataValues } from "../constants"; +import useStore from "../state/store"; export function useProfilePubkey() { const [events, setEvents] = useState([]); @@ -31,7 +31,7 @@ export function useProfilePubkey() { const subscription = ndk.subscribe(filters); - subscription.on('event', (event: NDKEvent) => { + subscription.on("event", (event: NDKEvent) => { setEvents((prevEvents) => prevEvents.some((existingEvent) => existingEvent.id === event.id) ? prevEvents @@ -39,7 +39,7 @@ export function useProfilePubkey() { ); }); - subscription.on('eose', () => { + subscription.on("eose", () => { setEose(true); }); }, [ndk, walletPubkey, setEvents]); diff --git a/src/index.css b/src/index.css index 0cf3d35..d8e32a3 100644 --- a/src/index.css +++ b/src/index.css @@ -1,4 +1,4 @@ -@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap'); +@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap"); @tailwind base; @tailwind components; diff --git a/src/main.tsx b/src/main.tsx index 93db379..966f17a 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,9 +1,9 @@ -import React from 'react'; -import ReactDOM from 'react-dom/client'; -import App from './App.tsx'; -import './index.css'; +import React from "react"; +import ReactDOM from "react-dom/client"; +import App from "./App.tsx"; +import "./index.css"; -ReactDOM.createRoot(document.getElementById('root')!).render( +ReactDOM.createRoot(document.getElementById("root")!).render( diff --git a/src/pages/About.tsx b/src/pages/About.tsx index 9f2611d..585a4e3 100644 --- a/src/pages/About.tsx +++ b/src/pages/About.tsx @@ -1,5 +1,5 @@ -import { Backbar } from '../components/Backbar'; -import { Footer } from '../components/Footer'; +import { Backbar } from "../components/Backbar"; +import { Footer } from "../components/Footer"; export function About() { return ( diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index c7b3016..07be7df 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -4,29 +4,29 @@ import { disconnect, init, WebLNProviders, -} from '@getalby/bitcoin-connect-react'; -import React from 'react'; -import { useNavigate } from 'react-router-dom'; -import { BuzzPay } from '../components/icons/BuzzPay'; -import { localStorageKeys } from '../constants'; -import { Footer } from '../components/Footer'; +} from "@getalby/bitcoin-connect-react"; +import React from "react"; +import { useNavigate } from "react-router-dom"; +import { BuzzPay } from "../components/icons/BuzzPay"; +import { localStorageKeys } from "../constants"; +import { Footer } from "../components/Footer"; export function Home() { const navigate = useNavigate(); React.useEffect(() => { const nwcUrl = window.localStorage.getItem(localStorageKeys.nwcUrl); if (nwcUrl) { - console.log('Restoring wallet URL', nwcUrl); + console.log("Restoring wallet URL", nwcUrl); navigate(`/wallet/${encodeURIComponent(nwcUrl)}/new`); } init({ - filters: ['nwc'], + filters: ["nwc"], showBalance: false, providerConfig: { nwc: { authorizationUrlOptions: { - requestMethods: ['get_info', 'make_invoice', 'lookup_invoice'], + requestMethods: ["get_info", "make_invoice", "lookup_invoice"], }, }, }, @@ -47,17 +47,17 @@ export function Home() { const info = await provider.getInfo(); if ( info.methods.length > 3 || - info.methods.indexOf('makeInvoice') < 0 || - info.methods.indexOf('lookupInvoice') < 0 || - info.methods.indexOf('getInfo') < 0 + info.methods.indexOf("makeInvoice") < 0 || + info.methods.indexOf("lookupInvoice") < 0 || + info.methods.indexOf("getInfo") < 0 ) { throw new Error( - 'This provider must support exactly NWC getInfo, makeInvoice and lookupInvoice. Supports: ' + - info.methods.join(',') + "This provider must support exactly NWC getInfo, makeInvoice and lookupInvoice. Supports: " + + info.methods.join(",") ); } if (!(provider instanceof WebLNProviders.NostrWebLNProvider)) { - throw new Error('WebLN provider is not an instance of NostrWebLNProvider'); + throw new Error("WebLN provider is not an instance of NostrWebLNProvider"); } // TODO: below line should not be needed when modal is updated to close automatically after connecting closeModal(); @@ -81,7 +81,7 @@ export function Home() { // Needed on iOS because PWA localStorage is not shared with Safari. // PWA can only be installed with a static URL (e.g. "/pos/"). function importWallet() { - const url = prompt('Copy wallet URL from your browser'); + const url = prompt("Copy wallet URL from your browser"); if (url) { window.location.href = url; } diff --git a/src/pages/Wallet.tsx b/src/pages/Wallet.tsx index aba5daa..15f8518 100644 --- a/src/pages/Wallet.tsx +++ b/src/pages/Wallet.tsx @@ -1,8 +1,8 @@ -import { webln } from '@getalby/sdk'; -import React from 'react'; -import { Outlet, useNavigate, useParams } from 'react-router-dom'; -import { localStorageKeys } from '../constants'; -import useStore from '../state/store'; +import { webln } from "@getalby/sdk"; +import React from "react"; +import { Outlet, useNavigate, useParams } from "react-router-dom"; +import { localStorageKeys } from "../constants"; +import useStore from "../state/store"; export function Wallet() { const { nwcUrl } = useParams(); @@ -13,7 +13,7 @@ export function Wallet() { (async () => { if (nwcUrl) { try { - console.log('Enabling provider'); + console.log("Enabling provider"); const _provider = new webln.NostrWebLNProvider({ nostrWalletConnectUrl: nwcUrl, }); @@ -25,14 +25,14 @@ export function Wallet() { window.localStorage.setItem(localStorageKeys.nwcUrl, nwcUrl); } catch (error) { console.error(error); - alert('Failed to load wallet: ' + error); + alert("Failed to load wallet: " + error); } } })(); }, [nwcUrl]); if (!nwcUrl) { - navigate('/'); + navigate("/"); return null; } diff --git a/src/pages/wallet/Items.tsx b/src/pages/wallet/Items.tsx index eef7cde..b80e54d 100644 --- a/src/pages/wallet/Items.tsx +++ b/src/pages/wallet/Items.tsx @@ -1,15 +1,15 @@ -import { NDKEvent } from '@nostr-dev-kit/ndk'; -import { FormEvent, useState } from 'react'; +import { NDKEvent } from "@nostr-dev-kit/ndk"; +import { FormEvent, useState } from "react"; -import { Backbar } from '../../components/Backbar'; -import { appCustomDataTag, appCustomDataValues } from '../../constants'; -import { useItems } from '../../hooks/useItems'; -import useStore from '../../state/store'; -import { Item } from '../../types'; +import { Backbar } from "../../components/Backbar"; +import { appCustomDataTag, appCustomDataValues } from "../../constants"; +import { useItems } from "../../hooks/useItems"; +import useStore from "../../state/store"; +import { Item } from "../../types"; export function Items() { - const [itemName, setItemName] = useState(''); - const [itemPrice, setItemPrice] = useState(''); + const [itemName, setItemName] = useState(""); + const [itemPrice, setItemPrice] = useState(""); const [isSaving, setSaving] = useState(false); const { cart, addItemToCart, removeItemFromCart, clearCart, ndk } = useStore(); @@ -31,7 +31,7 @@ export function Items() { }; if (isNaN(item.price) || item.price < 1) { - throw new Error('Invalid item price'); + throw new Error("Invalid item price"); } const event = new NDKEvent(ndk); @@ -40,15 +40,15 @@ export function Items() { event.content = JSON.stringify(item); event.tags = [ [appCustomDataTag, appCustomDataValues.item], - ['d', 'BuzzPay item - ' + item.name], + ["d", "BuzzPay item - " + item.name], ]; const publishedRelays = await event.publish(); - console.log('Published to relays', publishedRelays); + console.log("Published to relays", publishedRelays); } catch (error) { console.error(error); - alert('Failed to update profile: ' + error); + alert("Failed to update profile: " + error); } finally { setSaving(false); } diff --git a/src/pages/wallet/New.tsx b/src/pages/wallet/New.tsx index d2918c6..810f3cc 100644 --- a/src/pages/wallet/New.tsx +++ b/src/pages/wallet/New.tsx @@ -1,12 +1,12 @@ -import React, { FormEvent } from 'react'; -import { useNavigate } from 'react-router-dom'; -import { Navbar } from '../../components/Navbar'; -import useStore from '../../state/store'; -import { MAX_MEMO_LENGTH } from '../../constants'; +import React, { FormEvent } from "react"; +import { useNavigate } from "react-router-dom"; +import { Navbar } from "../../components/Navbar"; +import useStore from "../../state/store"; +import { MAX_MEMO_LENGTH } from "../../constants"; export function New() { - const [amount, setAmount] = React.useState(''); - const [label, setLabel] = React.useState(''); + const [amount, setAmount] = React.useState(""); + const [label, setLabel] = React.useState(""); const { cart, addItemToCart } = useStore(); const [isLoading, setLoading] = React.useState(false); const navigate = useNavigate(); @@ -15,7 +15,7 @@ export function New() { function convertCurrentEntryToCartItem() { if (amount) { const findFreeLabel = () => { - const labelPrefix = 'Item '; + const labelPrefix = "Item "; let index = 0; let freeLabel: string; do { @@ -40,15 +40,15 @@ export function New() { const finalCart = useStore.getState().cart; if (!finalCart.length) { - throw new Error('Empty cart'); + throw new Error("Empty cart"); } - let memo = ''; + let memo = ""; // TODO: group cart items - memo += finalCart.map((item) => item.name).join(', '); - memo += ' - '; + memo += finalCart.map((item) => item.name).join(", "); + memo += " - "; - memo += 'BuzzPay'; + memo += "BuzzPay"; const totalAmount = finalCart .map((cart) => cart.price * cart.quantity) @@ -61,7 +61,7 @@ export function New() { navigate(`../pay/${invoice.paymentRequest}`); } catch (error) { console.error(error); - alert('Failed to create invoice: ' + error); + alert("Failed to create invoice: " + error); setLoading(false); } } @@ -90,13 +90,13 @@ export function New() {
    diff --git a/src/pages/wallet/Paid.tsx b/src/pages/wallet/Paid.tsx index 7a16f3e..ec368ac 100644 --- a/src/pages/wallet/Paid.tsx +++ b/src/pages/wallet/Paid.tsx @@ -1,5 +1,5 @@ -import { PopiconsCircleCheckDuotone } from '@popicons/react'; -import { Link } from 'react-router-dom'; +import { PopiconsCircleCheckDuotone } from "@popicons/react"; +import { Link } from "react-router-dom"; export function Paid() { return ( diff --git a/src/pages/wallet/Pay.tsx b/src/pages/wallet/Pay.tsx index c189a55..c7c81fa 100644 --- a/src/pages/wallet/Pay.tsx +++ b/src/pages/wallet/Pay.tsx @@ -1,11 +1,11 @@ -import { Invoice } from '@getalby/lightning-tools'; -import { QRCodeSVG } from 'qrcode.react'; -import { useEffect, useState } from 'react'; -import { useNavigate, useParams } from 'react-router-dom'; -import { Backbar } from '../../components/Backbar'; -import { useProfileMetadata } from '../../hooks/useProfileMetadata'; -import { useProfilePubkey } from '../../hooks/useProfilePubkey'; -import useStore from '../../state/store'; +import { Invoice } from "@getalby/lightning-tools"; +import { QRCodeSVG } from "qrcode.react"; +import { useEffect, useState } from "react"; +import { useNavigate, useParams } from "react-router-dom"; +import { Backbar } from "../../components/Backbar"; +import { useProfileMetadata } from "../../hooks/useProfileMetadata"; +import { useProfilePubkey } from "../../hooks/useProfilePubkey"; +import useStore from "../../state/store"; export function Pay() { const [amount, setAmount] = useState(0); @@ -29,13 +29,13 @@ export function Pay() { setAmount(satoshi); const interval = setInterval(async () => { - console.log('Checking invoice', invoice); + console.log("Checking invoice", invoice); const response = await provider.lookupInvoice({ paymentRequest: invoice, }); if (response.paid) { useStore.getState().clearCart(); - navigate('../paid'); + navigate("../paid"); } }, 3000); return () => { @@ -56,7 +56,7 @@ export function Pay() { {metadata?.name && to {metadata?.name}} {cart && ( // TODO: group cart items -

    {cart.map((item) => item.name).join(', ')}

    +

    {cart.map((item) => item.name).join(", ")}

    )}
    @@ -74,7 +74,7 @@ export function Pay() {