@exodus/web3-ethereum 11.13.0 → 12.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, }: CreateEvmDepsFactoryParams) => EVMFactory;
3
- export default createEvmDepsFactory;
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 createEvmDepsFactory = ({ analytics, blockchainMetadata, }) => {
12
- return ({ assetName, origin, getAsset, getAddress: _getAddress, getPrivateKey: _getPrivateKey, getFeeData: getFeeConfig, getCustomFeeRate, getActiveWalletAccount, simulateEthereumTransactions, getActiveWalletAccountData, transactionSigner, getLedgerDevice, }) => {
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
- const privateKey = await getPrivateKey();
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 createEvmDepsFactory;
166
+ export default createEVMDepsFactory;
@@ -1,4 +1,4 @@
1
- export { default as createEvmDepsFactory } from './createEvmDeps.js';
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,7 +2,7 @@ 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 createEvmDepsFactory } from './createEvmDeps.js';
5
+ export { default as createEVMDepsFactory } from './createEVMDeps.js';
6
6
  const validateEVMDeps = (evm) => {
7
7
  const requiredKeys = [
8
8
  'chainId',
@@ -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: (assetName: string) => Promise<{
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": "11.13.0",
4
+ "version": "12.0.0",
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.23.0",
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
- "peerDependencies": {
55
- "@exodus/assets": "^8.0.95"
56
- },
57
- "gitHead": "8ba379ef8cf8553458af3a6dc7d5a8d97951852f"
54
+ "gitHead": "23ffed4aa324577548687a217407f36b5ac93606"
58
55
  }