@exodus/web3-ethereum-utils 4.7.2 → 4.7.4

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,3 +1,3 @@
1
1
  import type { EthAggregatedTransactionSimulationResult, EthSimulateTransactionParams } from './types.js';
2
2
  import type { CreateSimulateTransactionsParams } from '@exodus/web3-types';
3
- export declare const createSimulateTransactions: ({ apiEndpoint, headers: headersFromDeps }: Required<CreateSimulateTransactionsParams>) => ({ transactions, asset, origin, headers: headersFromParams, overrideApiEndpoint, }: EthSimulateTransactionParams) => Promise<EthAggregatedTransactionSimulationResult>;
3
+ export declare const createSimulateTransactions: ({ apiEndpoint, headers: headersFromDeps }: Required<CreateSimulateTransactionsParams>) => ({ transactions, asset, origin, blockNumber, headers: headersFromParams, overrideApiEndpoint, }: EthSimulateTransactionParams) => Promise<EthAggregatedTransactionSimulationResult>;
@@ -3,7 +3,7 @@ import { estimateFee } from './simulation/estimateFee.js';
3
3
  import { simulateTransactions } from './simulation/simulateTransactions.js';
4
4
  import { tryEstimatingChangesLocally } from './simulation/tryEstimatingChangesLocally.js';
5
5
  import { decodeRecipientAddresses, getDisplayDetails, getTxFeeDetails } from './transactions.js';
