Skip to content

Commit 06cf547

Browse files
committed
short implementation + test
1 parent 012b3a3 commit 06cf547

13 files changed

+63
-228
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"pretest": "npm run build",
77
"test": "mocha --ui bdd --recursive ./dist/test --timeout 90000",
8+
"tran": "mocha --ui bdd --recursive ./dist/test/model/transaction/Transaction.spec --timeout 90000",
89
"test:e2e": "mocha --ui bdd --recursive ./dist/e2e --timeout 90000",
910
"test:all": "mocha --ui bdd --recursive ./dist/ --timeout 90000",
1011
"build": "rm -rf dist/ && tsc",

src/model/transaction/AggregateTransaction.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,4 @@ export class AggregateTransaction extends Transaction {
145145
|| (this.signer !== undefined && this.signer.equals(publicAccount));
146146
}
147147

148-
/**
149-
* @description re-aplly a given value to the transaction in an immutable way
150-
* @param {Deadline} deadline
151-
* @returns {Transaction}
152-
* @memberof Transaction
153-
*/
154-
public reaplygiven(newDeadline: Deadline): AggregateTransaction {
155-
156-
if (this.isUnannounced) {
157-
return new AggregateTransaction(
158-
this.networkType,
159-
this.type,
160-
this.version,
161-
newDeadline,
162-
this.fee,
163-
this.innerTransactions,
164-
this.cosignatures,
165-
this.signature,
166-
this.signer);
167-
} else {
168-
throw new Error('Should not modify an announced transaction');
169-
}
170-
}
171-
172148
}

src/model/transaction/LockFundsTransaction.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,4 @@ export class LockFundsTransaction extends Transaction {
114114
.build();
115115
}
116116

117-
/**
118-
* @description re-aplly a given value to the transaction in an immutable way
119-
* @param {Deadline} deadline
120-
* @returns {Transaction}
121-
* @memberof Transaction
122-
*/
123-
public reaplygiven(deadline: Deadline, signedTransaction: SignedTransaction): LockFundsTransaction {
124-
125-
if (this.isUnannounced) {
126-
return new LockFundsTransaction(
127-
this.networkType,
128-
this.type,
129-
deadline,
130-
this.fee,
131-
this.mosaic,
132-
this.duration,
133-
signedTransaction,
134-
this.signature,
135-
this.signer);
136-
} else {
137-
throw new Error('Should not modify an announced transaction');
138-
}
139-
}
140-
141117
}

src/model/transaction/ModifyMultisigAccountTransaction.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,4 @@ export class ModifyMultisigAccountTransaction extends Transaction {
106106
.build();
107107
}
108108

109-
/**
110-
* @description re-aplly a given value to the transaction in an immutable way
111-
* @param {Deadline} deadline
112-
* @returns {Transaction}
113-
* @memberof Transaction
114-
*/
115-
public reaplygiven(newDeadline: Deadline): ModifyMultisigAccountTransaction {
116-
117-
if (this.isUnannounced) {
118-
return new ModifyMultisigAccountTransaction(
119-
this.networkType,
120-
this.version,
121-
newDeadline,
122-
this.fee,
123-
this.minApprovalDelta,
124-
this.minRemovalDelta,
125-
this.modifications,
126-
this.signature,
127-
this.signer);
128-
} else {
129-
throw new Error('Should not modify an announced transaction');
130-
}
131-
}
132109
}

src/model/transaction/MosaicDefinitionTransaction.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,4 @@ export class MosaicDefinitionTransaction extends Transaction {
126126
return mosaicDefinitionTransaction.build();
127127
}
128128

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): MosaicDefinitionTransaction {
136-
137-
if (this.isUnannounced) {
138-
return new MosaicDefinitionTransaction(
139-
this.networkType,
140-
this.version,
141-
newDeadline,
142-
this.fee,
143-
this.parentId,
144-
this.mosaicId,
145-
this.mosaicName,
146-
this.mosaicProperties,
147-
this.signature,
148-
this.signer);
149-
} else {
150-
throw new Error('Should not modify an announced transaction');
151-
}
152-
}
153129
}

src/model/transaction/MosaicSupplyChangeTransaction.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,4 @@ export class MosaicSupplyChangeTransaction extends Transaction {
104104
.build();
105105
}
106106

107-
/**
108-
* @description re-aplly a given value to the transaction in an immutable way
109-
* @param {Deadline} deadline
110-
* @returns {Transaction}
111-
* @memberof Transaction
112-
*/
113-
public reaplygiven(newDeadline: Deadline): MosaicSupplyChangeTransaction {
114-
115-
if (this.isUnannounced) {
116-
return new MosaicSupplyChangeTransaction(
117-
this.networkType,
118-
this.version,
119-
newDeadline,
120-
this.fee,
121-
this.mosaicId,
122-
this.direction,
123-
this.delta,
124-
this.signature,
125-
this.signer);
126-
} else {
127-
throw new Error('Should not modify an announced transaction');
128-
}
129-
}
130107
}

src/model/transaction/RegisterNamespaceTransaction.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -151,29 +151,4 @@ export class RegisterNamespaceTransaction extends Transaction {
151151
return registerNamespacetransaction.build();
152152
}
153153

154-
/**
155-
* @description re-aplly a given value to the transaction in an immutable way
156-
* @param {Deadline} deadline
157-
* @returns {Transaction}
158-
* @memberof Transaction
159-
*/
160-
public reaplygiven(newDeadline: Deadline): RegisterNamespaceTransaction {
161-
162-
if (this.isUnannounced) {
163-
return new RegisterNamespaceTransaction(
164-
this.networkType,
165-
this.version,
166-
newDeadline,
167-
this.fee,
168-
this.namespaceType,
169-
this.namespaceName,
170-
this.namespaceId,
171-
this.duration,
172-
this.parentId,
173-
this.signature,
174-
this.signer);
175-
} else {
176-
throw new Error('Should not modify an announced transaction');
177-
}
178-
}
179154
}

src/model/transaction/SecretLockTransaction.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,4 @@ export class SecretLockTransaction extends Transaction {
126126
.build();
127127
}
128128

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-
}
154129
}

src/model/transaction/SecretProofTransaction.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,4 @@ export class SecretProofTransaction extends Transaction {
9696
.build();
9797
}
9898

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-
}
12299
}

src/model/transaction/Transaction.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,11 @@ export abstract class Transaction {
163163
* @returns {Transaction}
164164
* @memberof Transaction
165165
*/
166-
public abstract reaplygiven(deadline: Deadline, signedTransaction?: SignedTransaction): Transaction;
166+
public reapplygiven(deadline: Deadline): Transaction {
167+
if (this.isUnannounced()) {
168+
return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {deadline});
169+
} else {
170+
throw new Error('an Announced transaction can\'t be modified');
171+
}
172+
}
167173
}

0 commit comments

Comments
 (0)