Skip to content

Commit

Permalink
feat: add index transaction command and template for it's handler
Browse files Browse the repository at this point in the history
Signed-off-by: Anmol Sharma <anmolsharma0234@gmail.com>
  • Loading branch information
theanmolsharma committed Apr 14, 2024
1 parent 0ab45ce commit b981e18
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@nestjs/common": "^9.0.0",
"@nestjs/config": "^3.2.2",
"@nestjs/core": "^10.3.7",
"@nestjs/cqrs": "^10.2.7",
"@nestjs/microservices": "^10.3.7",
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^10.3.7",
Expand Down
18 changes: 18 additions & 0 deletions src/commands/index-transaction.command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export type TransactionInput = {
scriptSig: string; // unlocking script
witness?: string[]; // witness data
prevOutScript: string; // previous output script
};

export type TransactionOutput = {
scriptPubKey: string;
value: number;
};

export class IndexTransactionCommand {
constructor(
public readonly txid: string,
public readonly vin: TransactionInput[],
public readonly vout: TransactionOutput[],
) {}
}
11 changes: 11 additions & 0 deletions src/handlers/commands/index-transaction.handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { IndexTransactionCommand } from '@/commands/index-transaction.command';

@CommandHandler(IndexTransactionCommand)
export class IndexTransactionHandler
implements ICommandHandler<IndexTransactionCommand>
{
async execute(command: IndexTransactionCommand) {
throw new Error(`Method not implemented. Command: ${command}`);
}
}

0 comments on commit b981e18

Please sign in to comment.