update calculations to be like in up-to-date safe-contracts tests
This commit is contained in:
parent
755db44c17
commit
c5bc2fa584
|
@ -40,21 +40,18 @@ export const estimateDataGas = (
|
|||
// For signature array length and dataGasEstimate we already calculated
|
||||
// the 0 bytes so we just add 64 for each non-zero byte
|
||||
const gasPrice = 0 // no need to get refund when we submit txs to metamask
|
||||
const signatureCost = signatureCount * (68 + 2176 + 2176) // array count (3 -> r, s, v) * signature count
|
||||
const signatureCost = signatureCount * (68 + 2176 + 2176 + 6000) // array count (3 -> r, s, v) * signature count
|
||||
|
||||
const sigs = getSignaturesFrom(safe.address, nonce)
|
||||
const sigs = `0x000000000000000000000000${
|
||||
'0xbc2BB26a6d821e69A38016f3858561a1D80d4182'.replace('0x', '')
|
||||
}0000000000000000000000000000000000000000000000000000000000000000`
|
||||
const payload = safe.contract.methods
|
||||
.execTransaction(to, valueInWei, data, operation, txGasEstimate, 0, gasPrice, gasToken, refundReceiver, sigs)
|
||||
.encodeABI()
|
||||
|
||||
let dataGasEstimate = estimateDataGasCosts(payload) + signatureCost
|
||||
console.log(dataGasEstimate, signatureCost)
|
||||
if (dataGasEstimate > 65536) {
|
||||
dataGasEstimate += 64
|
||||
} else {
|
||||
dataGasEstimate += 128
|
||||
}
|
||||
return dataGasEstimate + 34000 // Add aditional gas costs (e.g. base tx costs, transfer costs)
|
||||
const dataGasEstimate = estimateDataGasCosts(payload) + signatureCost + (nonce > 0 ? 5000 : 20000) + 1500 // 1500 -> hash generation costs
|
||||
|
||||
return dataGasEstimate + 32000 // Add aditional gas costs (e.g. base tx costs, transfer costs)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
|
@ -102,6 +99,7 @@ export const calculateTxFee = async (
|
|||
if (!safeInstance) {
|
||||
safeInstance = await getSafeEthereumInstance(safeAddress)
|
||||
}
|
||||
window.safeInstance = safeInstance
|
||||
|
||||
// Estimate safe transaction (need to be called with "from" set to the safe address)
|
||||
const nonce = await safeInstance.nonce()
|
||||
|
@ -145,7 +143,7 @@ export const calculateTxFee = async (
|
|||
dataGasEstimate,
|
||||
0,
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
'0x0000000000000000000000000000000000000000',
|
||||
safeAddress,
|
||||
sigs,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue