Skip to content

Commit d4c8793

Browse files
committed
Type cleanup
1 parent e96b22a commit d4c8793

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

packages/sequencer/src/state/masking/MaskGraph.ts

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,20 @@ type Node<T, Child, Parent> = {
1313
parent: Parent;
1414
};
1515

16-
// export type Mask = {
17-
// createMask(name: string): Promise<Mask>;
18-
// name: string;
19-
// mergeIntoParent(): Promise<void>;
20-
// updateParent(parent: Mask): void;
21-
// };
22-
//
23-
// export type MaskBase = {
24-
// createMask(name: string): Promise<Mask>;
25-
// name: string;
26-
// };
16+
type BaseMaskType<Interface, Mask> = Interface & {
17+
createMask(name: string): Promise<Mask>;
18+
name: string;
19+
};
20+
21+
type MaskType<Interface, Mask> = BaseMaskType<Interface, Mask> & {
22+
mergeIntoParent(): Promise<void>;
23+
updateParent(parent: Interface): void;
24+
};
2725

2826
export class MaskGraph<
29-
Base extends {
30-
createMask(name: string): Promise<Mask>;
31-
name: string;
32-
},
33-
Mask extends Base & {
34-
mergeIntoParent(): Promise<void>;
35-
updateParent(parent: Mask | Base): void;
36-
},
27+
Interface,
28+
Base extends BaseMaskType<Interface, Mask>,
29+
Mask extends MaskType<Interface, Mask>,
3730
> {
3831
public constructor(base: Base) {
3932
this.root = {
@@ -64,7 +57,7 @@ export class MaskGraph<
6457
return this.findNode(name)?.mask;
6558
}
6659

67-
public async getMask(name: string) {
60+
public getMask(name: string) {
6861
const candidate = this.findService(name);
6962

7063
assertMaskFound(candidate, name);
@@ -76,7 +69,7 @@ export class MaskGraph<
7669
name: string,
7770
parentName: string,
7871
fallback?: string
79-
): Promise<Base> {
72+
): Promise<Interface> {
8073
const candidate = this.findService(name);
8174
if (candidate !== undefined) {
8275
return candidate;

packages/sequencer/src/state/masking/StateServiceCreator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AsyncStateService } from "../async/AsyncStateService";
22

33
export interface StateServiceCreator {
44
createMask(name: string, parent: string): Promise<AsyncStateService>;
5-
getMask(name: string): Promise<AsyncStateService>;
5+
getMask(name: string): AsyncStateService;
66
mergeIntoParent(name: string): Promise<void>;
77
drop(name: string): Promise<void>;
88
}

packages/sequencer/src/state/masking/TreeStoreCreator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface TreeStoreCreator {
66
parent: string,
77
fallback?: string
88
): Promise<AsyncMerkleTreeStore>;
9-
getMask(name: string): Promise<AsyncMerkleTreeStore>;
9+
getMask(name: string): AsyncMerkleTreeStore;
1010
mergeIntoParent(name: string): Promise<void>;
1111
drop(name: string): Promise<void>;
1212
}

packages/sequencer/src/storage/inmemory/masking/InMemoryStateServiceCreator.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ import { StateServiceCreator } from "../../../state/masking/StateServiceCreator"
22
import { MaskGraph } from "../../../state/masking/MaskGraph";
33

44
import { InMemoryStateServiceMask } from "./InMemoryStateServiceMask";
5+
import { AsyncStateService } from "../../../state/async/AsyncStateService";
56

67
export class InMemoryStateServiceCreator
7-
extends MaskGraph<InMemoryStateServiceMask, InMemoryStateServiceMask>
8+
extends MaskGraph<
9+
AsyncStateService,
10+
InMemoryStateServiceMask,
11+
InMemoryStateServiceMask
12+
>
813
implements StateServiceCreator
914
{
1015
public constructor() {

packages/sequencer/src/storage/inmemory/masking/InMemoryTreeStoreCreator.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import {
99

1010
export class InMemoryTreeStoreCreator
1111
extends MaskGraph<
12-
AsyncMerkleTreeStore & {
13-
createMask: (name: string) => Promise<InMemoryMerkleTreeStoreMask>;
14-
name: string;
15-
},
12+
AsyncMerkleTreeStore,
13+
InMemoryBaseMerkleTreeStore,
1614
InMemoryMerkleTreeStoreMask
1715
>
1816
implements TreeStoreCreator

0 commit comments

Comments
 (0)