Skip to content

Commit

Permalink
feat: switch to generic chain type
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Sep 19, 2024
1 parent a2e715e commit 4f620fe
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,17 @@ let _globalEdrContext: EdrContext | undefined;

// Lazy initialize the global EDR context.
export async function getGlobalEdrContext(): Promise<EdrContext> {
const { EdrContext, L1_CHAIN_TYPE, l1ProviderFactory } = requireNapiRsModule(
"@nomicfoundation/edr"
) as typeof import("@nomicfoundation/edr");
const { EdrContext, GENERIC_CHAIN_TYPE, genericChainProviderFactory } =
requireNapiRsModule(
"@nomicfoundation/edr"
) as typeof import("@nomicfoundation/edr");

if (_globalEdrContext === undefined) {
// Only one is allowed to exist
_globalEdrContext = new EdrContext();
await _globalEdrContext.registerProviderFactory(
L1_CHAIN_TYPE,
l1ProviderFactory()
GENERIC_CHAIN_TYPE,
genericChainProviderFactory()
);
}

Expand Down Expand Up @@ -196,7 +197,7 @@ export class EdrProviderWrapper
loggerConfig: LoggerConfig,
tracingConfig?: TracingConfig
): Promise<EdrProviderWrapper> {
const { L1_CHAIN_TYPE } = requireNapiRsModule(
const { GENERIC_CHAIN_TYPE } = requireNapiRsModule(
"@nomicfoundation/edr"
) as typeof import("@nomicfoundation/edr");

Expand Down Expand Up @@ -232,7 +233,7 @@ export class EdrProviderWrapper

const context = await getGlobalEdrContext();
const provider = await context.createProvider(
L1_CHAIN_TYPE,
GENERIC_CHAIN_TYPE,
{
allowBlocksWithSameTimestamp:
config.allowBlocksWithSameTimestamp ?? false,
Expand Down

0 comments on commit 4f620fe

Please sign in to comment.