-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from turbo-eth/feat/add-gelato-integration
Feat: Add gelato integration
- Loading branch information
Showing
67 changed files
with
11,674 additions
and
1,539 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
**/generated/**-wagmi.ts | ||
**/generated/blockchain.ts | ||
**/components/shared/table/** | ||
**/components/shared/table/** | ||
**/generated | ||
.next/** |
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,5 +1,6 @@ | ||
**/generated/**-wagmi.ts | ||
**/generated/blockchain.ts | ||
**/generated/ | ||
|
||
.next/** | ||
.husky/** | ||
|
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,26 @@ | ||
import { useMemo } from 'react' | ||
|
||
import { providers } from 'ethers' | ||
import { type HttpTransport } from 'viem' | ||
import { type PublicClient, usePublicClient } from 'wagmi' | ||
|
||
export function publicClientToProvider(publicClient: PublicClient) { | ||
const { chain, transport } = publicClient | ||
const network = { | ||
chainId: chain.id, | ||
name: chain.name, | ||
ensAddress: chain.contracts?.ensRegistry?.address, | ||
} | ||
if (transport.type === 'fallback') | ||
return new providers.FallbackProvider( | ||
(transport.transports as ReturnType<HttpTransport>[]).map(({ value }) => new providers.JsonRpcProvider(value?.url, network)) | ||
) | ||
|
||
return new providers.JsonRpcProvider(transport.url as string, network) | ||
} | ||
|
||
/** Hook to convert a viem Public Client to an ethers.js Provider. */ | ||
export function useEthersProvider({ chainId }: { chainId?: number } = {}) { | ||
const publicClient = usePublicClient({ chainId }) | ||
return useMemo(() => publicClientToProvider(publicClient), [publicClient]) | ||
} |
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,22 @@ | ||
import { useMemo } from 'react' | ||
|
||
import { providers } from 'ethers' | ||
import { type WalletClient, useWalletClient } from 'wagmi' | ||
|
||
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 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
Oops, something went wrong.