WA-238 Fixing error of safes 1+ owners and threshold 1 when sending txs

This commit is contained in:
apanizo 2018-05-29 09:31:48 +02:00
parent a7076b9a1a
commit cfdbc8a761
4 changed files with 33 additions and 33 deletions

View File

@ -94,7 +94,8 @@ export const createTransaction = async (
const valueInWei = web3.toWei(txValue, 'ether') const valueInWei = web3.toWei(txValue, 'ether')
const CALL = 0 const CALL = 0
if (hasOneOwner(safe)) { const thresholdIsOne = safe.get('confirmations') === 1
if (hasOneOwner(safe) || thresholdIsOne) {
const txReceipt = await gnosisSafe.execTransactionIfApproved(txDestination, valueInWei, '0x', CALL, nonce, { from: user, gas: '5000000' }) const txReceipt = await gnosisSafe.execTransactionIfApproved(txDestination, valueInWei, '0x', CALL, nonce, { from: user, gas: '5000000' })
const executedConfirmations: List<Confirmation> = buildExecutedConfirmationFrom(safe.get('owners'), user) const executedConfirmations: List<Confirmation> = buildExecutedConfirmationFrom(safe.get('owners'), user)
return storeTransaction(txName, nonce, txDestination, txValue, user, executedConfirmations, txReceipt.tx, safeAddress, safe.get('confirmations')) return storeTransaction(txName, nonce, txDestination, txValue, user, executedConfirmations, txReceipt.tx, safeAddress, safe.get('confirmations'))

View File

@ -21,6 +21,7 @@ const styles = {
type Props = Open & WithStyles & { type Props = Open & WithStyles & {
confirmations: List<Confirmation>, confirmations: List<Confirmation>,
threshold: number,
} }
const GnoConfirmation = ({ owner, status, hash }: ConfirmationProps) => { const GnoConfirmation = ({ owner, status, hash }: ConfirmationProps) => {
@ -45,35 +46,31 @@ const GnoConfirmation = ({ owner, status, hash }: ConfirmationProps) => {
} }
const Confirmaitons = openHoc(({ const Confirmaitons = openHoc(({
open, toggle, confirmations, open, toggle, confirmations, threshold,
}: Props) => { }: Props) => (
const threshold = confirmations.count() <React.Fragment>
<ListItem onClick={toggle}>
return ( <Avatar>
<React.Fragment> <Group />
<ListItem onClick={toggle}> </Avatar>
<Avatar> <ListItemText primary="Threshold" secondary={`${threshold} confirmation${threshold === 1 ? '' : 's'} needed`} />
<Group /> <ListItemIcon>
</Avatar> {open ? <ExpandLess /> : <ExpandMore />}
<ListItemText primary="Threshold" secondary={`${threshold} confirmation${threshold === 1 ? '' : 's'} needed`} /> </ListItemIcon>
<ListItemIcon> </ListItem>
{open ? <ExpandLess /> : <ExpandMore />} <Collapse in={open} timeout="auto" unmountOnExit>
</ListItemIcon> <List component="div" disablePadding style={{ width: '100%' }}>
</ListItem> {confirmations.map(confirmation => (
<Collapse in={open} timeout="auto" unmountOnExit> <GnoConfirmation
<List component="div" disablePadding style={{ width: '100%' }}> key={confirmation.get('owner').get('address')}
{confirmations.map(confirmation => ( owner={confirmation.get('owner')}
<GnoConfirmation status={confirmation.get('status')}
key={confirmation.get('owner').get('address')} hash={confirmation.get('hash')}
owner={confirmation.get('owner')} />
status={confirmation.get('status')} ))}
hash={confirmation.get('hash')} </List>
/> </Collapse>
))} </React.Fragment>
</List> ))
</Collapse>
</React.Fragment>
)
})
export default withStyles(styles)(Confirmaitons) export default withStyles(styles)(Confirmaitons)

View File

@ -15,6 +15,7 @@ type Props = {
safeName: string, safeName: string,
confirmations: ImmutableList<Confirmation>, confirmations: ImmutableList<Confirmation>,
destination: string, destination: string,
threshold: number,
} }
const listStyle = { const listStyle = {
@ -24,7 +25,7 @@ const listStyle = {
class Collapsed extends React.PureComponent<Props, {}> { class Collapsed extends React.PureComponent<Props, {}> {
render() { render() {
const { const {
confirmations, destination, safeName, confirmations, destination, safeName, threshold,
} = this.props } = this.props
return ( return (
@ -35,7 +36,7 @@ class Collapsed extends React.PureComponent<Props, {}> {
<Avatar><Group /></Avatar> <Avatar><Group /></Avatar>
<ListItemText primary={safeName} secondary="Safe Name" /> <ListItemText primary={safeName} secondary="Safe Name" />
</ListItem> </ListItem>
<Confirmations confirmations={confirmations} /> <Confirmations confirmations={confirmations} threshold={threshold} />
<ListItem> <ListItem>
<Avatar><MailOutline /></Avatar> <Avatar><MailOutline /></Avatar>
<ListItemText primary="Destination" secondary={destination} /> <ListItemText primary="Destination" secondary={destination} />

View File

@ -82,6 +82,7 @@ class GnoTransaction extends React.PureComponent<Props, {}> {
safeName={safeName} safeName={safeName}
confirmations={transaction.get('confirmations')} confirmations={transaction.get('confirmations')}
destination={transaction.get('destination')} destination={transaction.get('destination')}
threshold={transaction.get('threshold')}
/> } /> }
<Hairline /> <Hairline />
</React.Fragment> </React.Fragment>