diff --git a/scaffolds/nextjs-dedicated-wallet/scaffold.tsx b/scaffolds/nextjs-dedicated-wallet/scaffold.tsx index 90b6d23..051916d 100644 --- a/scaffolds/nextjs-dedicated-wallet/scaffold.tsx +++ b/scaffolds/nextjs-dedicated-wallet/scaffold.tsx @@ -72,9 +72,6 @@ export default class DedicatedScaffold extends BaseScaffold { if (authType.replaceAll(' ', '') === 'EmailOTP') { (this.source as string[]).push('./src/components/magic/wallet-methods/UpdateEmail.tsx'); } - if (authType.replaceAll(' ', '') === 'SMSOTP') { - (this.source as string[]).push('./src/components/magic/wallet-methods/UpdatePhone.tsx'); - } }); } } diff --git a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx index 662e77c..2b0954e 100644 --- a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx +++ b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx @@ -22,9 +22,9 @@ const EmailOTP = ({ token, setToken }: LoginProps) => { try { setLoginInProgress(true); setEmailError(false); - const account = await magic?.auth.loginWithEmailOTP({ email }); - if (account) { - saveToken(account, setToken, 'EMAIL'); + const token = await magic?.auth.loginWithEmailOTP({ email }); + if (token) { + saveToken(token, setToken, 'EMAIL'); setEmail(''); } } catch (e) { diff --git a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx index 2b3e474..a0150b2 100644 --- a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx +++ b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx @@ -22,11 +22,11 @@ const SMSOTP = ({ token, setToken }: LoginProps) => { try { setLoginInProgress(true); setPhoneError(false); - const account = await magic?.auth.loginWithSMS({ + const token = await magic?.auth.loginWithSMS({ phoneNumber: phone, }); - if (account) { - saveToken(account, setToken, 'SMS'); + if (token) { + saveToken(token, setToken, 'SMS'); setPhone(''); } } catch (e) { diff --git a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx index f40e77f..0b3eb2c 100644 --- a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx +++ b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx @@ -10,9 +10,6 @@ import { LoginMethod } from '@/utils/common'; <% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%> <%-`import UpdateEmail from '../wallet-methods/UpdateEmail'`-%> <% }%> -<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%> -<%-`import UpdatePhone from '../wallet-methods/UpdatePhone'`-%> -<% }%> const WalletMethods = ({ token, setToken }: LoginProps) => { const [loginMethod, setLoginMethod] = useState( @@ -29,14 +26,6 @@ const WalletMethods = ({ token, setToken }: LoginProps) => { )}`-%> <% }%> - <% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%> - <%-`{loginMethod && loginMethod == 'SMS' && ( - <> - - - - )}`-%> - <% }%> diff --git a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx b/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx deleted file mode 100644 index 3eb73a7..0000000 --- a/scaffolds/nextjs-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React, { useCallback, useState } from 'react'; -import { useMagic } from '../MagicProvider'; -import Spinner from '@/components/ui/Spinner'; -import showToast from '@/utils/showToast'; -import { RPCError } from 'magic-sdk'; - -const UpdatePhone = () => { - const { magic } = useMagic(); - const [disabled, setDisabled] = useState(false); - - const updatePhone = useCallback(async () => { - if (!magic) return; - try { - setDisabled(true); - await magic.auth.updatePhoneNumberWithUI(); - showToast({ message: 'Phone Updated!', type: 'success' }); - setDisabled(false); - } catch (error) { - setDisabled(false); - console.error(error); - if (error instanceof RPCError) { - showToast({ message: error.message, type: 'error' }); - } else { - showToast({ message: 'Update phone failed', type: 'error' }); - } - } - }, [magic]); - - return ( -
- -
- Initiates the update phone number flow that allows a user to change their phone number. -
-
- ); -}; - -export default UpdatePhone; diff --git a/scaffolds/nextjs-flow-dedicated-wallet/scaffold.tsx b/scaffolds/nextjs-flow-dedicated-wallet/scaffold.tsx index 6f2f8c5..f26ba8d 100644 --- a/scaffolds/nextjs-flow-dedicated-wallet/scaffold.tsx +++ b/scaffolds/nextjs-flow-dedicated-wallet/scaffold.tsx @@ -72,9 +72,6 @@ export default class FlowDedicatedScaffold extends BaseScaffold { if (authType.replaceAll(' ', '') === 'EmailOTP') { (this.source as string[]).push('./src/components/magic/wallet-methods/UpdateEmail.tsx'); } - if (authType.replaceAll(' ', '') === 'SMSOTP') { - (this.source as string[]).push('./src/components/magic/wallet-methods/UpdatePhone.tsx'); - } }); } } diff --git a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx index 662e77c..2b0954e 100644 --- a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx +++ b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx @@ -22,9 +22,9 @@ const EmailOTP = ({ token, setToken }: LoginProps) => { try { setLoginInProgress(true); setEmailError(false); - const account = await magic?.auth.loginWithEmailOTP({ email }); - if (account) { - saveToken(account, setToken, 'EMAIL'); + const token = await magic?.auth.loginWithEmailOTP({ email }); + if (token) { + saveToken(token, setToken, 'EMAIL'); setEmail(''); } } catch (e) { diff --git a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx index 2b3e474..a0150b2 100644 --- a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx +++ b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx @@ -22,11 +22,11 @@ const SMSOTP = ({ token, setToken }: LoginProps) => { try { setLoginInProgress(true); setPhoneError(false); - const account = await magic?.auth.loginWithSMS({ + const token = await magic?.auth.loginWithSMS({ phoneNumber: phone, }); - if (account) { - saveToken(account, setToken, 'SMS'); + if (token) { + saveToken(token, setToken, 'SMS'); setPhone(''); } } catch (e) { diff --git a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx index db2d484..a2c7a0b 100644 --- a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx +++ b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx @@ -10,9 +10,6 @@ import GetMetadata from '../wallet-methods/GetMetadata' <% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%> <%-`import UpdateEmail from '../wallet-methods/UpdateEmail'`-%> <% }%> -<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%> -<%-`import UpdatePhone from '../wallet-methods/UpdatePhone'`-%> -<% }%> const WalletMethods = ({token, setToken}: LoginProps) => { const [loginMethod, setLoginMethod] = useState( @@ -29,14 +26,6 @@ const WalletMethods = ({token, setToken}: LoginProps) => { )}`-%> <% }%> - <% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%> - <%-`{loginMethod && loginMethod == 'SMS' && ( - <> - - - - )}`-%> - <% }%> diff --git a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx b/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx deleted file mode 100644 index d0e67c0..0000000 --- a/scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React, {useCallback, useState} from 'react' -import {useMagic} from '../MagicProvider' -import Spinner from '@/components/ui/Spinner' -import showToast from '@/utils/showToast' -import {RPCError} from 'magic-sdk' - -const UpdatePhone = () => { - const {magic} = useMagic() - const [disabled, setDisabled] = useState(false) - - const updatePhone = useCallback(async () => { - if (!magic) return - try { - setDisabled(true) - await magic.auth.updatePhoneNumberWithUI() - showToast({message: 'Phone Updated!', type: 'success'}) - setDisabled(false) - } catch (error) { - setDisabled(false) - console.error(error) - if (error instanceof RPCError) { - showToast({message: error.message, type: 'error'}) - } else { - showToast({message: 'Update phone failed', type: 'error'}) - } - } - }, [magic]) - - return ( -
- -
- Initiates the update phone number flow that allows a user to - change their phone number. -
-
- ) -} - -export default UpdatePhone diff --git a/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Home.tsx b/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Home.tsx index a1d58de..5099438 100644 --- a/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Home.tsx +++ b/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Home.tsx @@ -20,8 +20,8 @@ export default function Home({ setAccount }: Props) {
- + diff --git a/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Login.tsx b/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Login.tsx index 0055c1b..bec6b20 100644 --- a/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Login.tsx +++ b/scaffolds/nextjs-flow-universal-wallet/template/src/components/magic/Login.tsx @@ -17,11 +17,11 @@ const Login = ({ setAccount }: Props) => { if (!magic) return; try { setDisabled(true); - const account = await magic.flow.getAccount(); + const token = await magic.flow.getAccount(); setDisabled(false); - console.log('Logged in user:', account); - localStorage.setItem('user', account); - setAccount(account); + console.log('Logged in user:', token); + localStorage.setItem('user', token); + setAccount(token); } catch (error) { setDisabled(false); console.error(error); diff --git a/scaffolds/nextjs-solana-dedicated-wallet/scaffold.tsx b/scaffolds/nextjs-solana-dedicated-wallet/scaffold.tsx index 6c31bd7..e5b112b 100644 --- a/scaffolds/nextjs-solana-dedicated-wallet/scaffold.tsx +++ b/scaffolds/nextjs-solana-dedicated-wallet/scaffold.tsx @@ -72,9 +72,6 @@ export default class SolanaDedicatedScaffold extends BaseScaffold { if (authType.replaceAll(' ', '') === 'EmailOTP') { (this.source as string[]).push('./src/components/magic/wallet-methods/UpdateEmail.tsx'); } - if (authType.replaceAll(' ', '') === 'SMSOTP') { - (this.source as string[]).push('./src/components/magic/wallet-methods/UpdatePhone.tsx'); - } }); } } diff --git a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx index 662e77c..2b0954e 100644 --- a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx +++ b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/EmailOTP.tsx @@ -22,9 +22,9 @@ const EmailOTP = ({ token, setToken }: LoginProps) => { try { setLoginInProgress(true); setEmailError(false); - const account = await magic?.auth.loginWithEmailOTP({ email }); - if (account) { - saveToken(account, setToken, 'EMAIL'); + const token = await magic?.auth.loginWithEmailOTP({ email }); + if (token) { + saveToken(token, setToken, 'EMAIL'); setEmail(''); } } catch (e) { diff --git a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx index 2b3e474..a0150b2 100644 --- a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx +++ b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/auth/SMSOTP.tsx @@ -22,11 +22,11 @@ const SMSOTP = ({ token, setToken }: LoginProps) => { try { setLoginInProgress(true); setPhoneError(false); - const account = await magic?.auth.loginWithSMS({ + const token = await magic?.auth.loginWithSMS({ phoneNumber: phone, }); - if (account) { - saveToken(account, setToken, 'SMS'); + if (token) { + saveToken(token, setToken, 'SMS'); setPhone(''); } } catch (e) { diff --git a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx index db2d484..a2c7a0b 100644 --- a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx +++ b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/cards/WalletMethodsCard.tsx @@ -10,9 +10,6 @@ import GetMetadata from '../wallet-methods/GetMetadata' <% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("EmailOTP")){%> <%-`import UpdateEmail from '../wallet-methods/UpdateEmail'`-%> <% }%> -<% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%> -<%-`import UpdatePhone from '../wallet-methods/UpdatePhone'`-%> -<% }%> const WalletMethods = ({token, setToken}: LoginProps) => { const [loginMethod, setLoginMethod] = useState( @@ -29,14 +26,6 @@ const WalletMethods = ({token, setToken}: LoginProps) => { )}`-%> <% }%> - <% if(loginMethods.map(authType => authType.replaceAll(" ", "")).includes("SMSOTP")){%> - <%-`{loginMethod && loginMethod == 'SMS' && ( - <> - - - - )}`-%> - <% }%> diff --git a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx b/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx deleted file mode 100644 index d0e67c0..0000000 --- a/scaffolds/nextjs-solana-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React, {useCallback, useState} from 'react' -import {useMagic} from '../MagicProvider' -import Spinner from '@/components/ui/Spinner' -import showToast from '@/utils/showToast' -import {RPCError} from 'magic-sdk' - -const UpdatePhone = () => { - const {magic} = useMagic() - const [disabled, setDisabled] = useState(false) - - const updatePhone = useCallback(async () => { - if (!magic) return - try { - setDisabled(true) - await magic.auth.updatePhoneNumberWithUI() - showToast({message: 'Phone Updated!', type: 'success'}) - setDisabled(false) - } catch (error) { - setDisabled(false) - console.error(error) - if (error instanceof RPCError) { - showToast({message: error.message, type: 'error'}) - } else { - showToast({message: 'Update phone failed', type: 'error'}) - } - } - }, [magic]) - - return ( -
- -
- Initiates the update phone number flow that allows a user to - change their phone number. -
-
- ) -} - -export default UpdatePhone diff --git a/scaffolds/nextjs-universal-wallet/template/src/components/magic/Home.tsx b/scaffolds/nextjs-universal-wallet/template/src/components/magic/Home.tsx index 37d23bd..cf49a0f 100644 --- a/scaffolds/nextjs-universal-wallet/template/src/components/magic/Home.tsx +++ b/scaffolds/nextjs-universal-wallet/template/src/components/magic/Home.tsx @@ -19,8 +19,8 @@ export default function Home({ setAccount }: Props) {
- +