Skip to content

Commit

Permalink
Merge pull request #361 from alephium/support-custome-connect-provider
Browse files Browse the repository at this point in the history
Support custom connect provider
  • Loading branch information
polarker authored Jun 4, 2024
2 parents 747bfb0 + 5ac0a7c commit a095f9f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
22 changes: 14 additions & 8 deletions packages/web3-react/src/components/AlephiumConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import {
ConnectSettingContext,
ConnectSettingValue,
ConnectionStatus,
useAlephiumConnectContext
useAlephiumConnectContext,
useConnectSettingContext
} from '../contexts/alephiumConnect'
import { getLastConnectedAccount, removeLastConnectedAccount } from '../utils/storage'
import { ConnectResult, getConnectorById } from '../utils/connector'
Expand Down Expand Up @@ -94,13 +95,16 @@ export const ConnectSettingProvider: React.FC<{
errorMessage
}

return <ConnectSettingContext.Provider value={value}>{children}</ConnectSettingContext.Provider>
}

const DefaultThemeProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => {
const context = useConnectSettingContext()
return (
<ConnectSettingContext.Provider value={value}>
<ThemeProvider theme={defaultTheme}>
{children}
<AlephiumConnectModal theme={_theme} mode={_mode} customTheme={_customTheme} />
</ThemeProvider>
</ConnectSettingContext.Provider>
<ThemeProvider theme={defaultTheme}>
{children}
<AlephiumConnectModal theme={context.theme} mode={context.mode} customTheme={context.customTheme} />
</ThemeProvider>
)
}

Expand Down Expand Up @@ -321,7 +325,9 @@ export const AlephiumWalletProvider = ({
customTheme={customTheme}
csrModeOnly={csrModeOnly}
>
<AlephiumBalanceProvider>{children}</AlephiumBalanceProvider>
<DefaultThemeProvider>
<AlephiumBalanceProvider>{children}</AlephiumBalanceProvider>
</DefaultThemeProvider>
</ConnectSettingProvider>
</AlephiumConnectProvider>
)
Expand Down
9 changes: 8 additions & 1 deletion packages/web3-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the library. If not, see <http://www.gnu.org/licenses/>.
*/
export { AlephiumWalletProvider, AlephiumBalanceProvider } from './components/AlephiumConnect'
export {
AlephiumWalletProvider,
AlephiumBalanceProvider,
ConnectSettingProvider,
AlephiumConnectProvider
} from './components/AlephiumConnect'
export { AlephiumConnectButton, AlephiumConnectButtonCustom } from './components/ConnectButton'

export { default as supportedConnectors } from './constants/supportedConnectors'
Expand All @@ -24,3 +29,5 @@ export { useConnect } from './hooks/useConnect'
export { useTxStatus } from './hooks/useTxStatus'
export { useBalance } from './hooks/useBalance'
export { useWallet, Wallet, useWalletConfig, WalletConfig } from './hooks/useWallet'

export * from './contexts/alephiumConnect'

0 comments on commit a095f9f

Please sign in to comment.