Skip to content

Commit ef0e3d1

Browse files
rg911haryu703AnthonyLawfboucquez
authored
Dev -> Main (#764)
* fix import path (#748) (#749) Co-authored-by: haryu703 <[email protected]> * Added from / to height in receipt search (#750) * Notification multisig (#752) * - Subscribe multisig account from cosigner subscription - Fixed #751 * Lint fix * 0.23.1 release (#755) * 0.23.1 release node * updated versions * fixes finalizationEpoch (#758) * Fixed #754 (#757) * smal fix on mosaic restriction service * Fixed #760 (#761) - Removed NamespaceName api call - filter transaction by unrsolved address * Sub NamespaceId generation bug fix (#763) * Fixed #753 * Removed unused var * Add more unit tests Co-authored-by: fboucquez <[email protected]> * v0.23.2 release change log Co-authored-by: haryu703 <[email protected]> Co-authored-by: Anthony Law <[email protected]> Co-authored-by: fboucquez <[email protected]>
1 parent d96aa90 commit ef0e3d1

37 files changed

+254
-315
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
44

55
The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [0.23.2] - 15-Feb-2021
8+
9+
**Milestone**: Catapult-server main(0.10.0.6)
10+
Package | Version | Link
11+
---|---|---
12+
SDK Core| v0.23.2 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk)
13+
Catbuffer | v0.1.1 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript)
14+
Client Library | v0.11.1 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client)
15+
16+
- Fixed subnamespaceId generation issue in `NamespaceRegistrationTransaction`.
17+
- Fixed `mosaicRestrictionTransactionService` error handling issue.
18+
- Fixed `finalizationEpoch` issue in the dto model.
19+
- Changed WebSocket listener subscription to use `UnresolvedAddress` without querying the rest-gateway.
20+
721
## [0.23.1] - 02-Feb-2021
822

923
**Milestone**: Catapult-server main(0.10.0.6)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ The Symbol SDK for TypeScript / JavaScript allows you to develop web, mobile, an
99

1010
## Important Notes
1111

12-
### _Catapult-Server_ Network Compatibility ([email protected].6)
12+
### _Catapult-Server_ Network Compatibility ([email protected].7)
1313

14-
Symbol network pre-launch [catapult-server](https://github.com/nemtech/catapult-server/releases/tag/v0.10.0.6), **it is recommended to use this package's 0.23.1 version and upwards for the upcoming pre-release versions and final release**.
14+
Symbol network pre-launch [catapult-server](https://github.com/nemtech/catapult-server/releases/tag/v0.10.0.7), **it is recommended to use this package's 0.23.2 version and upwards for the upcoming pre-release versions and final release**.
1515

1616
Find the complete release notes [here](CHANGELOG.md).
1717

src/infrastructure/ChainHttp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class ChainHttp extends Http implements ChainRepository {
6060
UInt64.fromNumericString(body.latestFinalizedBlock.height),
6161
body.latestFinalizedBlock.hash,
6262
body.latestFinalizedBlock.finalizationPoint,
63-
body.latestFinalizedBlock.finalizationPoint,
63+
body.latestFinalizedBlock.finalizationEpoch,
6464
),
6565
),
6666
);

src/infrastructure/Listener.ts

