Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
♻️ Add default asset type as buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ManuGowda committed May 28, 2020
1 parent 2c0e0cf commit 9886e56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TransactionInterfaceAdapter {
}

// First encode message asset and then encode base message
public encode(message: BaseTransaction<{}>): Buffer {
public encode(message: BaseTransaction): Buffer {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const TransactionClass = this._transactionClassMap.get(message.type);

Expand All @@ -59,17 +59,17 @@ export class TransactionInterfaceAdapter {
}

// First decode base message and then decode asset
public decode(binaryMessage: Buffer): BaseTransaction<{}> {
public decode(binaryMessage: Buffer): BaseTransaction {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const baseMessage = codec.decode<BaseTransaction<{}>>(BaseTransaction.BASE_SCHEMA, binaryMessage);
const baseMessage = codec.decode<BaseTransaction>(BaseTransaction.BASE_SCHEMA, binaryMessage);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const TransactionClass = this._transactionClassMap.get(baseMessage.type);

if (!TransactionClass) {
throw new Error('Transaction type not found.');
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment
const assetMessage = codec.decode<BaseTransaction<{}>>(TransactionClass.ASSET_SCHEMA, baseMessage.asset as Buffer);
const assetMessage = codec.decode<BaseTransaction>(TransactionClass.ASSET_SCHEMA, baseMessage.asset as Buffer);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const message = { ...baseMessage, asset: assetMessage };

Expand Down
2 changes: 1 addition & 1 deletion elements/lisk-transactions/src/base_transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface StateStore {
export const ENTITY_ACCOUNT = 'account';
export const ENTITY_TRANSACTION = 'transaction';

export abstract class BaseTransaction<T> {
export abstract class BaseTransaction<T = Buffer> {
public static TYPE: number;
// Minimum remaining balance requirement for any account to perform a transaction
public static MIN_REMAINING_BALANCE = BigInt('5000000'); // 0.05 LSK
Expand Down

0 comments on commit 9886e56

Please sign in to comment.