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 Oct 22, 2024
1 parent fd31950 commit ce03078
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,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 @@ -197,7 +198,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 ce03078

Please sign in to comment.