@@ -28,10 +28,16 @@ import { ProtocolEnvironment } from "./ProtocolEnvironment";
2828import { ProvableBlockHook } from "./ProvableBlockHook" ;
2929import { TransitioningProtocolModule } from "./TransitioningProtocolModule" ;
3030
31+ /**
32+ * This is a mapping of abstract classes to their respective injection tokens.
33+ * Keys are the abstract classes names, which need to be set dynamically
34+ * and can't be hardcoded since producing optimized builds may mangle the
35+ * class names, making them different from the ones in the source code.
36+ */
3137const PROTOCOL_INJECTION_TOKENS : Record < string , string > = {
32- ProvableTransactionHook : "ProvableTransactionHook" ,
33- ProvableBlockHook : "ProvableBlockHook" ,
34- ProvableSettlementHook : "ProvableSettlementHook" ,
38+ [ ProvableTransactionHook . name ] : "ProvableTransactionHook" ,
39+ [ ProvableBlockHook . name ] : "ProvableBlockHook" ,
40+ [ ProvableSettlementHook . name ] : "ProvableSettlementHook" ,
3541} ;
3642
3743export type ProtocolModulesRecord = ModulesRecord <
@@ -162,7 +168,7 @@ export class Protocol<
162168
163169 implementingModules . forEach ( ( [ key ] ) => {
164170 this . container . register (
165- abstractType . name ,
171+ newInjectionToken ,
166172 { useToken : key } ,
167173 { lifecycle : Lifecycle . ContainerScoped }
168174 ) ;
@@ -175,7 +181,7 @@ export class Protocol<
175181
176182 // Register default (noop) version
177183 this . container . register (
178- abstractType . name ,
184+ newInjectionToken ,
179185 { useClass : defaultType } ,
180186 { lifecycle : Lifecycle . ContainerScoped }
181187 ) ;
0 commit comments