Skip to content

Commit 0127730

Browse files
committed
Renamed runtime and protocol references to parent
1 parent 9b941f6 commit 0127730

File tree

7 files changed

+14
-12
lines changed

7 files changed

+14
-12
lines changed

packages/module/src/method/runtimeMethod.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export function toWrappedMethod(
9595
const stateTransitionsHash = toStateTransitionsHash(stateTransitions);
9696
const eventsHash = toEventsHash(events);
9797

98-
const { name, runtime } = this;
98+
const { name, parent: runtime } = this;
9999

100100
if (name === undefined) {
101101
throw errors.runtimeNameNotSet();
@@ -275,10 +275,10 @@ function runtimeMethodInternal(options: {
275275
executionContext.beforeMethod(constructorName, methodName, args);
276276

277277
if (executionContext.isTopLevel) {
278-
if (!this.runtime) {
278+
if (!this.parent) {
279279
throw errors.runtimeNotProvided(constructorName);
280280
}
281-
executionContext.setProver(prover.bind(this.runtime.zkProgrammable));
281+
executionContext.setProver(prover.bind(this.parent.zkProgrammable));
282282
}
283283

284284
let result: unknown;

packages/module/src/runtime/Runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ export class Runtime<Modules extends RuntimeModulesRecord>
371371
containedModule: InstanceType<Modules[StringKeyOf<Modules>]>
372372
) {
373373
containedModule.name = moduleName;
374-
containedModule.runtime = this;
374+
containedModule.parent = this;
375375

376376
super.decorateModule(moduleName, containedModule);
377377
}

packages/module/src/runtime/RuntimeModule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class RuntimeModule<
7575

7676
public name?: string;
7777

78-
public runtime?: RuntimeEnvironment;
78+
public parent?: RuntimeEnvironment;
7979

8080
public events?: RuntimeEvents<any> = undefined;
8181

packages/module/src/state/decorator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function state() {
3838
throw errors.missingName(self.constructor.name);
3939
}
4040

41-
if (!self.runtime) {
41+
if (!self.parent) {
4242
throw errors.missingRuntime(self.constructor.name);
4343
}
4444

@@ -48,7 +48,7 @@ export function state() {
4848

4949
// TODO: why is this complaining about `any`?
5050

51-
value.stateServiceProvider = self.runtime.stateServiceProvider;
51+
value.stateServiceProvider = self.parent.stateServiceProvider;
5252
}
5353
return value;
5454
},

packages/protocol/src/protocol/Protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class Protocol<
9393
containedModule: InstanceType<Modules[StringKeyOf<Modules>]>
9494
) {
9595
log.debug(`Decorated ${moduleName}`);
96-
containedModule.protocol = this;
96+
containedModule.parent = this;
9797

9898
if (containedModule instanceof TransitioningProtocolModule) {
9999
containedModule.name = moduleName;

packages/protocol/src/protocol/ProtocolModule.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { ProtocolEnvironment } from "./ProtocolEnvironment";
1111
export abstract class ProtocolModule<
1212
Config = NoConfig,
1313
> extends ConfigurableModule<Config> {
14-
public protocol?: ProtocolEnvironment;
14+
public parent?: ProtocolEnvironment;
1515

1616
public get areProofsEnabled(): AreProofsEnabled | undefined {
17-
return this.protocol?.getAreProofsEnabled();
17+
return this.parent?.getAreProofsEnabled();
1818
}
1919

2020
public create(childContainerProvider: ChildContainerProvider): void {

packages/protocol/src/state/protocol/ProtocolState.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const errors = {
1616
),
1717
};
1818

19+
// TODO Homogenize @protocolState() towards a single @state() API
20+
1921
/**
2022
* Decorates a runtime module property as state, passing down some
2123
* underlying values to improve developer experience.
@@ -40,15 +42,15 @@ export function protocolState() {
4042
throw errors.missingName(self.constructor.name);
4143
}
4244

43-
if (!self.protocol) {
45+
if (!self.parent) {
4446
throw errors.missingProtocol(self.constructor.name);
4547
}
4648

4749
// TODO Add Prefix?
4850
const path = Path.fromProperty(self.name, propertyKey);
4951
if (value) {
5052
value.path = path;
51-
value.stateServiceProvider = self.protocol.stateServiceProvider;
53+
value.stateServiceProvider = self.parent.stateServiceProvider;
5254
}
5355
return value;
5456
},

0 commit comments

Comments
 (0)