@exodus/web3-ethereum 2.4.1 → 2.6.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.
|
@@ -41,16 +41,13 @@ const createEvmDepsFactory = ({ analytics, activeWalletAccountAtom, assetsModule
|
|
|
41
41
|
});
|
|
42
42
|
return privateKey;
|
|
43
43
|
};
|
|
44
|
-
const getNonce = async (
|
|
45
|
-
// Shouldn't we retrieve the nonce for a given account?
|
|
46
|
-
// We are relying on the assumption here that "account"
|
|
47
|
-
// is always equal to the activeWalletAccount.
|
|
44
|
+
const getNonce = async () => {
|
|
48
45
|
const [baseAssetTxLog, blockchainNonce] = await Promise.all([
|
|
49
46
|
blockchainMetadata.getTxLog({
|
|
50
47
|
assetName,
|
|
51
48
|
walletAccount: await activeWalletAccountAtom.get(),
|
|
52
49
|
}),
|
|
53
|
-
apiGetNonce({ asset, address:
|
|
50
|
+
apiGetNonce({ asset, address: await getAddress() }),
|
|
54
51
|
]);
|
|
55
52
|
const walletNonce = Array.from(baseAssetTxLog)
|
|
56
53
|
.filter((tx) => tx.sent && !tx.dropped && tx.data.nonce != null)
|
|
@@ -59,7 +59,7 @@ export function exposeHandlers(rpc, deps) {
|
|
|
59
59
|
async function prepareTransaction(transaction) {
|
|
60
60
|
const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = await getFeeData();
|
|
61
61
|
const preparedTransaction = { ...transaction };
|
|
62
|
-
preparedTransaction.nonce = await getNonce(
|
|
62
|
+
preparedTransaction.nonce = await getNonce();
|
|
63
63
|
if (!transaction.value) {
|
|
64
64
|
preparedTransaction.value = '0x0';
|
|
65
65
|
}
|
|
@@ -25,8 +25,18 @@ export function parseAndValidateTypedData(typedData, { chainId: activeChainId })
|
|
|
25
25
|
throw new InvalidInputError();
|
|
26
26
|
}
|
|
27
27
|
const allowedFieldsSet = new Set(parsedTypedData.types[parsedTypedData.primaryType].map(({ name }) => name));
|
|
28
|
+
// Handle cases where the message includes fields that doesn't belong to the primary type.
|
|
29
|
+
const isFieldExempted = (field) => {
|
|
30
|
+
// Handle OpenSea case. See: https://github.com/status-im/status-mobile/issues/13769
|
|
31
|
+
if (field === 'totalOriginalConsiderationItems' &&
|
|
32
|
+
parsedTypedData.primaryType === 'OrderComponents' &&
|
|
33
|
+
parsedTypedData.message['consideration']) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
28
38
|
for (const field in parsedTypedData.message) {
|
|
29
|
-
if (!allowedFieldsSet.has(field)) {
|
|
39
|
+
if (!allowedFieldsSet.has(field) && !isFieldExempted(field)) {
|
|
30
40
|
throw new InvalidInputError(`field '${field}' is not defined in the primary type definition`);
|
|
31
41
|
}
|
|
32
42
|
}
|
|
@@ -325,19 +325,22 @@ export function validateRequest(value) {
|
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
327
|
if ('gasPrice' in data && hasOwn(data, 'gasPrice')) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
328
|
+
let passes2 = 0
|
|
329
|
+
const sub17 = (() => {
|
|
330
|
+
if (!(typeof data.gasPrice === 'string')) return false
|
|
331
|
+
if (!format4.test(data.gasPrice)) return false
|
|
332
|
+
return true
|
|
333
|
+
})()
|
|
334
|
+
if (sub17) passes2++
|
|
335
|
+
const sub18 = (() => {
|
|
336
|
+
if (!(data.gasPrice === null)) return false
|
|
337
|
+
return true
|
|
338
|
+
})()
|
|
339
|
+
if (sub18) passes2++
|
|
340
|
+
if (passes2 !== 1) {
|
|
338
341
|
validate.errors = [
|
|
339
342
|
{
|
|
340
|
-
keywordLocation: '#/properties/gasPrice/
|
|
343
|
+
keywordLocation: '#/properties/gasPrice/oneOf',
|
|
341
344
|
instanceLocation: '#/gasPrice',
|
|
342
345
|
},
|
|
343
346
|
]
|
|
@@ -388,19 +391,19 @@ export function validateRequest(value) {
|
|
|
388
391
|
'maxPriorityFeePerGas' in data &&
|
|
389
392
|
hasOwn(data, 'maxPriorityFeePerGas')
|
|
390
393
|
) {
|
|
391
|
-
let
|
|
392
|
-
const
|
|
394
|
+
let passes3 = 0
|
|
395
|
+
const sub19 = (() => {
|
|
393
396
|
if (!(typeof data.maxPriorityFeePerGas === 'string')) return false
|
|
394
397
|
if (!format1.test(data.maxPriorityFeePerGas)) return false
|
|
395
398
|
return true
|
|
396
399
|
})()
|
|
397
|
-
if (
|
|
398
|
-
const
|
|
400
|
+
if (sub19) passes3++
|
|
401
|
+
const sub20 = (() => {
|
|
399
402
|
if (!(data.maxPriorityFeePerGas === null)) return false
|
|
400
403
|
return true
|
|
401
404
|
})()
|
|
402
|
-
if (
|
|
403
|
-
if (
|
|
405
|
+
if (sub20) passes3++
|
|
406
|
+
if (passes3 !== 1) {
|
|
404
407
|
validate.errors = [
|
|
405
408
|
{
|
|
406
409
|
keywordLocation: '#/properties/maxPriorityFeePerGas/oneOf',
|
|
@@ -411,19 +414,19 @@ export function validateRequest(value) {
|
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
416
|
if ('maxFeePerGas' in data && hasOwn(data, 'maxFeePerGas')) {
|
|
414
|
-
let
|
|
415
|
-
const
|
|
417
|
+
let passes4 = 0
|
|
418
|
+
const sub21 = (() => {
|
|
416
419
|
if (!(typeof data.maxFeePerGas === 'string')) return false
|
|
417
420
|
if (!format1.test(data.maxFeePerGas)) return false
|
|
418
421
|
return true
|
|
419
422
|
})()
|
|
420
|
-
if (
|
|
421
|
-
const
|
|
423
|
+
if (sub21) passes4++
|
|
424
|
+
const sub22 = (() => {
|
|
422
425
|
if (!(data.maxFeePerGas === null)) return false
|
|
423
426
|
return true
|
|
424
427
|
})()
|
|
425
|
-
if (
|
|
426
|
-
if (
|
|
428
|
+
if (sub22) passes4++
|
|
429
|
+
if (passes4 !== 1) {
|
|
427
430
|
validate.errors = [
|
|
428
431
|
{
|
|
429
432
|
keywordLocation: '#/properties/maxFeePerGas/oneOf',
|
|
@@ -1031,14 +1034,14 @@ export function validateRequest(value) {
|
|
|
1031
1034
|
}
|
|
1032
1035
|
}
|
|
1033
1036
|
if ('image' in data && hasOwn(data, 'image')) {
|
|
1034
|
-
let
|
|
1035
|
-
const
|
|
1037
|
+
let passes5 = 0
|
|
1038
|
+
const sub23 = (() => {
|
|
1036
1039
|
if (!(typeof data.image === 'string')) return false
|
|
1037
1040
|
if (!format6.test(data.image)) return false
|
|
1038
1041
|
return true
|
|
1039
1042
|
})()
|
|
1040
|
-
if (
|
|
1041
|
-
const
|
|
1043
|
+
if (sub23) passes5++
|
|
1044
|
+
const sub24 = (() => {
|
|
1042
1045
|
const err38 = validate.errors
|
|
1043
1046
|
const res38 = ref16(data.image)
|
|
1044
1047
|
const suberr38 = ref16.errors
|
|
@@ -1046,8 +1049,8 @@ export function validateRequest(value) {
|
|
|
1046
1049
|
if (!res38) return false
|
|
1047
1050
|
return true
|
|
1048
1051
|
})()
|
|
1049
|
-
if (
|
|
1050
|
-
if (
|
|
1052
|
+
if (sub24) passes5++
|
|
1053
|
+
if (passes5 !== 1) {
|
|
1051
1054
|
validate.errors = [
|
|
1052
1055
|
{
|
|
1053
1056
|
keywordLocation: '#/properties/image/oneOf',
|
package/lib/types.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare type EVMDeps = {
|
|
|
31
31
|
sendRawTransaction: (rawTransaction: string) => Promise<EthTransactionHash>;
|
|
32
32
|
getEstimatedGas: (transaction: EthTransaction) => Promise<string>;
|
|
33
33
|
getFeeData: () => Promise<FeeData>;
|
|
34
|
-
getNonce: (
|
|
34
|
+
getNonce: () => Promise<string>;
|
|
35
35
|
forwardRequest: (args: EthRequestArguments) => Promise<unknown>;
|
|
36
36
|
onEthWalletWatchAssetRequest?: (assetDetails: EthWalletWatchAsset) => Promise<boolean>;
|
|
37
37
|
};
|
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": "2.
|
|
4
|
+
"version": "2.6.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@exodus/currency": "^2.1.2",
|
|
35
35
|
"@exodus/ethereum-api": "^6.0.0",
|
|
36
36
|
"@exodus/web3-constants": "^1.19.0",
|
|
37
|
-
"@exodus/web3-ethereum-utils": "^1.
|
|
37
|
+
"@exodus/web3-ethereum-utils": "^1.9.0",
|
|
38
38
|
"@exodus/web3-provider": "^2.17.0",
|
|
39
39
|
"@exodus/web3-rpc-handlers": "^0.14.0",
|
|
40
40
|
"bn.js": "^5.2.0",
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"@exodus/json-rpc": "^1.11.0",
|
|
46
46
|
"@exodus/schemasafe": "^1.0.0",
|
|
47
47
|
"@exodus/web3-types": "^1.15.0",
|
|
48
|
-
"@exodus/web3-validation": "^1.
|
|
48
|
+
"@exodus/web3-validation": "^1.34.0",
|
|
49
49
|
"@wallet-standard/base": "^1.0.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@exodus/assets": "^8.0.72"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "5782440c25f9464da940fb715cd7b102b03cf9c9"
|
|
55
55
|
}
|