From 4e9c9f54518fe13318c76fe2c1fdfead354d1e24 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 8 Feb 2018 17:47:59 -0500 Subject: [PATCH 1/9] added rudimentary blockchain switcher --- app/src/assets/img/currency_logos/bch.svg | 14 +++++++ app/src/assets/img/currency_logos/btc.svg | 15 ++++++++ app/src/assets/img/currency_logos/ltc.svg | 16 ++++++++ .../components/denomination/denomination.html | 15 +++++++- .../components/denomination/denomination.ts | 29 +++++++++++++-- app/src/components/head-nav/head-nav.ts | 37 ------------------- 6 files changed, 84 insertions(+), 42 deletions(-) create mode 100644 app/src/assets/img/currency_logos/bch.svg create mode 100644 app/src/assets/img/currency_logos/btc.svg create mode 100644 app/src/assets/img/currency_logos/ltc.svg diff --git a/app/src/assets/img/currency_logos/bch.svg b/app/src/assets/img/currency_logos/bch.svg new file mode 100644 index 000000000..95a028243 --- /dev/null +++ b/app/src/assets/img/currency_logos/bch.svg @@ -0,0 +1,14 @@ + + + + cash + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/app/src/assets/img/currency_logos/btc.svg b/app/src/assets/img/currency_logos/btc.svg new file mode 100644 index 000000000..a421df204 --- /dev/null +++ b/app/src/assets/img/currency_logos/btc.svg @@ -0,0 +1,15 @@ + + + + bitcoin + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/app/src/assets/img/currency_logos/ltc.svg b/app/src/assets/img/currency_logos/ltc.svg new file mode 100644 index 000000000..d7afa3fac --- /dev/null +++ b/app/src/assets/img/currency_logos/ltc.svg @@ -0,0 +1,16 @@ + + + + litecoin + Created with Sketch. + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/components/denomination/denomination.html b/app/src/components/denomination/denomination.html index 65c736b07..ab0aefb6e 100644 --- a/app/src/components/denomination/denomination.html +++ b/app/src/components/denomination/denomination.html @@ -1,10 +1,21 @@ - + + + Blockchain + + + + + + + + Units {{ unit }} - + diff --git a/app/src/components/denomination/denomination.ts b/app/src/components/denomination/denomination.ts index b484472c3..e683b1cdb 100644 --- a/app/src/components/denomination/denomination.ts +++ b/app/src/components/denomination/denomination.ts @@ -9,17 +9,33 @@ import { ViewController } from 'ionic-angular'; export class DenominationComponent { public text: string; + public switcherOn: boolean; + public currencies: any = []; public units: any = []; constructor( - public currency: CurrencyProvider, + public currencyProvider: CurrencyProvider, public viewCtrl: ViewController ) { this.text = 'Hello World'; + this.switcherOn = true; + this.currencies = [ + { + name: 'Bitcoin', + ticker: 'BTC', + url: 'https://insight.bitpay.com' + }, + { + name: 'Bitcoin Cash', + ticker: 'BCH', + url: 'https://bch-insight.bitpay.com' + } + ]; + this.units = [ 'USD', - this.currency.defaultCurrency, - 'm' + this.currency.defaultCurrency, + this.currencyProvider.defaultCurrency, + 'm' + this.currencyProvider.defaultCurrency, 'bits' ]; } @@ -28,4 +44,11 @@ export class DenominationComponent { this.viewCtrl.dismiss(); } + public changeCurrency(currency: any): void { + console.log('selected currency is', currency.name, currency.ticker); + this.close(); + let theUrl: string = currency.url; + console.log('theUrl is', theUrl); + window.location.href = theUrl; + } } diff --git a/app/src/components/head-nav/head-nav.ts b/app/src/components/head-nav/head-nav.ts index 1ccf83d96..dfdf99804 100644 --- a/app/src/components/head-nav/head-nav.ts +++ b/app/src/components/head-nav/head-nav.ts @@ -112,43 +112,6 @@ export class HeadNavComponent { /* tslint:enable:no-unused-variable */ public changeCurrency(myEvent: any): void { - /* - let actionSheet: any = this.actionSheetCtrl.create({ - title: 'Change Denomination', - buttons: [ - { - text: 'USD', - handler: () => { - this.currency.setCurrency('USD'); - } - }, - { - text: this.currency.defaultCurrency, - handler: () => { - this.currency.setCurrency(this.currency.defaultCurrency); - } - }, - { - text: 'm' + this.currency.defaultCurrency, - handler: () => { - this.currency.setCurrency('m' + this.currency.defaultCurrency); - } - }, - { - text: 'bits', - handler: () => { - this.currency.setCurrency('bits'); - } - }, - { - text: 'Cancel', - role: 'cancel' - } - ] - }); - actionSheet.present(); - */ - let popover: any = this.popoverCtrl.create(DenominationComponent); popover.present({ ev: myEvent From d5b3705389ab3c683f8c19a2b3d8582e1528a21b Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Mon, 12 Feb 2018 11:17:56 -0500 Subject: [PATCH 2/9] added call to explorers api for explorer switcher --- .../components/denomination/denomination.html | 6 +++--- .../components/denomination/denomination.ts | 19 ++----------------- app/src/providers/currency/currency.ts | 12 ++++++++++++ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/app/src/components/denomination/denomination.html b/app/src/components/denomination/denomination.html index ab0aefb6e..95b29fac1 100644 --- a/app/src/components/denomination/denomination.html +++ b/app/src/components/denomination/denomination.html @@ -4,9 +4,9 @@ - - + + diff --git a/app/src/components/denomination/denomination.ts b/app/src/components/denomination/denomination.ts index e683b1cdb..3d2de7706 100644 --- a/app/src/components/denomination/denomination.ts +++ b/app/src/components/denomination/denomination.ts @@ -10,7 +10,6 @@ export class DenominationComponent { public text: string; public switcherOn: boolean; - public currencies: any = []; public units: any = []; constructor( @@ -19,18 +18,6 @@ export class DenominationComponent { ) { this.text = 'Hello World'; this.switcherOn = true; - this.currencies = [ - { - name: 'Bitcoin', - ticker: 'BTC', - url: 'https://insight.bitpay.com' - }, - { - name: 'Bitcoin Cash', - ticker: 'BCH', - url: 'https://bch-insight.bitpay.com' - } - ]; this.units = [ 'USD', @@ -44,11 +31,9 @@ export class DenominationComponent { this.viewCtrl.dismiss(); } - public changeCurrency(currency: any): void { - console.log('selected currency is', currency.name, currency.ticker); + public changeExplorer(explorer: any): void { this.close(); - let theUrl: string = currency.url; - console.log('theUrl is', theUrl); + let theUrl: string = explorer.url; window.location.href = theUrl; } } diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts index 19062a2bf..b1624e869 100644 --- a/app/src/providers/currency/currency.ts +++ b/app/src/providers/currency/currency.ts @@ -18,10 +18,22 @@ export class CurrencyProvider { private bitstamp: number; private kraken: number; private loading: boolean; + private explorers: any = []; constructor(public http: Http, private api: ApiProvider) { this.defaultCurrency = 'BCH'; this.currencySymbol = this.defaultCurrency; + + this.http.get(this.api.apiPrefix + 'explorers').subscribe( + (data) => { + this.explorers = JSON.parse(data['_body']); + this.loading = false; + }, + (err) => { + console.log('err is', err); + this.loading = false; + } + ); } public roundFloat(aFloat: number, decimalPlaces: number): number { From 82d5641468884a839556f1ed3f28f8d102876451 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 16 Mar 2018 16:23:33 -0400 Subject: [PATCH 3/9] moved call to explorers --- app/package.json | 2 +- .../components/denomination/denomination.ts | 22 +++++++++++++++---- app/src/providers/api/api.ts | 4 +++- app/src/providers/currency/currency.ts | 15 +------------ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/package.json b/app/package.json index b65e0b3ab..7cbe5dacf 100644 --- a/app/package.json +++ b/app/package.json @@ -67,4 +67,4 @@ "node": ">=8" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/app/src/components/denomination/denomination.ts b/app/src/components/denomination/denomination.ts index 3d2de7706..0cf6093bd 100644 --- a/app/src/components/denomination/denomination.ts +++ b/app/src/components/denomination/denomination.ts @@ -1,6 +1,8 @@ import { Component } from '@angular/core'; import { CurrencyProvider } from '../../providers/currency/currency'; import { ViewController } from 'ionic-angular'; +import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; @Component({ selector: 'denomination', @@ -8,16 +10,28 @@ import { ViewController } from 'ionic-angular'; }) export class DenominationComponent { - public text: string; public switcherOn: boolean; + private explorers: any = []; public units: any = []; constructor( public currencyProvider: CurrencyProvider, - public viewCtrl: ViewController + public viewCtrl: ViewController, + public http: Http, + public api: ApiProvider ) { - this.text = 'Hello World'; - this.switcherOn = true; + + let url: string = this.api.apiPrefix + 'explorers'; + this.http.get(url).subscribe( + (data) => { + this.explorers = JSON.parse(data['_body']); + this.switcherOn = true; + }, + (err) => { + this.switcherOn = false; + console.error('err', err); + } + ); this.units = [ 'USD', diff --git a/app/src/providers/api/api.ts b/app/src/providers/api/api.ts index 1a2b9a817..54083c09c 100644 --- a/app/src/providers/api/api.ts +++ b/app/src/providers/api/api.ts @@ -11,9 +11,11 @@ import 'rxjs/add/operator/map'; @Injectable() export class ApiProvider { - public apiPrefix: string = '/insight-api/'; + public apiPrefix: string; constructor(public http: Http) { + // TODO Make this an API call + this.apiPrefix = '/insight-api/'; } } diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts index 5549d62f6..4ff25051e 100644 --- a/app/src/providers/currency/currency.ts +++ b/app/src/providers/currency/currency.ts @@ -17,23 +17,12 @@ export class CurrencyProvider { public factor: number = 1; private bitstamp: number; private kraken: number; - private loading: boolean; - private explorers: any = []; constructor(public http: Http, private api: ApiProvider) { + // TODO Make this an API call this.defaultCurrency = 'BTC'; this.currencySymbol = this.defaultCurrency; - this.http.get(this.api.apiPrefix + 'explorers').subscribe( - (data) => { - this.explorers = JSON.parse(data['_body']); - this.loading = false; - }, - (err) => { - console.log('err is', err); - this.loading = false; - } - ); } public roundFloat(aFloat: number, decimalPlaces: number): number { @@ -98,11 +87,9 @@ export class CurrencyProvider { } else if (currencyParsed.data.kraken) { this.factor = this.kraken = currencyParsed.data.kraken; } - this.loading = false; }, (err) => { console.log('err is', err); - this.loading = false; } ); } else if (currency === 'm' + this.defaultCurrency) { From a345269a8d3baaa9986a26f1360e36762b4acba1 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 16 Mar 2018 17:54:35 -0400 Subject: [PATCH 4/9] put loading flag back in; readded click on denomination selection --- app/package.json | 2 +- app/src/components/denomination/denomination.html | 2 +- app/src/providers/currency/currency.ts | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/package.json b/app/package.json index 7cbe5dacf..b65e0b3ab 100644 --- a/app/package.json +++ b/app/package.json @@ -67,4 +67,4 @@ "node": ">=8" }, "license": "MIT" -} \ No newline at end of file +} diff --git a/app/src/components/denomination/denomination.html b/app/src/components/denomination/denomination.html index 95b29fac1..b3f0a8f0d 100644 --- a/app/src/components/denomination/denomination.html +++ b/app/src/components/denomination/denomination.html @@ -16,6 +16,6 @@ {{ unit }} - + diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts index 4ff25051e..e0f468066 100644 --- a/app/src/providers/currency/currency.ts +++ b/app/src/providers/currency/currency.ts @@ -17,12 +17,12 @@ export class CurrencyProvider { public factor: number = 1; private bitstamp: number; private kraken: number; + private loading: boolean; constructor(public http: Http, private api: ApiProvider) { // TODO Make this an API call this.defaultCurrency = 'BTC'; this.currencySymbol = this.defaultCurrency; - } public roundFloat(aFloat: number, decimalPlaces: number): number { @@ -87,9 +87,11 @@ export class CurrencyProvider { } else if (currencyParsed.data.kraken) { this.factor = this.kraken = currencyParsed.data.kraken; } + this.loading = false; }, (err) => { - console.log('err is', err); + this.loading = false; + console.error('err getting currency', err); } ); } else if (currency === 'm' + this.defaultCurrency) { From 87b8319bf39a69e52df926f05fdb416308502b25 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Tue, 20 Mar 2018 11:51:34 -0400 Subject: [PATCH 5/9] moved explorers call back into currency provider so that explorers data is available when denomination component is instantiated --- app/package.json | 2 +- app/src/components/denomination/denomination.ts | 16 ++-------------- app/src/providers/api/api.ts | 2 +- app/src/providers/currency/currency.ts | 13 +++++++++++++ package-lock.json | 2 +- package.json | 3 ++- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/package.json b/app/package.json index b65e0b3ab..7cbe5dacf 100644 --- a/app/package.json +++ b/app/package.json @@ -67,4 +67,4 @@ "node": ">=8" }, "license": "MIT" -} +} \ No newline at end of file diff --git a/app/src/components/denomination/denomination.ts b/app/src/components/denomination/denomination.ts index 0cf6093bd..43330920e 100644 --- a/app/src/components/denomination/denomination.ts +++ b/app/src/components/denomination/denomination.ts @@ -11,7 +11,6 @@ import { ApiProvider } from '../../providers/api/api'; export class DenominationComponent { public switcherOn: boolean; - private explorers: any = []; public units: any = []; constructor( @@ -20,25 +19,14 @@ export class DenominationComponent { public http: Http, public api: ApiProvider ) { - - let url: string = this.api.apiPrefix + 'explorers'; - this.http.get(url).subscribe( - (data) => { - this.explorers = JSON.parse(data['_body']); - this.switcherOn = true; - }, - (err) => { - this.switcherOn = false; - console.error('err', err); - } - ); - this.units = [ 'USD', this.currencyProvider.defaultCurrency, 'm' + this.currencyProvider.defaultCurrency, 'bits' ]; + + this.switcherOn = currencyProvider.explorers.length > 1; } public close(): void { diff --git a/app/src/providers/api/api.ts b/app/src/providers/api/api.ts index 54083c09c..a76ccd6e7 100644 --- a/app/src/providers/api/api.ts +++ b/app/src/providers/api/api.ts @@ -15,7 +15,7 @@ export class ApiProvider { constructor(public http: Http) { // TODO Make this an API call - this.apiPrefix = '/insight-api/'; + this.apiPrefix = '/api/'; } } diff --git a/app/src/providers/currency/currency.ts b/app/src/providers/currency/currency.ts index e0f468066..452fd1071 100644 --- a/app/src/providers/currency/currency.ts +++ b/app/src/providers/currency/currency.ts @@ -18,11 +18,24 @@ export class CurrencyProvider { private bitstamp: number; private kraken: number; private loading: boolean; + public explorers: any = []; constructor(public http: Http, private api: ApiProvider) { // TODO Make this an API call this.defaultCurrency = 'BTC'; this.currencySymbol = this.defaultCurrency; + + let url: string = this.api.apiPrefix + 'explorers'; + console.log('exploers url is', url); + this.http.get(url).subscribe( + (data) => { + console.log('', data); + this.explorers = JSON.parse(data['_body']); + }, + (err) => { + console.error('err', err); + } + ); } public roundFloat(aFloat: number, decimalPlaces: number): number { diff --git a/package-lock.json b/package-lock.json index 6e10a71e7..cff44db41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "insight", + "name": "insight-ui", "version": "1.0.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index 00c175d74..dfd3e2376 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "insight", + "name": "insight-ui", "description": "A bitcoin block explorer and API.", "version": "1.0.0", "repository": "git://github.com/bitpay/insight.git", @@ -10,6 +10,7 @@ "license": "MIT", "keywords": [ "insight", + "insight-ui", "blockchain", "block explorer", "bitcoin", From 055a76e7ba11b0d4989297aa676af11b6486d02b Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Thu, 22 Mar 2018 16:55:32 -0400 Subject: [PATCH 6/9] Added cli generated broadcast-tx page --- app/package-lock.json | 118 ++++++------------ app/package.json | 2 +- app/src/app/app.module.ts | 3 +- app/src/pages/broadcast-tx/broadcast-tx.html | 33 +++++ .../pages/broadcast-tx/broadcast-tx.module.ts | 16 +++ app/src/pages/broadcast-tx/broadcast-tx.scss | 3 + app/src/pages/broadcast-tx/broadcast-tx.ts | 63 ++++++++++ app/src/pages/index.ts | 2 +- app/src/pages/pages.module.ts | 4 +- 9 files changed, 160 insertions(+), 84 deletions(-) create mode 100644 app/src/pages/broadcast-tx/broadcast-tx.html create mode 100644 app/src/pages/broadcast-tx/broadcast-tx.module.ts create mode 100644 app/src/pages/broadcast-tx/broadcast-tx.scss create mode 100644 app/src/pages/broadcast-tx/broadcast-tx.ts diff --git a/app/package-lock.json b/app/package-lock.json index 922d88949..345b80e67 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -663,9 +663,9 @@ } }, "@ionic/cli-framework": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@ionic/cli-framework/-/cli-framework-0.1.2.tgz", - "integrity": "sha512-EEqcpkO7/uo4wt6d2cZHhWjO0yyD6HkEGsrl0ETbfUVJLR0NU3vDi9VvFM8K0NzHOaaHxCKzux+Y3+oJ7utZjA==", + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@ionic/cli-framework/-/cli-framework-0.1.3.tgz", + "integrity": "sha512-by5vosr5MXK5+yJMtRmBX9YjrcHTeelVLV5PsDv56zZR0aDMLP+1st5wvjKwAjlva660bIzx7yIax88hiV5KKA==", "dev": true, "requires": { "chalk": "2.3.2", @@ -744,19 +744,19 @@ } }, "@ionic/cli-utils": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/@ionic/cli-utils/-/cli-utils-1.19.1.tgz", - "integrity": "sha512-GUUn33FIaiN+hJTFnalZa67fcFN64lwupS/7+F1iUV/jPZNVzwpPWOWXs5a6hnuJuyNQvI6tm0Sm+P0HvGto1Q==", + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/@ionic/cli-utils/-/cli-utils-1.19.2.tgz", + "integrity": "sha512-nTbF273k1tcr6CPL5ARZ10VbXMNwRuW5svg42JFBEfxdbbVyvIUep+m4ibqBoDCRAFoDi28b4GeFkC5wyyDqQA==", "dev": true, "requires": { - "@ionic/cli-framework": "0.1.2", + "@ionic/cli-framework": "0.1.3", "@ionic/discover": "0.4.0", "archiver": "2.1.1", "basic-auth": "1.1.0", "body-parser": "1.18.2", "chalk": "2.3.2", "chokidar": "1.7.0", - "ci-info": "1.1.2", + "ci-info": "1.1.3", "cross-spawn": "5.1.0", "dargs": "5.1.0", "diff": "3.5.0", @@ -767,14 +767,14 @@ "leek": "0.0.24", "lodash": "4.17.4", "minimist": "1.2.0", - "opn": "5.2.0", + "opn": "5.3.0", "os-name": "2.0.1", "semver": "5.4.1", "slice-ansi": "1.0.0", "ssh-config": "1.1.3", "string-width": "2.1.1", "superagent": "3.8.2", - "tar": "4.4.0", + "tar": "4.4.1", "tiny-lr": "1.1.1", "tslib": "1.9.0", "untildify": "3.0.2", @@ -783,12 +783,6 @@ "ws": "3.3.3" }, "dependencies": { - "ansi-escapes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", - "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", - "dev": true - }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -822,12 +816,6 @@ "type-is": "1.6.15" } }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", - "dev": true - }, "chalk": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz", @@ -883,38 +871,10 @@ "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", "dev": true }, - "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "requires": { - "ansi-escapes": "3.0.0", - "chalk": "2.3.2", - "cli-cursor": "2.1.0", - "cli-width": "2.1.0", - "external-editor": "2.0.4", - "figures": "2.0.0", - "lodash": "4.17.4", - "mute-stream": "0.0.7", - "run-async": "2.3.0", - "rx-lite": "4.0.8", - "rx-lite-aggregates": "4.0.8", - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "through": "2.3.8" - } - }, - "livereload-js": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.3.0.tgz", - "integrity": "sha512-j1R0/FeGa64Y+NmqfZhyoVRzcFlOZ8sNlKzHjh4VvLULFACZhn68XrX5DFg2FhMvSMJmROuFxRSa560ECWKBMg==", - "dev": true - }, "opn": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-5.2.0.tgz", - "integrity": "sha512-Jd/GpzPyHF4P2/aNOVmS3lfMSWV9J7cOhCG1s08XCEAsPkB7lp6ddiU0J7XzyQRDUh8BqJ7PchfINjR8jyofRQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.3.0.tgz", + "integrity": "sha512-bYJHo/LOmoTd+pfiYhfZDnf9zekVJrY+cnS2a5F2x+w5ppvTqObojTP7WiFG+kVZs9Inw+qQ/lw7TroWwhdd2g==", "dev": true, "requires": { "is-wsl": "1.1.0" @@ -957,16 +917,17 @@ } }, "tar": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.0.tgz", - "integrity": "sha512-gJlTiiErwo96K904FnoYWl+5+FBgS+FimU6GMh66XLdLa55al8+d4jeDfPoGwSNHdtWI5FJP6xurmVqhBuGJpQ==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.1.tgz", + "integrity": "sha512-O+v1r9yN4tOsvl90p5HAP4AEqbYhx4036AGMm075fH9F8Qwi3oJ+v4u50FkT/KkvywNGtwkk0zRI+8eYm1X/xg==", "dev": true, "requires": { "chownr": "1.0.1", "fs-minipass": "1.2.5", - "minipass": "2.2.1", + "minipass": "2.2.4", "minizlib": "1.1.0", "mkdirp": "0.5.1", + "safe-buffer": "5.1.1", "yallist": "3.0.2" } }, @@ -2670,9 +2631,9 @@ "dev": true }, "ci-info": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.1.2.tgz", - "integrity": "sha512-uTGIPNx/nSpBdsF6xnseRXLLtfr9VLqkz8ZqHXr3Y7b6SftyRxBGjwMtJj1OhNbmlc1wZzLNAlAcvyIiE8a6ZA==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.1.3.tgz", + "integrity": "sha512-SK/846h/Rcy8q9Z9CAwGBLfCJ6EkjJWdpelWDufQpqVDYq2Wnnv8zlSO6AMQap02jvhVruKKpEtQOufo3pFhLg==", "dev": true }, "cipher-base": { @@ -4826,9 +4787,9 @@ } }, "formidable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.0.tgz", - "integrity": "sha512-hr9aT30rAi7kf8Q2aaTpSP7xGMhlJ+MdrUDVZs3rxbD3L/K46A86s2VY7qC2D2kGYGBtiT/3j6wTx1eeUq5xAQ==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz", + "integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg==", "dev": true }, "forwarded": { @@ -4877,7 +4838,7 @@ "integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", "dev": true, "requires": { - "minipass": "2.2.1" + "minipass": "2.2.4" } }, "fs-readdir-recursive": { @@ -6722,15 +6683,15 @@ "dev": true }, "ionic": { - "version": "3.19.1", - "resolved": "https://registry.npmjs.org/ionic/-/ionic-3.19.1.tgz", - "integrity": "sha512-U9flvol3qPaWGYkWouJGQJ3gzRflft5DmiOI8AKLjWMVhxU76O0VSZxKEdnfsNd02yGDcdwDPkhXh+LHobQLQw==", + "version": "3.20.0", + "resolved": "https://registry.npmjs.org/ionic/-/ionic-3.20.0.tgz", + "integrity": "sha512-yeLPusYOSyF+VmO+Hf2a5kf2Kx4ST1f3MILM8g+9ckF/MdaoD9UzXif2/sumGem6I6RTrqo9horBmC7QJYcClA==", "dev": true, "requires": { - "@ionic/cli-framework": "0.1.2", - "@ionic/cli-utils": "1.19.1", + "@ionic/cli-framework": "0.1.3", + "@ionic/cli-utils": "1.19.2", "chalk": "2.3.2", - "opn": "5.2.0", + "opn": "5.3.0", "semver": "5.4.1", "tslib": "1.9.0" }, @@ -6762,9 +6723,9 @@ "dev": true }, "opn": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-5.2.0.tgz", - "integrity": "sha512-Jd/GpzPyHF4P2/aNOVmS3lfMSWV9J7cOhCG1s08XCEAsPkB7lp6ddiU0J7XzyQRDUh8BqJ7PchfINjR8jyofRQ==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-5.3.0.tgz", + "integrity": "sha512-bYJHo/LOmoTd+pfiYhfZDnf9zekVJrY+cnS2a5F2x+w5ppvTqObojTP7WiFG+kVZs9Inw+qQ/lw7TroWwhdd2g==", "dev": true, "requires": { "is-wsl": "1.1.0" @@ -8487,11 +8448,12 @@ "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "minipass": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.1.tgz", - "integrity": "sha512-u1aUllxPJUI07cOqzR7reGmQxmCqlH88uIIsf6XZFEWgw7gXKpJdR+5R9Y3KEDmWYkdIz9wXZs3C0jOPxejk/Q==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", + "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, "requires": { + "safe-buffer": "5.1.1", "yallist": "3.0.2" }, "dependencies": { @@ -8509,7 +8471,7 @@ "integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", "dev": true, "requires": { - "minipass": "2.2.1" + "minipass": "2.2.4" } }, "mixin-deep": { @@ -12340,7 +12302,7 @@ "debug": "3.1.0", "extend": "3.0.1", "form-data": "2.3.2", - "formidable": "1.2.0", + "formidable": "1.2.1", "methods": "1.1.2", "mime": "1.6.0", "qs": "6.5.1", diff --git a/app/package.json b/app/package.json index 7cbe5dacf..10c8aadd0 100644 --- a/app/package.json +++ b/app/package.json @@ -46,7 +46,7 @@ "@types/jasmine": "2.5.41", "@types/node": "7.0.4", "codecov": "2.2.0", - "ionic": "3.19.1", + "ionic": "3.20.0", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "3.2.0", "karma": "1.4.1", diff --git a/app/src/app/app.module.ts b/app/src/app/app.module.ts index 7d0c3518a..f3b205084 100644 --- a/app/src/app/app.module.ts +++ b/app/src/app/app.module.ts @@ -5,7 +5,7 @@ import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import { InsightApp } from './app.component'; -import { PagesModule, HomePage, BlocksPage, BroadcastTxPage, NodeStatusPage, VerifyMessagePage } from '../pages'; +import { PagesModule, HomePage, BlocksPage, NodeStatusPage, VerifyMessagePage } from '../pages'; import { BlocksService, StorageService } from '../services'; import { ApiProvider } from '../providers/api/api'; import { CurrencyProvider } from '../providers/currency/currency'; @@ -26,7 +26,6 @@ import { BlocksProvider } from '../providers/blocks/blocks'; InsightApp, HomePage, BlocksPage, - BroadcastTxPage, NodeStatusPage, VerifyMessagePage ], diff --git a/app/src/pages/broadcast-tx/broadcast-tx.html b/app/src/pages/broadcast-tx/broadcast-tx.html new file mode 100644 index 000000000..005f5edba --- /dev/null +++ b/app/src/pages/broadcast-tx/broadcast-tx.html @@ -0,0 +1,33 @@ + + + + {{title}} + + + + +
+
+ + +

This form can be used to broadcast a raw transaction in hex format over the Bitcoin network.

+
+ + + Raw transaction data + + + + +

Raw transaction data must be a valid hexadecimal string.

+
+ + + + +
+
+
+
diff --git a/app/src/pages/broadcast-tx/broadcast-tx.module.ts b/app/src/pages/broadcast-tx/broadcast-tx.module.ts new file mode 100644 index 000000000..d330c98bb --- /dev/null +++ b/app/src/pages/broadcast-tx/broadcast-tx.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { IonicPageModule } from 'ionic-angular'; +import { BroadcastTxPage } from './broadcast-tx'; + +@NgModule({ + declarations: [ + BroadcastTxPage + ], + imports: [ + IonicPageModule.forChild(BroadcastTxPage) + ], + exports: [ + BroadcastTxPage + ] +}) +export class BroadcastTxPageModule {} diff --git a/app/src/pages/broadcast-tx/broadcast-tx.scss b/app/src/pages/broadcast-tx/broadcast-tx.scss new file mode 100644 index 000000000..4531e283f --- /dev/null +++ b/app/src/pages/broadcast-tx/broadcast-tx.scss @@ -0,0 +1,3 @@ +page-broadcast-tx { + +} diff --git a/app/src/pages/broadcast-tx/broadcast-tx.ts b/app/src/pages/broadcast-tx/broadcast-tx.ts new file mode 100644 index 000000000..984863f4e --- /dev/null +++ b/app/src/pages/broadcast-tx/broadcast-tx.ts @@ -0,0 +1,63 @@ +import { Component } from '@angular/core'; +import { IonicPage, NavController, NavParams } from 'ionic-angular'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { Http } from '@angular/http'; +import { ApiProvider } from '../../providers/api/api'; + +/** + * Generated class for the BroadcastTxPage page. + * + * See http://ionicframework.com/docs/components/#navigation for more info + * on Ionic pages and navigation. + */ +@IonicPage() +@Component({ + selector: 'page-broadcast-tx', + templateUrl: 'broadcast-tx.html' +}) +export class BroadcastTxPage { + + public title: string; + private nav: NavController; + public transaction: string; + public txForm: FormGroup; + private status: string; + // private txid: any; + + constructor(public navCtrl: NavController, public navParams: NavParams, public formBuilder: FormBuilder, private http: Http, private api: ApiProvider) { + this.nav = navCtrl; + this.title = 'Broadcast Transaction'; + this.txForm = formBuilder.group({ + rawData: ['', Validators.pattern(/^[0-9A-Fa-f]+$/)] + }); + } + + public ionViewDidLoad(): void { + console.log('ionViewDidLoad BroadcastTxPage'); + } + + public send(): void { + let postData: any = { + rawtx: this.transaction + }; + this.status = 'loading'; + + console.log('the postData is', postData); + + this.http.post(this.api.apiPrefix + 'tx/send', postData) + .subscribe( + response => console.log('response', response), + err => console.log('err', err) + ); + /* + .error(function(data, status, headers, config) { + $scope.status = 'error'; + if(data) { + $scope.error = data; + } else { + $scope.error = "No error message given (connection error?)" + } + }); + */ + } +} diff --git a/app/src/pages/index.ts b/app/src/pages/index.ts index 67a109d26..d15516e7d 100644 --- a/app/src/pages/index.ts +++ b/app/src/pages/index.ts @@ -1,6 +1,6 @@ -export * from './broadcastTxPage/broadcastTxPage'; export * from './nodeStatusPage/nodeStatusPage'; export * from './verifyMessagePage/verifyMessagePage'; export * from './home/home'; export * from './blocks/blocks'; +export * from './broadcast-tx/broadcast-tx'; export * from './pages.module'; diff --git a/app/src/pages/pages.module.ts b/app/src/pages/pages.module.ts index 6156b142f..25bc562c4 100644 --- a/app/src/pages/pages.module.ts +++ b/app/src/pages/pages.module.ts @@ -2,12 +2,12 @@ import { NgModule } from '@angular/core'; import { IonicModule } from 'ionic-angular'; import { ComponentsModule } from '../components'; import { BlocksPageModule } from '../pages/blocks/blocks.module'; +import { BroadcastTxPageModule } from './broadcast-tx/broadcast-tx.module'; import { HeadNavComponentModule } from '../components/head-nav/head-nav.module'; import { LatestTransactionsComponentModule } from '../components/latest-transactions/latest-transactions.module'; import { LatestBlocksComponentModule } from '../components/latest-blocks/latest-blocks.module'; import { HomePage, - BroadcastTxPage, NodeStatusPage, VerifyMessagePage } from './index'; @@ -15,7 +15,6 @@ import { @NgModule({ declarations: [ HomePage, - BroadcastTxPage, NodeStatusPage, VerifyMessagePage ], @@ -23,6 +22,7 @@ import { IonicModule, ComponentsModule, BlocksPageModule, + BroadcastTxPageModule, HeadNavComponentModule, LatestTransactionsComponentModule, LatestBlocksComponentModule From d74ca064d2c604066e0639f624b860f3bdc1a7eb Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 23 Mar 2018 15:56:01 -0400 Subject: [PATCH 7/9] Added toast to display feedback from transaction submission --- app/src/pages/broadcast-tx/broadcast-tx.ts | 50 ++++++++++------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/app/src/pages/broadcast-tx/broadcast-tx.ts b/app/src/pages/broadcast-tx/broadcast-tx.ts index 984863f4e..14f081128 100644 --- a/app/src/pages/broadcast-tx/broadcast-tx.ts +++ b/app/src/pages/broadcast-tx/broadcast-tx.ts @@ -1,15 +1,10 @@ import { Component } from '@angular/core'; -import { IonicPage, NavController, NavParams } from 'ionic-angular'; +import { IonicPage } from 'ionic-angular'; +import { ToastController } from 'ionic-angular'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Http } from '@angular/http'; import { ApiProvider } from '../../providers/api/api'; -/** - * Generated class for the BroadcastTxPage page. - * - * See http://ionicframework.com/docs/components/#navigation for more info - * on Ionic pages and navigation. - */ @IonicPage() @Component({ selector: 'page-broadcast-tx', @@ -18,46 +13,45 @@ import { ApiProvider } from '../../providers/api/api'; export class BroadcastTxPage { public title: string; - private nav: NavController; public transaction: string; public txForm: FormGroup; private status: string; - // private txid: any; - constructor(public navCtrl: NavController, public navParams: NavParams, public formBuilder: FormBuilder, private http: Http, private api: ApiProvider) { - this.nav = navCtrl; + constructor( + private toastCtrl: ToastController, + public formBuilder: FormBuilder, + private http: Http, + private api: ApiProvider, + ) { this.title = 'Broadcast Transaction'; this.txForm = formBuilder.group({ rawData: ['', Validators.pattern(/^[0-9A-Fa-f]+$/)] }); } - public ionViewDidLoad(): void { - console.log('ionViewDidLoad BroadcastTxPage'); - } - public send(): void { let postData: any = { rawtx: this.transaction }; this.status = 'loading'; - console.log('the postData is', postData); - this.http.post(this.api.apiPrefix + 'tx/send', postData) .subscribe( - response => console.log('response', response), + response => { + this.presentToast(response); + }, err => console.log('err', err) ); - /* - .error(function(data, status, headers, config) { - $scope.status = 'error'; - if(data) { - $scope.error = data; - } else { - $scope.error = "No error message given (connection error?)" - } - }); - */ + } + + private presentToast(response: any): void { + let body: any = JSON.parse(response._body); + let toast: any = this.toastCtrl.create({ + message: 'Transaction successfully broadcast. Trasaction id: ' + body.txid, + position: 'middle', + showCloseButton: true, + dismissOnPageChange: true + }); + toast.present(); } } From 2ac3ac8cd3f21bedcd0ea849a60029384271d94f Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Fri, 23 Mar 2018 17:15:09 -0400 Subject: [PATCH 8/9] added error messaging to toast --- app/src/pages/broadcast-tx/broadcast-tx.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/pages/broadcast-tx/broadcast-tx.ts b/app/src/pages/broadcast-tx/broadcast-tx.ts index 14f081128..044e4f4ac 100644 --- a/app/src/pages/broadcast-tx/broadcast-tx.ts +++ b/app/src/pages/broadcast-tx/broadcast-tx.ts @@ -38,16 +38,18 @@ export class BroadcastTxPage { this.http.post(this.api.apiPrefix + 'tx/send', postData) .subscribe( response => { - this.presentToast(response); + this.presentToast(true, response); }, - err => console.log('err', err) + err => { + this.presentToast(false, err); + } ); } - private presentToast(response: any): void { - let body: any = JSON.parse(response._body); + private presentToast(success: boolean, response: any): void { + let message: string = (success) ? 'Transaction successfully broadcast. Trasaction id: ' + JSON.parse(response._body).txid : 'An error occurred: ' + response._body; let toast: any = this.toastCtrl.create({ - message: 'Transaction successfully broadcast. Trasaction id: ' + body.txid, + message: message, position: 'middle', showCloseButton: true, dismissOnPageChange: true From 24e5b376ab6b71ba0b7b04329baee35cce5c03d6 Mon Sep 17 00:00:00 2001 From: Darren Nelsen Date: Mon, 26 Mar 2018 16:18:07 -0400 Subject: [PATCH 9/9] dismiss toast if present --- app/src/pages/broadcast-tx/broadcast-tx.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/pages/broadcast-tx/broadcast-tx.ts b/app/src/pages/broadcast-tx/broadcast-tx.ts index 044e4f4ac..4d6b4b5ea 100644 --- a/app/src/pages/broadcast-tx/broadcast-tx.ts +++ b/app/src/pages/broadcast-tx/broadcast-tx.ts @@ -16,6 +16,7 @@ export class BroadcastTxPage { public transaction: string; public txForm: FormGroup; private status: string; + private toast: any; constructor( private toastCtrl: ToastController, @@ -48,12 +49,16 @@ export class BroadcastTxPage { private presentToast(success: boolean, response: any): void { let message: string = (success) ? 'Transaction successfully broadcast. Trasaction id: ' + JSON.parse(response._body).txid : 'An error occurred: ' + response._body; - let toast: any = this.toastCtrl.create({ + if (this.toast) { + this.toast.dismiss(); + } + + this.toast = this.toastCtrl.create({ message: message, position: 'middle', showCloseButton: true, dismissOnPageChange: true }); - toast.present(); + this.toast.present(); } }