@meshconnect/uwc-core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/connection-manager.d.ts +18 -0
  2. package/dist/connection-manager.d.ts.map +1 -0
  3. package/dist/connection-manager.js +54 -0
  4. package/dist/connection-manager.js.map +1 -0
  5. package/dist/index.d.ts +4 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +4 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/managers/event-manager.d.ts +10 -0
  10. package/dist/managers/event-manager.d.ts.map +1 -0
  11. package/dist/managers/event-manager.js +19 -0
  12. package/dist/managers/event-manager.js.map +1 -0
  13. package/dist/managers/index.d.ts +3 -0
  14. package/dist/managers/index.d.ts.map +1 -0
  15. package/dist/managers/index.js +3 -0
  16. package/dist/managers/index.js.map +1 -0
  17. package/dist/managers/session-manager.d.ts +11 -0
  18. package/dist/managers/session-manager.d.ts.map +1 -0
  19. package/dist/managers/session-manager.js +36 -0
  20. package/dist/managers/session-manager.js.map +1 -0
  21. package/dist/services/connection-service.d.ts +24 -0
  22. package/dist/services/connection-service.d.ts.map +1 -0
  23. package/dist/services/connection-service.js +176 -0
  24. package/dist/services/connection-service.js.map +1 -0
  25. package/dist/services/index.d.ts +4 -0
  26. package/dist/services/index.d.ts.map +1 -0
  27. package/dist/services/index.js +4 -0
  28. package/dist/services/index.js.map +1 -0
  29. package/dist/services/network-switch-service.d.ts +20 -0
  30. package/dist/services/network-switch-service.d.ts.map +1 -0
  31. package/dist/services/network-switch-service.js +130 -0
  32. package/dist/services/network-switch-service.js.map +1 -0
  33. package/dist/services/signature-service.d.ts +18 -0
  34. package/dist/services/signature-service.d.ts.map +1 -0
  35. package/dist/services/signature-service.js +53 -0
  36. package/dist/services/signature-service.js.map +1 -0
  37. package/dist/services/transaction-service.d.ts +18 -0
  38. package/dist/services/transaction-service.d.ts.map +1 -0
  39. package/dist/services/transaction-service.js +53 -0
  40. package/dist/services/transaction-service.js.map +1 -0
  41. package/dist/universal-wallet-connector.d.ts +56 -0
  42. package/dist/universal-wallet-connector.d.ts.map +1 -0
  43. package/dist/universal-wallet-connector.js +302 -0
  44. package/dist/universal-wallet-connector.js.map +1 -0
  45. package/dist/utils/network-rpc-utils.d.ts +10 -0
  46. package/dist/utils/network-rpc-utils.d.ts.map +1 -0
  47. package/dist/utils/network-rpc-utils.js +20 -0
  48. package/dist/utils/network-rpc-utils.js.map +1 -0
  49. package/package.json +36 -0
  50. package/src/index.ts +3 -0
  51. package/src/managers/event-manager.ts +25 -0
  52. package/src/managers/index.ts +2 -0
  53. package/src/managers/session-manager.ts +43 -0
  54. package/src/services/connection-service.ts +248 -0
  55. package/src/services/index.ts +3 -0
  56. package/src/services/network-switch-service.ts +182 -0
  57. package/src/services/signature-service.ts +77 -0
  58. package/src/services/transaction-service.ts +79 -0
  59. package/src/universal-wallet-connector.ts +426 -0
  60. package/src/utils/network-rpc-utils.ts +27 -0
