@exodus/web3-ethereum 2.9.0 → 2.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.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const createEvmDepsFactory: ({
|
|
1
|
+
import type { CreateEvmDepsFactoryParams, EVMFactory } from '../types.js';
|
|
2
|
+
declare const createEvmDepsFactory: ({ analytics, blockchainMetadata, }: CreateEvmDepsFactoryParams) => EVMFactory;
|
|
3
3
|
export default createEvmDepsFactory;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fetchGasLimit, getNonce as apiGetNonce, getServer, } from '@exodus/ethereum-api';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
|
-
const createEvmDepsFactory = ({
|
|
4
|
-
return (assetName, origin) => {
|
|
5
|
-
const asset =
|
|
3
|
+
const createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
4
|
+
return ({ assetName, origin, getAsset, getAddress: _getAddress, getPrivateKey: _getPrivateKey, getFeeData: getFeeConfig, getActiveWalletAccount, }) => {
|
|
5
|
+
const asset = getAsset(assetName);
|
|
6
6
|
const server = getServer(asset);
|
|
7
7
|
const forwardRequest = async ({ method, params }) => {
|
|
8
8
|
if (server.proxyToCoinNode) {
|
|
@@ -14,39 +14,18 @@ const createEvmDepsFactory = ({ addressProvider, analytics, activeWalletAccountA
|
|
|
14
14
|
const sendRawTransaction = async (rawTransaction) => {
|
|
15
15
|
return server.sendRawTransaction(rawTransaction);
|
|
16
16
|
};
|
|
17
|
-
const _getAccountIndexForActiveWalletAccount = async () => {
|
|
18
|
-
const walletAccount = await activeWalletAccountAtom.get();
|
|
19
|
-
const walletAccountData = walletAccounts.get(walletAccount);
|
|
20
|
-
if (!walletAccountData ||
|
|
21
|
-
walletAccountData.isHardware ||
|
|
22
|
-
walletAccountData.is2FA) {
|
|
23
|
-
throw new Error('Invalid walletAccount');
|
|
24
|
-
}
|
|
25
|
-
const accountIndex = walletAccountData.index;
|
|
26
|
-
return accountIndex;
|
|
27
|
-
};
|
|
28
17
|
const getAddress = async () => {
|
|
29
|
-
|
|
30
|
-
const walletAccountData = walletAccounts.get(walletAccount);
|
|
31
|
-
const { address } = await addressProvider.getReceiveAddress({
|
|
32
|
-
assetName,
|
|
33
|
-
walletAccount: walletAccountData,
|
|
34
|
-
});
|
|
35
|
-
return address;
|
|
18
|
+
return _getAddress(assetName);
|
|
36
19
|
};
|
|
37
20
|
const getPrivateKey = async () => {
|
|
38
|
-
const
|
|
39
|
-
const { privateKey } = await wallet.getPrivateKey({
|
|
40
|
-
baseAssetName: assetName,
|
|
41
|
-
accountIndex,
|
|
42
|
-
});
|
|
21
|
+
const { privateKey } = await _getPrivateKey(assetName);
|
|
43
22
|
return privateKey;
|
|
44
23
|
};
|
|
45
24
|
const getNonce = async () => {
|
|
46
25
|
const [baseAssetTxLog, blockchainNonce] = await Promise.all([
|
|
47
26
|
blockchainMetadata.getTxLog({
|
|
48
27
|
assetName,
|
|
49
|
-
walletAccount: await
|
|
28
|
+
walletAccount: await getActiveWalletAccount(),
|
|
50
29
|
}),
|
|
51
30
|
apiGetNonce({ asset, address: await getAddress() }),
|
|
52
31
|
]);
|
|
@@ -71,7 +50,7 @@ const createEvmDepsFactory = ({ addressProvider, analytics, activeWalletAccountA
|
|
|
71
50
|
return `0x${gasLimit.toString(16)}`;
|
|
72
51
|
};
|
|
73
52
|
const getFeeData = async () => {
|
|
74
|
-
const { eip1559Enabled, tipGasPrice, gasPrice: _gasPrice, } = await
|
|
53
|
+
const { eip1559Enabled, tipGasPrice, gasPrice: _gasPrice, } = await getFeeConfig({
|
|
75
54
|
assetName,
|
|
76
55
|
});
|
|
77
56
|
const gasPrice = `0x${_gasPrice.toBaseNumber().toString(16)}`;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { EthTransaction, EthTransactionHash, EthWalletWatchAsset } from '@exodus/web3-ethereum-utils';
|
|
3
3
|
import type { CommonDeps } from '@exodus/web3-rpc-handlers';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Asset, IAnalyticsModule, IBlockchainMetadataModule, ApproveConnectionResponse, EthereumFeeData, GetFeeDataParams } from '@exodus/web3-types';
|
|
5
5
|
/**
|
|
6
6
|
* EVM-compatible chains.
|
|
7
7
|
*/
|
|
@@ -14,17 +14,22 @@ export interface FeeData {
|
|
|
14
14
|
maxFeePerGas?: string;
|
|
15
15
|
maxPriorityFeePerGas?: string;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
18
|
-
addressProvider: IAddressProvider;
|
|
19
|
-
activeWalletAccountAtom: IActiveWalletAccountAtom;
|
|
17
|
+
export interface CreateEvmDepsFactoryParams {
|
|
20
18
|
analytics: IAnalyticsModule;
|
|
21
|
-
assetsModule: IAssetsModule;
|
|
22
19
|
blockchainMetadata: IBlockchainMetadataModule;
|
|
23
|
-
feeMonitors: IFeeDataModule;
|
|
24
|
-
wallet: IWalletModule;
|
|
25
|
-
walletAccounts: IWalletAccountsModule;
|
|
26
20
|
}
|
|
27
|
-
export
|
|
21
|
+
export interface CreateEvmDepsParams {
|
|
22
|
+
assetName: string;
|
|
23
|
+
origin: string;
|
|
24
|
+
getAddress: (assetName: string) => Promise<string>;
|
|
25
|
+
getActiveWalletAccount: () => Promise<string>;
|
|
26
|
+
getAsset: (assetName: string) => Asset;
|
|
27
|
+
getFeeData: ({ assetName }: GetFeeDataParams) => Promise<EthereumFeeData>;
|
|
28
|
+
getPrivateKey: (assetName: string) => Promise<{
|
|
29
|
+
privateKey: Buffer;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export declare type EVMFactory = (params: CreateEvmDepsParams) => EVMDeps;
|
|
28
33
|
export declare type EVMDeps = {
|
|
29
34
|
chainId: string;
|
|
30
35
|
getAddress: () => Promise<string>;
|
|
@@ -39,4 +44,4 @@ export declare type EVMDeps = {
|
|
|
39
44
|
export declare type Dependencies = {
|
|
40
45
|
evms: EVMDeps[];
|
|
41
46
|
} & CommonDeps;
|
|
42
|
-
export { ApproveConnectionResponse
|
|
47
|
+
export { ApproveConnectionResponse };
|
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": "2.
|
|
4
|
+
"version": "2.11.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@exodus/currency": "^2.1.2",
|
|
35
35
|
"@exodus/ethereum-api": "^6.0.0",
|
|
36
|
-
"@exodus/web3-constants": "^1.
|
|
37
|
-
"@exodus/web3-ethereum-utils": "^1.
|
|
38
|
-
"@exodus/web3-provider": "^2.
|
|
39
|
-
"@exodus/web3-rpc-handlers": "^0.
|
|
40
|
-
"@exodus/web3-utils": "^1.
|
|
36
|
+
"@exodus/web3-constants": "^1.23.0",
|
|
37
|
+
"@exodus/web3-ethereum-utils": "^1.13.0",
|
|
38
|
+
"@exodus/web3-provider": "^2.21.0",
|
|
39
|
+
"@exodus/web3-rpc-handlers": "^0.18.0",
|
|
40
|
+
"@exodus/web3-utils": "^1.9.0",
|
|
41
41
|
"bn.js": "^5.2.0",
|
|
42
42
|
"eth-rpc-errors": "^4.0.3"
|
|
43
43
|
},
|
|
@@ -45,11 +45,12 @@
|
|
|
45
45
|
"@exodus/assets": "^8.0.72",
|
|
46
46
|
"@exodus/json-rpc": "^1.11.0",
|
|
47
47
|
"@exodus/schemasafe": "^1.0.0",
|
|
48
|
-
"@exodus/web3-types": "^1.
|
|
48
|
+
"@exodus/web3-types": "^1.19.0",
|
|
49
49
|
"@exodus/web3-validation": "^1.34.0",
|
|
50
50
|
"@wallet-standard/base": "^1.0.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@exodus/assets": "^8.0.72"
|
|
54
|
-
}
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "ee026a5dba0f36d61545cbb7fbecbbd143355ded"
|
|
55
56
|
}
|