lisk-sdk
lisk-sdk copied to clipboard
Unnecessary - `createAPIContext = (params: Params) => new APIContext(params);`
Description
Currently we have code like export const createAPIContext = (params: Params) => new APIContext(params); just to create instance of APIContext.
Motivation
This function seems unnecessarily extra lawyer just to create instance of APIContext. We could instead just call
new APIContext(params) directly. Hence relevant code like this should be updated also
export interface TransactionExecuteContext {
logger: Logger;
networkIdentifier: Buffer;
eventQueue: EventQueueAdder;
getAPIContext: () => APIContext;
....
}
public createTransactionExecuteContext(): TransactionExecuteContext { ....
return {
....
eventQueue: childQueue,
getAPIContext: () =>
createAPIContext({ stateStore: this._stateStore, eventQueue: childQueue }),
....
}
=>
export interface TransactionExecuteContext {
logger: Logger;
networkIdentifier: Buffer;
eventQueue: EventQueueAdder;
apiContext: APIContext;
....
}
public createTransactionExecuteContext(): TransactionExecuteContext {
....
const apiContext = new APIContext({ stateStore: this._stateStore, eventQueue: childQueue });
return {
....
eventQueue: childQueue,
apiContext,
....
}
Additional Information
framework/src/state_machine/types.ts framework/src/state_machine/transaction_context.ts