Blockchain Traits

This commit is contained in:
Jim Hamill
2025-04-20 02:22:30 +00:00
parent b097abbd1c
commit 22bff76a55
13 changed files with 302 additions and 189 deletions
+16 -6
View File
@@ -1,8 +1,15 @@
import { BaseWallet } from './base-wallet.js';
import { type TransactionTemplate, type WalletDependencies } from './types.js';
import {
type TransactionTemplate,
type WalletBlockchain,
type WalletDependencies,
} from './types.js';
import { TransactionBuilder } from './transaction-builder.js';
import { type BaseBlockchain, type BlockchainTransaction } from '../blockchain';
import {
type AddressStatusPayload,
type BlockchainTransaction,
} from '../blockchain';
import { type BaseStore, Activities, StoreInMemory } from '../storage';
import {
@@ -116,7 +123,7 @@ export class WalletP2PKH extends BaseWallet {
// Dependencies.
public readonly activities: Activities;
public readonly blockchain: BaseBlockchain;
public readonly blockchain: WalletBlockchain;
public readonly cache: BaseStore;
// Genesis Data.
@@ -408,11 +415,14 @@ export class WalletP2PKH extends BaseWallet {
await this.blockchain.broadcastTransaction(generatedTxBytes);
}
private async onAddressNotification(status: string | null) {
private async onAddressNotification(
_address: string,
payload?: AddressStatusPayload,
) {
// If wallet state has changed...
if (status !== this.status) {
if (payload && payload.status !== this.status) {
// Set our new status.
this.status = status;
this.status = payload.status;
// Emit an event.
this.emit('stateUpdated', this.status);