Skip to content

Commit

Permalink
fix #514/9
Browse files Browse the repository at this point in the history
  • Loading branch information
b1acksun committed Nov 9, 2017
1 parent 4f7c5b7 commit b11bf7d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/components/modules/AssetCreate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import assetConstants from "app/utils/Assets/Constants";
import assetUtils from "app/utils/Assets/AssetsUtils";
import utils from 'app/utils/Assets/utils';
import {validate_asset_symbol} from 'app/utils/ChainValidation';
import { formatAmount } from 'app/utils/ParsersAndFormatters'
import {api} from 'golos-js'

let MAX_SAFE_INT = new big("9007199254740991");
Expand Down Expand Up @@ -159,6 +160,7 @@ class AssetCreate extends React.Component {
errors: {
max_supply: null
},
nameCost: null,
isValid: true,
flagBooleans: flagBooleans,
permissionBooleans: permissionBooleans,
Expand Down Expand Up @@ -288,6 +290,7 @@ class AssetCreate extends React.Component {
}

validateAssetName(assetName) {
const balance = this.props.account.balance.split(' ')[0];
let error = '';
let promise;
if (assetName.length > 0) {
Expand All @@ -296,6 +299,18 @@ class AssetCreate extends React.Component {
promise = api.getAssetsAsync([assetName]).then(res => {
return (res && res.length > 0 && res[0] != null) ? tt('user_issued_assets.exists') : '';
});

api.getNameCostAsync(assetName).then(res => {
let cost = res.split(' ')[0]
if (cost !== '0.000') {
this.setState({ nameCost: res })
if (parseInt(cost.split('.')[0]) > parseInt(balance.split('.')[0])) {
this.setState({ isValid: false, errors: { symbol: tt('asset_create_jsx.insufficent_funds')} })
}
} else {
this.setState({ nameCost: null })
}
});
}
}
if (promise) {
Expand Down Expand Up @@ -436,7 +451,7 @@ class AssetCreate extends React.Component {
render() {
const { core } = this.props;
const { errors, isValid, update, flagBooleans, permissionBooleans,
core_exchange_rate, is_prediction_market, isBitAsset, bitasset_opts } = this.state;
core_exchange_rate, is_prediction_market, isBitAsset, bitasset_opts, nameCost } = this.state;

// Loop over flags
let flags = [];
Expand Down Expand Up @@ -505,7 +520,8 @@ class AssetCreate extends React.Component {
onChange={this.onUpdateInput.bind(this, "symbol")}
/>
</label>
{ errors.symbol ? <p className="error">{errors.symbol}</p> : null}
{ nameCost && <p className="warning">{ tt('asset_create_jsx.ticker_name_cost') }: { nameCost } </p> }
{ errors.symbol ? <p className="error">{ errors.symbol }</p> : null }
</div>

<div className="column small-6">
Expand Down
2 changes: 2 additions & 0 deletions app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@
"confirm_title": "Confirm Create Asset",
"confirm_create_asset": "Do you really want to create %(asset)s ?",
"notification": "%(asset)s successfully created",
"insufficent_funds": "Insufficent funds",
"ticker_name_cost": "Name cost",
"help" : {
"permissions_first" : "Permissions define the available features for an asset. However, even if a feature is permitted, it must still be activated using the corresponding flag in order to be enforced by the blockchain.",
"permissions_second" : "After creation, you may only remove a given permission, you cannot enable a permission that was disabled on creation.",
Expand Down
2 changes: 2 additions & 0 deletions app/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,8 @@
"confirm_title": "Подтвердите создание актива",
"confirm_create_asset": "Вы действительно хотите выпустить %(asset)s актив?",
"notification": "Актив %(asset)s успешно создан",
"insufficent_funds": "Недостаточно средств",
"ticker_name_cost": "Стоимость имени",
"help" : {
"permissions_first" : "Разрешения определяют доступные для актива функции. Однако, даже если функция разрешена, она по-прежнему должна быть активирована с помощью соответствующего маркера, чтобы она исполнялась блокчейном.",
"permissions_second" : "После создания Вы можете только удалить данное разрешение, Вы не можете включить разрешение, которое было отключено при создании.",
Expand Down

0 comments on commit b11bf7d

Please sign in to comment.