@@ -105,88 +105,109 @@ export default class ModuleWrapperFactory {
105
105
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106
106
public getModuleInstance : GetModuleInstance = async ( params : GetModuleParams ) : Promise < any > => {
107
107
assert . isETHAddressHex ( 'address' , params . address ) ;
108
+ let moduleWrapper ;
108
109
switch ( params . name ) {
109
110
// Permission
110
111
case ModuleName . GeneralPermissionManager :
111
- return new GeneralPermissionManagerWrapper (
112
+ moduleWrapper = new GeneralPermissionManagerWrapper (
112
113
this . web3Wrapper ,
113
114
this . contractFactory . getGeneralPermissionManagerContract ( params . address ) ,
114
115
this . contractFactory ,
115
116
) ;
117
+ break ;
116
118
// TMs
117
119
case ModuleName . CountTransferManager :
118
- return new CountTransferManagerWrapper (
120
+ moduleWrapper = new CountTransferManagerWrapper (
119
121
this . web3Wrapper ,
120
122
this . contractFactory . getCountTransferManagerContract ( params . address ) ,
121
123
this . contractFactory ,
122
124
) ;
125
+ break ;
123
126
case ModuleName . GeneralTransferManager :
124
- return new GeneralTransferManagerWrapper (
127
+ moduleWrapper = new GeneralTransferManagerWrapper (
125
128
this . web3Wrapper ,
126
129
this . contractFactory . getGeneralTransferManagerContract ( params . address ) ,
127
130
this . contractFactory ,
128
131
) ;
132
+ break ;
129
133
case ModuleName . ManualApprovalTransferManager :
130
- return new ManualApprovalTransferManagerWrapper (
134
+ moduleWrapper = new ManualApprovalTransferManagerWrapper (
131
135
this . web3Wrapper ,
132
136
this . contractFactory . getManualApprovalTransferManagerContract ( params . address ) ,
133
137
this . contractFactory ,
134
138
) ;
139
+ break ;
135
140
case ModuleName . PercentageTransferManager :
136
- return new PercentageTransferManagerWrapper (
141
+ moduleWrapper = new PercentageTransferManagerWrapper (
137
142
this . web3Wrapper ,
138
143
this . contractFactory . getPercentageTransferManagerContract ( params . address ) ,
139
144
this . contractFactory ,
140
145
) ;
146
+ break ;
141
147
case ModuleName . LockUpTransferManager :
142
- return new LockUpTransferManagerWrapper (
148
+ moduleWrapper = new LockUpTransferManagerWrapper (
143
149
this . web3Wrapper ,
144
150
this . contractFactory . getLockUpTransferManagerContract ( params . address ) ,
145
151
this . contractFactory ,
146
152
) ;
153
+ break ;
147
154
case ModuleName . VolumeRestrictionTM :
148
- return new VolumeRestrictionTransferManagerWrapper (
155
+ moduleWrapper = new VolumeRestrictionTransferManagerWrapper (
149
156
this . web3Wrapper ,
150
157
this . contractFactory . getVolumeRestrictionTMContract ( params . address ) ,
151
158
this . contractFactory ,
152
159
) ;
160
+ break ;
153
161
// STOs
154
162
case ModuleName . CappedSTO :
155
- return new CappedSTOWrapper (
163
+ moduleWrapper = new CappedSTOWrapper (
156
164
this . web3Wrapper ,
157
165
this . contractFactory . getCappedSTOContract ( params . address ) ,
158
166
this . contractFactory ,
159
167
) ;
168
+ break ;
160
169
case ModuleName . UsdTieredSTO :
161
- return new USDTieredSTOWrapper (
170
+ moduleWrapper = new USDTieredSTOWrapper (
162
171
this . web3Wrapper ,
163
172
this . contractFactory . getUSDTieredSTOContract ( params . address ) ,
164
173
this . contractFactory ,
165
174
) ;
175
+ break ;
166
176
// Checkpoint
167
177
case ModuleName . ERC20DividendCheckpoint :
168
- return new ERC20DividendCheckpointWrapper (
178
+ moduleWrapper = new ERC20DividendCheckpointWrapper (
169
179
this . web3Wrapper ,
170
180
this . contractFactory . getERC20DividendCheckpointContract ( params . address ) ,
171
181
this . contractFactory ,
172
182
) ;
183
+ break ;
173
184
case ModuleName . EtherDividendCheckpoint :
174
- return new EtherDividendCheckpointWrapper (
185
+ moduleWrapper = new EtherDividendCheckpointWrapper (
175
186
this . web3Wrapper ,
176
187
this . contractFactory . getEtherDividendCheckpointContract ( params . address ) ,
177
188
this . contractFactory ,
178
189
) ;
190
+ break ;
179
191
// Wallet
180
192
case ModuleName . VestingEscrowWallet :
181
- return new VestingEscrowWalletWrapper (
193
+ moduleWrapper = new VestingEscrowWalletWrapper (
182
194
this . web3Wrapper ,
183
195
this . contractFactory . getVestingEscrowWalletContract ( params . address ) ,
184
196
this . contractFactory ,
185
197
) ;
198
+ break ;
186
199
// Burn
187
200
default :
188
201
// TODO: Typed error here
189
202
throw new Error ( ) ;
190
203
}
204
+
205
+ // validate module
206
+ if ( await moduleWrapper . isValidModule ( ) ) {
207
+ return moduleWrapper ;
208
+ }
209
+
210
+ // TODO: Typed error here
211
+ throw new Error ( 'Invalid module' ) ;
191
212
} ;
192
213
}
0 commit comments