6
- export const createSimulateTransactions = ({ apiEndpoint, headers: headersFromDeps }) => async ({ transactions, asset, origin, headers: headersFromParams, overrideApiEndpoint, }) => {
6
+ export const createSimulateTransactions = ({ apiEndpoint, headers: headersFromDeps }) => async ({ transactions, asset, origin, blockNumber, headers: headersFromParams, overrideApiEndpoint, }) => {
7
7
  const headers = { ...headersFromDeps, ...headersFromParams };
8
8
  const simulationResult = createEmptySimulationResult({
9
9
  asset,
@@ -43,6 +43,7 @@ export const createSimulateTransactions = ({ apiEndpoint, headers: headersFromDe
43
43
  transactions,
44
44
  apiEndpoint: overrideApiEndpoint || apiEndpoint,
45
45
  origin,
46
+ blockNumber,
46
47
  simulationResult,
47
48
  headers,
48
49
  });
@@ -1,6 +1,7 @@
1
1
  import type { EthAggregatedTransactionSimulationResult, EthSimulateTransactionParams } from '../types.js';
2
2
  import type { CreateSimulateTransactionsParams, SimulateTransactionsInternalResult } from '@exodus/web3-types';
3
3
  type SimulateTransactionParams = Required<Pick<CreateSimulateTransactionsParams, 'apiEndpoint'>> & Required<Pick<EthSimulateTransactionParams, 'asset' | 'transactions' | 'origin'>> & {
4
+ blockNumber?: EthSimulateTransactionParams['blockNumber'];
4
5
  simulationResult: EthAggregatedTransactionSimulationResult;
5
6
  headers?: Record<string, string>;
6
7
  };
@@ -9,5 +10,5 @@ export declare const enum SimulationErrorMessages {
9
10
  'SimulationFailed' = 1,
10
11
  'SimulationNotSupported' = 2
11
12
  }
12
- export declare const simulateTransactions: ({ transactions, apiEndpoint, origin, simulationResult, headers, asset, }: SimulateTransactionParams) => SimulateTransactionsInternalResult<undefined, SimulationErrorMessages>;
13
+ export declare const simulateTransactions: ({ transactions, apiEndpoint, origin, blockNumber, simulationResult, headers, asset, }: SimulateTransactionParams) => SimulateTransactionsInternalResult<undefined, SimulationErrorMessages>;
13
14
  export {};
@@ -5,20 +5,26 @@
5
5
  import { pick } from '@exodus/basic-utils';
6
6
  import { createCurrency, makeSimulationAPICall } from '@exodus/web3-utils';
7
7
  import { BLOWFISH_EVM_CHAINS, MAX_INT256_SOLIDITY } from './common.js';
8
- const convertTransactionToApiPayload = (transactions, origin) => ({
9
- txObjects: transactions.map((transaction) => ({
10
- from: transaction.from,
11
- to: transaction.to,
12
- data: transaction.data,
13
- value: transaction.value,
14
- gas: transaction.gas,
15
- gas_price: transaction.gasPrice,
16
- })),
17
- metadata: {
18
- origin,
19
- },
20
- userAccount: transactions[0].from,
21
- });
8
+ const convertTransactionToApiPayload = (transactions, origin, blockNumber) => {
9
+ const payload = {
10
+ txObjects: transactions.map((transaction) => ({
11
+ from: transaction.from,
12
+ to: transaction.to,
13
+ data: transaction.data,
14
+ value: transaction.value,
15
+ gas: transaction.gas,
16
+ gas_price: transaction.gasPrice,
17
+ })),
18
+ metadata: {
19
+ origin,
20
+ },
21
+ userAccount: transactions[0].from,
22
+ };
23
+ if (blockNumber !== undefined) {
24
+ payload.blockNumber = blockNumber;
25
+ }
26
+ return payload;
27
+ };
22
28
  const createBalanceAmount = (amount, { decimals, symbol }) => {
23
29
  const beforeAmount = createCurrency({
24
30
  amount: amount.before,
@@ -121,7 +127,7 @@ const simulationResultHasAssets = (expectedStateChanges) => {
121
127
  }
122
128
  return true;
123
129
  };
124
- export const simulateTransactions = async ({ transactions, apiEndpoint, origin, simulationResult, headers, asset, }) => {
130
+ export const simulateTransactions = async ({ transactions, apiEndpoint, origin, blockNumber, simulationResult, headers, asset, }) => {
125
131
  const successDefaultResult = {
126
132
  kind: 'success',
127
133
  value: undefined,
@@ -136,7 +142,7 @@ export const simulateTransactions = async ({ transactions, apiEndpoint, origin,
136
142
  //Only one user address is supported
137
143
  //Sending multiple transactions with different from addresses would lead to invalid results
138
144
  const userAddress = transactions[0].from;
139
- const payload = convertTransactionToApiPayload(transactions, origin);
145
+ const payload = convertTransactionToApiPayload(transactions, origin, blockNumber);
140
146
  if (!Object.hasOwnProperty.call(BLOWFISH_EVM_CHAINS, asset.name)) {
141
147
  // ToDo: accept a logger dep and log the error
142
148
  return successDefaultResult;
package/lib/types.d.ts CHANGED
@@ -46,6 +46,7 @@ export interface EthWalletWatchAsset {
46
46
  }
47
47
  export interface EthSimulateTransactionParams extends SimulateTransactionParams {
48
48
  transactions: EthTransaction[];
49
+ blockNumber?: string;
49
50
  headers?: Record<string, string>;
50
51
  }
51
52
  export interface EthFeeDetails {
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.2",
4
+ "version": "4.7.4",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "module": "lib/index.js",
@@ -35,7 +35,7 @@
35
35
  "test": "run -T exodus-test --jest --esbuild"
36
36
  },
37
37
  "devDependencies": {
38
- "@exodus/web3-types": "1.59.1"
38
+ "@exodus/web3-types": "1.59.2"
39
39
  },
40
40
  "dependencies": {
41
41
  "@exodus/basic-utils": "^3.0.1",
@@ -43,6 +43,7 @@
43
43
  "@exodus/ethereumjs": "^1.5.0",
44
44
  "@exodus/solidity-contract": "^1.2.1",
45
45
  "@exodus/web3-utils": "^1.50.1",
46
+ "bn.js": "^5.2.0",
46
47
  "minimalistic-assert": "^1.0.1"
47
48
  },
48
49
  "author": "Exodus Movement, Inc.",
@@ -50,5 +51,5 @@
50
51
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Aweb3-ethereum-utils"
51
52
  },
52
53
  "homepage": "https://github.com/ExodusMovement/assets/tree/master/web3/web3-ethereum-utils",
53
- "gitHead": "b8caae006a00c4d6c065732eb99183a15c169f72"
54
+ "gitHead": "69553b4abf01b543d0e6006299166b8f7cc6271c"
54
55
  }