Skip to content

Commit a809e59

Browse files
committed
[SDK] Feature: Export Glyph Wallet Connectors. Some Refactoring and AI Feedback Resolution.
1 parent a77a74f commit a809e59

File tree

8 files changed

+103
-60
lines changed

8 files changed

+103
-60
lines changed

.changeset/six-zebras-move.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
2-
"thirdweb": patch
2+
"thirdweb": minor
33
---
44

5-
Added Glyph Wallet Connector to CreateWallet function
5+
Add Glyph wallet connector to `createWallet`, export the connector and also export new chains:
6+
7+
- `apechain` (mainnet)
8+
- `curtis` (testnet)

packages/thirdweb/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"@noble/curves": "1.8.2",
1818
"@noble/hashes": "1.7.2",
1919
"@passwordless-id/webauthn": "^2.1.2",
20-
"@privy-io/cross-app-connect": ">=0.2.3",
20+
"@privy-io/cross-app-connect": "^0.2.3",
2121
"@radix-ui/react-dialog": "1.1.14",
2222
"@radix-ui/react-focus-scope": "1.1.7",
2323
"@radix-ui/react-icons": "1.3.2",
@@ -26,7 +26,7 @@
2626
"@tanstack/react-query": "5.81.5",
2727
"@thirdweb-dev/engine": "workspace:*",
2828
"@thirdweb-dev/insight": "workspace:*",
29-
"@wagmi/core": ">=2.17.2",
29+
"@wagmi/core": "^2.17.2",
3030
"@walletconnect/sign-client": "2.20.1",
3131
"@walletconnect/universal-provider": "2.21.4",
3232
"abitype": "1.0.8",

packages/thirdweb/src/chains/chain-definitions/apechain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export const apechain = /* @__PURE__ */ defineChain({
1313
id: 33139,
1414
name: "Ape Chain",
1515
nativeCurrency: {
16-
name: 'ApeCoin',
17-
symbol: 'APE',
16+
name: "ApeCoin",
17+
symbol: "APE",
1818
decimals: 18,
1919
},
2020
});

packages/thirdweb/src/chains/chain-definitions/curtis.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defineChain } from "../utils.js";
22

33
/**
44
* @chain
5+
* Curtis test network (Ape Chain testnet variant).
56
*/
67
export const curtis = /* @__PURE__ */ defineChain({
78
blockExplorers: [
@@ -12,6 +13,6 @@ export const curtis = /* @__PURE__ */ defineChain({
1213
],
1314
id: 33_111,
1415
name: "Curtis",
15-
nativeCurrency: { name: 'ApeCoin', symbol: 'APE', decimals: 18 },
16+
nativeCurrency: { name: "ApeCoin", symbol: "APE", decimals: 18 },
1617
testnet: true,
1718
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export {
2+
glyphWalletTW,
3+
glyphWalletWagmiConnector,
4+
} from "../../wallets/glyph/glyph-wallet.js";
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
export const STAGING_GLYPH_APP_ID = 'clxt9p8e601al6tgmsyhu7j3t';
2-
export const GLYPH_APP_ID = 'cly38x0w10ac945q9yg9sm71i';
3-
export const GLYPH_ICON_URL = 'https://i.ibb.co/TxcwPQyr/Group-12489-1.png';
1+
/** Staging tenant id for Glyph Cross-App Connect. @internal */
2+
export const STAGING_GLYPH_APP_ID = "clxt9p8e601al6tgmsyhu7j3t";
3+
/** Production tenant id for Glyph Cross-App Connect. @internal */
4+
export const GLYPH_APP_ID = "cly38x0w10ac945q9yg9sm71i";
5+
/** Icon used in connectors & UIs. @internal */
6+
export const GLYPH_ICON_URL = "https://i.ibb.co/TxcwPQyr/Group-12489-1.png";
47

58
export const glyphConnectorDetails = {
6-
id: 'io.useglyph.privy',
7-
name: 'Glyph',
9+
id: "io.useglyph.privy",
10+
name: "Glyph",
811
iconUrl: GLYPH_ICON_URL,
9-
iconBackground: '#ffffff',
10-
shortName: 'Glyph',
11-
type: 'injected',
12+
iconBackground: "#ffffff",
13+
shortName: "Glyph",
14+
type: "injected",
1215
} as const;
Lines changed: 75 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
import { toPrivyWalletConnector } from "@privy-io/cross-app-connect/rainbow-kit";
22
import type { CreateConnectorFn } from "@wagmi/core";
33
import { 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";
419
import { 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";
725
import 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 };

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)