Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions packages/protocol/src/protocol/Protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ import { ProvableTransactionHook } from "./ProvableTransactionHook";
import { ProtocolEnvironment } from "./ProtocolEnvironment";
import { ProvableBlockHook } from "./ProvableBlockHook";

/**
* This is a mapping of abstract classes to their respective injection tokens.
* Keys are the abstract classes names, which need to be set dynamically
* and can't be hardcoded since producing optimized builds may mangle the
* class names, making them different from the ones in the source code.
*/
const PROTOCOL_INJECTION_TOKENS: Record<string, string> = {
ProvableTransactionHook: "ProvableTransactionHook",
ProvableBlockHook: "ProvableBlockHook",
ProvableSettlementHook: "ProvableSettlementHook",
[ProvableTransactionHook.name]: "ProvableTransactionHook",
[ProvableBlockHook.name]: "ProvableBlockHook",
[ProvableSettlementHook.name]: "ProvableSettlementHook",
};

export type ProtocolModulesRecord = ModulesRecord<
Expand Down Expand Up @@ -161,7 +167,7 @@ export class Protocol<

implementingModules.forEach(([key]) => {
this.container.register(
abstractType.name,
newInjectionToken,
{ useToken: key },
{ lifecycle: Lifecycle.ContainerScoped }
);
Expand All @@ -174,7 +180,7 @@ export class Protocol<

// Register default (noop) version
this.container.register(
abstractType.name,
newInjectionToken,
{ useClass: defaultType },
{ lifecycle: Lifecycle.ContainerScoped }
);
Expand Down
Loading