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

Commit

Permalink
MultiSig Wallet Revoke #3282
Browse files Browse the repository at this point in the history
  • Loading branch information
ngotchac committed Dec 1, 2016
1 parent 124f534 commit f200fa2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 12 deletions.
47 changes: 47 additions & 0 deletions js/src/redux/providers/walletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,42 @@ export function confirmOperation (address, owner, operation) {
};
}

export function revokeOperation (address, owner, operation) {
return (dispatch, getState) => {
const { api } = getState();
const contract = new Contract(api, WALLET_ABI).at(address);

const options = {
from: owner,
gas: MAX_GAS_ESTIMATION
};

const values = [ operation ];

contract.instance
.revoke
.estimateGas(options, values)
.then((gas) => {
options.gas = gas;
return contract.instance.revoke.postTransaction(options, values);
})
.then((requestId) => {
return api
.pollMethod('parity_checkRequest', requestId)
.catch((e) => {
if (e.code === ERROR_CODES.REQUEST_REJECTED) {
return;
}

throw e;
});
})
.catch((error) => {
dispatch(newError(error));
});
};
}

export function attachWallets (_wallets) {
return (dispatch, getState) => {
const { wallet, api } = getState();
Expand Down Expand Up @@ -246,6 +282,17 @@ function fetchWalletTransactions (contract) {
.getAll({
topics: [ [ signatures.single, signatures.multi, signatures.deposit ] ]
})
.then((logs) => {
return logs.sort((logA, logB) => {
const comp = logB.blockNumber.comparedTo(logA.blockNumber);

if (comp !== 0) {
return comp;
}

return logB.transactionIndex.comparedTo(logA.transactionIndex);
});
})
.then((logs) => {
const transactions = logs.map((log) => {
const signature = toHex(log.topics[0]);
Expand Down
13 changes: 8 additions & 5 deletions js/src/views/Wallet/Confirmations/confirmations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ReactTooltip from 'react-tooltip';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import { confirmOperation } from '../../../redux/providers/walletActions';
import { confirmOperation, revokeOperation } from '../../../redux/providers/walletActions';
import { bytesToHex } from '../../../api/util/format';
import { Container, InputAddress, Button, IdentityIcon } from '../../../ui';
import { TxRow } from '../../../ui/TxList/txList';
Expand All @@ -40,6 +40,7 @@ class WalletConfirmations extends Component {
owners: PropTypes.array.isRequired,
require: PropTypes.object.isRequired,
confirmOperation: PropTypes.func.isRequired,
revokeOperation: PropTypes.func.isRequired,

confirmations: PropTypes.array
};
Expand Down Expand Up @@ -90,7 +91,8 @@ function mapStateToProps (state) {

function mapDispatchToProps (dispatch) {
return bindActionCreators({
confirmOperation
confirmOperation,
revokeOperation
}, dispatch);
}

Expand All @@ -107,7 +109,8 @@ class WalletConfirmation extends Component {
isTest: PropTypes.bool.isRequired,
owners: PropTypes.array.isRequired,
require: PropTypes.object.isRequired,
confirmOperation: PropTypes.func.isRequired
confirmOperation: PropTypes.func.isRequired,
revokeOperation: PropTypes.func.isRequired
};

state = {
Expand Down Expand Up @@ -172,10 +175,10 @@ class WalletConfirmation extends Component {
}

handleRevoke = (e, item) => {
const { confirmOperation, confirmation, address } = this.props;
const { revokeOperation, confirmation, address } = this.props;
const owner = item.props.value;

confirmOperation(address, owner, confirmation.operation);
revokeOperation(address, owner, confirmation.operation);
}

renderActions (confirmation, className) {
Expand Down
18 changes: 11 additions & 7 deletions js/src/views/Wallet/Transactions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ export default class WalletTransactions extends Component {
return (
<div>
<Container title='Transactions'>
<table className={ txListStyles.transactions }>
<tbody>
{ this.renderTransactions() }
</tbody>
</table>
{ this.renderTransactions() }
</Container>
</div>
);
Expand All @@ -61,21 +57,29 @@ export default class WalletTransactions extends Component {
);
}

return transactions.map((transaction) => {
const txRows = transactions.map((transaction) => {
const { transactionHash, blockNumber, from, to, value, data } = transaction;

return (
<TxRow
key={ transactionHash }
tx={ {
hash: transactionHash,
input: data,
input: data && bytesToHex(data) || '',
blockNumber, from, to, value
} }
address={ address }
isTest={ isTest }
/>
);
});

return (
<table className={ txListStyles.transactions }>
<tbody>
{ txRows }
</tbody>
</table>
);
}
}

0 comments on commit f200fa2

Please sign in to comment.