Skip to content

Commit 012b3a3

Browse files
committed
reapply given for transfer
1 parent c4cdb1c commit 012b3a3

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

src/model/transaction/TransferTransaction.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {TransferTransaction as TransferTransactionLibrary, VerifiableTransaction,} from 'nem2-library';
18-
import {Address} from '../account/Address';
19-
import {PublicAccount} from '../account/PublicAccount';
20-
import {NetworkType} from '../blockchain/NetworkType';
21-
import {Mosaic} from '../mosaic/Mosaic';
22-
import {UInt64} from '../UInt64';
23-
import {Deadline} from './Deadline';
24-
import {Message} from './Message';
25-
import {Transaction} from './Transaction';
26-
import {TransactionInfo} from './TransactionInfo';
27-
import {TransactionType} from './TransactionType';
17+
import { TransferTransaction as TransferTransactionLibrary, VerifiableTransaction } from 'nem2-library';
18+
import { Address } from '../account/Address';
19+
import { PublicAccount } from '../account/PublicAccount';
20+
import { NetworkType } from '../blockchain/NetworkType';
21+
import { Mosaic } from '../mosaic/Mosaic';
22+
import { UInt64 } from '../UInt64';
23+
import { Deadline } from './Deadline';
24+
import { Message } from './Message';
25+
import { Transaction } from './Transaction';
26+
import { TransactionInfo } from './TransactionInfo';
27+
import { TransactionType } from './TransactionType';
2828

2929
/**
3030
* Transfer transactions contain data about transfers of mosaics and message to another account.
@@ -101,4 +101,28 @@ export class TransferTransaction extends Transaction {
101101
.addMessage(this.message)
102102
.build();
103103
}
104+
105+
/**
106+
* @description re-aplly a given value to the transaction in an immutable way
107+
* @param {Deadline} deadline
108+
* @returns {Transaction}
109+
* @memberof Transaction
110+
*/
111+
public reaplygiven(newDeadline: Deadline): TransferTransaction {
112+
113+
if (this.isUnannounced) {
114+
return new TransferTransaction(
115+
this.networkType,
116+
this.version,
117+
newDeadline,
118+
this.fee,
119+
this.recipient,
120+
this.mosaics,
121+
this.message,
122+
this.signature,
123+
this.signer);
124+
} else {
125+
throw new Error('Should not modify an announced transaction');
126+
}
127+
}
104128
}

0 commit comments

Comments
 (0)