@exodus/ethereum-lib 3.0.3 → 3.0.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -41,5 +41,5 @@
41
41
  "ms": "^2.1.1",
42
42
  "reselect": "~3.0.1"
43
43
  },
44
- "gitHead": "39949d6e7fbda630eaa97143d441f226344fa7e2"
44
+ "gitHead": "dcee33135e8134736fd7243c91b52ff1479de5d6"
45
45
  }
package/src/abi/index.js CHANGED
@@ -14,6 +14,7 @@ import maticStakingManager from './matic-staking-manager'
14
14
  import fantomSfc from './fantom-sfc'
15
15
  import ensRegistry from './ens-registry'
16
16
  import ensResolver from './ens-resolver'
17
+ import optimismGasOracle from './optimism-gas-oracle'
17
18
 
18
19
  export default {
19
20
  ant,
@@ -32,4 +33,5 @@ export default {
32
33
  fantomSfc,
33
34
  ensRegistry,
34
35
  ensResolver,
36
+ optimismGasOracle,
35
37
  }
@@ -0,0 +1,298 @@
1
+ export default [
2
+ {
3
+ inputs: [
4
+ {
5
+ internalType: 'address',
6
+ name: '_owner',
7
+ type: 'address',
8
+ },
9
+ ],
10
+ stateMutability: 'nonpayable',
11
+ type: 'constructor',
12
+ },
13
+ {
14
+ anonymous: false,
15
+ inputs: [
16
+ {
17
+ indexed: false,
18
+ internalType: 'uint256',
19
+ name: '',
20
+ type: 'uint256',
21
+ },
22
+ ],
23
+ name: 'DecimalsUpdated',
24
+ type: 'event',
25
+ },
26
+ {
27
+ anonymous: false,
28
+ inputs: [
29
+ {
30
+ indexed: false,
31
+ internalType: 'uint256',
32
+ name: '',
33
+ type: 'uint256',
34
+ },
35
+ ],
36
+ name: 'GasPriceUpdated',
37
+ type: 'event',
38
+ },
39
+ {
40
+ anonymous: false,
41
+ inputs: [
42
+ {
43
+ indexed: false,
44
+ internalType: 'uint256',
45
+ name: '',
46
+ type: 'uint256',
47
+ },
48
+ ],
49
+ name: 'L1BaseFeeUpdated',
50
+ type: 'event',
51
+ },
52
+ {
53
+ anonymous: false,
54
+ inputs: [
55
+ {
56
+ indexed: false,
57
+ internalType: 'uint256',
58
+ name: '',
59
+ type: 'uint256',
60
+ },
61
+ ],
62
+ name: 'OverheadUpdated',
63
+ type: 'event',
64
+ },
65
+ {
66
+ anonymous: false,
67
+ inputs: [
68
+ {
69
+ indexed: true,
70
+ internalType: 'address',
71
+ name: 'previousOwner',
72
+ type: 'address',
73
+ },
74
+ {
75
+ indexed: true,
76
+ internalType: 'address',
77
+ name: 'newOwner',
78
+ type: 'address',
79
+ },
80
+ ],
81
+ name: 'OwnershipTransferred',
82
+ type: 'event',
83
+ },
84
+ {
85
+ anonymous: false,
86
+ inputs: [
87
+ {
88
+ indexed: false,
89
+ internalType: 'uint256',
90
+ name: '',
91
+ type: 'uint256',
92
+ },
93
+ ],
94
+ name: 'ScalarUpdated',
95
+ type: 'event',
96
+ },
97
+ {
98
+ inputs: [],
99
+ name: 'decimals',
100
+ outputs: [
101
+ {
102
+ internalType: 'uint256',
103
+ name: '',
104
+ type: 'uint256',
105
+ },
106
+ ],
107
+ stateMutability: 'view',
108
+ type: 'function',
109
+ },
110
+ {
111
+ inputs: [],
112
+ name: 'gasPrice',
113
+ outputs: [
114
+ {
115
+ internalType: 'uint256',
116
+ name: '',
117
+ type: 'uint256',
118
+ },
119
+ ],
120
+ stateMutability: 'view',
121
+ type: 'function',
122
+ },
123
+ {
124
+ inputs: [
125
+ {
126
+ internalType: 'bytes',
127
+ name: '_data',
128
+ type: 'bytes',
129
+ },
130
+ ],
131
+ name: 'getL1Fee',
132
+ outputs: [
133
+ {
134
+ internalType: 'uint256',
135
+ name: '',
136
+ type: 'uint256',
137
+ },
138
+ ],
139
+ stateMutability: 'view',
140
+ type: 'function',
141
+ },
142
+ {
143
+ inputs: [
144
+ {
145
+ internalType: 'bytes',
146
+ name: '_data',
147
+ type: 'bytes',
148
+ },
149
+ ],
150
+ name: 'getL1GasUsed',
151
+ outputs: [
152
+ {
153
+ internalType: 'uint256',
154
+ name: '',
155
+ type: 'uint256',
156
+ },
157
+ ],
158
+ stateMutability: 'view',
159
+ type: 'function',
160
+ },
161
+ {
162
+ inputs: [],
163
+ name: 'l1BaseFee',
164
+ outputs: [
165
+ {
166
+ internalType: 'uint256',
167
+ name: '',
168
+ type: 'uint256',
169
+ },
170
+ ],
171
+ stateMutability: 'view',
172
+ type: 'function',
173
+ },
174
+ {
175
+ inputs: [],
176
+ name: 'overhead',
177
+ outputs: [
178
+ {
179
+ internalType: 'uint256',
180
+ name: '',
181
+ type: 'uint256',
182
+ },
183
+ ],
184
+ stateMutability: 'view',
185
+ type: 'function',
186
+ },
187
+ {
188
+ inputs: [],
189
+ name: 'owner',
190
+ outputs: [
191
+ {
192
+ internalType: 'address',
193
+ name: '',
194
+ type: 'address',
195
+ },
196
+ ],
197
+ stateMutability: 'view',
198
+ type: 'function',
199
+ },
200
+ {
201
+ inputs: [],
202
+ name: 'renounceOwnership',
203
+ outputs: [],
204
+ stateMutability: 'nonpayable',
205
+ type: 'function',
206
+ },
207
+ {
208
+ inputs: [],
209
+ name: 'scalar',
210
+ outputs: [
211
+ {
212
+ internalType: 'uint256',
213
+ name: '',
214
+ type: 'uint256',
215
+ },
216
+ ],
217
+ stateMutability: 'view',
218
+ type: 'function',
219
+ },
220
+ {
221
+ inputs: [
222
+ {
223
+ internalType: 'uint256',
224
+ name: '_decimals',
225
+ type: 'uint256',
226
+ },
227
+ ],
228
+ name: 'setDecimals',
229
+ outputs: [],
230
+ stateMutability: 'nonpayable',
231
+ type: 'function',
232
+ },
233
+ {
234
+ inputs: [
235
+ {
236
+ internalType: 'uint256',
237
+ name: '_gasPrice',
238
+ type: 'uint256',
239
+ },
240
+ ],
241
+ name: 'setGasPrice',
242
+ outputs: [],
243
+ stateMutability: 'nonpayable',
244
+ type: 'function',
245
+ },
246
+ {
247
+ inputs: [
248
+ {
249
+ internalType: 'uint256',
250
+ name: '_baseFee',
251
+ type: 'uint256',
252
+ },
253
+ ],
254
+ name: 'setL1BaseFee',
255
+ outputs: [],
256
+ stateMutability: 'nonpayable',
257
+ type: 'function',
258
+ },
259
+ {
260
+ inputs: [
261
+ {
262
+ internalType: 'uint256',
263
+ name: '_overhead',
264
+ type: 'uint256',
265
+ },
266
+ ],
267
+ name: 'setOverhead',
268
+ outputs: [],
269
+ stateMutability: 'nonpayable',
270
+ type: 'function',
271
+ },
272
+ {
273
+ inputs: [
274
+ {
275
+ internalType: 'uint256',
276
+ name: '_scalar',
277
+ type: 'uint256',
278
+ },
279
+ ],
280
+ name: 'setScalar',
281
+ outputs: [],
282
+ stateMutability: 'nonpayable',
283
+ type: 'function',
284
+ },
285
+ {
286
+ inputs: [
287
+ {
288
+ internalType: 'address',
289
+ name: 'newOwner',
290
+ type: 'address',
291
+ },
292
+ ],
293
+ name: 'transferOwnership',
294
+ outputs: [],
295
+ stateMutability: 'nonpayable',
296
+ type: 'function',
297
+ },
298
+ ]
@@ -30,6 +30,8 @@ export default function createContract(address, contractName) {
30
30
  return new SolidityContract(ABI.ensRegistry, address, true)
31
31
  case 'erc721':
32
32
  return new SolidityContract(ABI.erc721, address, true)
33
+ case 'optimismGasOracle':
34
+ return new SolidityContract(ABI.optimismGasOracle, address, true)
33
35
  default:
34
36
  return SolidityContract.erc20(address)
35
37
  }
@@ -0,0 +1,47 @@
1
+ /* @flow */
2
+ import { Transaction, FeeMarketEIP1559Transaction } from '@exodus/ethereumjs-tx'
3
+ import Common from '@exodus/ethereumjs-common'
4
+
5
+ import type { UnsignedTransaction } from '@exodus/models/lib/types'
6
+ import { CUSTOM_CHAINS } from '../constants'
7
+
8
+ export default function createEthereumJsTx(unsignedTx: UnsignedTransaction) {
9
+ const {
10
+ txData: { gasPrice, tipGasPrice: maxPriorityFeePerGas, chainId: chain, ...txData },
11
+ txMeta: { eip1559Enabled },
12
+ } = unsignedTx
13
+
14
+ let tx
15
+ /*
16
+ To assemble an EIP 1559 tx,
17
+ both `tipGasPrice` and `eip` must have been set in the input object used to build `unsignedTx`.
18
+ Whether bsc will support EIP 1559 is unknown.
19
+ So we must prevent building accidentally an EIP1559 tx on bsc if tipGasPrice is set
20
+ `eip` will be set with s corresponding feature flag in the wallet
21
+ */
22
+ if (maxPriorityFeePerGas && eip1559Enabled) {
23
+ tx = FeeMarketEIP1559Transaction.fromTxData(
24
+ {
25
+ maxFeePerGas: gasPrice,
26
+ maxPriorityFeePerGas,
27
+ type: '0x02', // https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#gas-fee-market-transactions-eip-1559,
28
+ ...txData,
29
+ },
30
+ {
31
+ common: new Common({
32
+ chain,
33
+ hardfork: 'london',
34
+ customChains: CUSTOM_CHAINS,
35
+ eips: [1559],
36
+ }),
37
+ }
38
+ )
39
+ } else {
40
+ // Legacy tx
41
+ tx = Transaction.fromTxData(
42
+ { gasPrice, ...txData },
43
+ { common: Common.custom({ chainId: chain }) }
44
+ )
45
+ }
46
+ return tx
47
+ }
@@ -2,3 +2,4 @@ export { default as createUnsignedTx } from './create-unsigned-tx'
2
2
  export { default as parseUnsignedTx } from './parse-unsigned-tx'
3
3
  export { default as signUnsignedTx } from './sign-unsigned-tx'
4
4
  export { default as createAndSignTx } from './create-and-sign-tx'
5
+ export { default as createEthereumJsTx } from './create-ethereumjs-tx'
@@ -1,52 +1,12 @@
1
1
  /* @flow */
2
- import { Transaction, FeeMarketEIP1559Transaction } from '@exodus/ethereumjs-tx'
3
- import Common from '@exodus/ethereumjs-common'
4
-
5
2
  import type { UnsignedTransaction, SignedTransaction } from '@exodus/models/lib/types'
6
- import { CUSTOM_CHAINS } from '../constants'
3
+ import createEthereumJsTx from './create-ethereumjs-tx'
7
4
 
8
5
  export default function signUnsignedTx(
9
6
  unsignedTx: UnsignedTransaction,
10
7
  privateKey: Buffer
11
8
  ): SignedTransaction {
12
- const {
13
- txData: { gasPrice, tipGasPrice: maxPriorityFeePerGas, chainId: chain, ...txData },
14
- txMeta: { eip1559Enabled },
15
- } = unsignedTx
16
-
17
- let tx
18
- /*
19
- To assemble an EIP 1559 tx,
20
- both `tipGasPrice` and `eip` must have been set in the input object used to build `unsignedTx`.
21
- Whether bsc will support EIP 1559 is unknown.
22
- So we must prevent building accidentally an EIP1559 tx on bsc if tipGasPrice is set
23
- `eip` will be set with s corresponding feature flag in the wallet
24
- */
25
- if (maxPriorityFeePerGas && eip1559Enabled) {
26
- tx = FeeMarketEIP1559Transaction.fromTxData(
27
- {
28
- maxFeePerGas: gasPrice,
29
- maxPriorityFeePerGas,
30
- type: '0x02', // https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#gas-fee-market-transactions-eip-1559,
31
- ...txData,
32
- },
33
- {
34
- common: new Common({
35
- chain,
36
- hardfork: 'london',
37
- customChains: CUSTOM_CHAINS,
38
- eips: [1559],
39
- }),
40
- }
41
- )
42
- } else {
43
- // Legacy tx
44
- tx = Transaction.fromTxData(
45
- { gasPrice, ...txData },
46
- { common: Common.custom({ chainId: chain }) }
47
- )
48
- }
49
-
9
+ const tx = createEthereumJsTx(unsignedTx)
50
10
  const signedTx = tx.sign(privateKey)
51
11
 
52
12
  // serialize and get txId
@@ -137,6 +137,7 @@ export const isRpcBalanceAsset = (asset) =>
137
137
  'fantommainnet',
138
138
  'rootstock',
139
139
  'ethereumarbone',
140
+ 'optimism',
140
141
  ...customTokensWithRpcBalance,
141
142
  ].includes(asset.name) || asset.baseAsset.name === 'rootstock'
142
143