-
Notifications
You must be signed in to change notification settings - Fork 317
feat: mf-6735 integrate privy wallet support #12281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
247d2e8
eccbafe
8fa8244
1f35cad
a07797e
901d82e
cc1152b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,3 +104,4 @@ | |
|
||
; FIREFLY_X_CLIENT_ID= | ||
; FIREFLY_X_CLIENT_SECRET= | ||
; PRIVY_APP_ID= |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ approvedList.set('string-width-cjs', 'npm:string-width@^4.2.0') | |
approvedList.set('strip-ansi-cjs', 'npm:strip-ansi@^6.0.1') | ||
approvedList.set('wrap-ansi-cjs', ['npm:wrap-ansi@^6.0.1', 'npm:wrap-ansi@^7.0.0']) | ||
|
||
approvedList.set('cbw-sdk', ['npm:@coinbase/[email protected]']) | ||
/** | ||
* @param {string} parentPackage The current resolving parentPackage | ||
* @param {string} dependedPackage The package it depends on | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||
import { PersistentStorages } from '@masknet/shared-base' | ||||||
|
||||||
export async function loginFireflyViaTwitter() { | ||||||
const data = await browser.storage.local.get('firefly_x_oauth') | ||||||
if (!data?.firefly_x_oauth) throw new Error('X OAuth token not found') | ||||||
const oauth: Record<string, string> = data.firefly_x_oauth | ||||||
|
||||||
const res = await fetch('https://firefly.social/api/twitter/auth', { | ||||||
method: 'POST', | ||||||
headers: { | ||||||
'X-Access-Token': oauth.oauth_token, | ||||||
'X-Access-Token-Secret': oauth.oauth_token_secret, | ||||||
'X-Client-Id': oauth.oauth_token.split('-')[0], | ||||||
'X-Consumer-Key': process.env.FIREFLY_X_CLIENT_ID, | ||||||
'X-Consumer-Secret': '[HIDE_FROM_CLIENT]', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardcoded placeholder '[HIDE_FROM_CLIENT]' for consumer secret suggests incomplete implementation. This should use the actual environment variable or be properly handled to avoid authentication failures.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
}, | ||||||
}) | ||||||
const json = await res.json() | ||||||
if (!json.success) throw new Error(json.message) | ||||||
|
||||||
const res2 = await fetch('https://api.firefly.land/v3/auth/exchange/twitter', { | ||||||
method: 'POST', | ||||||
headers: { | ||||||
'Content-Type': 'application/json', | ||||||
}, | ||||||
body: JSON.stringify({ | ||||||
data: json.data, | ||||||
}), | ||||||
}) | ||||||
const json2 = await res2.json() | ||||||
await browser.storage.local.set({ firefly_account: json2.data }) | ||||||
await PersistentStorages.Settings.storage.firefly_account.setValue(json2.data) | ||||||
return json2.data | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,51 @@ | ||
import { cloneElement, Suspense } from 'react' | ||
import { i18n } from '@lingui/core' | ||
import { useSiteThemeMode } from '@masknet/plugin-infra/content-script' | ||
import { LinguiProviderHMR, SharedContextProvider, PrivySetup } from '@masknet/shared' | ||
import { queryClient } from '@masknet/shared-base-ui' | ||
import { DialogStackingProvider, MaskThemeProvider } from '@masknet/theme' | ||
import { RootWeb3ContextProvider } from '@masknet/web3-hooks-base' | ||
import { QueryClientProvider } from '@tanstack/react-query' | ||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools' | ||
import { RootWeb3ContextProvider } from '@masknet/web3-hooks-base' | ||
import { DialogStackingProvider, MaskThemeProvider } from '@masknet/theme' | ||
import { jsxCompose } from '@masknet/shared-base' | ||
import { queryClient } from '@masknet/shared-base-ui' | ||
import { createPortal } from 'react-dom' | ||
import { i18n } from '@lingui/core' | ||
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client' | ||
import { Suspense } from 'react' | ||
import { createPortal } from 'react-dom' | ||
import { queryPersistOptions } from '../../../shared-ui/utils/persistOptions.js' | ||
import { LinguiProviderHMR, SharedContextProvider } from '@masknet/shared' | ||
import { useSiteThemeMode } from '@masknet/plugin-infra/content-script' | ||
import { useMaskSiteAdaptorMixedTheme } from '../../components/useMaskSiteAdaptorMixedTheme.js' | ||
|
||
export function ContentScriptGlobalProvider(children: React.ReactNode) { | ||
return jsxCompose( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is suitable to compose single-child jsx, if there are multiple children, it might end up xml style. You can see there is a Besides, it causes every component renders twice, once for the original, once for the cloned one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by renders twice? Does that mean the JSX tree is being duplicated in the final rendering tree? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Sorry, it might be that I misread it at the time. |
||
<Suspense />, | ||
<DialogStackingProvider hasGlobalBackdrop={false} />, | ||
<QueryClientProvider client={queryClient} />, | ||
<PersistQueryClientProvider client={queryClient} persistOptions={queryPersistOptions} />, | ||
<RootWeb3ContextProvider />, | ||
<SharedContextProvider />, | ||
<LinguiProviderHMR i18n={i18n} />, | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
<MaskThemeProvider useMaskIconPalette={useSiteThemeMode} useTheme={useMaskSiteAdaptorMixedTheme} />, | ||
)( | ||
cloneElement, | ||
const jsx = | ||
process.env.NODE_ENV === 'development' ? | ||
<> | ||
{/* https://github.com/TanStack/query/issues/5417 */} | ||
{createPortal(<ReactQueryDevtools buttonPosition="bottom-right" />, document.body)} | ||
{children} | ||
</> | ||
Comment on lines
18
to
22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple children should go here. Does that answer your question? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think xml style would be more convenient, it's inconvenient to add siblings. Like if you prepend a sibling before I think To avoid deep indent, we can reduce the indent width, that's why I ignored prettier for this, or we can group those providers by dimensions, like Anyway, I can revert to |
||
: children, | ||
: children | ||
|
||
// eslint-disable: react-compiler/react-compiler | ||
// prettier-ignore | ||
return ( | ||
<Suspense> | ||
<DialogStackingProvider hasGlobalBackdrop={false}> | ||
<QueryClientProvider client={queryClient}> | ||
<PersistQueryClientProvider client={queryClient} persistOptions={queryPersistOptions}> | ||
<RootWeb3ContextProvider> | ||
<PrivySetup /> | ||
<SharedContextProvider> | ||
<LinguiProviderHMR i18n={i18n}> | ||
<MaskThemeProvider | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
useMaskIconPalette={useSiteThemeMode} | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
useTheme={useMaskSiteAdaptorMixedTheme}> | ||
{jsx} | ||
</MaskThemeProvider> | ||
</LinguiProviderHMR> | ||
</SharedContextProvider> | ||
</RootWeb3ContextProvider> | ||
</PersistQueryClientProvider> | ||
</QueryClientProvider> | ||
</DialogStackingProvider> | ||
</Suspense> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import { cloneElement, Suspense } from 'react' | ||
import { Suspense } from 'react' | ||
import { CSSVariableInjector, CustomSnackbarProvider } from '@masknet/theme' | ||
import { ErrorBoundary } from '@masknet/shared-base-ui' | ||
import { Sniffings, jsxCompose } from '@masknet/shared-base' | ||
import { Sniffings } from '@masknet/shared-base' | ||
|
||
// Providers added here will be added to ALL ShadowRoots, if you're mean to add a global one, add it in ./SiteUIProvider.tsx | ||
export function ShadowRootAttachPointRoot(children: React.ReactNode) { | ||
return jsxCompose( | ||
<Suspense />, | ||
<ErrorBoundary />, | ||
<CustomSnackbarProvider | ||
disableWindowBlurListener={false} | ||
anchorOrigin={{ vertical: 'top', horizontal: 'right' }} | ||
children={null!} | ||
offsetY={Sniffings.is_facebook_page ? 80 : undefined} | ||
/>, | ||
)( | ||
cloneElement, | ||
<> | ||
<CSSVariableInjector /> | ||
{children} | ||
</>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let lines of code, and clear hierarchical relation at a glance. |
||
return ( | ||
<Suspense> | ||
<ErrorBoundary> | ||
<CustomSnackbarProvider | ||
disableWindowBlurListener={false} | ||
anchorOrigin={{ vertical: 'top', horizontal: 'right' }} | ||
offsetY={Sniffings.is_facebook_page ? 80 : undefined}> | ||
<CSSVariableInjector /> | ||
{children} | ||
</CustomSnackbarProvider> | ||
</ErrorBoundary> | ||
</Suspense> | ||
) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.