Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Edit Multisig Wallet settings (#3740)
Browse files Browse the repository at this point in the history
* WIP Sending tokens in multi-sig wallet

* Working Token transfer for multi-sig wallet #3282

* Add operation hash to transfer modal

* Add existing wallet from address #3282

* Wallet delete redirect to Wallets/Accounts #3282

* Rightly check balance in Transfer // Get all accounts balances #3282

* Fix linting

* Better Header UI for Wallet

* Use the `~` webpack alias

* Use Webpack `~` alias

* Add `ETH` format to number typed input

* Fix wallet creation hint && eth input type

* Update dailylimit #3282

* Fix too long copied message

* WIP Wallet settings modification #3282

* WIP edit contract parameters #3282

* Edit Wallet parameters #3282

* Don't show wallets if none

* Fix Transfer for Wallet #3282

* Optimized version of contract code

* Fix wrong max in Wallet creation // Round gas in API
  • Loading branch information
ngotchac authored and jacogr committed Dec 8, 2016
1 parent 69e010b commit 715761a
Show file tree
Hide file tree
Showing 23 changed files with 1,034 additions and 118 deletions.
13 changes: 10 additions & 3 deletions js/src/api/format/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ export function inNumber10 (number) {
}

export function inNumber16 (number) {
if (isInstanceOf(number, BigNumber)) {
return inHex(number.toString(16));
const bn = isInstanceOf(number, BigNumber)
? number
: (new BigNumber(number || 0));

if (!bn.isInteger()) {
throw new Error(`[format/input::inNumber16] the given number is not an integer: ${bn.toFormat()}`);
}

return inHex((new BigNumber(number || 0)).toString(16));
return inHex(bn.toString(16));
}

export function inOptions (options) {
Expand All @@ -130,6 +134,9 @@ export function inOptions (options) {

case 'gas':
case 'gasPrice':
options[key] = inNumber16((new BigNumber(options[key])).round());
break;

case 'value':
case 'nonce':
options[key] = inNumber16(options[key]);
Expand Down
2 changes: 1 addition & 1 deletion js/src/contracts/code/wallet.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/src/modals/CreateWallet/WalletDetails/walletDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,17 @@ export default class WalletDetails extends Component {
onChange={ this.onRequiredChange }
param={ parseAbiType('uint') }
min={ 1 }
max={ wallet.owners.length + 1 }
/>

<TypedInput
label='wallet day limit'
hint='number of days to wait for other owners confirmation'
hint='amount of ETH spendable without confirmations'
value={ wallet.daylimit }
error={ errors.daylimit }
onChange={ this.onDaylimitChange }
param={ parseAbiType('uint') }
isEth
/>
</div>
</Form>
Expand Down
3 changes: 2 additions & 1 deletion js/src/modals/CreateWallet/WalletInfo/walletInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import React, { Component, PropTypes } from 'react';

import { CompletedStep, IdentityIcon, CopyToClipboard } from '~/ui';
import { fromWei } from '~/api/util/wei';

import styles from '../createWallet.css';

Expand Down Expand Up @@ -62,7 +63,7 @@ export default class WalletInfo extends Component {
<code>{ required }</code> owners are required to confirm a transaction.
</p>
<p>
The daily limit is set to <code>{ daylimit }</code>.
The daily limit is set to <code>{ fromWei(daylimit).toFormat() }</code> ETH.
</p>
</CompletedStep>
);
Expand Down
8 changes: 7 additions & 1 deletion js/src/modals/CreateWallet/WalletType/walletType.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ export default class WalletType extends Component {
return [
{
label: 'Multi-Sig wallet', key: 'MULTISIG',
description: 'A standard multi-signature Wallet'
description: (
<span>
<span>Create/Deploy a </span>
<a href='https://github.com/ethereum/dapp-bin/blob/master/wallet/wallet.sol' target='_blank'>standard multi-signature </a>
<span> Wallet</span>
</span>
)
},
{
label: 'Watch a wallet', key: 'WATCH',
Expand Down
2 changes: 1 addition & 1 deletion js/src/modals/CreateWallet/createWalletStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { observable, computed, action, transaction } from 'mobx';

import { validateUint, validateAddress, validateName } from '../../util/validation';
import { validateUint, validateAddress, validateName } from '~/util/validation';
import { ERROR_CODES } from '~/api/transport/error';

import Contract from '~/api/contract';
Expand Down
19 changes: 11 additions & 8 deletions js/src/modals/Transfer/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { bytesToHex } from '~/api/util/format';
import Contract from '~/api/contract';
import ERRORS from './errors';
import { ERROR_CODES } from '~/api/transport/error';
import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '../../util/constants';
import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '~/util/constants';

const TITLES = {
transfer: 'transfer details',
Expand Down Expand Up @@ -116,7 +116,6 @@ export default class TransferStore {
this.api = api;

const { account, balance, gasLimit, senders, onClose, newError, sendersBalances } = props;

this.account = account;
this.balance = balance;
this.gasLimit = gasLimit;
Expand Down Expand Up @@ -412,34 +411,38 @@ export default class TransferStore {
return;
}

const { gas, gasPrice, tag, valueAll, isEth } = this;
const { gas, gasPrice, tag, valueAll, isEth, isWallet } = this;

const gasTotal = new BigNumber(gasPrice || 0).mul(new BigNumber(gas || 0));

const availableEth = new BigNumber(balance.tokens[0].value);

const senderBalance = this.balance.tokens.find((b) => tag === b.token.tag);
const available = new BigNumber(senderBalance.value);
const format = new BigNumber(senderBalance.token.format || 1);
const available = isWallet
? this.api.util.fromWei(new BigNumber(senderBalance.value))
: (new BigNumber(senderBalance.value)).div(format);

let { value, valueError } = this;
let totalEth = gasTotal;
let totalError = null;

if (valueAll) {
if (isEth) {
if (isEth && !isWallet) {
const bn = this.api.util.fromWei(availableEth.minus(gasTotal));
value = (bn.lt(0) ? new BigNumber(0.0) : bn).toString();
} else if (isEth) {
value = (available.lt(0) ? new BigNumber(0.0) : available).toString();
} else {
value = available.div(format).toString();
value = available.toString();
}
}

if (isEth) {
if (isEth && !isWallet) {
totalEth = totalEth.plus(this.api.util.toWei(value || 0));
}

if (new BigNumber(value || 0).gt(available.div(format))) {
if (new BigNumber(value || 0).gt(available)) {
valueError = ERRORS.largeAmount;
} else if (valueError === ERRORS.largeAmount) {
valueError = null;
Expand Down
7 changes: 3 additions & 4 deletions js/src/modals/Transfer/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ class Transfer extends Component {
? (
<div>
<br />
<p>
This transaction needs confirmation from other owners.
<div>
<p>This transaction needs confirmation from other owners.</p>
<Input
style={ { width: '50%', margin: '0 auto' } }
value={ this.store.operation }
label='operation hash'
readOnly
allowCopy
/>
</p>
</div>
</div>
)
: null
Expand Down Expand Up @@ -298,7 +298,6 @@ function mapStateToProps (initState, initProps) {
return (state) => {
const { gasLimit } = state.nodeStatus;
const sendersBalances = senders ? pick(state.balances.balances, Object.keys(senders)) : null;

return { gasLimit, wallet, senders, sendersBalances };
};
}
Expand Down
17 changes: 17 additions & 0 deletions js/src/modals/WalletSettings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

export default from './walletSettings';
63 changes: 63 additions & 0 deletions js/src/modals/WalletSettings/walletSettings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* Copyright 2015, 2016 Ethcore (UK) Ltd.
/* This file is part of Parity.
/*
/* Parity is free software: you can redistribute it and/or modify
/* it under the terms of the GNU General Public License as published by
/* the Free Software Foundation, either version 3 of the License, or
/* (at your option) any later version.
/*
/* Parity is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/

.splitInput {
display: flex;
flex-direction: row;

> * {
flex: 1;

margin: 0 0.25em;

&:first-child {
margin-left: 0;
}

&:last-child {
margin-right: 0;
}
}
}

.change {
background-color: rgba(255, 255, 255, 0.1);
padding: 0.75em 1.75em;
margin-bottom: 1em;

&.add {
background-color: rgba(139, 195, 74, 0.5);
}

&.remove {
background-color: rgba(244, 67, 54, 0.5);
}

.label {
text-transform: uppercase;
margin-bottom: 0.5em;
margin-left: -1em;
font-size: 0.8em;
}
}

.eth:after {
content: 'ETH';
font-size: 0.75em;
margin-left: 0.125em;
}

Loading

0 comments on commit 715761a

Please sign in to comment.