Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Viem utils #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SebastienGllmt opened this issue Jan 17, 2024 · 0 comments
Open

Viem utils #287

SebastienGllmt opened this issue Jan 17, 2024 · 0 comments
Milestone

Comments

@SebastienGllmt
Copy link
Contributor

SebastienGllmt commented Jan 17, 2024

It might be good to have a viem utils package that provides things like an auto-populated defineChain object based on your Paima .env file (todo: do we need anything else?)

Since Viem has its own wallet type and provider type, probably this should go in @paima/providers. I'm not sure if we want this to be separate from the EthersProvider, or if we want a separate "PrivateKey" type that can be turned into an EthersProvider or a Viem provider (but such an option may be difficult to compose with things like the Thirdweb SDK)

In other words, we need 3 things:

  1. A wrapper for defineChain that gets the Paima env variables and falls back to the viem built-in definition if one exists for the chain id
  2. A wrapper for createPublicClient
  3. A wrapper for createWalletClient

Since wagmi uses Viem under the hood, we can use these Viem definitions for a wagmi lib as well (see #292 for more)

const config = createConfig({
  chains: [paimaChain], // use Viem chain definition as-is
  client() {
    return paimaPublicClient; // use Viem public client definition
  },
})
This was referenced Jan 22, 2024
@SebastienGllmt SebastienGllmt added this to the DevX milestone Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant