Skip to content

Commit ec9747b

Browse files
committed
reapply given for secrete
1 parent 380be82 commit ec9747b

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

src/model/transaction/SecretLockTransaction.ts

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import {SecretLockTransaction as SecretLockTransactionLibrary, VerifiableTransaction} from 'nem2-library';
17-
import {Address} from '../account/Address';
18-
import {PublicAccount} from '../account/PublicAccount';
19-
import {NetworkType} from '../blockchain/NetworkType';
20-
import {Mosaic} from '../mosaic/Mosaic';
21-
import {UInt64} from '../UInt64';
22-
import {Deadline} from './Deadline';
23-
import {HashType, HashTypeLengthValidator} from './HashType';
24-
import {Transaction} from './Transaction';
25-
import {TransactionInfo} from './TransactionInfo';
26-
import {TransactionType} from './TransactionType';
16+
import { SecretLockTransaction as SecretLockTransactionLibrary, VerifiableTransaction } from 'nem2-library';
17+
import { Address } from '../account/Address';
18+
import { PublicAccount } from '../account/PublicAccount';
19+
import { NetworkType } from '../blockchain/NetworkType';
20+
import { Mosaic } from '../mosaic/Mosaic';
21+
import { UInt64 } from '../UInt64';
22+
import { Deadline } from './Deadline';
23+
import { HashType, HashTypeLengthValidator } from './HashType';
24+
import { Transaction } from './Transaction';
25+
import { TransactionInfo } from './TransactionInfo';
26+
import { TransactionType } from './TransactionType';
2727

2828
export class SecretLockTransaction extends Transaction {
2929

@@ -125,4 +125,30 @@ export class SecretLockTransaction extends Transaction {
125125
.addRecipient(this.recipient.plain())
126126
.build();
127127
}
128+
129+
/**
130+
* @description re-aplly a given value to the transaction in an immutable way
131+
* @param {Deadline} deadline
132+
* @returns {Transaction}
133+
* @memberof Transaction
134+
*/
135+
public reaplygiven(newDeadline: Deadline): SecretLockTransaction {
136+
137+
if (this.isUnannounced) {
138+
return new SecretLockTransaction(
139+
this.networkType,
140+
this.version,
141+
newDeadline,
142+
this.fee,
143+
this.mosaic,
144+
this.duration,
145+
this.hashType,
146+
this.secret,
147+
this.recipient,
148+
this.signature,
149+
this.signer);
150+
} else {
151+
throw new Error('Should not modify an announced transaction');
152+
}
153+
}
128154
}

0 commit comments

Comments
 (0)