Skip to content

Commit

Permalink
Merge pull request #399 from Adamant-im/stage
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
adamant-al authored Aug 31, 2020
2 parents a99b736 + fa9f320 commit 694a1bd
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adamant-im",
"version": "2.7.0",
"version": "2.8.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
16 changes: 14 additions & 2 deletions src/components/BuyTokensDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</v-list-tile-content>
</v-list-tile>

<v-list-tile @click="openLink('https://coindeal.com/ref/9WZN')">
<v-list-tile avatar @click="openLink('https://coindeal.com/ref/9WZN')">
<v-list-tile-avatar>
<icon><cdl-icon/></icon>
</v-list-tile-avatar>
Expand All @@ -40,6 +40,16 @@
<v-list-tile-title>CoinDeal</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>

<v-list-tile avatar @click="openLink('https://atomars.com/refcode/kaba')">
<v-list-tile-avatar>
<icon><atomars-icon/></icon>
</v-list-tile-avatar>

<v-list-tile-content>
<v-list-tile-title>Atomars</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>

</v-card-text>
Expand All @@ -52,6 +62,7 @@ import validateAddress from '@/lib/validateAddress'
import Icon from '@/components/icons/BaseIcon'
import CryptoIcon from '@/components/icons/CryptoIcon'
import CdlIcon from '@/components/icons/common/Cdl'
import AtomarsIcon from '@/components/icons/common/Atomars'
export default {
computed: {
Expand Down Expand Up @@ -94,7 +105,8 @@ export default {
components: {
Icon,
CryptoIcon,
CdlIcon
CdlIcon,
AtomarsIcon
},
props: {
value: {
Expand Down
22 changes: 16 additions & 6 deletions src/components/SendFundsForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

<v-text-field
:value="`${this.transferFeeFixed} ${this.transferFeeCurrency}`"
:label="$t('transfer.commission_label')"
:label="`${this.transferFeeLabel}`"
class="a-input"
disabled
/>
Expand Down Expand Up @@ -174,10 +174,11 @@ import QrcodeCapture from '@/components/QrcodeCapture'
import QrcodeScannerDialog from '@/components/QrcodeScannerDialog'
import get from 'lodash/get'
import { BigNumber } from 'bignumber.js'
import { INCREASE_FEE_MULTIPLIER } from '../lib/constants'
import { parseURI } from '@/lib/uri'
import { sendMessage } from '@/lib/adamant-api'
import { Cryptos, CryptoAmountPrecision, CryptoNaturalUnits, TransactionStatus as TS, isErc20, getMinAmount } from '@/lib/constants'
import { Cryptos, CryptoAmountPrecision, CryptoNaturalUnits, TransactionStatus as TS, isErc20, isFeeEstimate, isEthBased, getMinAmount } from '@/lib/constants'
import validateAddress from '@/lib/validateAddress'
import { formatNumber, isNumeric } from '@/lib/numericHelpers'
import partnerName from '@/mixins/partnerName'
Expand Down Expand Up @@ -238,6 +239,14 @@ export default {
return BigNumber(this.transferFee).toFixed()
},
/**
* Label for fee field. Estimate fee or precise value.
* @returns {string}
*/
transferFeeLabel () {
return isFeeEstimate(this.currency) ? this.$t('transfer.commission_estimate_label') : this.$t('transfer.commission_label')
},
/**
* Transfer currency (may differ from the amount currency in case of ERC-20 tokens)
* @returns {string}
Expand Down Expand Up @@ -369,7 +378,7 @@ export default {
}
},
allowIncreaseFee () {
return this.currency === Cryptos.BTC
return (this.currency === Cryptos.BTC) || isEthBased(this.currency)
}
},
watch: {
Expand Down Expand Up @@ -423,7 +432,7 @@ export default {
} else {
this.$store.dispatch('snackbar/show', {
message: abstract,
timeout: 3000
timeout: 5000
})
}
},
Expand Down Expand Up @@ -562,7 +571,8 @@ export default {
admAddress: this.address,
address: this.cryptoAddress,
comments: this.comment,
fee: this.transferFee
fee: this.transferFee,
increaseFee: this.increaseFee
})
}
},
Expand Down Expand Up @@ -620,7 +630,7 @@ export default {
return right.length <= units
},
calculateTransferFee (amount) {
const coef = this.increaseFee ? 2 : 1
const coef = this.increaseFee ? INCREASE_FEE_MULTIPLIER : 1
return coef * this.$store.getters[`${this.currency.toLowerCase()}/fee`](amount)
}
},
Expand Down
5 changes: 5 additions & 0 deletions src/components/icons/common/Atomars.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<g>
<path fill-rule="evenodd" d="m406.842164,28.551923c-3.861338,0.413763 -11.16889,1.898684 -11.760953,2.390028c-0.336183,0.279018 -1.949043,0.75539 -3.585042,1.057547c-1.634638,0.302156 -3.81234,0.982688 -4.838582,1.512142c-5.227846,2.700351 -9.77516,5.438811 -12.325794,7.424603c-1.562501,1.21543 -4.085914,3.154946 -5.608944,4.31185c-1.52303,1.156904 -3.178084,2.749349 -3.678956,3.538766c-0.500871,0.789417 -2.26481,2.854151 -3.918503,4.588146c-1.655054,1.733995 -4.072303,5.163876 -5.370758,7.621957c-1.298455,2.458081 -2.538384,4.714725 -2.754793,5.014159c-0.400153,0.551231 -2.312447,5.491893 -4.415291,11.408437c-5.50142,15.473935 -2.410444,37.482337 7.68865,54.739265c3.491129,5.965543 16.557342,19.599319 18.784042,19.599319c0.21777,0 0.803028,0.368848 1.302538,0.820721c2.316531,2.097399 13.421451,7.540294 16.58048,8.126912c1.188209,0.220492 2.780653,0.714559 3.538766,1.09974c4.9638,2.511163 28.110051,2.508441 35.14539,-0.004083c1.20318,-0.430096 3.591847,-1.147377 5.308149,-1.595167c1.71494,-0.446429 4.050526,-1.400535 5.189736,-2.119176c1.13921,-0.718642 3.772869,-2.173619 5.852575,-3.231166c3.636763,-1.851047 11.388021,-7.665512 13.70183,-10.278754c0.612479,-0.69142 2.319253,-2.605076 3.793285,-4.251963c3.254304,-3.63404 5.711024,-6.884261 6.587549,-8.710809c0.35796,-0.748585 0.894219,-1.728551 1.18957,-2.177702c6.214617,-9.434895 10.086844,-28.016138 8.453567,-40.55698c-1.626471,-12.485039 -8.0085,-28.150883 -14.08565,-34.571021c-1.559779,-1.648248 -3.549654,-3.943002 -4.422096,-5.098545c-0.871081,-1.155543 -2.860956,-3.115475 -4.422096,-4.355404c-1.56114,-1.239929 -3.410826,-2.709878 -4.109052,-3.266553c-2.169536,-1.728551 -6.564411,-4.472456 -10.120871,-6.316697c-1.872824,-0.9718 -3.527877,-1.965376 -3.677594,-2.207646c-0.149717,-0.242269 -1.312066,-0.60159 -2.583299,-0.798944c-1.271234,-0.197354 -3.670789,-0.813916 -5.332648,-1.36923c-6.221423,-2.082428 -18.364834,-3.17264 -26.105204,-2.343752m-206.609491,83.514877c-3.892643,0.234103 -11.242387,1.166432 -16.332766,2.071539c-9.396785,1.671386 -11.416603,2.121899 -17.648915,3.936197c-1.921822,0.560758 -4.189354,1.018076 -5.038658,1.018076c-0.849304,0 -2.458081,0.489983 -3.575515,1.088851c-1.116072,0.598868 -2.332863,1.088851 -2.701712,1.088851c-0.367487,0 -1.474032,0.34571 -2.45672,0.766279c-0.984049,0.42193 -3.760619,1.510781 -6.172425,2.41861c-5.022326,1.891879 -9.85138,4.230186 -10.326391,4.999187c-0.17966,0.289907 -0.828888,0.526732 -1.444089,0.526732c-0.615201,0 -2.071539,0.489983 -3.235249,1.088851c-6.794431,3.496573 -6.554883,3.357744 -13.833853,8.041165c-0.592063,0.379737 -1.921822,1.077963 -2.956231,1.551613c-1.99532,0.911913 -6.858401,4.472456 -10.91301,7.990806c-1.347453,1.169154 -3.297858,2.561522 -4.334988,3.095059c-3.552377,1.825187 -26.539384,24.504593 -28.481622,28.099163c-0.3076,0.570286 -2.326058,3.242054 -4.483344,5.93696c-2.158647,2.694906 -4.615367,6.124787 -5.461949,7.621957c-0.845221,1.49717 -3.168557,5.294538 -5.161154,8.438596c-3.491129,5.508225 -5.938322,10.210701 -6.799875,13.066213c-0.225937,0.748585 -0.582535,1.48356 -0.792139,1.633277c-0.596146,0.427374 -4.05597,7.966307 -5.995486,13.066213c-0.967716,2.545189 -2.20084,5.730079 -2.741183,7.077532c-0.538981,1.347453 -1.154182,3.616347 -1.365147,5.042742c-0.210965,1.426395 -0.579813,2.713961 -0.817999,2.860956c-0.239547,0.146995 -0.594785,1.307982 -0.792139,2.579216c-0.195993,1.271234 -0.820721,3.781035 -1.389646,5.57764c-1.009909,3.193056 -2.429499,10.742877 -4.026027,21.420423c-1.751689,11.720121 -1.6115,34.400889 0.28174,45.543918c1.401896,8.254852 2.867762,15.540627 3.778313,18.782681c0.547148,1.946321 1.512142,5.621194 2.143676,8.166383c1.450894,5.840325 3.349578,11.92428 4.163494,13.338426c0.344349,0.598868 0.790778,1.796604 0.992216,2.662241c0.201437,0.865637 1.85513,4.663005 3.674872,8.438596c1.819742,3.775591 3.94028,8.212659 4.713364,9.859546c1.886434,4.016499 4.88758,9.195347 6.368418,10.986507c0.662838,0.803028 1.763939,2.640464 2.447193,4.083192c0.681893,1.444089 2.025263,3.604097 2.983452,4.801833c0.958189,1.197736 3.331884,4.31185 5.275483,6.92101c5.642971,7.57432 16.287851,19.053533 24.05272,25.939155c8.062942,7.149668 23.060505,18.044984 28.917162,21.006659c0.898302,0.454595 2.000764,1.079324 2.449915,1.389646c1.528475,1.056186 17.589028,9.257956 18.128009,9.257956c0.29399,0 1.542085,0.453234 2.772487,1.007187c1.230402,0.555314 3.952529,1.56114 6.048568,2.236228c2.096038,0.675088 5.316315,1.811576 7.157835,2.526134c1.840158,0.713197 5.270039,1.770744 7.621957,2.349196c2.350557,0.578452 5.500059,1.41959 6.997229,1.868741c1.49717,0.449151 4.533704,1.088851 6.749516,1.420951c2.214451,0.3321 4.236992,0.733613 4.494233,0.892858c0.740419,0.457317 25.266789,2.373695 30.677018,2.395472c6.612048,0.028582 26.310725,-1.536641 31.032256,-2.464887c2.096038,-0.412402 5.280928,-0.993577 7.077532,-1.29165c4.584063,-0.760835 15.041116,-3.638124 19.044005,-5.238735c1.849686,-0.740419 3.659901,-1.346092 4.021944,-1.346092c0.363404,0 1.621027,-0.489983 2.794264,-1.088851c1.173237,-0.598868 2.572411,-1.097017 3.10867,-1.107906c0.536259,-0.009527 1.954488,-0.491344 3.152224,-1.069796c1.197736,-0.578452 2.591466,-1.060269 3.097781,-1.069796c0.506316,-0.010889 1.084768,-0.283101 1.284844,-0.607034c0.198715,-0.322572 2.479858,-1.565223 5.067241,-2.758876c2.587382,-1.195014 5.195181,-2.441749 5.794049,-2.769765c0.598868,-0.329377 2.664963,-1.41959 4.592229,-2.424055c1.925905,-1.005826 4.253324,-2.394111 5.172043,-3.085532c0.917357,-0.69142 3.383605,-2.29067 5.479643,-3.552377c4.156689,-2.502996 4.586785,-2.803792 12.440123,-8.71217c2.938537,-2.210368 5.47556,-4.36221 5.636165,-4.784139c0.161967,-0.420569 1.024881,-1.143294 1.9191,-1.604694c1.826548,-0.944578 16.306906,-15.235749 18.3975,-18.156592c0.74178,-1.037131 1.966737,-2.50708 2.719406,-3.266553c1.420951,-1.431839 11.42477,-14.564744 11.42477,-14.998923c0,-0.465484 3.444853,-5.979153 4.42618,-7.082976c1.229041,-1.382841 3.003868,-4.590868 6.017263,-10.873539c1.29165,-2.694906 3.304663,-6.735905 4.472456,-8.980299c2.11101,-4.058692 5.230568,-12.079442 6.618853,-17.020103c0.400153,-1.423673 0.858831,-2.803792 1.020798,-3.065116c0.83161,-1.344731 5.430645,-19.399243 5.841686,-22.92712c0.261324,-2.245755 0.871081,-5.920628 1.35562,-8.166383c1.105184,-5.121683 1.320232,-44.461872 0.262685,-48.259241c-0.344349,-1.239929 -0.973161,-4.72153 -1.396451,-7.737648c-1.083407,-7.718593 -7.372883,-30.174785 -10.179396,-36.343127c-0.559397,-1.230402 -1.018076,-2.500274 -1.018076,-2.822846c0,-0.322572 -1.898684,-4.344516 -4.219298,-8.939467c-2.320614,-4.594952 -4.464289,-8.883664 -4.763723,-9.530169c-1.159626,-2.502996 -4.740585,-8.382792 -6.545356,-10.748321c-1.041214,-1.363786 -1.89324,-2.588743 -1.89324,-2.723489c0,-0.249075 -1.996681,-3.335967 -3.683039,-5.696052c-2.535662,-3.548293 -10.525107,-13.25404 -13.699108,-16.64445c-6.912843,-7.38241 -18.505024,-18.027291 -22.360918,-20.533009c-1.646887,-1.069796 -4.193438,-3.013395 -5.657942,-4.317294c-1.465866,-1.303899 -4.20977,-3.228443 -6.100288,-4.276463c-1.889157,-1.048019 -5.834881,-3.405382 -8.769334,-5.237374c-6.059456,-3.78648 -11.548627,-6.737266 -12.532676,-6.738627c-0.366126,-0.001361 -2.268893,-0.865637 -4.226103,-1.923183c-1.95721,-1.056186 -5.576279,-2.684018 -8.043887,-3.616347c-2.466248,-0.932329 -6.07715,-2.298837 -8.023471,-3.035172c-1.946321,-0.736336 -5.498698,-1.818381 -7.89417,-2.403639c-2.395472,-0.585257 -5.702857,-1.411423 -7.349745,-1.834714c-18.873872,-4.848109 -36.795,-6.411972 -58.525745,-5.102628m28.854553,117.157653c1.197736,0.446429 4.015138,1.367869 6.260894,2.045679c6.964564,2.102844 17.480143,7.97039 22.55555,12.587118c6.481386,5.896129 8.109218,7.74037 11.973279,13.576612c2.062012,3.112753 4.200243,6.323503 4.752835,7.134697c0.553953,0.811194 1.013993,1.668664 1.024881,1.905489c0.009527,0.236825 0.491344,1.410062 1.069796,2.607798c0.578452,1.197736 1.060269,2.59691 1.069796,3.110031c0.010889,0.513121 0.476372,2.105566 1.03577,3.538766c3.972945,10.186202 3.891282,30.968286 -0.161967,40.562425c-0.469567,1.11335 -0.854748,2.583299 -0.856109,3.266553c-0.002722,4.72153 -11.650706,21.46806 -19.022228,27.349217c-2.027985,1.618305 -4.028749,3.278803 -4.445234,3.689844c-1.092934,1.076601 -12.779028,8.041165 -13.492226,8.041165c-0.329377,0 -2.132787,0.496788 -4.00425,1.105184c-1.872824,0.607034 -4.507843,1.450894 -5.855297,1.875546c-8.905441,2.806514 -25.196014,2.545189 -35.38766,-0.567564c-2.545189,-0.777167 -5.730079,-1.738079 -7.077532,-2.135509c-6.784903,-2.003486 -17.921128,-9.826881 -24.522287,-17.228346c-2.232145,-2.505719 -4.344516,-4.799111 -4.691587,-5.098545c-0.348432,-0.299434 -1.742162,-2.673129 -3.100503,-5.274122c-1.356981,-2.600993 -3.061033,-5.663387 -3.78648,-6.805319c-5.721912,-9.010243 -7.971751,-35.714315 -3.952529,-46.922676c0.470928,-1.310704 0.854748,-2.723489 0.854748,-3.139974c0,-1.224957 5.870268,-13.06213 7.773036,-15.675372c0.231381,-0.318489 1.181403,-1.754411 2.109649,-3.191695c1.833353,-2.839179 10.141287,-11.190667 14.072039,-14.148259c7.559349,-5.686525 18.187896,-10.310059 30.215617,-13.143793c2.652713,-0.624728 23.442964,0.134745 25.588,0.935051" id="path0"/>
</g>
</template>
1 change: 1 addition & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
"balance": "Balance",
"comments_label": "Comment",
"commission_label": "Transfer fee",
"commission_estimate_label": "Estimated transfer fee",
"confirm_approve": "Confirm",
"confirm_cancel": "Cancel",
"confirm_message": "Confirm transfer of <b>{amount} {crypto}</b> to address <span class=\"address-in-confirm\">{address}</span>.",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@
"balance": "Баланс",
"comments_label": "Комментарий",
"commission_label": "Комиссия за перевод",
"commission_estimate_label": "Приблизительная комиссия за перевод",
"confirm_approve": "Подтвердить",
"confirm_cancel": "Отмена",
"confirm_message": "Подтвердите перевод <b>{amount} {crypto}</b> на адрес <span class=\"address-in-confirm\">{address}</span>.",
Expand Down
25 changes: 20 additions & 5 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export const BTC_BASED = Object.freeze([

export const isErc20 = crypto => ERC20.includes(crypto)

export const isEthBased = crypto => isErc20(crypto) || crypto === Cryptos.ETH

export const isFeeEstimate = crypto => isEthBased(crypto)

export const isBtcBased = crypto => BTC_BASED.includes(crypto)

/** Number of decimal places for the different crypto amounts */
Expand Down Expand Up @@ -88,7 +92,7 @@ export const CryptoNaturalUnits = {
export const Fees = {
/** Storing a value into the KVS */
KVS: 0.001,
/** Transfering tokens */
/** Transferring tokens */
ADM_TRANSFER: 0.5,
NOT_ADM_TRANSFER: 0.001
}
Expand Down Expand Up @@ -117,11 +121,22 @@ export const WelcomeMessage = {
ADAMANT_ICO: 'ADAMANT Tokens'
}

/** Gas value for the ETH transfers */
export const ETH_TRANSFER_GAS = 21000
/**
* These gas limit values are used only for estimate fees for ETH & ERC-20 transfers in the Send tokens form,
* Actual gas limit values are calculated with estimateGas(transactionObject)
* when each specific transaction is created
*/

/** Gas limit value for the ETH transfers */
export const ETH_TRANSFER_GAS = 22000 // Default gas limit; while to be calculated with estimateGas(transactionObject)
/** Gas limit value for the ERC-20 transfers */
export const ERC20_TRANSFER_GAS = ETH_TRANSFER_GAS * 2

/** Gas price multiplier. To be sure a transaction will be confirmed */
export const ETH_GASPRICE_MULTIPLIER = 1.1

/** Gas value for the ERC-20 transfers */
export const ERC20_TRANSFER_GAS = ETH_TRANSFER_GAS * 10
/** Increase fee multiplier. Used in SendFundsForm */
export const INCREASE_FEE_MULTIPLIER = 2

export default {
EPOCH,
Expand Down
30 changes: 27 additions & 3 deletions src/lib/textHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,37 @@
export function copyToClipboard (data) {
let el = document.createElement('textarea')
el.value = data

document.body.appendChild(el)
el.select()
document.execCommand('copy')

var isiOSDevice = navigator.userAgent.match(/ipad|iphone/i)
if (isiOSDevice) {
copyToClipboardIos(el)
} else {
el.select()
document.execCommand('copy')
}
document.body.removeChild(el)
}

/**
* Copy to clipboard helper for iOS devices
*
* @param {HTMLTextAreaElement} el
*/
function copyToClipboardIos (el) {
var range = document.createRange()
el.contentEditable = true
el.readOnly = false
range.selectNodeContents(el)

var s = window.getSelection()
s.removeAllRanges()
s.addRange(range)
el.setSelectionRange(0, 999999) // A big number, to cover anything that could be inside the element.

document.execCommand('copy')
}

/**
* Download file helper.
*
Expand Down
14 changes: 10 additions & 4 deletions src/store/modules/erc20/erc20-actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abiDecoder from 'abi-decoder'

import * as ethUtils from '../../../lib/eth-utils'
import { ERC20_TRANSFER_GAS } from '../../../lib/constants'
import { INCREASE_FEE_MULTIPLIER } from '../../../lib/constants'
import Erc20 from './erc20.abi.json'
import createActions from '../eth-base/eth-base-actions'

Expand All @@ -13,17 +13,23 @@ const STATUS_INTERVAL = 8000
// Setup decoder
abiDecoder.addABI(Erc20)

const initTransaction = (api, context, ethAddress, amount) => {
const initTransaction = (api, context, ethAddress, amount, increaseFee) => {
const contract = api.eth.contract(Erc20).at(context.state.contractAddress)

return {
const transaction = {
from: context.state.address,
to: context.state.contractAddress,
value: api.fromDecimal('0'),
gasLimit: api.fromDecimal(ERC20_TRANSFER_GAS),
// gasLimit: api.fromDecimal(ERC20_TRANSFER_GAS), // Don't take default value, instead calculate with estimateGas(transactionObject)
gasPrice: api.fromDecimal(context.getters.gasPrice),
data: contract.transfer.getData(ethAddress, ethUtils.toWhole(amount, context.state.decimals))
}

let gasLimit = api.eth.estimateGas(transaction)
gasLimit = increaseFee ? (gasLimit * INCREASE_FEE_MULTIPLIER).toString(16) : gasLimit.toString(16)
transaction.gas = '0x' + gasLimit

return transaction
}

const parseTransaction = (context, tx) => {
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/eth-base/eth-base-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ export default function createActions (config) {
}
},

sendTokens (context, { amount, admAddress, address, comments }) {
sendTokens (context, { amount, admAddress, address, comments, increaseFee }) {
address = address.trim()
const crypto = context.state.crypto
const ethTx = initTransaction(api, context, address, amount)
const ethTx = initTransaction(api, context, address, amount, increaseFee)

return utils.promisify(api.eth.getTransactionCount, context.state.address, 'pending')
.then(count => {
Expand Down
Loading

0 comments on commit 694a1bd

Please sign in to comment.