Skip to content

Commit

Permalink
Merge pull request #15 from bitshares/bitshares
Browse files Browse the repository at this point in the history
Merge from master
  • Loading branch information
testzcrypto committed Mar 28, 2017
2 parents de2d702 + 82b56d1 commit 8caff39
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 77 deletions.
2 changes: 1 addition & 1 deletion electron/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "BitShares2-light",
"identifier": "org.bitshares.graphene",
"description": "BitShares - cryptocurrency and decentralized exchange",
"version": "2.0.170327",
"version": "2.0.170328",
"author": "community@bitshares.org",
"main": "electron.js",
"config": {
Expand Down
21 changes: 15 additions & 6 deletions web/app/actions/WalletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ class WalletActions {
createAccountWithPassword( account_name, password, registrar, referrer, referrer_percent, refcode ) {
let {privKey : owner_private} = WalletDb.generateKeyFromPassword(account_name, "owner", password);
let {privKey: active_private} = WalletDb.generateKeyFromPassword(account_name, "active", password);
//let memo_private = WalletDb.generateNextKey()
console.log("create account:", account_name);
console.log("new active pubkey", active_private.toPublicKey().toPublicKeyString());
console.log("new owner pubkey", owner_private.toPublicKey().toPublicKeyString());

return new Promise((resolve, reject) => {
let create_account = () => {
return application_api.create_account(
owner_private.private_key.toPublicKey().toPublicKeyString(),
active_private.private_key.toPublicKey().toPublicKeyString(),
owner_private.toPublicKey().toPublicKeyString(),
active_private.toPublicKey().toPublicKeyString(),
account_name,
registrar, //registrar_id,
referrer, //referrer_id,
Expand Down Expand Up @@ -86,13 +88,20 @@ class WalletActions {
"referrer": referrer
}
})
}).then(r => resolve(r.json()));
}).then(r => r.json().then(res => {
if (!res || (res && res.error)) {
reject(res.error);
} else {
resolve(res);
}
})).catch(reject);

return create_account_promise.then(result => {
if (result.error) {
if (result && result.error) {
reject(result.error);
} else {
resolve(result);
}
resolve(result);
}).catch(error => {
reject(error);
});
Expand Down
3 changes: 2 additions & 1 deletion web/app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@
"new_memo": "New memo key",
"memo_warning": "WARNING: If you replace the memo key you will be unable to read old memos when logging in with your password, and unless you import the new memo private key into your old wallet that wallet will be unable to decode new memos",
"use_text": "Use",
"remove_text": "Remove"
"remove_text": "Remove",
"valid_pub": "Valid Public Key"
},
"votes": {
"proxy_current": "Your current proxy is",
Expand Down
5 changes: 5 additions & 0 deletions web/app/assets/stylesheets/themes/_theme-template.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1223,4 +1223,9 @@
}
}
}

input.my-key, td.my-key a {
font-weight: bold;
color: $info-color;
}
}
62 changes: 45 additions & 17 deletions web/app/components/Account/AccountOverview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class AccountOverview extends React.Component {
}

_getSeparator(render) {
return render ? <span> | </span> : null;
return render ? <span>&nbsp;|&nbsp;</span> : null;
}

