11import { toPrivyWalletConnector } from "@privy-io/cross-app-connect/rainbow-kit" ;
22import type { CreateConnectorFn } from "@wagmi/core" ;
33import { createEmitter } from "@wagmi/core/internal" ;
4+ import type { Chain , EIP1193Provider } from "viem" ;
5+ import {
6+ abstract ,
7+ apeChain ,
8+ arbitrum ,
9+ arbitrumSepolia ,
10+ base ,
11+ baseSepolia ,
12+ curtis ,
13+ mainnet ,
14+ optimism ,
15+ optimismSepolia ,
16+ polygon ,
17+ sepolia ,
18+ } from "viem/chains" ;
419import { fromProvider } from "../../adapters/eip1193/from-eip1193.js" ;
5- import { apechain } from "../../chains/chain-definitions/apechain.js" ;
6- import { GLYPH_APP_ID , glyphConnectorDetails , STAGING_GLYPH_APP_ID } from "../../wallets/glyph/constants.js" ;
20+ import {
21+ GLYPH_APP_ID ,
22+ glyphConnectorDetails ,
23+ STAGING_GLYPH_APP_ID ,
24+ } from "../../wallets/glyph/constants.js" ;
725import type { Wallet } from "../../wallets/interfaces/wallet.js" ;
8- import type { Chain , EIP1193Provider } from "viem" ;
9- import { abstract , apeChain , arbitrum , arbitrumSepolia , base , baseSepolia , curtis , mainnet , optimism , optimismSepolia , polygon , sepolia } from "viem/chains" ;
1026
1127/**
1228 * Create a wagmi connector for the Glyph Global Wallet.
@@ -17,47 +33,50 @@ import { abstract, apeChain, arbitrum, arbitrumSepolia, base, baseSepolia, curti
1733 * @example
1834 * import { createConfig, http } from "wagmi";
1935 * import { apeChain } from "wagmi/chains";
20- * import { glyphWalletConnector } from "@use-glyph/sdk-react "
36+ * import { glyphWalletWagmiConnector } from "thirdweb/wallets/glyph "
2137 *
2238 * export const wagmiConfig = createConfig({
2339 * chains: [apeChain],
2440 * transports: {
2541 * [apeChain.id]: http(),
2642 * },
27- * connectors: [glyphWalletConnector ()],
43+ * connectors: [glyphWalletWagmiConnector ()],
2844 * ssr: true,
2945 * });
3046 */
31- function glyphWalletConnector ( options ?: {
32- useStagingTenant ?: boolean
47+ function glyphWalletWagmiConnector ( options ?: {
48+ useStagingTenant ?: boolean ;
3349} ) : CreateConnectorFn {
34- const { useStagingTenant } = options ?? { } ;
50+ const { useStagingTenant } = options ?? { } ;
3551
36- return ( params ) => {
37- const connector = toPrivyWalletConnector ( {
38- iconUrl : glyphConnectorDetails . iconUrl ,
39- id : useStagingTenant ? STAGING_GLYPH_APP_ID : GLYPH_APP_ID ,
40- name : glyphConnectorDetails . name
41- } ) ( params ) ;
52+ return ( params ) => {
53+ const connector = toPrivyWalletConnector ( {
54+ iconUrl : glyphConnectorDetails . iconUrl ,
55+ id : useStagingTenant ? STAGING_GLYPH_APP_ID : GLYPH_APP_ID ,
56+ name : glyphConnectorDetails . name ,
57+ } ) ( params ) ;
4258
43- const getGlyphProvider = async ( parameters ?: { chainId ?: number | undefined } | undefined ) => {
44- const chainId = parameters ?. chainId ?? params . chains ?. [ 0 ] ?. id ?? apechain . id ;
59+ const getGlyphProvider = async (
60+ parameters ?: { chainId ?: number | undefined } | undefined ,
61+ ) => {
62+ const chainId =
63+ parameters ?. chainId ?? params . chains ?. [ 0 ] ?. id ?? apeChain . id ;
4564
46- const provider = await connector . getProvider ( {
47- chainId
48- } ) ;
65+ const provider = await connector . getProvider ( {
66+ chainId,
67+ } ) ;
4968
50- return provider ;
51- } ;
69+ return provider ;
70+ } ;
5271
53- const glyphConnector = {
54- ...connector ,
55- getProvider : getGlyphProvider ,
56- type : glyphConnectorDetails . type ,
57- id : glyphConnectorDetails . id
58- } ;
59- return glyphConnector ;
72+ const glyphConnector = {
73+ ...connector ,
74+ getProvider : getGlyphProvider ,
75+ type : glyphConnectorDetails . type ,
76+ id : glyphConnectorDetails . id ,
6077 } ;
78+ return glyphConnector ;
79+ } ;
6180}
6281
6382/**
@@ -68,24 +87,37 @@ function glyphWalletConnector(options?: {
6887 * @example
6988 * ```tsx
7089 * import { createThirdwebClient } from "thirdweb";
71- * import { glyphWalletTW } from "@use-glyph/sdk-react "
90+ * import { glyphWalletTW } from "thirdweb/wallets/glyph "
7291 *
7392 * const client = createThirdwebClient({ clientId });
7493 *
7594 * <ConnectButton client={client} wallets=[glyphWalletTW()]>
7695 * ```
7796 */
78- const glyphWalletTW = ( chains ?: [ Chain , ...Chain [ ] ] ) : Wallet => {
79- const connector = glyphWalletConnector ( ) ( {
80- chains : chains ?? [ apeChain , curtis , mainnet , base , arbitrum , polygon , optimism , abstract , sepolia , baseSepolia , optimismSepolia , arbitrumSepolia ] ,
81- emitter : createEmitter ( "io.useglyph" )
82- } ) ;
83- return fromProvider ( {
84- provider : connector . getProvider as (
85- parameters ?: { chainId ?: number | undefined } | undefined
86- ) => Promise < EIP1193Provider > ,
87- walletId : "io.useglyph"
88- } ) ;
89- } ;
97+ function glyphWalletTW ( chains ?: [ Chain , ...Chain [ ] ] ) : Wallet {
98+ const connector = glyphWalletWagmiConnector ( ) ( {
99+ chains : chains ?? [
100+ apeChain ,
101+ curtis ,
102+ mainnet ,
103+ base ,
104+ arbitrum ,
105+ polygon ,
106+ optimism ,
107+ abstract ,
108+ sepolia ,
109+ baseSepolia ,
110+ optimismSepolia ,
111+ arbitrumSepolia ,
112+ ] ,
113+ emitter : createEmitter ( "io.useglyph" ) ,
114+ } ) ;
115+ return fromProvider ( {
116+ provider : connector . getProvider as (
117+ parameters ?: { chainId ?: number | undefined } | undefined ,
118+ ) => Promise < EIP1193Provider > ,
119+ walletId : "io.useglyph" ,
120+ } ) ;
121+ }
90122
91- export { glyphWalletTW } ;
123+ export { glyphWalletTW , glyphWalletWagmiConnector } ;
0 commit comments