Skip to content

Commit 2b78872

Browse files
rg911fboucquez
andauthored
Listener (WS) refactoring (#570)
* Fixed #569 - Listener filter on recipientAddress and target addresses (publicKeys) - Now resolving alias * Improved listener: 1) Added transaction hashes to the subscription 2) Reused methods when subscriptions are the same 3) Improved how aliases are loaded (lazy on demand) * Refactored regard PR feedbacks * typo fixed * Bugs fixed to use super.isSigned Co-authored-by: fernando <fboucquez@gmail.com>
1 parent 5f60492 commit 2b78872

File tree

54 files changed

+1273
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1273
-188
lines changed

src/infrastructure/BlockHttp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class BlockHttp extends Http implements BlockRepository {
5555
* @returns Observable<BlockInfo>
5656
*/
5757
public getBlockByHeight(height: UInt64): Observable<BlockInfo> {
58-
return this.call(this.blockRoutesApi.getBlockByHeight(height.toString()), (body) => this.toBlockInfo(body));
58+
return this.call(this.blockRoutesApi.getBlockByHeight(height.toString()), (body) => BlockHttp.toBlockInfo(body));
5959
}
6060

6161
/**
@@ -87,7 +87,7 @@ export class BlockHttp extends Http implements BlockRepository {
8787
*/
8888
public getBlocksByHeightWithLimit(height: UInt64, limit: number): Observable<BlockInfo[]> {
8989
return this.call(this.blockRoutesApi.getBlocksByHeightWithLimit(height.toString(), limit), (body) =>
90-
body.map((blockDTO) => this.toBlockInfo(blockDTO)),
90+
body.map((blockDTO) => BlockHttp.toBlockInfo(blockDTO)),
9191
);
9292
}
9393

@@ -98,7 +98,7 @@ export class BlockHttp extends Http implements BlockRepository {
9898
* @param {BlockInfoDTO} dto the dto object from rest.
9999
* @returns {BlockInfo} a BlockInfo model
100100
*/
101-
private toBlockInfo(dto: BlockInfoDTO): BlockInfo {
101+
public static toBlockInfo(dto: BlockInfoDTO): BlockInfo {
102102
const networkType = dto.block.network.valueOf();
103103
return new BlockInfo(
104104
dto.meta.hash,

src/infrastructure/IListener.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,21 @@ export interface IListener {
7171
* it emits a new Transaction in the event stream.
7272
*
7373
* @param address address we listen when a transaction is in unconfirmed state
74+
* @param transactionHash transactionHash for filtering multiple transactions
7475
* @return an observable stream of Transaction with state unconfirmed
7576
*/
76-
unconfirmedAdded(address: Address): Observable<Transaction>;
77+
unconfirmedAdded(address: Address, transactionHash?: string): Observable<Transaction>;
7778

7879
/**
7980
* Returns an observable stream of Transaction Hashes for specific address.
8081
* Each time a transaction with state unconfirmed changes its state,
8182
* it emits a new message with the transaction hash in the event stream.
8283
*
8384
* @param address address we listen when a transaction is removed from unconfirmed state
85+
* @param transactionHash the transaction hash filter.
8486
* @return an observable stream of Strings with the transaction hash
8587
*/
86-
unconfirmedRemoved(address: Address): Observable<string>;
88+
unconfirmedRemoved(address: Address, transactionHash?: string): Observable<string>;
8789

8890
/**
8991
* Return an observable of {@link AggregateTransaction} for specific address.
@@ -102,19 +104,21 @@ export interface IListener {
102104
* it emits a new message with the transaction hash in the event stream.
103105
*
104106
* @param address address we listen when a transaction is confirmed or rejected
107+
* @param transactionHash the transaction hash filter.
105108
* @return an observable stream of Strings with the transaction hash
106109
*/
107-
aggregateBondedRemoved(address: Address): Observable<string>;
110+
aggregateBondedRemoved(address: Address, transactionHash?: string): Observable<string>;
108111

109112
/**
110113
* Returns an observable stream of {@link TransactionStatusError} for specific address.
111114
* Each time a transaction contains an error,
112115
* it emits a new message with the transaction status error in the event stream.
113116
*
114117
* @param address address we listen to be notified when some error happened
118+
* @param transactionHash transactionHash for filtering multiple transactions
115119
* @return an observable stream of {@link TransactionStatusError}
116120
*/
117-
status(address: Address): Observable<TransactionStatusError>;
121+
status(address: Address, transactionHash?: string): Observable<TransactionStatusError>;
118122

119123
/**
120124
* Returns an observable stream of {@link CosignatureSignedTransaction} for specific address.

0 commit comments

Comments
 (0)