Skip to content

Commit

Permalink
fix: ChainConnectorEvm constructor params
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm committed Nov 14, 2023
1 parent 60dd662 commit 65df14a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apps/extension/src/core/rpcs/chain-connector-evm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chaindataProvider } from "@core/rpcs/chaindata"
import { ChainConnectorEvm } from "@talismn/chain-connector-evm"

export const chainConnectorEvm = new ChainConnectorEvm(chaindataProvider, chaindataProvider)
export const chainConnectorEvm = new ChainConnectorEvm(chaindataProvider)
17 changes: 7 additions & 10 deletions packages/chain-connector-evm/src/ChainConnectorEvm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ export type ChainConnectorEvmOptions = {
}

export class ChainConnectorEvm {
#chaindataEvmNetworkProvider: ChaindataEvmNetworkProvider
#chaindataTokenProvider: ChaindataTokenProvider
#chaindataProvider: ChaindataEvmNetworkProvider & ChaindataTokenProvider
#onfinalityApiKey?: string

constructor(
chaindataEvmNetworkProvider: ChaindataEvmNetworkProvider,
chaindataTokenProvider: ChaindataTokenProvider,
chaindataProvider: ChaindataEvmNetworkProvider & ChaindataTokenProvider,
options?: ChainConnectorEvmOptions
) {
this.#chaindataEvmNetworkProvider = chaindataEvmNetworkProvider
this.#chaindataTokenProvider = chaindataTokenProvider
this.#chaindataProvider = chaindataProvider
this.#onfinalityApiKey = options?.onfinalityApiKey ?? undefined
}

Expand All @@ -32,9 +29,9 @@ export class ChainConnectorEvm {
public async getPublicClientForEvmNetwork(
evmNetworkId: EvmNetworkId
): Promise<PublicClient | null> {
const network = await this.#chaindataEvmNetworkProvider.getEvmNetwork(evmNetworkId)
const network = await this.#chaindataProvider.getEvmNetwork(evmNetworkId)
if (!network?.nativeToken?.id) return null
const nativeToken = await this.#chaindataTokenProvider.getToken(network.nativeToken.id)
const nativeToken = await this.#chaindataProvider.getToken(network.nativeToken.id)
if (!nativeToken) return null

return getEvmNetworkPublicClient(network, nativeToken, {
Expand All @@ -46,9 +43,9 @@ export class ChainConnectorEvm {
evmNetworkId: EvmNetworkId,
account?: `0x${string}` | Account
): Promise<WalletClient | null> {
const network = await this.#chaindataEvmNetworkProvider.getEvmNetwork(evmNetworkId)
const network = await this.#chaindataProvider.getEvmNetwork(evmNetworkId)
if (!network?.nativeToken?.id) return null
const nativeToken = await this.#chaindataTokenProvider.getToken(network.nativeToken.id)
const nativeToken = await this.#chaindataProvider.getToken(network.nativeToken.id)
if (!nativeToken) return null

return getEvmNetworkWalletClient(network, nativeToken, {
Expand Down

0 comments on commit 65df14a

Please sign in to comment.