Merge pull request #176 from gnosis/support_off_chain_sigs
Feature #176: Support off chain sigs
This commit is contained in:
commit
22d7d13f8f
|
@ -15,6 +15,11 @@ export const getApprovalTransaction = async (
|
||||||
data: string,
|
data: string,
|
||||||
operation: Operation,
|
operation: Operation,
|
||||||
nonce: number,
|
nonce: number,
|
||||||
|
safeTxGas: number,
|
||||||
|
baseGas: number,
|
||||||
|
gasPrice: number,
|
||||||
|
gasToken: string,
|
||||||
|
refundReceiver: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
) => {
|
) => {
|
||||||
const txHash = await safeInstance.getTransactionHash(
|
const txHash = await safeInstance.getTransactionHash(
|
||||||
|
@ -22,11 +27,11 @@ export const getApprovalTransaction = async (
|
||||||
valueInWei,
|
valueInWei,
|
||||||
data,
|
data,
|
||||||
operation,
|
operation,
|
||||||
0,
|
safeTxGas,
|
||||||
0,
|
baseGas,
|
||||||
0,
|
gasPrice,
|
||||||
ZERO_ADDRESS,
|
gasToken,
|
||||||
ZERO_ADDRESS,
|
refundReceiver,
|
||||||
nonce,
|
nonce,
|
||||||
{
|
{
|
||||||
from: sender,
|
from: sender,
|
||||||
|
@ -40,7 +45,6 @@ export const getApprovalTransaction = async (
|
||||||
return contract.methods.approveHash(txHash)
|
return contract.methods.approveHash(txHash)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error while approving transaction: ${err}`)
|
console.error(`Error while approving transaction: ${err}`)
|
||||||
|
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +56,11 @@ export const getExecutionTransaction = async (
|
||||||
data: string,
|
data: string,
|
||||||
operation: Operation,
|
operation: Operation,
|
||||||
nonce: string | number,
|
nonce: string | number,
|
||||||
|
safeTxGas: string | number,
|
||||||
|
baseGas: string | number,
|
||||||
|
gasPrice: string | number,
|
||||||
|
gasToken: string,
|
||||||
|
refundReceiver: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
sigs: string,
|
sigs: string,
|
||||||
) => {
|
) => {
|
||||||
|
@ -59,7 +68,7 @@ export const getExecutionTransaction = async (
|
||||||
const web3 = getWeb3()
|
const web3 = getWeb3()
|
||||||
const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address)
|
const contract = new web3.eth.Contract(GnosisSafeSol.abi, safeInstance.address)
|
||||||
|
|
||||||
return contract.methods.execTransaction(to, valueInWei, data, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs)
|
return contract.methods.execTransaction(to, valueInWei, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, sigs)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Error while creating transaction: ${err}`)
|
console.error(`Error while creating transaction: ${err}`)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||||
import { getTxServiceUriFrom, getTxServiceHost } from '~/config'
|
import { getTxServiceUriFrom, getTxServiceHost } from '~/config'
|
||||||
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
|
|
||||||
|
|
||||||
export type TxServiceType = 'confirmation' | 'execution' | 'initialised'
|
export type TxServiceType = 'confirmation' | 'execution' | 'initialised'
|
||||||
export type Operation = 0 | 1 | 2
|
export type Operation = 0 | 1 | 2
|
||||||
|
@ -14,6 +13,11 @@ const calculateBodyFrom = async (
|
||||||
data: string,
|
data: string,
|
||||||
operation: Operation,
|
operation: Operation,
|
||||||
nonce: string | number,
|
nonce: string | number,
|
||||||
|
safeTxGas: string | number,
|
||||||
|
baseGas: string | number,
|
||||||
|
gasPrice: string | number,
|
||||||
|
gasToken: string,
|
||||||
|
refundReceiver: string,
|
||||||
transactionHash: string,
|
transactionHash: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
confirmationType: TxServiceType,
|
confirmationType: TxServiceType,
|
||||||
|
@ -23,11 +27,11 @@ const calculateBodyFrom = async (
|
||||||
valueInWei,
|
valueInWei,
|
||||||
data,
|
data,
|
||||||
operation,
|
operation,
|
||||||
0,
|
safeTxGas,
|
||||||
0,
|
baseGas,
|
||||||
0,
|
gasPrice,
|
||||||
ZERO_ADDRESS,
|
gasToken,
|
||||||
ZERO_ADDRESS,
|
refundReceiver,
|
||||||
nonce,
|
nonce,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,11 +41,11 @@ const calculateBodyFrom = async (
|
||||||
data,
|
data,
|
||||||
operation,
|
operation,
|
||||||
nonce,
|
nonce,
|
||||||
safeTxGas: 0,
|
safeTxGas,
|
||||||
baseGas: 0,
|
baseGas,
|
||||||
gasPrice: 0,
|
gasPrice,
|
||||||
gasToken: ZERO_ADDRESS,
|
gasToken,
|
||||||
refundReceiver: ZERO_ADDRESS,
|
refundReceiver,
|
||||||
contractTransactionHash,
|
contractTransactionHash,
|
||||||
transactionHash,
|
transactionHash,
|
||||||
sender: getWeb3().utils.toChecksumAddress(sender),
|
sender: getWeb3().utils.toChecksumAddress(sender),
|
||||||
|
@ -63,12 +67,32 @@ export const saveTxToHistory = async (
|
||||||
data: string,
|
data: string,
|
||||||
operation: Operation,
|
operation: Operation,
|
||||||
nonce: number | string,
|
nonce: number | string,
|
||||||
|
safeTxGas: string | number,
|
||||||
|
baseGas: string | number,
|
||||||
|
gasPrice: string | number,
|
||||||
|
gasToken: string,
|
||||||
|
refundReceiver: string,
|
||||||
txHash: string,
|
txHash: string,
|
||||||
sender: string,
|
sender: string,
|
||||||
type: TxServiceType,
|
type: TxServiceType,
|
||||||
) => {
|
) => {
|
||||||
const url = buildTxServiceUrl(safeInstance.address)
|
const url = buildTxServiceUrl(safeInstance.address)
|
||||||
const body = await calculateBodyFrom(safeInstance, to, valueInWei, data, operation, nonce, txHash, sender, type)
|
const body = await calculateBodyFrom(
|
||||||
|
safeInstance,
|
||||||
|
to,
|
||||||
|
valueInWei,
|
||||||
|
data,
|
||||||
|
operation,
|
||||||
|
nonce,
|
||||||
|
safeTxGas,
|
||||||
|
baseGas,
|
||||||
|
gasPrice,
|
||||||
|
gasToken,
|
||||||
|
refundReceiver,
|
||||||
|
txHash,
|
||||||
|
sender,
|
||||||
|
type,
|
||||||
|
)
|
||||||
const response = await axios.post(url, body)
|
const response = await axios.post(url, body)
|
||||||
|
|
||||||
if (response.status !== 202) {
|
if (response.status !== 202) {
|
||||||
|
|
|
@ -16,5 +16,7 @@ export const sameAddress = (firstAddress: string, secondAddress: string): boolea
|
||||||
export const shortVersionOf = (address: string, cut: number) => {
|
export const shortVersionOf = (address: string, cut: number) => {
|
||||||
const final = 42 - cut
|
const final = 42 - cut
|
||||||
|
|
||||||
|
if (!address) return 'Unknown address'
|
||||||
|
if (address.length < final) return address
|
||||||
return `${address.substring(0, cut)}...${address.substring(final)}`
|
return `${address.substring(0, cut)}...${address.substring(final)}`
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,9 @@ export const getTxData = (tx: Transaction): DecodedTxData => {
|
||||||
}
|
}
|
||||||
} else if (tx.cancellationTx) {
|
} else if (tx.cancellationTx) {
|
||||||
txData.cancellationTx = true
|
txData.cancellationTx = true
|
||||||
|
} else {
|
||||||
|
txData.recipient = tx.recipient
|
||||||
|
txData.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return txData
|
return txData
|
||||||
|
|
|
@ -98,6 +98,26 @@ const ExpandedTx = ({
|
||||||
{formatDate(tx.executionDate)}
|
{formatDate(tx.executionDate)}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
)}
|
)}
|
||||||
|
{tx.refundParams && (
|
||||||
|
<Paragraph noMargin>
|
||||||
|
<Bold>TX refund: </Bold>
|
||||||
|
max.
|
||||||
|
{' '}
|
||||||
|
{tx.refundParams.fee}
|
||||||
|
{' '}
|
||||||
|
{tx.refundParams.symbol}
|
||||||
|
</Paragraph>
|
||||||
|
)}
|
||||||
|
{tx.operation === 1 && (
|
||||||
|
<Paragraph noMargin>
|
||||||
|
<Bold>Delegate Call</Bold>
|
||||||
|
</Paragraph>
|
||||||
|
)}
|
||||||
|
{tx.operation === 2 && (
|
||||||
|
<Paragraph noMargin>
|
||||||
|
<Bold>Contract Creation</Bold>
|
||||||
|
</Paragraph>
|
||||||
|
)}
|
||||||
</Block>
|
</Block>
|
||||||
<Hairline />
|
<Hairline />
|
||||||
<TxDescription tx={tx} />
|
<TxDescription tx={tx} />
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import { List, Map } from 'immutable'
|
import { List, Map } from 'immutable'
|
||||||
import { createSelector, createStructuredSelector, type Selector } from 'reselect'
|
import { createSelector, createStructuredSelector, type Selector } from 'reselect'
|
||||||
import { isAfter, parseISO } from 'date-fns'
|
|
||||||
import {
|
import {
|
||||||
safeSelector,
|
safeSelector,
|
||||||
safeActiveTokensSelector,
|
safeActiveTokensSelector,
|
||||||
|
@ -117,9 +116,7 @@ const extendedTransactionsSelector: Selector<GlobalState, RouterProps, List<Tran
|
||||||
let replacementTransaction
|
let replacementTransaction
|
||||||
if (!tx.isExecuted) {
|
if (!tx.isExecuted) {
|
||||||
replacementTransaction = transactions.findLast(
|
replacementTransaction = transactions.findLast(
|
||||||
(transaction) => (transaction.nonce === tx.nonce
|
(transaction) => transaction.isExecuted && transaction.nonce >= tx.nonce,
|
||||||
&& isAfter(parseISO(transaction.submissionDate), parseISO(tx.submissionDate)))
|
|
||||||
|| transaction.nonce > tx.nonce,
|
|
||||||
)
|
)
|
||||||
if (replacementTransaction) {
|
if (replacementTransaction) {
|
||||||
extendedTx = tx.set('cancelled', true)
|
extendedTx = tx.set('cancelled', true)
|
||||||
|
|
|
@ -54,9 +54,15 @@ const createTransaction = (
|
||||||
let tx
|
let tx
|
||||||
try {
|
try {
|
||||||
if (isExecution) {
|
if (isExecution) {
|
||||||
tx = await getExecutionTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from, sigs)
|
tx = await getExecutionTransaction(
|
||||||
|
safeInstance, to, valueInWei, txData, CALL, nonce,
|
||||||
|
0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, from, sigs
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
tx = await getApprovalTransaction(safeInstance, to, valueInWei, txData, CALL, nonce, from)
|
tx = await getApprovalTransaction(
|
||||||
|
safeInstance, to, valueInWei, txData, CALL, nonce,
|
||||||
|
0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, from, sigs
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendParams = { from, value: 0 }
|
const sendParams = { from, value: 0 }
|
||||||
|
@ -81,6 +87,11 @@ const createTransaction = (
|
||||||
txData,
|
txData,
|
||||||
CALL,
|
CALL,
|
||||||
nonce,
|
nonce,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
ZERO_ADDRESS,
|
||||||
txHash,
|
txHash,
|
||||||
from,
|
from,
|
||||||
isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
isExecution ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
||||||
|
@ -95,7 +106,6 @@ const createTransaction = (
|
||||||
})
|
})
|
||||||
.then((receipt) => {
|
.then((receipt) => {
|
||||||
closeSnackbar(pendingExecutionKey)
|
closeSnackbar(pendingExecutionKey)
|
||||||
|
|
||||||
showSnackbar(
|
showSnackbar(
|
||||||
isExecution
|
isExecution
|
||||||
? notificationsQueue.afterExecution.noMoreConfirmationsNeeded
|
? notificationsQueue.afterExecution.noMoreConfirmationsNeeded
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { getHumanFriendlyToken } from '~/logic/tokens/store/actions/fetchTokens'
|
||||||
import { isTokenTransfer } from '~/logic/tokens/utils/tokenHelpers'
|
import { isTokenTransfer } from '~/logic/tokens/utils/tokenHelpers'
|
||||||
import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds'
|
import { decodeParamsFromSafeMethod } from '~/logic/contracts/methodIds'
|
||||||
import { ALTERNATIVE_TOKEN_ABI } from '~/logic/tokens/utils/alternativeAbi'
|
import { ALTERNATIVE_TOKEN_ABI } from '~/logic/tokens/utils/alternativeAbi'
|
||||||
|
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
|
||||||
|
|
||||||
let web3
|
let web3
|
||||||
|
|
||||||
|
@ -32,6 +33,11 @@ type TxServiceModel = {
|
||||||
data: string,
|
data: string,
|
||||||
operation: number,
|
operation: number,
|
||||||
nonce: number,
|
nonce: number,
|
||||||
|
safeTxGas: number,
|
||||||
|
baseGas: number,
|
||||||
|
gasPrice: number,
|
||||||
|
gasToken: string,
|
||||||
|
refundReceiver: string,
|
||||||
safeTxHash: string,
|
safeTxHash: string,
|
||||||
submissionDate: string,
|
submissionDate: string,
|
||||||
executionDate: string,
|
executionDate: string,
|
||||||
|
@ -55,6 +61,7 @@ export const buildTransactionFrom = async (
|
||||||
owner: makeOwner({ address: conf.owner, name: ownerName }),
|
owner: makeOwner({ address: conf.owner, name: ownerName }),
|
||||||
type: ((conf.confirmationType.toLowerCase(): any): TxServiceType),
|
type: ((conf.confirmationType.toLowerCase(): any): TxServiceType),
|
||||||
hash: conf.transactionHash,
|
hash: conf.transactionHash,
|
||||||
|
signature: conf.signature,
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -63,6 +70,27 @@ export const buildTransactionFrom = async (
|
||||||
const isSendTokenTx = await isTokenTransfer(tx.data, tx.value)
|
const isSendTokenTx = await isTokenTransfer(tx.data, tx.value)
|
||||||
const customTx = tx.to !== safeAddress && !!tx.data && !isSendTokenTx
|
const customTx = tx.to !== safeAddress && !!tx.data && !isSendTokenTx
|
||||||
|
|
||||||
|
let refundParams = null
|
||||||
|
if (tx.gasPrice > 0) {
|
||||||
|
let refundSymbol = 'ETH'
|
||||||
|
let decimals = 18
|
||||||
|
if (tx.gasToken !== ZERO_ADDRESS) {
|
||||||
|
const gasToken = await (await getHumanFriendlyToken()).at(tx.gasToken)
|
||||||
|
refundSymbol = await gasToken.symbol()
|
||||||
|
decimals = await gasToken.decimals()
|
||||||
|
}
|
||||||
|
|
||||||
|
const feeString = (tx.gasPrice * (tx.baseGas + tx.safeTxGas)).toString().padStart(decimals, 0)
|
||||||
|
const whole = feeString.slice(0, feeString.length - decimals) || '0'
|
||||||
|
const fraction = feeString.slice(feeString.length - decimals)
|
||||||
|
|
||||||
|
const formattedFee = `${whole}.${fraction}`
|
||||||
|
refundParams = {
|
||||||
|
fee: formattedFee,
|
||||||
|
symbol: refundSymbol,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let symbol = 'ETH'
|
let symbol = 'ETH'
|
||||||
let decimals = 18
|
let decimals = 18
|
||||||
let decodedParams
|
let decodedParams
|
||||||
|
@ -102,6 +130,13 @@ export const buildTransactionFrom = async (
|
||||||
decimals,
|
decimals,
|
||||||
recipient: tx.to,
|
recipient: tx.to,
|
||||||
data: tx.data ? tx.data : EMPTY_DATA,
|
data: tx.data ? tx.data : EMPTY_DATA,
|
||||||
|
operation: tx.operation,
|
||||||
|
safeTxGas: tx.safeTxGas,
|
||||||
|
baseGas: tx.baseGas,
|
||||||
|
gasPrice: tx.gasPrice,
|
||||||
|
gasToken: tx.gasToken,
|
||||||
|
refundReceiver: tx.refundReceiver,
|
||||||
|
refundParams,
|
||||||
isExecuted: tx.isExecuted,
|
isExecuted: tx.isExecuted,
|
||||||
submissionDate: tx.submissionDate,
|
submissionDate: tx.submissionDate,
|
||||||
executionDate: tx.executionDate,
|
executionDate: tx.executionDate,
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
type NotifiedTransaction,
|
type NotifiedTransaction,
|
||||||
getApprovalTransaction,
|
getApprovalTransaction,
|
||||||
getExecutionTransaction,
|
getExecutionTransaction,
|
||||||
CALL,
|
|
||||||
saveTxToHistory,
|
saveTxToHistory,
|
||||||
TX_TYPE_EXECUTION,
|
TX_TYPE_EXECUTION,
|
||||||
TX_TYPE_CONFIRMATION,
|
TX_TYPE_CONFIRMATION,
|
||||||
|
@ -31,18 +30,27 @@ export const generateSignaturesFromTxConfirmations = (
|
||||||
) => {
|
) => {
|
||||||
// The constant parts need to be sorted so that the recovered signers are sorted ascending
|
// The constant parts need to be sorted so that the recovered signers are sorted ascending
|
||||||
// (natural order) by address (not checksummed).
|
// (natural order) by address (not checksummed).
|
||||||
let confirmedAdresses = confirmations.map((conf) => conf.owner.address)
|
const confirmationsMap = confirmations.reduce((map, obj) => {
|
||||||
|
map[obj.owner.address] = obj // eslint-disable-line no-param-reassign
|
||||||
|
return map
|
||||||
|
}, {})
|
||||||
|
|
||||||
if (preApprovingOwner) {
|
if (preApprovingOwner) {
|
||||||
confirmedAdresses = confirmedAdresses.push(preApprovingOwner)
|
confirmationsMap[preApprovingOwner] = { owner: preApprovingOwner }
|
||||||
}
|
}
|
||||||
|
|
||||||
let sigs = '0x'
|
let sigs = '0x'
|
||||||
confirmedAdresses.sort().forEach((addr) => {
|
Object.keys(confirmationsMap).sort().forEach((addr) => {
|
||||||
|
const conf = confirmationsMap[addr]
|
||||||
|
if (conf.signature) {
|
||||||
|
sigs += conf.signature.slice(2)
|
||||||
|
} else {
|
||||||
|
// https://gnosis-safe.readthedocs.io/en/latest/contracts/signatures.html#pre-validated-signatures
|
||||||
sigs += `000000000000000000000000${addr.replace(
|
sigs += `000000000000000000000000${addr.replace(
|
||||||
'0x',
|
'0x',
|
||||||
'',
|
'',
|
||||||
)}000000000000000000000000000000000000000000000000000000000000000001`
|
)}000000000000000000000000000000000000000000000000000000000000000001`
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return sigs
|
return sigs
|
||||||
}
|
}
|
||||||
|
@ -60,7 +68,6 @@ const processTransaction = (
|
||||||
|
|
||||||
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
|
const safeInstance = await getGnosisSafeInstanceAt(safeAddress)
|
||||||
const from = userAccountSelector(state)
|
const from = userAccountSelector(state)
|
||||||
const nonce = (await safeInstance.nonce()).toString()
|
|
||||||
const threshold = (await safeInstance.getThreshold()).toNumber()
|
const threshold = (await safeInstance.getThreshold()).toNumber()
|
||||||
const shouldExecute = threshold === tx.confirmations.size || approveAndExecute
|
const shouldExecute = threshold === tx.confirmations.size || approveAndExecute
|
||||||
|
|
||||||
|
@ -86,13 +93,31 @@ const processTransaction = (
|
||||||
tx.recipient,
|
tx.recipient,
|
||||||
tx.value,
|
tx.value,
|
||||||
tx.data,
|
tx.data,
|
||||||
CALL,
|
tx.operation,
|
||||||
nonce,
|
tx.nonce,
|
||||||
|
tx.safeTxGas,
|
||||||
|
tx.baseGas,
|
||||||
|
tx.gasPrice,
|
||||||
|
tx.gasToken,
|
||||||
|
tx.refundReceiver,
|
||||||
from,
|
from,
|
||||||
sigs,
|
sigs,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
transaction = await getApprovalTransaction(safeInstance, tx.recipient, tx.value, tx.data, CALL, nonce, from)
|
transaction = await getApprovalTransaction(
|
||||||
|
safeInstance,
|
||||||
|
tx.recipient,
|
||||||
|
tx.value,
|
||||||
|
tx.data,
|
||||||
|
tx.operation,
|
||||||
|
tx.nonce,
|
||||||
|
tx.safeTxGas,
|
||||||
|
tx.baseGas,
|
||||||
|
tx.gasPrice,
|
||||||
|
tx.gasToken,
|
||||||
|
tx.refundReceiver,
|
||||||
|
from,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendParams = { from, value: 0 }
|
const sendParams = { from, value: 0 }
|
||||||
|
@ -115,8 +140,13 @@ const processTransaction = (
|
||||||
tx.recipient,
|
tx.recipient,
|
||||||
tx.value,
|
tx.value,
|
||||||
tx.data,
|
tx.data,
|
||||||
CALL,
|
tx.operation,
|
||||||
nonce,
|
tx.nonce,
|
||||||
|
tx.safeTxGas,
|
||||||
|
tx.baseGas,
|
||||||
|
tx.gasPrice,
|
||||||
|
tx.gasToken,
|
||||||
|
tx.refundReceiver,
|
||||||
txHash,
|
txHash,
|
||||||
from,
|
from,
|
||||||
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
shouldExecute ? TX_TYPE_EXECUTION : TX_TYPE_CONFIRMATION,
|
||||||
|
|
|
@ -8,12 +8,14 @@ export type ConfirmationProps = {
|
||||||
owner: Owner,
|
owner: Owner,
|
||||||
type: TxServiceType,
|
type: TxServiceType,
|
||||||
hash: string,
|
hash: string,
|
||||||
|
signature?: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeConfirmation: RecordFactory<ConfirmationProps> = Record({
|
export const makeConfirmation: RecordFactory<ConfirmationProps> = Record({
|
||||||
owner: makeOwner(),
|
owner: makeOwner(),
|
||||||
type: 'initialised',
|
type: 'initialised',
|
||||||
hash: '',
|
hash: '',
|
||||||
|
signature: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Confirmation = RecordOf<ConfirmationProps>
|
export type Confirmation = RecordOf<ConfirmationProps>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
import { List, Record } from 'immutable'
|
import { List, Record } from 'immutable'
|
||||||
import type { RecordFactory, RecordOf } from 'immutable'
|
import type { RecordFactory, RecordOf } from 'immutable'
|
||||||
import { type Confirmation } from '~/routes/safe/store/models/confirmation'
|
import { type Confirmation } from '~/routes/safe/store/models/confirmation'
|
||||||
|
import { ZERO_ADDRESS } from '~/logic/wallets/ethAddresses'
|
||||||
|
|
||||||
export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution' | 'pending'
|
export type TransactionStatus = 'awaiting_confirmations' | 'success' | 'cancelled' | 'awaiting_execution' | 'pending'
|
||||||
|
|
||||||
|
@ -10,7 +11,13 @@ export type TransactionProps = {
|
||||||
value: string,
|
value: string,
|
||||||
confirmations: List<Confirmation>,
|
confirmations: List<Confirmation>,
|
||||||
recipient: string,
|
recipient: string,
|
||||||
data: string,
|
data?: string,
|
||||||
|
operation: number,
|
||||||
|
safeTxGas: number,
|
||||||
|
baseGas: number,
|
||||||
|
gasPrice: number,
|
||||||
|
gasToken: string,
|
||||||
|
refundReceiver: string,
|
||||||
isExecuted: boolean,
|
isExecuted: boolean,
|
||||||
submissionDate: string,
|
submissionDate: string,
|
||||||
executionDate: string,
|
executionDate: string,
|
||||||
|
@ -25,6 +32,7 @@ export type TransactionProps = {
|
||||||
status?: TransactionStatus,
|
status?: TransactionStatus,
|
||||||
isTokenTransfer: boolean,
|
isTokenTransfer: boolean,
|
||||||
decodedParams?: Object,
|
decodedParams?: Object,
|
||||||
|
refundParams?: Object,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
||||||
|
@ -32,7 +40,13 @@ export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
||||||
value: 0,
|
value: 0,
|
||||||
confirmations: List([]),
|
confirmations: List([]),
|
||||||
recipient: '',
|
recipient: '',
|
||||||
data: '',
|
data: null,
|
||||||
|
operation: 0,
|
||||||
|
safeTxGas: 0,
|
||||||
|
baseGas: 0,
|
||||||
|
gasPrice: 0,
|
||||||
|
gasToken: ZERO_ADDRESS,
|
||||||
|
refundReceiver: ZERO_ADDRESS,
|
||||||
isExecuted: false,
|
isExecuted: false,
|
||||||
submissionDate: '',
|
submissionDate: '',
|
||||||
executionDate: '',
|
executionDate: '',
|
||||||
|
@ -47,6 +61,7 @@ export const makeTransaction: RecordFactory<TransactionProps> = Record({
|
||||||
decimals: 18,
|
decimals: 18,
|
||||||
isTokenTransfer: false,
|
isTokenTransfer: false,
|
||||||
decodedParams: {},
|
decodedParams: {},
|
||||||
|
refundParams: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
export type Transaction = RecordOf<TransactionProps>
|
export type Transaction = RecordOf<TransactionProps>
|
||||||
|
|
Loading…
Reference in New Issue