_onNavigate(route, e) {
Expand All @@ -99,20 +99,35 @@ class AccountOverview extends React.Component {
}

_renderBalances(balanceList, optionalAssets, visible) {
const core_asset = ChainStore.getAsset("1.3.0");
let {settings, hiddenAssets, orders} = this.props;
let preferredUnit = settings.get("unit") || "1.3.0";
let showAssetPercent = settings.get("showAssetPercent", false);

const renderBorrow = (asset, account) => {
let isBitAsset = asset && asset.has("bitasset_data_id");
let modalRef = "cp_modal_" + asset.get("id");
return {
isBitAsset,
borrowModal: !isBitAsset ? null : <BorrowModal
ref={modalRef}
quote_asset={asset.get("id")}
backing_asset={asset.getIn(["bitasset", "options", "short_backing_asset"])}
account={account}
/>,
borrowLink: !isBitAsset ? null : <a onClick={() => {ReactTooltip.hide();this.refs[modalRef].show();}}><Translate content="exchange.borrow" /></a>
};
};

let balances = [], openOrders = [];
balanceList.forEach( balance => {
let balanceObject = ChainStore.getObject(balance);
let asset_type = balanceObject.get("asset_type");
let asset = ChainStore.getObject(asset_type);
let isBitAsset = asset && asset.has("bitasset_data_id");
const core_asset = ChainStore.getAsset("1.3.0");


let assetInfoLinks;
let marketLink, directMarketLink, settleLink, transferLink, borrowLink, borrowModal;
let marketLink, directMarketLink, settleLink, transferLink;
let symbol = "";
if (!asset) return null;

Expand All @@ -131,17 +146,20 @@ class AccountOverview extends React.Component {
directMarketLink = notCore ? <Link to={`/market/${asset.get("symbol")}_${preferredMarket}`}><Translate content="account.trade" /></Link> : null;
transferLink = <Link to={`/transfer?asset=${asset.get("id")}`}><Translate content="transaction.trxTypes.transfer" /></Link>;

if (isBitAsset) {
let modalRef = "cp_modal_" + asset.get("id");
borrowModal = <BorrowModal
ref={modalRef}
quote_asset={asset.get("id")}
backing_asset={asset.getIn(["bitasset", "options", "short_backing_asset"])}
account={this.props.account}
/>;
let {isBitAsset, borrowModal, borrowLink} = renderBorrow(asset, this.props.account);
// if (isBitAsset) {

borrowLink = <a onClick={() => {ReactTooltip.hide();this.refs[modalRef].show();}}><Translate content="exchange.borrow" /></a>;
}

// let modalRef = "cp_modal_" + asset.get("id");
// borrowModal = <BorrowModal
// ref={modalRef}
// quote_asset={asset.get("id")}
// backing_asset={asset.getIn(["bitasset", "options", "short_backing_asset"])}
// account={this.props.account}
// />;
//
// borrowLink = <a onClick={() => {ReactTooltip.hide();this.refs[modalRef].show();}}><Translate content="exchange.borrow" /></a>;
// }

/* Popover content */
settleLink = <a href onClick={this._onSettleAsset.bind(this, asset.get("id"))}>
Expand Down Expand Up @@ -221,8 +239,8 @@ class AccountOverview extends React.Component {
</td>
<td style={{textAlign: "center"}}>
{directMarketLink}
{isBitAsset ? <div className="inline-block" data-place="bottom" data-tip={counterpart.translate("tooltip.borrow", {asset: symbol})}>&nbsp;| {borrowLink}{borrowModal}</div> : null}
{isBitAsset ? <div className="inline-block" data-place="bottom" data-tip={counterpart.translate("tooltip.settle", {asset: symbol})}>&nbsp;| {settleLink}</div> : null}
{isBitAsset ? <div className="inline-block" data-place="bottom" data-tip={counterpart.translate("tooltip.borrow", {asset: symbol})}>{this._getSeparator(true)}{borrowLink}{borrowModal}</div> : null}
{isBitAsset ? <div className="inline-block" data-place="bottom" data-tip={counterpart.translate("tooltip.settle", {asset: symbol})}>{this._getSeparator(true)}{settleLink}</div> : null}
</td>
<td style={{textAlign: "center"}} className="column-hide-small" data-place="bottom" data-tip={counterpart.translate("tooltip." + (includeAsset ? "hide_asset" : "show_asset"))}>
<a style={{marginRight: 0}} className={includeAsset ? "order-cancel" : "action-plus"} onClick={this._hideAsset.bind(this, asset_type, includeAsset)}>
Expand Down Expand Up @@ -259,6 +277,13 @@ class AccountOverview extends React.Component {

const canDepositWithdraw = !!this.props.backedCoins.get("OPEN", []).find(a => a.symbol === asset.get("symbol"));
const canBuy = !!this.props.bridgeCoins.get(asset.get("symbol"));

const notCore = asset.get("id") !== "1.3.0";
let {market} = assetUtils.parseDescription(asset.getIn(["options", "description"]));
if (asset.get("symbol").indexOf("OPEN.") !== -1 && !market) market = "USD";
let preferredMarket = market ? market : core_asset ? core_asset.get("symbol") : "BTS";
let directMarketLink = notCore ? <Link to={`/market/${asset.get("symbol")}_${preferredMarket}`}><Translate content="account.trade" /></Link> : null;
let {isBitAsset, borrowModal, borrowLink} = renderBorrow(asset, this.props.account);
if (includeAsset && visible || !includeAsset && !visible) balances.push(
<tr key={"zz" + a} style={{maxWidth: "100rem"}}>
<td style={{textAlign: "right"}}>
Expand All @@ -281,7 +306,10 @@ class AccountOverview extends React.Component {
</a>
</span> : null}
</td>
<td></td>
<td style={{textAlign: "center"}}>
{directMarketLink}
{isBitAsset ? <div className="inline-block" data-place="bottom" data-tip={counterpart.translate("tooltip.borrow", {asset: asset.get("symbol")})}> {this._getSeparator(!!directMarketLink)}{borrowLink}{borrowModal}</div> : null}
</td>
<td style={{textAlign: "center"}} className="column-hide-small" data-place="bottom" data-tip={counterpart.translate("tooltip." + (includeAsset ? "hide_asset" : "show_asset"))}>
<a style={{marginRight: 0}} className={includeAsset ? "order-cancel" : "action-plus"} onClick={this._hideAsset.bind(this, asset.get("id"), includeAsset)}>
<Icon name={includeAsset ? "cross-circle" : "plus-circle"} className="icon-14px" />
Expand Down
10 changes: 7 additions & 3 deletions web/app/components/Account/AccountPermissions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class AccountPermissions extends React.Component {
// console.log("-- AccountPermissions.onPublish -->", updateObject, s.memo_key);
var tr = wallet_api.new_transaction();
tr.add_type_operation("account_update", updateObject);
console.log("transaction:", JSON.stringify(tr.serialize()));
WalletDb.process_transaction(tr, null ,true);
}

Expand Down Expand Up @@ -205,7 +206,6 @@ class AccountPermissions extends React.Component {
}

onMemoKeyChanged(memo_key) {
console.log("onMemoKeyChanged", memo_key);
this.setState({memo_key});
}

Expand Down Expand Up @@ -321,13 +321,17 @@ class AccountPermissions extends React.Component {

<Tab title="account.perm.memo_key">
<HelpContent style={{maxWidth: "800px"}} path="components/AccountPermMemo" />
<PubKeyInput ref="memo_key" value={this.state.memo_key}
<PubKeyInput
ref="memo_key"
value={this.state.memo_key}
label="account.perm.memo_public_key"
placeholder="Public Key"
onChange={this.onMemoKeyChanged.bind(this)}
tabIndex={7}
/>



</Tab>

<Tab title="account.perm.password_model">
Expand Down Expand Up @@ -370,7 +374,7 @@ class AccountPermissions extends React.Component {
/>

</div>
)
);
}
}

Expand Down
61 changes: 36 additions & 25 deletions web/app/components/Account/AccountPermissionsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import PrivateKeyView from "components/PrivateKeyView";
import counterpart from "counterpart";
import utils from "common/utils";
import AddressIndex from "stores/AddressIndex";
import PrivateKeyStore from "stores/PrivateKeyStore";

class AccountPermissionRow extends React.Component {
static propTypes = {
Expand All @@ -35,19 +36,25 @@ class AccountPermissionRow extends React.Component {
let suffix = "_accounts";
let pubKey = this.props.pubkey;

const keys = PrivateKeyStore.getState().keys;

let has_private = false;

if (this.props.account) {
name = this.props.account.get("name");
item_id = this.props.account.get("id");
name_or_key = <Link to={`/account/${name}/permissions`}>{name}</Link>;
} else if (pubKey) {
name = item_id = this.props.pubkey;
name_or_key = <PrivateKeyView pubkey={this.props.pubkey}>{this.props.pubkey}</PrivateKeyView>
name = item_id = pubKey;
name_or_key = <PrivateKeyView pubkey={pubKey}>{pubKey}</PrivateKeyView>
suffix = "_keys";
has_private = keys.has(pubKey);
} else if (this.props.address) {
pubKey = this._lookUpPubKeyForAddress(this.props.address);
item_id = this.props.address;
name_or_key = !pubKey ? this.props.address : <PrivateKeyView pubkey={pubKey}>{pubKey}</PrivateKeyView>;
suffix = "_addresses";
has_private = keys.has(pubKey);
}

return (
Expand All @@ -63,7 +70,7 @@ class AccountPermissionRow extends React.Component {
</div>)
: null}
</td>
<td>{name_or_key}</td>
<td className={has_private ? "my-key" : ""}>{name_or_key}</td>
<td>{this.props.weights[item_id]}</td>
<td>
<button className="button outline" onClick={this.props.onRemoveItem.bind(this, item_id, suffix)}>
Expand Down Expand Up @@ -186,29 +193,33 @@ class AccountPermissionsList extends React.Component {
allowUppercase={true}
>
<input value={this.state.weight_input}
onChange={this.onWeightChanged.bind(this)}
className="weight-input"
type="number"
autoComplete="off"
placeholder={counterpart.translate("account.perm.weight")}
onKeyDown={this.onWeightKeyDown.bind(this)}
tabIndex={this.props.tabIndex + 1}/>
onChange={this.onWeightChanged.bind(this)}
className="weight-input"
type="number"
autoComplete="off"
placeholder={counterpart.translate("account.perm.weight")}
onKeyDown={this.onWeightKeyDown.bind(this)}
tabIndex={this.props.tabIndex + 1}
/>
</AccountSelector>
<table className="table">
<thead>
<tr>
<th style={{width: cw[0]}}></th>
<th style={{width: cw[1]}}><Translate content="account.perm.acct_or_key" /></th>
<th style={{width: cw[2]}}><Translate content="account.perm.weight" /></th>
<th style={{width: cw[3]}}><Translate content="account.perm.action" /></th>
</tr>
</thead>
<tbody>
{account_rows}
{key_rows}
{address_rows}
</tbody>
</table>

<div style={{paddingTop: "2rem"}}>
<table className="table">
<thead>
<tr>
<th style={{width: cw[0]}}></th>
<th style={{width: cw[1]}}><Translate content="account.perm.acct_or_key" /></th>
<th style={{width: cw[2]}}><Translate content="account.perm.weight" /></th>
<th style={{width: cw[3]}}><Translate content="account.perm.action" /></th>
</tr>
</thead>
<tbody>
{account_rows}
{key_rows}
{address_rows}
</tbody>
</table>
</div>
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions web/app/components/Account/AccountPermissionsMigrate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class AccountPermissionsMigrate extends React.Component {
active: this.props.account.getIn(["active", "weight_threshold"]),
owner: this.props.account.getIn(["owner", "weight_threshold"])
};
console.log("key", this.props[role], "weights", weights, "weight of role:", weights[role]);
this.props[role === "active" ? "onAddActive" : role === "owner" ? "onAddOwner" : "onSetMemo"](this.props[role], weights[role]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/Account/CreateAccountPassword.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class CreateAccountPassword extends React.Component {

<div>

{!this.state.showPass ? <div onClick={() => {this.setState({showPass: true});}} className="button"><Translate content="wallet.password_show" /></div> : <div><Translate content="settings.password" />: <pre style={{paddingTop: 20}} className="no-overflow">{this.state.pass}</pre></div>}
{!this.state.showPass ? <div onClick={() => {this.setState({showPass: true});}} className="button"><Translate content="wallet.password_show" /></div> : <div><h5><Translate content="settings.password" />:</h5><div style={{fontWeight: "bold", wordWrap: "break-word"}} className="no-overflow">{this.state.pass}</div></div>}
</div>
<div className="divider" />
<div onClick={() => {this.setState({step: 3});}} className="button"><Translate content="init_error.understand" /></div>
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/Forms/PasswordInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class PasswordInput extends Component {

const strength = pw(this.state.value || "");
/* Require a length of passwordLength + 50% for the max score */
const score = strength.score + Math.floor(this.state.value.length / (this.props.passwordLength * 1.5));
const score = Math.min(5, strength.score + Math.floor(this.state.value.length / (this.props.passwordLength * 1.5)));

return (
<div className="account-selector">
Expand Down

0 comments on commit 8caff39

Please sign in to comment.