-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/thirdweb/src/react/wallets/coinbase/coinbaseConfig.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
injectedCoinbaseProvider, | ||
coinbaseMetadata, | ||
coinbaseWallet, | ||
} from "../../../wallets/index.js"; | ||
import type { WalletConfig } from "../../types/wallets.js"; | ||
import { InjectedConnectUI } from "../shared/InjectedConnectUI.js"; | ||
|
||
/** | ||
* Integrate Coinbase wallet connection into your app. | ||
* @example | ||
* ```tsx | ||
* <ThirdwebProvider | ||
* client={client}> | ||
* wallets={[ coinbaseConfig() ]} | ||
* <App /> | ||
* </ThirdwebProvider> | ||
* ``` | ||
* @returns WalletConfig object to be passed into `ThirdwebProvider` | ||
*/ | ||
export const coinbaseConfig = (): WalletConfig => { | ||
return { | ||
metadata: coinbaseMetadata, | ||
create() { | ||
return coinbaseWallet(); | ||
}, | ||
connectUI(props) { | ||
return ( | ||
<InjectedConnectUI | ||
{...props} | ||
links={{ | ||
extension: | ||
"https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad", | ||
android: "https://play.google.com/store/apps/details?id=org.toshi", | ||
ios: "https://apps.apple.com/us/app/coinbase-wallet-nfts-crypto/id1278383455", | ||
}} | ||
/> | ||
); | ||
}, | ||
isInstalled() { | ||
return !!injectedCoinbaseProvider(); | ||
}, | ||
}; | ||
}; |
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,10 +1,12 @@ | ||
import type { WalletConfig } from "../types/wallets.js"; | ||
import { coinbaseConfig } from "./coinbase/coinbaseConfig.js"; | ||
import { metamaskConfig } from "./metamask/metamaskConfig.js"; | ||
import { rainbowConfig } from "./rainbow/rainbowConfig.js"; | ||
import { zerionConfig } from "./zerion/zerionConfig.js"; | ||
|
||
export const defaultWallets: WalletConfig[] = [ | ||
/* @__PURE__ */ metamaskConfig(), | ||
/* @__PURE__ */ zerionConfig(), | ||
/* @__PURE__ */ coinbaseConfig(), | ||
/* @__PURE__ */ rainbowConfig(), | ||
/* @__PURE__ */ zerionConfig(), | ||
]; |
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
40 changes: 40 additions & 0 deletions
40
packages/thirdweb/src/wallets/injected/wallets/coinbase.ts
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { WalletMetadata } from "../../types.js"; | ||
import { InjectedWallet } from "../index.js"; | ||
import { injectedProvider } from "../mipdStore.js"; | ||
import type { SpecificInjectedWalletOptions } from "../types.js"; | ||
|
||
export const coinbaseMetadata: WalletMetadata = { | ||
id: "com.coinbase.wallet", | ||
name: "Coinbase Wallet", | ||
iconUrl: | ||
"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQ4IiBoZWlnaHQ9IjQ4IiByeD0iOCIgZmlsbD0iIz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U3OUMxOS40NTkgMTkuOTYxNCAxOS45MjYyIDE5LjQ1OSAyMC41MDA2IDE5LjQ1OVoiIGZpbGw9IiMwMDUyRkYiLz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF8zMzAzXzg2MzQiPgo8cmVjdCB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIGZpbGw9IndoaXRlIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg0IDQpIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==", | ||
}; | ||
|
||
/** | ||
* Connect to Injected Coinbase Wallet Provider | ||
* @param options - The options for connecting to the Injected Coinbase Wallet Provider. | ||
* @example | ||
* ```ts | ||
* const wallet = await coinbaseWallet(); | ||
* ``` | ||
* @returns A Promise that resolves to a Wallet instance. | ||
*/ | ||
export function coinbaseWallet(options?: SpecificInjectedWalletOptions) { | ||
return new InjectedWallet({ | ||
...options, | ||
walletId: coinbaseMetadata.id, | ||
metadata: coinbaseMetadata, | ||
}); | ||
} | ||
|
||
/** | ||
* Get the injected Coinbase wallet provider | ||
* @example | ||
* ```ts | ||
* const provider = injectedCoinbaseProvider(); | ||
* ``` | ||
* @returns The injected coinbase wallet provider | ||
*/ | ||
export function injectedCoinbaseProvider() { | ||
return injectedProvider(coinbaseMetadata.id); | ||
} |