@@ -28,10 +28,16 @@ import { ProtocolEnvironment } from "./ProtocolEnvironment";
28
28
import { ProvableBlockHook } from "./ProvableBlockHook" ;
29
29
import { TransitioningProtocolModule } from "./TransitioningProtocolModule" ;
30
30
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
+ */
31
37
const 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" ,
35
41
} ;
36
42
37
43
export type ProtocolModulesRecord = ModulesRecord <
@@ -162,7 +168,7 @@ export class Protocol<
162
168
163
169
implementingModules . forEach ( ( [ key ] ) => {
164
170
this . container . register (
165
- abstractType . name ,
171
+ newInjectionToken ,
166
172
{ useToken : key } ,
167
173
{ lifecycle : Lifecycle . ContainerScoped }
168
174
) ;
@@ -175,7 +181,7 @@ export class Protocol<
175
181
176
182
// Register default (noop) version
177
183
this . container . register (
178
- abstractType . name ,
184
+ newInjectionToken ,
179
185
{ useClass : defaultType } ,
180
186
{ lifecycle : Lifecycle . ContainerScoped }
181
187
) ;
0 commit comments