This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f98b7ed
commit 81db689
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright © 2021 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
*/ | ||
|
||
import { BaseModule, ModuleInitArgs } from '../base_module'; | ||
import { BaseFee, TokenAPI, ModuleConfig } from './types'; | ||
import { | ||
TransactionExecuteContext, | ||
TransactionVerifyContext, | ||
VerificationResult, | ||
} from '../../node/state_machine'; | ||
import { FeeAPI } from './api'; | ||
import { FeeEndpoint } from './endpoint'; | ||
import { configSchema } from './schemas'; | ||
|
||
export class FeeModule extends BaseModule { | ||
public id = 11; | ||
public name = 'fee'; | ||
public api = new FeeAPI(this.id); | ||
public configSchema = configSchema; | ||
public endpoint = new FeeEndpoint(this.id); | ||
private _tokenAPI!: TokenAPI; | ||
private _minFeePerBytes!: number; | ||
private _baseFees!: Array<BaseFee>; | ||
private _moduleConfig!: ModuleConfig; | ||
|
||
public addDependencies(tokenAPI: TokenAPI) { | ||
this._tokenAPI = tokenAPI; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
public async init(args: ModuleInitArgs): Promise<void> { | ||
const { genesisConfig, moduleConfig } = args; | ||
this._moduleConfig = (moduleConfig as unknown) as ModuleConfig; | ||
this._minFeePerBytes = genesisConfig.minFeePerByte; | ||
this._baseFees = genesisConfig.baseFees.map(fee => ({ ...fee, baseFee: BigInt(fee.baseFee) })); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
public async verifyTransaction(_context: TransactionVerifyContext): Promise<VerificationResult> { | ||
return { status: 1 }; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/require-await | ||
public async beforeTransactionExecute(_context: TransactionExecuteContext): Promise<void> { | ||
// eslint-disable-next-line no-console | ||
console.log(this._tokenAPI, this._minFeePerBytes, this._baseFees, this._moduleConfig); | ||
} | ||
} |