1414 * limitations under the License.
1515 */
1616import { Convert , Convert as convert , RawAddress } from '../../core/format' ;
17+ import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping' ;
1718import { AmountDto } from '../../infrastructure/catbuffer/AmountDto' ;
1819import { BlockDurationDto } from '../../infrastructure/catbuffer/BlockDurationDto' ;
1920import { EmbeddedSecretLockTransactionBuilder } from '../../infrastructure/catbuffer/EmbeddedSecretLockTransactionBuilder' ;
@@ -30,6 +31,7 @@ import { PublicAccount } from '../account/PublicAccount';
3031import { NetworkType } from '../blockchain/NetworkType' ;
3132import { Mosaic } from '../mosaic/Mosaic' ;
3233import { MosaicId } from '../mosaic/MosaicId' ;
34+ import { NamespaceId } from '../namespace/NamespaceId' ;
3335import { UInt64 } from '../UInt64' ;
3436import { Deadline } from './Deadline' ;
3537import { HashType , HashTypeLengthValidator } from './HashType' ;
@@ -49,7 +51,7 @@ export class SecretLockTransaction extends Transaction {
4951 * @param duration - The funds lock duration.
5052 * @param hashType - The hash algorithm secret is generated with.
5153 * @param secret - The proof hashed.
52- * @param recipientAddress - The recipient address of the funds.
54+ * @param recipientAddress - The unresolved recipient address of the funds.
5355 * @param networkType - The network type.
5456 * @param maxFee - (Optional) Max fee defined by the sender
5557 *
@@ -60,7 +62,7 @@ export class SecretLockTransaction extends Transaction {
6062 duration : UInt64 ,
6163 hashType : HashType ,
6264 secret : string ,
63- recipientAddress : Address ,
65+ recipientAddress : Address | NamespaceId ,
6466 networkType : NetworkType ,
6567 maxFee : UInt64 = new UInt64 ( [ 0 , 0 ] ) ) : SecretLockTransaction {
6668 return new SecretLockTransaction (
@@ -111,9 +113,9 @@ export class SecretLockTransaction extends Transaction {
111113 */
112114 public readonly secret : string ,
113115 /**
114- * The recipientAddress of the funds.
116+ * The unresolved recipientAddress of the funds.
115117 */
116- public readonly recipientAddress : Address ,
118+ public readonly recipientAddress : Address | NamespaceId ,
117119 signature ?: string ,
118120 signer ?: PublicAccount ,
119121 transactionInfo ?: TransactionInfo ) {
@@ -139,13 +141,13 @@ export class SecretLockTransaction extends Transaction {
139141 isEmbedded ? Deadline . create ( ) : Deadline . createFromDTO (
140142 ( builder as SecretLockTransactionBuilder ) . getDeadline ( ) . timestamp ) ,
141143 new Mosaic (
142- new MosaicId ( builder . getMosaic ( ) . mosaicId . unresolvedMosaicId ) ,
144+ UnresolvedMapping . toUnresolvedMosaic ( new UInt64 ( builder . getMosaic ( ) . mosaicId . unresolvedMosaicId ) . toHex ( ) ) ,
143145 new UInt64 ( builder . getMosaic ( ) . amount . amount ) ,
144146 ) ,
145147 new UInt64 ( builder . getDuration ( ) . blockDuration ) ,
146148 builder . getHashAlgorithm ( ) . valueOf ( ) ,
147149 Convert . uint8ToHex ( builder . getSecret ( ) . hash256 ) ,
148- Address . createFromEncoded ( Convert . uint8ToHex ( builder . getRecipientAddress ( ) . unresolvedAddress ) ) ,
150+ UnresolvedMapping . toUnresolvedAddress ( Convert . uint8ToHex ( builder . getRecipientAddress ( ) . unresolvedAddress ) ) ,
149151 networkType ,
150152 isEmbedded ? new UInt64 ( [ 0 , 0 ] ) : new UInt64 ( ( builder as SecretLockTransactionBuilder ) . fee . amount ) ,
151153 ) ;
@@ -204,7 +206,7 @@ export class SecretLockTransaction extends Transaction {
204206 new BlockDurationDto ( this . duration . toDTO ( ) ) ,
205207 this . hashType . valueOf ( ) ,
206208 new Hash256Dto ( this . getSecretByte ( ) ) ,
207- new UnresolvedAddressDto ( RawAddress . stringToAddress ( this . recipientAddress . plain ( ) ) ) ,
209+ new UnresolvedAddressDto ( UnresolvedMapping . toUnresolvedAddressBytes ( this . recipientAddress , this . networkType ) ) ,
208210 ) ;
209211 return transactionBuilder . serialize ( ) ;
210212 }
@@ -223,7 +225,7 @@ export class SecretLockTransaction extends Transaction {
223225 new BlockDurationDto ( this . duration . toDTO ( ) ) ,
224226 this . hashType . valueOf ( ) ,
225227 new Hash256Dto ( this . getSecretByte ( ) ) ,
226- new UnresolvedAddressDto ( RawAddress . stringToAddress ( this . recipientAddress . plain ( ) ) ) ,
228+ new UnresolvedAddressDto ( UnresolvedMapping . toUnresolvedAddressBytes ( this . recipientAddress , this . networkType ) ) ,
227229 ) ;
228230 return transactionBuilder . serialize ( ) ;
229231 }
0 commit comments