Skip to content

Commit 81f9940

Browse files
authored
Merge branch 'master' into travis-alpha-releases-from-master
2 parents bf9e541 + 0aae295 commit 81f9940

23 files changed

+666
-246
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ All notable changes to this project will be documented in this file.
33

44
The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

6+
## [0.17.2] - 02-Mar-2020
7+
8+
**Milestone**: Fushicho.4(RC3 0.9.3.1)
9+
Versions | |
10+
---|---|---
11+
SDK Core| v0.17.2 | https://www.npmjs.com/package/symbol-sdk
12+
Catbuffer | v0.0.11 | https://www.npmjs.com/package/catbuffer-typescript
13+
Client Library | v0.8.5 | https://www.npmjs.com/package/symbol-openapi-typescript-node-client
14+
15+
- **[BREAKING CHANGE]** Added `s-part` of transaction signature to transaction hash.
16+
- Added `numStatements` to `blockInfo` model.
17+
- Fixed `mosaicNonce` issue in `createTransactionFromPayload`.
18+
- Improved error handling in WS `listener` and `TransactionService`.
19+
- Improved test coverage.
20+
621
## [0.17.1] - 24-Feb-2020
722

823
**Milestone**: Fushicho.4(RC3 0.9.3.1)
@@ -392,6 +407,7 @@ Client Library | v0.7.20-alpha.6 | https://www.npmjs.com/package/nem2-sdk-opena
392407

393408
- Initial code release.
394409

410+
[0.17.1]: https://github.com/nemtech/symbol-sdk-typescript-javascript/compare/v0.17.1...v0.17.2
395411
[0.17.1]: https://github.com/nemtech/symbol-sdk-typescript-javascript/compare/v0.17.0...v0.17.1
396412
[0.17.0]: https://github.com/nemtech/symbol-sdk-typescript-javascript/compare/v0.16.5...v0.17.0
397413
[0.16.5]: https://github.com/nemtech/symbol-sdk-typescript-javascript/compare/v0.16.4...v0.16.5

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ The Symbol SDK for TypeScript / JavaScript allows you to develop web, mobile, an
1313

1414
**!!! Please be noted that the NEM2-SDK is rebranded to SYMBOL-SDK now**.
1515