Lines changed: 51 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Observable, of, OperatorFunction, Subject } from 'rxjs';
18-
import { catchError, filter, flatMap, map, mergeMap, share, switchMap } from 'rxjs/operators';
17+
import { Observable, of, Subject } from 'rxjs';
18+
import { catchError, filter, map, mergeMap, share, switchMap } from 'rxjs/operators';
1919
import { BlockInfoDTO } from 'symbol-openapi-typescript-fetch-client';
2020
import * as WebSocket from 'ws';
2121
import { UnresolvedAddress } from '../model';
2222
import { Address } from '../model/account/Address';
2323
import { PublicAccount } from '../model/account/PublicAccount';
2424
import { FinalizedBlock } from '../model/blockchain/FinalizedBlock';
2525
import { NewBlock } from '../model/blockchain/NewBlock';
26-
import { NamespaceName } from '../model/namespace/NamespaceName';
2726
import { AggregateTransaction } from '../model/transaction/AggregateTransaction';
2827
import { CosignatureSignedTransaction } from '../model/transaction/CosignatureSignedTransaction';
2928
import { Deadline } from '../model/transaction/Deadline';
@@ -335,24 +334,25 @@ export class Listener implements IListener {
335334
transactionHash?: string,
336335
subscribeMultisig = false,
337336
): Observable<T> {
338-
return this.getResolvedAddress(unresolvedAddress).pipe(
339-
mergeMap((address: Address) => {
340-
return this.subscribeWithMultig(address, channel, subscribeMultisig).pipe(
341-
switchMap((subscribers) => {
342-
return this.messageSubject.asObservable().pipe(
343-
filter((listenerMessage) => listenerMessage.channelName === channel),
344-
filter((listenerMessage) => listenerMessage.message instanceof Transaction),
345-
switchMap((_) => {
346-
const transactionObservable = of(_.message as T).pipe(
347-
filter((transaction) => this.filterHash(transaction, transactionHash)),
348-
);
349-
if (subscribers.includes(_.channelParam.toUpperCase())) {
350-
return transactionObservable;
351-
} else {
352-
return transactionObservable.pipe(this.filterByNotifyAccount(address));
353-
}
354-
}),
337+
return this.subscribeWithMultig(unresolvedAddress, channel, subscribeMultisig).pipe(
338+
switchMap((subscribers) => {
339+
return this.messageSubject.asObservable().pipe(
340+
filter((listenerMessage) => listenerMessage.channelName === channel),
341+
filter((listenerMessage) => listenerMessage.message instanceof Transaction),
342+
switchMap((_) => {
343+
const transactionObservable = of(_.message as T).pipe(
344+
filter((transaction) => this.filterHash(transaction, transactionHash)),
355345
);
346+
if (subscribers.includes(_.channelParam.toUpperCase())) {
347+
return transactionObservable;
348+
} else {
349+
return transactionObservable.pipe(
350+
filter(
351+
(transaction) =>
352+
transaction.isSigned(unresolvedAddress) || transaction.shouldNotifyAccount(unresolvedAddress),
353+
),
354+
);
355+
}
356356
}),
357357
);
358358
}),
@@ -414,18 +414,14 @@ export class Listener implements IListener {
414414
transactionHash: string | undefined,
415415
subscribeMultisig = false,
416416
): Observable<string> {
417-
return this.getResolvedAddress(unresolvedAddress).pipe(
418-
mergeMap((address: Address) => {
419-
return this.subscribeWithMultig(address, channel, subscribeMultisig).pipe(
420-
switchMap((subscribers) => {
421-
return this.messageSubject.asObservable().pipe(
422-
filter((_) => _.channelName === channel),
423-
filter((_) => typeof _.message === 'string'),
424-
filter((_) => subscribers.includes(_.channelParam.toUpperCase())),
425-
map((_) => _.message as string),
426-
filter((_) => !transactionHash || _.toUpperCase() == transactionHash.toUpperCase()),
427-
);
428-
}),
417+
return this.subscribeWithMultig(unresolvedAddress, channel, subscribeMultisig).pipe(
418+
switchMap((subscribers) => {
419+
return this.messageSubject.asObservable().pipe(
420+
filter((_) => _.channelName === channel),
421+
filter((_) => typeof _.message === 'string'),
422+
filter((_) => subscribers.includes(_.channelParam.toUpperCase())),
423+
map((_) => _.message as string),
424+
filter((_) => !transactionHash || _.toUpperCase() == transactionHash.toUpperCase()),
429425
);
430426
}),
431427
);
@@ -469,39 +465,6 @@ export class Listener implements IListener {
469465
}
470466
}
471467

472-
/**
473-
* It filters a transaction by address using the aliases.
474-
*
475-
* This method delegates the rest loading as much as possible. It tries to filter by signer first.
476-
*
477-
* Note: this filter performs one extra rest call and it should be down in the pipeline.
478-
*
479-
* @param address the address.
480-
* @return an observable filter.
481-
*/
482-
private filterByNotifyAccount<T extends Transaction>(address: Address): OperatorFunction<T, T> {
483-
return (transactionObservable): Observable<T> => {
484-
return transactionObservable.pipe(
485-
flatMap((transaction) => {
486-
if (transaction.isSigned(address)) {
487-
return of(transaction);
488-
}
489-
const namespaceIdsObservable = this.namespaceRepository.getAccountsNames([address]).pipe(
490-
map((names) => {
491-
return ([] as NamespaceName[])
492-
.concat(...Array.from(names.map((accountName) => accountName.names)))
493-
.map((name) => name.namespaceId);
494-
}),
495-
);
496-
return namespaceIdsObservable.pipe(
497-
filter((namespaceIds) => transaction.shouldNotifyAccount(address, namespaceIds)),
498-
map(() => transaction),
499-
);
500-
}),
501-
);
502-
};
503-
}
504-
505468
/**
506469
* Returns an observable stream of {@link CosignatureSignedTransaction} for specific address.
507470
* Each time a cosigner signs a transaction the address initialized,
@@ -512,17 +475,13 @@ export class Listener implements IListener {
512475
* @return an observable stream of {@link CosignatureSignedTransaction}
513476
*/
514477
public cosignatureAdded(unresolvedAddress: UnresolvedAddress, subscribeMultisig = false): Observable<CosignatureSignedTransaction> {
515-
return this.getResolvedAddress(unresolvedAddress).pipe(
516-
mergeMap((address: Address) => {
517-
return this.subscribeWithMultig(address, ListenerChannelName.cosignature, subscribeMultisig).pipe(
518-
switchMap((subscribers) => {
519-
return this.messageSubject.asObservable().pipe(
520-
filter((_) => _.channelName.toUpperCase() === ListenerChannelName.cosignature.toUpperCase()),
521-
filter((_) => _.message instanceof CosignatureSignedTransaction),
522-
filter((_) => subscribers.includes(_.channelParam.toUpperCase())),
523-
map((_) => _.message as CosignatureSignedTransaction),
524-
);
525-
}),
478+
return this.subscribeWithMultig(unresolvedAddress, ListenerChannelName.cosignature, subscribeMultisig).pipe(
479+
switchMap((subscribers) => {
480+
return this.messageSubject.asObservable().pipe(
481+
filter((_) => _.channelName.toUpperCase() === ListenerChannelName.cosignature.toUpperCase()),
482+
filter((_) => _.message instanceof CosignatureSignedTransaction),
483+
filter((_) => subscribers.includes(_.channelParam.toUpperCase())),
484+
map((_) => _.message as CosignatureSignedTransaction),
526485
);
527486
}),
528487
);
@@ -604,22 +563,26 @@ export class Listener implements IListener {
604563
* @param multisig subscribe multisig account
605564
* @returns {string[]}
606565
*/
607-
private subscribeWithMultig(cosigner: Address, channel: ListenerChannelName, multisig = false): Observable<string[]> {
566+
private subscribeWithMultig(cosigner: UnresolvedAddress, channel: ListenerChannelName, multisig = false): Observable<string[]> {
608567
if (!multisig) {
609568
this.subscribeTo(`${channel.toString()}/${cosigner.plain()}`);
610569
return of([cosigner.plain()]);
611570
}
612-
return this.multisigRepository!.getMultisigAccountInfo(cosigner).pipe(
613-
map((multisigInfo) => {
614-
const subscribers = [cosigner].concat(multisigInfo.multisigAddresses);
615-
subscribers.forEach((m) => {
616-
this.subscribeTo(`${channel.toString()}/${m.plain()}`);
617-
});
618-
return subscribers.map((m) => m.plain());
619-
}),
620-
catchError(() => {
621-
this.subscribeTo(`${channel.toString()}/${cosigner.plain()}`);
622-
return of([cosigner.plain()]);
571+
return this.getResolvedAddress(cosigner).pipe(
572+
mergeMap((address: Address) => {
573+
return this.multisigRepository!.getMultisigAccountInfo(address).pipe(
574+
map((multisigInfo) => {
575+
const subscribers = [cosigner].concat(multisigInfo.multisigAddresses);
576+
subscribers.forEach((m) => {
577+
this.subscribeTo(`${channel.toString()}/${m.plain()}`);
578+
});
579+
return subscribers.map((m) => m.plain());
580+
}),
581+
catchError(() => {
582+
this.subscribeTo(`${channel.toString()}/${cosigner.plain()}`);
583+
return of([cosigner.plain()]);
584+
}),
585+
);
623586
}),
624587
);
625588
}

src/infrastructure/searchCriteria/RestrictionMosaicSearchCriteria.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { Address } from '../../model/account/Address';
1818
import { MosaicId } from '../../model/mosaic/MosaicId';
19-
import { MosaicRestrictionType } from '../../model/restriction/MosaicRestrictionType';
19+
import { MosaicRestrictionEntryType } from '../../model/restriction/MosaicRestrictionEntryType';
2020
import { SearchCriteria } from './SearchCriteria';
2121

2222
/**
@@ -32,7 +32,7 @@ export interface RestrictionMosaicSearchCriteria extends SearchCriteria {
3232
/**
3333
* Mosaic restriction entity type. (optional)
3434
*/
35-
entryType?: MosaicRestrictionType;
35+
entryType?: MosaicRestrictionEntryType;
3636

3737
/**
3838
* Mosaic restriction target address. (optional)

src/model/UInt64.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export class UInt64 {
9494
/**
9595
* Get DTO representation with format: `[lower, higher]`
9696
*
97-
* @internal
9897
* @returns {[number,number]}
9998
*/
10099
public toDTO(): number[] {

src/model/namespace/NamespaceId.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,12 @@ export class NamespaceId {
106106
public encodeUnresolvedAddress(networkType: NetworkType): Uint8Array {
107107
return RawAddress.aliasToRecipient(Convert.hexToUint8(this.toHex()), networkType);
108108
}
109+
110+
/**
111+
* Get string value of id
112+
* @returns {string}
113+
*/
114+
public plain(): string {
115+
return this.toHex();
116+
}
109117
}

src/model/transaction/AccountAddressRestrictionTransaction.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import {
2727
} from 'catbuffer-typescript';
2828
import { Convert } from '../../core/format';
2929
import { DtoMapping, UnresolvedMapping } from '../../core/utils';
30-
import { Address, PublicAccount, UnresolvedAddress } from '../account';
31-
import { NamespaceId } from '../namespace';
30+
import { PublicAccount, UnresolvedAddress } from '../account';
3231
import { NetworkType } from '../network';
3332
import { Statement } from '../receipt';
3433
import { AddressRestrictionFlag } from '../restriction';
@@ -201,14 +200,13 @@ export class AccountAddressRestrictionTransaction extends Transaction {
201200
* @internal
202201
* Check a given address should be notified in websocket channels
203202
* @param address address to be notified
204-
* @param alias address alias (names)
205203
* @returns {boolean}
206204
*/
207-
public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean {
205+
public shouldNotifyAccount(address: UnresolvedAddress): boolean {
208206
return (
209207
super.isSigned(address) ||
210-
this.restrictionAdditions.find((_) => _.equals(address) || alias.find((a) => _.equals(a)) !== undefined) !== undefined ||
211-
this.restrictionDeletions.find((_) => _.equals(address) || alias.find((a) => _.equals(a)) !== undefined) !== undefined
208+
this.restrictionAdditions.find((_) => _.equals(address)) !== undefined ||
209+
this.restrictionDeletions.find((_) => _.equals(address)) !== undefined
212210
);
213211
}
214212
}

src/model/transaction/AccountKeyLinkTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
TransactionBuilder,
2525
} from 'catbuffer-typescript';
2626
import { Convert } from '../../core/format';
27-
import { Address, PublicAccount } from '../account';
27+
import { Address, PublicAccount, UnresolvedAddress } from '../account';
2828
import { NetworkType } from '../network';
2929
import { UInt64 } from '../UInt64';
3030
import { Deadline } from './Deadline';
@@ -178,7 +178,7 @@ export class AccountKeyLinkTransaction extends Transaction {
178178
* @param address address to be notified
179179
* @returns {boolean}
180180
*/
181-
public shouldNotifyAccount(address: Address): boolean {
181+
public shouldNotifyAccount(address: UnresolvedAddress): boolean {
182182
return super.isSigned(address) || Address.createFromPublicKey(this.linkedPublicKey, this.networkType).equals(address);
183183
}
184184
}

src/model/transaction/AccountMetadataTransaction.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ import {
2525
} from 'catbuffer-typescript';
2626
import { Convert } from '../../core/format';
2727
import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping';
28-
import { Address } from '../account/Address';
2928
import { PublicAccount } from '../account/PublicAccount';
3029
import { UnresolvedAddress } from '../account/UnresolvedAddress';
31-
import { NamespaceId } from '../namespace/NamespaceId';
3230
import { NetworkType } from '../network/NetworkType';
3331
import { UInt64 } from '../UInt64';
3432
import { Deadline } from './Deadline';
@@ -203,14 +201,9 @@ export class AccountMetadataTransaction extends Transaction {
203201
* @internal
204202
* Check a given address should be notified in websocket channels
205203
* @param address address to be notified
206-
* @param alias address alias (names)
207204
* @returns {boolean}
208205
*/
209-
public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean {
210-
return (
211-
super.isSigned(address) ||
212-
this.targetAddress.equals(address) ||
213-
alias.find((name) => this.targetAddress.equals(name)) !== undefined
214-
);
206+
public shouldNotifyAccount(address: UnresolvedAddress): boolean {
207+
return super.isSigned(address) || this.targetAddress.equals(address);
215208
}
216209
}

0 commit comments

Comments
 (0)