@exodus/ethereum-api 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/index.js +1 -0
- package/src/optimism-gas/addresses.js +1 -0
- package/src/optimism-gas/index.js +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@exodus/asset-lib": "^3.7.1",
|
|
18
18
|
"@exodus/crypto": "^1.0.0-rc.0",
|
|
19
|
-
"@exodus/ethereum-lib": "^3.0.
|
|
19
|
+
"@exodus/ethereum-lib": "^3.0.4",
|
|
20
20
|
"@exodus/ethereumjs-util": "^7.1.0-exodus.6",
|
|
21
21
|
"@exodus/fetch": "^1.2.1",
|
|
22
22
|
"@exodus/simple-retry": "^0.0.6",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@exodus/models": "^8.10.4"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "dcee33135e8134736fd7243c91b52ff1479de5d6"
|
|
40
40
|
}
|
package/src/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GAS_ORACLE_ADDRESS = '0x420000000000000000000000000000000000000F'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import BN from 'bn.js'
|
|
2
|
+
import * as ethUtil from '@exodus/ethereumjs-util'
|
|
3
|
+
import { createEthereumJsTx, createContract } from '@exodus/ethereum-lib'
|
|
4
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
5
|
+
import { GAS_ORACLE_ADDRESS } from './addresses'
|
|
6
|
+
|
|
7
|
+
const gasContract = createContract(GAS_ORACLE_ADDRESS, 'optimismGasOracle')
|
|
8
|
+
|
|
9
|
+
export async function estimateOptimismL1DataFee({ unsignedTx }) {
|
|
10
|
+
const ethjsTx = createEthereumJsTx(unsignedTx)
|
|
11
|
+
const serialized = ethjsTx.serialize()
|
|
12
|
+
const callData = gasContract.getL1Fee.build(serialized)
|
|
13
|
+
const buffer = Buffer.from(callData)
|
|
14
|
+
const data = ethUtil.bufferToHex(buffer)
|
|
15
|
+
const server = getServerByName('optimism')
|
|
16
|
+
const hex = await server.ethCall({ to: GAS_ORACLE_ADDRESS, data }, 'latest')
|
|
17
|
+
const l1DataFee = new BN(hex.slice(2), 16)
|
|
18
|
+
const padFee = l1DataFee.div(new BN(4, 10))
|
|
19
|
+
const maxL1DataFee = l1DataFee.add(padFee)
|
|
20
|
+
return maxL1DataFee.toString()
|
|
21
|
+
}
|