@exodus/web3-ethereum-utils 3.38.0 → 3.38.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/LICENSE +7 -0
- package/lib/createSimulateTransactions.js +1 -1
- package/lib/signatures.d.ts +1 -0
- package/lib/signatures.js +5 -4
- package/lib/simulation/simulateTransactions.d.ts +1 -1
- package/lib/transactions.d.ts +1 -0
- package/lib/transactions.js +1 -1
- package/lib/types.d.ts +4 -4
- package/package.json +20 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2024 Exodus Movement, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createEmptySimulationResult } from '@exodus/web3-utils';
|
|
2
2
|
import { estimateFee } from './simulation/estimateFee.js';
|
|
3
|
-
import { simulateTransactions
|
|
3
|
+
import { simulateTransactions } from './simulation/simulateTransactions.js';
|
|
4
4
|
import { tryEstimatingChangesLocally } from './simulation/tryEstimatingChangesLocally.js';
|
|
5
5
|
import { getDisplayDetails, getTxFeeDetails } from './transactions.js';
|
|
6
6
|
export const createSimulateTransactions = ({ apiEndpoint, headers }) => async ({ transactions, asset, origin, overrideApiEndpoint, }) => {
|
package/lib/signatures.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
3
|
import { SignTypedDataVersion } from '@metamask/eth-sig-util';
|
|
3
4
|
import type { EthTransactionParams } from './types.js';
|
|
4
5
|
import type { MessageTypes, TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';
|
package/lib/signatures.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import Common,
|
|
2
|
-
import { FeeMarketEIP1559Transaction, Transaction as LegacyTransaction, } from '@exodus/ethereumjs
|
|
1
|
+
import { Common, Hardfork } from '@exodus/ethereumjs/common';
|
|
2
|
+
import { FeeMarketEIP1559Transaction, Transaction as LegacyTransaction, } from '@exodus/ethereumjs/tx';
|
|
3
3
|
import { SignTypedDataVersion, personalSign, signTypedData as ethSigUtilSignTypedData, } from '@metamask/eth-sig-util';
|
|
4
|
+
const custom = Common.default?.custom || Common.custom;
|
|
4
5
|
export function signMessage(message, privateKey) {
|
|
5
6
|
return personalSign({ privateKey, data: message });
|
|
6
7
|
}
|
|
@@ -12,10 +13,10 @@ export function signTransaction(transactionParams, privateKey) {
|
|
|
12
13
|
const isEIP1559Enabled = !!transactionParams.maxFeePerGas;
|
|
13
14
|
const transaction = isEIP1559Enabled
|
|
14
15
|
? FeeMarketEIP1559Transaction.fromTxData(transactionData, {
|
|
15
|
-
common:
|
|
16
|
+
common: custom({ chainId }, { hardfork: Hardfork.London }),
|
|
16
17
|
})
|
|
17
18
|
: LegacyTransaction.fromTxData(transactionData, {
|
|
18
|
-
common:
|
|
19
|
+
common: custom({ chainId }),
|
|
19
20
|
});
|
|
20
21
|
const signedTransaction = transaction.sign(privateKey);
|
|
21
22
|
return signedTransaction.serialize();
|
|
@@ -1,6 +1,6 @@
|
|
|
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
4
|
simulationResult: EthAggregatedTransactionSimulationResult;
|
|
5
5
|
headers?: Record<string, string>;
|
|
6
6
|
};
|
package/lib/transactions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
3
|
import type { EthTransaction } from './types.js';
|
|
3
4
|
import type { ApprovalBalanceChange } from '@exodus/web3-types';
|
|
4
5
|
export declare function getTransactionId(serializedTransaction: Buffer, isEIP1559Transaction?: boolean): string;
|
package/lib/transactions.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FeeMarketEIP1559Transaction, Transaction as LegacyTransaction, } from '@exodus/ethereumjs
|
|
1
|
+
import { FeeMarketEIP1559Transaction, Transaction as LegacyTransaction, } from '@exodus/ethereumjs/tx';
|
|
2
2
|
export function getTransactionId(serializedTransaction, isEIP1559Transaction = false) {
|
|
3
3
|
const Transaction = isEIP1559Transaction
|
|
4
4
|
? FeeMarketEIP1559Transaction
|
package/lib/types.d.ts
CHANGED
|
@@ -25,15 +25,15 @@ export interface EthTransaction {
|
|
|
25
25
|
maxPriorityFeePerGas?: string;
|
|
26
26
|
maxFeePerGas?: string;
|
|
27
27
|
}
|
|
28
|
-
export
|
|
29
|
-
export
|
|
28
|
+
export type EthTransactionHash = string;
|
|
29
|
+
export type EthParentCapability = 'eth_accounts';
|
|
30
30
|
export interface EthWalletPermission {
|
|
31
31
|
parentCapability: EthParentCapability;
|
|
32
32
|
}
|
|
33
33
|
export interface EthWalletSwitchEthereumChain {
|
|
34
34
|
chainId: string;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type EthWalletWatchAssetOptions = {
|
|
37
37
|
address: string;
|
|
38
38
|
symbol?: string;
|
|
39
39
|
decimals?: number;
|
|
@@ -52,7 +52,7 @@ export interface EthFeeDetails {
|
|
|
52
52
|
maxFeePerGas: BN;
|
|
53
53
|
gasPrice: BN;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
55
|
+
export type EthAggregatedTransactionSimulationResult = AggregatedTransactionSimulationResult<EthFeeDetails>;
|
|
56
56
|
export interface EthSimulateMessageParams {
|
|
57
57
|
asset: Asset;
|
|
58
58
|
message: 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": "3.38.
|
|
4
|
+
"version": "3.38.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -18,23 +18,34 @@
|
|
|
18
18
|
"lib/**/*.js"
|
|
19
19
|
],
|
|
20
20
|
"publishConfig": {
|
|
21
|
-
"access": "
|
|
21
|
+
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"repository":
|
|
24
|
-
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
26
|
+
},
|
|
27
|
+
"license": "MIT",
|
|
25
28
|
"scripts": {
|
|
26
29
|
"clean": "run -T rimraf lib",
|
|
27
|
-
"build": "yarn clean && run -T tsc"
|
|
30
|
+
"build": "yarn clean && run -T tsc",
|
|
31
|
+
"lint": "run -T eslintc .",
|
|
32
|
+
"lint:fix": "yarn lint --fix",
|
|
33
|
+
"prepublishOnly": "yarn run -T build --scope @exodus/web3-ethereum-utils",
|
|
34
|
+
"test": "run -T exodus-test --jest --esbuild"
|
|
28
35
|
},
|
|
29
36
|
"devDependencies": {
|
|
30
37
|
"@exodus/web3-types": "1.52.0"
|
|
31
38
|
},
|
|
32
39
|
"dependencies": {
|
|
33
40
|
"@exodus/basic-utils": "^3.0.1",
|
|
34
|
-
"@exodus/ethereumjs
|
|
35
|
-
"@exodus/
|
|
36
|
-
"@exodus/web3-utils": "^1.48.2",
|
|
41
|
+
"@exodus/ethereumjs": "^1.0.0",
|
|
42
|
+
"@exodus/web3-utils": "^1.48.3",
|
|
37
43
|
"@metamask/eth-sig-util": "^4.0.1"
|
|
38
44
|
},
|
|
39
|
-
"
|
|
45
|
+
"author": "Exodus Movement, Inc.",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Aweb3-ethereum-utils"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://github.com/ExodusMovement/assets/tree/master/web3/web3-ethereum-utils",
|
|
50
|
+
"gitHead": "9f590f5439d73cba02054d608fb3d5c62fbdcf34"
|
|
40
51
|
}
|