@exodus/web3-ethereum 1.4.5 → 1.5.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.
@@ -2,6 +2,7 @@ import { AssetNotSupportedError, InvalidInputError, UnauthorizedError, UserRejec
2
2
  import { getTransactionId, signMessage, signTransaction, signTypedData, } from '@exodus/web3-ethereum-utils';
3
3
  import { SignTypedDataVersion } from '@metamask/eth-sig-util';
4
4
  import { parseAndValidateTypedData } from './parseAndValidateTypedData.js';
5
+ import { simulateTransaction } from '../simulation/index.js';
5
6
  // See: https://eips.ethereum.org/EIPS/eip-2255.
6
7
  const ETH_ACCOUNTS_PERMISSION = 'eth_accounts';
7
8
  const PROXIED_METHODS = [
@@ -47,7 +48,7 @@ version) {
47
48
  return typedData.toString();
48
49
  }
49
50
  export function exposeHandlers(rpc, deps) {
50
- const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = () => true, } = deps;
51
+ const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = () => true, asset, } = deps;
51
52
  const network = `evm:${chainId}`;
52
53
  async function assertTrusted() {
53
54
  const trusted = await isTrusted();
@@ -107,7 +108,8 @@ export function exposeHandlers(rpc, deps) {
107
108
  await assertTrusted();
108
109
  const preparedTransaction = await prepareTransaction(transaction);
109
110
  validateTransaction(preparedTransaction);
110
- await approve(approveTransactions, network, [preparedTransaction]);
111
+ const simulatedChanges = await simulateTransaction(asset, preparedTransaction);
112
+ await approve(approveTransactions, network, simulatedChanges);
111
113
  const privateKey = await getPrivateKey();
112
114
  const signedTransaction = signTransaction({ ...preparedTransaction, chainId }, privateKey);
113
115
  const isEIP1559Enabled = !!preparedTransaction.maxFeePerGas;
@@ -144,31 +144,35 @@ export function validateRequest(value) {
144
144
  return true
145
145
  })()
146
146
  const sub10 = (() => {
147
+ if (!(data[i] === null)) return false
148
+ return true
149
+ })()
150
+ const sub11 = (() => {
147
151
  if (!Array.isArray(data[i])) return false
148
152
  if (data[i].length < 1) return false
149
153
  for (let j = 0; j < data[i].length; j++) {
150
154
  if (j in data[i] && hasOwn(data[i], j)) {
151
- const sub11 = (() => {
155
+ const sub12 = (() => {
152
156
  if (!(typeof data[i][j] === 'number')) return false
153
157
  return true
154
158
  })()
155
- const sub12 = (() => {
159
+ const sub13 = (() => {
156
160
  if (!(typeof data[i][j] === 'string')) return false
157
161
  if (data[i][j].length > 100 && stringLength(data[i][j]) > 100)
158
162
  return false
159
163
  if (!format3.test(data[i][j])) return false
160
164
  return true
161
165
  })()
162
- if (!(sub11 || sub12)) return false
166
+ if (!(sub12 || sub13)) return false
163
167
  }
164
168
  }
165
169
  return true
166
170
  })()
167
- const sub13 = (() => {
171
+ const sub14 = (() => {
168
172
  if (!(Array.isArray(data[i]) && data[i].length === 0)) return false
169
173
  return true
170
174
  })()
171
- if (!(sub2 || sub3 || sub8 || sub9 || sub10 || sub13)) {
175
+ if (!(sub2 || sub3 || sub8 || sub9 || sub10 || sub11 || sub14)) {
172
176
  validate.errors = [
173
177
  { keywordLocation: '#/items/anyOf', instanceLocation: '#/' + i },
174
178
  ]
@@ -241,17 +245,17 @@ export function validateRequest(value) {
241
245
  }
242
246
  if ('chainId' in data && hasOwn(data, 'chainId')) {
243
247
  let passes1 = 0
244
- const sub14 = (() => {
248
+ const sub15 = (() => {
245
249
  if (!(typeof data.chainId === 'string')) return false
246
250
  if (!format4.test(data.chainId)) return false
247
251
  return true
248
252
  })()
249
- if (sub14) passes1++
250
- const sub15 = (() => {
253
+ if (sub15) passes1++
254
+ const sub16 = (() => {
251
255
  if (!(typeof data.chainId === 'number')) return false
252
256
  return true
253
257
  })()
254
- if (sub15) passes1++
258
+ if (sub16) passes1++
255
259
  if (passes1 !== 1) {
256
260
  validate.errors = [
257
261
  {
@@ -385,17 +389,17 @@ export function validateRequest(value) {
385
389
  hasOwn(data, 'maxPriorityFeePerGas')
386
390
  ) {
387
391
  let passes2 = 0
388
- const sub16 = (() => {
392
+ const sub17 = (() => {
389
393
  if (!(typeof data.maxPriorityFeePerGas === 'string')) return false
390
394
  if (!format1.test(data.maxPriorityFeePerGas)) return false
391
395
  return true
392
396
  })()
393
- if (sub16) passes2++
394
- const sub17 = (() => {
397
+ if (sub17) passes2++
398
+ const sub18 = (() => {
395
399
  if (!(data.maxPriorityFeePerGas === null)) return false
396
400
  return true
397
401
  })()
398
- if (sub17) passes2++
402
+ if (sub18) passes2++
399
403
  if (passes2 !== 1) {
400
404
  validate.errors = [
401
405
  {
@@ -408,17 +412,17 @@ export function validateRequest(value) {
408
412
  }
409
413
  if ('maxFeePerGas' in data && hasOwn(data, 'maxFeePerGas')) {
410
414
  let passes3 = 0
411
- const sub18 = (() => {
415
+ const sub19 = (() => {
412
416
  if (!(typeof data.maxFeePerGas === 'string')) return false
413
417
  if (!format1.test(data.maxFeePerGas)) return false
414
418
  return true
415
419
  })()
416
- if (sub18) passes3++
417
- const sub19 = (() => {
420
+ if (sub19) passes3++
421
+ const sub20 = (() => {
418
422
  if (!(data.maxFeePerGas === null)) return false
419
423
  return true
420
424
  })()
421
- if (sub19) passes3++
425
+ if (sub20) passes3++
422
426
  if (passes3 !== 1) {
423
427
  validate.errors = [
424
428
  {
@@ -1028,13 +1032,13 @@ export function validateRequest(value) {
1028
1032
  }
1029
1033
  if ('image' in data && hasOwn(data, 'image')) {
1030
1034
  let passes4 = 0
1031
- const sub20 = (() => {
1035
+ const sub21 = (() => {
1032
1036
  if (!(typeof data.image === 'string')) return false
1033
1037
  if (!format6.test(data.image)) return false
1034
1038
  return true
1035
1039
  })()
1036
- if (sub20) passes4++
1037
- const sub21 = (() => {
1040
+ if (sub21) passes4++
1041
+ const sub22 = (() => {
1038
1042
  const err38 = validate.errors
1039
1043
  const res38 = ref16(data.image)
1040
1044
  const suberr38 = ref16.errors
@@ -1042,7 +1046,7 @@ export function validateRequest(value) {
1042
1046
  if (!res38) return false
1043
1047
  return true
1044
1048
  })()
1045
- if (sub21) passes4++
1049
+ if (sub22) passes4++
1046
1050
  if (passes4 !== 1) {
1047
1051
  validate.errors = [
1048
1052
  {
@@ -1,18 +1,10 @@
1
+ import type { Asset } from '@exodus/web3-types';
2
+ export { Asset };
1
3
  export interface CurrencyParams {
2
4
  amount: string;
3
5
  symbol: string;
4
6
  denominator: number;
5
7
  }
6
- export interface Asset {
7
- name: string;
8
- displayTicker: string;
9
- currency: {
10
- defaultUnit: {
11
- power: number;
12
- };
13
- baseUnit: (args: unknown) => unknown;
14
- };
15
- }
16
8
  export interface EthBalanceChanges {
17
9
  willReceive: Array<EthBalanceChange>;
18
10
  willSend: Array<EthBalanceChange>;
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": "1.4.5",
4
+ "version": "1.5.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -33,22 +33,22 @@
33
33
  "dependencies": {
34
34
  "@exodus/currency": "^2.1.2",
35
35
  "@exodus/ethereum-api": "^3.2.4",
36
- "@exodus/web3-constants": "^1.14.0",
36
+ "@exodus/web3-constants": "^1.15.0",
37
37
  "@exodus/web3-ethereum-utils": "^1.8.0",
38
- "@exodus/web3-provider": "^2.12.0",
39
- "@exodus/web3-rpc-handlers": "^0.7.0",
38
+ "@exodus/web3-provider": "^2.13.0",
39
+ "@exodus/web3-rpc-handlers": "^0.8.0",
40
40
  "eth-rpc-errors": "^4.0.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@exodus/assets": "^8.0.72",
44
44
  "@exodus/json-rpc": "^1.11.0",
45
45
  "@exodus/schemasafe": "^1.0.0",
46
- "@exodus/web3-types": "^1.10.0",
47
- "@exodus/web3-validation": "^1.29.1",
46
+ "@exodus/web3-types": "^1.11.0",
47
+ "@exodus/web3-validation": "^1.29.2",
48
48
  "@wallet-standard/base": "^1.0.1"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@exodus/assets": "^8.0.72"
52
52
  },
53
- "gitHead": "e48f74f32e040de9e86ef77ea48058d5c0b36c86"
53
+ "gitHead": "4a0c077d0175fe3c6a35e2f9a459f8cad214e8f6"
54
54
  }