@exodus/web3-ethereum 11.14.0 → 12.0.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/lib/rpc-handlers/{createEvmDeps.d.ts → createEVMDeps.d.ts} +2 -2
- package/lib/rpc-handlers/{createEvmDeps.js → createEVMDeps.js} +7 -9
- package/lib/rpc-handlers/index.d.ts +1 -1
- package/lib/rpc-handlers/index.js +1 -2
- package/lib/rpc-handlers/validator.js +13 -1
- package/lib/types.d.ts +1 -2
- package/package.json +3 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { CreateEvmDepsFactoryParams, EVMFactory } from '../types.js';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const createEVMDepsFactory: ({ analytics, blockchainMetadata, }: CreateEvmDepsFactoryParams) => EVMFactory;
|
|
3
|
+
export default createEVMDepsFactory;
|
|
@@ -8,8 +8,8 @@ async function getDefaultPurposeForLedger(asset) {
|
|
|
8
8
|
});
|
|
9
9
|
return purposes[0];
|
|
10
10
|
}
|
|
11
|
-
const
|
|
12
|
-
return ({ assetName, origin, getAsset, getAddress: _getAddress, getPrivateKey
|
|
11
|
+
const createEVMDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
12
|
+
return ({ assetName, origin, getAsset, getAddress: _getAddress, getPrivateKey, getFeeData: getFeeConfig, getCustomFeeRate, getActiveWalletAccount, simulateEthereumTransactions, getActiveWalletAccountData, transactionSigner, getLedgerDevice, }) => {
|
|
13
13
|
const asset = getAsset(assetName);
|
|
14
14
|
const server = getServer(asset);
|
|
15
15
|
const forwardRequest = async ({ method, params }) => {
|
|
@@ -25,10 +25,6 @@ const createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
|
25
25
|
const getAddress = async () => {
|
|
26
26
|
return _getAddress(assetName);
|
|
27
27
|
};
|
|
28
|
-
const getPrivateKey = async () => {
|
|
29
|
-
const { privateKey } = await _getPrivateKey(assetName);
|
|
30
|
-
return privateKey;
|
|
31
|
-
};
|
|
32
28
|
const getNonce = async () => {
|
|
33
29
|
const [baseAssetTxLog, blockchainNonce] = await Promise.all([
|
|
34
30
|
blockchainMetadata.getTxLog({
|
|
@@ -113,7 +109,10 @@ const createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
|
113
109
|
throw new InvalidInputError("Can't set both rawMessage and EIP712Message");
|
|
114
110
|
}
|
|
115
111
|
if (walletAccount.source === 'exodus') {
|
|
116
|
-
|
|
112
|
+
if (!getPrivateKey) {
|
|
113
|
+
throw new Error('`getPrivateKey` should be provided to sign with Exodus accounts.');
|
|
114
|
+
}
|
|
115
|
+
const { privateKey } = await getPrivateKey(assetName);
|
|
117
116
|
if (rawMessage) {
|
|
118
117
|
return hex0xStringToBuffer(signMessage(bufferToHex0xString(rawMessage), privateKey));
|
|
119
118
|
}
|
|
@@ -152,7 +151,6 @@ const createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
|
152
151
|
forwardRequest,
|
|
153
152
|
sendRawTransaction,
|
|
154
153
|
getAddress,
|
|
155
|
-
getPrivateKey,
|
|
156
154
|
getNonce,
|
|
157
155
|
getFeeData,
|
|
158
156
|
getEstimatedGas,
|
|
@@ -165,4 +163,4 @@ const createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
|
165
163
|
};
|
|
166
164
|
};
|
|
167
165
|
};
|
|
168
|
-
export default
|
|
166
|
+
export default createEVMDepsFactory;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as createEVMDepsFactory } from './createEVMDeps.js';
|
|
2
2
|
import type { Dependencies, EthRequestArguments } from '../types.js';
|
|
3
3
|
import type { RPC, Transport } from '@exodus/web3-types';
|
|
4
4
|
export declare function validateRequestWithEVMPrefix(request: EthRequestArguments): unknown;
|
|
@@ -2,13 +2,12 @@ import { RPC_REQUEST_TIMEOUT } from '@exodus/web3-constants';
|
|
|
2
2
|
import { validate as validateDeps, validateCommonDeps, } from '@exodus/web3-rpc-handlers';
|
|
3
3
|
import { exposeHandlers } from './exposeHandlers.js';
|
|
4
4
|
import { validateRequest } from './validator.js';
|
|
5
|
-
export { default as
|
|
5
|
+
export { default as createEVMDepsFactory } from './createEVMDeps.js';
|
|
6
6
|
const validateEVMDeps = (evm) => {
|
|
7
7
|
const requiredKeys = [
|
|
8
8
|
'chainId',
|
|
9
9
|
'forwardRequest',
|
|
10
10
|
'getAddress',
|
|
11
|
-
'getPrivateKey',
|
|
12
11
|
'getEstimatedGas',
|
|
13
12
|
'getFeeData',
|
|
14
13
|
'getCustomFeeData',
|
|
@@ -1060,12 +1060,24 @@ export function validateRequest(value) {
|
|
|
1060
1060
|
return false
|
|
1061
1061
|
}
|
|
1062
1062
|
}
|
|
1063
|
+
if ('chainId' in data && hasOwn(data, 'chainId')) {
|
|
1064
|
+
if (!(typeof data.chainId === 'number')) {
|
|
1065
|
+
validate.errors = [
|
|
1066
|
+
{
|
|
1067
|
+
keywordLocation: '#/properties/chainId/type',
|
|
1068
|
+
instanceLocation: '#/chainId',
|
|
1069
|
+
},
|
|
1070
|
+
]
|
|
1071
|
+
return false
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1063
1074
|
for (const key6 of Object.keys(data)) {
|
|
1064
1075
|
if (
|
|
1065
1076
|
key6 !== 'address' &&
|
|
1066
1077
|
key6 !== 'symbol' &&
|
|
1067
1078
|
key6 !== 'decimals' &&
|
|
1068
|
-
key6 !== 'image'
|
|
1079
|
+
key6 !== 'image' &&
|
|
1080
|
+
key6 !== 'chainId'
|
|
1069
1081
|
) {
|
|
1070
1082
|
validate.errors = [
|
|
1071
1083
|
{
|
package/lib/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface CreateEvmDepsParams {
|
|
|
33
33
|
getAsset: (assetName: string) => Asset;
|
|
34
34
|
getFeeData: ({ assetName }: GetFeeDataParams) => Promise<EthereumFeeData>;
|
|
35
35
|
getCustomFeeRate?: () => Promise<NumberUnit>;
|
|
36
|
-
getPrivateKey
|
|
36
|
+
getPrivateKey?: (assetName: string) => Promise<{
|
|
37
37
|
privateKey: Buffer;
|
|
38
38
|
}>;
|
|
39
39
|
simulateEthereumTransactions: SimulateTransactionsFn;
|
|
@@ -46,7 +46,6 @@ export declare type EVMTransactionSignerModule = ITransactionSignerModule<EVMUns
|
|
|
46
46
|
export declare type EVMDeps = {
|
|
47
47
|
chainId: string;
|
|
48
48
|
getAddress: () => Promise<string>;
|
|
49
|
-
getPrivateKey: () => Promise<Buffer>;
|
|
50
49
|
sendRawTransaction: (rawTransaction: string) => Promise<EthTransactionHash>;
|
|
51
50
|
simulateEthereumTransactions: SimulateTransactionsFn;
|
|
52
51
|
getEstimatedGas: (transaction: EthTransaction) => Promise<string>;
|
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": "12.0.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@exodus/currency": "^2.1.2",
|
|
36
36
|
"@exodus/ethereum-api": "^6.3.33",
|
|
37
37
|
"@exodus/web3-constants": "^1.30.0",
|
|
38
|
-
"@exodus/web3-ethereum-utils": "^3.
|
|
38
|
+
"@exodus/web3-ethereum-utils": "^3.25.0",
|
|
39
39
|
"@exodus/web3-provider": "^3.14.0",
|
|
40
40
|
"@exodus/web3-rpc-handlers": "^2.20.0",
|
|
41
41
|
"@exodus/web3-utils": "^1.43.0",
|
|
@@ -51,8 +51,5 @@
|
|
|
51
51
|
"@exodus/web3-validation": "^1.38.0",
|
|
52
52
|
"@wallet-standard/base": "^1.0.1"
|
|
53
53
|
},
|
|
54
|
-
"
|
|
55
|
-
"@exodus/assets": "^8.0.95"
|
|
56
|
-
},
|
|
57
|
-
"gitHead": "2907aa869e958d805f8652dec0b577fc84235632"
|
|
54
|
+
"gitHead": "1806ac87e07db41fd3f711418bc3ba75bb88bf8a"
|
|
58
55
|
}
|