Skip to content
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

Create GenLayer client like viem examples #30

Open
AgustinRamiroDiaz opened this issue Nov 21, 2024 · 0 comments
Open

Create GenLayer client like viem examples #30

AgustinRamiroDiaz opened this issue Nov 21, 2024 · 0 comments

Comments

@AgustinRamiroDiaz
Copy link
Contributor

AgustinRamiroDiaz commented Nov 21, 2024

Viem has examples for many clients in their public repo

Which seem to compile without the as unknown patch that we do

// Extend Viem client to work with GenLayer-specific chains (simulator, testnet, etc.)
export const createClient = (config: ClientConfig = {chain: simulator}) => {
// Determine the RPC URL based on the provided configuration or default to the simulator's RPC UR
const chainConfig = config.chain || simulator;
const rpcUrl = config.endpoint || chainConfig.rpcUrls.default.http[0];
// Create a Viem client connected to the GenLayer Simulator (or custom chain)
const baseClient = createViemClient({
chain: chainConfig,
transport: http(rpcUrl),
...(config.account ? {account: config.account} : {}),
})
.extend(publicActions)
.extend(client => accountActions(client as unknown as GenLayerClient<SimulatorChain>))
.extend(client => transactionActions(client as unknown as GenLayerClient<SimulatorChain>))
.extend(client => contractActions(client as unknown as GenLayerClient<SimulatorChain>));
const genLayerClient = overrideContractActions(baseClient as unknown as GenLayerClient<SimulatorChain>);

We should follow a similar approach so that we have better TypeScript usage

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