From 8b30faf70f1e086245e98755cc9b47bcecf42c5f Mon Sep 17 00:00:00 2001 From: Alan-AC7 Date: Fri, 24 Nov 2023 15:41:12 -0600 Subject: [PATCH 1/7] added btc component on profile preferences --- package.json | 3 +- .../BitcoinConnect/BitcoinButton.tsx | 25 ++++ src/pages/setting/index.module.scss | 1 + src/pages/setting/preference.tsx | 15 ++- src/styles/global.scss | 11 ++ yarn.lock | 127 +++++++++++++++++- 6 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 src/components/BitcoinConnect/BitcoinButton.tsx diff --git a/package.json b/package.json index 8e32a3aa..03e8da77 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "@emoji-mart/react": "1.1.1", "@emotion/react": "11.10.0", "@emotion/styled": "11.10.0", + "@getalby/bitcoin-connect-react": "2.4.2", "@joyid/nostr": "0.1.0", "@noble/hashes": "1.1.5", "@noble/secp256k1": "1.7.0", @@ -112,7 +113,7 @@ }, "scripts": { "wasm:profile": "cd wasm && rustc --crate-type cdylib --target wasm32-unknown-unknown -C lto -C opt-level=z -o profile.wasm examples/profile.rs", - "dev": "REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD) next dev", + "dev": "set \"REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD)\" && next dev", "build:wasm": "cd wasm && wasm-pack build --target web --release && cd ..", "build": "REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD) next build", "start": "REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD) next start", diff --git a/src/components/BitcoinConnect/BitcoinButton.tsx b/src/components/BitcoinConnect/BitcoinButton.tsx new file mode 100644 index 00000000..ca4f161f --- /dev/null +++ b/src/components/BitcoinConnect/BitcoinButton.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { Button } from '@getalby/bitcoin-connect-react'; + +interface BitcoinButtonProps { + isDisabled: boolean; +} + +const BitcoinButton: React.FC = ({ isDisabled }) => { + const handleConnect = () => { + if (!isDisabled) { + alert('Connected!'); + + } + }; + + return ( +
+
+
+
+ ); +}; + +export default BitcoinButton; diff --git a/src/pages/setting/index.module.scss b/src/pages/setting/index.module.scss index 8d0c90d5..d4bc4d00 100644 --- a/src/pages/setting/index.module.scss +++ b/src/pages/setting/index.module.scss @@ -11,3 +11,4 @@ .about { text-align: center; } + diff --git a/src/pages/setting/preference.tsx b/src/pages/setting/preference.tsx index 3d343771..18db40ee 100644 --- a/src/pages/setting/preference.tsx +++ b/src/pages/setting/preference.tsx @@ -17,6 +17,9 @@ import { RelayGroup } from 'core/relay/group'; import { useReadonlyMyPublicKey } from 'hooks/useMyPublicKey'; import { useEffect, useState } from 'react'; import { exportDB } from 'dexie-export-import'; +import BitcoinButton from 'components/BitcoinConnect/BitcoinButton'; + + export default function Preference() { const myPublicKey = useReadonlyMyPublicKey(); @@ -98,7 +101,7 @@ export default function Preference() { duration: 0, }); - // Function to close the loading message when called + const closeLoadingMessage = () => { message.destroy(key); }; @@ -159,6 +162,16 @@ export default function Preference() { Zap Amount + + , + ]} + > + Bitcoin Connect + + Database Date: Wed, 29 Nov 2023 16:07:40 -0600 Subject: [PATCH 2/7] corrections were made on package.json, bitcoinconnect and preferences.tsx --- src/pages/_app.page.tsx | 1 + src/pages/setting/preference.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/_app.page.tsx b/src/pages/_app.page.tsx index 499d31a0..624594e1 100644 --- a/src/pages/_app.page.tsx +++ b/src/pages/_app.page.tsx @@ -14,6 +14,7 @@ import { joyIdConfig } from 'core/joyid/config'; import Head from 'next/head'; import theme from 'constants/theme'; + type NextPageWithLayout = NextPage & { getLayout?: (page: ReactNode) => ReactElement; }; diff --git a/src/pages/setting/preference.tsx b/src/pages/setting/preference.tsx index 18db40ee..3558f048 100644 --- a/src/pages/setting/preference.tsx +++ b/src/pages/setting/preference.tsx @@ -166,7 +166,7 @@ export default function Preference() { , + , ]} > Bitcoin Connect From c5e52841e96d606260c423ed2f4529e3ac899322 Mon Sep 17 00:00:00 2001 From: Alan-AC7 Date: Thu, 30 Nov 2023 12:43:01 -0600 Subject: [PATCH 3/7] package.json, btcbutton, preference were changed --- package.json | 2 +- src/components/BitcoinConnect/BitcoinButton.tsx | 15 ++++++--------- src/pages/setting/preference.tsx | 2 +- src/styles/global.scss | 11 ++++------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 03e8da77..5164b4c1 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ }, "scripts": { "wasm:profile": "cd wasm && rustc --crate-type cdylib --target wasm32-unknown-unknown -C lto -C opt-level=z -o profile.wasm examples/profile.rs", - "dev": "set \"REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD)\" && next dev", + "dev": "REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD) next dev", "build:wasm": "cd wasm && wasm-pack build --target web --release && cd ..", "build": "REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD) next build", "start": "REACT_APP_COMMIT_HASH=$(git rev-parse --short HEAD) next start", diff --git a/src/components/BitcoinConnect/BitcoinButton.tsx b/src/components/BitcoinConnect/BitcoinButton.tsx index ca4f161f..b737c1cf 100644 --- a/src/components/BitcoinConnect/BitcoinButton.tsx +++ b/src/components/BitcoinConnect/BitcoinButton.tsx @@ -2,22 +2,19 @@ import React from 'react'; import { Button } from '@getalby/bitcoin-connect-react'; interface BitcoinButtonProps { - isDisabled: boolean; + } -const BitcoinButton: React.FC = ({ isDisabled }) => { +const BitcoinButton: React.FC = () => { const handleConnect = () => { - if (!isDisabled) { - alert('Connected!'); - - } + }; return (
-
-
+ +
); }; diff --git a/src/pages/setting/preference.tsx b/src/pages/setting/preference.tsx index 3558f048..efc53545 100644 --- a/src/pages/setting/preference.tsx +++ b/src/pages/setting/preference.tsx @@ -166,7 +166,7 @@ export default function Preference() { , + , ]} > Bitcoin Connect diff --git a/src/styles/global.scss b/src/styles/global.scss index 07678cbd..314af331 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -163,13 +163,10 @@ white-space: nowrap; } + +//bitcoin-connect :root { - --bc-color-brand: rgb(89,128,34); - - + --bc-color-brand: var(--primary-07); } -.bitcoinConnectContainer { - --bc-color-brand: var(--bc-color-brand); - -} \ No newline at end of file + From d9c92514808536d628489ed51d91e4bab3c5d10f Mon Sep 17 00:00:00 2001 From: Alan-AC7 Date: Mon, 4 Dec 2023 16:23:53 -0600 Subject: [PATCH 4/7] imported bitcoin connect on client side in src/components/PostItems/PostReaction --- src/components/PostItems/PostReactions/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/PostItems/PostReactions/index.tsx b/src/components/PostItems/PostReactions/index.tsx index 99c77a41..5bf54fd7 100644 --- a/src/components/PostItems/PostReactions/index.tsx +++ b/src/components/PostItems/PostReactions/index.tsx @@ -2,7 +2,7 @@ import { Tooltip, message } from 'antd'; import { useTranslation } from 'next-i18next'; import { fetchPublicBookmarkListEvent } from 'components/PostItems/PostReactions/util'; import { useReadonlyMyPublicKey } from 'hooks/useMyPublicKey'; -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; import { EventSetMetadataContent, @@ -24,6 +24,8 @@ import { dexieDb } from 'core/db'; import Icon from 'components/Icon'; import styles from './index.module.scss'; + + interface PostReactionsProp { ownerEvent: Event; worker: CallWorker; @@ -35,6 +37,11 @@ const PostReactions: React.FC = ({ worker, seen, }) => { + useEffect(() => { + // Import Bitcoin Connect for Zaps + import('@getalby/bitcoin-connect-react'); + }, []); + const { t } = useTranslation(); const router = useRouter(); From 7a704fc79a7c40661d1c72dc43bb5407b02eb722 Mon Sep 17 00:00:00 2001 From: Alan-AC7 Date: Thu, 7 Dec 2023 18:09:51 -0600 Subject: [PATCH 5/7] used dynamic import while importing btc-connect --- src/components/BitcoinConnect/BitcoinButton.tsx | 8 +++++--- src/components/PostItems/PostReactions/index.tsx | 11 ++++------- src/pages/setting/preference.tsx | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/components/BitcoinConnect/BitcoinButton.tsx b/src/components/BitcoinConnect/BitcoinButton.tsx index b737c1cf..ffd1949e 100644 --- a/src/components/BitcoinConnect/BitcoinButton.tsx +++ b/src/components/BitcoinConnect/BitcoinButton.tsx @@ -2,18 +2,20 @@ import React from 'react'; import { Button } from '@getalby/bitcoin-connect-react'; interface BitcoinButtonProps { - + isDisabled: boolean; } -const BitcoinButton: React.FC = () => { +const BitcoinButton: React.FC = ({ isDisabled }) => { const handleConnect = () => { + + }; return (
-
); diff --git a/src/components/PostItems/PostReactions/index.tsx b/src/components/PostItems/PostReactions/index.tsx index 5bf54fd7..eec16316 100644 --- a/src/components/PostItems/PostReactions/index.tsx +++ b/src/components/PostItems/PostReactions/index.tsx @@ -2,7 +2,7 @@ import { Tooltip, message } from 'antd'; import { useTranslation } from 'next-i18next'; import { fetchPublicBookmarkListEvent } from 'components/PostItems/PostReactions/util'; import { useReadonlyMyPublicKey } from 'hooks/useMyPublicKey'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import { useSelector } from 'react-redux'; import { EventSetMetadataContent, @@ -24,7 +24,7 @@ import { dexieDb } from 'core/db'; import Icon from 'components/Icon'; import styles from './index.module.scss'; - +import('@getalby/bitcoin-connect-react'); interface PostReactionsProp { ownerEvent: Event; @@ -37,11 +37,6 @@ const PostReactions: React.FC = ({ worker, seen, }) => { - useEffect(() => { - // Import Bitcoin Connect for Zaps - import('@getalby/bitcoin-connect-react'); - }, []); - const { t } = useTranslation(); const router = useRouter(); @@ -68,6 +63,8 @@ const PostReactions: React.FC = ({ }; const zap = async () => { + + if (signEvent == null) return; let zapEndpoint: any = null; diff --git a/src/pages/setting/preference.tsx b/src/pages/setting/preference.tsx index efc53545..3558f048 100644 --- a/src/pages/setting/preference.tsx +++ b/src/pages/setting/preference.tsx @@ -166,7 +166,7 @@ export default function Preference() { , + , ]} > Bitcoin Connect From 1c6baf8b8bf30b7ce5ec628d618103eb0a411af7 Mon Sep 17 00:00:00 2001 From: Alan-AC7 Date: Thu, 7 Dec 2023 18:13:20 -0600 Subject: [PATCH 6/7] corrected an unnecesary prop on btc-connect component --- src/components/BitcoinConnect/BitcoinButton.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/BitcoinConnect/BitcoinButton.tsx b/src/components/BitcoinConnect/BitcoinButton.tsx index ffd1949e..3299a9c6 100644 --- a/src/components/BitcoinConnect/BitcoinButton.tsx +++ b/src/components/BitcoinConnect/BitcoinButton.tsx @@ -5,10 +5,11 @@ interface BitcoinButtonProps { isDisabled: boolean; } -const BitcoinButton: React.FC = ({ isDisabled }) => { +const BitcoinButton: React.FC = ({ }) => { const handleConnect = () => { - + alert('Connected!'); + }; From 2d6e09380e35fa88006c26bcb26c89653a49fb2e Mon Sep 17 00:00:00 2001 From: Alan-AC7 Date: Fri, 8 Dec 2023 12:40:54 -0600 Subject: [PATCH 7/7] added key=btc-connect on Bitcoin Connect Component --- src/components/BitcoinConnect/BitcoinButton.tsx | 14 ++++---------- src/components/PostItems/PostReactions/index.tsx | 16 ++++++++++++++-- src/pages/setting/preference.tsx | 2 +- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/components/BitcoinConnect/BitcoinButton.tsx b/src/components/BitcoinConnect/BitcoinButton.tsx index 3299a9c6..3fa0723b 100644 --- a/src/components/BitcoinConnect/BitcoinButton.tsx +++ b/src/components/BitcoinConnect/BitcoinButton.tsx @@ -1,25 +1,19 @@ import React from 'react'; import { Button } from '@getalby/bitcoin-connect-react'; -interface BitcoinButtonProps { - isDisabled: boolean; -} +interface BitcoinButtonProps {} -const BitcoinButton: React.FC = ({ }) => { +const BitcoinButton: React.FC = () => { const handleConnect = () => { - - alert('Connected!'); - }; return (
- -
); }; export default BitcoinButton; + diff --git a/src/components/PostItems/PostReactions/index.tsx b/src/components/PostItems/PostReactions/index.tsx index eec16316..3e7ae1f0 100644 --- a/src/components/PostItems/PostReactions/index.tsx +++ b/src/components/PostItems/PostReactions/index.tsx @@ -2,7 +2,7 @@ import { Tooltip, message } from 'antd'; import { useTranslation } from 'next-i18next'; import { fetchPublicBookmarkListEvent } from 'components/PostItems/PostReactions/util'; import { useReadonlyMyPublicKey } from 'hooks/useMyPublicKey'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useSelector } from 'react-redux'; import { EventSetMetadataContent, @@ -24,7 +24,7 @@ import { dexieDb } from 'core/db'; import Icon from 'components/Icon'; import styles from './index.module.scss'; -import('@getalby/bitcoin-connect-react'); + interface PostReactionsProp { ownerEvent: Event; @@ -37,6 +37,14 @@ const PostReactions: React.FC = ({ worker, seen, }) => { + + + + // load bitcoin connect for zaps + import('@getalby/bitcoin-connect-react'); + + + const { t } = useTranslation(); const router = useRouter(); @@ -137,8 +145,12 @@ const PostReactions: React.FC = ({ const handler = worker.pubEvent(event); noticePubEventResult(worker.relays.length, handler); setIsBookMarking(false); + + }; + + return (
    {contextHolder} diff --git a/src/pages/setting/preference.tsx b/src/pages/setting/preference.tsx index 3558f048..01a02982 100644 --- a/src/pages/setting/preference.tsx +++ b/src/pages/setting/preference.tsx @@ -166,7 +166,7 @@ export default function Preference() { , + , ]} > Bitcoin Connect