@exodus/web3-ethereum-utils 1.10.0 → 1.11.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.
@@ -0,0 +1,7 @@
1
+ import type { EthTransaction } from '../types.js';
2
+ import type { NumberUnit } from '@exodus/web3-types';
3
+ import type { Asset } from '@exodus/web3-types';
4
+ export declare const estimateSimpleTransfer: ({ asset, transaction, }: {
5
+ asset: Asset;
6
+ transaction: EthTransaction;
7
+ }) => NumberUnit | never;
@@ -0,0 +1,21 @@
1
+ /*
2
+ This utility determines whether the provided transaction is a simple native token transfer
3
+ and returns the value it's sending if that's true. Throws an error otherwise.
4
+
5
+ Note: only simple transfers (non-smart contract calls) can be reliably evaluated locally.
6
+ Even empty `data` field transactions ("0x") can cause unexpected state changes if sent to a smart contract
7
+ with a gas limit exceeding 21000 units.
8
+ */
9
+ import { hexToBN } from '@exodus/web3-utils';
10
+ export const estimateSimpleTransfer = ({ asset, transaction, }) => {
11
+ // Transaction shouldn't provide any parameters to a smart contract.
12
+ if (!['0x', null, undefined].includes(transaction.data)) {
13
+ throw new Error('Non-empty transaction input.');
14
+ }
15
+ // Simple transfers should consume 21.000 (constant) units of gas.
16
+ if (![undefined, '0x5208'].includes(transaction.gas)) {
17
+ throw new Error('Gas value is too high.');
18
+ }
19
+ const txValue = hexToBN(transaction.value || '0x0').toString();
20
+ return asset.currency.baseUnit(txValue);
21
+ };
package/lib/types.d.ts CHANGED
@@ -31,6 +31,10 @@ export declare type EthParentCapability = 'eth_accounts';
31
31
  export interface EthWalletPermission {
32
32
  parentCapability: EthParentCapability;
33
33
  }
34
+ export interface EthWalletRequestPermission {
35
+ walletPermissions: EthWalletPermission[];
36
+ selectedWallet: string | null;
37
+ }
34
38
  export declare type EthWalletWatchAssetOptions = {
35
39
  address: string;
36
40
  symbol?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exodus/web3-ethereum-utils",
3
3
  "description": "Web3 Ethereum utils.",
4
- "version": "1.10.0",
4
+ "version": "1.11.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -26,13 +26,13 @@
26
26
  "build": "yarn clean && tsc"
27
27
  },
28
28
  "devDependencies": {
29
- "@exodus/web3-types": "^1.16.0"
29
+ "@exodus/web3-types": "^1.17.0"
30
30
  },
31
31
  "dependencies": {
32
32
  "@exodus/ethereumjs-common": "^2.4.0-exodus.6",
33
33
  "@exodus/ethereumjs-tx": "^3.3.0-exodus.6",
34
- "@exodus/web3-utils": "^1.5.0",
34
+ "@exodus/web3-utils": "^1.6.0",
35
35
  "@metamask/eth-sig-util": "^4.0.1"
36
36
  },
37
- "gitHead": "88c28467495b5524e3d0d0080e58ea9d5fbe7b11"
37
+ "gitHead": "a9cd4485d1f90608ba4e38dd0d9bd237768d6009"
38
38
  }