From f5f3743013fff51c1b233484a883c7ede7aaf661 Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Fri, 12 Apr 2019 16:10:53 +0300 Subject: [PATCH 1/9] CLIENT-1385: lock gateways from config --- mocks/waves-client-config/master/config.json | 5 +++- .../components/singleSend/SingleSend.js | 26 ++++++++++++++++++- .../components/singleSend/single-send.html | 19 +++++--------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/mocks/waves-client-config/master/config.json b/mocks/waves-client-config/master/config.json index d58bc3d936..62a78a1a89 100644 --- a/mocks/waves-client-config/master/config.json +++ b/mocks/waves-client-config/master/config.json @@ -7,7 +7,10 @@ "ZEC", "BCH", "DASH", - "XMR" + "XMR", + "USD", + "EUR", + "TRY" ], "CAN_TRANSFER_TRANSACTION": true, "CAN_SET_ASSET_SCRIPT_TRANSACTION": true, diff --git a/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js b/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js index b8680828cf..b74195baf4 100644 --- a/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js +++ b/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js @@ -21,6 +21,7 @@ * @param {$rootScope.Scope} $scope * @param {app.utils} utils * @param {IPollCreate} createPoll + * @param {ConfigService} configService * @param {IOuterBlockchains} outerBlockchains * @param {User} user * @param {GatewayService} gatewayService @@ -31,6 +32,7 @@ utils, createPoll, waves, + configService, outerBlockchains, user, gatewayService) { @@ -138,6 +140,15 @@ return this.toBankMode && this.termsLoadError; } + get isCoinomatAccepted() { + return configService + .get('PERMISSIONS.CAN_TRANSFER_COINOMAT').indexOf(this.balance.asset.displayName) !== -1; + } + + get isBankAccepted() { + return this.toBankMode ? this.isCoinomatAccepted : true; + } + get isBankPendingOrError() { return this.isBankError || this.isBankPending; } @@ -256,7 +267,6 @@ } $postLink() { - this.receive(utils.observe(this.tx, 'fee'), this._currentHasCommission, this); const onHasMoneyHash = () => { this.receive(utils.observe(this.state, 'toBankMode'), this._onChangeBankMode, this); @@ -272,6 +282,9 @@ this.receive(utils.observe(this.state, 'paymentId'), this._updateGatewayDetails, this); this.receive(utils.observe(this.tx, 'recipient'), this._updateGatewayDetails, this); + this.receive(utils.observe(this.state, 'paymentId'), this._updateGatewayPermisson, this); + this.receive(utils.observe(this.tx, 'recipient'), this._updateGatewayPermisson, this); + this.receive(utils.observe(this.tx, 'amount'), this._onChangeAmount, this); this.observe('gatewayDetails', this._updateWavesTxObject); @@ -284,6 +297,7 @@ this._currentHasCommission(); this._onChangeBaseAssets(); this._updateGatewayDetails(); + this._updateGatewayPermisson(); }; if (!this.state.moneyHash) { this.receiveOnce(utils.observe(this.state, 'moneyHash'), onHasMoneyHash); @@ -460,6 +474,7 @@ } this._setMinAmount(); + this._updateGatewayPermisson(); } /** @@ -515,6 +530,7 @@ this.tx.amount = this.moneyHash[this.assetId].cloneWithTokens('0'); this.mirror = this.moneyHash[this.mirrorId].cloneWithTokens('0'); this._updateGatewayDetails(); + this._updateGatewayPermisson(); // analytics.push('Send', `Send.ChangeCurrency.${WavesApp.type}`, this.assetId); } @@ -661,6 +677,13 @@ return Promise.resolve(); } + /** + * @private + */ + _updateGatewayPermisson() { + this.gatewayDetailsError = !this.isCoinomatAccepted; + } + } return new SingleSend(); @@ -672,6 +695,7 @@ 'utils', 'createPoll', 'waves', + 'configService', 'outerBlockchains', 'user', 'gatewayService' diff --git a/src/modules/utils/modals/sendAsset/components/singleSend/single-send.html b/src/modules/utils/modals/sendAsset/components/singleSend/single-send.html index 64ffb0575d..76a9085d4e 100644 --- a/src/modules/utils/modals/sendAsset/components/singleSend/single-send.html +++ b/src/modules/utils/modals/sendAsset/components/singleSend/single-send.html @@ -58,18 +58,18 @@
+ ng-if="$ctrl.toBankMode && $ctrl.termsIsPending && !$ctrl.isLira && $ctrl.isBankAccepted">
-
+
-
+
@@ -99,17 +99,12 @@
-
+
- - -
@@ -143,7 +138,7 @@
-
@@ -243,7 +238,7 @@
-
+
-
+
Date: Fri, 12 Apr 2019 16:22:04 +0300 Subject: [PATCH 2/9] CLIENT-1385: remove lira --- mocks/waves-client-config/master/config.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mocks/waves-client-config/master/config.json b/mocks/waves-client-config/master/config.json index 62a78a1a89..2207043792 100644 --- a/mocks/waves-client-config/master/config.json +++ b/mocks/waves-client-config/master/config.json @@ -9,8 +9,7 @@ "DASH", "XMR", "USD", - "EUR", - "TRY" + "EUR" ], "CAN_TRANSFER_TRANSACTION": true, "CAN_SET_ASSET_SCRIPT_TRANSACTION": true, From c4cec85f595fa174f2a2a8718659b866e0397c4a Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Fri, 12 Apr 2019 16:35:44 +0300 Subject: [PATCH 3/9] CLIENT-1385: edit layout --- src/modules/utils/modals/sendAsset/send.modal.less | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/utils/modals/sendAsset/send.modal.less b/src/modules/utils/modals/sendAsset/send.modal.less index f75daafffe..22f616903b 100644 --- a/src/modules/utils/modals/sendAsset/send.modal.less +++ b/src/modules/utils/modals/sendAsset/send.modal.less @@ -110,6 +110,7 @@ md-dialog.modal-send { .plate-warning { &.server-error { margin-bottom: 30px; + justify-content: center; } } From 31fbe4459e36e91b9348d57a6652d1b8eb20474d Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Mon, 29 Apr 2019 17:07:40 +0300 Subject: [PATCH 4/9] CLIENT-1385: replace names of assets to ids in config --- mocks/waves-client-config/master/config.json | 20 +++---- .../master/testnet.config.json | 53 +++++++++++++++++++ server.ts | 7 ++- .../components/singleSend/SingleSend.js | 2 +- 4 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 mocks/waves-client-config/master/testnet.config.json diff --git a/mocks/waves-client-config/master/config.json b/mocks/waves-client-config/master/config.json index 18b7ee9245..2f78c5b440 100644 --- a/mocks/waves-client-config/master/config.json +++ b/mocks/waves-client-config/master/config.json @@ -1,15 +1,15 @@ { "PERMISSIONS": { "CAN_TRANSFER_COINOMAT": [ - "BTC", - "ETH", - "LTC", - "ZEC", - "BCH", - "DASH", - "XMR", - "USD", - "EUR" + "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS", + "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu", + "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk", + "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa", + "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy", + "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H", + "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3", + "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck", + "Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU" ], "CAN_TRANSFER_TRANSACTION": true, "CAN_SET_ASSET_SCRIPT_TRANSACTION": true, @@ -58,5 +58,5 @@ ] } }, - "SERVICE_TEMPORARILY_UNAVAILABLE": true + "SERVICE_TEMPORARILY_UNAVAILABLE": false } diff --git a/mocks/waves-client-config/master/testnet.config.json b/mocks/waves-client-config/master/testnet.config.json new file mode 100644 index 0000000000..af47d7900c --- /dev/null +++ b/mocks/waves-client-config/master/testnet.config.json @@ -0,0 +1,53 @@ +{ + "PERMISSIONS": { + "CAN_TRANSFER_COINOMAT": [ + "DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn", + "BrmjyAWT5jjr3Wpsiyivyvg5vDuzoX2s93WgiexXetB3", + "BNdAstuFogzSyN2rY3beJbnBYwYcu7RzTHFjW88g8roK", + "CFg2KQfkUgUVM2jFCMC5Xh8T8zrebvPc4HjHPfAugU1S", + "8HT8tXwrXAYqwm8XrZ2hywWWTUAXxobHB5DakVC1y6jn", + "DGgBtwVoXKAKKvV2ayUpSoPzTJxt7jo9KiXMJRzTH2ET", + "8oPbSCKFHkXBy1hCGSg9pJkSARE7zhTQTLpc8KZwdtr7", + "D6N2rAqWN6ZCWnCeNFWLGqqjS6nJLeK4m19XiuhdDenr", + "AsuWyM9MUUsMmWkK7jS48L3ky6gA1pxx7QtEYPbfLjAJ" + ], + "CAN_TRANSFER_TRANSACTION": true, + "CAN_SET_ASSET_SCRIPT_TRANSACTION": true, + "CAN_MASS_TRANSFER_TRANSACTION": true, + "CAN_CREATE_ALIAS_TRANSACTION": true, + "CAN_ISSUE_TRANSACTION": true, + "CAN_REISSUE_TRANSACTION": true, + "CAN_SET_SCRIPT_TRANSACTION": true, + "CAN_LEASE_TRANSACTION": true, + "CAN_CANCEL_LEASE_TRANSACTION": true, + "CAN_BURN_TRANSACTION": true, + "CAN_SPONSORSHIP_TRANSACTION": true, + "CAN_DATA_TRANSACTION": true, + "CAN_CREATE_ORDER": true, + "CAN_CANCEL_ORDER": true, + "CAN_PAIRING_WITH_MOBILE": true, + "CAN_ANY_TRANSACTION": true + }, + "NOTIFICATIONS": [], + "SETTINGS": { + "DEX": { + "WATCH_LIST_PAIRS": [ + "WAVES", + "AsuWyM9MUUsMmWkK7jS48L3ky6gA1pxx7QtEYPbfLjAJ", + "D6N2rAqWN6ZCWnCeNFWLGqqjS6nJLeK4m19XiuhdDenr", + "DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn", + "BrmjyAWT5jjr3Wpsiyivyvg5vDuzoX2s93WgiexXetB3", + "BNdAstuFogzSyN2rY3beJbnBYwYcu7RzTHFjW88g8roK", + "CFg2KQfkUgUVM2jFCMC5Xh8T8zrebvPc4HjHPfAugU1S", + "8HT8tXwrXAYqwm8XrZ2hywWWTUAXxobHB5DakVC1y6jn", + "7itsmgdmomeTXvZzaaxqF3346h4FhciRoWceEw9asNV3", + "DGgBtwVoXKAKKvV2ayUpSoPzTJxt7jo9KiXMJRzTH2ET", + "FvKx3cerSVYGfXKFvUgp7koNuTAcLs8DmtmwRrFVCqJv", + "3P8gkhcLhFQvBkDzMnWeqqwvq3qxkpTNQPs4LUQ95tKD", + "8oPbSCKFHkXBy1hCGSg9pJkSARE7zhTQTLpc8KZwdtr7", + "6KSUNALdYEd1EVTE4dTcSHzNw1dA3Q6ieokSRVuEcALV" + ] + } + }, + "SERVICE_TEMPORARILY_UNAVAILABLE": false +} \ No newline at end of file diff --git a/server.ts b/server.ts index f35f9f54f9..8e949dbf01 100644 --- a/server.ts +++ b/server.ts @@ -154,7 +154,12 @@ function wavesClientConfig(req, res, next) { } let response_json = { error: 'oops' }; - const path = join(__dirname, 'mocks/waves-client-config/master/config.json'); + const connection: string = parseCookie(req.headers.cookie).connection; + const path = join( + __dirname, + `mocks/waves-client-config/master/${connection === 'mainnet' ? '' : 'testnet.'}config.json` + ); + if (fs.existsSync(path)) { response_json = JSON.parse(fs.readFileSync(path, 'utf8')) || ''; } diff --git a/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js b/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js index 5636cc3878..1fabd92f54 100644 --- a/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js +++ b/src/modules/utils/modals/sendAsset/components/singleSend/SingleSend.js @@ -142,7 +142,7 @@ get isCoinomatAccepted() { return configService - .get('PERMISSIONS.CAN_TRANSFER_COINOMAT').indexOf(this.balance.asset.displayName) !== -1; + .get('PERMISSIONS.CAN_TRANSFER_COINOMAT').indexOf(this.balance.asset.id) !== -1; } get isBankAccepted() { From 5253860b3c5dbf4e049ec481932e13106c681070 Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Mon, 29 Apr 2019 17:56:51 +0300 Subject: [PATCH 5/9] CLIENT-1385: check connection exist --- server.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server.ts b/server.ts index 8e949dbf01..fe430d5727 100644 --- a/server.ts +++ b/server.ts @@ -1,7 +1,7 @@ import { createSecureServer } from 'http2'; import { createServer } from 'https'; import { route, parseArguments, stat, getLocales } from './ts-scripts/utils'; -import { readFileSync, existsSync,mkdirSync } from 'fs'; +import { readFileSync, existsSync, mkdirSync } from 'fs'; import { serialize, parse as parserCookie } from 'cookie'; import { compile } from 'handlebars'; import { parse } from 'url'; @@ -73,11 +73,11 @@ function createMyServer(port) { console.log('Available urls:'); console.log(url); const cachePath = join(process.cwd(), '.cache-download'); - if (!existsSync(cachePath)){ + if (!existsSync(cachePath)) { mkdirSync(cachePath); } getLocales(cachePath).then(() => { - const localesTimer = setInterval(function() { + const localesTimer = setInterval(function () { getLocales(cachePath) .catch(err => console.log(err)) }, 60 * 10000); @@ -148,13 +148,14 @@ function request(req, res) { } function wavesClientConfig(req, res, next) { - if (!req.url.includes('waves-client-config')) { + const connection: string | null = parseCookie(req.headers.cookie).connection; + + if (!req.url.includes('waves-client-config') || !connection) { next(); return null; } let response_json = { error: 'oops' }; - const connection: string = parseCookie(req.headers.cookie).connection; const path = join( __dirname, `mocks/waves-client-config/master/${connection === 'mainnet' ? '' : 'testnet.'}config.json` From 02249554f2abaa3741ca358f38d037a6b90ddcc0 Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Tue, 21 May 2019 15:18:29 +0300 Subject: [PATCH 6/9] CLIENT-1385: fix connection lack --- server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.ts b/server.ts index 60396d928f..5a3a11e1eb 100644 --- a/server.ts +++ b/server.ts @@ -141,7 +141,8 @@ function request(req, res) { } function wavesClientConfig(req, res, next) { - const connection: string | null = parseCookie(req.headers.cookie).connection; + const connection: string | null = parseCookie(req.headers.cookie) ? + parseCookie(req.headers.cookie).connection : null; if (!req.url.includes('waves-client-config') || !connection) { next(); From 0d1093ea9fa3576e1cd5e89469abb97b9d9cbe36 Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Tue, 21 May 2019 15:20:34 +0300 Subject: [PATCH 7/9] CLIENT-1385: refactor connection --- server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 5a3a11e1eb..f921568718 100644 --- a/server.ts +++ b/server.ts @@ -141,8 +141,8 @@ function request(req, res) { } function wavesClientConfig(req, res, next) { - const connection: string | null = parseCookie(req.headers.cookie) ? - parseCookie(req.headers.cookie).connection : null; + const cookies = parseCookie(req.headers.cookie); + const connection: string | null = cookies ? cookies.connection : null; if (!req.url.includes('waves-client-config') || !connection) { next(); From fe82424e24e84bc93d83015fe8276495f859aa84 Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Tue, 21 May 2019 15:23:40 +0300 Subject: [PATCH 8/9] CLIENT-1385: remove whitespace --- server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index f921568718..2e2e0dcb06 100644 --- a/server.ts +++ b/server.ts @@ -1,7 +1,7 @@ import { createSecureServer } from 'http2'; import { createServer } from 'https'; import { route, parseArguments, stat, loadLocales } from './ts-scripts/utils'; -import { readFileSync, existsSync,mkdirSync } from 'fs'; +import { readFileSync, existsSync, mkdirSync } from 'fs'; import { serialize, parse as parserCookie } from 'cookie'; import { compile } from 'handlebars'; import { parse } from 'url'; @@ -141,7 +141,7 @@ function request(req, res) { } function wavesClientConfig(req, res, next) { - const cookies = parseCookie(req.headers.cookie); + const cookies = parseCookie(req.headers.cookie); const connection: string | null = cookies ? cookies.connection : null; if (!req.url.includes('waves-client-config') || !connection) { From bf3ca98e6c9543e3142e5630dbada21dc01d7bb5 Mon Sep 17 00:00:00 2001 From: Max Axenov Date: Tue, 21 May 2019 15:29:07 +0300 Subject: [PATCH 9/9] CLIENT-1385: rename cookie --- server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 2e2e0dcb06..a5982a01de 100644 --- a/server.ts +++ b/server.ts @@ -141,8 +141,8 @@ function request(req, res) { } function wavesClientConfig(req, res, next) { - const cookies = parseCookie(req.headers.cookie); - const connection: string | null = cookies ? cookies.connection : null; + const parsedCookie = parseCookie(req.headers.cookie); + const connection: string | null = parsedCookie ? parsedCookie.connection : null; if (!req.url.includes('waves-client-config') || !connection) { next();