Skip to content

Commit bd2808c

Browse files
committed
chore: update types for custom wagmi connectors
1 parent 3498a4b commit bd2808c

File tree

2 files changed

+17
-27
lines changed

2 files changed

+17
-27
lines changed

packages/adapters/wagmi/src/connectors/AuthConnector.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,8 @@ export type AuthParameters = {
3636
export function authConnector(parameters: AuthParameters) {
3737
let currentAccounts: Address[] = []
3838
let socialProvider: W3mFrameProvider | undefined = undefined
39-
let connectSocialPromise:
40-
| Promise<{
41-
accounts: Address[]
42-
account: Address
43-
chainId: number
44-
chain: {
45-
id: number
46-
unsuported: boolean
47-
}
48-
}>
49-
| undefined = undefined
39+
let connectSocialPromise: Promise<Awaited<ReturnType<typeof connectSocial>>> | undefined =
40+
undefined
5041
type Properties = {
5142
provider?: W3mFrameProvider
5243
getProvider(): Promise<W3mFrameProvider>
@@ -132,7 +123,7 @@ export function authConnector(parameters: AuthParameters) {
132123
chainId: parsedChainId,
133124
chain: {
134125
id: parsedChainId,
135-
unsuported: false
126+
unsupported: false
136127
}
137128
}
138129
}
@@ -173,7 +164,6 @@ export function authConnector(parameters: AuthParameters) {
173164
const result = await connectSocialPromise
174165
connectSocialPromise = undefined
175166

176-
// Return shape per wagmi connector contract
177167
return {
178168
accounts: (options.withCapabilities
179169
? (result.accounts.map(address => ({ address, capabilities: {} })) as unknown)

packages/adapters/wagmi/src/connectors/WalletConnectConnector.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
8282
name: 'WalletConnect',
8383
type: walletConnect.type,
8484

85-
async setup(this: Properties) {
85+
async setup() {
8686
const provider = await this.getProvider().catch(() => null)
8787
if (!provider) {
8888
return
@@ -205,7 +205,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
205205
throw error
206206
}
207207
},
208-
async disconnect(this: Properties) {
208+
async disconnect() {
209209
const provider = await this.getProvider()
210210
try {
211211
await provider?.disconnect()
@@ -302,7 +302,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
302302

303303
return network?.id as number
304304
},
305-
async isAuthorized(this: Properties) {
305+
async isAuthorized() {
306306
try {
307307
const [accounts, provider] = await Promise.all([this.getAccounts(), this.getProvider()])
308308

@@ -326,7 +326,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
326326
return false
327327
}
328328
},
329-
async switchChain(this: Properties, { addEthereumChainParameter, chainId }) {
329+
async switchChain({ addEthereumChainParameter, chainId }) {
330330
const provider = await this.getProvider()
331331
if (!provider) {
332332
throw new ProviderNotFoundError()
@@ -397,7 +397,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
397397
}
398398
}
399399
},
400-
onAccountsChanged(this: Properties, accounts) {
400+
onAccountsChanged(accounts) {
401401
if (accounts.length === 0) {
402402
this.onDisconnect()
403403
} else {
@@ -406,15 +406,15 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
406406
})
407407
}
408408
},
409-
onChainChanged(this: Properties, chain) {
409+
onChainChanged(chain) {
410410
const chainId = Number(chain)
411411

412412
config.emitter.emit('change', { chainId })
413413
},
414-
onConnect(this: Properties, _connectInfo) {
414+
onConnect(_connectInfo) {
415415
this.setRequestedChainsIds(ChainController.getCaipNetworks().map(x => Number(x.id)))
416416
},
417-
async onDisconnect(this: Properties, _error) {
417+
async onDisconnect(_error) {
418418
this.setRequestedChainsIds([])
419419
config.emitter.emit('disconnect')
420420

@@ -440,13 +440,13 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
440440
provider.on('connect', connect)
441441
}
442442
},
443-
onDisplayUri(this: Properties, uri) {
443+
onDisplayUri(uri) {
444444
config.emitter.emit('message', { type: 'display_uri', data: uri })
445445
},
446-
onSessionDelete(this: Properties) {
446+
onSessionDelete() {
447447
this.onDisconnect()
448448
},
449-
getNamespaceChainsIds(this: Properties) {
449+
getNamespaceChainsIds() {
450450
if (!provider_?.session?.namespaces) {
451451
return []
452452
}
@@ -459,7 +459,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
459459
return chainIds
460460
},
461461

462-
async getRequestedChainsIds(this: Properties) {
462+
async getRequestedChainsIds() {
463463
const chainIds = (await config.storage?.getItem(this.requestedChainsStorageKey)) ?? []
464464

465465
return [...new Set(chainIds)]
@@ -475,7 +475,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
475475
* connector later on, however, this chain will not have been approved or rejected
476476
* by the wallet. In this case, the chain is considered stale.
477477
*/
478-
async isChainsStale(this: Properties) {
478+
async isChainsStale() {
479479
if (!isNewChainsStale) {
480480
return false
481481
}
@@ -493,7 +493,7 @@ export function walletConnect(parameters: AppKitOptionsParams, appKit: AppKit) {
493493
return !connectorChains.every(id => requestedChains.includes(Number(id)))
494494
},
495495

496-
async setRequestedChainsIds(this: Properties, chains) {
496+
async setRequestedChainsIds(chains) {
497497
await config.storage?.setItem(this.requestedChainsStorageKey, chains)
498498
},
499499

0 commit comments

Comments
 (0)