mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-13 19:44:12 +00:00
metamask signature generation fix, gas calculations wip
This commit is contained in:
parent
c6325567ba
commit
dc4c6097c1
@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
import { List } from 'immutable'
|
||||
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
||||
import { executeTransaction, approveTransaction } from '~/logic/safe/safeBlockchainOperations'
|
||||
import { executeTransaction, approveTransaction } from '~/logic/safe/transactions'
|
||||
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { type Safe } from '~/routes/safe/store/models/safe'
|
||||
|
@ -4,6 +4,7 @@ import { BigNumber } from 'bignumber.js'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { EMPTY_DATA } from '~/logic/wallets/ethTransactions'
|
||||
import { getSafeEthereumInstance } from '../safeFrontendOperations'
|
||||
import { generateMetamaskSignature } from '~/logic/safe/transactions'
|
||||
|
||||
const estimateDataGasCosts = (data) => {
|
||||
const reducer = (accumulator, currentValue) => {
|
||||
@ -119,10 +120,21 @@ export const calculateTxFee = async (
|
||||
Number(threshold),
|
||||
safeAddress,
|
||||
)
|
||||
const signature = await generateMetamaskSignature(
|
||||
safe,
|
||||
safeAddress,
|
||||
'0xbc2BB26a6d821e69A38016f3858561a1D80d4182',
|
||||
to,
|
||||
valueInWei,
|
||||
nonce,
|
||||
data,
|
||||
operation,
|
||||
txGasEstimate,
|
||||
)
|
||||
const sigs = getSignaturesFrom(safeInstance.address, nonce)
|
||||
const estimate = await safeInstance.execTransaction.estimateGas(
|
||||
to, valueInWei, data, operation, txGasEstimate, dataGasEstimate, 0, '0x0000000000000000000000000000000000000000', safeAddress, sigs
|
||||
)
|
||||
to, valueInWei, data, operation, txGasEstimate, dataGasEstimate, 0, '0x0000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000', signature,
|
||||
)
|
||||
|
||||
return estimate
|
||||
} catch (error) {
|
||||
|
@ -1,2 +1,4 @@
|
||||
// @flow
|
||||
export * from './gas'
|
||||
export * from './safeBlockchainOperations'
|
||||
export * from './safeTxSignerEIP712'
|
||||
|
@ -4,7 +4,7 @@ import { calculateGasOf, checkReceiptStatus, calculateGasPrice } from '~/logic/w
|
||||
import { type Operation, submitOperation } from '~/logic/safe/safeTxHistory'
|
||||
import { getSafeEthereumInstance } from '~/logic/safe/safeFrontendOperations'
|
||||
import { buildSignaturesFrom } from '~/logic/safe/safeTxSigner'
|
||||
import { generateMetamaskSignature, generateTxGasEstimateFrom, estimateDataGas } from '~/logic/safe/safeTxSignerEIP712'
|
||||
import { generateMetamaskSignature, generateTxGasEstimateFrom, estimateDataGas } from '~/logic/safe/transactions'
|
||||
import { storeSignature, getSignaturesFrom } from '~/utils/storage/signatures'
|
||||
import { signaturesViaMetamask } from '~/config'
|
||||
|
@ -82,14 +82,14 @@ export const generateMetamaskSignature = async (
|
||||
operation,
|
||||
txGasEstimate,
|
||||
)
|
||||
|
||||
console.log({sender})
|
||||
const jsonTypedData = JSON.stringify(typedData)
|
||||
const signedTypedData = {
|
||||
method: 'eth_signTypedData_v3',
|
||||
// To change once Metamask fixes their status
|
||||
// https://github.com/MetaMask/metamask-extension/pull/5368
|
||||
// https://github.com/MetaMask/metamask-extension/issues/5366
|
||||
params: [jsonTypedData, sender],
|
||||
params: [sender, jsonTypedData],
|
||||
from: sender,
|
||||
}
|
||||
const txSignedResponse = await web3.currentProvider.sendAsync(signedTypedData)
|
Loading…
x
Reference in New Issue
Block a user