Skip to content

Commit

Permalink
Merge pull request #368 from Adamant-im/stage
Browse files Browse the repository at this point in the history
Update to Stage 2.3.0 (Bitcoin & Registered Tx status)
  • Loading branch information
adamant-al authored Dec 23, 2019
2 parents 1acf6be + 6310cec commit 33b51f3
Show file tree
Hide file tree
Showing 43 changed files with 639 additions and 259 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant-im",
"version": "2.1.0",
"version": "2.3.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -25,7 +25,7 @@
"bip39": "^3.0.1",
"bitcoinjs-lib": "^4.0.2",
"bytebuffer": "^5.0.1",
"coininfo": "^4.3.0",
"coininfo": "^5.1.0",
"core-js": "^3.0.1",
"dayjs": "^1.8.11",
"deepmerge": "^2.1.1",
Expand Down
46 changes: 36 additions & 10 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
maxlength="100"
/>

<v-checkbox
:label="$t('transfer.increase_fee')"
color="grey darken-1"
v-model="increaseFee"
v-if="allowIncreaseFee"
/>

<div class="text-xs-center">
<v-btn
:class="`${className}__button`"
Expand Down Expand Up @@ -170,7 +177,7 @@ import { BigNumber } from 'bignumber.js'
import { parseURI } from '@/lib/uri'
import { sendMessage } from '@/lib/adamant-api'
import { Cryptos, CryptoAmountPrecision, CryptoNaturalUnits, TransactionStatus as TS, isErc20 } from '@/lib/constants'
import { Cryptos, CryptoAmountPrecision, CryptoNaturalUnits, TransactionStatus as TS, isErc20, getMinAmount } from '@/lib/constants'
import validateAddress from '@/lib/validateAddress'
import { formatNumber, isNumeric } from '@/lib/numericHelpers'
Expand All @@ -184,9 +191,7 @@ function validateForm () {
const propertyValue = this[property]
return validators
.map(validator => {
return validator.call(this, propertyValue)
})
.map(validator => validator.call(this, propertyValue))
.filter(v => v !== true) // returns only errors
})
.slice(0, 1) // get first error
Expand Down Expand Up @@ -220,7 +225,7 @@ export default {
* @returns {number}
*/
transferFee () {
return this.$store.getters[`${this.currency.toLowerCase()}/fee`]
return this.calculateTransferFee(this.amount)
},
/**
Expand Down Expand Up @@ -289,8 +294,14 @@ export default {
if (this.balance < this.transferFee) return 0
return BigNumber(this.balance)
.minus(this.transferFee)
let amount = BigNumber(this.balance)
// For BTC we keep 1000 satoshis (0.00001 BTC) untouched as there are problems when we try to drain the wallet
if (this.currency === Cryptos.BTC) {
amount = amount.minus(0.00001)
}
return amount
.minus(this.calculateTransferFee(this.balance))
.toNumber()
},
/**
Expand Down Expand Up @@ -332,7 +343,8 @@ export default {
amount: BigNumber(this.amount).toFixed(),
crypto: this.currency,
name: this.recipientName,
address: this.cryptoAddress
address: this.cryptoAddress,
fee: this.transferFee
})
},
validationRules () {
Expand All @@ -344,12 +356,16 @@ export default {
amount: [
v => v > 0 || this.$t('transfer.error_incorrect_amount'),
v => this.finalAmount <= this.balance || this.$t('transfer.error_not_enough'),
v => this.validateMinAmount(v, this.currency) || this.$t('transfer.error_dust_amount'),
v => this.validateNaturalUnits(v, this.currency) || this.$t('transfer.error_dust_amount'),
v => isErc20(this.currency)
? this.ethBalance >= this.transferFee || this.$t('transfer.error_not_enough_eth_fee')
: true
]
}
},
allowIncreaseFee () {
return this.currency === Cryptos.BTC
}
},
watch: {
Expand Down Expand Up @@ -391,7 +407,8 @@ export default {
showQrcodeScanner: false,
showSpinner: false,
dialog: false,
fetchAddress: null // fn throttle
fetchAddress: null, // fn throttle
increaseFee: false
}),
methods: {
confirm () {
Expand Down Expand Up @@ -540,7 +557,8 @@ export default {
amount: this.amount,
admAddress: this.address,
address: this.cryptoAddress,
comments: this.comment
comments: this.comment,
fee: this.transferFee
})
}
},
Expand Down Expand Up @@ -586,12 +604,20 @@ export default {
})
}
},
validateMinAmount (amount, currency) {
const min = getMinAmount(currency)
return amount > min
},
validateNaturalUnits (amount, currency) {
const units = CryptoNaturalUnits[currency]
const [ , right = '' ] = BigNumber(amount).toFixed().split('.')
return right.length <= units
},
calculateTransferFee (amount) {
const coef = this.increaseFee ? 2 : 1
return coef * this.$store.getters[`${this.currency.toLowerCase()}/fee`](amount)
}
},
filters: {
Expand Down
7 changes: 7 additions & 0 deletions src/components/icons/BtcFill.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<g>
<path
d="M 254.01758 31.763672 C 152.48291 32.527436 60.371006 101.57736 34.681641 204.67773 C 4.2063816 326.8494 78.563911 450.60352 200.70703 481.06445 C 322.90001 511.53256 446.64651 437.17483 477.10742 314.99609 C 507.56836 192.81017 433.21912 69.042991 311.0332 38.582031 C 291.94612 33.822507 272.82029 31.622234 254.01758 31.763672 z M 246.10547 99.84375 L 273.08203 106.57031 L 262.24219 150.0332 C 269.48447 151.68616 276.77295 153.35281 283.86914 155.12109 L 294.63281 111.94531 L 321.625 118.67188 L 310.57031 163.01758 C 344.65204 174.75742 369.57706 192.35553 364.67969 225.0918 C 361.13541 249.05586 347.84961 260.65756 330.21289 264.72461 C 354.43069 277.33322 366.75549 296.66901 355.01562 330.18945 C 340.44653 371.82098 305.83383 375.33374 259.80469 366.62305 L 248.63477 411.39258 L 221.64062 404.66406 L 232.66602 360.49609 C 225.66977 358.75858 218.51956 356.91299 211.1543 354.91406 L 200.0918 399.29102 L 173.12891 392.56445 L 184.29883 347.71094 C 177.99451 346.0964 171.5916 344.38171 165.05664 342.74414 L 129.92969 333.98828 L 143.33008 303.08789 C 143.33008 303.08789 163.21831 308.37842 162.94922 307.98633 C 170.59126 309.87762 173.98257 304.89554 175.32031 301.57422 L 192.97266 230.80469 C 193.96445 231.04301 194.92471 231.28876 195.82422 231.51172 C 194.74788 231.08118 193.77101 230.80353 193.01758 230.61133 L 205.61133 180.09375 C 205.94191 174.35835 203.96579 167.12383 193.0332 164.39453 C 193.45605 164.11006 173.42773 159.51953 173.42773 159.51953 L 180.60938 130.68945 L 217.83594 139.98438 L 217.80469 140.12305 C 223.40169 141.5146 229.16725 142.83608 235.04102 144.17383 L 246.10547 99.84375 z M 254.96875 181.91602 L 241.53125 235.80859 C 256.76924 239.60657 303.74222 255.09874 311.35352 224.60742 C 319.28006 192.80141 270.20673 185.71399 254.96875 181.91602 z M 234.75 263.00977 L 219.92578 322.43164 C 238.22366 326.97534 294.66415 345.09665 303.00586 311.57617 C 311.72424 276.61801 253.04788 267.57654 234.75 263.00977 z "
id="path3713" />
</g>
</template>
2 changes: 2 additions & 0 deletions src/components/icons/CryptoIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import DashFillIcon from './DashFill'
import KcsFillIcon from './KcsFill'
import LskFillIcon from './LskFill'
import UsdsFillIcon from './UsdsFill'
import BtcFillIcon from './BtcFill'
import UnknownCryptoFillIcon from './UnknownCryptoFill'
import { Cryptos } from '@/lib/constants'
Expand All @@ -38,6 +39,7 @@ export default {
KcsFillIcon,
LskFillIcon,
UsdsFillIcon,
BtcFillIcon,
UnknownCryptoFillIcon
},
props: {
Expand Down
14 changes: 13 additions & 1 deletion src/components/transactions/BtcTransaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,19 @@ export default {
return getExplorerUrl(this.crypto, this.id)
},
confirmations () {
return this.transaction.confirmations || 0
const { height, confirmations } = this.transaction
let result = confirmations
if (height) {
// Calculate confirmations count based on the tx block height and the last block height.
// That's for BTC only as it does not return the confirmations for the transaction.
const c = this.$store.getters[`${this.cryptoKey}/height`] - height
if (isFinite(c) && c > result) {
result = c
}
}
return result
}
},
methods: {
Expand Down
3 changes: 3 additions & 0 deletions src/config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"dash": [
{ "url": "https://dashnode1.adamant.im" }
],
"btc": [
{ "url": "https://btcnode2.adamant.im" }
]
},
"env": "development"
Expand Down
3 changes: 3 additions & 0 deletions src/config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"dash": [
{ "url": "https://dashnode1.adamant.im" }
],
"btc": [
{ "url": "https://btcnode2.adamant.im" }
]
},
"env": "production"
Expand Down
3 changes: 3 additions & 0 deletions src/config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
],
"dash": [
{ "url": "https://dashnode1.adamant.im" }
],
"btc": [
{ "url": "https://btcnode2.adamant.im" }
]
},
"env": "test"
Expand Down
3 changes: 3 additions & 0 deletions src/config/tor.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"dash": [
{ "url": "http://ldod53womnlwjmd4noq5yuq26xx3mmbrr4uogkfymuakhofjcuqeygad.onion" }
],
"btc": [
{ "url": "http://mgplh7en3d6ywsec5h6q3tc6mirsleb5cmlyn6nmp25qrb6gy35nypad.onion" }
]
},
"env": "production"
Expand Down
35 changes: 2 additions & 33 deletions src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,7 @@
"send_btn": "Send funds",
"share_uri": "Share {crypto} address",
"show_qr_code": "Show QR code",
"wallet": "wallet",
"your_address_ADM": "ADAMANT adresse",
"your_address_BNB": "Binance Coin adresse",
"your_address_BZ": "Bit-Z adresse",
"your_address_DASH": "Dash adresse",
"your_address_DOGE": "Dogecoin adresse",
"your_address_ETH": "Ethereum adresse",
"your_address_KCS": "KuCoin Shares adresse",
"your_address_USDS": "StableUSD adresse",
"your_address_tooltip_ADM": "Das ist deine eindeutige Identifizierung auf ADAMANT. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_BNB": "Das ist deine eindeutige Identifizierung auf Binance Coin. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_BZ": "Das ist deine eindeutige Identifizierung auf Bit-Z. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_DASH": "Das ist deine eindeutige Identifizierung auf Dash. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_DOGE": "Das ist deine eindeutige Identifizierung auf Dogecoin. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_ETH": "Das ist deine eindeutige Identifizierung auf Ethereum. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_KCS": "Das ist deine eindeutige Identifizierung auf KuCoin Shares. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_address_tooltip_USDS": "Das ist deine eindeutige Identifizierung auf StableUSD. Klick hier um diese in die Zwischenablage zu kopieren.",
"your_balance_ADM": "ADAMANT Balance",
"your_balance_BNB": "Binance Coin Balance",
"your_balance_BZ": "Bit-Z Balance",
"your_balance_DASH": "Dash Balance",
"your_balance_DOGE": "Dogecoin Balance",
"your_balance_ETH": "Ethereum Balance",
"your_balance_KCS": "KuCoin Shares Balance",
"your_balance_USDS": "StableUSD Balance",
"your_balance_tooltip_ADM": "Hier siehst du deinen ADAMANT Kontostand. Klicke hier um alle Ein- und ausgehenden Transaktionen zu sehen.",
"your_balance_tooltip_BNB": "Hier siehst du deinen ADAMANT BNB Kontostand.",
"your_balance_tooltip_BZ": "Hier siehst du deinen ADAMANT BZ Kontostand.",
"your_balance_tooltip_DASH": "Hier siehst du deinen ADAMANT DASH Kontostand.",
"your_balance_tooltip_DOGE": "Hier siehst du deinen ADAMANT DOGE Kontostand.",
"your_balance_tooltip_ETH": "Hier siehst du deinen ADAMANT ETH Kontostand.",
"your_balance_tooltip_KCS": "Hier siehst du deinen ADAMANT KCS Kontostand.",
"your_balance_tooltip_USDS": "Hier siehst du deinen ADAMANT USDS Kontostand."
"wallet": "wallet"
},
"login": {
"brand_title": "ADAMANT",
Expand Down Expand Up @@ -243,6 +211,7 @@
"error_transfer_send": "Error while sending transaction",
"error_unknown": "Unknown error",
"final_amount_label": "Betrag inklusive Transaktionsgebühr",
"increase_fee": "Increase fee",
"invalid_qr_code": "QR code does not contain an address or unrecognizable",
"max_transfer": "Max to transfer",
"no_address_text": "This user does not have a public {crypto} wallet yet. To get it, he should login into messenger when his balance is more than 0.001 ADM.",
Expand Down
12 changes: 3 additions & 9 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,7 @@
"send_crypto": "Send {crypto}",
"share_uri": "Share {crypto} address",
"show_qr_code": "Show QR code",
"wallet": "wallet",
"your_address_ADM": "ADAMANT address",
"your_address_BNB": "Binance Coin address",
"your_address_BZ": "Bit-Z address",
"your_address_DASH": "Dash address",
"your_address_DOGE": "DOGE address",
"your_address_ETH": "Ethereum address",
"your_address_KCS": "KuCoin Shares address",
"your_address_USDS": "StableUSD address"
"wallet": "wallet"
},
"login": {
"brand_title": "ADAMANT",
Expand Down Expand Up @@ -205,6 +197,7 @@
"statuses": {
"error": "Error",
"pending": "Pending",
"registered": "Pending",
"success": "Success"
},
"transactions": "Transactions",
Expand Down Expand Up @@ -241,6 +234,7 @@
"error_transfer_send": "Error while completing a transaction",
"error_unknown": "Unknown error. Weak connection?",
"final_amount_label": "Amount including a transfer fee",
"increase_fee": "Increase fee",
"invalid_qr_code": "QR code does not contain an address or unrecognizable",
"no_address_text": "This user does not have a public {crypto} wallet yet. They must log in the Messenger with more than 0.001 ADM on their balance",
"no_address_title": "Recipient has no {crypto} wallet yet",
Expand Down
12 changes: 3 additions & 9 deletions src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,7 @@
"send_crypto": "Отправить {crypto}",
"share_uri": "Поделиться ссылкой {crypto}",
"show_qr_code": "Показать QR-код",
"wallet": "кошелек",
"your_address_ADM": "ADAMANT address",
"your_address_BNB": "Кошелек Binance Coin",
"your_address_BZ": "Кошелек Bit-Z",
"your_address_DASH": "Кошелек Dash",
"your_address_DOGE": "Кошелек Dogecoin",
"your_address_ETH": "Кошелек Ethereum",
"your_address_KCS": "Кошелек KuCoin Shares",
"your_address_USDS": "Кошелек StableUSD"
"wallet": "кошелек"
},
"login": {
"brand_title": "АДАМАНТ",
Expand Down Expand Up @@ -206,6 +198,7 @@
"statuses": {
"error": "Ошибка",
"pending": "Ожидание",
"registered": "Ожидание",
"success": "Успешно"
},
"transactions": "Транзакции",
Expand Down Expand Up @@ -242,6 +235,7 @@
"error_transfre_send": "Ошибка при отправке транзакции",
"error_unknown": "Неизвестная ошибка. Плохое подключение?",
"final_amount_label": "Количество, включая комиссию за перевод",
"increase_fee": "Увеличить комиссию",
"invalid_qr_code": "QR-код не содержит адрес или не удается распознать",
"no_address_text": "У этого пользователя еще нет публичного {crypto}-кошелька. Он должен зайти в Мессенджер с балансом более 0.001 ADM",
"no_address_title": "У получателя нет {crypto}-кошелька",
Expand Down
Loading

0 comments on commit 33b51f3

Please sign in to comment.