@@ -2,25 +2,16 @@ import "reflect-metadata";
2
2
import { PrivateKey } from "o1js" ;
3
3
import { Runtime , RuntimeModulesRecord } from "@proto-kit/module" ;
4
4
import {
5
- BlockProver ,
6
- StateTransitionProver ,
7
- VanillaProtocol ,
8
- AccountStateModule ,
5
+ MandatoryProtocolModulesRecord ,
6
+ Protocol ,
9
7
ProtocolModulesRecord ,
10
8
} from "@proto-kit/protocol" ;
11
- import { ModulesConfig } from "@proto-kit/common" ;
12
9
import {
13
- BlockProducerModule ,
14
- InMemoryDatabase ,
15
- LocalTaskQueue ,
16
- LocalTaskWorkerModule ,
17
- ManualBlockTrigger ,
18
- NoopBaseLayer ,
19
- PrivateMempool ,
20
- Sequencer ,
21
- SequencerModulesRecord ,
22
- UnprovenProducerModule ,
23
- } from "@proto-kit/sequencer" ;
10
+ InMemorySequencerModules ,
11
+ VanillaProtocolModules ,
12
+ VanillaRuntimeModules ,
13
+ } from "@proto-kit/library" ;
14
+ import { Sequencer , SequencerModulesRecord } from "@proto-kit/sequencer" ;
24
15
import {
25
16
BlockStorageResolver ,
26
17
GraphqlSequencerModule ,
@@ -33,41 +24,37 @@ import {
33
24
} from "@proto-kit/api" ;
34
25
import {
35
26
AppChain ,
36
- AppChainModulesRecord ,
37
- InMemorySigner ,
38
- InMemoryTransactionSender ,
39
27
StateServiceQueryModule ,
40
28
BlockStorageNetworkStateModule ,
29
+ AppChainModulesRecord ,
30
+ InMemoryTransactionSender ,
41
31
} from "@proto-kit/sdk" ;
42
32
43
33
export class LocalhostAppChain <
44
- RuntimeModules extends RuntimeModulesRecord
34
+ RuntimeModules extends RuntimeModulesRecord ,
35
+ ProtocolModules extends ProtocolModulesRecord &
36
+ MandatoryProtocolModulesRecord ,
37
+ SequencerModules extends SequencerModulesRecord ,
38
+ AppChainModules extends AppChainModulesRecord
45
39
> extends AppChain <
46
40
RuntimeModules ,
47
- ProtocolModulesRecord ,
48
- SequencerModulesRecord ,
49
- AppChainModulesRecord
41
+ ProtocolModules ,
42
+ SequencerModules ,
43
+ AppChainModules
50
44
> {
51
- public static fromRuntime <
52
- RuntimeModules extends RuntimeModulesRecord
53
- > ( definition : { modules : RuntimeModules } ) {
45
+ public static fromRuntime < RuntimeModules extends RuntimeModulesRecord > (
46
+ runtimeModules : RuntimeModules
47
+ ) {
54
48
const appChain = LocalhostAppChain . from ( {
55
- runtime : Runtime . from ( definition ) ,
56
-
57
- protocol : VanillaProtocol . from ( { } ) ,
58
-
59
- sequencer : Sequencer . from ( {
60
- modules : {
61
- Database : InMemoryDatabase ,
62
- Mempool : PrivateMempool ,
63
- GraphqlServer,
64
- LocalTaskWorkerModule,
65
- BaseLayer : NoopBaseLayer ,
66
- BlockProducerModule,
67
- UnprovenProducerModule,
68
- BlockTrigger : ManualBlockTrigger ,
69
- TaskQueue : LocalTaskQueue ,
70
-
49
+ Runtime : Runtime . from ( {
50
+ modules : VanillaRuntimeModules . with ( runtimeModules ) ,
51
+ } ) ,
52
+ Protocol : Protocol . from ( {
53
+ modules : VanillaProtocolModules . with ( { } ) ,
54
+ } ) ,
55
+ Sequencer : Sequencer . from ( {
56
+ modules : InMemorySequencerModules . with ( {
57
+ GraphqlServer : GraphqlServer ,
71
58
Graphql : GraphqlSequencerModule . from ( {
72
59
modules : {
73
60
MempoolResolver,
@@ -78,26 +65,32 @@ export class LocalhostAppChain<
78
65
MerkleWitnessResolver,
79
66
} ,
80
67
} ) ,
81
- } ,
68
+ } ) ,
82
69
} ) ,
83
-
84
70
modules : {
71
+ // TODO: remove in favour of a real tx sender for the SettlementModule
72
+ // temporary dependency to make the SettlementModule work
73
+ TransactionSender : InMemoryTransactionSender ,
85
74
QueryTransportModule : StateServiceQueryModule ,
86
75
NetworkStateTransportModule : BlockStorageNetworkStateModule ,
87
76
} ,
88
77
} ) ;
89
78
90
- appChain . configure ( {
91
- ...appChain . config ,
92
-
79
+ appChain . configurePartial ( {
93
80
Protocol : {
94
81
BlockProver : { } ,
95
82
StateTransitionProver : { } ,
96
83
AccountState : { } ,
97
84
BlockHeight : { } ,
98
85
LastStateRoot : { } ,
86
+ TransactionFee : {
87
+ tokenId : 0n ,
88
+ feeRecipient : PrivateKey . random ( ) . toPublicKey ( ) . toBase58 ( ) ,
89
+ baseFee : 0n ,
90
+ perWeightUnitFee : 0n ,
91
+ methods : { } ,
92
+ } ,
99
93
} ,
100
-
101
94
Sequencer : {
102
95
Database : { } ,
103
96
UnprovenProducerModule : { } ,
@@ -123,8 +116,10 @@ export class LocalhostAppChain<
123
116
BaseLayer : { } ,
124
117
TaskQueue : { } ,
125
118
BlockTrigger : { } ,
119
+ SettlementModule : {
120
+ feepayer : PrivateKey . random ( ) ,
121
+ } ,
126
122
} ,
127
-
128
123
QueryTransportModule : { } ,
129
124
NetworkStateTransportModule : { } ,
130
125
} ) ;
0 commit comments