WA-234 Changing confirmations to threshold

This commit is contained in:
apanizo 2018-06-07 21:45:23 +02:00
parent 260e7e1280
commit 6cf958c1b5
10 changed files with 25 additions and 25 deletions

View File

@ -84,7 +84,7 @@ class AddOwner extends React.Component<Props, State> {
steps={steps}
onReset={this.onReset}
>
<Stepper.Page numOwners={safe.get('owners').count()} threshold={safe.get('confirmations')} addresses={addresses}>
<Stepper.Page numOwners={safe.get('owners').count()} threshold={safe.get('threshold')} addresses={addresses}>
{ AddOwnerForm }
</Stepper.Page>
<Stepper.Page>

View File

@ -101,7 +101,7 @@ export const createTransaction = async (
const valueInWei = web3.toWei(txValue, 'ether')
const CALL = 0
const thresholdIsOne = safe.get('confirmations') === 1
const thresholdIsOne = safe.get('threshold') === 1
if (hasOneOwner(safe) || thresholdIsOne) {
const txConfirmationData =
gnosisSafe.contract.execTransactionIfApproved.getData(txDest, valueInWei, data, CALL, nonce)
@ -109,7 +109,7 @@ export const createTransaction = async (
checkReceiptStatus(txHash)
const executedConfirmations: List<Confirmation> = buildExecutedConfirmationFrom(safe.get('owners'), user)
return storeTransaction(txName, nonce, txDest, txValue, user, executedConfirmations, txHash, safeAddress, safe.get('confirmations'), data)
return storeTransaction(txName, nonce, txDest, txValue, user, executedConfirmations, txHash, safeAddress, safe.get('threshold'), data)
}
const txConfirmationData =
@ -119,5 +119,5 @@ export const createTransaction = async (
const confirmations: List<Confirmation> = buildConfirmationsFrom(safe.get('owners'), user, txConfirmationHash)
return storeTransaction(txName, nonce, txDest, txValue, user, confirmations, '', safeAddress, safe.get('confirmations'), data)
return storeTransaction(txName, nonce, txDest, txValue, user, confirmations, '', safeAddress, safe.get('threshold'), data)
}

View File

@ -33,7 +33,7 @@ describe('Transactions Suite', () => {
const txName = 'Buy butteries for project'
const nonce: number = 10
const confirmations: List<Confirmation> = buildConfirmationsFrom(owners, 'foo', 'confirmationHash')
storeTransaction(txName, nonce, destination, value, 'foo', confirmations, '', safe.get('address'), safe.get('confirmations'), '0x')
storeTransaction(txName, nonce, destination, value, 'foo', confirmations, '', safe.get('address'), safe.get('threshold'), '0x')
// WHEN
const transactions: Map<string, List<Transaction>> = loadSafeTransactions()
@ -55,12 +55,12 @@ describe('Transactions Suite', () => {
const safeAddress = safe.get('address')
const creator = 'foo'
const confirmations: List<Confirmation> = buildConfirmationsFrom(owners, creator, 'confirmationHash')
storeTransaction(firstTxName, firstNonce, destination, value, creator, confirmations, '', safeAddress, safe.get('confirmations'), '0x')
storeTransaction(firstTxName, firstNonce, destination, value, creator, confirmations, '', safeAddress, safe.get('threshold'), '0x')
const secondTxName = 'Buy printers for project'
const secondNonce: number = firstNonce + 100
const secondConfirmations: List<Confirmation> = buildConfirmationsFrom(owners, creator, 'confirmationHash')
storeTransaction(secondTxName, secondNonce, destination, value, creator, secondConfirmations, '', safeAddress, safe.get('confirmations'), '0x')
storeTransaction(secondTxName, secondNonce, destination, value, creator, secondConfirmations, '', safeAddress, safe.get('threshold'), '0x')
// WHEN
const transactions: Map<string, List<Transaction>> = loadSafeTransactions()
@ -82,7 +82,7 @@ describe('Transactions Suite', () => {
const safeAddress = safe.address
const creator = 'foo'
const confirmations: List<Confirmation> = buildConfirmationsFrom(owners, creator, 'confirmationHash')
storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safeAddress, safe.get('confirmations'), '0x')
storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safeAddress, safe.get('threshold'), '0x')
const secondSafe = SafeFactory.dailyLimitSafe(10, 2)
const txSecondName = 'Buy batteris for Beta project'
@ -92,7 +92,7 @@ describe('Transactions Suite', () => {
const secondConfirmations: List<Confirmation> = buildConfirmationsFrom(secondSafe.get('owners'), secondCreator, 'confirmationHash')
storeTransaction(
txSecondName, txSecondNonce, destination, value, secondCreator,
secondConfirmations, '', secondSafeAddress, secondSafe.get('confirmations'), '0x',
secondConfirmations, '', secondSafeAddress, secondSafe.get('threshold'), '0x',
)
let transactions: Map<string, List<Transaction>> = loadSafeTransactions()
@ -112,7 +112,7 @@ describe('Transactions Suite', () => {
const txConfirmations: List<Confirmation> = buildConfirmationsFrom(owners, creator, 'secondConfirmationHash')
storeTransaction(
txFirstName, txFirstNonce, destination, value, creator,
txConfirmations, '', safe.get('address'), safe.get('confirmations'), '0x',
txConfirmations, '', safe.get('address'), safe.get('threshold'), '0x',
)
transactions = loadSafeTransactions()
@ -148,10 +148,10 @@ describe('Transactions Suite', () => {
const nonce: number = 10
const creator = 'foo'
const confirmations: List<Confirmation> = buildConfirmationsFrom(owners, creator, 'confirmationHash')
storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safe.get('address'), safe.get('confirmations'), '0x')
storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safe.get('address'), safe.get('threshold'), '0x')
// WHEN
const createTxFnc = () => storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safe.get('address'), safe.get('confirmations'), '0x')
const createTxFnc = () => storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safe.get('address'), safe.get('threshold'), '0x')
expect(createTxFnc).toThrow(/Transaction with same nonce/)
})
@ -161,7 +161,7 @@ describe('Transactions Suite', () => {
const nonce: number = 10
const creator = 'foo'
const confirmations: List<Confirmation> = buildConfirmationsFrom(owners, creator, 'confirmationHash')
storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safe.get('address'), safe.get('confirmations'), '0x')
storeTransaction(txName, nonce, destination, value, creator, confirmations, '', safe.get('address'), safe.get('threshold'), '0x')
// WHEN
const transactions: Map<string, List<Transaction>> = loadSafeTransactions()
@ -185,7 +185,7 @@ describe('Transactions Suite', () => {
const nonce: number = 10
const tx = ''
const confirmations: List<Confirmation> = buildExecutedConfirmationFrom(oneOwnerSafe.get('owners'), ownerName)
const createTxFnc = () => storeTransaction(txName, nonce, destination, value, ownerName, confirmations, tx, oneOwnerSafe.get('address'), oneOwnerSafe.get('confirmations'), '0x')
const createTxFnc = () => storeTransaction(txName, nonce, destination, value, ownerName, confirmations, tx, oneOwnerSafe.get('address'), oneOwnerSafe.get('threshold'), '0x')
expect(createTxFnc).toThrow(/The tx should be mined before storing it in safes with one owner/)
})
@ -197,7 +197,7 @@ describe('Transactions Suite', () => {
const nonce: number = 10
const tx = 'validTxHash'
const confirmations: List<Confirmation> = buildExecutedConfirmationFrom(oneOwnerSafe.get('owners'), ownerName)
storeTransaction(txName, nonce, destination, value, ownerName, confirmations, tx, oneOwnerSafe.get('address'), oneOwnerSafe.get('confirmations'), '0x')
storeTransaction(txName, nonce, destination, value, ownerName, confirmations, tx, oneOwnerSafe.get('address'), oneOwnerSafe.get('threshold'), '0x')
// WHEN
const safeTransactions: Map<string, List<Transaction>> = loadSafeTransactions()

View File

@ -70,7 +70,7 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
onAddOwner = () => {
const { safe } = this.props
this.setState({ component: <AddOwner threshold={safe.get('confirmations')} safe={safe} /> })
this.setState({ component: <AddOwner threshold={safe.get('threshold')} safe={safe} /> })
}
render() {
@ -83,7 +83,7 @@ class GnoSafe extends React.PureComponent<SafeProps, State> {
<List style={listStyle}>
<Balance balance={balance} />
<Owners owners={safe.owners} onAddOwner={this.onAddOwner} />
<Confirmations confirmations={safe.get('confirmations')} onEditThreshold={this.onEditThreshold} />
<Confirmations confirmations={safe.get('threshold')} onEditThreshold={this.onEditThreshold} />
<Address address={safe.get('address')} />
<DailyLimit balance={balance} dailyLimit={safe.get('dailyLimit')} onWithdrawn={this.onWithdrawn} />
<MultisigTx balance={balance} onAddTx={this.onAddTx} onSeeTxs={this.onListTransactions} />

View File

@ -20,7 +20,7 @@ const ThresholdForm = ({ numOwners, safe }: ThresholdProps) => () => (
{'Change safe\'s threshold'}
</Heading>
<Heading tag="h4" margin="lg">
{`Safe's owners: ${numOwners} and Safe's threshold: ${safe.get('confirmations')}`}
{`Safe's owners: ${numOwners} and Safe's threshold: ${safe.get('threshold')}`}
</Heading>
<Block margin="md">
<Field

View File

@ -20,14 +20,14 @@ const addSafe = createAction(
ADD_SAFE,
(
name: string, address: string,
confirmations: number, limit: number,
threshold: number, limit: number,
ownersName: string[], ownersAddress: string[],
): SafeProps => {
const owners: List<Owner> = buildOwnersFrom(ownersName, ownersAddress)
const dailyLimit: DailyLimit = buildDailyLimitFrom(limit)
return ({
address, name, confirmations, owners, dailyLimit,
address, name, threshold, owners, dailyLimit,
})
},
)

View File

@ -7,7 +7,7 @@ import type { Owner } from '~/routes/safe/store/model/owner'
export type SafeProps = {
name: string,
address: string,
confirmations: number,
threshold: number,
owners: List<Owner>,
dailyLimit: DailyLimit,
}
@ -15,7 +15,7 @@ export type SafeProps = {
export const makeSafe: RecordFactory<SafeProps> = Record({
name: '',
address: '',
confirmations: 0,
threshold: 0,
owners: List([]),
dailyLimit: makeDailyLimit(),
})

View File

@ -52,5 +52,5 @@ export default handleActions({
[UPDATE_DAILY_LIMIT]: (state: State, action: ActionType<typeof updateDailyLimit>): State =>
state.updateIn([action.payload.safeAddress, 'dailyLimit'], () => makeDailyLimit(action.payload.dailyLimit)),
[UPDATE_THRESHOLD]: (state: State, action: ActionType<typeof updateThreshold>): State =>
state.updateIn([action.payload.safeAddress, 'confirmations'], () => action.payload.threshold),
state.updateIn([action.payload.safeAddress, 'threshold'], () => action.payload.threshold),
}, Map())

View File

@ -20,7 +20,7 @@ class SafeBuilder {
}
withConfirmations(confirmations: number) {
this.safe = this.safe.set('confirmations', confirmations)
this.safe = this.safe.set('threshold', confirmations)
return this
}

View File

@ -32,7 +32,7 @@ const SafeTable = ({ safes }: Props) => (
</TableCell>
<TableCell padding="none">{safe.get('name')}</TableCell>
<TableCell padding="none">{safe.get('address')}</TableCell>
<TableCell padding="none" numeric>{safe.get('confirmations')}</TableCell>
<TableCell padding="none" numeric>{safe.get('threshold')}</TableCell>
<TableCell padding="none" numeric>{safe.get('owners').count()}</TableCell>
<TableCell padding="none" numeric>{`${safe.get('dailyLimit').get('value')} ETH`}</TableCell>
</TableRow>