@exodus/web3-ethereum 6.2.2 → 8.0.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
1
|
import type { CreateEvmDepsFactoryParams, EVMFactory } from '../types.js';
|
|
2
|
-
declare const createEvmDepsFactory: ({ analytics, blockchainMetadata,
|
|
2
|
+
declare const createEvmDepsFactory: ({ analytics, blockchainMetadata, }: CreateEvmDepsFactoryParams) => EVMFactory;
|
|
3
3
|
export default createEvmDepsFactory;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { fetchGasLimit, getNonce as apiGetNonce, getServer, } from '@exodus/ethereum-api';
|
|
2
|
-
import { createSimulateTransaction } from '@exodus/web3-ethereum-utils';
|
|
3
2
|
import BN from 'bn.js';
|
|
4
|
-
const createEvmDepsFactory = ({ analytics, blockchainMetadata,
|
|
5
|
-
return ({ assetName, origin, getAsset, getAddress: _getAddress, getPrivateKey: _getPrivateKey, getFeeData: getFeeConfig, getActiveWalletAccount, }) => {
|
|
3
|
+
const createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
4
|
+
return ({ assetName, origin, getAsset, getAddress: _getAddress, getPrivateKey: _getPrivateKey, getFeeData: getFeeConfig, getActiveWalletAccount, simulateTransactions, }) => {
|
|
6
5
|
const asset = getAsset(assetName);
|
|
7
6
|
const server = getServer(asset);
|
|
8
7
|
const forwardRequest = async ({ method, params }) => {
|
|
@@ -78,8 +77,6 @@ const createEvmDepsFactory = ({ analytics, blockchainMetadata, simulateTransacti
|
|
|
78
77
|
});
|
|
79
78
|
return true;
|
|
80
79
|
};
|
|
81
|
-
const getOrigin = () => origin;
|
|
82
|
-
const simulateTransaction = createSimulateTransaction(simulateTransactionConfig);
|
|
83
80
|
return {
|
|
84
81
|
chainId: 'undefined',
|
|
85
82
|
forwardRequest,
|
|
@@ -90,8 +87,7 @@ const createEvmDepsFactory = ({ analytics, blockchainMetadata, simulateTransacti
|
|
|
90
87
|
getFeeData,
|
|
91
88
|
getEstimatedGas,
|
|
92
89
|
onEthWalletWatchAssetRequest: trackWalletWatchAssetUse,
|
|
93
|
-
|
|
94
|
-
simulateTransaction,
|
|
90
|
+
simulateTransactions,
|
|
95
91
|
};
|
|
96
92
|
};
|
|
97
93
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AssetNotSupportedError, InvalidInputError, UnauthorizedError, UserRejectedRequestError, } from '@exodus/web3-errors';
|
|
2
2
|
import { getTransactionId, signMessage, signTransaction, signTypedData, } from '@exodus/web3-ethereum-utils';
|
|
3
|
+
import { connect } from '@exodus/web3-rpc-handlers';
|
|
3
4
|
import { hexToBN } from '@exodus/web3-utils';
|
|
4
5
|
import { SignTypedDataVersion } from '@metamask/eth-sig-util';
|
|
5
6
|
import { parseAndValidateTypedData } from './parseAndValidateTypedData.js';
|
|
@@ -61,7 +62,7 @@ const isValidGasLimitValue = (value) => {
|
|
|
61
62
|
return proposedGasLimit.lte(maximumBlockGasLimit);
|
|
62
63
|
};
|
|
63
64
|
export function exposeHandlers(rpc, deps) {
|
|
64
|
-
const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction,
|
|
65
|
+
const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, simulateTransactions, scanDomains, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = async () => true, getAsset, getOrigin, } = deps;
|
|
65
66
|
const network = `evm:${chainId}`;
|
|
66
67
|
async function assertTrusted() {
|
|
67
68
|
const trusted = await isTrusted();
|
|
@@ -123,9 +124,9 @@ export function exposeHandlers(rpc, deps) {
|
|
|
123
124
|
const preparedTransaction = await prepareTransaction(transaction);
|
|
124
125
|
validateTransaction(preparedTransaction);
|
|
125
126
|
const origin = getOrigin();
|
|
126
|
-
const simulatedChanges = await
|
|
127
|
+
const simulatedChanges = await simulateTransactions({
|
|
127
128
|
asset,
|
|
128
|
-
|
|
129
|
+
transactions: [preparedTransaction],
|
|
129
130
|
origin,
|
|
130
131
|
});
|
|
131
132
|
await approve(approveTransactions, network, simulatedChanges);
|
|
@@ -211,18 +212,14 @@ export function exposeHandlers(rpc, deps) {
|
|
|
211
212
|
// See: https://docs.metamask.io/guide/rpc-api.html#restricted-methods.
|
|
212
213
|
throw new InvalidInputError();
|
|
213
214
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
throw new UserRejectedRequestError();
|
|
223
|
-
}
|
|
224
|
-
await ensureTrusted(network);
|
|
225
|
-
}
|
|
215
|
+
await connect({
|
|
216
|
+
approveConnection,
|
|
217
|
+
ensureTrusted,
|
|
218
|
+
isTrusted,
|
|
219
|
+
ensureUnlocked,
|
|
220
|
+
getOrigin,
|
|
221
|
+
scanDomains,
|
|
222
|
+
}, network);
|
|
226
223
|
return [{ parentCapability: ETH_ACCOUNTS_PERMISSION }];
|
|
227
224
|
});
|
|
228
225
|
exposeEvmFunction('wallet_watchAsset', async (assetDetails) => {
|
|
@@ -13,8 +13,7 @@ const validateEVMDeps = (evm) => {
|
|
|
13
13
|
'getFeeData',
|
|
14
14
|
'getNonce',
|
|
15
15
|
'sendRawTransaction',
|
|
16
|
-
'
|
|
17
|
-
'getOrigin',
|
|
16
|
+
'simulateTransactions',
|
|
18
17
|
];
|
|
19
18
|
const optionalKeys = ['onEthWalletWatchAssetRequest'];
|
|
20
19
|
validateDeps(evm, requiredKeys, optionalKeys);
|
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import type { EthAggregatedTransactionSimulationResult, EthSimulateTransactionParams, EthTransaction, EthTransactionHash, EthWalletWatchAsset } from '@exodus/web3-ethereum-utils';
|
|
3
3
|
import type { CommonDeps } from '@exodus/web3-rpc-handlers';
|
|
4
|
-
import type { Asset, IAnalyticsModule, IBlockchainMetadataModule, EthereumFeeData, GetFeeDataParams,
|
|
4
|
+
import type { Asset, IAnalyticsModule, IBlockchainMetadataModule, EthereumFeeData, GetFeeDataParams, CreateSimulationServiceParams } from '@exodus/web3-types';
|
|
5
5
|
/**
|
|
6
6
|
* EVM-compatible chains.
|
|
7
7
|
*/
|
|
@@ -17,8 +17,9 @@ export interface FeeData {
|
|
|
17
17
|
export interface CreateEvmDepsFactoryParams {
|
|
18
18
|
analytics: IAnalyticsModule;
|
|
19
19
|
blockchainMetadata: IBlockchainMetadataModule;
|
|
20
|
-
simulateTransactionConfig?:
|
|
20
|
+
simulateTransactionConfig?: CreateSimulationServiceParams;
|
|
21
21
|
}
|
|
22
|
+
declare type SimulateTransactionsFn = (params: EthSimulateTransactionParams) => Promise<EthAggregatedTransactionSimulationResult>;
|
|
22
23
|
export interface CreateEvmDepsParams {
|
|
23
24
|
assetName: string;
|
|
24
25
|
origin: string;
|
|
@@ -29,6 +30,7 @@ export interface CreateEvmDepsParams {
|
|
|
29
30
|
getPrivateKey: (assetName: string) => Promise<{
|
|
30
31
|
privateKey: Buffer;
|
|
31
32
|
}>;
|
|
33
|
+
simulateTransactions: SimulateTransactionsFn;
|
|
32
34
|
}
|
|
33
35
|
export declare type EVMFactory = (params: CreateEvmDepsParams) => EVMDeps;
|
|
34
36
|
export declare type EVMDeps = {
|
|
@@ -36,10 +38,9 @@ export declare type EVMDeps = {
|
|
|
36
38
|
getAddress: () => Promise<string>;
|
|
37
39
|
getPrivateKey: () => Promise<Buffer>;
|
|
38
40
|
sendRawTransaction: (rawTransaction: string) => Promise<EthTransactionHash>;
|
|
39
|
-
|
|
41
|
+
simulateTransactions: SimulateTransactionsFn;
|
|
40
42
|
getEstimatedGas: (transaction: EthTransaction) => Promise<string>;
|
|
41
43
|
getFeeData: () => Promise<FeeData>;
|
|
42
|
-
getOrigin: () => string;
|
|
43
44
|
getNonce: () => Promise<string>;
|
|
44
45
|
forwardRequest: (args: EthRequestArguments) => Promise<unknown>;
|
|
45
46
|
onEthWalletWatchAssetRequest?: (assetDetails: EthWalletWatchAsset) => Promise<boolean>;
|
|
@@ -47,3 +48,4 @@ export declare type EVMDeps = {
|
|
|
47
48
|
export declare type Dependencies = {
|
|
48
49
|
evms: EVMDeps[];
|
|
49
50
|
} & CommonDeps;
|
|
51
|
+
export {};
|
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": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"@exodus/currency": "^2.1.2",
|
|
34
34
|
"@exodus/ethereum-api": "^6.0.0",
|
|
35
35
|
"@exodus/web3-constants": "^1.29.0",
|
|
36
|
-
"@exodus/web3-ethereum-utils": "^
|
|
37
|
-
"@exodus/web3-provider": "^2.
|
|
38
|
-
"@exodus/web3-rpc-handlers": "^
|
|
39
|
-
"@exodus/web3-utils": "^1.
|
|
36
|
+
"@exodus/web3-ethereum-utils": "^3.1.0",
|
|
37
|
+
"@exodus/web3-provider": "^2.33.0",
|
|
38
|
+
"@exodus/web3-rpc-handlers": "^2.0.0",
|
|
39
|
+
"@exodus/web3-utils": "^1.23.0",
|
|
40
40
|
"bn.js": "^5.2.0",
|
|
41
41
|
"eth-rpc-errors": "^4.0.3"
|
|
42
42
|
},
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"@exodus/assets": "^8.0.72",
|
|
45
45
|
"@exodus/json-rpc": "^1.11.0",
|
|
46
46
|
"@exodus/schemasafe": "^1.0.0",
|
|
47
|
-
"@exodus/web3-types": "^1.
|
|
47
|
+
"@exodus/web3-types": "^1.31.0",
|
|
48
48
|
"@exodus/web3-validation": "^1.36.0",
|
|
49
49
|
"@wallet-standard/base": "^1.0.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@exodus/assets": "^8.0.72"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "809f56d8040d221eb52373bc9ce3c797c1bbb7a5"
|
|
55
55
|
}
|