Skip to content

Commit 1a57f2d

Browse files
committed
Merge remote-tracking branch 'origin/master' into catbuffer-library
# Conflicts: # src/infrastructure/transaction/CreateTransactionFromPayload.ts # src/model/transaction/AccountAddressRestrictionTransaction.ts # src/model/transaction/AccountMosaicRestrictionTransaction.ts # src/model/transaction/AccountOperationRestrictionTransaction.ts # src/service/AggregateTransactionService.ts
2 parents 2f7f516 + 3526679 commit 1a57f2d

File tree

91 files changed

+517
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+517
-593
lines changed

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ describe('AccountHttp', () => {
229229

230230
describe('transactions', () => {
231231
it('should not return accounts when account does not exist', () => {
232-
return accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address).toPromise().then(r => {
232+
return accountRepository.getAccountInfo(Account.generateNewAccount(networkType).address).toPromise().then((r) => {
233233
return Promise.reject('should fail!');
234-
}, err => {
234+
}, (err) => {
235235
const error = JSON.parse(err.message);
236236
expect(error.statusCode).to.be.eq(404);
237237
expect(error.errorDetails.statusMessage).to.be.eq('Not Found');
@@ -245,7 +245,7 @@ describe('AccountHttp', () => {
245245
const transactions = await accountRepository.getAccountTransactions(publicAccount.address, {transactionType: TransactionType.TRANSFER} as QueryParams).toPromise();
246246

247247
expect(transactions.length).to.be.greaterThan(0);
248-
transactions.forEach(t => {
248+
transactions.forEach((t) => {
249249
expect(t.type).to.be.eq(TransactionType.TRANSFER);
250250
});
251251
});

e2e/infrastructure/BlockHttp.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { Deadline } from '../../src/model/transaction/Deadline';
2828
import { TransactionInfo } from '../../src/model/transaction/TransactionInfo';
2929
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction';
3030
import { IntegrationTestHelper } from './IntegrationTestHelper';
31+
import { UInt64 } from '../../src/model/UInt64';
3132

3233
describe('BlockHttp', () => {
3334
const helper = new IntegrationTestHelper();
@@ -87,7 +88,7 @@ describe('BlockHttp', () => {
8788

8889
describe('getBlockByHeight', () => {
8990
it('should return block info given height', (done) => {
90-
blockRepository.getBlockByHeight('1')
91+
blockRepository.getBlockByHeight(UInt64.fromUint(1))
9192
.subscribe((blockInfo) => {
9293
blockReceiptHash = blockInfo.blockReceiptsHash;
9394
blockTransactionHash = blockInfo.blockTransactionsHash;
@@ -105,7 +106,7 @@ describe('BlockHttp', () => {
105106
let firstId: string;
106107

107108
it('should return block transactions data given height', (done) => {
108-
blockRepository.getBlockTransactions('1')
109+
blockRepository.getBlockTransactions(UInt64.fromUint(1))
109110
.subscribe((transactions) => {
110111
nextId = transactions[0].transactionInfo!.id;
111112
firstId = transactions[1].transactionInfo!.id;
@@ -115,7 +116,7 @@ describe('BlockHttp', () => {
115116
});
116117

117118
it('should return block transactions data given height with paginated transactionId', (done) => {
118-
blockRepository.getBlockTransactions('1', new QueryParams(10, nextId))
119+
blockRepository.getBlockTransactions(UInt64.fromUint(1), new QueryParams(10, nextId))
119120
.subscribe((transactions) => {
120121
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
121122
expect(transactions.length).to.be.greaterThan(0);

e2e/infrastructure/RestrictionHttp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { deepEqual } from 'assert';
1818
import { expect } from 'chai';
19-
import { RestrictionAccountRepository } from '../../src/infrastructure/RestrictionAccountRespository';
19+
import { RestrictionAccountRepository } from '../../src/infrastructure/RestrictionAccountRepository';
2020
import { RestrictionMosaicRepository } from '../../src/infrastructure/RestrictionMosaicRepository';
2121
import { Account } from '../../src/model/account/Account';
2222
import { Address } from '../../src/model/account/Address';

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ describe('TransactionHttp', () => {
531531
const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction(
532532
Deadline.create(),
533533
AccountRestrictionFlags.BlockIncomingTransactionType,
534-
[TransactionType.LINK_ACCOUNT],
534+
[TransactionType.ACCOUNT_LINK],
535535
[],
536536
networkType, helper.maxFee,
537537
);
@@ -551,7 +551,7 @@ describe('TransactionHttp', () => {
551551
Deadline.create(),
552552
AccountRestrictionFlags.BlockIncomingTransactionType,
553553
[],
554-
[TransactionType.LINK_ACCOUNT],
554+
[TransactionType.ACCOUNT_LINK],
555555
networkType, helper.maxFee,
556556
);
557557
const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(),
@@ -569,12 +569,12 @@ describe('TransactionHttp', () => {
569569
it('standalone', () => {
570570
AccountRestrictionModification.createForOperation(
571571
AccountRestrictionModificationAction.Add,
572-
TransactionType.LINK_ACCOUNT,
572+
TransactionType.ACCOUNT_LINK,
573573
);
574574
const addressModification = AccountRestrictionTransaction.createOperationRestrictionModificationTransaction(
575575
Deadline.create(),
576576
AccountRestrictionFlags.BlockOutgoingTransactionType,
577-
[TransactionType.LINK_ACCOUNT],
577+
[TransactionType.ACCOUNT_LINK],
578578
[],
579579
networkType, helper.maxFee,
580580
);
@@ -595,7 +595,7 @@ describe('TransactionHttp', () => {
595595
Deadline.create(),
596596
AccountRestrictionFlags.BlockOutgoingTransactionType,
597597
[],
598-
[TransactionType.LINK_ACCOUNT],
598+
[TransactionType.ACCOUNT_LINK],
599599
networkType, helper.maxFee,
600600
);
601601
const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(),

e2e/service/MetadataTransactionService.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('MetadataTransactionService', () => {
160160
newValue,
161161
targetAccount.publicAccount,
162162
).subscribe((transaction: AccountMetadataTransaction) => {
163-
expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA_TRANSACTION);
163+
expect(transaction.type).to.be.equal(TransactionType.ACCOUNT_METADATA);
164164
expect(transaction.scopedMetadataKey.toHex()).to.be.equal(key.toHex());
165165
expect(transaction.value).to.be.equal(newValue);
166166
expect(transaction.targetPublicKey).to.be.equal(targetAccount.publicKey);
@@ -180,7 +180,7 @@ describe('MetadataTransactionService', () => {
180180
targetAccount.publicAccount,
181181
mosaicId,
182182
).subscribe((transaction: MosaicMetadataTransaction) => {
183-
expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA_TRANSACTION);
183+
expect(transaction.type).to.be.equal(TransactionType.MOSAIC_METADATA);
184184
expect(transaction.scopedMetadataKey.toHex()).to.be.equal(key.toHex());
185185
expect(transaction.valueSizeDelta).to.be.equal(5);
186186
expect(transaction.value).to.be.equal(newValue + 'delta');
@@ -202,7 +202,7 @@ describe('MetadataTransactionService', () => {
202202
targetAccount.publicAccount,
203203
namespaceId,
204204
).subscribe((transaction: NamespaceMetadataTransaction) => {
205-
expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA_TRANSACTION);
205+
expect(transaction.type).to.be.equal(TransactionType.NAMESPACE_METADATA);
206206
expect(transaction.scopedMetadataKey.toHex()).to.be.equal(key.toHex());
207207
expect(transaction.valueSizeDelta).to.be.equal(5);
208208
expect(transaction.value).to.be.equal(newValue + 'delta');

e2e/service/MosaicRestrictionTransactionService.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ describe('MosaicRestrictionTransactionService', () => {
7474
UInt64.fromUint(1000),
7575
networkType, helper.maxFee,
7676
);
77-
console.log(mosaicId.toHex());
7877
const signedTransaction = mosaicDefinitionTransaction.signWith(account, generationHash);
7978
return helper.announce(signedTransaction);
8079
});

e2e/service/MosaicService.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ describe('MosaicService', () => {
4444
const views = amountViews.map((v) => {
4545
return {mosaicId: v.fullName(), amount: v.relativeAmount()};
4646
});
47-
console.log(views);
4847
done();
4948
});
5049
});

package-lock.json

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@
5858
},
5959
"dependencies": {
6060
"bluebird": "^3.5.5",
61-
"catbuffer": "0.0.7",
62-
"nem2-sdk-openapi-typescript-node-client": "0.7.20-beta.6",
61+
"catbuffer": "0.0.11",
6362
"crypto-js": "^3.1.9-1",
63+
"futoin-hkdf": "^1.3.1",
6464
"js-joda": "^1.6.2",
6565
"js-sha256": "^0.9.0",
6666
"js-sha3": "^0.8.0",
6767
"long": "^4.0.0",
6868
"merkletreejs": "^0.1.7",
69+
"nem2-sdk-openapi-typescript-node-client": "0.7.20-alpha.7",
6970
"request": "^2.88.0",
7071
"request-promise-native": "^1.0.5",
7172
"ripemd160": "^2.0.2",

src/core/crypto/Crypto.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,19 @@ export class Crypto {
228228
recipientPub: string,
229229
msg: string,
230230
iv: Uint8Array,
231-
salt: Uint8Array,
232231
signSchema: SignSchema): string => {
233232
// Errors
234-
if (!senderPriv || !recipientPub || !msg || !iv || !salt) { throw new Error('Missing argument !'); }
233+
if (!senderPriv || !recipientPub || !msg || !iv) { throw new Error('Missing argument !'); }
235234
// Processing
236235
const keyPair = KeyPair.createKeyPairFromPrivateKeyString(senderPriv, signSchema);
237236
const pk = convert.hexToUint8(recipientPub);
238-
const encKey = utility.ua2words(KeyPair.deriveSharedKey(keyPair, pk, salt, signSchema), 32);
237+
const encKey = utility.ua2words(KeyPair.deriveSharedKey(keyPair, pk, signSchema), 32);
239238
const encIv = {
240239
iv: utility.ua2words(iv, 16),
241240
};
242241
const encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(msg), encKey, encIv);
243242
// Result
244-
const result = convert.uint8ToHex(salt) + convert.uint8ToHex(iv) + CryptoJS.enc.Hex.stringify(encrypted.ciphertext);
243+
const result = convert.uint8ToHex(iv) + CryptoJS.enc.Hex.stringify(encrypted.ciphertext);
245244
return result;
246245
}
247246

@@ -264,8 +263,7 @@ export class Crypto {
264263
if (!senderPriv || !recipientPub || !msg) { throw new Error('Missing argument !'); }
265264
// Processing
266265
const iv = Crypto.randomBytes(16);
267-
const salt = Crypto.randomBytes(32);
268-
const encoded = Crypto._encode(senderPriv, recipientPub, isHexString ? msg : convert.utf8ToHex(msg), iv, salt, signSchema);
266+
const encoded = Crypto._encode(senderPriv, recipientPub, isHexString ? msg : convert.utf8ToHex(msg), iv, signSchema);
269267
// Result
270268
return encoded;
271269
}
@@ -277,22 +275,20 @@ export class Crypto {
277275
* @param {string} senderPublic - A sender public key
278276
* @param {Uint8Array} payload - An encrypted message payload in bytes
279277
* @param {Uint8Array} iv - 16-byte AES initialization vector
280-
* @param {Uint8Array} salt - 32-byte salt
281278
* @param {SignSchema} signSchema The Sign Schema. (KECCAK(NIS1) / SHA3(Catapult))
282279
* @return {string} - The decoded payload as hex
283280
*/
284281
public static _decode = (recipientPrivate: string,
285282
senderPublic: string,
286283
payload: Uint8Array,
287284
iv: Uint8Array,
288-
salt: Uint8Array,
289285
signSchema: SignSchema): string => {
290286
// Error
291287
if (!recipientPrivate || !senderPublic || !payload) { throw new Error('Missing argument !'); }
292288
// Processing
293289
const keyPair = KeyPair.createKeyPairFromPrivateKeyString(recipientPrivate, signSchema);
294290
const pk = convert.hexToUint8(senderPublic);
295-
const encKey = utility.ua2words(KeyPair.deriveSharedKey(keyPair, pk, salt, signSchema), 32);
291+
const encKey = utility.ua2words(KeyPair.deriveSharedKey(keyPair, pk, signSchema), 32);
296292
const encIv = {
297293
iv: utility.ua2words(iv, 16),
298294
};
@@ -321,10 +317,9 @@ export class Crypto {
321317
if (!recipientPrivate || !senderPublic || !payload) { throw new Error('Missing argument !'); }
322318
// Processing
323319
const binPayload = convert.hexToUint8(payload);
324-
const payloadBuffer = new Uint8Array(binPayload.buffer, 48);
325-
const salt = new Uint8Array(binPayload.buffer, 0, 32);
326-
const iv = new Uint8Array(binPayload.buffer, 32, 16);
327-
const decoded = Crypto._decode(recipientPrivate, senderPublic, payloadBuffer, iv, salt, signSchema);
320+
const payloadBuffer = new Uint8Array(binPayload.buffer, 16);
321+
const iv = new Uint8Array(binPayload.buffer, 0, 16);
322+
const decoded = Crypto._decode(recipientPrivate, senderPublic, payloadBuffer, iv, signSchema);
328323
return decoded.toUpperCase();
329324
}
330325

0 commit comments

Comments
 (0)