Prevent showing enable data modal (#1086)
* Prevent from showing enable modal * Add message info for failing txs * c'mon Travis! Stop complaining. * PR feedback improvements Co-authored-by: Mati Dastugue <mdastugu@amazon.com> Co-authored-by: Mikhail Mikheev <mmvsha73@gmail.com>
This commit is contained in:
parent
16a7c8fb54
commit
0e3436bf67
|
@ -1,18 +1,19 @@
|
||||||
function transactionDataCheck(): any {
|
import { loadFromStorage, saveToStorage } from 'src/utils/storage'
|
||||||
let completed = false
|
import { WALLET_PROVIDER } from 'src/logic/wallets/getWeb3'
|
||||||
return (stateAndHelpers) => {
|
|
||||||
const { wallet } = stateAndHelpers
|
|
||||||
|
|
||||||
if (wallet && wallet.name === 'Ledger' && !completed) {
|
const USER_ENABLED_LEDGER_TX_DATA = 'USER_ENABLED_LEDGER_TX_DATA'
|
||||||
|
function transactionDataCheck(): any {
|
||||||
|
return async (stateAndHelpers) => {
|
||||||
|
const { wallet } = stateAndHelpers
|
||||||
|
const isTransactionDataEnabled = await loadFromStorage<boolean>(USER_ENABLED_LEDGER_TX_DATA)
|
||||||
|
if (wallet && wallet.name === WALLET_PROVIDER.LEDGER && !isTransactionDataEnabled) {
|
||||||
return {
|
return {
|
||||||
heading: 'Allow Transaction Data', // edit modal heading here
|
heading: 'Allow Transaction Data', // edit modal heading here
|
||||||
description: 'Please allow transaction data on your Ledger device.', // edit modal description that is displayed here. You can include html strings here and they will be rendered as html elements.
|
description: 'Please allow transaction data on your Ledger device.', // edit modal description that is displayed here. You can include html strings here and they will be rendered as html elements.
|
||||||
eventCode: 'allowTransactionData',
|
eventCode: 'allowTransactionData',
|
||||||
button: {
|
button: {
|
||||||
text: 'Done',
|
text: 'Done',
|
||||||
onclick: () => {
|
onclick: async () => await saveToStorage(USER_ENABLED_LEDGER_TX_DATA, true),
|
||||||
completed = true
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
icon: `
|
icon: `
|
||||||
<svg height="14" viewBox="0 0 18 14" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor"><path d="m10.29375 4.05351563c0-.04921875 0-.09140625 0-.13007813 0-1.0546875 0-2.109375 0-3.1640625 0-.43945312.3480469-.76992188.7804688-.7453125.2003906.01054688.3585937.10546875.4992187.24609375.5800781.58359375 1.1566406 1.16367188 1.7367187 1.74023438 1.4695313 1.46953125 2.9390625 2.93906249 4.4050782 4.40859375.1335937.13359375.2425781.27421875.2707031.46757812.0351562.20742188-.0246094.421875-.1652344.58007813-.0246094.028125-.0492187.05273437-.0738281.08085937-2.0601563 2.06367188-4.1203125 4.1238281-6.1804688 6.1875-.2109375.2109375-.4570312.3023438-.7453125.2179688-.2707031-.0808594-.4464843-.2707032-.5132812-.5484375-.0140625-.0738282-.0175781-.1441407-.0140625-.2179688 0-1.0335937 0-2.0707031 0-3.1042969 0-.0386719 0-.08085935 0-.13359372h-5.06953125c-.49570313 0-.80507813-.309375-.80507813-.80859375 0-1.42382813 0-2.84414063 0-4.26796875 0-.49570313.30585938-.8015625.8015625-.8015625h4.93593748z"/><path d="m5.69882812 13.978125h-4.01132812c-.928125 0-1.6875-.8753906-1.6875-1.9511719v-10.06171872c0-1.07578125.75585938-1.95117188 1.6875-1.95117188h4.01132812c.34101563 0 .61523438.31992188.61523438.71015625 0 .39023438-.27421875.71015625-.61523438.71015625h-4.01132812c-.253125 0-.45703125.23554688-.45703125.52734375v10.06171875c0 .2917969.20390625.5273437.45703125.5273437h4.01132812c.34101563 0 .61523438.3199219.61523438.7101563s-.27773438.7171875-.61523438.7171875z"/></g></svg>
|
<svg height="14" viewBox="0 0 18 14" width="18" xmlns="http://www.w3.org/2000/svg"><g fill="currentColor"><path d="m10.29375 4.05351563c0-.04921875 0-.09140625 0-.13007813 0-1.0546875 0-2.109375 0-3.1640625 0-.43945312.3480469-.76992188.7804688-.7453125.2003906.01054688.3585937.10546875.4992187.24609375.5800781.58359375 1.1566406 1.16367188 1.7367187 1.74023438 1.4695313 1.46953125 2.9390625 2.93906249 4.4050782 4.40859375.1335937.13359375.2425781.27421875.2707031.46757812.0351562.20742188-.0246094.421875-.1652344.58007813-.0246094.028125-.0492187.05273437-.0738281.08085937-2.0601563 2.06367188-4.1203125 4.1238281-6.1804688 6.1875-.2109375.2109375-.4570312.3023438-.7453125.2179688-.2707031-.0808594-.4464843-.2707032-.5132812-.5484375-.0140625-.0738282-.0175781-.1441407-.0140625-.2179688 0-1.0335937 0-2.0707031 0-3.1042969 0-.0386719 0-.08085935 0-.13359372h-5.06953125c-.49570313 0-.80507813-.309375-.80507813-.80859375 0-1.42382813 0-2.84414063 0-4.26796875 0-.49570313.30585938-.8015625.8015625-.8015625h4.93593748z"/><path d="m5.69882812 13.978125h-4.01132812c-.928125 0-1.6875-.8753906-1.6875-1.9511719v-10.06171872c0-1.07578125.75585938-1.95117188 1.6875-1.95117188h4.01132812c.34101563 0 .61523438.31992188.61523438.71015625 0 .39023438-.27421875.71015625-.61523438.71015625h-4.01132812c-.253125 0-.45703125.23554688-.45703125.52734375v10.06171875c0 .2917969.20390625.5273437.45703125.5273437h4.01132812c.34101563 0 .61523438.3199219.61523438.7101563s-.27773438.7171875-.61523438.7171875z"/></g></svg>
|
||||||
|
|
|
@ -69,12 +69,14 @@ export const createSafe = (values, userAccount) => {
|
||||||
})
|
})
|
||||||
.then(async (receipt) => {
|
.then(async (receipt) => {
|
||||||
await checkReceiptStatus(receipt.transactionHash)
|
await checkReceiptStatus(receipt.transactionHash)
|
||||||
|
|
||||||
const safeAddress = receipt.events.ProxyCreation.returnValues.proxy
|
const safeAddress = receipt.events.ProxyCreation.returnValues.proxy
|
||||||
const safeProps = await getSafeProps(safeAddress, name, ownersNames, ownerAddresses)
|
const safeProps = await getSafeProps(safeAddress, name, ownersNames, ownerAddresses)
|
||||||
// returning info for testing purposes, in app is fully async
|
// returning info for testing purposes, in app is fully async
|
||||||
return { safeAddress: safeProps.address, safeTx: receipt }
|
return { safeAddress: safeProps.address, safeTx: receipt }
|
||||||
})
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
|
||||||
return promiEvent
|
return promiEvent
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ const createTransaction = ({
|
||||||
|
|
||||||
const notificationsQueue = getNotificationsFromTxType(notifiedTransaction, origin)
|
const notificationsQueue = getNotificationsFromTxType(notifiedTransaction, origin)
|
||||||
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
|
const beforeExecutionKey = showSnackbar(notificationsQueue.beforeExecution, enqueueSnackbar, closeSnackbar)
|
||||||
|
|
||||||
let pendingExecutionKey
|
let pendingExecutionKey
|
||||||
|
|
||||||
let txHash
|
let txHash
|
||||||
|
@ -246,6 +247,10 @@ const createTransaction = ({
|
||||||
return receipt.transactionHash
|
return receipt.transactionHash
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
const errorMsg = err.message
|
||||||
|
? `${notificationsQueue.afterExecutionError.message} - ${err.message}`
|
||||||
|
: notificationsQueue.afterExecutionError.message
|
||||||
|
|
||||||
console.error(err)
|
console.error(err)
|
||||||
closeSnackbar(beforeExecutionKey)
|
closeSnackbar(beforeExecutionKey)
|
||||||
|
|
||||||
|
@ -253,7 +258,7 @@ const createTransaction = ({
|
||||||
closeSnackbar(pendingExecutionKey)
|
closeSnackbar(pendingExecutionKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
showSnackbar(notificationsQueue.afterExecutionError, enqueueSnackbar, closeSnackbar)
|
showSnackbar(errorMsg, enqueueSnackbar, closeSnackbar)
|
||||||
|
|
||||||
const executeDataUsedSignatures = safeInstance.contract.methods
|
const executeDataUsedSignatures = safeInstance.contract.methods
|
||||||
.execTransaction(to, valueInWei, txData, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs)
|
.execTransaction(to, valueInWei, txData, operation, 0, 0, 0, ZERO_ADDRESS, ZERO_ADDRESS, sigs)
|
||||||
|
|
|
@ -199,6 +199,9 @@ const processTransaction = ({
|
||||||
return receipt.transactionHash
|
return receipt.transactionHash
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
const errorMsg = err.message
|
||||||
|
? `${notificationsQueue.afterExecutionError.message} - ${err.message}`
|
||||||
|
: notificationsQueue.afterExecutionError.message
|
||||||
console.error(err)
|
console.error(err)
|
||||||
|
|
||||||
if (txHash !== undefined) {
|
if (txHash !== undefined) {
|
||||||
|
@ -208,7 +211,7 @@ const processTransaction = ({
|
||||||
closeSnackbar(pendingExecutionKey)
|
closeSnackbar(pendingExecutionKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
showSnackbar(notificationsQueue.afterExecutionError, enqueueSnackbar, closeSnackbar)
|
showSnackbar(errorMsg, enqueueSnackbar, closeSnackbar)
|
||||||
|
|
||||||
const executeData = safeInstance.contract.methods.approveHash(txHash).encodeABI()
|
const executeData = safeInstance.contract.methods.approveHash(txHash).encodeABI()
|
||||||
const errMsg = await getErrorMessage(safeInstance.address, 0, executeData, from)
|
const errMsg = await getErrorMessage(safeInstance.address, 0, executeData, from)
|
||||||
|
|
Loading…
Reference in New Issue