@exodus/web3-ethereum 12.20.0 → 12.21.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/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { EthereumProvider } from './provider/index.js';
2
2
  export { ExodusEthereumWallet } from './wallet-standard/index.js';
3
3
  export { registerRPCHandlers } from './rpc-handlers/index.js';
4
+ export type { EVMDeps } from './types.js';
@@ -71,22 +71,39 @@ export function exposeHandlers(rpc, deps) {
71
71
  throw new UnauthorizedError();
72
72
  }
73
73
  }
74
+ // Fee data might be not available in rare cases if the monitors hasn't yet started.
75
+ // In that case we'll fetch the actual gas price and treat the transaction as legacy (no EIP-1559).
76
+ async function gracefullyHandleMissingFeeData() {
77
+ const feeData = await getFeeData();
78
+ if (feeData) {
79
+ return feeData;
80
+ }
81
+ const gasPrice = (await forwardRequest({
82
+ method: 'eth_gasPrice',
83
+ }));
84
+ return {
85
+ gasPrice,
86
+ };
87
+ }
74
88
  async function prepareTransaction(transaction) {
75
- const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = await getFeeData();
76
- const eip1559Enabled = maxFeePerGas !== undefined && maxPriorityFeePerGas !== undefined;
89
+ const transactionNeedsGasPrice = !transaction.gasPrice || !transaction.maxFeePerGas;
77
90
  const preparedTransaction = { ...transaction };
78
91
  preparedTransaction.nonce = await getNonce();
79
92
  if (!transaction.value) {
80
93
  preparedTransaction.value = '0x0';
81
94
  }
82
- if (!transaction.gasPrice && !eip1559Enabled) {
83
- preparedTransaction.gasPrice = gasPrice;
84
- }
85
- if (!transaction.maxFeePerGas && eip1559Enabled) {
86
- preparedTransaction.maxFeePerGas = maxFeePerGas;
87
- }
88
- if (!transaction.maxPriorityFeePerGas && eip1559Enabled) {
89
- preparedTransaction.maxPriorityFeePerGas = maxPriorityFeePerGas;
95
+ if (transactionNeedsGasPrice) {
96
+ const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = await gracefullyHandleMissingFeeData();
97
+ const eip1559Enabled = maxFeePerGas !== undefined && maxPriorityFeePerGas !== undefined;
98
+ if (!transaction.gasPrice && !eip1559Enabled) {
99
+ preparedTransaction.gasPrice = gasPrice;
100
+ }
101
+ if (!transaction.maxFeePerGas && eip1559Enabled) {
102
+ preparedTransaction.maxFeePerGas = maxFeePerGas;
103
+ }
104
+ if (!transaction.maxPriorityFeePerGas && eip1559Enabled) {
105
+ preparedTransaction.maxPriorityFeePerGas = maxPriorityFeePerGas;
106
+ }
90
107
  }
91
108
  if (!transaction.data) {
92
109
  preparedTransaction.data = '0x';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/web3-ethereum",
3
3
  "description": "Apps connectivity library for EVM-compatible chains.",
4
- "version": "12.20.0",
4
+ "version": "12.21.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -51,5 +51,5 @@
51
51
  "@exodus/web3-validation": "^1.38.0",
52
52
  "@wallet-standard/base": "^1.0.1"
53
53
  },
54
- "gitHead": "05698eaa248101096af41b749fd8bee915145650"
54
+ "gitHead": "4cf17dd4153a6f326ae87e90c8827797628056fa"
55
55
  }