Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@
}
},
"credit_offer": {
"override_authority_warning_p1": "%(symbol)s is controlled by its issuer",
"override_authority_warning_p2": "Do your own due diligence when using ",
"override_authority_warning": "Be careful, this asset has an `override_authority` setting, so the owner of the asset could transfer it back to himself with no agreement",
"total_to_repay": "Repay Total",
"current_available_balance": "Current Available Balance",
"accepted_pawn": "Acceptable",
"account": "Account",
"active": "Active",
Expand All @@ -589,7 +594,6 @@
"credit_offers": "Credit Offers",
"credit_right_account": "Account",
"credit_rights": "Credit Rights",
"current_available_balance": "Current Available Balance",
"current_balance": "Available",
"debt": "Debt",
"edit": "Modify credit offer",
Expand Down Expand Up @@ -631,7 +635,6 @@
"title_add_pawn": "Add collateral",
"title_add_whitelist": "Add white account",
"total_amount": "Total",
"total_to_repay": "Repay Total",
"validity_period": "Expiration",
"whitelist_account": "Account"
},
Expand Down
67 changes: 57 additions & 10 deletions app/components/Account/CreditOffer/CreditOfferPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
Button,
Table,
Form,
Icon as AntIcon
Icon as AntIcon,
Alert
} from "bitshares-ui-style-guide";
import assetUtils from "common/asset_utils";
import SearchInput from "../../Utility/SearchInput";
import LinkToAssetById from "../../Utility/LinkToAssetById";
import FormattedAsset from "../../Utility/FormattedAsset";
Expand Down Expand Up @@ -408,8 +410,11 @@ class CreditOfferPage extends React.Component {
precision: asset.get("precision")
});
this.setState({maxAmount: true});

this._onAmountChanged({amount: balance.getAmount({real: true}), asset: asset.get('id')})

this._onAmountChanged({
amount: balance.getAmount({real: true}),
asset: asset.get("id")
});
}
}

Expand Down Expand Up @@ -451,7 +456,12 @@ class CreditOfferPage extends React.Component {
let maxReal = maxAssetAmount.getAmount({real: true});
let maxError = amount > maxReal || maxReal <= 0;
const isSubmitNotValid =
!amount || minError || maxError || !selectAsset || balanceError || account.get("id") == info.owner_account;
!amount ||
minError ||
maxError ||
!selectAsset ||
balanceError ||
account.get("id") == info.owner_account;
let _error = maxError ? "has-error" : "";
if (currentBalance && currentBalance > 0) {
balance = (
Expand Down Expand Up @@ -491,6 +501,37 @@ class CreditOfferPage extends React.Component {
</span>
);
}

const borrowingAsset = selectAsset.toJS();
const borrowingAssetPermissions = assetUtils.getFlagBooleans(
borrowingAsset.options.flags,
!!borrowingAsset.bitasset_data_id
);

const issuer = ChainStore.getObject(
borrowingAsset.issuer,
false,
false
);
const issuerName = issuer ? issuer.get("name") : "";

let overrideAuthorityMessage = [
counterpart.translate(
"credit_offer.override_authority_warning_p1",
{symbol: borrowingAsset.symbol}
),
" ",
<a target="_blank" href={`/account/${issuerName}`}>
{issuerName}
</a>,
<br />,
counterpart.translate("credit_offer.override_authority_warning_p2"),
" ",
<a target="_blank" href={`/asset/${borrowingAsset.symbol}`}>
{borrowingAsset.symbol}
</a>
];

return (
<Modal
wrapClassName="modal--transaction-confirm"
Expand All @@ -500,12 +541,13 @@ class CreditOfferPage extends React.Component {
overlay={true}
onCancel={this.hideAcceptModal}
footer={[
info.owner_account === info.owner_account && (
<Translate
component="span"
content="credit_offer.info_borrow_err"
/>
) || null,
(info.owner_account === info.owner_account && (
<Translate
component="span"
content="credit_offer.info_borrow_err"
/>
)) ||
null,
<Button
key={"send"}
disabled={isSubmitNotValid}
Expand All @@ -518,6 +560,11 @@ class CreditOfferPage extends React.Component {
</Button>
]}
>
{borrowingAssetPermissions.override_authority && (
<div style={{marginBottom: 12}}>
<Alert message={overrideAuthorityMessage}></Alert>
</div>
)}
<div className="grid-block vertical no-overflow">
<Form className="full-width" layout="vertical">
<Form.Item
Expand Down