Skip to content

Commit af872f4

Browse files
committed
Added recipient to secretProofTransaction
1 parent 1c8ee7e commit af872f4

File tree

11 files changed

+160
-111
lines changed

11 files changed

+160
-111
lines changed

e2e/conf/network.conf

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
{
2-
"apiUrl": "http://localhost:3000",
2+
"apiUrl": "http://c2.nem.ninja:3000",
33
"testAccount": {
4-
"privateKey": "D242FB34C2C4DD36E995B9C865F93940065E326661BA5A4A247331D211FE3A3D",
5-
"address": "SBMYYFIM6VGG45KWGSZLSXFHP74WVT7MOF6UYBHT",
6-
"publicKey": "2FC3872A792933617D70E02AFF8FBDE152821A0DF0CA5FB04CB56FC3D21C8863"
4+
"privateKey": "E1C8521608F4896CA26A0C2DE739310EA4B06861D126CF4D6922064678A1969B",
5+
"address": "SAKT3CKHCYIG5BBOPTSY2WXSVPBSLIA67AEOX4ND",
6+
"publicKey": "9F784BF20318AE3CA6246C0EC2207FE095FFF7A84B6787E7E3C2CE4C3B92A2EA"
77
},
88
"multisigAccount": {
9-
"privateKey": "6EBE2AB0584C816771B494B36B40EC6CE1A0024C37DC6056D89D570A21A70262",
10-
"address": "SCJAK5N6ICIE3JGHV5SVDSSNM5RUZZVDWQJ5G76N",
11-
"publicKey": "224556169645EFAB772BFE1B5665490334428017E5D86FB3C9DFC4070B2F16A6"
9+
"privateKey": "9B2ADEC0FAF3E7384588AB9702DE1000F0F714A6A1E372B00CE556CF82723B31",
10+
"address": "SB2LOQ2VVN6Z7W23MMBME2WTHCJSBXTLDHX7OW4U",
11+
"publicKey": "941CC85FA0277E5C5C021B3D50AD1896D91E9B29E8871FCC513F6E99225FCBE9"
1212
},
1313
"cosignatoryAccount": {
14-
"privateKey": "44C0044B36AEF44C7743C407CEE4B6FD801BF6B0652AB7799B0991FFD3A81E71",
15-
"address": "SCPL4YCGZYCML5WUSCIVN5MQF5YZAAF4GMZJIEL4",
16-
"publicKey": "76C1622C7FB58986E500228E8FFB30C606CAAFC1CD78E770E82C73DAB7BD7C9F"
14+
"privateKey": "87D49ED34E65DA7950FFB1FFB6986F01AF8060E49B4D9E0AC549FB35DF3D33D5",
15+
"address": "SBVC4PTUNTIKF3L4MJTFDT7LRZ3LJV6A5H4EPY2T",
16+
"publicKey": "A23535E00ED113E27F22C5DC671628789C33C4D3E2F3528F9044400AF552FCF9"
1717
},
1818
"cosignatory2Account": {
19-
"privateKey": "F7B3A64652BAE6DB00D8B7C45F9D1C9BE0DB9E02002111A0B547AE1E220B7DDC",
20-
"address": "SBISV4QCGJ7SSOLG64DBNPWU6J7SSY64R22D2L3Q",
21-
"publicKey": "B5C2611E32E16482B0B9811ABF906A1DE84184DED1D343790482F517C02FB01C"
19+
"privateKey": "48654243251D4ABB9B5E7B621E2FE2E0F6E28791188BAD1454DAE7D98D30FC90",
20+
"address": "SBR5LJWIRDYUKDKRE2LCB632TI4OJNV4YKI3XZ42",
21+
"publicKey": "C5AB53ABEE0CF07501E90C749F64D9CA0DAFDE2970F141D9B4EA40BD95913178"
2222
},
2323
"cosignatory3Account": {
24-
"privateKey": "A7D6ED74CDDECBF621DDC63558433DB604FA800D138810B3DF9B4EC880D0705F",
25-
"address": "SD2UY5LHIAAZDVKRHBOYSS4MTLHVTJVUTQPEGV2U",
26-
"publicKey": "3A33DA75E00F643C49C57E8BD3282149911B06FF107C37F7AEDFED5532166BDA"
24+
"privateKey": "4855155D9541B216FCC6A43350F054C1A63B747CF02C750FD8A1003B6877522A",
25+
"address": "SAHUOMARZKLKJU3RPZ3AJMXDQYKCXMRLHRFIM3PC",
26+
"publicKey": "DED79A396AAA62A1BD1CF7D8F3270536E0D7BBF262F3A6A958EBE08C1C44BE6F"
2727
},
2828
"cosignatory4Account": {
29-
"privateKey": "D2A12301F5595869EFD5374B3372F0ED7EC26BF73A71D310950CC018D3FA0B03",
30-
"address": "SD7PYMM2BTT4SGSITZ2MBQBK4SXIQQQV4ZOP46VF",
31-
"publicKey": "FDE589878756C2287056EC8D7B2829D9C1FA6D389EBDC808034813FE7810AAB0"
29+
"privateKey": "A7C1236D3819F19FB251FEDBEDC0CE6BB11CDCC889B31E37A72653F051FFB0D0",
30+
"address": "SDCAY6EFPM4B4V7DFJKK72L3RBBW6EYEYK7VSDI3",
31+
"publicKey": "F21F9A51DBFC3B9B77D81EF1EF4F3FFE60EEA21775ECFE12031DAA8EF65030E1"
3232
},
3333
"testAccount2": {
34-
"privateKey": "E5DCCEBDB01A8B03A7DB7BA5888E2E33FD4617B5F6FED48C4C09C0780F422713",
35-
"address": "SBSBLBT7CIOQG6XUI7TRDMHV4TKS5O7QM3MWQYHL",
36-
"publicKey": "5F14CD455A1C0B08073C657EFA09365921736C1ADAF0F0685848678AE966EE09"
34+
"privateKey": "C8E081BD133B878BDA2A85975E6C3A39F8CB3ACB9594D0CF4D845D2E8198DEBD",
35+
"address": "SCIBGQYCSX7BR734WZDVIURZZWNLOUJGNX5M3GU7",
36+
"publicKey": "65843A6B96C25F06C8DF5521872905A1D93ED7EB1AFC8F392C7BB00CACFAE907"
3737
},
3838
"testAccount3": {
39-
"privateKey": "CA95470BEFF4487D692D501E5C41F86FAE9CE6DD15B7B64E150E42A18BDE9CF8",
40-
"address": "SBCFDASM35I6JSLUPQMSX2WGJG55WOCNB53NNVPH",
41-
"publicKey": "E97077A656D9E7F5679880D4950BBF2B3638B7ACE17C82CCB7881DE9BAF396C6"
39+
"privateKey": "A0591F79F588758280DFB4823A47FCEEC6A551344F794FFDE3760A9D7E1DE348",
40+
"address": "SAGYYBZZ3N2NXHHRBCJP5M22CNAYMLKPD5RZD6KP",
41+
"publicKey": "6D652E480E5B2997A19D0C7485724693D79A63FCD591A948B40240BD196BA7D6"
4242
},
4343
"testAccountNoBalance": {
4444
"privateKey": "A0591F79F588758280DFB4823A47FCEEC6A551344F794FFDE3760A9D7E1DE348",
45-
"address": "SC5NTT5APX2FAUS4VQUII3UTMAD7GHRFTLDQOEDW",
45+
"address": "SAGYYBZZ3N2NXHHRBCJP5M22CNAYMLKPD5RZD6KP",
4646
"publicKey": "6D652E480E5B2997A19D0C7485724693D79A63FCD591A948B40240BD196BA7D6"
4747
},
4848
"harvestingAccount": {
49-
"privateKey": "0B9802C011DA2D61BCD203F4DC76C012898EE38BA54A7E030B86630A8FD43CA6",
50-
"address": "SAALWHKCWH72J53M3M4LB6UYFGLQMAOXJACWJX2U",
51-
"publicKey": "092CAAFEBCB51C64A7CE423050964492407B264CA306D063DBA927A2304C4DD8"
49+
"privateKey": "0446068B404C969CC5BDD1C412CC96D2AEB555EEF495A8B72AC46086A81A5C23",
50+
"address": "SDU2SMXJNXHW2UC5JLE2474XGEIWNHWM4FL3HQ3K",
51+
"publicKey": "67730056F5F26C8BB9A9BCBBADFCEBDFB48F3552E1321F8A5B42176BB01E72E2"
5252
}
5353
}
Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
// /*
2-
// * Copyright 2018 NEM
3-
// *
4-
// * Licensed under the Apache License, Version 2.0 (the "License");
5-
// * you may not use this file except in compliance with the License.
6-
// * You may obtain a copy of the License at
7-
// *
8-
// * http://www.apache.org/licenses/LICENSE-2.0
9-
// *
10-
// * Unless required by applicable law or agreed to in writing, software
11-
// * distributed under the License is distributed on an "AS IS" BASIS,
12-
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// * See the License for the specific language governing permissions and
14-
// * limitations under the License.
15-
// */
1+
/*
2+
* Copyright 2018 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1616

1717
import {expect} from 'chai';
1818
import {BlockchainHttp} from '../../src/infrastructure/BlockchainHttp';
@@ -43,29 +43,29 @@ describe('BlockchainHttp', () => {
4343
});
4444
});
4545

46-
// describe('getBlockTransactions', () => {
47-
// let nextId: string;
48-
// let firstId: string;
46+
describe('getBlockTransactions', () => {
47+
let nextId: string;
48+
let firstId: string;
4949

50-
// it('should return block transactions data given height', (done) => {
51-
// blockchainHttp.getBlockTransactions(1)
52-
// .subscribe((transactions) => {
53-
// nextId = transactions[0].transactionInfo!.id;
54-
// firstId = transactions[1].transactionInfo!.id;
55-
// expect(transactions.length).to.be.greaterThan(0);
56-
// done();
57-
// });
58-
// });
50+
it('should return block transactions data given height', (done) => {
51+
blockchainHttp.getBlockTransactions(1)
52+
.subscribe((transactions) => {
53+
nextId = transactions[0].transactionInfo!.id;
54+
firstId = transactions[1].transactionInfo!.id;
55+
expect(transactions.length).to.be.greaterThan(0);
56+
done();
57+
});
58+
});
5959

60-
// it('should return block transactions data given height with paginated transactionId', (done) => {
61-
// blockchainHttp.getBlockTransactions(1, new QueryParams(10, nextId))
62-
// .subscribe((transactions) => {
63-
// expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
64-
// expect(transactions.length).to.be.greaterThan(0);
65-
// done();
66-
// });
67-
// });
68-
// });
60+
it('should return block transactions data given height with paginated transactionId', (done) => {
61+
blockchainHttp.getBlockTransactions(1, new QueryParams(10, nextId))
62+
.subscribe((transactions) => {
63+
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
64+
expect(transactions.length).to.be.greaterThan(0);
65+
done();
66+
});
67+
});
68+
});
6969

7070
describe('getBlocksByHeightWithLimit', () => {
7171
it('should return block info given height and limit', (done) => {
@@ -77,37 +77,37 @@ describe('BlockchainHttp', () => {
7777
});
7878
});
7979

80-
// describe('getBlockchainHeight', () => {
81-
// it('should return blockchain height', (done) => {
82-
// blockchainHttp.getBlockchainHeight()
83-
// .subscribe((height) => {
84-
// expect(height.lower).to.be.greaterThan(0);
85-
// done();
86-
// });
87-
// });
88-
// });
80+
describe('getBlockchainHeight', () => {
81+
it('should return blockchain height', (done) => {
82+
blockchainHttp.getBlockchainHeight()
83+
.subscribe((height) => {
84+
expect(height.lower).to.be.greaterThan(0);
85+
done();
86+
});
87+
});
88+
});
8989

90-
// describe('getBlockchainScore', () => {
91-
// it('should return blockchain score', (done) => {
92-
// blockchainHttp.getBlockchainScore()
93-
// .subscribe((blockchainScore) => {
94-
// expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
95-
// expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
96-
// expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
97-
// done();
98-
// });
99-
// });
100-
// });
90+
describe('getBlockchainScore', () => {
91+
it('should return blockchain score', (done) => {
92+
blockchainHttp.getBlockchainScore()
93+
.subscribe((blockchainScore) => {
94+
expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
95+
expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
96+
expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
97+
done();
98+
});
99+
});
100+
});
101101

102-
// describe('getDiagnosticStorage', () => {
103-
// it('should return blockchain diagnostic storage', (done) => {
104-
// blockchainHttp.getDiagnosticStorage()
105-
// .subscribe((blockchainStorageInfo) => {
106-
// expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
107-
// expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
108-
// expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
109-
// done();
110-
// });
111-
// });
112-
// });
113-
// });
102+
describe('getDiagnosticStorage', () => {
103+
it('should return blockchain diagnostic storage', (done) => {
104+
blockchainHttp.getDiagnosticStorage()
105+
.subscribe((blockchainStorageInfo) => {
106+
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
107+
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
108+
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
109+
done();
110+
});
111+
});
112+
});
113+
});

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,14 +1190,20 @@ describe('TransactionHttp', () => {
11901190
Deadline.create(),
11911191
HashType.Op_Sha3_256,
11921192
secret,
1193+
account2.address,
11931194
proof,
11941195
NetworkType.MIJIN_TEST,
11951196
);
1196-
listener.confirmed(account2.address).subscribe((transaction: Transaction) => {
1197-
done();
1198-
});
11991197
transactionHttp.announce(secretProofTransaction.signWith(account2));
12001198
});
1199+
listener.confirmed(account2.address).subscribe((transaction: Transaction) => {
1200+
done();
1201+
});
1202+
listener.status(account2.address).subscribe((error) => {
1203+
console.log('Error:', error);
1204+
assert(false);
1205+
done();
1206+
});
12011207
listener.status(account.address).subscribe((error) => {
12021208
console.log('Error:', error);
12031209
assert(false);
@@ -1236,6 +1242,7 @@ describe('TransactionHttp', () => {
12361242
Deadline.create(),
12371243
HashType.Op_Sha3_256,
12381244
secret,
1245+
account2.address,
12391246
proof,
12401247
NetworkType.MIJIN_TEST,
12411248
);
@@ -1283,6 +1290,7 @@ describe('TransactionHttp', () => {
12831290
Deadline.create(),
12841291
HashType.Op_Keccak_256,
12851292
secret,
1293+
account2.address,
12861294
proof,
12871295
NetworkType.MIJIN_TEST,
12881296
);
@@ -1331,6 +1339,7 @@ describe('TransactionHttp', () => {
13311339
Deadline.create(),
13321340
HashType.Op_Keccak_256,
13331341
secret,
1342+
account2.address,
13341343
proof,
13351344
NetworkType.MIJIN_TEST,
13361345
);
@@ -1380,6 +1389,7 @@ describe('TransactionHttp', () => {
13801389
Deadline.create(),
13811390
HashType.Op_Hash_160,
13821391
secret,
1392+
account2.address,
13831393
proof,
13841394
NetworkType.MIJIN_TEST,
13851395
);
@@ -1430,6 +1440,7 @@ describe('TransactionHttp', () => {
14301440
Deadline.create(),
14311441
HashType.Op_Hash_160,
14321442
secret,
1443+
account2.address,
14331444
proof,
14341445
NetworkType.MIJIN_TEST,
14351446
);
@@ -1484,6 +1495,7 @@ describe('TransactionHttp', () => {
14841495
Deadline.create(),
14851496
HashType.Op_Hash_256,
14861497
secret,
1498+
account2.address,
14871499
proof,
14881500
NetworkType.MIJIN_TEST,
14891501
);
@@ -1534,6 +1546,7 @@ describe('TransactionHttp', () => {
15341546
Deadline.create(),
15351547
HashType.Op_Hash_256,
15361548
secret,
1549+
account2.address,
15371550
proof,
15381551
NetworkType.MIJIN_TEST,
15391552
);

src/infrastructure/AccountHttp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ export class AccountHttp extends Http implements AccountRepository {
9898
* @returns Observable<AccountProperty[]>
9999
*/
100100
public getAccountPropertiesFromAccounts(addresses: Address[]): Observable<AccountPropertiesInfo[]> {
101-
const accountIds = addresses.map((address) => address.plain());
101+
const accountIds = {
102+
addresses: addresses.map((address) => address.plain())
103+
};
102104
return observableFrom(
103105
this.accountRoutesApi.getAccountPropertiesFromAccounts(accountIds)).pipe(map((accountProperties) => {
104106
return accountProperties.map((property) => {

src/infrastructure/transaction/CreateTransactionFromDTO.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ const CreateStandaloneTransactionFromDTO = (transactionDTO, transactionInfo): Tr
240240
new UInt64(transactionDTO.maxFee || [0, 0]),
241241
transactionDTO.hashAlgorithm,
242242
transactionDTO.secret,
243+
transactionDTO.recipient,
243244
transactionDTO.proof,
244245
transactionDTO.signature,
245246
transactionDTO.signer ? PublicAccount.createFromPublicKey(transactionDTO.signer,

src/infrastructure/transaction/CreateTransactionFromPayload.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,18 @@ const CreateTransaction = (type: number, transactionData: string, networkType: N
311311
const secretProofHashAlgorithm = parseInt(convert.uint8ToHex(convert.hexToUint8(
312312
transactionData.substring(0, 2)).reverse()), 16);
313313

314-
const secretProofSecretLength = HashType.Op_Hash_160 === secretProofHashAlgorithm ? 40 : 64;
315-
const secretProofSecret = transactionData.substring(2, 2 + secretProofSecretLength);
316-
const secretProofSize = transactionData.substring(2 + secretProofSecretLength, 6 + secretProofSecretLength);
317-
const mosaicProof = transactionData.substring(6 + secretProofSecretLength);
314+
const secretProofSecretLength = 64;
315+
const secretProofSecret = transactionData.substring(2, 66);
316+
const secretProofRecipient = transactionData.substring(66, 116);
317+
const secretProofSize = transactionData.substring(116, 120);
318+
const secretProofProof = transactionData.substring(120);
318319

319320
return SecretProofTransaction.create(
320321
Deadline.createFromDTO(deadline),
321322
secretProofHashAlgorithm,
322323
secretProofSecret,
323-
mosaicProof,
324+
Address.createFromEncoded(secretProofRecipient),
325+
secretProofProof,
324326
networkType,
325327
);
326328
case TransactionType.MODIFY_MULTISIG_ACCOUNT:

src/infrastructure/transaction/SerializeTransactionToJSON.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export const SerializeTransactionToJSON = (transaction: Transaction): any => {
147147
return {
148148
hashAlgorithm: (transaction as SecretProofTransaction).hashType,
149149
secret: (transaction as SecretProofTransaction).secret,
150+
recipient: (transaction as SecretProofTransaction).recipient.toDTO(),
150151
proof: (transaction as SecretProofTransaction).proof,
151152
};
152153
case TransactionType.TRANSFER:

0 commit comments

Comments
 (0)