@exodus/web3-ethereum 12.15.0 → 12.17.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 @@ async function getDefaultPurposeForLedger(asset) {
|
|
|
9
9
|
return purposes[0];
|
|
10
10
|
}
|
|
11
11
|
const createEVMDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
12
|
-
return ({ assetName, origin, getAsset, getAddress: _getAddress, getSupportedChainIds, getPrivateKey, getFeeData: getFeeConfig, getCustomFeeRate, getActiveWalletAccount, simulateEthereumTransactions, getActiveWalletAccountData, transactionSigner, getLedgerDevice, }) => {
|
|
12
|
+
return ({ assetName, origin, getAsset, getAddress: _getAddress, getSupportedChainIds, getPrivateKey, getFeeData: getFeeConfig, getCustomFeeRate, getActiveWalletAccount, simulateEthereumTransactions, getActiveWalletAccountData, transactionSigner, messageSigner: _messageSigner, getLedgerDevice, onEthWalletWatchAssetRequest: _onEthWalletWatchAssetRequest, }) => {
|
|
13
13
|
const asset = getAsset(assetName);
|
|
14
14
|
const server = getServer(asset);
|
|
15
15
|
const forwardRequest = async ({ method, params }) => {
|
|
@@ -90,62 +90,66 @@ const createEVMDepsFactory = ({ analytics, blockchainMetadata, }) => {
|
|
|
90
90
|
}
|
|
91
91
|
return feeData;
|
|
92
92
|
};
|
|
93
|
-
const trackWalletWatchAssetUse =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
throw new
|
|
93
|
+
const trackWalletWatchAssetUse = _onEthWalletWatchAssetRequest
|
|
94
|
+
? _onEthWalletWatchAssetRequest
|
|
95
|
+
: async (assetDetails) => {
|
|
96
|
+
// TODO: do we still need this? If yes, this ...assetDetails expansion is no bueno
|
|
97
|
+
// why is this not always returning true in browser?
|
|
98
|
+
analytics.track({
|
|
99
|
+
event: 'DappWalletWatchAsset',
|
|
100
|
+
properties: {
|
|
101
|
+
...assetDetails,
|
|
102
|
+
dappDomain: origin,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
return true;
|
|
106
|
+
};
|
|
107
|
+
const messageSigner = _messageSigner
|
|
108
|
+
? _messageSigner
|
|
109
|
+
: {
|
|
110
|
+
signMessage: async ({ baseAssetName, walletAccount, message, }) => {
|
|
111
|
+
const { rawMessage, EIP712Message } = message;
|
|
112
|
+
if (rawMessage && EIP712Message) {
|
|
113
|
+
throw new InvalidInputError("Can't set both rawMessage and EIP712Message");
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
if (walletAccount.source === 'exodus') {
|
|
116
|
+
if (!getPrivateKey) {
|
|
117
|
+
throw new Error('`getPrivateKey` should be provided to sign with Exodus accounts.');
|
|
118
|
+
}
|
|
119
|
+
const { privateKey } = await getPrivateKey(assetName);
|
|
120
|
+
if (rawMessage) {
|
|
121
|
+
return hex0xStringToBuffer(signMessage(bufferToHex0xString(rawMessage), privateKey));
|
|
122
|
+
}
|
|
123
|
+
if (EIP712Message) {
|
|
124
|
+
const typedDataVersion = Array.isArray(EIP712Message)
|
|
125
|
+
? SignTypedDataVersion.V1
|
|
126
|
+
: SignTypedDataVersion.V4;
|
|
127
|
+
return hex0xStringToBuffer(signTypedData(EIP712Message, privateKey, typedDataVersion));
|
|
128
|
+
}
|
|
118
129
|
}
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
else if (getLedgerDevice) {
|
|
131
|
+
const device = await getLedgerDevice();
|
|
132
|
+
const purpose = await getDefaultPurposeForLedger(asset);
|
|
133
|
+
const { derivationPath } = await getAsset(assetName).baseAsset.api.getKeyIdentifier({
|
|
134
|
+
compatibilityMode: 'ledger',
|
|
135
|
+
purpose,
|
|
136
|
+
accountIndex: 0,
|
|
137
|
+
chainIndex: 0,
|
|
138
|
+
addressIndex: 0,
|
|
139
|
+
});
|
|
140
|
+
const signedMessage = await device.signMessage({
|
|
141
|
+
assetName: baseAssetName,
|
|
142
|
+
derivationPath,
|
|
143
|
+
message: {
|
|
144
|
+
rawMessage,
|
|
145
|
+
EIP712Message,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
return Buffer.from(signedMessage);
|
|
124
149
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const purpose = await getDefaultPurposeForLedger(asset);
|
|
129
|
-
const { derivationPath } = await getAsset(assetName).baseAsset.api.getKeyIdentifier({
|
|
130
|
-
compatibilityMode: 'ledger',
|
|
131
|
-
purpose,
|
|
132
|
-
accountIndex: 0,
|
|
133
|
-
chainIndex: 0,
|
|
134
|
-
addressIndex: 0,
|
|
135
|
-
});
|
|
136
|
-
const signedMessage = await device.signMessage({
|
|
137
|
-
assetName: baseAssetName,
|
|
138
|
-
derivationPath,
|
|
139
|
-
message: {
|
|
140
|
-
rawMessage,
|
|
141
|
-
EIP712Message,
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
return Buffer.from(signedMessage);
|
|
145
|
-
}
|
|
146
|
-
throw new InvalidInputError();
|
|
147
|
-
},
|
|
148
|
-
};
|
|
150
|
+
throw new InvalidInputError();
|
|
151
|
+
},
|
|
152
|
+
};
|
|
149
153
|
return {
|
|
150
154
|
chainId: 'undefined',
|
|
151
155
|
forwardRequest,
|
|
@@ -63,7 +63,7 @@ const isValidGasLimitValue = (value) => {
|
|
|
63
63
|
return proposedGasLimit.lte(maximumBlockGasLimit);
|
|
64
64
|
};
|
|
65
65
|
export function exposeHandlers(rpc, deps) {
|
|
66
|
-
const { chainId, isTrusted, isAutoApproved, ensureTrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getSupportedChainIds = async () => [], getAddress, getEstimatedGas, getCustomFeeData, getFeeData, getNonce, sendRawTransaction, simulateEthereumTransactions, scanDomains, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = async () => true, getAsset, addEthereumChain, getOrigin, getPathname, getActiveWalletAccountData, transactionSigner, messageSigner, } = deps;
|
|
66
|
+
const { chainId, isTrusted, isAutoApproved, ensureTrusted, ensureUntrusted, approveConnection, approveMessage, approveTransactions, forwardRequest, getSupportedChainIds = async () => [], getAddress, getEstimatedGas, getCustomFeeData, getFeeData, getNonce, sendRawTransaction, simulateEthereumTransactions, scanDomains, onTransactionsSigned = () => { }, onEthWalletWatchAssetRequest = () => { }, isUnlocked = () => true, ensureUnlocked = async () => true, getAsset, addEthereumChain, getOrigin, getPathname, getActiveWalletAccountData, transactionSigner, messageSigner, } = deps;
|
|
67
67
|
const network = `evm:${chainId}`;
|
|
68
68
|
async function assertTrusted() {
|
|
69
69
|
const trusted = await isTrusted();
|
|
@@ -296,4 +296,13 @@ export function exposeHandlers(rpc, deps) {
|
|
|
296
296
|
exposeEvmFunction('wallet_getSnaps', async () => {
|
|
297
297
|
throw new UnsupportedMethodError();
|
|
298
298
|
});
|
|
299
|
+
exposeEvmFunction('wallet_revokePermissions', async (permissions) => {
|
|
300
|
+
const parentCapability = Object.keys(permissions)[0];
|
|
301
|
+
if (parentCapability !== ETH_ACCOUNTS_PERMISSION) {
|
|
302
|
+
// `eth_accounts` is currently the only permission.
|
|
303
|
+
throw new InvalidInputError();
|
|
304
|
+
}
|
|
305
|
+
await ensureUntrusted();
|
|
306
|
+
return null;
|
|
307
|
+
});
|
|
299
308
|
}
|
|
@@ -1533,11 +1533,11 @@ export function validateRequest(value) {
|
|
|
1533
1533
|
})()
|
|
1534
1534
|
if (sub23) passes5++
|
|
1535
1535
|
const sub24 = (() => {
|
|
1536
|
-
const
|
|
1537
|
-
const
|
|
1538
|
-
const
|
|
1539
|
-
validate.errors =
|
|
1540
|
-
if (!
|
|
1536
|
+
const err41 = validate.errors
|
|
1537
|
+
const res41 = ref18(data.image)
|
|
1538
|
+
const suberr41 = ref18.errors
|
|
1539
|
+
validate.errors = err41
|
|
1540
|
+
if (!res41) return false
|
|
1541
1541
|
return true
|
|
1542
1542
|
})()
|
|
1543
1543
|
if (sub24) passes5++
|
|
@@ -1626,13 +1626,13 @@ export function validateRequest(value) {
|
|
|
1626
1626
|
]
|
|
1627
1627
|
return false
|
|
1628
1628
|
}
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
const
|
|
1632
|
-
validate.errors =
|
|
1633
|
-
if (!
|
|
1629
|
+
const err42 = validate.errors
|
|
1630
|
+
const res42 = ref17(data.options)
|
|
1631
|
+
const suberr42 = ref17.errors
|
|
1632
|
+
validate.errors = err42
|
|
1633
|
+
if (!res42) {
|
|
1634
1634
|
validate.errors = [
|
|
1635
|
-
errorMerge(
|
|
1635
|
+
errorMerge(suberr42[0], '#/properties/options/$ref', '#/options'),
|
|
1636
1636
|
]
|
|
1637
1637
|
return false
|
|
1638
1638
|
}
|
|
@@ -2782,7 +2782,7 @@ export function validateRequest(value) {
|
|
|
2782
2782
|
return false
|
|
2783
2783
|
}
|
|
2784
2784
|
break
|
|
2785
|
-
case '
|
|
2785
|
+
case 'wallet_revokePermissions':
|
|
2786
2786
|
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2787
2787
|
validate.errors = [
|
|
2788
2788
|
{
|
|
@@ -2793,8 +2793,8 @@ export function validateRequest(value) {
|
|
|
2793
2793
|
return false
|
|
2794
2794
|
}
|
|
2795
2795
|
const err38 = validate.errors
|
|
2796
|
-
const res38 =
|
|
2797
|
-
const suberr38 =
|
|
2796
|
+
const res38 = ref11(data.params)
|
|
2797
|
+
const suberr38 = ref11.errors
|
|
2798
2798
|
validate.errors = err38
|
|
2799
2799
|
if (!res38) {
|
|
2800
2800
|
validate.errors = [
|
|
@@ -2807,7 +2807,7 @@ export function validateRequest(value) {
|
|
|
2807
2807
|
return false
|
|
2808
2808
|
}
|
|
2809
2809
|
break
|
|
2810
|
-
case '
|
|
2810
|
+
case 'wallet_switchEthereumChain':
|
|
2811
2811
|
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2812
2812
|
validate.errors = [
|
|
2813
2813
|
{
|
|
@@ -2818,8 +2818,8 @@ export function validateRequest(value) {
|
|
|
2818
2818
|
return false
|
|
2819
2819
|
}
|
|
2820
2820
|
const err39 = validate.errors
|
|
2821
|
-
const res39 =
|
|
2822
|
-
const suberr39 =
|
|
2821
|
+
const res39 = ref14(data.params)
|
|
2822
|
+
const suberr39 = ref14.errors
|
|
2823
2823
|
validate.errors = err39
|
|
2824
2824
|
if (!res39) {
|
|
2825
2825
|
validate.errors = [
|
|
@@ -2832,7 +2832,7 @@ export function validateRequest(value) {
|
|
|
2832
2832
|
return false
|
|
2833
2833
|
}
|
|
2834
2834
|
break
|
|
2835
|
-
case '
|
|
2835
|
+
case 'wallet_addEthereumChain':
|
|
2836
2836
|
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2837
2837
|
validate.errors = [
|
|
2838
2838
|
{
|
|
@@ -2842,14 +2842,14 @@ export function validateRequest(value) {
|
|
|
2842
2842
|
]
|
|
2843
2843
|
return false
|
|
2844
2844
|
}
|
|
2845
|
-
const
|
|
2846
|
-
const
|
|
2847
|
-
const
|
|
2848
|
-
validate.errors =
|
|
2849
|
-
if (!
|
|
2845
|
+
const err40 = validate.errors
|
|
2846
|
+
const res40 = ref15(data.params)
|
|
2847
|
+
const suberr40 = ref15.errors
|
|
2848
|
+
validate.errors = err40
|
|
2849
|
+
if (!res40) {
|
|
2850
2850
|
validate.errors = [
|
|
2851
2851
|
errorMerge(
|
|
2852
|
-
|
|
2852
|
+
suberr40[0],
|
|
2853
2853
|
'#/oneOf/47/properties/params/$ref',
|
|
2854
2854
|
'#/params',
|
|
2855
2855
|
),
|
|
@@ -2857,7 +2857,7 @@ export function validateRequest(value) {
|
|
|
2857
2857
|
return false
|
|
2858
2858
|
}
|
|
2859
2859
|
break
|
|
2860
|
-
case '
|
|
2860
|
+
case 'wallet_watchAsset':
|
|
2861
2861
|
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2862
2862
|
validate.errors = [
|
|
2863
2863
|
{
|
|
@@ -2867,10 +2867,35 @@ export function validateRequest(value) {
|
|
|
2867
2867
|
]
|
|
2868
2868
|
return false
|
|
2869
2869
|
}
|
|
2870
|
+
const err43 = validate.errors
|
|
2871
|
+
const res43 = ref16(data.params)
|
|
2872
|
+
const suberr43 = ref16.errors
|
|
2873
|
+
validate.errors = err43
|
|
2874
|
+
if (!res43) {
|
|
2875
|
+
validate.errors = [
|
|
2876
|
+
errorMerge(
|
|
2877
|
+
suberr43[0],
|
|
2878
|
+
'#/oneOf/48/properties/params/$ref',
|
|
2879
|
+
'#/params',
|
|
2880
|
+
),
|
|
2881
|
+
]
|
|
2882
|
+
return false
|
|
2883
|
+
}
|
|
2884
|
+
break
|
|
2885
|
+
case 'web3_clientVersion':
|
|
2886
|
+
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2887
|
+
validate.errors = [
|
|
2888
|
+
{
|
|
2889
|
+
keywordLocation: '#/oneOf/49/required',
|
|
2890
|
+
instanceLocation: '#/params',
|
|
2891
|
+
},
|
|
2892
|
+
]
|
|
2893
|
+
return false
|
|
2894
|
+
}
|
|
2870
2895
|
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
2871
2896
|
validate.errors = [
|
|
2872
2897
|
{
|
|
2873
|
-
keywordLocation: '#/oneOf/
|
|
2898
|
+
keywordLocation: '#/oneOf/49/properties/params/const',
|
|
2874
2899
|
instanceLocation: '#/params',
|
|
2875
2900
|
},
|
|
2876
2901
|
]
|
|
@@ -2881,7 +2906,7 @@ export function validateRequest(value) {
|
|
|
2881
2906
|
if (!('params' in data && hasOwn(data, 'params'))) {
|
|
2882
2907
|
validate.errors = [
|
|
2883
2908
|
{
|
|
2884
|
-
keywordLocation: '#/oneOf/
|
|
2909
|
+
keywordLocation: '#/oneOf/50/required',
|
|
2885
2910
|
instanceLocation: '#/params',
|
|
2886
2911
|
},
|
|
2887
2912
|
]
|
|
@@ -2890,7 +2915,7 @@ export function validateRequest(value) {
|
|
|
2890
2915
|
if (!(Array.isArray(data.params) && data.params.length === 0)) {
|
|
2891
2916
|
validate.errors = [
|
|
2892
2917
|
{
|
|
2893
|
-
keywordLocation: '#/oneOf/
|
|
2918
|
+
keywordLocation: '#/oneOf/50/properties/params/const',
|
|
2894
2919
|
instanceLocation: '#/params',
|
|
2895
2920
|
},
|
|
2896
2921
|
]
|
package/lib/types.d.ts
CHANGED
|
@@ -40,8 +40,10 @@ export interface CreateEvmDepsParams {
|
|
|
40
40
|
simulateEthereumTransactions: SimulateTransactionsFn;
|
|
41
41
|
getActiveWalletAccountData: GetActiveWalletAccountData;
|
|
42
42
|
transactionSigner: EVMTransactionSignerModule;
|
|
43
|
+
messageSigner?: EVMMessageSigner;
|
|
43
44
|
getLedgerDevice?: GetLedgerDevice;
|
|
44
45
|
addEthereumChain?: (param: AddEthereumChainParameter) => Promise<null>;
|
|
46
|
+
onEthWalletWatchAssetRequest?: (param: EthWalletWatchAsset) => Promise<boolean>;
|
|
45
47
|
}
|
|
46
48
|
export declare type EVMFactory = (params: CreateEvmDepsParams) => EVMDeps;
|
|
47
49
|
export declare type EVMTransactionSignerModule = ITransactionSignerModule<EVMUnsignedTransaction>;
|
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": "12.
|
|
4
|
+
"version": "12.17.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@exodus/web3-constants": "^1.30.0",
|
|
38
38
|
"@exodus/web3-ethereum-utils": "^3.33.0",
|
|
39
39
|
"@exodus/web3-provider": "^3.15.0",
|
|
40
|
-
"@exodus/web3-rpc-handlers": "^2.
|
|
40
|
+
"@exodus/web3-rpc-handlers": "^2.24.0",
|
|
41
41
|
"@exodus/web3-utils": "^1.46.0",
|
|
42
42
|
"bn.js": "^5.2.0",
|
|
43
43
|
"eth-rpc-errors": "^4.0.3"
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"@exodus/assets": "^8.0.95",
|
|
47
47
|
"@exodus/json-rpc": "^1.11.0",
|
|
48
48
|
"@exodus/schemasafe": "^1.0.0",
|
|
49
|
-
"@exodus/web3-management": "0.
|
|
49
|
+
"@exodus/web3-management": "0.35.0",
|
|
50
50
|
"@exodus/web3-types": "0.0.0",
|
|
51
51
|
"@exodus/web3-validation": "^1.38.0",
|
|
52
52
|
"@wallet-standard/base": "^1.0.1"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "fd27d08c77e036bc7fc316bd2d9980747122b69a"
|
|
55
55
|
}
|