Skip to content

Commit

Permalink
typings
Browse files Browse the repository at this point in the history
  • Loading branch information
SamueleA committed Feb 13, 2024
1 parent e42ee79 commit bcd510a
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.3.3",
"viem": "^2.7.8",
"viem": "^2.5.7",
"wagmi": "^2.5.7"
},
"devDependencies": {
Expand Down
9 changes: 6 additions & 3 deletions examples/react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import { KitWalletProvider } from '@0xsequence/kit-wallet'
import { KitCheckoutProvider } from '@0xsequence/kit-checkout'
import Homepage from './components/Homepage'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { type Chain } from 'viem'
import { createConfig, http, WagmiProvider } from 'wagmi'
import { mainnet, polygon, Chain } from 'wagmi/chains'
import { mainnet, polygon } from 'wagmi/chains'

import '@0xsequence/design-system/styles.css'

Expand All @@ -20,7 +21,8 @@ function App() {
const { debug } = qs.parse(location.search)
const isDebugMode = debug === 'true'

const chains = [mainnet, polygon] as [Chain, ...Chain[]]
/* typing error from wagmi? */
const chains: readonly [Chain, ...Chain[]] = [mainnet as Chain, polygon as Chain]

const projectAccessKey = 'iK0DPkHRt0IFo8o4M3fZIIOAAAAAAAAAA'

Expand Down Expand Up @@ -53,8 +55,9 @@ function App() {

const config = createConfig({
transports,
chains,
/* @ts-ignore-next-line */
connectors,
chains
})

const kitConfig: KitConfig = {
Expand Down
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/apple/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export const apple = (options: AppleOptions) => ({
}
});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export const coinbaseWallet = (params: CoinbaseWalletParameters) => ({
createConnector: (() => {
const connector = coinbaseWalletBase({...params});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/discord/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export const discord = (options: DiscordOptions) => ({
}
});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/email/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ export const email = (options: EmailOptions) => ({
});

return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/facebook/facebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export const facebook = (options: FacebookOptions) => ({
}
});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/google/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export const google = (options: GoogleOptions) => ({
}
});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/mock/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export const mock = (options: MockParameters) => ({
createConnector: (() => {
const connector = mockBase(options);
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/sequence/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export const sequence = (options: SequenceOptions) => ({
...options,
});
return connector
}) as CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
2 changes: 1 addition & 1 deletion packages/connectors/src/connectors/twitch/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export const twitch = (options: TwitchOptions) => ({
}
});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ export function sequenceWallet(params: BaseSequenceConnectorOptions) {
async setup() {
const provider = await this.getProvider()
provider.on('chainChanged', (chainIdHex: string) => {
// @ts-ignore-next-line
config.emitter.emit('change', { chain: { id: normalizeChainId(chainIdHex), unsupported: false } })
})

provider.on('accountsChanged', (accounts: string[]) => {
// @ts-ignore-next-line
config.emitter.emit('accountsChanged', this.onAccountsChanged(accounts))
config.emitter.emit('change', { chainId: normalizeChainId(chainIdHex) })
})

provider.on('disconnect', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const walletConnect = (options: WalletConnectParameters) => ({
...options,
});
return connector
}) as () => CreateConnectorFn<any, any, any>
}) as () => CreateConnectorFn
})
3 changes: 1 addition & 2 deletions packages/connectors/src/defaultConnectors.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Chain } from 'wagmi/chains'
import { CreateConnectorFn } from 'wagmi'
import { getKitConnectWallets } from '@0xsequence/kit'

Expand Down Expand Up @@ -26,7 +25,7 @@ export const getDefaultConnectors = ({
defaultChainId,
projectAccessKey,
appName,
}: GetDefaultConnectors): CreateConnectorFn<any, any, any>[] => {
}: GetDefaultConnectors): CreateConnectorFn[] => {
const connectors = getKitConnectWallets(projectAccessKey, [
coinbaseWallet({
appName
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"ethers": "5.7.2",
"0xsequence": "^1.8.2",
"viem": "^2.7.8",
"viem": "^2.5.7",
"wagmi": "^2.5.7"
},
"files": [
Expand Down
8 changes: 4 additions & 4 deletions packages/kit/src/utils/getKitConnectWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ export interface WalletProperties {
}

export type Wallet = WalletProperties & {
createConnector: () => CreateConnectorFn<any, any, any>
createConnector: () => CreateConnectorFn
}

export interface WalletField {
_wallet: WalletProperties
}

export type ExtendedConnector = CreateConnectorFn<any, any, any> & WalletField
export type ExtendedConnector = CreateConnectorFn & WalletField

export const getKitConnectWallets = (projectAccessKey:string, wallets: any[]): CreateConnectorFn<any, any, any>[] => {
export const getKitConnectWallets = (projectAccessKey:string, wallets: any[]): CreateConnectorFn[] => {
localStorage.setItem(LocalStorageKey.ProjectAccessKey, projectAccessKey)

const connectors: CreateConnectorFn<any, any, any>[] = []
const connectors: CreateConnectorFn[] = []

// hide connector if there is an identical injected wallet
const injectedWallet = wallets.find(connector => connector.id === 'injected')
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bcd510a

Please sign in to comment.