@exodus/web3-ethereum-utils 4.7.0 → 4.7.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.
@@ -1,12 +1,4 @@
1
1
  import BN from 'bn.js';
2
- import type { Asset } from '@exodus/web3-types';
3
- import type { CreateCurrencyParams } from '@exodus/web3-utils';
4
- export declare const getCreateCurrencyParams: (asset: Asset, amount: CreateCurrencyParams["amount"]) => {
5
- amount: string | number;
6
- base: string;
7
- symbol: string;
8
- denominator: number;
9
- };
10
2
  interface BlowfishEvmChain {
11
3
  [key: string]: {
12
4
  network: string;
@@ -1,10 +1,4 @@
1
1
  import BN from 'bn.js';
2
- export const getCreateCurrencyParams = (asset, amount) => ({
3
- amount,
4
- base: 'wei',
5
- symbol: asset.displayTicker,
6
- denominator: asset.units[asset.ticker],
7
- });
8
2
  export const BLOWFISH_EVM_CHAINS = {
9
3
  avalanchec: {
10
4
  network: 'avalanche',
@@ -8,15 +8,14 @@
8
8
  However, a final fee for non-simple transfers is always calculated on-chain once the EVM executes a transaction
9
9
  and has the number of gas consumed.
10
10
  */
11
- import { createCurrency, hexToBN } from '@exodus/web3-utils';
12
- import { getCreateCurrencyParams } from './common.js';
11
+ import { hexToBN } from '@exodus/web3-utils';
13
12
  export const estimateFee = ({ asset, transaction, }) => {
14
13
  const gas = hexToBN(transaction.gas);
15
14
  if (transaction.maxFeePerGas) {
16
15
  const maxFeePerGas = hexToBN(transaction.maxFeePerGas);
17
16
  const maximumFee = gas.mul(maxFeePerGas);
18
- return createCurrency(getCreateCurrencyParams(asset, maximumFee.toString()));
17
+ return asset.currency.baseUnit(maximumFee.toString());
19
18
  }
20
19
  const gasPrice = hexToBN(transaction.gasPrice);
21
- return createCurrency(getCreateCurrencyParams(asset, gas.mul(gasPrice).toString()));
20
+ return asset.currency.baseUnit(gas.mul(gasPrice).toString());
22
21
  };
@@ -6,8 +6,7 @@
6
6
  Even empty `data` field transactions ("0x") can cause unexpected state changes if sent to a smart contract
7
7
  with a gas limit exceeding 21000 units.
8
8
  */
9
- import { createCurrency, hexToBN } from '@exodus/web3-utils';
10
- import { getCreateCurrencyParams } from './common.js';
9
+ import { hexToBN } from '@exodus/web3-utils';
11
10
  import { isSimpleTransfer } from '../transactions.js';
12
11
  export class NotSimpleTransferError extends Error {
13
12
  constructor(msg) {
@@ -19,5 +18,5 @@ export const estimateSimpleTransfer = ({ asset, transaction, }) => {
19
18
  throw new NotSimpleTransferError('The transaction input should be empty ("0x").');
20
19
  }
21
20
  const txValue = hexToBN(transaction.value || '0x0').toString();
22
- return createCurrency(getCreateCurrencyParams(asset, txValue));
21
+ return asset.currency.baseUnit(txValue);
23
22
  };
@@ -1,5 +1,3 @@
1
- import { createCurrency } from '@exodus/web3-utils';
2
- import { getCreateCurrencyParams } from './common.js';
3
1
  import { estimateSimpleTransfer, NotSimpleTransferError, } from './estimateSimpleTransfer.js';
4
2
  /*
5
3
  Mutates the provided 'simulationResult' adding a 'willSend' entry if the transaction is a simple transfer.
@@ -9,7 +7,7 @@ export const tryEstimatingChangesLocally = ({ asset, simulationResult, transacti
9
7
  try {
10
8
  const estimatedValue = estimateSimpleTransfer({ asset, transaction });
11
9
  const actualTransferValue = transaction.from.toLowerCase() === transaction.to.toLowerCase()
12
- ? createCurrency(getCreateCurrencyParams(asset, 0)) // A self-send does not transfer any funds.
10
+ ? asset.currency.ZERO // A self-send does not transfer any funds.
13
11
  : estimatedValue;
14
12
  simulationResult.balanceChanges.willSend.push({
15
13
  balance: actualTransferValue,
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": "4.7.0",
4
+ "version": "4.7.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -50,5 +50,5 @@
50
50
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Aweb3-ethereum-utils"
51
51
  },
52
52
  "homepage": "https://github.com/ExodusMovement/assets/tree/master/web3/web3-ethereum-utils",
53
- "gitHead": "600b3f3f510e30333080011e85958f71835e020c"
53
+ "gitHead": "db330dc364fca76569899c315c7e491a5e0cca24"
54
54
  }