Skip to content

Commit 1fc1cf8

Browse files
committed
Add in tsyringe code
1 parent 2d5ca04 commit 1fc1cf8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/library/src/hooks/TransactionFeeHook.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ const errors = {
5151
export class TransactionFeeHook extends ProvableTransactionHook<TransactionFeeHookConfig> {
5252
public constructor(
5353
// dependency on runtime, since balances are part of runtime logic
54-
@inject("Runtime") public runtime: Runtime<RuntimeModulesRecord>
54+
@inject("Runtime") public runtime: Runtime<RuntimeModulesRecord>,
55+
@inject("Balances") public balances: Balances
5556
) {
5657
super();
5758
}
@@ -91,10 +92,6 @@ export class TransactionFeeHook extends ProvableTransactionHook<TransactionFeeHo
9192
super.config = value;
9293
}
9394

94-
public get balances() {
95-
return this.runtime.dependencyContainer.resolve<Balances>("Balances");
96-
}
97-
9895
public get feeAnalyzer() {
9996
if (this.persistedFeeAnalyzer === undefined) {
10097
throw new Error("TransactionFeeHook.start not called by protocol");

packages/protocol/src/protocol/Protocol.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ export class Protocol<
132132
public create(childContainerProvider: ChildContainerProvider) {
133133
super.create(childContainerProvider);
134134

135+
const runtime: ModuleContainer<any> = this.container.resolve("Runtime");
136+
runtime.moduleNames.forEach((runtimeModuleName) => {
137+
this.container.register(runtimeModuleName, {
138+
useFactory: (dependencyContainer) => {
139+
return runtime.resolve(runtimeModuleName);
140+
},
141+
});
142+
});
143+
135144
// Register the BlockModules seperately since we need to
136145
// inject them differently later
137146
const ABSTRACT_MODULE_TYPES = [

0 commit comments

Comments
 (0)