Skip to content

Commit

Permalink
feat: add solana to defaultConnectors (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuizAsFight authored Jul 16, 2024
1 parent 23afa71 commit c9a306d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-items-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuels/connectors": patch
---

Accept `ethWagmiConfig` for eth wallet wagmi configs
5 changes: 5 additions & 0 deletions .changeset/hungry-students-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fuel-connectors/solana-connector": patch
---

Include more solana wallets
29 changes: 6 additions & 23 deletions examples/react-app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ import { coinbaseWallet, walletConnect } from '@wagmi/connectors';
import { http, createConfig, injected } from '@wagmi/core';
import { mainnet, sepolia } from '@wagmi/core/chains';

import {
BakoSafeConnector,
BurnerWalletConnector,
FuelWalletConnector,
FuelWalletDevelopmentConnector,
FueletWalletConnector,
SolanaConnector,
WalletConnectConnector,
} from '@fuels/connectors';
import { defaultConnectors } from '@fuels/connectors';
import { FuelProvider } from '@fuels/react';

import * as Toast from '@radix-ui/react-toast';
Expand Down Expand Up @@ -66,20 +58,11 @@ ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<FuelProvider
theme="dark"
fuelConfig={{
connectors: [
new FuelWalletConnector(),
new BakoSafeConnector(),
new FueletWalletConnector(),
new WalletConnectConnector({
wagmiConfig,
projectId: WC_PROJECT_ID,
}),
new FuelWalletDevelopmentConnector(),
new BurnerWalletConnector(),
new SolanaConnector({
projectId: WC_PROJECT_ID,
}),
],
connectors: defaultConnectors({
devMode: true,
wcProjectId: WC_PROJECT_ID,
ethWagmiConfig: wagmiConfig,
}),
}}
>
<Toast.Provider>
Expand Down
8 changes: 8 additions & 0 deletions packages/connectors/src/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { BurnerWalletConnector } from '@fuel-connectors/burner-wallet-connector'
import { FuelWalletDevelopmentConnector } from '@fuel-connectors/fuel-development-wallet';
import { FuelWalletConnector } from '@fuel-connectors/fuel-wallet';
import { FueletWalletConnector } from '@fuel-connectors/fuelet-wallet';
import { SolanaConnector } from '@fuel-connectors/solana-connector';
import { WalletConnectConnector } from '@fuel-connectors/walletconnect-connector';
import type { Config } from '@wagmi/core';
import type { FuelConnector } from 'fuels';
import type { BurnerWalletConfig } from '../../burner-wallet-connector/src/types';

Expand All @@ -13,19 +15,25 @@ type DefaultConnectors = {
devMode?: boolean;
wcProjectId?: string;
burnerWalletConfig?: BurnerWalletConfig;
ethWagmiConfig?: Config;
};

export function defaultConnectors({
devMode,
wcProjectId = DEFAULT_WC_PROJECT_ID,
burnerWalletConfig,
ethWagmiConfig,
}: DefaultConnectors = {}): Array<FuelConnector> {
const connectors = [
new FuelWalletConnector(),
new BakoSafeConnector(),
new FueletWalletConnector(),
new WalletConnectConnector({
projectId: wcProjectId,
wagmiConfig: ethWagmiConfig,
}),
new SolanaConnector({
projectId: wcProjectId,
}),
new BurnerWalletConnector(burnerWalletConfig),
];
Expand Down
1 change: 1 addition & 0 deletions packages/solana-connector/src/utils/solanaProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function createSolanaProvider(config: SolanaConfig): ModalConfig {
const solanaConfig =
config.solanaConfig ??
defaultSolanaConfig({
enableInjected: true,
chains,
projectId: config.projectId ?? DEFAULT_PROJECT_ID,
metadata: {
Expand Down

0 comments on commit c9a306d

Please sign in to comment.