@toruslabs/ethereum-controllers 8.17.0 → 9.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.
- package/dist/lib.cjs/Account/AccountTrackerController.js +15 -7
- package/dist/lib.cjs/AccountAbstraction/AccountAbstractionController.js +4 -6
- package/dist/lib.cjs/Eip5792/walletGetCallsStatus.js +2 -2
- package/dist/lib.cjs/Eip5792/walletSendCalls.js +8 -9
- package/dist/lib.cjs/Eip7702/eip7702Utils.js +3 -3
- package/dist/lib.cjs/Gas/GasFeeController.js +3 -2
- package/dist/lib.cjs/Keyring/KeyringController.js +69 -40
- package/dist/lib.cjs/Message/utils.js +15 -14
- package/dist/lib.cjs/Nfts/NftHandler.js +54 -12
- package/dist/lib.cjs/Nfts/NftsController.js +1 -4
- package/dist/lib.cjs/Preferences/PreferencesController.js +2 -2
- package/dist/lib.cjs/Tokens/TokenHandler.js +39 -7
- package/dist/lib.cjs/Tokens/TokensController.js +15 -7
- package/dist/lib.cjs/Transaction/TransactionController.js +17 -20
- package/dist/lib.cjs/Transaction/TransactionGasUtil.js +11 -12
- package/dist/lib.cjs/Transaction/TransactionUtils.js +44 -39
- package/dist/lib.cjs/index.js +0 -1
- package/dist/lib.cjs/types/Account/AccountTrackerController.d.ts +1 -1
- package/dist/lib.cjs/types/AccountAbstraction/AccountAbstractionController.d.ts +1 -3
- package/dist/lib.cjs/types/Keyring/KeyringController.d.ts +4 -4
- package/dist/lib.cjs/types/Nfts/NftHandler.d.ts +4 -3
- package/dist/lib.cjs/types/Nfts/NftsController.d.ts +0 -1
- package/dist/lib.cjs/types/Tokens/TokenHandler.d.ts +4 -3
- package/dist/lib.cjs/types/Tokens/TokensController.d.ts +1 -1
- package/dist/lib.cjs/types/Transaction/TransactionUtils.d.ts +11 -3
- package/dist/lib.cjs/types/utils/abis.d.ts +544 -99
- package/dist/lib.cjs/types/utils/eip5792Types.d.ts +0 -1
- package/dist/lib.cjs/types/utils/hex.d.ts +9 -0
- package/dist/lib.cjs/types/utils/interfaces.d.ts +205 -2
- package/dist/lib.cjs/types/utils/transaction.d.ts +1 -1
- package/dist/lib.cjs/types/utils/viem.d.ts +8 -0
- package/dist/lib.cjs/utils/abis.js +12 -0
- package/dist/lib.cjs/utils/conversionUtils.js +3 -4
- package/dist/lib.cjs/utils/eip5792Types.js +0 -2
- package/dist/lib.cjs/utils/helpers.js +9 -8
- package/dist/lib.cjs/utils/hex.js +23 -0
- package/dist/lib.cjs/utils/transaction.js +7 -11
- package/dist/lib.cjs/utils/viem.js +214 -0
- package/dist/lib.esm/Account/AccountTrackerController.js +15 -7
- package/dist/lib.esm/AccountAbstraction/AccountAbstractionController.js +5 -7
- package/dist/lib.esm/Eip5792/walletGetCallsStatus.js +1 -1
- package/dist/lib.esm/Eip5792/walletSendCalls.js +9 -10
- package/dist/lib.esm/Eip7702/eip7702Utils.js +1 -1
- package/dist/lib.esm/Gas/GasFeeController.js +3 -2
- package/dist/lib.esm/Keyring/KeyringController.js +68 -40
- package/dist/lib.esm/Message/utils.js +13 -12
- package/dist/lib.esm/Network/createEthereumMiddleware.js +2 -2
- package/dist/lib.esm/Nfts/NftHandler.js +54 -12
- package/dist/lib.esm/Nfts/NftsController.js +1 -4
- package/dist/lib.esm/Preferences/PreferencesController.js +1 -1
- package/dist/lib.esm/Tokens/TokenHandler.js +39 -7
- package/dist/lib.esm/Tokens/TokensController.js +15 -7
- package/dist/lib.esm/Transaction/TransactionController.js +6 -9
- package/dist/lib.esm/Transaction/TransactionGasUtil.js +11 -12
- package/dist/lib.esm/Transaction/TransactionUtils.js +30 -26
- package/dist/lib.esm/index.js +2 -2
- package/dist/lib.esm/utils/abis.js +12 -0
- package/dist/lib.esm/utils/conversionUtils.js +2 -3
- package/dist/lib.esm/utils/eip5792Types.js +1 -2
- package/dist/lib.esm/utils/helpers.js +8 -7
- package/dist/lib.esm/utils/hex.js +21 -0
- package/dist/lib.esm/utils/interfaces.js +64 -0
- package/dist/lib.esm/utils/transaction.js +7 -11
- package/dist/lib.esm/utils/viem.js +214 -0
- package/package.json +13 -18
- package/dist/ethereumControllers.umd.min.js +0 -2
- package/dist/ethereumControllers.umd.min.js.LICENSE.txt +0 -50
|
@@ -8,7 +8,6 @@ const EIP_5792_METHODS = {
|
|
|
8
8
|
WALLET_GET_CALLS_STATUS: "wallet_getCallsStatus",
|
|
9
9
|
WALLET_SHOW_CALLS_STATUS: "wallet_showCallsStatus"
|
|
10
10
|
};
|
|
11
|
-
const SUPPORTED_EIP_5792_VERSIONS = ["1.0", "2.0"];
|
|
12
11
|
|
|
13
12
|
// ============================================================================
|
|
14
13
|
// EIP-5792 Types
|
|
@@ -102,4 +101,4 @@ const Eip5792AtomicStatus = {
|
|
|
102
101
|
* Currently only atomic batches are supported via EIP-7702.
|
|
103
102
|
*/
|
|
104
103
|
|
|
105
|
-
export { EIP5792ErrorCode, EIP_5792_METHODS, Eip5792AtomicStatus, GetCallsStatusCode
|
|
104
|
+
export { EIP5792ErrorCode, EIP_5792_METHODS, Eip5792AtomicStatus, GetCallsStatusCode };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import {
|
|
3
|
-
import { formatSmallNumbers, significantDigits, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, addressSlicer, TransactionStatus } from '@toruslabs/base-controllers';
|
|
2
|
+
import { TransactionStatus, formatSmallNumbers, significantDigits, ACTIVITY_ACTION_RECEIVE, ACTIVITY_ACTION_SEND, addressSlicer } from '@toruslabs/base-controllers';
|
|
4
3
|
import { BigNumber } from 'bignumber.js';
|
|
5
4
|
import log from 'loglevel';
|
|
5
|
+
import { toHex, isAddress, getAddress } from 'viem';
|
|
6
6
|
import { determineTransactionType } from '../Transaction/TransactionUtils.js';
|
|
7
|
-
import { SUPPORTED_NETWORKS,
|
|
7
|
+
import { SUPPORTED_NETWORKS, CONTRACT_TYPE_ERC1155, CONTRACT_TYPE_ERC721, CONTRACT_TYPE_ERC20, MAINNET_CHAIN_ID, TEST_CHAINS, METHOD_TYPES, CONTRACT_TYPE_ETH } from './constants.js';
|
|
8
|
+
import { addHexPrefix, stripHexPrefix } from './hex.js';
|
|
8
9
|
|
|
9
10
|
function hexToBn(hex) {
|
|
10
11
|
return new BigNumber(stripHexPrefix(hex), 16);
|
|
@@ -93,18 +94,18 @@ function formatTime(time) {
|
|
|
93
94
|
}
|
|
94
95
|
function isAddressByChainId(address, _chainId) {
|
|
95
96
|
// TOOD: add rsk network checks.
|
|
96
|
-
return
|
|
97
|
+
return isAddress(address);
|
|
97
98
|
}
|
|
98
99
|
function toChecksumAddressByChainId(address, chainId) {
|
|
99
100
|
// TOOD: add rsk network checks.
|
|
100
101
|
if (!isAddressByChainId(address)) return address;
|
|
101
|
-
return
|
|
102
|
+
return getAddress(address);
|
|
102
103
|
}
|
|
103
104
|
const GAS_LIMITS = {
|
|
104
105
|
// maximum gasLimit of a simple send
|
|
105
|
-
SIMPLE:
|
|
106
|
+
SIMPLE: toHex(21000),
|
|
106
107
|
// a base estimate for token transfers.
|
|
107
|
-
BASE_TOKEN_ESTIMATE:
|
|
108
|
+
BASE_TOKEN_ESTIMATE: toHex(100000)
|
|
108
109
|
};
|
|
109
110
|
function bnLessThan(a, b) {
|
|
110
111
|
if (a === null || a === undefined || b === null || b === undefined) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isHex } from 'viem';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Removes '0x' from a given `String` if present
|
|
5
|
+
*/
|
|
6
|
+
const stripHexPrefix = str => {
|
|
7
|
+
if (typeof str !== "string") throw new Error(`[stripHexPrefix] input must be type 'string', received ${typeof str}`);
|
|
8
|
+
return isHex(str) ? str.slice(2) : str;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Adds "0x" to a given `string` if it does not already start with "0x".
|
|
13
|
+
*/
|
|
14
|
+
const addHexPrefix = str => {
|
|
15
|
+
if (typeof str !== "string") {
|
|
16
|
+
return str;
|
|
17
|
+
}
|
|
18
|
+
return isHex(str) ? str : `0x${str}`;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { addHexPrefix, stripHexPrefix };
|
|
@@ -25,4 +25,68 @@ const TRANSACTION_CATEGORY_EIP7702 = {
|
|
|
25
25
|
* Type Def for function to query the deployment bytecode of an address. (eth_getCode)
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A [[HexString]] whose length is even, which ensures it is a valid
|
|
30
|
+
* representation of binary data.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An object that can be used to represent binary data.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A BLOb object that can be passed for [[link-eip-4844]]
|
|
39
|
+
* transactions.
|
|
40
|
+
*
|
|
41
|
+
* It may have had its commitment and proof already provided
|
|
42
|
+
* or rely on an attached [[KzgLibrary]] to compute them.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A KZG Library with the necessary functions to compute
|
|
47
|
+
* BLOb commitments and proofs.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A KZG Library with any of the various API configurations.
|
|
52
|
+
* As the library is still experimental and the API is not
|
|
53
|
+
* stable, depending on the version used the method names and
|
|
54
|
+
* signatures are still in flux.
|
|
55
|
+
*
|
|
56
|
+
* This allows any of the versions to be passed into Transaction
|
|
57
|
+
* while providing a stable external API.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Any type that can be used where a numeric value is needed.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Any type that can be used where a big number is needed.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A SignatureLike
|
|
70
|
+
*
|
|
71
|
+
* @_docloc: api/crypto:Signing
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* A **TransactionLike** is an object which is appropriate as a loose
|
|
76
|
+
* input for many operations which will populate missing properties of
|
|
77
|
+
* a transaction.
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A single [[AccessList]] entry of storage keys (slots) for an address.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* An ordered collection of [[AccessList]] entries.
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Any ethers-supported access list structure.
|
|
90
|
+
*/
|
|
91
|
+
|
|
28
92
|
export { TRANSACTION_CATEGORY_EIP7702 };
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { createCustomCommon, Mainnet } from '@ethereumjs/common';
|
|
2
|
-
import { createTxFromRLP } from '@ethereumjs/tx';
|
|
3
|
-
import { hexToBytes, addHexPrefix, bytesToHex } from '@ethereumjs/util';
|
|
4
1
|
import log from 'loglevel';
|
|
2
|
+
import { recoverTransactionAddress, keccak256 } from 'viem';
|
|
5
3
|
import { METHOD_TYPES } from './constants.js';
|
|
4
|
+
import { addHexPrefix } from './hex.js';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Transaction decoder for analytics.
|
|
9
8
|
* Decodes eth_sendRawTransaction and eth_sendUserOperation requests.
|
|
10
9
|
*/
|
|
11
|
-
const transactionDecoder = (req, chainId) => {
|
|
10
|
+
const transactionDecoder = async (req, chainId) => {
|
|
12
11
|
let sender = "";
|
|
13
12
|
let txHash = "";
|
|
14
13
|
try {
|
|
15
14
|
if (req.method === METHOD_TYPES.ETH_SEND_RAW_TRANSACTION) {
|
|
16
15
|
const rawTx = req.params[0];
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
chainId
|
|
21
|
-
}, Mainnet)
|
|
16
|
+
const normalizedRawTx = addHexPrefix(rawTx);
|
|
17
|
+
sender = await recoverTransactionAddress({
|
|
18
|
+
serializedTransaction: normalizedRawTx
|
|
22
19
|
});
|
|
23
|
-
|
|
24
|
-
txHash = bytesToHex(tx.hash());
|
|
20
|
+
txHash = keccak256(normalizedRawTx);
|
|
25
21
|
} else if (req.method === METHOD_TYPES.ETH_SEND_USER_OPERATION) {
|
|
26
22
|
const userOpReq = req;
|
|
27
23
|
sender = userOpReq.params.map(p => p.sender).join(",");
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { isHex, parseSignature, isAddress, toHex } from 'viem';
|
|
2
|
+
|
|
3
|
+
// viem's serializeTransaction infers tx type via `if (transaction.type)` which is
|
|
4
|
+
// falsy for type 0 (legacy). Map numeric types to string names so the check passes,
|
|
5
|
+
// and strip undefined/null fields that also break viem's type inference.
|
|
6
|
+
const VIEM_TX_TYPE_NAMES = {
|
|
7
|
+
0: "legacy",
|
|
8
|
+
1: "eip2930",
|
|
9
|
+
2: "eip1559",
|
|
10
|
+
3: "eip4844",
|
|
11
|
+
4: "eip7702"
|
|
12
|
+
};
|
|
13
|
+
const VIEM_QUANTITY_FIELDS = ["gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "maxFeePerBlobGas", "value"];
|
|
14
|
+
function toViemQuantity(value) {
|
|
15
|
+
if (typeof value === "bigint") return value;
|
|
16
|
+
if (typeof value === "number") return BigInt(value);
|
|
17
|
+
if (typeof value === "string" && isHex(value)) return BigInt(value);
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
function toViemNumber(value) {
|
|
21
|
+
if (typeof value === "number") return value;
|
|
22
|
+
if (typeof value === "bigint") return Number(value);
|
|
23
|
+
if (typeof value === "string" && isHex(value)) return Number(value);
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function toViemHex(value) {
|
|
27
|
+
if (typeof value === "string" && isHex(value)) return value;
|
|
28
|
+
if (value instanceof Uint8Array) return toHex(value);
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
function toViemAddress(value) {
|
|
32
|
+
if (typeof value === "string" && isAddress(value)) return value;
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
function toViemHexArray(value) {
|
|
36
|
+
if (!Array.isArray(value)) return undefined;
|
|
37
|
+
const normalized = [];
|
|
38
|
+
for (const item of value) {
|
|
39
|
+
const hex = toViemHex(item);
|
|
40
|
+
if (!hex) return undefined;
|
|
41
|
+
normalized.push(hex);
|
|
42
|
+
}
|
|
43
|
+
return normalized;
|
|
44
|
+
}
|
|
45
|
+
function toViemAccessList(value) {
|
|
46
|
+
if (!value) return undefined;
|
|
47
|
+
const accessList = [];
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
for (const entry of value) {
|
|
50
|
+
if (Array.isArray(entry)) {
|
|
51
|
+
const [addressLike, storageKeysLike] = entry;
|
|
52
|
+
const address = toViemAddress(addressLike);
|
|
53
|
+
const storageKeys = toViemHexArray(storageKeysLike);
|
|
54
|
+
if (!address || !storageKeys) return undefined;
|
|
55
|
+
accessList.push({
|
|
56
|
+
address,
|
|
57
|
+
storageKeys
|
|
58
|
+
});
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (typeof entry === "object" && entry !== null) {
|
|
62
|
+
const address = toViemAddress(entry.address);
|
|
63
|
+
const storageKeys = toViemHexArray(entry.storageKeys);
|
|
64
|
+
if (!address || !storageKeys) return undefined;
|
|
65
|
+
accessList.push({
|
|
66
|
+
address,
|
|
67
|
+
storageKeys
|
|
68
|
+
});
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
return accessList;
|
|
74
|
+
}
|
|
75
|
+
if (typeof value === "object") {
|
|
76
|
+
for (const [addressLike, storageKeysLike] of Object.entries(value)) {
|
|
77
|
+
const address = toViemAddress(addressLike);
|
|
78
|
+
const storageKeys = toViemHexArray(storageKeysLike);
|
|
79
|
+
if (!address || !storageKeys) return undefined;
|
|
80
|
+
accessList.push({
|
|
81
|
+
address,
|
|
82
|
+
storageKeys
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return accessList;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
function toViemAuthorizationList(value) {
|
|
90
|
+
if (!value) return undefined;
|
|
91
|
+
const authorizationList = [];
|
|
92
|
+
for (const authorization of value) {
|
|
93
|
+
const address = toViemAddress(authorization.address);
|
|
94
|
+
const chainId = toViemNumber(authorization.chainId);
|
|
95
|
+
const nonce = toViemNumber(authorization.nonce);
|
|
96
|
+
if (!address || typeof chainId === "undefined" || typeof nonce === "undefined") {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
const normalizedAuthorization = {
|
|
100
|
+
address,
|
|
101
|
+
chainId,
|
|
102
|
+
nonce
|
|
103
|
+
};
|
|
104
|
+
const signature = authorization.signature;
|
|
105
|
+
if (typeof signature === "string" && isHex(signature)) {
|
|
106
|
+
const parsed = parseSignature(signature);
|
|
107
|
+
normalizedAuthorization.r = parsed.r;
|
|
108
|
+
normalizedAuthorization.s = parsed.s;
|
|
109
|
+
normalizedAuthorization.yParity = parsed.yParity;
|
|
110
|
+
} else if (typeof signature === "object" && signature !== null) {
|
|
111
|
+
const r = toViemHex(signature.r);
|
|
112
|
+
const s = toViemHex(signature.s);
|
|
113
|
+
const yParity = toViemNumber(signature.yParity);
|
|
114
|
+
const vRaw = signature.v;
|
|
115
|
+
const v = typeof vRaw === "bigint" ? vRaw : typeof vRaw === "number" ? BigInt(vRaw) : typeof vRaw === "string" && isHex(vRaw) ? BigInt(vRaw) : undefined;
|
|
116
|
+
if (r && s) {
|
|
117
|
+
normalizedAuthorization.r = r;
|
|
118
|
+
normalizedAuthorization.s = s;
|
|
119
|
+
}
|
|
120
|
+
if (typeof yParity !== "undefined") {
|
|
121
|
+
normalizedAuthorization.yParity = yParity;
|
|
122
|
+
}
|
|
123
|
+
if (typeof v !== "undefined") {
|
|
124
|
+
normalizedAuthorization.v = v;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
authorizationList.push(normalizedAuthorization);
|
|
128
|
+
}
|
|
129
|
+
return authorizationList;
|
|
130
|
+
}
|
|
131
|
+
function toViemBlobs(value) {
|
|
132
|
+
if (!value) return undefined;
|
|
133
|
+
const blobs = [];
|
|
134
|
+
for (const blob of value) {
|
|
135
|
+
if (typeof blob === "string" || blob instanceof Uint8Array) {
|
|
136
|
+
const normalizedBlob = toViemHex(blob);
|
|
137
|
+
if (!normalizedBlob) return undefined;
|
|
138
|
+
blobs.push(normalizedBlob);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (typeof blob === "object" && blob !== null) {
|
|
142
|
+
const normalizedBlob = toViemHex(blob.data);
|
|
143
|
+
if (!normalizedBlob) return undefined;
|
|
144
|
+
blobs.push(normalizedBlob);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
return blobs;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Prepare transaction params for signing.
|
|
154
|
+
* @param tx - The transaction to prepare.
|
|
155
|
+
* @returns The prepared transaction.
|
|
156
|
+
*/
|
|
157
|
+
function prepareViemTx(tx) {
|
|
158
|
+
var _input$gas;
|
|
159
|
+
const input = tx;
|
|
160
|
+
const prepared = {};
|
|
161
|
+
const txType = typeof input.type === "number" ? VIEM_TX_TYPE_NAMES[input.type] : input.type;
|
|
162
|
+
if (typeof txType === "string") {
|
|
163
|
+
prepared.type = txType;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// For EIP-4844 Transactions, we want to sign the transaction payload body (tx_payload_body) without the sidecars (ie. without the network wrapper).
|
|
167
|
+
// ref: https://github.com/wevm/viem/blob/b3af510a6e2e45526e2bb10298b7fc1f178a73a3/src/accounts/utils/signTransaction.ts#L56
|
|
168
|
+
if (prepared.type === "eip4844") {
|
|
169
|
+
prepared.sidecars = false;
|
|
170
|
+
}
|
|
171
|
+
const chainId = toViemNumber(input.chainId);
|
|
172
|
+
if (typeof chainId !== "undefined") {
|
|
173
|
+
prepared.chainId = chainId;
|
|
174
|
+
}
|
|
175
|
+
const nonce = toViemNumber(input.nonce);
|
|
176
|
+
if (typeof nonce !== "undefined") {
|
|
177
|
+
prepared.nonce = nonce;
|
|
178
|
+
}
|
|
179
|
+
const gas = toViemQuantity((_input$gas = input.gas) !== null && _input$gas !== void 0 ? _input$gas : input.gasLimit);
|
|
180
|
+
if (typeof gas !== "undefined") {
|
|
181
|
+
prepared.gas = gas;
|
|
182
|
+
}
|
|
183
|
+
for (const field of VIEM_QUANTITY_FIELDS) {
|
|
184
|
+
const value = toViemQuantity(input[field]);
|
|
185
|
+
if (typeof value !== "undefined") {
|
|
186
|
+
prepared[field] = value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (typeof input.to === "string") {
|
|
190
|
+
prepared.to = input.to;
|
|
191
|
+
}
|
|
192
|
+
if (typeof input.data === "string") {
|
|
193
|
+
prepared.data = input.data;
|
|
194
|
+
}
|
|
195
|
+
const accessList = toViemAccessList(input.accessList);
|
|
196
|
+
if (accessList) {
|
|
197
|
+
prepared.accessList = accessList;
|
|
198
|
+
}
|
|
199
|
+
const authorizationList = toViemAuthorizationList(input.authorizationList);
|
|
200
|
+
if (authorizationList) {
|
|
201
|
+
prepared.authorizationList = authorizationList;
|
|
202
|
+
}
|
|
203
|
+
const blobVersionedHashes = toViemHexArray(input.blobVersionedHashes);
|
|
204
|
+
if (blobVersionedHashes) {
|
|
205
|
+
prepared.blobVersionedHashes = blobVersionedHashes;
|
|
206
|
+
}
|
|
207
|
+
const blobs = toViemBlobs(input.blobs);
|
|
208
|
+
if (blobs) {
|
|
209
|
+
prepared.blobs = blobs;
|
|
210
|
+
}
|
|
211
|
+
return prepared;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { prepareViemTx };
|
package/package.json
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toruslabs/ethereum-controllers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"homepage": "https://github.com/torusresearch/controllers#readme",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "dist/lib.cjs/index.js",
|
|
8
8
|
"module": "dist/lib.esm/index.js",
|
|
9
|
-
"unpkg": "dist/
|
|
10
|
-
"jsdelivr": "dist/
|
|
9
|
+
"unpkg": "dist/lib.esm/index.js",
|
|
10
|
+
"jsdelivr": "dist/lib.esm/index.js",
|
|
11
11
|
"types": "dist/lib.cjs/types/index.d.ts",
|
|
12
12
|
"author": "Torus Labs",
|
|
13
13
|
"scripts": {
|
|
14
14
|
"dev": "rimraf dist/ && cross-env NODE_ENV=development torus-scripts start",
|
|
15
15
|
"build": "rimraf dist/ && cross-env NODE_ENV=production torus-scripts build",
|
|
16
|
-
"lint": "
|
|
16
|
+
"lint": "torus-scripts lint src/ test/",
|
|
17
17
|
"prepack": "npm run build",
|
|
18
18
|
"pre-commit": "lint-staged --cwd .",
|
|
19
|
-
"test": "vitest run --config test/configs/browsers.config.mts --coverage"
|
|
19
|
+
"test": "vitest run --config test/configs/browsers.config.mts --coverage",
|
|
20
|
+
"type-check": "tsc --noEmit -p tsconfig.json"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@metamask/smart-accounts-kit": "~0.3.0",
|
|
27
|
-
"@toruslabs/base-controllers": "^8.17.0",
|
|
28
|
-
"@toruslabs/http-helpers": "^8.1.1",
|
|
23
|
+
"@metamask/smart-accounts-kit": "~0.4.0-beta.1",
|
|
24
|
+
"@toruslabs/base-controllers": "^9.0.0",
|
|
25
|
+
"@toruslabs/http-helpers": "^9.0.0",
|
|
26
|
+
"@toruslabs/metadata-helpers": "^8.1.0",
|
|
29
27
|
"@web3auth/auth": "^10.8.0",
|
|
30
28
|
"async-mutex": "^0.5.0",
|
|
31
29
|
"bignumber.js": "^9.3.1",
|
|
32
|
-
"bn.js": "^5.2.2",
|
|
33
30
|
"deepmerge": "^4.3.1",
|
|
34
31
|
"ethereum-cryptography": "^3.2.0",
|
|
35
|
-
"ethers": "^6.16.0",
|
|
36
32
|
"fast-json-patch": "^3.1.1",
|
|
37
33
|
"fast-safe-stringify": "^2.1.1",
|
|
38
34
|
"jsonschema": "^1.5.0",
|
|
@@ -61,16 +57,15 @@
|
|
|
61
57
|
"url": "https://github.com/torusresearch/controllers/issues"
|
|
62
58
|
},
|
|
63
59
|
"engines": {
|
|
64
|
-
"node": ">=
|
|
65
|
-
"npm": ">=
|
|
60
|
+
"node": ">=22.x",
|
|
61
|
+
"npm": ">=10.x"
|
|
66
62
|
},
|
|
67
63
|
"keywords": [],
|
|
68
64
|
"publishConfig": {
|
|
69
65
|
"access": "public"
|
|
70
66
|
},
|
|
71
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "85e8f530c68dc0916a30421454b99bba01711d0a",
|
|
72
68
|
"devDependencies": {
|
|
73
|
-
"@typechain/ethers-v6": "^0.5.1",
|
|
74
69
|
"@types/uuid": "^10.0.0",
|
|
75
70
|
"typechain": "^8.3.2"
|
|
76
71
|
}
|