14
14
* limitations under the License.
15
15
*/
16
16
import { Convert , Convert as convert , RawAddress } from '../../core/format' ;
17
+ import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping' ;
17
18
import { AmountDto } from '../../infrastructure/catbuffer/AmountDto' ;
18
19
import { BlockDurationDto } from '../../infrastructure/catbuffer/BlockDurationDto' ;
19
20
import { EmbeddedSecretLockTransactionBuilder } from '../../infrastructure/catbuffer/EmbeddedSecretLockTransactionBuilder' ;
@@ -30,6 +31,7 @@ import { PublicAccount } from '../account/PublicAccount';
30
31
import { NetworkType } from '../blockchain/NetworkType' ;
31
32
import { Mosaic } from '../mosaic/Mosaic' ;
32
33
import { MosaicId } from '../mosaic/MosaicId' ;
34
+ import { NamespaceId } from '../namespace/NamespaceId' ;
33
35
import { UInt64 } from '../UInt64' ;
34
36
import { Deadline } from './Deadline' ;
35
37
import { HashType , HashTypeLengthValidator } from './HashType' ;
@@ -49,7 +51,7 @@ export class SecretLockTransaction extends Transaction {
49
51
* @param duration - The funds lock duration.
50
52
* @param hashType - The hash algorithm secret is generated with.
51
53
* @param secret - The proof hashed.
52
- * @param recipientAddress - The recipient address of the funds.
54
+ * @param recipientAddress - The unresolved recipient address of the funds.
53
55
* @param networkType - The network type.
54
56
* @param maxFee - (Optional) Max fee defined by the sender
55
57
*
@@ -60,7 +62,7 @@ export class SecretLockTransaction extends Transaction {
60
62
duration : UInt64 ,
61
63
hashType : HashType ,
62
64
secret : string ,
63
- recipientAddress : Address ,
65
+ recipientAddress : Address | NamespaceId ,
64
66
networkType : NetworkType ,
65
67
maxFee : UInt64 = new UInt64 ( [ 0 , 0 ] ) ) : SecretLockTransaction {
66
68
return new SecretLockTransaction (
@@ -111,9 +113,9 @@ export class SecretLockTransaction extends Transaction {
111
113
*/
112
114
public readonly secret : string ,
113
115
/**
114
- * The recipientAddress of the funds.
116
+ * The unresolved recipientAddress of the funds.
115
117
*/
116
- public readonly recipientAddress : Address ,
118
+ public readonly recipientAddress : Address | NamespaceId ,
117
119
signature ?: string ,
118
120
signer ?: PublicAccount ,
119
121
transactionInfo ?: TransactionInfo ) {
@@ -139,13 +141,13 @@ export class SecretLockTransaction extends Transaction {
139
141
isEmbedded ? Deadline . create ( ) : Deadline . createFromDTO (
140
142
( builder as SecretLockTransactionBuilder ) . getDeadline ( ) . timestamp ) ,
141
143
new Mosaic (
142
- new MosaicId ( builder . getMosaic ( ) . mosaicId . unresolvedMosaicId ) ,
144
+ UnresolvedMapping . toUnresolvedMosaic ( new UInt64 ( builder . getMosaic ( ) . mosaicId . unresolvedMosaicId ) . toHex ( ) ) ,
143
145
new UInt64 ( builder . getMosaic ( ) . amount . amount ) ,
144
146
) ,
145
147
new UInt64 ( builder . getDuration ( ) . blockDuration ) ,
146
148
builder . getHashAlgorithm ( ) . valueOf ( ) ,
147
149
Convert . uint8ToHex ( builder . getSecret ( ) . hash256 ) ,
148
- Address . createFromEncoded ( Convert . uint8ToHex ( builder . getRecipientAddress ( ) . unresolvedAddress ) ) ,
150
+ UnresolvedMapping . toUnresolvedAddress ( Convert . uint8ToHex ( builder . getRecipientAddress ( ) . unresolvedAddress ) ) ,
149
151
networkType ,
150
152
isEmbedded ? new UInt64 ( [ 0 , 0 ] ) : new UInt64 ( ( builder as SecretLockTransactionBuilder ) . fee . amount ) ,
151
153
) ;
@@ -204,7 +206,7 @@ export class SecretLockTransaction extends Transaction {
204
206
new BlockDurationDto ( this . duration . toDTO ( ) ) ,
205
207
this . hashType . valueOf ( ) ,
206
208
new Hash256Dto ( this . getSecretByte ( ) ) ,
207
- new UnresolvedAddressDto ( RawAddress . stringToAddress ( this . recipientAddress . plain ( ) ) ) ,
209
+ new UnresolvedAddressDto ( UnresolvedMapping . toUnresolvedAddressBytes ( this . recipientAddress ) ) ,
208
210
) ;
209
211
return transactionBuilder . serialize ( ) ;
210
212
}
@@ -223,7 +225,7 @@ export class SecretLockTransaction extends Transaction {
223
225
new BlockDurationDto ( this . duration . toDTO ( ) ) ,
224
226
this . hashType . valueOf ( ) ,
225
227
new Hash256Dto ( this . getSecretByte ( ) ) ,
226
- new UnresolvedAddressDto ( RawAddress . stringToAddress ( this . recipientAddress . plain ( ) ) ) ,
228
+ new UnresolvedAddressDto ( UnresolvedMapping . toUnresolvedAddressBytes ( this . recipientAddress ) ) ,
227
229
) ;
228
230
return transactionBuilder . serialize ( ) ;
229
231
}
0 commit comments