From ef0e3d1a7913f6ee5fbb620b383bd96671276177 Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Mon, 15 Feb 2021 15:43:56 +0000 Subject: [PATCH] Dev -> Main (#764) * fix import path (#748) (#749) Co-authored-by: haryu703 <34744512+haryu703@users.noreply.github.com> * 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 * v0.23.2 release change log Co-authored-by: haryu703 <34744512+haryu703@users.noreply.github.com> Co-authored-by: Anthony Law Co-authored-by: fboucquez --- CHANGELOG.md | 14 ++ README.md | 4 +- src/infrastructure/ChainHttp.ts | 2 +- src/infrastructure/Listener.ts | 139 +++++++----------- .../RestrictionMosaicSearchCriteria.ts | 4 +- src/model/UInt64.ts | 1 - src/model/namespace/NamespaceId.ts | 8 + .../AccountAddressRestrictionTransaction.ts | 10 +- .../transaction/AccountKeyLinkTransaction.ts | 4 +- .../transaction/AccountMetadataTransaction.ts | 11 +- src/model/transaction/AggregateTransaction.ts | 9 +- .../MosaicAddressRestrictionTransaction.ts | 9 +- .../transaction/MosaicMetadataTransaction.ts | 11 +- .../MultisigAccountModificationTransaction.ts | 9 +- .../NamespaceMetadataTransaction.ts | 10 +- .../NamespaceRegistrationTransaction.ts | 3 +- .../transaction/SecretLockTransaction.ts | 11 +- .../transaction/SecretProofTransaction.ts | 11 +- src/model/transaction/Transaction.ts | 8 +- src/model/transaction/TransferTransaction.ts | 9 +- src/service/CurrencyService.ts | 2 - .../MosaicRestrictionTransactionService.ts | 38 ++--- test/core/utils/TransactionMapping.spec.ts | 2 +- test/infrastructure/ChainHttp.spec.ts | 16 +- test/infrastructure/Listener.spec.ts | 46 +++--- .../AccountMetadataTransaction.spec.ts | 14 +- .../AccountRestrictionTransaction.spec.ts | 26 ++-- .../transaction/AggregateTransaction.spec.ts | 14 +- .../MosaicMetadataTransaction.spec.ts | 12 +- ...isigAccountModificationTransaction.spec.ts | 32 ++-- .../NamespaceMetadataTransaction.spec.ts | 12 +- .../NamespaceRegistrationTransaction.spec.ts | 25 +++- .../transaction/SecretLockTransaction.spec.ts | 10 +- .../SecretProofTransaction.spec.ts | 10 +- test/model/transaction/Transaction.spec.ts | 4 +- .../transaction/TransferTransaction.spec.ts | 9 +- ...osaicRestrictionTransactionservice.spec.ts | 10 +- 37 files changed, 254 insertions(+), 315 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c0aba028..322dcda4cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.23.2] - 15-Feb-2021 + +**Milestone**: Catapult-server main(0.10.0.6) + Package | Version | Link +---|---|--- +SDK Core| v0.23.2 | [symbol-sdk](https://www.npmjs.com/package/symbol-sdk) +Catbuffer | v0.1.1 | [catbuffer-typescript](https://www.npmjs.com/package/catbuffer-typescript) +Client Library | v0.11.1 | [symbol-openapi-typescript-fetch-client](https://www.npmjs.com/package/symbol-openapi-typescript-fetch-client) + +- Fixed subnamespaceId generation issue in `NamespaceRegistrationTransaction`. +- Fixed `mosaicRestrictionTransactionService` error handling issue. +- Fixed `finalizationEpoch` issue in the dto model. +- Changed WebSocket listener subscription to use `UnresolvedAddress` without querying the rest-gateway. + ## [0.23.1] - 02-Feb-2021 **Milestone**: Catapult-server main(0.10.0.6) diff --git a/README.md b/README.md index d9a5bf3e0f..f09769944a 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ The Symbol SDK for TypeScript / JavaScript allows you to develop web, mobile, an ## Important Notes -### _Catapult-Server_ Network Compatibility (catapult-server@0.10.0.6) +### _Catapult-Server_ Network Compatibility (catapult-server@0.10.0.7) -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**. +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**. Find the complete release notes [here](CHANGELOG.md). diff --git a/src/infrastructure/ChainHttp.ts b/src/infrastructure/ChainHttp.ts index 2349900812..9af94c3e5b 100644 --- a/src/infrastructure/ChainHttp.ts +++ b/src/infrastructure/ChainHttp.ts @@ -60,7 +60,7 @@ export class ChainHttp extends Http implements ChainRepository { UInt64.fromNumericString(body.latestFinalizedBlock.height), body.latestFinalizedBlock.hash, body.latestFinalizedBlock.finalizationPoint, - body.latestFinalizedBlock.finalizationPoint, + body.latestFinalizedBlock.finalizationEpoch, ), ), ); diff --git a/src/infrastructure/Listener.ts b/src/infrastructure/Listener.ts index b3dc8be545..946c8fcda0 100644 --- a/src/infrastructure/Listener.ts +++ b/src/infrastructure/Listener.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { Observable, of, OperatorFunction, Subject } from 'rxjs'; -import { catchError, filter, flatMap, map, mergeMap, share, switchMap } from 'rxjs/operators'; +import { Observable, of, Subject } from 'rxjs'; +import { catchError, filter, map, mergeMap, share, switchMap } from 'rxjs/operators'; import { BlockInfoDTO } from 'symbol-openapi-typescript-fetch-client'; import * as WebSocket from 'ws'; import { UnresolvedAddress } from '../model'; @@ -23,7 +23,6 @@ import { Address } from '../model/account/Address'; import { PublicAccount } from '../model/account/PublicAccount'; import { FinalizedBlock } from '../model/blockchain/FinalizedBlock'; import { NewBlock } from '../model/blockchain/NewBlock'; -import { NamespaceName } from '../model/namespace/NamespaceName'; import { AggregateTransaction } from '../model/transaction/AggregateTransaction'; import { CosignatureSignedTransaction } from '../model/transaction/CosignatureSignedTransaction'; import { Deadline } from '../model/transaction/Deadline'; @@ -335,24 +334,25 @@ export class Listener implements IListener { transactionHash?: string, subscribeMultisig = false, ): Observable { - return this.getResolvedAddress(unresolvedAddress).pipe( - mergeMap((address: Address) => { - return this.subscribeWithMultig(address, channel, subscribeMultisig).pipe( - switchMap((subscribers) => { - return this.messageSubject.asObservable().pipe( - filter((listenerMessage) => listenerMessage.channelName === channel), - filter((listenerMessage) => listenerMessage.message instanceof Transaction), - switchMap((_) => { - const transactionObservable = of(_.message as T).pipe( - filter((transaction) => this.filterHash(transaction, transactionHash)), - ); - if (subscribers.includes(_.channelParam.toUpperCase())) { - return transactionObservable; - } else { - return transactionObservable.pipe(this.filterByNotifyAccount(address)); - } - }), + return this.subscribeWithMultig(unresolvedAddress, channel, subscribeMultisig).pipe( + switchMap((subscribers) => { + return this.messageSubject.asObservable().pipe( + filter((listenerMessage) => listenerMessage.channelName === channel), + filter((listenerMessage) => listenerMessage.message instanceof Transaction), + switchMap((_) => { + const transactionObservable = of(_.message as T).pipe( + filter((transaction) => this.filterHash(transaction, transactionHash)), ); + if (subscribers.includes(_.channelParam.toUpperCase())) { + return transactionObservable; + } else { + return transactionObservable.pipe( + filter( + (transaction) => + transaction.isSigned(unresolvedAddress) || transaction.shouldNotifyAccount(unresolvedAddress), + ), + ); + } }), ); }), @@ -414,18 +414,14 @@ export class Listener implements IListener { transactionHash: string | undefined, subscribeMultisig = false, ): Observable { - return this.getResolvedAddress(unresolvedAddress).pipe( - mergeMap((address: Address) => { - return this.subscribeWithMultig(address, channel, subscribeMultisig).pipe( - switchMap((subscribers) => { - return this.messageSubject.asObservable().pipe( - filter((_) => _.channelName === channel), - filter((_) => typeof _.message === 'string'), - filter((_) => subscribers.includes(_.channelParam.toUpperCase())), - map((_) => _.message as string), - filter((_) => !transactionHash || _.toUpperCase() == transactionHash.toUpperCase()), - ); - }), + return this.subscribeWithMultig(unresolvedAddress, channel, subscribeMultisig).pipe( + switchMap((subscribers) => { + return this.messageSubject.asObservable().pipe( + filter((_) => _.channelName === channel), + filter((_) => typeof _.message === 'string'), + filter((_) => subscribers.includes(_.channelParam.toUpperCase())), + map((_) => _.message as string), + filter((_) => !transactionHash || _.toUpperCase() == transactionHash.toUpperCase()), ); }), ); @@ -469,39 +465,6 @@ export class Listener implements IListener { } } - /** - * It filters a transaction by address using the aliases. - * - * This method delegates the rest loading as much as possible. It tries to filter by signer first. - * - * Note: this filter performs one extra rest call and it should be down in the pipeline. - * - * @param address the address. - * @return an observable filter. - */ - private filterByNotifyAccount(address: Address): OperatorFunction { - return (transactionObservable): Observable => { - return transactionObservable.pipe( - flatMap((transaction) => { - if (transaction.isSigned(address)) { - return of(transaction); - } - const namespaceIdsObservable = this.namespaceRepository.getAccountsNames([address]).pipe( - map((names) => { - return ([] as NamespaceName[]) - .concat(...Array.from(names.map((accountName) => accountName.names))) - .map((name) => name.namespaceId); - }), - ); - return namespaceIdsObservable.pipe( - filter((namespaceIds) => transaction.shouldNotifyAccount(address, namespaceIds)), - map(() => transaction), - ); - }), - ); - }; - } - /** * Returns an observable stream of {@link CosignatureSignedTransaction} for specific address. * Each time a cosigner signs a transaction the address initialized, @@ -512,17 +475,13 @@ export class Listener implements IListener { * @return an observable stream of {@link CosignatureSignedTransaction} */ public cosignatureAdded(unresolvedAddress: UnresolvedAddress, subscribeMultisig = false): Observable { - return this.getResolvedAddress(unresolvedAddress).pipe( - mergeMap((address: Address) => { - return this.subscribeWithMultig(address, ListenerChannelName.cosignature, subscribeMultisig).pipe( - switchMap((subscribers) => { - return this.messageSubject.asObservable().pipe( - filter((_) => _.channelName.toUpperCase() === ListenerChannelName.cosignature.toUpperCase()), - filter((_) => _.message instanceof CosignatureSignedTransaction), - filter((_) => subscribers.includes(_.channelParam.toUpperCase())), - map((_) => _.message as CosignatureSignedTransaction), - ); - }), + return this.subscribeWithMultig(unresolvedAddress, ListenerChannelName.cosignature, subscribeMultisig).pipe( + switchMap((subscribers) => { + return this.messageSubject.asObservable().pipe( + filter((_) => _.channelName.toUpperCase() === ListenerChannelName.cosignature.toUpperCase()), + filter((_) => _.message instanceof CosignatureSignedTransaction), + filter((_) => subscribers.includes(_.channelParam.toUpperCase())), + map((_) => _.message as CosignatureSignedTransaction), ); }), ); @@ -604,22 +563,26 @@ export class Listener implements IListener { * @param multisig subscribe multisig account * @returns {string[]} */ - private subscribeWithMultig(cosigner: Address, channel: ListenerChannelName, multisig = false): Observable { + private subscribeWithMultig(cosigner: UnresolvedAddress, channel: ListenerChannelName, multisig = false): Observable { if (!multisig) { this.subscribeTo(`${channel.toString()}/${cosigner.plain()}`); return of([cosigner.plain()]); } - return this.multisigRepository!.getMultisigAccountInfo(cosigner).pipe( - map((multisigInfo) => { - const subscribers = [cosigner].concat(multisigInfo.multisigAddresses); - subscribers.forEach((m) => { - this.subscribeTo(`${channel.toString()}/${m.plain()}`); - }); - return subscribers.map((m) => m.plain()); - }), - catchError(() => { - this.subscribeTo(`${channel.toString()}/${cosigner.plain()}`); - return of([cosigner.plain()]); + return this.getResolvedAddress(cosigner).pipe( + mergeMap((address: Address) => { + return this.multisigRepository!.getMultisigAccountInfo(address).pipe( + map((multisigInfo) => { + const subscribers = [cosigner].concat(multisigInfo.multisigAddresses); + subscribers.forEach((m) => { + this.subscribeTo(`${channel.toString()}/${m.plain()}`); + }); + return subscribers.map((m) => m.plain()); + }), + catchError(() => { + this.subscribeTo(`${channel.toString()}/${cosigner.plain()}`); + return of([cosigner.plain()]); + }), + ); }), ); } diff --git a/src/infrastructure/searchCriteria/RestrictionMosaicSearchCriteria.ts b/src/infrastructure/searchCriteria/RestrictionMosaicSearchCriteria.ts index 93a5dd915e..dbaedafc41 100644 --- a/src/infrastructure/searchCriteria/RestrictionMosaicSearchCriteria.ts +++ b/src/infrastructure/searchCriteria/RestrictionMosaicSearchCriteria.ts @@ -16,7 +16,7 @@ import { Address } from '../../model/account/Address'; import { MosaicId } from '../../model/mosaic/MosaicId'; -import { MosaicRestrictionType } from '../../model/restriction/MosaicRestrictionType'; +import { MosaicRestrictionEntryType } from '../../model/restriction/MosaicRestrictionEntryType'; import { SearchCriteria } from './SearchCriteria'; /** @@ -32,7 +32,7 @@ export interface RestrictionMosaicSearchCriteria extends SearchCriteria { /** * Mosaic restriction entity type. (optional) */ - entryType?: MosaicRestrictionType; + entryType?: MosaicRestrictionEntryType; /** * Mosaic restriction target address. (optional) diff --git a/src/model/UInt64.ts b/src/model/UInt64.ts index 22daa127c7..a568c184bd 100644 --- a/src/model/UInt64.ts +++ b/src/model/UInt64.ts @@ -94,7 +94,6 @@ export class UInt64 { /** * Get DTO representation with format: `[lower, higher]` * - * @internal * @returns {[number,number]} */ public toDTO(): number[] { diff --git a/src/model/namespace/NamespaceId.ts b/src/model/namespace/NamespaceId.ts index 62c1f903a4..b486e09dca 100644 --- a/src/model/namespace/NamespaceId.ts +++ b/src/model/namespace/NamespaceId.ts @@ -106,4 +106,12 @@ export class NamespaceId { public encodeUnresolvedAddress(networkType: NetworkType): Uint8Array { return RawAddress.aliasToRecipient(Convert.hexToUint8(this.toHex()), networkType); } + + /** + * Get string value of id + * @returns {string} + */ + public plain(): string { + return this.toHex(); + } } diff --git a/src/model/transaction/AccountAddressRestrictionTransaction.ts b/src/model/transaction/AccountAddressRestrictionTransaction.ts index fe50442492..d99c656d69 100644 --- a/src/model/transaction/AccountAddressRestrictionTransaction.ts +++ b/src/model/transaction/AccountAddressRestrictionTransaction.ts @@ -27,8 +27,7 @@ import { } from 'catbuffer-typescript'; import { Convert } from '../../core/format'; import { DtoMapping, UnresolvedMapping } from '../../core/utils'; -import { Address, PublicAccount, UnresolvedAddress } from '../account'; -import { NamespaceId } from '../namespace'; +import { PublicAccount, UnresolvedAddress } from '../account'; import { NetworkType } from '../network'; import { Statement } from '../receipt'; import { AddressRestrictionFlag } from '../restriction'; @@ -201,14 +200,13 @@ export class AccountAddressRestrictionTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { + public shouldNotifyAccount(address: UnresolvedAddress): boolean { return ( super.isSigned(address) || - this.restrictionAdditions.find((_) => _.equals(address) || alias.find((a) => _.equals(a)) !== undefined) !== undefined || - this.restrictionDeletions.find((_) => _.equals(address) || alias.find((a) => _.equals(a)) !== undefined) !== undefined + this.restrictionAdditions.find((_) => _.equals(address)) !== undefined || + this.restrictionDeletions.find((_) => _.equals(address)) !== undefined ); } } diff --git a/src/model/transaction/AccountKeyLinkTransaction.ts b/src/model/transaction/AccountKeyLinkTransaction.ts index bf2261481a..fd689faf40 100644 --- a/src/model/transaction/AccountKeyLinkTransaction.ts +++ b/src/model/transaction/AccountKeyLinkTransaction.ts @@ -24,7 +24,7 @@ import { TransactionBuilder, } from 'catbuffer-typescript'; import { Convert } from '../../core/format'; -import { Address, PublicAccount } from '../account'; +import { Address, PublicAccount, UnresolvedAddress } from '../account'; import { NetworkType } from '../network'; import { UInt64 } from '../UInt64'; import { Deadline } from './Deadline'; @@ -178,7 +178,7 @@ export class AccountKeyLinkTransaction extends Transaction { * @param address address to be notified * @returns {boolean} */ - public shouldNotifyAccount(address: Address): boolean { + public shouldNotifyAccount(address: UnresolvedAddress): boolean { return super.isSigned(address) || Address.createFromPublicKey(this.linkedPublicKey, this.networkType).equals(address); } } diff --git a/src/model/transaction/AccountMetadataTransaction.ts b/src/model/transaction/AccountMetadataTransaction.ts index 6e741a1a93..9076fd577f 100644 --- a/src/model/transaction/AccountMetadataTransaction.ts +++ b/src/model/transaction/AccountMetadataTransaction.ts @@ -25,10 +25,8 @@ import { } from 'catbuffer-typescript'; import { Convert } from '../../core/format'; import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; -import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { UnresolvedAddress } from '../account/UnresolvedAddress'; -import { NamespaceId } from '../namespace/NamespaceId'; import { NetworkType } from '../network/NetworkType'; import { UInt64 } from '../UInt64'; import { Deadline } from './Deadline'; @@ -203,14 +201,9 @@ export class AccountMetadataTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.targetAddress.equals(address) || - alias.find((name) => this.targetAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.targetAddress.equals(address); } } diff --git a/src/model/transaction/AggregateTransaction.ts b/src/model/transaction/AggregateTransaction.ts index 183ced95a0..119f685385 100644 --- a/src/model/transaction/AggregateTransaction.ts +++ b/src/model/transaction/AggregateTransaction.ts @@ -31,8 +31,7 @@ import { KeyPair, MerkleHashBuilder, SHA3Hasher } from '../../core/crypto'; import { Convert } from '../../core/format'; import { DtoMapping } from '../../core/utils'; import { CreateTransactionFromPayload } from '../../infrastructure/transaction'; -import { Account, Address, PublicAccount } from '../account'; -import { NamespaceId } from '../namespace'; +import { Account, PublicAccount, UnresolvedAddress } from '../account'; import { NetworkType } from '../network'; import { Statement } from '../receipt'; import { UInt64 } from '../UInt64'; @@ -396,15 +395,13 @@ export class AggregateTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { + public shouldNotifyAccount(address: UnresolvedAddress): boolean { return ( super.isSigned(address) || this.cosignatures.find((_) => _.signer.address.equals(address)) !== undefined || - this.innerTransactions.find((innerTransaction: InnerTransaction) => innerTransaction.shouldNotifyAccount(address, alias)) !== - undefined + this.innerTransactions.find((innerTransaction: InnerTransaction) => innerTransaction.shouldNotifyAccount(address)) !== undefined ); } } diff --git a/src/model/transaction/MosaicAddressRestrictionTransaction.ts b/src/model/transaction/MosaicAddressRestrictionTransaction.ts index 4eb754b25f..d7c7d54f32 100644 --- a/src/model/transaction/MosaicAddressRestrictionTransaction.ts +++ b/src/model/transaction/MosaicAddressRestrictionTransaction.ts @@ -253,14 +253,9 @@ export class MosaicAddressRestrictionTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.targetAddress.equals(address) || - alias.find((name) => this.targetAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.targetAddress.equals(address); } } diff --git a/src/model/transaction/MosaicMetadataTransaction.ts b/src/model/transaction/MosaicMetadataTransaction.ts index f760c6dfc7..8de0fb4336 100644 --- a/src/model/transaction/MosaicMetadataTransaction.ts +++ b/src/model/transaction/MosaicMetadataTransaction.ts @@ -27,11 +27,9 @@ import { import { Convert } from '../../core/format'; import { DtoMapping } from '../../core/utils/DtoMapping'; import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; -import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { UnresolvedAddress } from '../account/UnresolvedAddress'; import { UnresolvedMosaicId } from '../mosaic/UnresolvedMosaicId'; -import { NamespaceId } from '../namespace/NamespaceId'; import { NetworkType } from '../network/NetworkType'; import { Statement } from '../receipt/Statement'; import { UInt64 } from '../UInt64'; @@ -228,14 +226,9 @@ export class MosaicMetadataTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.targetAddress.equals(address) || - alias.find((name) => this.targetAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.targetAddress.equals(address); } } diff --git a/src/model/transaction/MultisigAccountModificationTransaction.ts b/src/model/transaction/MultisigAccountModificationTransaction.ts index 57baf055dd..5fe980f776 100644 --- a/src/model/transaction/MultisigAccountModificationTransaction.ts +++ b/src/model/transaction/MultisigAccountModificationTransaction.ts @@ -25,10 +25,8 @@ import { } from 'catbuffer-typescript'; import { Convert } from '../../core/format'; import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; -import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { UnresolvedAddress } from '../account/UnresolvedAddress'; -import { NamespaceId } from '../namespace/NamespaceId'; import { NetworkType } from '../network/NetworkType'; import { UInt64 } from '../UInt64'; import { Deadline } from './Deadline'; @@ -217,14 +215,13 @@ export class MultisigAccountModificationTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { + public shouldNotifyAccount(address: UnresolvedAddress): boolean { return ( super.isSigned(address) || - this.addressAdditions.find((_) => _.equals(address) || alias.find((a) => _.equals(a)) !== undefined) !== undefined || - this.addressDeletions.find((_) => _.equals(address) || alias.find((a) => _.equals(a)) !== undefined) !== undefined + this.addressAdditions.find((_) => _.equals(address)) !== undefined || + this.addressDeletions.find((_) => _.equals(address)) !== undefined ); } } diff --git a/src/model/transaction/NamespaceMetadataTransaction.ts b/src/model/transaction/NamespaceMetadataTransaction.ts index f4f9d43649..7030f64198 100644 --- a/src/model/transaction/NamespaceMetadataTransaction.ts +++ b/src/model/transaction/NamespaceMetadataTransaction.ts @@ -25,7 +25,6 @@ import { } from 'catbuffer-typescript'; import { Convert } from '../../core/format'; import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; -import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { UnresolvedAddress } from '../account/UnresolvedAddress'; import { NamespaceId } from '../namespace/NamespaceId'; @@ -214,14 +213,9 @@ export class NamespaceMetadataTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.targetAddress.equals(address) || - alias.find((name) => this.targetAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.targetAddress.equals(address); } } diff --git a/src/model/transaction/NamespaceRegistrationTransaction.ts b/src/model/transaction/NamespaceRegistrationTransaction.ts index 64ac9abd08..fb6a791c21 100644 --- a/src/model/transaction/NamespaceRegistrationTransaction.ts +++ b/src/model/transaction/NamespaceRegistrationTransaction.ts @@ -24,6 +24,7 @@ import { TransactionBuilder, } from 'catbuffer-typescript'; import { Convert } from '../../core/format'; +import * as Utilities from '../../core/format/Utilities'; import { NamespaceMosaicIdGenerator } from '../../infrastructure/transaction'; import { Address, PublicAccount } from '../account'; import { NamespaceId, NamespaceRegistrationType } from '../namespace'; @@ -105,7 +106,7 @@ export class NamespaceRegistrationTransaction extends Transaction { const namespaceId = typeof parentNamespace === 'string' ? new NamespaceId(NamespaceMosaicIdGenerator.subnamespaceNamespaceId(parentNamespace, namespaceName)) - : new NamespaceId(NamespaceMosaicIdGenerator.namespaceId(namespaceName)); + : new NamespaceId(Utilities.generateNamespaceId(parentId.id.toDTO(), namespaceName)); return new NamespaceRegistrationTransaction( networkType, TransactionVersion.NAMESPACE_REGISTRATION, diff --git a/src/model/transaction/SecretLockTransaction.ts b/src/model/transaction/SecretLockTransaction.ts index f39ca41cc5..a731f9e454 100644 --- a/src/model/transaction/SecretLockTransaction.ts +++ b/src/model/transaction/SecretLockTransaction.ts @@ -29,12 +29,10 @@ import { import { Convert, Convert as convert } from '../../core/format'; import { DtoMapping } from '../../core/utils/DtoMapping'; import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; -import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { UnresolvedAddress } from '../account/UnresolvedAddress'; import { LockHashAlgorithm, LockHashAlgorithmLengthValidator } from '../lock/LockHashAlgorithm'; import { Mosaic } from '../mosaic/Mosaic'; -import { NamespaceId } from '../namespace/NamespaceId'; import { NetworkType } from '../network/NetworkType'; import { Statement } from '../receipt/Statement'; import { UInt64 } from '../UInt64'; @@ -245,14 +243,9 @@ export class SecretLockTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.recipientAddress.equals(address) || - alias.find((name) => this.recipientAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.recipientAddress.equals(address); } } diff --git a/src/model/transaction/SecretProofTransaction.ts b/src/model/transaction/SecretProofTransaction.ts index 382a5967d0..bd25b6ec71 100644 --- a/src/model/transaction/SecretProofTransaction.ts +++ b/src/model/transaction/SecretProofTransaction.ts @@ -27,11 +27,9 @@ import { import { Convert, Convert as convert } from '../../core/format'; import { DtoMapping } from '../../core/utils/DtoMapping'; import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping'; -import { Address } from '../account/Address'; import { PublicAccount } from '../account/PublicAccount'; import { UnresolvedAddress } from '../account/UnresolvedAddress'; import { LockHashAlgorithm, LockHashAlgorithmLengthValidator } from '../lock/LockHashAlgorithm'; -import { NamespaceId } from '../namespace/NamespaceId'; import { NetworkType } from '../network/NetworkType'; import { Statement } from '../receipt/Statement'; import { UInt64 } from '../UInt64'; @@ -221,14 +219,9 @@ export class SecretProofTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.recipientAddress.equals(address) || - alias.find((name) => this.recipientAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.recipientAddress.equals(address); } } diff --git a/src/model/transaction/Transaction.ts b/src/model/transaction/Transaction.ts index 0dd090771d..b54046da01 100644 --- a/src/model/transaction/Transaction.ts +++ b/src/model/transaction/Transaction.ts @@ -19,8 +19,7 @@ import { KeyPair, SHA3Hasher } from '../../core/crypto'; import { Convert } from '../../core/format'; import { DtoMapping } from '../../core/utils'; import { SerializeTransactionToJSON } from '../../infrastructure/transaction'; -import { Account, Address, PublicAccount } from '../account'; -import { NamespaceId } from '../namespace'; +import { Account, PublicAccount, UnresolvedAddress } from '../account'; import { NetworkType } from '../network'; import { Statement } from '../receipt'; import { UInt64 } from '../UInt64'; @@ -440,17 +439,16 @@ export abstract class Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public abstract shouldNotifyAccount(address: Address, alias?: NamespaceId[]): boolean; + public abstract shouldNotifyAccount(address: UnresolvedAddress): boolean; /** * @internal * Checks if the transaction is signer by an address. * @param address the address. */ - public isSigned(address: Address): boolean { + public isSigned(address: UnresolvedAddress): boolean { return this.signer !== undefined && this.signer!.address.equals(address); } diff --git a/src/model/transaction/TransferTransaction.ts b/src/model/transaction/TransferTransaction.ts index 7572628d91..472202e7eb 100644 --- a/src/model/transaction/TransferTransaction.ts +++ b/src/model/transaction/TransferTransaction.ts @@ -277,14 +277,9 @@ export class TransferTransaction extends Transaction { * @internal * Check a given address should be notified in websocket channels * @param address address to be notified - * @param alias address alias (names) * @returns {boolean} */ - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { - return ( - super.isSigned(address) || - this.recipientAddress.equals(address) || - alias.find((name) => this.recipientAddress.equals(name)) !== undefined - ); + public shouldNotifyAccount(address: UnresolvedAddress): boolean { + return super.isSigned(address) || this.recipientAddress.equals(address); } } diff --git a/src/service/CurrencyService.ts b/src/service/CurrencyService.ts index 40408e5957..86cb9d9a34 100644 --- a/src/service/CurrencyService.ts +++ b/src/service/CurrencyService.ts @@ -26,8 +26,6 @@ import { ICurrencyService } from './interfaces'; * A service used to load Currencies objects. */ export class CurrencyService implements ICurrencyService { - x; - constructor(private readonly repositoryFactory: RepositoryFactory) {} /** diff --git a/src/service/MosaicRestrictionTransactionService.ts b/src/service/MosaicRestrictionTransactionService.ts index 6ae65d9855..868b3d9ea4 100644 --- a/src/service/MosaicRestrictionTransactionService.ts +++ b/src/service/MosaicRestrictionTransactionService.ts @@ -27,6 +27,7 @@ import { NetworkType } from '../model/network/NetworkType'; import { MosaicAddressRestriction } from '../model/restriction/MosaicAddressRestriction'; import { MosaicGlobalRestriction } from '../model/restriction/MosaicGlobalRestriction'; import { MosaicGlobalRestrictionItem } from '../model/restriction/MosaicGlobalRestrictionItem'; +import { MosaicRestrictionEntryType } from '../model/restriction/MosaicRestrictionEntryType'; import { MosaicRestrictionType } from '../model/restriction/MosaicRestrictionType'; import { Deadline } from '../model/transaction/Deadline'; import { MosaicAddressRestrictionTransaction } from '../model/transaction/MosaicAddressRestrictionTransaction'; @@ -125,7 +126,9 @@ export class MosaicRestrictionTransactionService { this.getGlobalRestrictionEntry(resolvedMosaicId, restrictionKey).pipe( mergeMap((restrictionEntry: MosaicGlobalRestrictionItem | undefined) => { if (!restrictionEntry) { - throw new Error('Global restriction is not valid for RestrictionKey: ' + restrictionKey); + throw new Error( + `Global restriction for mosaic: ${mosaicId.toHex()} is not valid for with RestrictionKey: ${restrictionKey}`, + ); } return this.getAddressRestrictionEntry(resolvedMosaicId, restrictionKey, resolvedAddress).pipe( map((optionalValue) => { @@ -156,16 +159,12 @@ export class MosaicRestrictionTransactionService { * @return {Observable} */ private getAddressRestrictionEntry(mosaicId: MosaicId, restrictionKey: UInt64, targetAddress: Address): Observable { - return this.restrictionMosaicRepository.search({ mosaicId, targetAddress }).pipe( + return this.restrictionMosaicRepository.search({ mosaicId, targetAddress, entryType: MosaicRestrictionEntryType.ADDRESS }).pipe( map((mosaicRestriction) => { - return (mosaicRestriction.data[0] as MosaicAddressRestriction).getRestriction(restrictionKey)?.restrictionValue; - }), - catchError((err: Error) => { - const error = JSON.parse(err.message); - if (error && error.statusCode && error.statusCode === 404) { - return of(undefined); - } - throw new Error(err.message); + const addressRestriction = mosaicRestriction.data.find( + (r) => r instanceof MosaicAddressRestriction && r.mosaicId.equals(mosaicId) && r.targetAddress.equals(targetAddress), + ); + return addressRestriction ? addressRestriction.getRestriction(restrictionKey)?.restrictionValue : undefined; }), ); } @@ -177,20 +176,13 @@ export class MosaicRestrictionTransactionService { * @return {Observable} */ private getGlobalRestrictionEntry(mosaicId: MosaicId, restrictionKey: UInt64): Observable { - return this.restrictionMosaicRepository.search({ mosaicId }).pipe( + return this.restrictionMosaicRepository.search({ mosaicId, entryType: MosaicRestrictionEntryType.GLOBAL }).pipe( map((mosaicRestrictionPage: Page) => { - const globalRestriction = mosaicRestrictionPage.data.find((r) => r instanceof MosaicGlobalRestriction); - if (globalRestriction !== undefined) { - return globalRestriction.getRestriction(restrictionKey); - } - throw new Error('No global restriction found for mosaic' + mosaicId.toHex()); - }), - catchError((err: Error) => { - const error = JSON.parse(err.message); - if (error && error.statusCode && error.statusCode === 404) { - return of(undefined); - } - throw new Error(err.message); + const globalRestriction = mosaicRestrictionPage.data.find( + (r) => r instanceof MosaicGlobalRestriction && r.mosaicId.equals(mosaicId), + ); + + return globalRestriction ? globalRestriction.getRestriction(restrictionKey) : undefined; }), ); } diff --git a/test/core/utils/TransactionMapping.spec.ts b/test/core/utils/TransactionMapping.spec.ts index 0f5d752c4d..2a09c51e48 100644 --- a/test/core/utils/TransactionMapping.spec.ts +++ b/test/core/utils/TransactionMapping.spec.ts @@ -1471,7 +1471,7 @@ describe('TransactionMapping - createFromDTO (Transaction.toJSON() feed)', () => ); const expectedHex = - 'A5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001A84E4100000000000000002B02000000000000FFFFFFFFFFFFFFFFCFCBE72D994BE69B0113726F6F742D746573742D6E616D657370616365'; + 'A5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001A84E4100000000000000002B02000000000000FFFFFFFFFFFFFFFFE25C68E93F91F0E90113726F6F742D746573742D6E616D657370616365'; assertSerialization(registerNamespaceTransaction, expectedHex); const transaction = TransactionMapping.createFromDTO(registerNamespaceTransaction.toJSON()) as NamespaceRegistrationTransaction; diff --git a/test/infrastructure/ChainHttp.spec.ts b/test/infrastructure/ChainHttp.spec.ts index dd53b77986..28dc8d918d 100644 --- a/test/infrastructure/ChainHttp.spec.ts +++ b/test/infrastructure/ChainHttp.spec.ts @@ -41,19 +41,19 @@ describe('ChainHttp', () => { chainInfoDTO.scoreHigh = '3'; const finalizedBlockDto = {} as FinalizedBlockDTO; finalizedBlockDto.finalizationEpoch = 1; - finalizedBlockDto.finalizationPoint = 1; + finalizedBlockDto.finalizationPoint = 2; finalizedBlockDto.hash = 'hash'; finalizedBlockDto.height = '1'; chainInfoDTO.latestFinalizedBlock = finalizedBlockDto; when(chainRoutesApi.getChainInfo()).thenReturn(Promise.resolve(chainInfoDTO)); const info = await chainRepository.getChainInfo().toPromise(); expect(info).to.be.not.null; - expect(info.height.toString()).to.be.equals('1'); - expect(info.scoreLow.toString()).to.be.equals('2'); - expect(info.scoreHigh.toString()).to.be.equals('3'); - expect(info.latestFinalizedBlock.height.toString()).to.be.equals('1'); - expect(info.latestFinalizedBlock.hash).to.be.equals('hash'); - expect(info.latestFinalizedBlock.finalizationPoint).to.be.equals(1); - expect(info.latestFinalizedBlock.finalizationEpoch).to.be.equals(1); + expect(info.height.toString()).to.be.equals(chainInfoDTO.height); + expect(info.scoreLow.toString()).to.be.equals(chainInfoDTO.scoreLow); + expect(info.scoreHigh.toString()).to.be.equals(chainInfoDTO.scoreHigh); + expect(info.latestFinalizedBlock.height.toString()).to.be.equals(finalizedBlockDto.height); + expect(info.latestFinalizedBlock.hash).to.be.equals(finalizedBlockDto.hash); + expect(info.latestFinalizedBlock.finalizationPoint).to.be.equals(finalizedBlockDto.finalizationPoint); + expect(info.latestFinalizedBlock.finalizationEpoch).to.be.equals(finalizedBlockDto.finalizationEpoch); }); }); diff --git a/test/infrastructure/Listener.spec.ts b/test/infrastructure/Listener.spec.ts index 0a42d96237..71b5e8f3bd 100644 --- a/test/infrastructure/Listener.spec.ts +++ b/test/infrastructure/Listener.spec.ts @@ -18,6 +18,7 @@ import { deepEqual } from 'assert'; import { expect } from 'chai'; import { Observable, of as observableOf } from 'rxjs'; import { deepEqual as deepEqualParam, instance, mock, verify, when } from 'ts-mockito'; +import { UnresolvedAddress } from '../../src'; import { Listener, ListenerChannelName } from '../../src/infrastructure/Listener'; import { MultisigRepository } from '../../src/infrastructure/MultisigRepository'; import { NamespaceRepository } from '../../src/infrastructure/NamespaceRepository'; @@ -221,6 +222,12 @@ describe('Listener', () => { expect(payload).to.be.eq(`{"subscribe":"${name}/${subscribedAddress.plain()}"}`); } } + class WebSocketMockAlias { + constructor(public readonly url: string) {} + send(payload: string): void { + expect(payload).to.be.eq(`{"subscribe":"${name}/${new NamespaceId('test').plain()}"}`); + } + } let multisigIndex = 0; class WebSocketMultisigMock { @@ -230,7 +237,12 @@ describe('Listener', () => { } } - const subscriptionMethod = (listener: Listener, address: Address, hash?: string, multisig = false): Observable => { + const subscriptionMethod = ( + listener: Listener, + address: UnresolvedAddress, + hash?: string, + multisig = false, + ): Observable => { switch (name) { case ListenerChannelName.confirmedAdded: { return listener.confirmed(address, hash, multisig); @@ -246,9 +258,9 @@ describe('Listener', () => { describe(`${name} transaction subscription`, () => { it('subscribe multsig', () => { + const alias = new NamespaceId('test'); const multisigInfo = new MultisigAccountInfo(1, subscribedAddress, 1, 1, [], [multisigAccount.address]); when(multisigRepoMock.getMultisigAccountInfo(deepEqualParam(subscribedAddress))).thenReturn(observableOf(multisigInfo)); - const alias = new NamespaceId('test'); when(namespaceRepoMock.getAccountsNames(deepEqualParam([subscribedAddress]))).thenReturn( observableOf([new AccountNames(subscribedAddress, [new NamespaceName(alias, 'test')])]), ); @@ -282,10 +294,6 @@ describe('Listener', () => { describe(`${name} transaction subscription`, () => { it('Using alias', () => { const alias = new NamespaceId('test'); - when(namespaceRepoMock.getAccountsNames(deepEqualParam([subscribedAddress]))).thenReturn( - observableOf([new AccountNames(subscribedAddress, [new NamespaceName(alias, 'test')])]), - ); - const transferTransaction = TransferTransaction.create( Deadline.create(epochAdjustment), alias, @@ -298,9 +306,9 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMockAlias); listener.open(); - subscriptionMethod(listener, subscribedAddress, hash).subscribe((confirmedTransaction) => { + subscriptionMethod(listener, alias, hash).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); }); @@ -319,7 +327,7 @@ describe('Listener', () => { null, ); - verify(namespaceRepoMock.getAccountsNames(deepEqualParam([subscribedAddress]))).times(2); + verify(namespaceRepoMock.getAccountsNames(deepEqualParam([subscribedAddress]))).times(0); expect(reportedTransactions.length).to.be.equal(2); }); @@ -372,9 +380,6 @@ describe('Listener', () => { const subscribedAddress = account.address; const alias = new NamespaceId('test'); - when(namespaceRepoMock.getAccountsNames(deepEqualParam([account.address]))).thenReturn( - observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), - ); const transferTransaction = TransferTransaction.create( Deadline.create(epochAdjustment), alias, @@ -387,9 +392,9 @@ describe('Listener', () => { transferTransactionDTO.meta = { height: '1', hash: hash }; const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMockAlias); listener.open(); - subscriptionMethod(listener, subscribedAddress).subscribe((confirmedTransaction) => { + subscriptionMethod(listener, alias).subscribe((confirmedTransaction) => { reportedTransactions.push(confirmedTransaction); }); @@ -408,17 +413,12 @@ describe('Listener', () => { null, ); expect(reportedTransactions.length).to.be.equal(2); - verify(namespaceRepoMock.getAccountsNames(deepEqualParam([account.address]))).times(2); + verify(namespaceRepoMock.getAccountsNames(deepEqualParam([account.address]))).times(0); }); it('Using alias invalid', () => { - const subscribedAddress = account.address; - const alias = new NamespaceId('test'); const alias2 = new NamespaceId('test2'); - when(namespaceRepoMock.getAccountsNames(deepEqualParam([account.address]))).thenReturn( - observableOf([new AccountNames(account.address, [new NamespaceName(alias, 'test')])]), - ); const transferTransaction = TransferTransaction.create( Deadline.create(epochAdjustment), alias2, @@ -432,9 +432,9 @@ describe('Listener', () => { const reportedTransactions: Transaction[] = []; - const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMock); + const listener = new Listener('http://localhost:3000', namespaceRepo, WebSocketMockAlias); listener.open(); - subscriptionMethod(listener, subscribedAddress, hash).subscribe((unconfirmedTransaction) => { + subscriptionMethod(listener, alias, hash).subscribe((unconfirmedTransaction) => { reportedTransactions.push(unconfirmedTransaction); }); @@ -454,7 +454,7 @@ describe('Listener', () => { ); expect(reportedTransactions.length).to.be.equal(0); - verify(namespaceRepoMock.getAccountsNames(deepEqualParam([account.address]))).times(2); + verify(namespaceRepoMock.getAccountsNames(deepEqualParam([account.address]))).times(0); }); it('Using signer', () => { diff --git a/test/model/transaction/AccountMetadataTransaction.spec.ts b/test/model/transaction/AccountMetadataTransaction.spec.ts index ed3645c804..09825617f8 100644 --- a/test/model/transaction/AccountMetadataTransaction.spec.ts +++ b/test/model/transaction/AccountMetadataTransaction.spec.ts @@ -162,14 +162,14 @@ describe('AccountMetadataTransaction', () => { NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, []); + let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -177,20 +177,20 @@ describe('AccountMetadataTransaction', () => { const wrongAlias = new NamespaceId('wrong'); const tx = AccountMetadataTransaction.create( Deadline.create(epochAdjustment), - account.address, + alias, UInt64.fromUint(1000), 1, Convert.uint8ToUtf8(new Uint8Array(10)), NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, [alias]); + let canNotify = tx.shouldNotifyAccount(alias); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [wrongAlias]); + canNotify = tx.shouldNotifyAccount(wrongAlias); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); }); diff --git a/test/model/transaction/AccountRestrictionTransaction.spec.ts b/test/model/transaction/AccountRestrictionTransaction.spec.ts index e434d47381..6fd01919d6 100644 --- a/test/model/transaction/AccountRestrictionTransaction.spec.ts +++ b/test/model/transaction/AccountRestrictionTransaction.spec.ts @@ -258,14 +258,14 @@ describe('AccountRestrictionTransaction', () => { [], NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(address, []); + let canNotify = tx.shouldNotifyAccount(address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( Deadline.create(epochAdjustment), @@ -274,14 +274,14 @@ describe('AccountRestrictionTransaction', () => { [address], NetworkType.PRIVATE_TEST, ); - let canNotifyDeletion = txDeletion.shouldNotifyAccount(address, []); + let canNotifyDeletion = txDeletion.shouldNotifyAccount(address); expect(canNotifyDeletion).to.be.true; - canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI'), []); + canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI')); expect(canNotifyDeletion).to.be.false; Object.assign(txDeletion, { signer: account.publicAccount }); - expect(txDeletion.shouldNotifyAccount(account.address, [])).to.be.true; + expect(txDeletion.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -294,14 +294,14 @@ describe('AccountRestrictionTransaction', () => { [], NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, [alias]); + let canNotify = tx.shouldNotifyAccount(alias); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [wrongAlias]); + canNotify = tx.shouldNotifyAccount(wrongAlias); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; const txDeletion = AccountRestrictionTransaction.createAddressRestrictionModificationTransaction( Deadline.create(epochAdjustment), @@ -310,15 +310,13 @@ describe('AccountRestrictionTransaction', () => { [alias], NetworkType.PRIVATE_TEST, ); - let canNotifyDeletion = txDeletion.shouldNotifyAccount(account.address, [alias]); + let canNotifyDeletion = txDeletion.shouldNotifyAccount(alias); expect(canNotifyDeletion).to.be.true; - canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI'), [ - wrongAlias, - ]); + canNotifyDeletion = txDeletion.shouldNotifyAccount(wrongAlias); expect(canNotifyDeletion).to.be.false; Object.assign(txDeletion, { signer: account.publicAccount }); - expect(txDeletion.shouldNotifyAccount(account.address, [])).to.be.true; + expect(txDeletion.shouldNotifyAccount(account.address)).to.be.true; }); }); diff --git a/test/model/transaction/AggregateTransaction.spec.ts b/test/model/transaction/AggregateTransaction.spec.ts index 133acf976e..4c5eeb7ad9 100644 --- a/test/model/transaction/AggregateTransaction.spec.ts +++ b/test/model/transaction/AggregateTransaction.spec.ts @@ -703,14 +703,14 @@ describe('AggregateTransaction', () => { NetworkType.PRIVATE_TEST, [], ); - let canNotify = tx.shouldNotifyAccount(account.address, []); + let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -727,15 +727,13 @@ describe('AggregateTransaction', () => { NetworkType.PRIVATE_TEST, [], ); - let canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [ - unresolvedAddress, - ]); + let canNotify = tx.shouldNotifyAccount(unresolvedAddress); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); }); diff --git a/test/model/transaction/MosaicMetadataTransaction.spec.ts b/test/model/transaction/MosaicMetadataTransaction.spec.ts index c2d78df375..0d6b3f818d 100644 --- a/test/model/transaction/MosaicMetadataTransaction.spec.ts +++ b/test/model/transaction/MosaicMetadataTransaction.spec.ts @@ -221,14 +221,14 @@ describe('MosaicMetadataTransaction', () => { Convert.uint8ToUtf8(new Uint8Array(10)), NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, []); + let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -243,13 +243,13 @@ describe('MosaicMetadataTransaction', () => { Convert.uint8ToUtf8(new Uint8Array(10)), NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, [alias]); + let canNotify = tx.shouldNotifyAccount(alias); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [wrongAlias]); + canNotify = tx.shouldNotifyAccount(wrongAlias); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); }); diff --git a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts index da46360875..207d1c9316 100644 --- a/test/model/transaction/MultisigAccountModificationTransaction.spec.ts +++ b/test/model/transaction/MultisigAccountModificationTransaction.spec.ts @@ -151,14 +151,14 @@ describe('MultisigAccountModificationTransaction', () => { NetworkType.PRIVATE_TEST, ); - let canNotify = txAddition.shouldNotifyAccount(address1, []); + let canNotify = txAddition.shouldNotifyAccount(address1); expect(canNotify).to.be.true; - canNotify = txAddition.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = txAddition.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(txAddition, { signer: account.publicAccount }); - expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; + expect(txAddition.shouldNotifyAccount(account.address)).to.be.true; const txDeletion = MultisigAccountModificationTransaction.create( Deadline.create(epochAdjustment), @@ -169,14 +169,14 @@ describe('MultisigAccountModificationTransaction', () => { NetworkType.PRIVATE_TEST, ); - let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1, []); + let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1); expect(canNotifyDeletion).to.be.true; - canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotifyDeletion).to.be.false; Object.assign(txDeletion, { signer: account.publicAccount }); - expect(txDeletion.shouldNotifyAccount(account.address, [])).to.be.true; + expect(txDeletion.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -191,17 +191,17 @@ describe('MultisigAccountModificationTransaction', () => { NetworkType.PRIVATE_TEST, ); - let canNotify = txAddition.shouldNotifyAccount(address1, [alias]); + let canNotify = txAddition.shouldNotifyAccount(alias); expect(canNotify).to.be.true; - canNotify = txAddition.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [wrongAlias]); + canNotify = txAddition.shouldNotifyAccount(wrongAlias); expect(canNotify).to.be.false; - canNotify = txAddition.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [alias]); + canNotify = txAddition.shouldNotifyAccount(alias); expect(canNotify).to.be.true; Object.assign(txAddition, { signer: account.publicAccount }); - expect(txAddition.shouldNotifyAccount(account.address, [])).to.be.true; + expect(txAddition.shouldNotifyAccount(account.address)).to.be.true; const txDeletion = MultisigAccountModificationTransaction.create( Deadline.create(epochAdjustment), @@ -212,20 +212,16 @@ describe('MultisigAccountModificationTransaction', () => { NetworkType.PRIVATE_TEST, ); - let canNotifyDeletion = txDeletion.shouldNotifyAccount(address1, [alias]); + let canNotifyDeletion = txDeletion.shouldNotifyAccount(alias); expect(canNotifyDeletion).to.be.true; - canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [ - wrongAlias, - ]); + canNotifyDeletion = txDeletion.shouldNotifyAccount(wrongAlias); expect(canNotifyDeletion).to.be.false; - canNotifyDeletion = txDeletion.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [ - alias, - ]); + canNotifyDeletion = txDeletion.shouldNotifyAccount(alias); expect(canNotifyDeletion).to.be.true; Object.assign(txDeletion, { signer: account.publicAccount }); - expect(txDeletion.shouldNotifyAccount(account.address, [])).to.be.true; + expect(txDeletion.shouldNotifyAccount(account.address)).to.be.true; }); }); diff --git a/test/model/transaction/NamespaceMetadataTransaction.spec.ts b/test/model/transaction/NamespaceMetadataTransaction.spec.ts index 9988950b08..75ac95a411 100644 --- a/test/model/transaction/NamespaceMetadataTransaction.spec.ts +++ b/test/model/transaction/NamespaceMetadataTransaction.spec.ts @@ -175,14 +175,14 @@ describe('NamespaceMetadataTransaction', () => { Convert.uint8ToUtf8(new Uint8Array(10)), NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, []); + let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -197,13 +197,13 @@ describe('NamespaceMetadataTransaction', () => { Convert.uint8ToUtf8(new Uint8Array(10)), NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, [alias]); + let canNotify = tx.shouldNotifyAccount(alias); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), [wrongAlias]); + canNotify = tx.shouldNotifyAccount(wrongAlias); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [wrongAlias])).to.be.true; + expect(tx.shouldNotifyAccount(wrongAlias)).to.be.false; }); }); diff --git a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts index 5c499ab5dc..96856ba61e 100644 --- a/test/model/transaction/NamespaceRegistrationTransaction.spec.ts +++ b/test/model/transaction/NamespaceRegistrationTransaction.spec.ts @@ -101,7 +101,7 @@ describe('NamespaceRegistrationTransaction', () => { const signedTransaction = registerNamespaceTransaction.signWith(account, generationHash); expect(signedTransaction.payload.substring(256, signedTransaction.payload.length)).to.be.equal( - '4BFA5F372D55B384CFCBE72D994BE69B0113726F6F742D746573742D6E616D657370616365', + '4BFA5F372D55B384EE393014E8B74B9C0113726F6F742D746573742D6E616D657370616365', ); }); @@ -153,4 +153,27 @@ describe('NamespaceRegistrationTransaction', () => { Object.assign(tx, { signer: account.publicAccount }); expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); + + it('Sub namespacename craetd by different type of parent id', () => { + const parentNamespace = 'parent'; + const childNamespace = 'child'; + const parentId = new NamespaceId(parentNamespace); + + const subNameSpaceTransactionStringParent = NamespaceRegistrationTransaction.createSubNamespace( + Deadline.create(1573430400), + childNamespace, + parentNamespace, + NetworkType.TEST_NET, + UInt64.fromUint(100000), + ); + const subNameSpaceTransactionIdParent = NamespaceRegistrationTransaction.createSubNamespace( + Deadline.create(1573430400), + childNamespace, + parentId, + NetworkType.TEST_NET, + UInt64.fromUint(100000), + ); + + expect(subNameSpaceTransactionStringParent.namespaceId.equals(subNameSpaceTransactionIdParent.namespaceId)).to.be.true; + }); }); diff --git a/test/model/transaction/SecretLockTransaction.spec.ts b/test/model/transaction/SecretLockTransaction.spec.ts index 19788b92a4..4378082264 100644 --- a/test/model/transaction/SecretLockTransaction.spec.ts +++ b/test/model/transaction/SecretLockTransaction.spec.ts @@ -328,14 +328,14 @@ describe('SecretLockTransaction', () => { recipientAddress, NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(recipientAddress, []); + let canNotify = tx.shouldNotifyAccount(recipientAddress); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -347,9 +347,9 @@ describe('SecretLockTransaction', () => { UInt64.fromUint(100), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), - account.address, + namespaceId, NetworkType.PRIVATE_TEST, - ).shouldNotifyAccount(account.address, [namespaceId]); + ).shouldNotifyAccount(namespaceId); expect(canNotify).to.be.true; }); }); diff --git a/test/model/transaction/SecretProofTransaction.spec.ts b/test/model/transaction/SecretProofTransaction.spec.ts index 79264b9674..7329fb74b6 100644 --- a/test/model/transaction/SecretProofTransaction.spec.ts +++ b/test/model/transaction/SecretProofTransaction.spec.ts @@ -301,14 +301,14 @@ describe('SecretProofTransaction', () => { proof, NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(account.address, []); + let canNotify = tx.shouldNotifyAccount(account.address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { @@ -318,10 +318,10 @@ describe('SecretProofTransaction', () => { Deadline.create(epochAdjustment), LockHashAlgorithm.Op_Sha3_256, sha3_256.create().update(convert.hexToUint8(proof)).hex(), - account.address, + namespaceId, proof, NetworkType.PRIVATE_TEST, - ).shouldNotifyAccount(account.address, [namespaceId]); + ).shouldNotifyAccount(namespaceId); expect(canNotify).to.be.true; }); }); diff --git a/test/model/transaction/Transaction.spec.ts b/test/model/transaction/Transaction.spec.ts index a65010fa4b..4490dfdb2a 100644 --- a/test/model/transaction/Transaction.spec.ts +++ b/test/model/transaction/Transaction.spec.ts @@ -20,8 +20,8 @@ import { Convert } from '../../../src/core/format/Convert'; import { TransactionMapping } from '../../../src/core/utils/TransactionMapping'; import { Account } from '../../../src/model/account/Account'; import { Address } from '../../../src/model/account/Address'; +import { UnresolvedAddress } from '../../../src/model/account/UnresolvedAddress'; import { PlainMessage } from '../../../src/model/message/PlainMessage'; -import { NamespaceId } from '../../../src/model/namespace/NamespaceId'; import { NetworkType } from '../../../src/model/network/NetworkType'; import { AggregateTransaction } from '../../../src/model/transaction/AggregateTransaction'; import { Deadline } from '../../../src/model/transaction/Deadline'; @@ -54,7 +54,7 @@ describe('Transaction', () => { } // eslint-disable-next-line @typescript-eslint/no-unused-vars - public shouldNotifyAccount(address: Address, alias: NamespaceId[]): boolean { + public shouldNotifyAccount(address: UnresolvedAddress): boolean { throw new Error('Not implemented'); } resolveAliases(): TransferTransaction { diff --git a/test/model/transaction/TransferTransaction.spec.ts b/test/model/transaction/TransferTransaction.spec.ts index e774e5f64b..80fbeac97f 100644 --- a/test/model/transaction/TransferTransaction.spec.ts +++ b/test/model/transaction/TransferTransaction.spec.ts @@ -504,18 +504,17 @@ describe('TransferTransaction', () => { PlainMessage.create('test-message'), NetworkType.PRIVATE_TEST, ); - let canNotify = tx.shouldNotifyAccount(address, []); + let canNotify = tx.shouldNotifyAccount(address); expect(canNotify).to.be.true; - canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI'), []); + canNotify = tx.shouldNotifyAccount(Address.createFromRawAddress('VDR6EW2WBHJQDYMNGFX2UBZHMMZC5PGL22BHJVI')); expect(canNotify).to.be.false; Object.assign(tx, { signer: account.publicAccount }); - expect(tx.shouldNotifyAccount(account.address, [])).to.be.true; + expect(tx.shouldNotifyAccount(account.address)).to.be.true; }); it('Notify Account with alias', () => { - const address = Address.createFromRawAddress('VATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA35C4KNQ'); const namespaceId = new NamespaceId('test'); const canNotify = TransferTransaction.create( Deadline.create(epochAdjustment), @@ -523,7 +522,7 @@ describe('TransferTransaction', () => { [NetworkCurrencyLocal.createAbsolute(1)], PlainMessage.create('test-message'), NetworkType.PRIVATE_TEST, - ).shouldNotifyAccount(address, [namespaceId]); + ).shouldNotifyAccount(namespaceId); expect(canNotify).to.be.true; }); }); diff --git a/test/service/MosaicRestrictionTransactionservice.spec.ts b/test/service/MosaicRestrictionTransactionservice.spec.ts index 76b14549a9..0e9539fd01 100644 --- a/test/service/MosaicRestrictionTransactionservice.spec.ts +++ b/test/service/MosaicRestrictionTransactionservice.spec.ts @@ -84,10 +84,14 @@ describe('MosaicRestrictionTransactionService', () => { const mockRestrictionRepository = mock(); const mockNamespaceRepository = mock(); - when(mockRestrictionRepository.search(deepEqual({ mosaicId }))).thenReturn(observableOf(mockGlobalRestriction())); - when(mockRestrictionRepository.search(deepEqual({ mosaicId, targetAddress: account.address }))).thenReturn( - observableOf(mockAddressRestriction()), + when(mockRestrictionRepository.search(deepEqual({ mosaicId, entryType: MosaicRestrictionEntryType.GLOBAL }))).thenReturn( + observableOf(mockGlobalRestriction()), ); + when( + mockRestrictionRepository.search( + deepEqual({ mosaicId, targetAddress: account.address, entryType: MosaicRestrictionEntryType.ADDRESS }), + ), + ).thenReturn(observableOf(mockAddressRestriction())); when(mockNamespaceRepository.getLinkedMosaicId(deepEqual(unresolvedMosaicId))).thenReturn(observableOf(mosaicId)); when(mockNamespaceRepository.getLinkedMosaicId(deepEqual(unresolvedAddress))).thenThrow(new Error('invalid namespaceId')); when(mockNamespaceRepository.getLinkedAddress(deepEqual(unresolvedAddress))).thenReturn(observableOf(account.address));