Skip to content

Commit

Permalink
remove resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
shazarre committed Oct 17, 2024
1 parent 0fb571b commit 754c5ce
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions packages/cli/src/viem.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { Command } from '@oclif/core'
import { createPublicClient, extractChain, http, HttpTransport, PublicClient } from 'viem'
import { celo, celoAlfajores } from 'viem/chains'
import { ContractAddressResolver, ViemAddressResolver } from './packages-to-be/address-resolver'
import { L2Resolver, ViemL2Resolver } from './packages-to-be/l2-resolver'
import { getNodeUrl } from './utils/config'

export abstract class ViemCommand extends Command {
protected requireSynced = true

// Indicates if celocli running in L2 context
private cel2: boolean | null = null

private publicClient?: PublicClient<HttpTransport, typeof celo>
private addressResolver?: ContractAddressResolver
private l2Resolver?: L2Resolver

protected async getPublicClient(): Promise<PublicClient<HttpTransport, typeof celo>> {
if (!this.publicClient) {
Expand All @@ -37,43 +30,13 @@ export abstract class ViemCommand extends Command {
return this.publicClient
}

protected async getAddressResolver(): Promise<ContractAddressResolver> {
if (!this.addressResolver) {
this.addressResolver = new ViemAddressResolver(await this.getPublicClient())
}

return this.addressResolver
}

protected async getL2Resolver(): Promise<L2Resolver> {
if (!this.l2Resolver) {
this.l2Resolver = new ViemL2Resolver(await this.getPublicClient())
}

return this.l2Resolver
}

protected async checkIfSynced(): Promise<boolean> {
return true
}

protected async checkIfL2(): Promise<boolean> {
const l2Resolver = await this.getL2Resolver()

return l2Resolver.resolve()
}

protected async getNodeUrl(): Promise<string> {
const res = await this.parse()

return (res.flags && res.flags.node) || getNodeUrl(this.config.configDir)
}

protected async isCel2(): Promise<boolean> {
if (this.cel2 === null) {
this.cel2 = await this.checkIfL2()
}

return !!this.cel2
}
}

0 comments on commit 754c5ce

Please sign in to comment.