Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 238250f

Browse files
authored
refactor: core v3 upgrades (#705)
1 parent a9455cd commit 238250f

File tree

12 files changed

+137
-55
lines changed

12 files changed

+137
-55
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,3 @@ jobs:
2929
run: npm run build -- --prod
3030
- name: Codecov
3131
run: ./node_modules/.bin/codecov --token=${{ secrets.CODECOV_TOKEN }}
32-
33-
e2e:
34-
runs-on: ubuntu-latest
35-
36-
strategy:
37-
matrix:
38-
node-version: [12.x]
39-
40-
steps:
41-
- uses: actions/checkout@v1
42-
- name: Use Node.js ${{ matrix.node-version }}
43-
uses: actions/setup-node@v1
44-
with:
45-
node-version: ${{ matrix.node-version }}
46-
- name: Install
47-
run: npm install --ignore-scripts
48-
- name: Pre Test
49-
run: npx webdriver-manager update --versions.chrome=85.0.4183.83
50-
- name: Test
51-
run: npm run test:e2e -- --prod --webdriver-update false

config.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version='1.0' encoding='utf-8'?>
2-
<widget id="io.ark.wallet.mobile" version="1.8.6" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget id="io.ark.wallet.mobile" version="1.9.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
33
<name>Ark Mobile</name>
44
<description>ARK</description>
55
<author email="mobile@ark.io" href="http://ark.io/">Ark Ecosystem</author>
@@ -30,6 +30,8 @@
3030
<preference name="Orientation" value="portrait" />
3131
<preference name="target-device" value="handset" />
3232
<preference name="DisableDeploy" value="true" />
33+
<preference name="WKWebViewOnly" value="true" />
34+
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
3335
<platform name="android">
3436
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
3537
<application android:networkSecurityConfig="@xml/network_security_config" />
@@ -114,6 +116,7 @@
114116
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
115117
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
116118
</platform>
119+
<plugin name="cordova-plugin-advanced-http" spec="^3.2.0" />
117120
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
118121
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
119122
<plugin name="cordova-plugin-device" spec="2.0.2" />

package-lock.json

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ark-mobile",
3-
"version": "1.8.6",
3+
"version": "1.9.2",
44
"author": "Ark Ecosystem <mobile@ark.io>",
55
"homepage": "https://github.com/ArkEcosystem/mobile-wallet#readme",
66
"scripts": {
@@ -36,6 +36,7 @@
3636
"@ionic-native/background-mode": "^5.22.0",
3737
"@ionic-native/clipboard": "^5.22.0",
3838
"@ionic-native/core": "^5.22.0",
39+
"@ionic-native/http": "^5.36.0",
3940
"@ionic-native/in-app-browser": "^5.22.0",
4041
"@ionic-native/keyboard": "^5.22.0",
4142
"@ionic-native/local-notifications": "^5.22.0",
@@ -63,6 +64,7 @@
6364
"cordova-custom-config": "^5.1.0",
6465
"cordova-ios": "5.1.1",
6566
"cordova-plugin-add-swift-support": "^2.0.2",
67+
"cordova-plugin-advanced-http": "^3.2.1",
6668
"cordova-plugin-device": "^2.0.3",
6769
"cordova-plugin-inappbrowser": "^3.2.0",
6870
"cordova-plugin-ionic": "^5.4.6",
@@ -170,6 +172,9 @@
170172
"cordova-plugin-ionic-webview": {
171173
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
172174
},
175+
"cordova-plugin-advanced-http": {
176+
"ANDROIDBLACKLISTSECURESOCKETPROTOCOLS": "SSLv3,TLSv1"
177+
},
173178
"cordova-plugin-ionic-keyboard": {},
174179
"cordova-plugin-ionic": {
175180
"APP_ID": "efb289f2",

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ErrorHandler, NgModule } from "@angular/core";
33
import { BrowserModule, HammerModule } from "@angular/platform-browser";
44
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
55
import { RouteReuseStrategy } from "@angular/router";
6+
import { HTTP } from "@ionic-native/http/ngx";
67
import { Keyboard } from "@ionic-native/keyboard/ngx";
78
import { Network } from "@ionic-native/network/ngx";
89
import { QRScanner } from "@ionic-native/qr-scanner/ngx";
@@ -54,6 +55,7 @@ export function createTranslateLoader(http: HttpClient) {
5455
Network,
5556
ScreenOrientation,
5657
GlobalErrorHandlerService,
58+
HTTP,
5759
{ provide: UserDataService, useClass: UserDataServiceImpl },
5860
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
5961
{ provide: ErrorHandler, useClass: GlobalErrorHandlerService },

src/app/modals/custom-network-create/custom-network-create.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { HttpClient } from "@angular/common/http";
21
import { Component } from "@angular/core";
32
import { LoadingController, ModalController } from "@ionic/angular";
43
import { Network, Peer } from "ark-ts";
5-
import lodash from "lodash";
64
import { finalize } from "rxjs/operators";
75

86
import { LoggerService } from "@/services/logger/logger.service";
97
import { ToastProvider } from "@/services/toast/toast";
108
import ArkClient from "@/utils/ark-client";
9+
import { HttpClient } from "@/utils/ark-http-client";
1110

1211
@Component({
1312
selector: "customNetworkCreate",
@@ -50,19 +49,15 @@ export class CustomNetworkCreateModal {
5049
this.network.version = response.version;
5150
this.network.type = null;
5251

53-
const apiConfig: any = lodash.find(
54-
response.ports,
55-
(_, key) => key.split("/").reverse()[0] === "core-api",
56-
);
57-
if (!response.ports || !apiConfig) {
52+
if (!response.ports || !seedServerUrl.port) {
5853
this.configureError();
5954
return;
6055
}
61-
this.network.apiPort = apiConfig;
56+
this.network.apiPort = parseInt(seedServerUrl.port);
6257

6358
this.network.activePeer = new Peer();
6459
this.network.activePeer.ip = seedServerUrl.hostname;
65-
this.network.activePeer.port = apiConfig;
60+
this.network.activePeer.port = parseInt(seedServerUrl.port);
6661

6762
if (seedServerUrl.protocol === "https:") {
6863
this.network.activePeer.port = 443;

src/app/models/market.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ export class MarketHistory {
221221
getPriceByDate(currencyCode: string, date: Date): number {
222222
const timestampDate = date.setHours(0, 0, 0, 0);
223223

224-
return this.history[currencyCode.toUpperCase()][timestampDate];
224+
if (this.history[currencyCode.toUpperCase()]) {
225+
return this.history[currencyCode.toUpperCase()][timestampDate];
226+
}
227+
228+
return 0;
225229
}
226230

227231
getLastWeekPrice(currencyCode: string): any {

src/app/services/ark-api/ark-api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { HttpClient } from "@angular/common/http";
21
import { Injectable } from "@angular/core";
32
import * as ArkCrypto from "@arkecosystem/crypto";
43
import * as arkts from "ark-ts";
@@ -25,11 +24,12 @@ import { FeeStatistic, StoredNetwork } from "@/models/stored-network";
2524
import { StorageProvider } from "@/services/storage/storage";
2625
import { ToastProvider } from "@/services/toast/toast";
2726
import { UserDataService } from "@/services/user-data/user-data.interface";
27+
import ArkClient, { WalletResponse } from "@/utils/ark-client";
28+
import { HttpClient } from "@/utils/ark-http-client";
2829
import { PeerDiscovery } from "@/utils/ark-peer-discovery";
30+
import { ArkUtility } from "@/utils/ark-utility";
2931
import { SafeBigNumber as BigNumber } from "@/utils/bignumber";
3032

31-
import ArkClient, { WalletResponse } from "../../utils/ark-client";
32-
import { ArkUtility } from "../../utils/ark-utility";
3333
import { LoggerService } from "../logger/logger.service";
3434

3535
interface NodeFees {
@@ -574,7 +574,7 @@ export class ArkApiProvider {
574574

575575
return new Observable((observer) => {
576576
this.httpClient
577-
.get(`${this._network.getPeerAPIUrl()}/api/v2/node/fees?days=7`)
577+
.get(`${this._network.getPeerAPIUrl()}/api/node/fees?days=7`)
578578
.subscribe(
579579
(response: NodeFeesResponse) => {
580580
const data = response.data;

src/app/services/neo-api/neo-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { HttpClient } from "@angular/common/http";
21
import { Injectable } from "@angular/core";
32
import { Observable, of } from "rxjs";
43
import { map } from "rxjs/operators";
54

65
import { NetworkProvider } from "@/services/network/network";
6+
import { HttpClient } from "@/utils/ark-http-client";
77

88
@Injectable({ providedIn: "root" })
99
export class NeoApiProvider {

src/app/utils/ark-client.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { HttpClient } from "@angular/common/http";
21
import {
32
AccountResponse,
43
AccountVotesResponse,
@@ -17,6 +16,7 @@ import { tap, timeout } from "rxjs/operators";
1716
import { TRANSACTION_GROUPS } from "@/app/app.constants";
1817
import { INodeConfiguration } from "@/models/node";
1918
import { LoggerService } from "@/services/logger/logger.service";
19+
import { HttpClient } from "@/utils/ark-http-client";
2020

2121
export interface PeerApiResponse extends Peer {
2222
latency?: number;
@@ -70,7 +70,8 @@ export default class ApiClient {
7070
const data = response.data;
7171

7272
if (data.length) {
73-
const lastVote = data[0].asset.votes[0];
73+
const lastVote =
74+
data[0].asset.votes[data[0].asset.votes.length - 1];
7475

7576
if (lastVote.charAt(0) === "-") {
7677
observer.next({
@@ -80,9 +81,7 @@ export default class ApiClient {
8081
observer.complete();
8182
}
8283

83-
const delegatePublicKey = data[0].asset.votes[0].substring(
84-
1,
85-
);
84+
const delegatePublicKey = lastVote.substring(1);
8685
this.getDelegateByPublicKey(
8786
delegatePublicKey,
8887
).subscribe(
@@ -284,7 +283,24 @@ export default class ApiClient {
284283
observer.next(this.__formatDelegateResponse(data));
285284
observer.complete();
286285
},
287-
(error) => observer.error(error),
286+
(error) => {
287+
const response =
288+
typeof error.error === "string"
289+
? JSON.parse(error.error)
290+
: error.error;
291+
if (
292+
response &&
293+
error.status === 404 &&
294+
response.message === "Delegate not found"
295+
) {
296+
observer.next(null);
297+
observer.complete();
298+
299+
return;
300+
}
301+
302+
observer.error(error);
303+
},
288304
);
289305
});
290306
}
@@ -322,7 +338,7 @@ export default class ApiClient {
322338
) {
323339
const url = `${host}/api/${path}`;
324340
return this.httpClient
325-
.request("GET", url, {
341+
.get(url, {
326342
...options,
327343
headers: this.defaultHeaders,
328344
})

0 commit comments

Comments
 (0)