This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from magiclabs/fix/deprecated_package
Removed deprecated package. Updated magic-sdk package to latest version
- Loading branch information
Showing
29 changed files
with
126 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
...olds/nextjs-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 43 additions & 59 deletions
102
scaffolds/nextjs-flow-dedicated-wallet/template/src/components/magic/MagicProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,48 @@ | ||
import {getNetwork, getNetworkUrl} from '@/utils/network' | ||
import {OAuthExtension} from '@magic-ext/oauth' | ||
import {AuthExtension} from '@magic-ext/auth' | ||
import {Magic as MagicBase} from 'magic-sdk' | ||
import { | ||
ReactNode, | ||
createContext, | ||
useContext, | ||
useEffect, | ||
useMemo, | ||
useState, | ||
} from 'react' | ||
import {FlowExtension} from '@magic-ext/flow' | ||
import * as fcl from '@onflow/fcl' | ||
import { getNetwork, getNetworkUrl } from '@/utils/network'; | ||
import { OAuthExtension } from '@magic-ext/oauth'; | ||
import { Magic as MagicBase } from 'magic-sdk'; | ||
import { ReactNode, createContext, useContext, useEffect, useMemo, useState } from 'react'; | ||
import { FlowExtension } from '@magic-ext/flow'; | ||
import * as fcl from '@onflow/fcl'; | ||
|
||
export type Magic = MagicBase< | ||
AuthExtension & OAuthExtension[] & FlowExtension[] | ||
> | ||
export type Magic = MagicBase<OAuthExtension[] & FlowExtension[]>; | ||
|
||
type MagicContextType = { | ||
magic: Magic | null | ||
} | ||
magic: Magic | null; | ||
}; | ||
|
||
const MagicContext = createContext<MagicContextType>({ | ||
magic: null, | ||
}) | ||
|
||
export const useMagic = () => useContext(MagicContext) | ||
|
||
const MagicProvider = ({children}: {children: ReactNode}) => { | ||
const [magic, setMagic] = useState<Magic | null>(null) | ||
|
||
useEffect(() => { | ||
if (process.env.NEXT_PUBLIC_MAGIC_API_KEY) { | ||
const magic = new MagicBase( | ||
process.env.NEXT_PUBLIC_MAGIC_API_KEY as string, | ||
{ | ||
extensions: [ | ||
new AuthExtension(), | ||
new OAuthExtension(), | ||
new FlowExtension({ | ||
rpcUrl: getNetworkUrl(), | ||
network: getNetwork() as string, | ||
}), | ||
], | ||
} | ||
) | ||
setMagic(magic) | ||
fcl.config().put('accessNode.api', getNetworkUrl()) | ||
} | ||
}, []) | ||
|
||
const value = useMemo(() => { | ||
return { | ||
magic, | ||
} | ||
}, [magic]) | ||
|
||
return ( | ||
<MagicContext.Provider value={value}>{children}</MagicContext.Provider> | ||
) | ||
} | ||
|
||
export default MagicProvider | ||
magic: null, | ||
}); | ||
|
||
export const useMagic = () => useContext(MagicContext); | ||
|
||
const MagicProvider = ({ children }: { children: ReactNode }) => { | ||
const [magic, setMagic] = useState<Magic | null>(null); | ||
|
||
useEffect(() => { | ||
if (process.env.NEXT_PUBLIC_MAGIC_API_KEY) { | ||
const magic = new MagicBase(process.env.NEXT_PUBLIC_MAGIC_API_KEY as string, { | ||
extensions: [ | ||
new OAuthExtension(), | ||
new FlowExtension({ | ||
rpcUrl: getNetworkUrl(), | ||
network: getNetwork() as string, | ||
}), | ||
], | ||
}); | ||
setMagic(magic); | ||
fcl.config().put('accessNode.api', getNetworkUrl()); | ||
} | ||
}, []); | ||
|
||
const value = useMemo(() => { | ||
return { | ||
magic, | ||
}; | ||
}, [magic]); | ||
|
||
return <MagicContext.Provider value={value}>{children}</MagicContext.Provider>; | ||
}; | ||
|
||
export default MagicProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
...nextjs-flow-dedicated-wallet/template/src/components/magic/wallet-methods/UpdatePhone.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.