@exodus/web3-ethereum 12.20.0 → 12.21.1

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';
@@ -132,6 +149,7 @@ export function exposeHandlers(rpc, deps) {
132
149
  }
133
150
  async function approveAndSignTransaction(transaction) {
134
151
  await assertTrusted();
152
+ await ensureUnlocked();
135
153
  const asset = await getAsset(network);
136
154
  const preparedTransaction = await prepareTransaction(transaction);
137
155
  validateTransaction(preparedTransaction);
@@ -163,6 +181,7 @@ export function exposeHandlers(rpc, deps) {
163
181
  }
164
182
  async function approveAndSignMessage(message) {
165
183
  await assertTrusted();
184
+ await ensureUnlocked();
166
185
  await approve(approveMessage, network, message);
167
186
  const walletAccount = await getActiveWalletAccountData();
168
187
  const asset = await getAsset(network);
@@ -177,6 +196,7 @@ export function exposeHandlers(rpc, deps) {
177
196
  }
178
197
  async function approveAndSignTypedData(typedData) {
179
198
  await assertTrusted();
199
+ await ensureUnlocked();
180
200
  const parsedTypedData = parseAndValidateTypedData(typedData, { chainId });
181
201
  const message = typedDataToMessage(typedData, SignTypedDataVersion.V4);
182
202
  await approve(approveMessage, network, message);
@@ -235,6 +255,7 @@ export function exposeHandlers(rpc, deps) {
235
255
  approveAndSignMessage(message));
236
256
  exposeEvmFunction('eth_signTypedData_v1', async (typedData) => {
237
257
  await assertTrusted();
258
+ await ensureUnlocked();
238
259
  const message = typedDataToMessage(typedData, SignTypedDataVersion.V1);
239
260
  await approve(approveMessage, network, message);
240
261
  const walletAccount = await getActiveWalletAccountData();
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.1",
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": "077c733bebfb35b62950f9bcc9cfde7dd523cb15"
55
55
  }