16-
Due to a network upgrade with [catapult-server@Fushicho](https://github.com/nemtech/catapult-server/releases/tag/v0.9.3.1) version, **it is recommended to use this package's 0.17.1 version and upwards to use this package with Fushicho versioned networks**.
16+
Due to a network upgrade with [catapult-server@Fushicho](https://github.com/nemtech/catapult-server/releases/tag/v0.9.3.1) version, **it is recommended to use this package's 0.17.2 version and upwards to use this package with Fushicho versioned networks**.
1717

18-
The upgrade to this package's [version v0.17.0](https://github.com/nemtech/symbol-sdk-typescript-javascript/releases/tag/v0.17.1) is mandatory for **fushicho compatibility**.
18+
The upgrade to this package's [version v0.17.2](https://github.com/nemtech/symbol-sdk-typescript-javascript/releases/tag/v0.17.2) is mandatory for **fushicho compatibility**.
1919

2020
You can find the complete changelog [here](CHANGELOG.md).
2121

e2e/infrastructure/IntegrationTestHelper.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import { combineLatest } from 'rxjs';
17-
import { filter } from 'rxjs/operators';
17+
import { map } from 'rxjs/operators';
1818
import { IListener } from '../../src/infrastructure/IListener';
1919
import { RepositoryFactory } from '../../src/infrastructure/RepositoryFactory';
2020
import { RepositoryFactoryHttp } from '../../src/infrastructure/RepositoryFactoryHttp';
@@ -23,6 +23,7 @@ import { NetworkType } from '../../src/model/blockchain/NetworkType';
2323
import { SignedTransaction } from '../../src/model/transaction/SignedTransaction';
2424
import { Transaction } from '../../src/model/transaction/Transaction';
2525
import { UInt64 } from '../../src/model/UInt64';
26+
import { TransactionService } from '../../src/service/TransactionService';
2627

2728
export class IntegrationTestHelper {
2829
public readonly yaml = require('js-yaml');
@@ -41,6 +42,7 @@ export class IntegrationTestHelper {
4142
public listener: IListener;
4243
public maxFee: UInt64;
4344
public harvestingAccount: Account;
45+
public transactionService: TransactionService;
4446

4547
start(): Promise<IntegrationTestHelper> {
4648
return new Promise<IntegrationTestHelper>(
@@ -55,6 +57,7 @@ export class IntegrationTestHelper {
5557
console.log(`Running tests against: ${json.apiUrl}`);
5658
this.apiUrl = json.apiUrl;
5759
this.repositoryFactory = new RepositoryFactoryHttp(json.apiUrl);
60+
this.transactionService = new TransactionService(this.repositoryFactory.createTransactionRepository(), this.repositoryFactory.createReceiptRepository());
5861
combineLatest(this.repositoryFactory.getGenerationHash(),
5962
this.repositoryFactory.getNetworkType()).subscribe(([generationHash, networkType]) => {
6063
this.networkType = networkType;
@@ -107,20 +110,10 @@ export class IntegrationTestHelper {
107110
}
108111

109112
announce(signedTransaction: SignedTransaction): Promise<Transaction> {
110-
return new Promise<Transaction>(
111-
(resolve, reject) => {
112-
const address = signedTransaction.getSignerAddress();
113-
console.log(`Announcing transaction: ${signedTransaction.type}`);
114-
this.listener.confirmed(address, signedTransaction.hash).subscribe((transaction) => {
115-
console.log(`Transaction ${signedTransaction.type} confirmed`);
116-
resolve(transaction);
117-
});
118-
this.listener.status(address).pipe(filter((status) => status.hash === signedTransaction.hash)).subscribe((error) => {
119-
console.log(`Error processing transaction ${signedTransaction.type}`, error);
120-
reject(error);
121-
});
122-
this.repositoryFactory.createTransactionRepository().announce(signedTransaction);
123-
},
124-
);
113+
console.log(`Announcing transaction: ${signedTransaction.type}`);
114+
return this.transactionService.announce(signedTransaction, this.listener).pipe(map((t) => {
115+
console.log(`Transaction ${signedTransaction.type} confirmed`);
116+
return t;
117+
})).toPromise();
125118
}
126119
}

src/core/crypto/nacl_catapult.ts

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -669,28 +669,6 @@ const unpack25519 = (o, n) => {
669669
o[15] &= 0x7fff;
670670
};
671671

672-
export const cleanup = (arr) => {
673-
for (let i = 0; i < arr.length; i++) {
674-
arr[i] = 0;
675-
}
676-
};
677-
678-
export const crypto_shared_key_hash = (shared, pk, sk, hashfunc) => {
679-
const d = new Uint8Array(64);
680-
const p = [gf(), gf(), gf(), gf()];
681-
682-
hashfunc(d, sk, 32);
683-
d[0] &= 248;
684-
d[31] &= 127;
685-
d[31] |= 64;
686-
687-
const q = [gf(), gf(), gf(), gf()];
688-
// tslint:disable: no-use-before-declare
689-
unpackneg(q, pk);
690-
scalarmult(p, q, d);
691-
pack(shared, p);
692-
};
693-
694672
export const crypto_verify_32 = (x, xi, y, yi) => {
695673
return vn(x, xi, y, yi, 32);
696674
};
@@ -728,47 +706,6 @@ export const add = (p, q) => {
728706
M(p[3], e, h);
729707
};
730708

731-
export const modL = (r, x) => {
732-
// tslint:disable-next-line:one-variable-per-declaration
733-
let carry, i, j, k;
734-
for (i = 63; i >= 32; --i) {
735-
carry = 0;
736-
for (j = i - 32, k = i - 12; j < k; ++j) {
737-
x[j] += carry - 16 * x[i] * L[j - (i - 32)];
738-
carry = (x[j] + 128) >> 8;
739-
x[j] -= carry * 256;
740-
}
741-
x[j] += carry;
742-
x[i] = 0;
743-
}
744-
carry = 0;
745-
for (j = 0; j < 32; j++) {
746-
x[j] += carry - (x[31] >> 4) * L[j];
747-
carry = x[j] >> 8;
748-
x[j] &= 255;
749-
}
750-
for (j = 0; j < 32; j++) {
751-
x[j] -= carry * L[j];
752-
}
753-
for (i = 0; i < 32; i++) {
754-
x[i + 1] += x[i] >> 8;
755-
r[i] = x[i] & 255;
756-
}
757-
};
758-
759-
export const reduce = (r) => {
760-
// tslint:disable-next-line:one-variable-per-declaration
761-
let x = new Float64Array(64),
762-
i;
763-
for (i = 0; i < 64; i++) {
764-
x[i] = r[i];
765-
}
766-
for (i = 0; i < 64; i++) {
767-
r[i] = 0;
768-
}
769-
modL(r, x);
770-
};
771-
772709
export const pack = (r, p) => {
773710
// tslint:disable-next-line:one-variable-per-declaration
774711
const tx = gf(),
@@ -797,64 +734,6 @@ export const scalarmult = (p, q, s) => {
797734
}
798735
};
799736

800-
export const scalarbase = (p, s) => {
801-
const q = [gf(), gf(), gf(), gf()];
802-
set25519(q[0], X);
803-
set25519(q[1], Y);
804-
set25519(q[2], gf1);
805-
M(q[3], X, Y);
806-
scalarmult(p, q, s);
807-
};
808-
809-
export const unpackneg = (r, p) => {
810-
// tslint:disable-next-line:one-variable-per-declaration
811-
const t = gf(),
812-
chk = gf(),
813-
num = gf(),
814-
den = gf(),
815-
den2 = gf(),
816-
den4 = gf(),
817-
den6 = gf();
818-
819-
set25519(r[2], gf1);
820-
unpack25519(r[1], p);
821-
S(num, r[1]);
822-
M(den, num, D);
823-
Z(num, num, r[2]);
824-
A(den, r[2], den);
825-
826-
S(den2, den);
827-
S(den4, den2);
828-
M(den6, den4, den2);
829-
M(t, den6, num);
830-
M(t, t, den);
831-
832-
pow2523(t, t);
833-
M(t, t, num);
834-
M(t, t, den);
835-
M(t, t, den);
836-
M(r[0], t, den);
837-
838-
S(chk, r[0]);
839-
M(chk, chk, den);
840-
if (neq25519(chk, num)) {
841-
M(r[0], r[0], I);
842-
}
843-
844-
S(chk, r[0]);
845-
M(chk, chk, den);
846-
if (neq25519(chk, num)) {
847-
return -1;
848-
}
849-
850-
if (par25519(r[0]) === (p[31] >> 7)) {
851-
Z(r[0], gf0, r[0]);
852-
}
853-
854-
M(r[3], r[0], r[1]);
855-
return 0;
856-
};
857-
858737
export const unpack = (r, p) => {
859738
// tslint:disable-next-line:one-variable-per-declaration
860739
const t = gf(),

src/infrastructure/Http.ts

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

17-
import { NodeRoutesApi } from 'symbol-openapi-typescript-node-client';
17+
import * as http from 'http';
1818
// tslint:disable-next-line: ordered-imports
1919
import { from as observableFrom, Observable, of as observableOf, throwError } from 'rxjs';
2020
import { catchError, map, shareReplay } from 'rxjs/operators';
21+
import { NodeRoutesApi } from 'symbol-openapi-typescript-node-client';
2122
import { NetworkType } from '../model/blockchain/NetworkType';
2223
import { QueryParams } from './QueryParams';
2324
import { TransactionFilter } from './TransactionFilter';
@@ -59,7 +60,7 @@ export abstract class Http {
5960

6061
transactionFilter(filter?: TransactionFilter): any {
6162
return {
62-
type: filter ? filter.convertCSV(filter.types) : undefined,
63+
type: filter ? filter.types : undefined,
6364
};
6465
}
6566

@@ -80,4 +81,16 @@ export abstract class Http {
8081
}
8182
return new Error(error);
8283
}
84+
85+
/**
86+
* This method knows how to call, convert and handle exception when doing remote http operations.
87+
* @param remoteCall the remote call
88+
* @param mapper the mapper from dto to the model object.
89+
*/
90+
protected call<D, M>(remoteCall: Promise<{ response: http.IncomingMessage; body: D; }>, mapper: (value: D, index: number) => M) {
91+
return observableFrom(remoteCall).pipe(
92+
map(({body}, index) => mapper(body, index)),
93+
catchError((error) => throwError(this.errorHandling(error))),
94+
);
95+
}
8396
}

src/infrastructure/NetworkHttp.ts

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

17-
import { from as observableFrom, Observable, throwError } from 'rxjs';
18-
import { catchError, map } from 'rxjs/operators';
17+
import { Observable } from 'rxjs';
18+
import { map } from 'rxjs/operators';
1919
import { NetworkRoutesApi } from 'symbol-openapi-typescript-node-client';
2020
import { NetworkFees } from '../model/blockchain/NetworkFees';
2121
import { NetworkName } from '../model/blockchain/NetworkName';
@@ -35,8 +35,8 @@ export class NetworkHttp extends Http implements NetworkRepository {
3535
* @internal
3636
* Symbol openapi typescript-node client account routes api
3737
*/
38-
private nodeHttp: NodeHttp;
39-
private networkRouteApi: NetworkRoutesApi;
38+
private readonly nodeHttp: NodeHttp;
39+
private readonly networkRoutesApi: NetworkRoutesApi;
4040

4141
/**
4242
* Constructor
@@ -45,7 +45,7 @@ export class NetworkHttp extends Http implements NetworkRepository {
4545
constructor(url: string) {
4646
super(url);
4747
this.nodeHttp = new NodeHttp(url);
48-
this.networkRouteApi = new NetworkRoutesApi(url);
48+
this.networkRoutesApi = new NetworkRoutesApi(url);
4949

5050
}
5151

@@ -55,10 +55,7 @@ export class NetworkHttp extends Http implements NetworkRepository {
5555
* @return network identifier.
5656
*/
5757
public getNetworkType(): Observable<NetworkType> {
58-
return observableFrom(this.nodeHttp.getNodeInfo()).pipe(
59-
map(((nodeInfo: NodeInfo) => nodeInfo.networkIdentifier),
60-
catchError((error) => throwError(this.errorHandling(error)))),
61-
);
58+
return this.nodeHttp.getNodeInfo().pipe(map((nodeInfo: NodeInfo) => nodeInfo.networkIdentifier));
6259
}
6360

6461
/**
@@ -67,10 +64,7 @@ export class NetworkHttp extends Http implements NetworkRepository {
6764
* @return current network type name and description
6865
*/
6966
public getNetworkName(): Observable<NetworkName> {
70-
return observableFrom(this.networkRouteApi.getNetworkType()).pipe(
71-
map((({body}) => new NetworkName(body.name, body.description))),
72-
catchError((error) => throwError(this.errorHandling(error))),
73-
);
67+
return this.call(this.networkRoutesApi.getNetworkType(), (body) => new NetworkName(body.name, body.description));
7468
}
7569

7670
/**
@@ -80,10 +74,7 @@ export class NetworkHttp extends Http implements NetworkRepository {
8074
* @summary Get transaction fees information
8175
*/
8276
public getNetworkFees(): Observable<NetworkFees> {
83-
return observableFrom(this.networkRouteApi.getNetworkFees()).pipe(
84-
map((({body}) =>
85-
new NetworkFees(body.averageFeeMultiplier, body.medianFeeMultiplier, body.highestFeeMultiplier, body.lowestFeeMultiplier))),
86-
catchError((error) => throwError(this.errorHandling(error))),
87-
);
77+
return this.call(this.networkRoutesApi.getNetworkFees(), (body) =>
78+
new NetworkFees(body.averageFeeMultiplier, body.medianFeeMultiplier, body.highestFeeMultiplier, body.lowestFeeMultiplier));
8879
}
8980
}

0 commit comments

Comments
 (0)