@@ -0,0 +1,43 @@
1
+ import type { Session, Network } from '@meshconnect/uwc-types'
2
+
3
+ export class SessionManager {
4
+ private session: Session = {
5
+ connectionMode: null,
6
+ activeWallet: null,
7
+ activeNetwork: null,
8
+ activeAddress: null,
9
+ availableNetworks: [],
10
+ availableAddresses: []
11
+ }
12
+
13
+ getSession(): Session {
14
+ return this.session
15
+ }
16
+
17
+ updateSession(updates: Partial<Session>): void {
18
+ this.session = { ...this.session, ...updates }
19
+ }
20
+
21
+ setActiveNetwork(network: Network | null): void {
22
+ this.session.activeNetwork = network
23
+ }
24
+
25
+ setActiveAddress(address: string | null): void {
26
+ this.session.activeAddress = address
27
+ }
28
+
29
+ setAvailableNetworks(networks: Network[]): void {
30
+ this.session.availableNetworks = networks
31
+ }
32
+
33
+ clearSession(): void {
34
+ this.session = {
35
+ connectionMode: null,
36
+ activeWallet: null,
37
+ activeNetwork: null,
38
+ activeAddress: null,
39
+ availableNetworks: [],
40
+ availableAddresses: []
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,248 @@
1
+ import type {
2
+ Network,
3
+ NetworkId,
4
+ WalletMetadata,
5
+ ConnectionMode,
6
+ Connector,
7
+ SupportedProvider,
8
+ ExtensionInjectedProvider,
9
+ IntegratedBrowserInjectedProvider,
10
+ WalletConnectProvider
11
+ } from '@meshconnect/uwc-types'
12
+ import type { SessionManager } from '../managers/session-manager'
13
+ import type { EventManager } from '../managers/event-manager'
14
+
15
+ export class ConnectionService {
16
+ private activeConnector: Connector | null = null
17
+
18
+ constructor(
19
+ private networks: Network[],
20
+ private wallets: WalletMetadata[],
21
+ private sessionManager: SessionManager,
22
+ private connectors: Map<ConnectionMode, Connector>,
23
+ private usingIntegratedBrowser: boolean,
24
+ private eventManager: EventManager
25
+ ) {}
26
+
27
+ async connect(
28
+ connectionMode: ConnectionMode,
29
+ walletId: string,
30
+ networkId?: NetworkId
31
+ ): Promise<void> {
32
+ // Find the wallet
33
+ const wallet = this.findWallet(walletId)
34
+
35
+ // Get the appropriate provider based on connection mode
36
+ const provider = this.getProviderForMode(wallet, connectionMode)
37
+
38
+ // Validate and determine the network
39
+ const network = this.validateAndDetermineNetwork(networkId, provider)
40
+
41
+ // Get the appropriate connector
42
+ const connector = this.getConnector(connectionMode)
43
+
44
+ // Store the active connector BEFORE starting connection
45
+ // This allows getConnectionURI to work while connection is in progress
46
+ this.activeConnector = connector
47
+
48
+ let result
49
+ if (connectionMode === 'injected') {
50
+ // For injected, pass the provider (which is ExtensionInjectedProvider | IntegratedBrowserInjectedProvider)
51
+ result = await connector.connect(
52
+ network,
53
+ provider as
54
+ | ExtensionInjectedProvider
55
+ | IntegratedBrowserInjectedProvider
56
+ )
57
+ } else if (connectionMode === 'walletConnect') {
58
+ // For WalletConnect, start connection and poll for URI
59
+ const connectPromise = connector.connect(
60
+ network,
61
+ provider as WalletConnectProvider
62
+ )
63
+
64
+ // Poll for URI and notify when it becomes available
65
+ const pollForURI = setInterval(() => {
66
+ const uri = this.getConnectionURI()
67
+ if (uri) {
68
+ clearInterval(pollForURI)
69
+ // Notify subscribers that URI is available
70
+ this.eventManager.notify()
71
+ }
72
+ }, 100) // Poll every 100ms
73
+
74
+ // Stop polling after 10 seconds
75
+ const timeoutId = setTimeout(() => {
76
+ clearInterval(pollForURI)
77
+ }, 10000)
78
+
79
+ try {
80
+ result = await connectPromise
81
+ } finally {
82
+ // Ensure cleanup happens regardless of success or failure
83
+ clearInterval(pollForURI)
84
+ clearTimeout(timeoutId)
85
+ }
86
+ } else {
87
+ throw new Error(`Unsupported connection mode: ${connectionMode}`)
88
+ }
89
+
90
+ // Filter available addresses to only include those for configured networks
91
+ const filteredAvailableAddresses = result.availableAddresses.filter(addr =>
92
+ this.networks.some(n => n.id === addr.networkId)
93
+ )
94
+
95
+ this.sessionManager.updateSession({
96
+ connectionMode,
97
+ activeWallet: wallet,
98
+ activeNetwork: network,
99
+ activeAddress: result.address,
100
+ availableNetworks: this.networks.filter(n =>
101
+ provider.supportedNetworkIds.includes(n.id)
102
+ ),
103
+ availableAddresses: filteredAvailableAddresses
104
+ })
105
+ }
106
+
107
+ private getConnector(connectionMode: ConnectionMode): Connector {
108
+ const connector = this.connectors.get(connectionMode)
109
+ if (!connector) {
110
+ throw new Error(
111
+ `No connector found for connection mode: ${connectionMode}`
112
+ )
113
+ }
114
+ return connector
115
+ }
116
+
117
+ private findWallet(walletId: string): WalletMetadata {
118
+ const wallet = this.wallets.find(w => w.id === walletId)
119
+ if (!wallet) {
120
+ throw new Error(`Wallet with id '${walletId}' not found`)
121
+ }
122
+ return wallet
123
+ }
124
+
125
+ private getProviderForMode(
126
+ wallet: WalletMetadata,
127
+ connectionMode: ConnectionMode
128
+ ): SupportedProvider {
129
+ let provider: SupportedProvider | undefined
130
+
131
+ if (connectionMode === 'injected') {
132
+ provider = this.usingIntegratedBrowser
133
+ ? wallet.integratedBrowserInjectedProvider
134
+ : wallet.extensionInjectedProvider
135
+
136
+ if (!provider) {
137
+ throw new Error(
138
+ this.usingIntegratedBrowser
139
+ ? `Wallet '${wallet.id}' does not have an integrated browser injected provider`
140
+ : `Wallet '${wallet.id}' does not have an extension injected provider`
141
+ )
142
+ }
143
+ } else if (connectionMode === 'walletConnect') {
144
+ provider = wallet.walletConnectProvider
145
+
146
+ if (!provider) {
147
+ throw new Error(
148
+ `Wallet '${wallet.id}' does not have a WalletConnect provider`
149
+ )
150
+ }
151
+ } else {
152
+ throw new Error(`Unsupported connection mode: ${connectionMode}`)
153
+ }
154
+
155
+ return provider
156
+ }
157
+
158
+ private validateAndDetermineNetwork(
159
+ networkId: NetworkId | undefined,
160
+ provider: SupportedProvider
161
+ ): Network {
162
+ let targetNetworkId: NetworkId
163
+
164
+ if (networkId) {
165
+ // Check if networkId is in the configured networks
166
+ const networkExists = this.networks.some(n => n.id === networkId)
167
+ if (!networkExists) {
168
+ throw new Error(
169
+ `Network ${networkId} is not in the configured networks`
170
+ )
171
+ }
172
+
173
+ // Check if networkId is supported by the wallet
174
+ const supportedByWallet = provider.supportedNetworkIds.includes(networkId)
175
+ if (!supportedByWallet) {
176
+ throw new Error(`Network ${networkId} is not supported by the wallet`)
177
+ }
178
+
179
+ targetNetworkId = networkId
180
+ } else {
181
+ // Use the first supported network that exists in both wallet and configured networks
182
+ const supportedNetwork = provider.supportedNetworkIds.find(id =>
183
+ this.networks.some(n => n.id === id)
184
+ )
185
+ if (!supportedNetwork) {
186
+ throw new Error(
187
+ 'No common supported network found between wallet and configured networks'
188
+ )
189
+ }
190
+ targetNetworkId = supportedNetwork
191
+ }
192
+
193
+ // Find and return the network object
194
+ const network = this.networks.find(n => n.id === targetNetworkId)
195
+ if (!network) {
196
+ throw new Error(
197
+ `Network ${targetNetworkId} not found in configured networks`
198
+ )
199
+ }
200
+ return network
201
+ }
202
+
203
+ async disconnect(): Promise<void> {
204
+ // If there's an active connector with a disconnect method, call it
205
+ if (
206
+ this.activeConnector &&
207
+ typeof this.activeConnector.disconnect === 'function'
208
+ ) {
209
+ await this.activeConnector.disconnect()
210
+ }
211
+
212
+ // Clear the active connector
213
+ this.activeConnector = null
214
+
215
+ // Clear the session state
216
+ this.sessionManager.clearSession()
217
+ }
218
+
219
+ getConnectionURI(): string | undefined {
220
+ // Only WalletConnect connector has getConnectionURI method
221
+ if (
222
+ this.activeConnector &&
223
+ typeof this.activeConnector.getConnectionURI === 'function'
224
+ ) {
225
+ try {
226
+ const uri = this.activeConnector.getConnectionURI()
227
+ return uri
228
+ } catch {
229
+ // If there's no URI available yet, return undefined
230
+ return undefined
231
+ }
232
+ }
233
+
234
+ return undefined
235
+ }
236
+
237
+ getWallets(): WalletMetadata[] {
238
+ return this.wallets
239
+ }
240
+
241
+ updateWallets(wallets: WalletMetadata[]): void {
242
+ this.wallets = wallets
243
+ }
244
+
245
+ getNetworks(): Network[] {
246
+ return this.networks
247
+ }
248
+ }
@@ -0,0 +1,3 @@
1
+ export * from './connection-service'
2
+ export * from './signature-service'
3
+ export * from './transaction-service'
@@ -0,0 +1,182 @@
1
+ import type {
2
+ Network,
3
+ NetworkId,
4
+ Connector,
5
+ ConnectionMode,
6
+ SupportedProvider,
7
+ WalletMetadata,
8
+ ExtensionInjectedProvider,
9
+ IntegratedBrowserInjectedProvider,
10
+ WalletConnectProvider
11
+ } from '@meshconnect/uwc-types'
12
+ import type { SessionManager } from '../managers/session-manager'
13
+ import type { EventManager } from '../managers/event-manager'
14
+
15
+ export class NetworkSwitchService {
16
+ private isLoading = false
17
+ private isWaitingForUserApproval = false
18
+
19
+ constructor(
20
+ private networks: Network[],
21
+ private sessionManager: SessionManager,
22
+ private connectors: Map<ConnectionMode, Connector>,
23
+ private usingIntegratedBrowser: boolean,
24
+ private eventManager: EventManager
25
+ ) {}
26
+
27
+ getLoadingState() {
28
+ return {
29
+ isLoading: this.isLoading,
30
+ isWaitingForUserApproval: this.isWaitingForUserApproval
31
+ }
32
+ }
33
+
34
+ async switchNetwork(networkId: NetworkId): Promise<void> {
35
+ // Check if there's an active connection
36
+ const session = this.sessionManager.getSession()
37
+ if (!session) {
38
+ throw new Error('No active connection. Connect to a wallet first.')
39
+ }
40
+
41
+ // Find the network
42
+ const network = this.networks.find(n => n.id === networkId)
43
+ if (!network) {
44
+ throw new Error(`Network with id '${networkId}' not found`)
45
+ }
46
+
47
+ // Check if the network is supported by the current wallet
48
+ const currentWallet = session.activeWallet
49
+ if (!currentWallet) {
50
+ throw new Error('No active wallet found in session')
51
+ }
52
+
53
+ // Check if connection mode is set
54
+ if (!session.connectionMode) {
55
+ throw new Error('No connection mode found in session')
56
+ }
57
+
58
+ // Get the provider for the current connection mode
59
+ let provider: SupportedProvider | undefined
60
+
61
+ if (session.connectionMode === 'injected') {
62
+ provider = this.usingIntegratedBrowser
63
+ ? currentWallet.integratedBrowserInjectedProvider
64
+ : currentWallet.extensionInjectedProvider
65
+ } else if (session.connectionMode === 'walletConnect') {
66
+ provider = currentWallet.walletConnectProvider
67
+ }
68
+
69
+ if (!provider) {
70
+ throw new Error(
71
+ `Wallet '${currentWallet.id}' does not have a provider for ${session.connectionMode} mode`
72
+ )
73
+ }
74
+
75
+ // Validate the network is supported by the wallet
76
+ if (!provider.supportedNetworkIds.includes(networkId)) {
77
+ throw new Error(
78
+ `Network ${networkId} is not supported by the current wallet`
79
+ )
80
+ }
81
+
82
+ // Get the active connector
83
+ const activeConnector = this.connectors.get(session.connectionMode)
84
+
85
+ // Check if the connector supports network switching
86
+ if (
87
+ !activeConnector ||
88
+ typeof activeConnector.switchNetwork !== 'function'
89
+ ) {
90
+ throw new Error('Current connector does not support network switching')
91
+ }
92
+
93
+ // Determine if user approval is required based on wallet metadata
94
+ const requiresApproval = this.checkIfApprovalRequired(
95
+ currentWallet,
96
+ network,
97
+ session.activeNetwork
98
+ )
99
+
100
+ try {
101
+ // Set loading states
102
+ this.isLoading = true
103
+ this.isWaitingForUserApproval = requiresApproval
104
+ this.eventManager.notify()
105
+
106
+ // Perform the network switch and get the new address
107
+ // Pass the appropriate provider based on connection mode
108
+ let result
109
+ if (session.connectionMode === 'injected' && provider) {
110
+ result = await activeConnector.switchNetwork(
111
+ network,
112
+ provider as
113
+ | ExtensionInjectedProvider
114
+ | IntegratedBrowserInjectedProvider
115
+ )
116
+ } else if (session.connectionMode === 'walletConnect' && provider) {
117
+ result = await activeConnector.switchNetwork(
118
+ network,
119
+ provider as WalletConnectProvider
120
+ )
121
+ } else {
122
+ result = await activeConnector.switchNetwork(network)
123
+ }
124
+
125
+ // Update the session with the new network, address, and available addresses
126
+ this.sessionManager.updateSession({
127
+ activeNetwork: network,
128
+ activeAddress: result.address,
129
+ ...(result.availableAddresses && {
130
+ availableAddresses: result.availableAddresses
131
+ })
132
+ })
133
+ } finally {
134
+ // Clear loading states
135
+ this.isLoading = false
136
+ this.isWaitingForUserApproval = false
137
+ this.eventManager.notify()
138
+ }
139
+ }
140
+
141
+ private checkIfApprovalRequired(
142
+ wallet: WalletMetadata,
143
+ targetNetwork: Network,
144
+ currentNetwork: Network | null
145
+ ): boolean {
146
+ if (!currentNetwork) return false
147
+
148
+ // Check if switching between different namespaces
149
+ const isNamespaceSwitch =
150
+ currentNetwork.namespace !== targetNetwork.namespace
151
+
152
+ // Get the provider to check metadata
153
+ const provider = this.usingIntegratedBrowser
154
+ ? wallet.integratedBrowserInjectedProvider
155
+ : wallet.extensionInjectedProvider
156
+
157
+ if (!provider) return false
158
+
159
+ // Check if namespace switch requires approval
160
+ if (isNamespaceSwitch && provider.requiresUserApprovalOnNamespaceSwitch) {
161
+ return true
162
+ }
163
+
164
+ // Check if network switch within same namespace requires approval
165
+ if (
166
+ !isNamespaceSwitch &&
167
+ provider.namespaceMetaData?.[targetNetwork.namespace]
168
+ ) {
169
+ const namespaceData = provider.namespaceMetaData[targetNetwork.namespace]
170
+ // Only EIP155 networks have the requiresUserApprovalOnNetworkSwitch property
171
+ if (
172
+ namespaceData &&
173
+ targetNetwork.namespace === 'eip155' &&
174
+ 'requiresUserApprovalOnNetworkSwitch' in namespaceData
175
+ ) {
176
+ return namespaceData.requiresUserApprovalOnNetworkSwitch || false
177
+ }
178
+ }
179
+
180
+ return false
181
+ }
182
+ }
@@ -0,0 +1,77 @@
1
+ import type {
2
+ ConnectionMode,
3
+ Connector,
4
+ ExtensionInjectedProvider,
5
+ IntegratedBrowserInjectedProvider,
6
+ WalletConnectProvider,
7
+ SupportedProvider
8
+ } from '@meshconnect/uwc-types'
9
+ import type { SessionManager } from '../managers/session-manager'
10
+
11
+ /**
12
+ * Service for handling signature operations across different connector types
13
+ */
14
+ export class SignatureService {
15
+ constructor(
16
+ private sessionManager: SessionManager,
17
+ private connectors: Map<ConnectionMode, Connector>
18
+ ) {}
19
+
20
+ /**
21
+ * Sign a message with the currently connected wallet
22
+ * @param message The message to sign
23
+ * @param provider The wallet provider to use for signing (required for injected connector)
24
+ * @returns A promise that resolves to the signature
25
+ */
26
+ async signMessage(
27
+ message: string,
28
+ provider?: SupportedProvider
29
+ ): Promise<string> {
30
+ const session = this.sessionManager.getSession()
31
+
32
+ if (!session.connectionMode) {
33
+ throw new Error('No active connection')
34
+ }
35
+
36
+ if (!session.activeAddress) {
37
+ throw new Error('No active wallet address')
38
+ }
39
+
40
+ // Get the appropriate connector
41
+ const connector = this.connectors.get(session.connectionMode)
42
+ if (!connector) {
43
+ throw new Error(
44
+ `No connector found for connection mode: ${session.connectionMode}`
45
+ )
46
+ }
47
+
48
+ // Check if the connector supports signing
49
+ if (!connector.signMessage) {
50
+ throw new Error(`Connector does not support message signing`)
51
+ }
52
+
53
+ // Call the connector's signMessage method with the appropriate provider
54
+ if (session.connectionMode === 'injected') {
55
+ if (!provider) {
56
+ throw new Error('Provider is required for injected connector')
57
+ }
58
+ return await connector.signMessage(
59
+ message,
60
+ provider as
61
+ | ExtensionInjectedProvider
62
+ | IntegratedBrowserInjectedProvider
63
+ )
64
+ } else if (session.connectionMode === 'walletConnect') {
65
+ if (!provider) {
66
+ throw new Error('Provider is required for WalletConnect connector')
67
+ }
68
+ return await connector.signMessage(
69
+ message,
70
+ provider as WalletConnectProvider
71
+ )
72
+ } else {
73
+ // For other connectors that might not need the provider
74
+ return await connector.signMessage(message)
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,79 @@
1
+ import type {
2
+ ConnectionMode,
3
+ Connector,
4
+ ExtensionInjectedProvider,
5
+ IntegratedBrowserInjectedProvider,
6
+ WalletConnectProvider,
7
+ SupportedProvider,
8
+ TransactionRequest,
9
+ TransactionResult
10
+ } from '@meshconnect/uwc-types'
11
+ import type { SessionManager } from '../managers/session-manager'
12
+
13
+ /**
14
+ * Service for handling transaction operations across different connector types
15
+ */
16
+ export class TransactionService {
17
+ constructor(
18
+ private sessionManager: SessionManager,
19
+ private connectors: Map<ConnectionMode, Connector>
20
+ ) {}
21
+
22
+ /**
23
+ * Send a transaction with the currently connected wallet
24
+ * @param request The transaction request parameters
25
+ * @param provider The wallet provider to use for sending (required for injected connector)
26
+ * @returns A promise that resolves to the transaction result
27
+ */
28
+ async sendTransaction(
29
+ request: TransactionRequest,
30
+ provider?: SupportedProvider
31
+ ): Promise<TransactionResult> {
32
+ const session = this.sessionManager.getSession()
33
+
34
+ if (!session.connectionMode) {
35
+ throw new Error('No active connection')
36
+ }
37
+
38
+ if (!session.activeAddress) {
39
+ throw new Error('No active wallet address')
40
+ }
41
+
42
+ // Get the appropriate connector
43
+ const connector = this.connectors.get(session.connectionMode)
44
+ if (!connector) {
45
+ throw new Error(
46
+ `No connector found for connection mode: ${session.connectionMode}`
47
+ )
48
+ }
49
+
50
+ // Check if the connector supports transactions
51
+ if (!connector.sendTransaction) {
52
+ throw new Error(`Connector does not support transactions`)
53
+ }
54
+
55
+ // Call the connector's sendTransaction method with the appropriate provider
56
+ if (session.connectionMode === 'injected') {
57
+ if (!provider) {
58
+ throw new Error('Provider is required for injected connector')
59
+ }
60
+ return await connector.sendTransaction(
61
+ request,
62
+ provider as
63
+ | ExtensionInjectedProvider
64
+ | IntegratedBrowserInjectedProvider
65
+ )
66
+ } else if (session.connectionMode === 'walletConnect') {
67
+ if (!provider) {
68
+ throw new Error('Provider is required for WalletConnect connector')
69
+ }
70
+ return await connector.sendTransaction(
71
+ request,
72
+ provider as WalletConnectProvider
73
+ )
74
+ } else {
75
+ // For other connectors that might not need the provider
76
+ return await connector.sendTransaction(request)
77
+ }
78
+ }
79
+ }