@exodus/web3-ethereum 1.4.6 → 1.5.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.
|
@@ -12,11 +12,11 @@ export declare class EthereumProvider extends BaseProvider<EthereumProviderEvent
|
|
|
12
12
|
constructor({ accountsObservable, storage, supportedChainIds, transport, getDefaultChainId, }: Deps);
|
|
13
13
|
protected _callRpcMethod<Params, Response>(method: string, params: Params): Promise<Response>;
|
|
14
14
|
isConnected(): boolean;
|
|
15
|
-
request(args: RequestArguments)
|
|
15
|
+
request: (args: RequestArguments) => Promise<unknown>;
|
|
16
16
|
get chainId(): ChainId | null;
|
|
17
17
|
get selectedAddress(): string | null;
|
|
18
|
-
enable()
|
|
19
|
-
send(methodOrPayload: string | JsonRpcRequest, paramsOrCallback: unknown[] | JsonRpcCallback)
|
|
20
|
-
sendAsync(payload: JsonRpcRequest, callback: JsonRpcCallback)
|
|
18
|
+
enable: () => Promise<string[]>;
|
|
19
|
+
send: (methodOrPayload: string | JsonRpcRequest, paramsOrCallback: unknown[] | JsonRpcCallback) => Promise<void | JsonRpcResult>;
|
|
20
|
+
sendAsync: (payload: JsonRpcRequest, callback: JsonRpcCallback) => void;
|
|
21
21
|
}
|
|
22
22
|
export {};
|
package/lib/provider/provider.js
CHANGED
|
@@ -63,7 +63,7 @@ export class EthereumProvider extends BaseProvider {
|
|
|
63
63
|
#initialize = async () => {
|
|
64
64
|
const chainId = await this.#getChainId();
|
|
65
65
|
this.#handleConnect(chainId);
|
|
66
|
-
this.#handleChainChanged(chainId);
|
|
66
|
+
this.#handleChainChanged(chainId.toLowerCase());
|
|
67
67
|
const accounts = await this.#getAccounts();
|
|
68
68
|
this.#handleAccountsChanged(accounts);
|
|
69
69
|
this.#initialized = true;
|
|
@@ -110,7 +110,7 @@ export class EthereumProvider extends BaseProvider {
|
|
|
110
110
|
// Get default chain Id from remote config
|
|
111
111
|
const defaultChainId = await this.#getDefaultChainId();
|
|
112
112
|
if (defaultChainId) {
|
|
113
|
-
this.#handleChainChanged(defaultChainId);
|
|
113
|
+
this.#handleChainChanged(defaultChainId.toLowerCase());
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
return accounts;
|
|
@@ -132,7 +132,7 @@ export class EthereumProvider extends BaseProvider {
|
|
|
132
132
|
isConnected() {
|
|
133
133
|
return this.#isConnected;
|
|
134
134
|
}
|
|
135
|
-
async
|
|
135
|
+
request = async (args) => {
|
|
136
136
|
await this.#awaitInitialized();
|
|
137
137
|
this.#assertConnected();
|
|
138
138
|
const { method, params = [] } = args;
|
|
@@ -184,7 +184,7 @@ export class EthereumProvider extends BaseProvider {
|
|
|
184
184
|
revisedParams = params.slice(0, 2);
|
|
185
185
|
}
|
|
186
186
|
return this._callRpcMethod(method, revisedParams);
|
|
187
|
-
}
|
|
187
|
+
};
|
|
188
188
|
/*
|
|
189
189
|
* Legacy API.
|
|
190
190
|
*/
|
|
@@ -196,12 +196,12 @@ export class EthereumProvider extends BaseProvider {
|
|
|
196
196
|
console.warn('Exodus: "ethereum.selectedAddress" is deprecated and may be removed in the future. Please use "ethereum.request({ method: \'eth_accounts\' })" instead.');
|
|
197
197
|
return this.#selectedAddress;
|
|
198
198
|
}
|
|
199
|
-
async
|
|
199
|
+
enable = async () => {
|
|
200
200
|
console.warn('Exodus: "ethereum.enable()" is deprecated and may be removed in the future. Please use "ethereum.request({ method: \'eth_requestAccounts\' })" instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102.');
|
|
201
201
|
this.#assertConnected();
|
|
202
202
|
return this.#requestAccounts();
|
|
203
|
-
}
|
|
204
|
-
async
|
|
203
|
+
};
|
|
204
|
+
send = async (methodOrPayload, paramsOrCallback) => {
|
|
205
205
|
console.warn('Exodus: "ethereum.send()" is deprecated and may be removed in the future. Please use "ethereum.request()" instead.');
|
|
206
206
|
const hasMethod = typeof methodOrPayload === 'string';
|
|
207
207
|
const hasParams = Array.isArray(paramsOrCallback);
|
|
@@ -215,8 +215,8 @@ export class EthereumProvider extends BaseProvider {
|
|
|
215
215
|
const payload = methodOrPayload;
|
|
216
216
|
const callback = paramsOrCallback;
|
|
217
217
|
this.sendAsync(payload, callback);
|
|
218
|
-
}
|
|
219
|
-
sendAsync(payload, callback) {
|
|
218
|
+
};
|
|
219
|
+
sendAsync = (payload, callback) => {
|
|
220
220
|
console.warn('Exodus: "ethereum.sendAsync()" is deprecated and may be removed in the future. Please use "ethereum.request()" instead.');
|
|
221
221
|
const { id, jsonrpc, method, params } = payload;
|
|
222
222
|
const hasCallback = callback && typeof callback === 'function';
|
|
@@ -231,5 +231,5 @@ export class EthereumProvider extends BaseProvider {
|
|
|
231
231
|
callback(err, { id, jsonrpc, error: err });
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
|
-
}
|
|
234
|
+
};
|
|
235
235
|
}
|
|
@@ -2,6 +2,7 @@ import { AssetNotSupportedError, InvalidInputError, UnauthorizedError, UserRejec
|
|
|
2
2
|
import { getTransactionId, signMessage, signTransaction, signTypedData, } from '@exodus/web3-ethereum-utils';
|
|
3
3
|
import { SignTypedDataVersion } from '@metamask/eth-sig-util';
|
|
4
4
|
import { parseAndValidateTypedData } from './parseAndValidateTypedData.js';
|
|
5
|
+
import { simulateTransaction } from '../simulation/index.js';
|
|
5
6
|
// See: https://eips.ethereum.org/EIPS/eip-2255.
|
|
6
7
|
const ETH_ACCOUNTS_PERMISSION = 'eth_accounts';
|
|
7
8
|
const PROXIED_METHODS = [
|
|
@@ -47,7 +48,7 @@ version) {
|
|
|
47
48
|
return typedData.toString();
|
|
48
49
|
}
|
|
49
50
|
export function exposeHandlers(rpc, deps) {
|
|
50
|
-
const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = () => true, } = deps;
|
|
51
|
+
const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getAddress, getPrivateKey, getEstimatedGas, getFeeData, getNonce, sendRawTransaction, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = () => true, asset, } = deps;
|
|
51
52
|
const network = `evm:${chainId}`;
|
|
52
53
|
async function assertTrusted() {
|
|
53
54
|
const trusted = await isTrusted();
|
|
@@ -107,7 +108,8 @@ export function exposeHandlers(rpc, deps) {
|
|
|
107
108
|
await assertTrusted();
|
|
108
109
|
const preparedTransaction = await prepareTransaction(transaction);
|
|
109
110
|
validateTransaction(preparedTransaction);
|
|
110
|
-
await
|
|
111
|
+
const simulatedChanges = await simulateTransaction(asset, preparedTransaction);
|
|
112
|
+
await approve(approveTransactions, network, simulatedChanges);
|
|
111
113
|
const privateKey = await getPrivateKey();
|
|
112
114
|
const signedTransaction = signTransaction({ ...preparedTransaction, chainId }, privateKey);
|
|
113
115
|
const isEIP1559Enabled = !!preparedTransaction.maxFeePerGas;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import type { Asset } from '@exodus/web3-types';
|
|
2
|
+
export { Asset };
|
|
1
3
|
export interface CurrencyParams {
|
|
2
4
|
amount: string;
|
|
3
5
|
symbol: string;
|
|
4
6
|
denominator: number;
|
|
5
7
|
}
|
|
6
|
-
export interface Asset {
|
|
7
|
-
name: string;
|
|
8
|
-
displayTicker: string;
|
|
9
|
-
currency: {
|
|
10
|
-
defaultUnit: {
|
|
11
|
-
power: number;
|
|
12
|
-
};
|
|
13
|
-
baseUnit: (args: unknown) => unknown;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
8
|
export interface EthBalanceChanges {
|
|
17
9
|
willReceive: Array<EthBalanceChange>;
|
|
18
10
|
willSend: Array<EthBalanceChange>;
|
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": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -33,22 +33,22 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@exodus/currency": "^2.1.2",
|
|
35
35
|
"@exodus/ethereum-api": "^3.2.4",
|
|
36
|
-
"@exodus/web3-constants": "^1.
|
|
36
|
+
"@exodus/web3-constants": "^1.15.0",
|
|
37
37
|
"@exodus/web3-ethereum-utils": "^1.8.0",
|
|
38
|
-
"@exodus/web3-provider": "^2.
|
|
39
|
-
"@exodus/web3-rpc-handlers": "^0.
|
|
38
|
+
"@exodus/web3-provider": "^2.13.0",
|
|
39
|
+
"@exodus/web3-rpc-handlers": "^0.8.0",
|
|
40
40
|
"eth-rpc-errors": "^4.0.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@exodus/assets": "^8.0.72",
|
|
44
44
|
"@exodus/json-rpc": "^1.11.0",
|
|
45
45
|
"@exodus/schemasafe": "^1.0.0",
|
|
46
|
-
"@exodus/web3-types": "^1.
|
|
46
|
+
"@exodus/web3-types": "^1.11.0",
|
|
47
47
|
"@exodus/web3-validation": "^1.29.2",
|
|
48
48
|
"@wallet-standard/base": "^1.0.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@exodus/assets": "^8.0.72"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "0576160a36d260f5f63789ddd28c18c9d8885e7b"
|
|
54
54
|
}
|