-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
653 additions
and
1,368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as React from 'react'; | ||
import { type WalletClient, useWalletClient } from 'wagmi'; | ||
import { providers } from 'ethers'; | ||
|
||
export function walletClientToSigner(walletClient: WalletClient) { | ||
const { account, chain, transport } = walletClient; | ||
const network = { | ||
chainId: chain.id, | ||
name: chain.name, | ||
ensAddress: chain.contracts?.ensRegistry?.address, | ||
}; | ||
const provider = new providers.Web3Provider(transport, network); | ||
const signer = provider.getSigner(account.address); | ||
return signer; | ||
} | ||
|
||
/** Hook to convert a viem Wallet Client to an ethers.js Signer. */ | ||
export function useEthersSigner({ chainId }: { chainId?: number } = {}) { | ||
const { data: walletClient } = useWalletClient({ chainId }); | ||
return React.useMemo( | ||
() => (walletClient ? walletClientToSigner(walletClient) : undefined), | ||
[walletClient], | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "ES2020", | ||
"outDir": "dist/esm", | ||
"declarationDir": "dist/esm", | ||
"declaration": true | ||
"skipLibCheck": true, | ||
"target": "es6", | ||
"outDir": "dist/esm", | ||
"declarationDir": "dist/esm", | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "es2020", | ||
"moduleResolution": "Node", | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"incremental": true, | ||
"noUncheckedIndexedAccess": true, | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true, | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"allowJs": true, | ||
"declaration": true, | ||
"resolveJsonModule": true, | ||
"maxNodeModuleJsDepth": 0 | ||
} | ||
} |
Oops, something went wrong.