@exodus/web3-ethereum 4.0.0 → 5.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.
|
@@ -9,7 +9,7 @@ interface EthereumProviderEvents {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class EthereumProvider extends BaseProvider<EthereumProviderEvents> {
|
|
11
11
|
#private;
|
|
12
|
-
constructor({ accountsObservable, storage, supportedChainIds, transport, getDefaultChainId,
|
|
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
15
|
request: (args: RequestArguments) => Promise<unknown>;
|
package/lib/provider/provider.js
CHANGED
|
@@ -5,20 +5,18 @@ export class EthereumProvider extends BaseProvider {
|
|
|
5
5
|
#storage;
|
|
6
6
|
#supportedChainIds = [];
|
|
7
7
|
#getDefaultChainId;
|
|
8
|
-
#walletProviderManager;
|
|
9
8
|
#initializePromise = null;
|
|
10
9
|
#initialized = false;
|
|
11
10
|
#isConnected = false;
|
|
12
11
|
#chainId = null;
|
|
13
12
|
#accounts = [];
|
|
14
13
|
#selectedAddress = null;
|
|
15
|
-
constructor({ accountsObservable, storage, supportedChainIds, transport, getDefaultChainId,
|
|
14
|
+
constructor({ accountsObservable, storage, supportedChainIds, transport, getDefaultChainId, }) {
|
|
16
15
|
if (!supportedChainIds?.length) {
|
|
17
16
|
throw new Error('At least one supported chain must be provided');
|
|
18
17
|
}
|
|
19
18
|
super({ transport });
|
|
20
19
|
this.#storage = createStorageWrapper(storage);
|
|
21
|
-
this.#walletProviderManager = walletProviderManager;
|
|
22
20
|
this.#supportedChainIds = supportedChainIds
|
|
23
21
|
.map((chainId) => chainId.toLowerCase())
|
|
24
22
|
.sort();
|
|
@@ -107,12 +105,7 @@ export class EthereumProvider extends BaseProvider {
|
|
|
107
105
|
};
|
|
108
106
|
#requestAccounts = async () => {
|
|
109
107
|
const permissions = { eth_accounts: {} };
|
|
110
|
-
|
|
111
|
-
this.#walletProviderManager.getWalletProviders().forEach(({ name }) => {
|
|
112
|
-
availableWallets.push(name);
|
|
113
|
-
});
|
|
114
|
-
const { selectedWallet } = await this._callRpcMethod('wallet_requestPermissions', [permissions, availableWallets]);
|
|
115
|
-
this.#walletProviderManager.setDefaultWalletProvider(selectedWallet);
|
|
108
|
+
await this._callRpcMethod('wallet_requestPermissions', [permissions]);
|
|
116
109
|
const accounts = await this._callRpcMethod('eth_accounts', []);
|
|
117
110
|
this.#handleAccountsChanged(accounts);
|
|
118
111
|
if (!(await this.#storage.getChainId())) {
|
package/lib/provider/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Deps as BaseProviderDeps } from '@exodus/web3-provider';
|
|
2
|
-
import type { Observable, Storage
|
|
2
|
+
import type { Observable, Storage } from '@exodus/web3-types';
|
|
3
3
|
export declare type ChainId = string;
|
|
4
4
|
export interface ProviderConnectInfo {
|
|
5
5
|
chainId: ChainId;
|
|
@@ -35,11 +35,10 @@ export declare type Deps = BaseProviderDeps & {
|
|
|
35
35
|
storage: Storage;
|
|
36
36
|
supportedChainIds: string[];
|
|
37
37
|
getDefaultChainId?: () => Promise<string | null>;
|
|
38
|
-
walletProviderManager: WalletProviderManager;
|
|
39
38
|
};
|
|
40
39
|
export interface ProviderStorage {
|
|
41
40
|
getChainId: () => Promise<ChainId | null>;
|
|
42
41
|
setChainId: (chainId: ChainId) => Promise<void>;
|
|
43
42
|
clearChainId: () => Promise<void>;
|
|
44
43
|
}
|
|
45
|
-
export {
|
|
44
|
+
export {};
|
|
@@ -205,9 +205,8 @@ export function exposeHandlers(rpc, deps) {
|
|
|
205
205
|
}
|
|
206
206
|
return permissions;
|
|
207
207
|
});
|
|
208
|
-
exposeEvmFunction('wallet_requestPermissions', async (requestedPermissions
|
|
208
|
+
exposeEvmFunction('wallet_requestPermissions', async (requestedPermissions) => {
|
|
209
209
|
const parentCapability = Object.keys(requestedPermissions)[0];
|
|
210
|
-
let selectedWallet = null;
|
|
211
210
|
if (parentCapability !== ETH_ACCOUNTS_PERMISSION) {
|
|
212
211
|
// `eth_accounts` is currently the only permission.
|
|
213
212
|
// See: https://docs.metamask.io/guide/rpc-api.html#restricted-methods.
|
|
@@ -219,19 +218,13 @@ export function exposeHandlers(rpc, deps) {
|
|
|
219
218
|
}
|
|
220
219
|
const trusted = await isTrusted();
|
|
221
220
|
if (!trusted) {
|
|
222
|
-
const
|
|
223
|
-
if (!
|
|
221
|
+
const approved = await approveConnection(network);
|
|
222
|
+
if (!approved) {
|
|
224
223
|
throw new UserRejectedRequestError();
|
|
225
224
|
}
|
|
226
|
-
|
|
227
|
-
if (response.selectedWallet === 'exodus') {
|
|
228
|
-
await ensureTrusted(network);
|
|
229
|
-
}
|
|
225
|
+
await ensureTrusted(network);
|
|
230
226
|
}
|
|
231
|
-
return {
|
|
232
|
-
walletPermissions: [{ parentCapability: ETH_ACCOUNTS_PERMISSION }],
|
|
233
|
-
selectedWallet,
|
|
234
|
-
};
|
|
227
|
+
return [{ parentCapability: ETH_ACCOUNTS_PERMISSION }];
|
|
235
228
|
});
|
|
236
229
|
exposeEvmFunction('wallet_watchAsset', async (assetDetails) => {
|
|
237
230
|
await assertTrusted();
|
|
@@ -913,12 +913,6 @@ export function validateRequest(value) {
|
|
|
913
913
|
validate.errors = [{ keywordLocation: '#/type', instanceLocation: '#' }]
|
|
914
914
|
return false
|
|
915
915
|
}
|
|
916
|
-
if (data.length > 2) {
|
|
917
|
-
validate.errors = [
|
|
918
|
-
{ keywordLocation: '#/maxItems', instanceLocation: '#' },
|
|
919
|
-
]
|
|
920
|
-
return false
|
|
921
|
-
}
|
|
922
916
|
if (data.length < 1) {
|
|
923
917
|
validate.errors = [
|
|
924
918
|
{ keywordLocation: '#/minItems', instanceLocation: '#' },
|
|
@@ -935,46 +929,7 @@ export function validateRequest(value) {
|
|
|
935
929
|
return false
|
|
936
930
|
}
|
|
937
931
|
}
|
|
938
|
-
if (
|
|
939
|
-
if (!Array.isArray(data[1])) {
|
|
940
|
-
validate.errors = [
|
|
941
|
-
{ keywordLocation: '#/1/type', instanceLocation: '#/1' },
|
|
942
|
-
]
|
|
943
|
-
return false
|
|
944
|
-
}
|
|
945
|
-
for (let l = 0; l < data[1].length; l++) {
|
|
946
|
-
if (l in data[1] && hasOwn(data[1], l)) {
|
|
947
|
-
if (!(typeof data[1][l] === 'string')) {
|
|
948
|
-
validate.errors = [
|
|
949
|
-
{
|
|
950
|
-
keywordLocation: '#/1/items/type',
|
|
951
|
-
instanceLocation: '#/1/' + l,
|
|
952
|
-
},
|
|
953
|
-
]
|
|
954
|
-
return false
|
|
955
|
-
}
|
|
956
|
-
if (data[1][l].length > 20 && stringLength(data[1][l]) > 20) {
|
|
957
|
-
validate.errors = [
|
|
958
|
-
{
|
|
959
|
-
keywordLocation: '#/1/items/maxLength',
|
|
960
|
-
instanceLocation: '#/1/' + l,
|
|
961
|
-
},
|
|
962
|
-
]
|
|
963
|
-
return false
|
|
964
|
-
}
|
|
965
|
-
if (!format3.test(data[1][l])) {
|
|
966
|
-
validate.errors = [
|
|
967
|
-
{
|
|
968
|
-
keywordLocation: '#/1/items/format',
|
|
969
|
-
instanceLocation: '#/1/' + l,
|
|
970
|
-
},
|
|
971
|
-
]
|
|
972
|
-
return false
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
if (data.length > 2) {
|
|
932
|
+
if (data.length > 1) {
|
|
978
933
|
validate.errors = [
|
|
979
934
|
{ keywordLocation: '#/items', instanceLocation: '#' },
|
|
980
935
|
]
|
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 { Asset, IAnalyticsModule, IBlockchainMetadataModule,
|
|
4
|
+
import type { Asset, IAnalyticsModule, IBlockchainMetadataModule, EthereumFeeData, GetFeeDataParams } from '@exodus/web3-types';
|
|
5
5
|
/**
|
|
6
6
|
* EVM-compatible chains.
|
|
7
7
|
*/
|
|
@@ -45,4 +45,3 @@ export declare type EVMDeps = {
|
|
|
45
45
|
export declare type Dependencies = {
|
|
46
46
|
evms: EVMDeps[];
|
|
47
47
|
} & CommonDeps;
|
|
48
|
-
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": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@exodus/currency": "^2.1.2",
|
|
35
35
|
"@exodus/ethereum-api": "^6.0.0",
|
|
36
36
|
"@exodus/web3-constants": "^1.29.0",
|
|
37
|
-
"@exodus/web3-ethereum-utils": "^1.
|
|
38
|
-
"@exodus/web3-provider": "^2.
|
|
39
|
-
"@exodus/web3-rpc-handlers": "^1.
|
|
40
|
-
"@exodus/web3-utils": "^1.
|
|
37
|
+
"@exodus/web3-ethereum-utils": "^1.22.0",
|
|
38
|
+
"@exodus/web3-provider": "^2.29.0",
|
|
39
|
+
"@exodus/web3-rpc-handlers": "^1.4.0",
|
|
40
|
+
"@exodus/web3-utils": "^1.18.0",
|
|
41
41
|
"bn.js": "^5.2.0",
|
|
42
42
|
"eth-rpc-errors": "^4.0.3"
|
|
43
43
|
},
|
|
@@ -45,12 +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.27.0",
|
|
49
49
|
"@exodus/web3-validation": "^1.35.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": "
|
|
55
|
+
"gitHead": "ce1e0287af1a5ee3d1f90b71dda277ca6f785825"
|
|
56
56
|
}
|