Skip to content

Commit c4cdb1c

Browse files
committed
reapply given for secrete
1 parent ec9747b commit c4cdb1c

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

src/model/transaction/SecretProofTransaction.ts

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import {SecretProofTransaction as SecretProofTransactionLibrary, VerifiableTransaction} from 'nem2-library';
17-
import {PublicAccount} from '../account/PublicAccount';
18-
import {NetworkType} from '../blockchain/NetworkType';
19-
import {UInt64} from '../UInt64';
20-
import {Deadline} from './Deadline';
21-
import {HashType, HashTypeLengthValidator} from './HashType';
22-
import {Transaction} from './Transaction';
23-
import {TransactionInfo} from './TransactionInfo';
24-
import {TransactionType} from './TransactionType';
16+
import { SecretProofTransaction as SecretProofTransactionLibrary, VerifiableTransaction } from 'nem2-library';
17+
import { PublicAccount } from '../account/PublicAccount';
18+
import { NetworkType } from '../blockchain/NetworkType';
19+
import { UInt64 } from '../UInt64';
20+
import { Deadline } from './Deadline';
21+
import { HashType, HashTypeLengthValidator } from './HashType';
22+
import { Transaction } from './Transaction';
23+
import { TransactionInfo } from './TransactionInfo';
24+
import { TransactionType } from './TransactionType';
2525

2626
export class SecretProofTransaction extends Transaction {
2727

@@ -95,4 +95,28 @@ export class SecretProofTransaction extends Transaction {
9595
.addProof(this.proof)
9696
.build();
9797
}
98+
99+
/**
100+
* @description re-aplly a given value to the transaction in an immutable way
101+
* @param {Deadline} deadline
102+
* @returns {Transaction}
103+
* @memberof Transaction
104+
*/
105+
public reaplygiven(newDeadline: Deadline): SecretProofTransaction {
106+
107+
if (this.isUnannounced) {
108+
return new SecretProofTransaction(
109+
this.networkType,
110+
this.version,
111+
newDeadline,
112+
this.fee,
113+
this.hashType,
114+
this.secret,
115+
this.proof,
116+
this.signature,
117+
this.signer);
118+
} else {
119+
throw new Error('Should not modify an announced transaction');
120+
}
121+
}
98122
}

0 commit comments

Comments
 (0)