From 7571a03f1de5c414c3c3433d772d5f0c54e1541c Mon Sep 17 00:00:00 2001 From: AalaaGhanam Date: Mon, 25 Jul 2022 23:49:50 +0200 Subject: [PATCH 1/6] ADD: usd --- lib/coins/dollar.js | 29 +++++++++++++++++++++++++++++ lib/coins/index.js | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 lib/coins/dollar.js diff --git a/lib/coins/dollar.js b/lib/coins/dollar.js new file mode 100644 index 0000000..95f9fd1 --- /dev/null +++ b/lib/coins/dollar.js @@ -0,0 +1,29 @@ +const CoinHelper = require('./coin'); +const iban = require('iban'); +const countriesSepa = require('./countriesSepa'); + +function addressValidator(network, address) { + const countrySepa = countriesSepa.find((countrySepa) => address.startsWith(countrySepa.iban)); + + return ( + address && + iban.isValid(address) && + countrySepa && + address.indexOf(' ') === -1 + ); +} + +class DollarHelper extends CoinHelper { + getURIPrefix() { + return 'dollar'; + } + + validAddress(address) { + return addressValidator(this.opts.network, address); + } +} + +DollarHelper.code = 'USD'; +DollarHelper.decimals = 2; + +module.exports = DollarHelper; diff --git a/lib/coins/index.js b/lib/coins/index.js index f480edd..3bf688c 100644 --- a/lib/coins/index.js +++ b/lib/coins/index.js @@ -10,6 +10,7 @@ const ZcashHelper = require('./zcash'); const XrpHelper = require('./xrp'); const PolygonHelper = require('./polygon'); const TokenHelper = require('./tokens/token'); +const DollarHelper = require('./dollar'); module.exports = { EUR: EuroHelper, @@ -44,4 +45,5 @@ module.exports = { USDT: TokenHelper.getToken('TRX', 'USDT'), USDC: TokenHelper.getToken('TRX', 'USDC'), }, + USD: DollarHelper, }; From 5e154feb2f823dcb220deb7c24f80beffe69da45 Mon Sep 17 00:00:00 2001 From: AalaaGhanam Date: Tue, 26 Jul 2022 00:08:34 +0200 Subject: [PATCH 2/6] Update dollar.js --- lib/coins/dollar.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/coins/dollar.js b/lib/coins/dollar.js index 95f9fd1..5895033 100644 --- a/lib/coins/dollar.js +++ b/lib/coins/dollar.js @@ -5,12 +5,7 @@ const countriesSepa = require('./countriesSepa'); function addressValidator(network, address) { const countrySepa = countriesSepa.find((countrySepa) => address.startsWith(countrySepa.iban)); - return ( - address && - iban.isValid(address) && - countrySepa && - address.indexOf(' ') === -1 - ); + return address && iban.isValid(address) && countrySepa && address.indexOf(' ') === -1; } class DollarHelper extends CoinHelper { From 16343e9a63b508b8a48f34a56c2da20e81162049 Mon Sep 17 00:00:00 2001 From: AalaaGhanam Date: Tue, 26 Jul 2022 00:14:40 +0200 Subject: [PATCH 3/6] Update package.json --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7f6ab9..201c702 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "Common amon libraries", "main": "./lib/index.js", "directories": { - "lib": "lib" + "lib": "lib", + "test": "test" }, "scripts": { "test": "mocha ./test/test.config.js ./test/unit --recursive --timeout 15000", @@ -44,5 +45,6 @@ "prettier": "^2.5.1", "qs": "^6.10.3", "sha.js": "^2.4.11" - } + }, + "devDependencies": {} } From 6800bdd3d0f090f8325b591fb496bc9f9854cd3a Mon Sep 17 00:00:00 2001 From: AalaaGhanam Date: Tue, 26 Jul 2022 01:05:05 +0200 Subject: [PATCH 4/6] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 201c702..740fe30 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@amontech/amon-lib", - "version": "2.14.2", + "version": "2.14.3", "description": "Common amon libraries", "main": "./lib/index.js", "directories": { From c62debf07e7c115c354e8001ca20cd2c9d04ec64 Mon Sep 17 00:00:00 2001 From: AalaaGhanam Date: Tue, 26 Jul 2022 13:39:18 +0200 Subject: [PATCH 5/6] Revert "Update package.json" This reverts commit 16343e9a63b508b8a48f34a56c2da20e81162049. --- package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 740fe30..2c20761 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "description": "Common amon libraries", "main": "./lib/index.js", "directories": { - "lib": "lib", - "test": "test" + "lib": "lib" }, "scripts": { "test": "mocha ./test/test.config.js ./test/unit --recursive --timeout 15000", @@ -45,6 +44,5 @@ "prettier": "^2.5.1", "qs": "^6.10.3", "sha.js": "^2.4.11" - }, - "devDependencies": {} + } } From 134e6f070c46731fa46e085cf0a0357411c72488 Mon Sep 17 00:00:00 2001 From: AalaaGhanam Date: Tue, 26 Jul 2022 13:39:22 +0200 Subject: [PATCH 6/6] Revert "Update package.json" This reverts commit 6800bdd3d0f090f8325b591fb496bc9f9854cd3a. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2c20761..e7f6ab9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@amontech/amon-lib", - "version": "2.14.3", + "version": "2.14.2", "description": "Common amon libraries", "main": "./lib/index.js", "directories": {