@exodus/ethereum-api 8.3.0 → 8.3.2

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-api",
3
- "version": "8.3.0",
3
+ "version": "8.3.2",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -58,5 +58,5 @@
58
58
  "cross-fetch": "^3.1.5",
59
59
  "delay": "4.0.1"
60
60
  },
61
- "gitHead": "7fee55f46b28a0472a166f76e5d06b0f4c99457d"
61
+ "gitHead": "11a9b2f22c847d15a678534743f628adf15b0a2e"
62
62
  }
@@ -14,7 +14,6 @@ import {
14
14
  encodePrivate,
15
15
  encodePublicFactory,
16
16
  hasChecksum,
17
- parseUnsignedTx,
18
17
  signUnsignedTx,
19
18
  signUnsignedTxWithSigner,
20
19
  signMessage,
@@ -230,13 +229,11 @@ export const createAssetFactory = ({
230
229
  getSupportedPurposes: () => [44],
231
230
  getTokens,
232
231
  hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
233
- parseUnsignedTx: (unsignedTx, { asset }) => parseUnsignedTx(asset, unsignedTx),
234
232
  sendTx,
235
233
  signTx: ({ unsignedTx, privateKey, signer }) =>
236
234
  signer
237
235
  ? signUnsignedTxWithSigner(unsignedTx, signer)
238
236
  : signUnsignedTx(unsignedTx, privateKey),
239
- signUnsignedTx,
240
237
  signHardware: signHardwareFactory({ baseAssetName: asset.name }),
241
238
  signMessage: ({ message, privateKey, signer }) =>
242
239
  signer ? signMessageWithSigner({ message, signer }) : signMessage({ privateKey, message }),
@@ -90,7 +90,7 @@ const getFeeAsyncFactory = ({
90
90
  const l1DataFee = optimismL1DataFee
91
91
  ? asset.baseAsset.currency.baseUnit(optimismL1DataFee)
92
92
  : asset.baseAsset.currency.ZERO
93
- return { fee: fee.add(l1DataFee), gasLimit, ...rest }
93
+ return { fee: fee.add(l1DataFee), optimismL1DataFee, gasLimit, ...rest }
94
94
  }
95
95
  }
96
96
 
@@ -17,6 +17,9 @@ export const createEthereumHooks = ({
17
17
  baseAssetName: assetName,
18
18
  })
19
19
 
20
+ // some assets may not be available
21
+ const stakingAssets = stakingAssetNames.map((assetName) => assets[assetName]).filter(Boolean)
22
+
20
23
  const userAddress = await assetClientInterface.getReceiveAddress({
21
24
  assetName,
22
25
  walletAccount,
@@ -27,19 +30,18 @@ export const createEthereumHooks = ({
27
30
  staking: Object.create(null),
28
31
  }
29
32
 
30
- for (const stakingAssetName of stakingAssetNames) {
33
+ for (const asset of stakingAssets) {
34
+ const stakingAssetName = asset.name
31
35
  const getStakingInfo =
32
36
  stakingAssetName === 'polygon' ? getPolygonStakingInfo : getEthereumStakingInfo
33
- const asset = assets[stakingAssetName]
34
- if (asset) {
35
- // asset may not be enabled in the wallet
36
- const assetStakingInfo = await getStakingInfo({
37
- address: userAddress.toString(),
38
- asset,
39
- server,
40
- })
41
- stakingInfo.staking[stakingAssetName] = assetStakingInfo
42
- }
37
+
38
+ // asset may not be enabled in the wallet
39
+ const assetStakingInfo = await getStakingInfo({
40
+ address: userAddress.toString(),
41
+ asset,
42
+ server,
43
+ })
44
+ stakingInfo.staking[stakingAssetName] = assetStakingInfo
43
45
  }
44
46
 
45
47
  const batch = assetClientInterface.createOperationsBatch()
@@ -50,9 +52,9 @@ export const createEthereumHooks = ({
50
52
  batch,
51
53
  })
52
54
 
53
- const processTxLogsPromises = stakingAssetNames.map((stakingAssetName) => {
55
+ const processTxLogsPromises = stakingAssets.map((asset) => {
54
56
  return processTxLog({
55
- asset: assets[stakingAssetName],
57
+ asset,
56
58
  assetClientInterface,
57
59
  walletAccount,
58
60
  batch,
@@ -162,7 +162,7 @@ const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
162
162
  gasLimit,
163
163
  replacedTxId: bumpTxId,
164
164
  nonce,
165
- tipGasPrice: tipGasPrice.toBaseString(),
165
+ ...(tipGasPrice ? { tipGasPrice: tipGasPrice.toBaseString() } : {}),
166
166
  }
167
167
  : { gasLimit, replacedTxId: bumpTxId, nonce },
168
168
  },
@@ -193,7 +193,7 @@ const txSendFactory = ({ assetClientInterface, createUnsignedTx }) => {
193
193
  gasLimit,
194
194
  replacedTxId: bumpTxId,
195
195
  nonce,
196
- tipGasPrice: tipGasPrice.toBaseString(),
196
+ ...(tipGasPrice ? { tipGasPrice: tipGasPrice.toBaseString() } : {}),
197
197
  }
198
198
  : { gasLimit, replacedTxId: bumpTxId, nonce },
199
199
  },
@@ -245,7 +245,14 @@ const createTx = async ({
245
245
 
246
246
  if (eip1559Enabled) {
247
247
  if (customGasPrice) {
248
- gasPrice = customGasPrice
248
+ gasPrice = customGasPrice // aka maxFeePerGas
249
+
250
+ // We must ensure maxPriorityFeePerGas <= maxFeePerGas or our transaction library throws an error
251
+ // It's a bit counterintuitive since maxPriorityFeePerGas should only contain the tip,
252
+ // so we should be subtracting the base gas price from the custom gas price to keep just the tip
253
+ // but the fee is also limited by our maxFeePerGas above, so that implicitly captures the max tip.
254
+ // Setting this tipGasPrice to undefined will result in a legacy transaction (not an EIP1559 anymore)
255
+ tipGasPrice = customGasPrice // aka maxPriorityFeePerGas
249
256
  }
250
257
 
251
258
  if (isSendAll && !isToken) {