-
Notifications
You must be signed in to change notification settings - Fork 240
/
metamask-wallet.ts
52 lines (49 loc) · 1.4 KB
/
metamask-wallet.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { walletIds } from "@thirdweb-dev/wallets";
import { WalletOptions, WalletConfig } from "@thirdweb-dev/react-core";
import { WCMeta } from "../types/wc";
import { WalletConnectBase } from "./wallet-connect/WalletConnectBase";
import { WalletConnectConfig } from "./wallet-connect/wallet-connect";
import { METAMASK_ICON } from "../../assets/svgs";
export class MetaMaskWallet extends WalletConnectBase {
static id = walletIds.metamask;
static meta = {
name: "MetaMask",
iconURL: METAMASK_ICON,
links: {
native: "metamask:",
universal: "https://metamask.app.link",
},
};
getMeta(): WCMeta {
return MetaMaskWallet.meta;
}
}
/**
* Wallet config for MetaMask Wallet.
*
* @param config - The config for MetamaskWallet
* @returns The wallet config to be used by the ThirdwebProvider
*
* @example
* ```jsx
* import { ThirdwebProvider, metamaskWallet } from "@thirdweb-dev/react-native";
*
* <ThirdwebProvider
* supportedWallets={[metamaskWallet()]}>
* <YourApp />
* </ThirdwebProvider>
* ```
*/
export const metamaskWallet = (config?: WalletConnectConfig) => {
return {
id: MetaMaskWallet.id,
meta: MetaMaskWallet.meta,
create: (options: WalletOptions) =>
new MetaMaskWallet({
...options,
walletId: walletIds.metamask,
projectId: config?.projectId,
}),
recommended: config?.recommended,
} satisfies WalletConfig;
};