Skip to content

Commit e3693e5

Browse files
authored
Merge pull request #463 from NEMStudios/travis-alpha-releases-from-master
NPM Alpha deployments from master
2 parents 97c3ff6 + 8329571 commit e3693e5

File tree

7 files changed

+310
-85
lines changed

7 files changed

+310
-85
lines changed

.travis.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ cache:
88
- "node_modules"
99
before_script:
1010
- npm run build
11-
script:
11+
script:
1212
- npm run test:cov
1313
- npm run coveralls-report
1414
- npm install --global typedoc
1515
- typedoc --out ts-docs src
1616
- touch ./ts-docs/.nojekyll
1717
deploy:
18-
provider: pages
19-
skip_cleanup: true
20-
local_dir: ts-docs
21-
github_token: $GITHUB_TOKEN
22-
on:
23-
branch: master
24-
18+
- provider: pages
19+
skip_cleanup: true
20+
local_dir: ts-docs
21+
github_token: $GITHUB_TOKEN
22+
on:
23+
branch: master
24+
- provider: script
25+
skip_cleanup: true
26+
script: /bin/sh travis/uploadArchives.sh
27+
on:
28+
branch: master
29+
node_js: "8"

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "symbol-sdk",
3-
"version": "0.17.3",
3+
"version": "0.17.4",
44
"description": "Reactive symbol sdk for typescript and javascript",
55
"scripts": {
66
"pretest": "npm run build",
@@ -11,7 +11,8 @@
1111
"build": "rm -rf dist/ && tsc && npm run e2econfigcopy",
1212
"test:cov": "nyc --reporter=lcov --reporter=text-summary npm t",
1313
"test:coveralls": "npm run test:cov | coveralls",
14-
"coveralls-report": "cat ./coverage/lcov.info | coveralls"
14+
"coveralls-report": "cat ./coverage/lcov.info | coveralls",
15+
"version": "echo $npm_package_version"
1516
},
1617
"contributors": [
1718
{

src/infrastructure/AccountHttp.ts

Lines changed: 42 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +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';
19-
import { AccountInfoDTO, AccountRoutesApi } from 'symbol-openapi-typescript-node-client';
17+
import { Observable } from 'rxjs';
18+
import { AccountIds, AccountInfoDTO, AccountRoutesApi } from 'symbol-openapi-typescript-node-client';
2019
import { AccountInfo } from '../model/account/AccountInfo';
2120
import { ActivityBucket } from '../model/account/ActivityBucket';
2221
import { Address } from '../model/account/Address';
@@ -58,25 +57,18 @@ export class AccountHttp extends Http implements AccountRepository {
5857
* @returns Observable<AccountInfo>
5958
*/
6059
public getAccountInfo(address: Address): Observable<AccountInfo> {
61-
return observableFrom(this.accountRoutesApi.getAccountInfo(address.plain())).pipe(
62-
map(({body}) => this.toAccountInfo(body)),
63-
catchError((error) => throwError(this.errorHandling(error))),
64-
);
60+
return this.call(this.accountRoutesApi.getAccountInfo(address.plain()), (body) => this.toAccountInfo(body));
6561
}
62+
6663
/**
6764
* Gets AccountsInfo for different accounts.
6865
* @param addresses List of Address
6966
* @returns Observable<AccountInfo[]>
7067
*/
7168
public getAccountsInfo(addresses: Address[]): Observable<AccountInfo[]> {
72-
const accountIdsBody = {
73-
addresses: addresses.map((address) => address.plain()),
74-
};
75-
return observableFrom(
76-
this.accountRoutesApi.getAccountsInfo(accountIdsBody)).pipe(
77-
map(({body}) => body.map(this.toAccountInfo)),
78-
catchError((error) => throwError(this.errorHandling(error))),
79-
);
69+
const accountIds = new AccountIds();
70+
accountIds.addresses = addresses.map((address) => address.plain());
71+
return this.call(this.accountRoutesApi.getAccountsInfo(accountIds), (body) => body.map(this.toAccountInfo));
8072
}
8173

8274
/**
@@ -122,17 +114,13 @@ export class AccountHttp extends Http implements AccountRepository {
122114
public getAccountTransactions(address: Address,
123115
queryParams?: QueryParams,
124116
transactionFilter?: TransactionFilter): Observable<Transaction[]> {
125-
return observableFrom(
126-
this.accountRoutesApi.getAccountConfirmedTransactions(address.plain(),
127-
this.queryParams(queryParams).pageSize,
128-
this.queryParams(queryParams).id,
129-
this.queryParams(queryParams).ordering,
130-
this.transactionFilter(transactionFilter).type)).pipe(
131-
map(({body}) => body.map((transactionDTO) => {
132-
return CreateTransactionFromDTO(transactionDTO);
133-
})),
134-
catchError((error) => throwError(this.errorHandling(error))),
135-
);
117+
118+
return this.call(this.accountRoutesApi.getAccountConfirmedTransactions(address.plain(),
119+
this.queryParams(queryParams).pageSize,
120+
this.queryParams(queryParams).id,
121+
this.queryParams(queryParams).ordering,
122+
this.transactionFilter(transactionFilter).type),
123+
(body) => body.map((transactionDTO) => CreateTransactionFromDTO(transactionDTO)));
136124
}
137125

138126
/**
@@ -145,18 +133,13 @@ export class AccountHttp extends Http implements AccountRepository {
145133
*/
146134
public getAccountIncomingTransactions(address: Address,
147135
queryParams?: QueryParams,
148-
transactionFilter?: TransactionFilter): Observable <Transaction[]> {
149-
return observableFrom(
150-
this.accountRoutesApi.getAccountIncomingTransactions(address.plain(),
151-
this.queryParams(queryParams).pageSize,
152-
this.queryParams(queryParams).id,
153-
this.queryParams(queryParams).ordering),
154-
this.transactionFilter(transactionFilter).type).pipe(
155-
map(({body}) => body.map((transactionDTO) => {
156-
return CreateTransactionFromDTO(transactionDTO);
157-
})),
158-
catchError((error) => throwError(this.errorHandling(error))),
159-
);
136+
transactionFilter?: TransactionFilter): Observable<Transaction[]> {
137+
return this.call(this.accountRoutesApi.getAccountIncomingTransactions(address.plain(),
138+
this.queryParams(queryParams).pageSize,
139+
this.queryParams(queryParams).id,
140+
this.queryParams(queryParams).ordering,
141+
this.transactionFilter(transactionFilter).type),
142+
(body) => body.map((transactionDTO) => CreateTransactionFromDTO(transactionDTO)));
160143
}
161144

162145
/**
@@ -169,18 +152,13 @@ export class AccountHttp extends Http implements AccountRepository {
169152
*/
170153
public getAccountOutgoingTransactions(address: Address,
171154
queryParams?: QueryParams,
172-
transactionFilter?: TransactionFilter): Observable <Transaction[]> {
173-
return observableFrom(
174-
this.accountRoutesApi.getAccountOutgoingTransactions(address.plain(),
175-
this.queryParams(queryParams).pageSize,
176-
this.queryParams(queryParams).id,
177-
this.queryParams(queryParams).ordering),
178-
this.transactionFilter(transactionFilter).type).pipe(
179-
map(({body}) => body.map((transactionDTO) => {
180-
return CreateTransactionFromDTO(transactionDTO);
181-
})),
182-
catchError((error) => throwError(this.errorHandling(error))),
183-
);
155+
transactionFilter?: TransactionFilter): Observable<Transaction[]> {
156+
return this.call(this.accountRoutesApi.getAccountOutgoingTransactions(address.plain(),
157+
this.queryParams(queryParams).pageSize,
158+
this.queryParams(queryParams).id,
159+
this.queryParams(queryParams).ordering,
160+
this.transactionFilter(transactionFilter).type),
161+
(body) => body.map((transactionDTO) => CreateTransactionFromDTO(transactionDTO)));
184162
}
185163

186164
/**
@@ -194,18 +172,13 @@ export class AccountHttp extends Http implements AccountRepository {
194172
*/
195173
public getAccountUnconfirmedTransactions(address: Address,
196174
queryParams?: QueryParams,
197-
transactionFilter?: TransactionFilter): Observable <Transaction[]> {
198-
return observableFrom(
199-
this.accountRoutesApi.getAccountUnconfirmedTransactions(address.plain(),
200-
this.queryParams(queryParams).pageSize,
201-
this.queryParams(queryParams).id,
202-
this.queryParams(queryParams).ordering),
203-
this.transactionFilter(transactionFilter).type).pipe(
204-
map(({body}) => body.map((transactionDTO) => {
205-
return CreateTransactionFromDTO(transactionDTO);
206-
})),
207-
catchError((error) => throwError(this.errorHandling(error))),
208-
);
175+
transactionFilter?: TransactionFilter): Observable<Transaction[]> {
176+
return this.call(this.accountRoutesApi.getAccountUnconfirmedTransactions(address.plain(),
177+
this.queryParams(queryParams).pageSize,
178+
this.queryParams(queryParams).id,
179+
this.queryParams(queryParams).ordering,
180+
this.transactionFilter(transactionFilter).type),
181+
(body) => body.map((transactionDTO) => CreateTransactionFromDTO(transactionDTO)));
209182
}
210183

211184
/**
@@ -218,17 +191,12 @@ export class AccountHttp extends Http implements AccountRepository {
218191
*/
219192
public getAccountPartialTransactions(address: Address,
220193
queryParams?: QueryParams,
221-
transactionFilter?: TransactionFilter): Observable <AggregateTransaction[]> {
222-
return observableFrom(
223-
this.accountRoutesApi.getAccountPartialTransactions(address.plain(),
224-
this.queryParams(queryParams).pageSize,
225-
this.queryParams(queryParams).id,
226-
this.queryParams(queryParams).ordering),
227-
this.transactionFilter(transactionFilter).type).pipe(
228-
map(({body}) => body.map((transactionDTO) => {
229-
return CreateTransactionFromDTO(transactionDTO) as AggregateTransaction;
230-
})),
231-
catchError((error) => throwError(this.errorHandling(error))),
232-
);
194+
transactionFilter?: TransactionFilter): Observable<AggregateTransaction[]> {
195+
return this.call(this.accountRoutesApi.getAccountPartialTransactions(address.plain(),
196+
this.queryParams(queryParams).pageSize,
197+
this.queryParams(queryParams).id,
198+
this.queryParams(queryParams).ordering,
199+
this.transactionFilter(transactionFilter).type),
200+
(body) => body.map((transactionDTO) => CreateTransactionFromDTO(transactionDTO) as AggregateTransaction));
233201
}
234202
}

src/infrastructure/Http.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export abstract class Http {
7979
if (error.code && error.address && error.code === 'ECONNREFUSED') {
8080
return new Error(`Cannot reach node: ${error.address}:${error.port}`);
8181
}
82+
if (error instanceof Error) {
83+
return error;
84+
}
8285
return new Error(error);
8386
}
8487

0 commit comments

Comments
 (0)