viem 0.0.1-alpha.12 → 0.0.1-alpha.14

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.
@@ -1,8 +1,8 @@
1
- export { C as CallArgs, a as CallContractArgs, b as CallContractResponse, c as CallResponse, d as CreateBlockFilterResponse, e as CreatePendingTransactionFilterResponse, D as DropTransactionArgs, E as EstimateGasArgs, f as EstimateGasResponse, bh as FormattedTransactionRequest, G as GetBalanceArgs, g as GetBalanceResponse, h as GetBlockArgs, i as GetBlockNumberArgs, j as GetBlockNumberResponse, k as GetBlockResponse, l as GetBlockTransactionCountArgs, m as GetBlockTransactionCountResponse, n as GetFeeHistoryArgs, o as GetFeeHistoryResponse, p as GetFilterChangesArgs, q as GetFilterChangesResponse, r as GetFilterLogsArgs, s as GetFilterLogsResponse, t as GetGasPriceResponse, u as GetPermissionsResponse, v as GetTransactionArgs, w as GetTransactionConfirmationsArgs, x as GetTransactionConfirmationsResponse, y as GetTransactionCountArgs, z as GetTransactionCountResponse, B as GetTransactionReceiptArgs, F as GetTransactionReceiptResponse, A as GetTransactionResponse, I as ImpersonateAccountArgs, H as IncreaseTimeArgs, M as MineArgs, O as OnBlock, J as OnBlockNumber, K as OnBlockNumberResponse, L as OnBlockResponse, N as OnTransactions, P as OnTransactionsResponse, bf as ReplacementReason, bg as ReplacementResponse, Q as RequestPermissionsResponse, R as ResetArgs, S as RevertArgs, T as SendTransactionArgs, U as SendTransactionResponse, V as SendUnsignedTransactionArgs, W as SendUnsignedTransactionResponse, X as SetBalanceArgs, Y as SetBlockGasLimitArgs, a1 as SetBlockTimestampIntervalArgs, Z as SetCodeArgs, _ as SetCoinbaseArgs, $ as SetIntervalMiningArgs, a0 as SetMinGasPriceArgs, a3 as SetNextBlockBaseFeePerGasArgs, a2 as SetNextBlockTimestampArgs, a4 as SetNonceArgs, a5 as SetStorageAtArgs, a6 as SignMessageArgs, a7 as SignMessageResponse, a8 as StopImpersonatingAccountArgs, a9 as SwitchChainArgs, aa as UninstallFilterArgs, ab as UninstallFilterResponse, ac as WaitForTransactionReceiptArgs, ad as WaitForTransactionReceiptResponse, ae as WatchAssetArgs, af as WatchAssetResponse, ag as WatchBlockNumberArgs, ah as WatchBlocksArgs, ai as WatchPendingTransactionsArgs, aj as addChain, ak as call, al as callContract, am as createBlockFilter, an as createPendingTransactionFilter, ap as dropTransaction, ao as estimateGas, aq as getAccounts, ar as getAutomine, as as getBalance, at as getBlock, au as getBlockNumber, be as getBlockNumberCache, av as getBlockTransactionCount, aw as getChainId, ax as getFeeHistory, ay as getFilterChanges, az as getFilterLogs, aA as getGasPrice, aB as getPermissions, aC as getTransaction, aD as getTransactionConfirmations, aE as getTransactionCount, aF as getTransactionReceipt, aG as getTxpoolContent, aH as getTxpoolStatus, aI as impersonateAccount, aJ as increaseTime, aK as inspectTxpool, aL as mine, aM as removeBlockTimestampInterval, aO as requestAccounts, aP as requestPermissions, aN as reset, aQ as revert, aR as sendTransaction, aS as sendUnsignedTransaction, aT as setAutomine, aU as setBalance, aV as setBlockGasLimit, aW as setBlockTimestampInterval, aX as setCode, aY as setCoinbase, aZ as setIntervalMining, a_ as setLoggingEnabled, a$ as setMinGasPrice, b0 as setNextBlockBaseFeePerGas, b1 as setNextBlockTimestamp, b2 as setNonce, b3 as setStorageAt, b4 as signMessage, b5 as snapshot, b6 as stopImpersonatingAccount, b7 as switchChain, b8 as uninstallFilter, b9 as waitForTransactionReceipt, ba as watchAsset, bb as watchBlockNumber, bc as watchBlocks, bd as watchPendingTransactions } from '../watchAsset-43255bfd.js';
1
+ export { C as CallArgs, a as CallContractArgs, b as CallContractResponse, c as CallResponse, d as CreateBlockFilterResponse, e as CreatePendingTransactionFilterResponse, D as DeployContractArgs, g as DeployContractResponse, h as DropTransactionArgs, E as EstimateGasArgs, f as EstimateGasResponse, bn as FormattedTransactionRequest, G as GetBalanceArgs, i as GetBalanceResponse, j as GetBlockArgs, k as GetBlockNumberArgs, l as GetBlockNumberResponse, m as GetBlockResponse, n as GetBlockTransactionCountArgs, o as GetBlockTransactionCountResponse, p as GetBytecodeArgs, q as GetBytecodeResponse, r as GetFeeHistoryArgs, s as GetFeeHistoryResponse, t as GetFilterChangesArgs, u as GetFilterChangesResponse, v as GetFilterLogsArgs, w as GetFilterLogsResponse, x as GetGasPriceResponse, y as GetPermissionsResponse, z as GetTransactionArgs, A as GetTransactionConfirmationsArgs, B as GetTransactionConfirmationsResponse, F as GetTransactionCountArgs, H as GetTransactionCountResponse, J as GetTransactionReceiptArgs, K as GetTransactionReceiptResponse, I as GetTransactionResponse, L as ImpersonateAccountArgs, M as IncreaseTimeArgs, N as MineArgs, O as OnBlock, P as OnBlockNumber, Q as OnBlockNumberResponse, R as OnBlockResponse, S as OnTransactions, T as OnTransactionsResponse, bl as ReplacementReason, bm as ReplacementResponse, V as RequestPermissionsResponse, U as ResetArgs, W as RevertArgs, X as SendTransactionArgs, Y as SendTransactionResponse, Z as SendUnsignedTransactionArgs, _ as SendUnsignedTransactionResponse, $ as SetBalanceArgs, a0 as SetBlockGasLimitArgs, a5 as SetBlockTimestampIntervalArgs, a1 as SetCodeArgs, a2 as SetCoinbaseArgs, a3 as SetIntervalMiningArgs, a4 as SetMinGasPriceArgs, a7 as SetNextBlockBaseFeePerGasArgs, a6 as SetNextBlockTimestampArgs, a8 as SetNonceArgs, a9 as SetStorageAtArgs, aa as SignMessageArgs, ab as SignMessageResponse, ac as StopImpersonatingAccountArgs, ad as SwitchChainArgs, ae as UninstallFilterArgs, af as UninstallFilterResponse, ag as WaitForTransactionReceiptArgs, ah as WaitForTransactionReceiptResponse, ai as WatchAssetArgs, aj as WatchAssetResponse, ak as WatchBlockNumberArgs, al as WatchBlocksArgs, am as WatchPendingTransactionsArgs, an as addChain, ao as call, ap as callContract, aq as createBlockFilter, ar as createPendingTransactionFilter, as as deployContract, at as dropTransaction, au as estimateGas, av as getAccounts, aw as getAutomine, ax as getBalance, ay as getBlock, az as getBlockNumber, bk as getBlockNumberCache, aA as getBlockTransactionCount, aB as getBytecode, aC as getChainId, aD as getFeeHistory, aE as getFilterChanges, aF as getFilterLogs, aG as getGasPrice, aH as getPermissions, aI as getTransaction, aJ as getTransactionConfirmations, aK as getTransactionCount, aL as getTransactionReceipt, aM as getTxpoolContent, aN as getTxpoolStatus, aO as impersonateAccount, aP as increaseTime, aQ as inspectTxpool, aR as mine, aS as removeBlockTimestampInterval, aU as requestAccounts, aV as requestPermissions, aT as reset, aW as revert, aX as sendTransaction, aY as sendUnsignedTransaction, aZ as setAutomine, a_ as setBalance, a$ as setBlockGasLimit, b0 as setBlockTimestampInterval, b1 as setCode, b2 as setCoinbase, b3 as setIntervalMining, b4 as setLoggingEnabled, b5 as setMinGasPrice, b6 as setNextBlockBaseFeePerGas, b7 as setNextBlockTimestamp, b8 as setNonce, b9 as setStorageAt, ba as signMessage, bb as snapshot, bc as stopImpersonatingAccount, bd as switchChain, be as uninstallFilter, bf as waitForTransactionReceipt, bg as watchAsset, bh as watchBlockNumber, bi as watchBlocks, bj as watchPendingTransactions } from '../stopImpersonatingAccount-fcc5a678.js';
2
2
  import 'abitype';
3
3
  import '../chains.js';
4
4
  import '../rpc-b77c5aee.js';
5
5
  import '@wagmi/chains';
6
- import '../transactionRequest-08d30731.js';
6
+ import '../transactionRequest-1d4e4385.js';
7
7
  import '../createWalletClient-3f9fa8b6.js';
8
8
  import '../eip1193-c001fcd5.js';
@@ -59,10 +59,10 @@
59
59
 
60
60
 
61
61
 
62
- var _chunkQO5C5Y2Ljs = require('../chunk-QO5C5Y2L.js');
63
- require('../chunk-A3PVAH22.js');
64
62
 
65
63
 
64
+ var _chunkVUNR7KGGjs = require('../chunk-VUNR7KGG.js');
65
+ require('../chunk-6Z62LPKB.js');
66
66
 
67
67
 
68
68
 
@@ -122,4 +122,8 @@ require('../chunk-A3PVAH22.js');
122
122
 
123
123
 
124
124
 
125
- exports.addChain = _chunkQO5C5Y2Ljs.addChain; exports.call = _chunkQO5C5Y2Ljs.call; exports.callContract = _chunkQO5C5Y2Ljs.callContract; exports.createBlockFilter = _chunkQO5C5Y2Ljs.createBlockFilter; exports.createPendingTransactionFilter = _chunkQO5C5Y2Ljs.createPendingTransactionFilter; exports.dropTransaction = _chunkQO5C5Y2Ljs.dropTransaction; exports.estimateGas = _chunkQO5C5Y2Ljs.estimateGas; exports.getAccounts = _chunkQO5C5Y2Ljs.getAccounts; exports.getAutomine = _chunkQO5C5Y2Ljs.getAutomine; exports.getBalance = _chunkQO5C5Y2Ljs.getBalance; exports.getBlock = _chunkQO5C5Y2Ljs.getBlock; exports.getBlockNumber = _chunkQO5C5Y2Ljs.getBlockNumber; exports.getBlockNumberCache = _chunkQO5C5Y2Ljs.getBlockNumberCache; exports.getBlockTransactionCount = _chunkQO5C5Y2Ljs.getBlockTransactionCount; exports.getChainId = _chunkQO5C5Y2Ljs.getChainId; exports.getFeeHistory = _chunkQO5C5Y2Ljs.getFeeHistory; exports.getFilterChanges = _chunkQO5C5Y2Ljs.getFilterChanges; exports.getFilterLogs = _chunkQO5C5Y2Ljs.getFilterLogs; exports.getGasPrice = _chunkQO5C5Y2Ljs.getGasPrice; exports.getPermissions = _chunkQO5C5Y2Ljs.getPermissions; exports.getTransaction = _chunkQO5C5Y2Ljs.getTransaction; exports.getTransactionConfirmations = _chunkQO5C5Y2Ljs.getTransactionConfirmations; exports.getTransactionCount = _chunkQO5C5Y2Ljs.getTransactionCount; exports.getTransactionReceipt = _chunkQO5C5Y2Ljs.getTransactionReceipt; exports.getTxpoolContent = _chunkQO5C5Y2Ljs.getTxpoolContent; exports.getTxpoolStatus = _chunkQO5C5Y2Ljs.getTxpoolStatus; exports.impersonateAccount = _chunkQO5C5Y2Ljs.impersonateAccount; exports.increaseTime = _chunkQO5C5Y2Ljs.increaseTime; exports.inspectTxpool = _chunkQO5C5Y2Ljs.inspectTxpool; exports.mine = _chunkQO5C5Y2Ljs.mine; exports.removeBlockTimestampInterval = _chunkQO5C5Y2Ljs.removeBlockTimestampInterval; exports.requestAccounts = _chunkQO5C5Y2Ljs.requestAccounts; exports.requestPermissions = _chunkQO5C5Y2Ljs.requestPermissions; exports.reset = _chunkQO5C5Y2Ljs.reset; exports.revert = _chunkQO5C5Y2Ljs.revert; exports.sendTransaction = _chunkQO5C5Y2Ljs.sendTransaction; exports.sendUnsignedTransaction = _chunkQO5C5Y2Ljs.sendUnsignedTransaction; exports.setAutomine = _chunkQO5C5Y2Ljs.setAutomine; exports.setBalance = _chunkQO5C5Y2Ljs.setBalance; exports.setBlockGasLimit = _chunkQO5C5Y2Ljs.setBlockGasLimit; exports.setBlockTimestampInterval = _chunkQO5C5Y2Ljs.setBlockTimestampInterval; exports.setCode = _chunkQO5C5Y2Ljs.setCode; exports.setCoinbase = _chunkQO5C5Y2Ljs.setCoinbase; exports.setIntervalMining = _chunkQO5C5Y2Ljs.setIntervalMining; exports.setLoggingEnabled = _chunkQO5C5Y2Ljs.setLoggingEnabled; exports.setMinGasPrice = _chunkQO5C5Y2Ljs.setMinGasPrice; exports.setNextBlockBaseFeePerGas = _chunkQO5C5Y2Ljs.setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = _chunkQO5C5Y2Ljs.setNextBlockTimestamp; exports.setNonce = _chunkQO5C5Y2Ljs.setNonce; exports.setStorageAt = _chunkQO5C5Y2Ljs.setStorageAt; exports.signMessage = _chunkQO5C5Y2Ljs.signMessage; exports.snapshot = _chunkQO5C5Y2Ljs.snapshot; exports.stopImpersonatingAccount = _chunkQO5C5Y2Ljs.stopImpersonatingAccount; exports.switchChain = _chunkQO5C5Y2Ljs.switchChain; exports.uninstallFilter = _chunkQO5C5Y2Ljs.uninstallFilter; exports.waitForTransactionReceipt = _chunkQO5C5Y2Ljs.waitForTransactionReceipt; exports.watchAsset = _chunkQO5C5Y2Ljs.watchAsset; exports.watchBlockNumber = _chunkQO5C5Y2Ljs.watchBlockNumber; exports.watchBlocks = _chunkQO5C5Y2Ljs.watchBlocks; exports.watchPendingTransactions = _chunkQO5C5Y2Ljs.watchPendingTransactions;
125
+
126
+
127
+
128
+
129
+ exports.addChain = _chunkVUNR7KGGjs.addChain; exports.call = _chunkVUNR7KGGjs.call; exports.callContract = _chunkVUNR7KGGjs.callContract; exports.createBlockFilter = _chunkVUNR7KGGjs.createBlockFilter; exports.createPendingTransactionFilter = _chunkVUNR7KGGjs.createPendingTransactionFilter; exports.deployContract = _chunkVUNR7KGGjs.deployContract; exports.dropTransaction = _chunkVUNR7KGGjs.dropTransaction; exports.estimateGas = _chunkVUNR7KGGjs.estimateGas; exports.getAccounts = _chunkVUNR7KGGjs.getAccounts; exports.getAutomine = _chunkVUNR7KGGjs.getAutomine; exports.getBalance = _chunkVUNR7KGGjs.getBalance; exports.getBlock = _chunkVUNR7KGGjs.getBlock; exports.getBlockNumber = _chunkVUNR7KGGjs.getBlockNumber; exports.getBlockNumberCache = _chunkVUNR7KGGjs.getBlockNumberCache; exports.getBlockTransactionCount = _chunkVUNR7KGGjs.getBlockTransactionCount; exports.getBytecode = _chunkVUNR7KGGjs.getBytecode; exports.getChainId = _chunkVUNR7KGGjs.getChainId; exports.getFeeHistory = _chunkVUNR7KGGjs.getFeeHistory; exports.getFilterChanges = _chunkVUNR7KGGjs.getFilterChanges; exports.getFilterLogs = _chunkVUNR7KGGjs.getFilterLogs; exports.getGasPrice = _chunkVUNR7KGGjs.getGasPrice; exports.getPermissions = _chunkVUNR7KGGjs.getPermissions; exports.getTransaction = _chunkVUNR7KGGjs.getTransaction; exports.getTransactionConfirmations = _chunkVUNR7KGGjs.getTransactionConfirmations; exports.getTransactionCount = _chunkVUNR7KGGjs.getTransactionCount; exports.getTransactionReceipt = _chunkVUNR7KGGjs.getTransactionReceipt; exports.getTxpoolContent = _chunkVUNR7KGGjs.getTxpoolContent; exports.getTxpoolStatus = _chunkVUNR7KGGjs.getTxpoolStatus; exports.impersonateAccount = _chunkVUNR7KGGjs.impersonateAccount; exports.increaseTime = _chunkVUNR7KGGjs.increaseTime; exports.inspectTxpool = _chunkVUNR7KGGjs.inspectTxpool; exports.mine = _chunkVUNR7KGGjs.mine; exports.removeBlockTimestampInterval = _chunkVUNR7KGGjs.removeBlockTimestampInterval; exports.requestAccounts = _chunkVUNR7KGGjs.requestAccounts; exports.requestPermissions = _chunkVUNR7KGGjs.requestPermissions; exports.reset = _chunkVUNR7KGGjs.reset; exports.revert = _chunkVUNR7KGGjs.revert; exports.sendTransaction = _chunkVUNR7KGGjs.sendTransaction; exports.sendUnsignedTransaction = _chunkVUNR7KGGjs.sendUnsignedTransaction; exports.setAutomine = _chunkVUNR7KGGjs.setAutomine; exports.setBalance = _chunkVUNR7KGGjs.setBalance; exports.setBlockGasLimit = _chunkVUNR7KGGjs.setBlockGasLimit; exports.setBlockTimestampInterval = _chunkVUNR7KGGjs.setBlockTimestampInterval; exports.setCode = _chunkVUNR7KGGjs.setCode; exports.setCoinbase = _chunkVUNR7KGGjs.setCoinbase; exports.setIntervalMining = _chunkVUNR7KGGjs.setIntervalMining; exports.setLoggingEnabled = _chunkVUNR7KGGjs.setLoggingEnabled; exports.setMinGasPrice = _chunkVUNR7KGGjs.setMinGasPrice; exports.setNextBlockBaseFeePerGas = _chunkVUNR7KGGjs.setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = _chunkVUNR7KGGjs.setNextBlockTimestamp; exports.setNonce = _chunkVUNR7KGGjs.setNonce; exports.setStorageAt = _chunkVUNR7KGGjs.setStorageAt; exports.signMessage = _chunkVUNR7KGGjs.signMessage; exports.snapshot = _chunkVUNR7KGGjs.snapshot; exports.stopImpersonatingAccount = _chunkVUNR7KGGjs.stopImpersonatingAccount; exports.switchChain = _chunkVUNR7KGGjs.switchChain; exports.uninstallFilter = _chunkVUNR7KGGjs.uninstallFilter; exports.waitForTransactionReceipt = _chunkVUNR7KGGjs.waitForTransactionReceipt; exports.watchAsset = _chunkVUNR7KGGjs.watchAsset; exports.watchBlockNumber = _chunkVUNR7KGGjs.watchBlockNumber; exports.watchBlocks = _chunkVUNR7KGGjs.watchBlocks; exports.watchPendingTransactions = _chunkVUNR7KGGjs.watchPendingTransactions;
@@ -4,6 +4,7 @@ import {
4
4
  callContract,
5
5
  createBlockFilter,
6
6
  createPendingTransactionFilter,
7
+ deployContract,
7
8
  dropTransaction,
8
9
  estimateGas,
9
10
  getAccounts,
@@ -13,6 +14,7 @@ import {
13
14
  getBlockNumber,
14
15
  getBlockNumberCache,
15
16
  getBlockTransactionCount,
17
+ getBytecode,
16
18
  getChainId,
17
19
  getFeeHistory,
18
20
  getFilterChanges,
@@ -59,14 +61,15 @@ import {
59
61
  watchBlockNumber,
60
62
  watchBlocks,
61
63
  watchPendingTransactions
62
- } from "../chunk-DPSKYDCG.mjs";
63
- import "../chunk-ERPD74AT.mjs";
64
+ } from "../chunk-DUNJAMH5.mjs";
65
+ import "../chunk-KB6CBNKW.mjs";
64
66
  export {
65
67
  addChain,
66
68
  call,
67
69
  callContract,
68
70
  createBlockFilter,
69
71
  createPendingTransactionFilter,
72
+ deployContract,
70
73
  dropTransaction,
71
74
  estimateGas,
72
75
  getAccounts,
@@ -76,6 +79,7 @@ export {
76
79
  getBlockNumber,
77
80
  getBlockNumberCache,
78
81
  getBlockTransactionCount,
82
+ getBytecode,
79
83
  getChainId,
80
84
  getFeeHistory,
81
85
  getFilterChanges,
package/dist/chains.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkA3PVAH22js = require('./chunk-A3PVAH22.js');
6
+ var _chunk6Z62LPKBjs = require('./chunk-6Z62LPKB.js');
7
7
 
8
8
  // src/chains.ts
9
9
 
@@ -48,13 +48,13 @@ function defineFormatter({
48
48
  };
49
49
  };
50
50
  }
51
- var defineBlock = defineFormatter({ format: _chunkA3PVAH22js.formatBlock });
52
- var defineTransaction = defineFormatter({ format: _chunkA3PVAH22js.formatTransaction });
51
+ var defineBlock = defineFormatter({ format: _chunk6Z62LPKBjs.formatBlock });
52
+ var defineTransaction = defineFormatter({ format: _chunk6Z62LPKBjs.formatTransaction });
53
53
  var defineTransactionRequest = defineFormatter({
54
- format: _chunkA3PVAH22js.formatTransactionRequest
54
+ format: _chunk6Z62LPKBjs.formatTransactionRequest
55
55
  });
56
56
  var defineTransactionReceipt = defineFormatter({
57
- format: _chunkA3PVAH22js.formatTransactionReceipt
57
+ format: _chunk6Z62LPKBjs.formatTransactionReceipt
58
58
  });
59
59
  var arbitrumGoerli = defineChain(_chains.arbitrumGoerli);
60
60
  var arbitrum = defineChain(_chains.arbitrum);
package/dist/chains.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  formatTransaction,
4
4
  formatTransactionReceipt,
5
5
  formatTransactionRequest
6
- } from "./chunk-ERPD74AT.mjs";
6
+ } from "./chunk-KB6CBNKW.mjs";
7
7
 
8
8
  // src/chains.ts
9
9
  import {
@@ -3,7 +3,7 @@ import {
3
3
  buildRequest,
4
4
  getSocket,
5
5
  rpc
6
- } from "./chunk-ERPD74AT.mjs";
6
+ } from "./chunk-KB6CBNKW.mjs";
7
7
 
8
8
  // src/clients/transports/createTransport.ts
9
9
  function createTransport(config, value) {
@@ -9,7 +9,7 @@ var __publicField = (obj, key, value) => {
9
9
  var package_default = {
10
10
  name: "viem",
11
11
  description: "TypeScript Interface for Ethereum",
12
- version: "0.0.1-alpha.12",
12
+ version: "0.0.1-alpha.14",
13
13
  scripts: {
14
14
  anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
15
15
  bench: "vitest bench --no-threads",
@@ -2091,13 +2091,27 @@ function formatBlock(block) {
2091
2091
  };
2092
2092
  }
2093
2093
 
2094
+ // src/utils/formatters/extract.ts
2095
+ function extract(value, { formatter }) {
2096
+ if (!formatter)
2097
+ return {};
2098
+ const keys = Object.keys(formatter({}));
2099
+ return keys.reduce((data, key) => {
2100
+ if (_optionalChain([value, 'optionalAccess', _36 => _36.hasOwnProperty, 'call', _37 => _37(key)])) {
2101
+ ;
2102
+ data[key] = value[key];
2103
+ }
2104
+ return data;
2105
+ }, {});
2106
+ }
2107
+
2094
2108
  // src/utils/formatters/feeHistory.ts
2095
2109
  function formatFeeHistory(feeHistory) {
2096
2110
  return {
2097
2111
  baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
2098
2112
  gasUsedRatio: feeHistory.gasUsedRatio,
2099
2113
  oldestBlock: BigInt(feeHistory.oldestBlock),
2100
- reward: _optionalChain([feeHistory, 'access', _36 => _36.reward, 'optionalAccess', _37 => _37.map, 'call', _38 => _38(
2114
+ reward: _optionalChain([feeHistory, 'access', _38 => _38.reward, 'optionalAccess', _39 => _39.map, 'call', _40 => _40(
2101
2115
  (reward) => reward.map((value) => BigInt(value))
2102
2116
  )])
2103
2117
  };
@@ -2248,7 +2262,7 @@ function withTimeout(fn, {
2248
2262
  }
2249
2263
  }, timeout);
2250
2264
  }
2251
- resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _39 => _39.signal]) }));
2265
+ resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _41 => _41.signal]) }));
2252
2266
  } catch (err) {
2253
2267
  if (err.name === "AbortError")
2254
2268
  reject(errorInstance);
@@ -2289,8 +2303,8 @@ async function http(url, {
2289
2303
  ),
2290
2304
  {
2291
2305
  delay: ({ count, data: data2 }) => {
2292
- const retryAfter = _optionalChain([data2, 'optionalAccess', _40 => _40.headers, 'access', _41 => _41.get, 'call', _42 => _42("Retry-After")]);
2293
- if (_optionalChain([retryAfter, 'optionalAccess', _43 => _43.match, 'call', _44 => _44(/\d/)]))
2306
+ const retryAfter = _optionalChain([data2, 'optionalAccess', _42 => _42.headers, 'access', _43 => _43.get, 'call', _44 => _44("Retry-After")]);
2307
+ if (_optionalChain([retryAfter, 'optionalAccess', _45 => _45.match, 'call', _46 => _46(/\d/)]))
2294
2308
  return parseInt(retryAfter) * 1e3;
2295
2309
  return ~~((Math.random() + 0.5) * (1 << count)) * retryDelay;
2296
2310
  },
@@ -2305,7 +2319,7 @@ async function http(url, {
2305
2319
  }
2306
2320
  );
2307
2321
  let data;
2308
- if (_optionalChain([response, 'access', _45 => _45.headers, 'access', _46 => _46.get, 'call', _47 => _47("Content-Type"), 'optionalAccess', _48 => _48.startsWith, 'call', _49 => _49("application/json")])) {
2322
+ if (_optionalChain([response, 'access', _47 => _47.headers, 'access', _48 => _48.get, 'call', _49 => _49("Content-Type"), 'optionalAccess', _50 => _50.startsWith, 'call', _51 => _51("application/json")])) {
2309
2323
  data = await response.json();
2310
2324
  } else {
2311
2325
  data = await response.text();
@@ -2383,15 +2397,15 @@ function webSocket(socket, {
2383
2397
  if (typeof message.id === "number" && id_ !== message.id)
2384
2398
  return;
2385
2399
  if (message.error) {
2386
- _optionalChain([onError, 'optionalCall', _50 => _50(new RpcError({ body, error: message.error, url: socket.url }))]);
2400
+ _optionalChain([onError, 'optionalCall', _52 => _52(new RpcError({ body, error: message.error, url: socket.url }))]);
2387
2401
  } else {
2388
- _optionalChain([onData, 'optionalCall', _51 => _51(message)]);
2402
+ _optionalChain([onData, 'optionalCall', _53 => _53(message)]);
2389
2403
  }
2390
2404
  if (body.method === "eth_subscribe" && typeof message.result === "string") {
2391
2405
  socket.subscriptions.set(message.result, callback);
2392
2406
  }
2393
2407
  if (body.method === "eth_unsubscribe") {
2394
- socket.subscriptions.delete(_optionalChain([body, 'access', _52 => _52.params, 'optionalAccess', _53 => _53[0]]));
2408
+ socket.subscriptions.delete(_optionalChain([body, 'access', _54 => _54.params, 'optionalAccess', _55 => _55[0]]));
2395
2409
  }
2396
2410
  };
2397
2411
  socket.requests.set(id_, callback);
@@ -2615,4 +2629,5 @@ function parseGwei(ether, unit = "wei") {
2615
2629
 
2616
2630
 
2617
2631
 
2618
- exports.stringify = stringify; exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UnknownRpcError = UnknownRpcError; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.encodeHex = encodeHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.boolToBytes = boolToBytes; exports.encodeBytes = encodeBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.encodeRlp = encodeRlp; exports.decodeHex = decodeHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.decodeBytes = decodeBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.decodeRlp = decodeRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.getContractError = getContractError; exports.keccak256 = keccak256; exports.getEventSignature = getEventSignature; exports.getFunctionSignature = getFunctionSignature; exports.checksumAddress = checksumAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddress = isAddress; exports.isAddressEqual = isAddressEqual; exports.encodeAbi = encodeAbi; exports.decodeAbi = decodeAbi; exports.formatAbiItemWithParams = formatAbiItemWithParams; exports.decodeErrorResult = decodeErrorResult; exports.decodeFunctionData = decodeFunctionData; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.getAbiItem = getAbiItem; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.buildRequest = buildRequest; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.formatBlock = formatBlock; exports.formatFeeHistory = formatFeeHistory; exports.format = format3; exports.formatLog = formatLog; exports.formatTransactionReceipt = formatTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.getCache = getCache; exports.withCache = withCache; exports.wait = wait; exports.getSocket = getSocket; exports.rpc = rpc; exports.formatUnit = formatUnit; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseUnit = parseUnit; exports.parseEther = parseEther; exports.parseGwei = parseGwei; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.InvalidGasArgumentsError = InvalidGasArgumentsError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.UrlRequiredError = UrlRequiredError;
2632
+
2633
+ exports.stringify = stringify; exports.BaseError = BaseError; exports.AbiConstructorNotFoundError = AbiConstructorNotFoundError; exports.AbiConstructorParamsNotFoundError = AbiConstructorParamsNotFoundError; exports.AbiDecodingDataSizeInvalidError = AbiDecodingDataSizeInvalidError; exports.AbiEncodingArrayLengthMismatchError = AbiEncodingArrayLengthMismatchError; exports.AbiEncodingLengthMismatchError = AbiEncodingLengthMismatchError; exports.AbiErrorInputsNotFoundError = AbiErrorInputsNotFoundError; exports.AbiErrorNotFoundError = AbiErrorNotFoundError; exports.AbiErrorSignatureNotFoundError = AbiErrorSignatureNotFoundError; exports.AbiEventNotFoundError = AbiEventNotFoundError; exports.AbiFunctionNotFoundError = AbiFunctionNotFoundError; exports.AbiFunctionOutputsNotFoundError = AbiFunctionOutputsNotFoundError; exports.AbiFunctionSignatureNotFoundError = AbiFunctionSignatureNotFoundError; exports.InvalidAbiEncodingTypeError = InvalidAbiEncodingTypeError; exports.InvalidAbiDecodingTypeError = InvalidAbiDecodingTypeError; exports.InvalidArrayError = InvalidArrayError; exports.InvalidDefinitionTypeError = InvalidDefinitionTypeError; exports.InvalidAddressError = InvalidAddressError; exports.BlockNotFoundError = BlockNotFoundError; exports.SizeExceedsPaddingSizeError = SizeExceedsPaddingSizeError; exports.DataLengthTooLongError = DataLengthTooLongError; exports.DataLengthTooShortError = DataLengthTooShortError; exports.InvalidBytesBooleanError = InvalidBytesBooleanError; exports.InvalidHexBooleanError = InvalidHexBooleanError; exports.InvalidHexValueError = InvalidHexValueError; exports.OffsetOutOfBoundsError = OffsetOutOfBoundsError; exports.FilterTypeNotSupportedError = FilterTypeNotSupportedError; exports.RequestError = RequestError; exports.RpcRequestError = RpcRequestError; exports.ParseRpcError = ParseRpcError; exports.InvalidRequestRpcError = InvalidRequestRpcError; exports.MethodNotFoundRpcError = MethodNotFoundRpcError; exports.InvalidParamsRpcError = InvalidParamsRpcError; exports.InternalRpcError = InternalRpcError; exports.InvalidInputRpcError = InvalidInputRpcError; exports.ResourceNotFoundRpcError = ResourceNotFoundRpcError; exports.ResourceUnavailableRpcError = ResourceUnavailableRpcError; exports.TransactionRejectedRpcError = TransactionRejectedRpcError; exports.MethodNotSupportedRpcError = MethodNotSupportedRpcError; exports.LimitExceededRpcError = LimitExceededRpcError; exports.JsonRpcVersionUnsupportedError = JsonRpcVersionUnsupportedError; exports.UnknownRpcError = UnknownRpcError; exports.isBytes = isBytes; exports.isHex = isHex; exports.pad = pad; exports.padHex = padHex; exports.padBytes = padBytes; exports.trim = trim; exports.size = size; exports.slice = slice; exports.sliceBytes = sliceBytes; exports.sliceHex = sliceHex; exports.boolToHex = boolToHex; exports.bytesToHex = bytesToHex; exports.encodeHex = encodeHex; exports.numberToHex = numberToHex; exports.stringToHex = stringToHex; exports.boolToBytes = boolToBytes; exports.encodeBytes = encodeBytes; exports.hexToBytes = hexToBytes; exports.numberToBytes = numberToBytes; exports.stringToBytes = stringToBytes; exports.encodeRlp = encodeRlp; exports.decodeHex = decodeHex; exports.hexToBigInt = hexToBigInt; exports.hexToBool = hexToBool; exports.hexToNumber = hexToNumber; exports.hexToString = hexToString; exports.decodeBytes = decodeBytes; exports.bytesToBigint = bytesToBigint; exports.bytesToBool = bytesToBool; exports.bytesToNumber = bytesToNumber; exports.bytesToString = bytesToString; exports.decodeRlp = decodeRlp; exports.extractFunctionParts = extractFunctionParts; exports.extractFunctionName = extractFunctionName; exports.extractFunctionParams = extractFunctionParams; exports.extractFunctionType = extractFunctionType; exports.getContractError = getContractError; exports.keccak256 = keccak256; exports.getEventSignature = getEventSignature; exports.getFunctionSignature = getFunctionSignature; exports.checksumAddress = checksumAddress; exports.getAddress = getAddress; exports.getContractAddress = getContractAddress; exports.getCreateAddress = getCreateAddress; exports.getCreate2Address = getCreate2Address; exports.isAddress = isAddress; exports.isAddressEqual = isAddressEqual; exports.encodeAbi = encodeAbi; exports.decodeAbi = decodeAbi; exports.formatAbiItemWithParams = formatAbiItemWithParams; exports.decodeErrorResult = decodeErrorResult; exports.decodeFunctionData = decodeFunctionData; exports.decodeFunctionResult = decodeFunctionResult; exports.encodeDeployData = encodeDeployData; exports.getAbiItem = getAbiItem; exports.encodeErrorResult = encodeErrorResult; exports.encodeEventTopics = encodeEventTopics; exports.encodeFunctionData = encodeFunctionData; exports.encodeFunctionResult = encodeFunctionResult; exports.formatAbiItemWithArgs = formatAbiItemWithArgs; exports.buildRequest = buildRequest; exports.etherUnits = etherUnits; exports.gweiUnits = gweiUnits; exports.weiUnits = weiUnits; exports.transactionType = transactionType; exports.formatTransaction = formatTransaction; exports.formatBlock = formatBlock; exports.extract = extract; exports.formatFeeHistory = formatFeeHistory; exports.format = format3; exports.formatLog = formatLog; exports.formatTransactionReceipt = formatTransactionReceipt; exports.formatTransactionRequest = formatTransactionRequest; exports.getCache = getCache; exports.withCache = withCache; exports.wait = wait; exports.getSocket = getSocket; exports.rpc = rpc; exports.formatUnit = formatUnit; exports.formatEther = formatEther; exports.formatGwei = formatGwei; exports.parseUnit = parseUnit; exports.parseEther = parseEther; exports.parseGwei = parseGwei; exports.HttpRequestError = HttpRequestError; exports.WebSocketRequestError = WebSocketRequestError; exports.RpcError = RpcError; exports.TimeoutError = TimeoutError; exports.InvalidGasArgumentsError = InvalidGasArgumentsError; exports.TransactionNotFoundError = TransactionNotFoundError; exports.TransactionReceiptNotFoundError = TransactionReceiptNotFoundError; exports.WaitForTransactionReceiptTimeoutError = WaitForTransactionReceiptTimeoutError; exports.UrlRequiredError = UrlRequiredError;
@@ -7,8 +7,10 @@ import {
7
7
  WaitForTransactionReceiptTimeoutError,
8
8
  checksumAddress,
9
9
  decodeFunctionResult,
10
+ encodeDeployData,
10
11
  encodeFunctionData,
11
12
  encodeHex,
13
+ extract,
12
14
  format,
13
15
  formatBlock,
14
16
  formatFeeHistory,
@@ -23,7 +25,7 @@ import {
23
25
  numberToHex,
24
26
  wait,
25
27
  withCache
26
- } from "./chunk-ERPD74AT.mjs";
28
+ } from "./chunk-KB6CBNKW.mjs";
27
29
 
28
30
  // src/actions/public/call.ts
29
31
  async function call(client, {
@@ -45,6 +47,7 @@ async function call(client, {
45
47
  if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
46
48
  throw new InvalidGasArgumentsError();
47
49
  const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
50
+ const formatter = chain?.formatters?.transactionRequest;
48
51
  const request_ = format(
49
52
  {
50
53
  from,
@@ -57,10 +60,10 @@ async function call(client, {
57
60
  nonce,
58
61
  to,
59
62
  value,
60
- ...rest
63
+ ...extract(rest, { formatter })
61
64
  },
62
65
  {
63
- formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
66
+ formatter: formatter || formatTransactionRequest
64
67
  }
65
68
  );
66
69
  const response = await client.request({
@@ -123,6 +126,148 @@ async function createBlockFilter(client) {
123
126
  return { id, type: "block" };
124
127
  }
125
128
 
129
+ // src/actions/wallet/addChain.ts
130
+ async function addChain(client, chain) {
131
+ const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
132
+ await client.request({
133
+ method: "wallet_addEthereumChain",
134
+ params: [
135
+ {
136
+ chainId: numberToHex(id),
137
+ chainName: name,
138
+ nativeCurrency,
139
+ rpcUrls: rpcUrls.default.http,
140
+ blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
141
+ }
142
+ ]
143
+ });
144
+ }
145
+
146
+ // src/actions/wallet/getAccounts.ts
147
+ async function getAccounts(client) {
148
+ const addresses = await client.request({ method: "eth_accounts" });
149
+ return addresses.map((address) => checksumAddress(address));
150
+ }
151
+
152
+ // src/actions/wallet/getPermissions.ts
153
+ async function getPermissions(client) {
154
+ const permissions = await client.request({ method: "wallet_getPermissions" });
155
+ return permissions;
156
+ }
157
+
158
+ // src/actions/wallet/requestAccounts.ts
159
+ async function requestAccounts(client) {
160
+ const addresses = await client.request({ method: "eth_requestAccounts" });
161
+ return addresses.map((address) => getAddress(address));
162
+ }
163
+
164
+ // src/actions/wallet/requestPermissions.ts
165
+ async function requestPermissions(client, permissions) {
166
+ return client.request({
167
+ method: "wallet_requestPermissions",
168
+ params: [permissions]
169
+ });
170
+ }
171
+
172
+ // src/actions/wallet/sendTransaction.ts
173
+ async function sendTransaction(client, {
174
+ chain,
175
+ from,
176
+ accessList,
177
+ data,
178
+ gas,
179
+ gasPrice,
180
+ maxFeePerGas,
181
+ maxPriorityFeePerGas,
182
+ nonce,
183
+ to,
184
+ value,
185
+ ...rest
186
+ }) {
187
+ if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
188
+ throw new InvalidGasArgumentsError();
189
+ const formatter = chain?.formatters?.transactionRequest;
190
+ const request_ = format(
191
+ {
192
+ from,
193
+ accessList,
194
+ data,
195
+ gas,
196
+ gasPrice,
197
+ maxFeePerGas,
198
+ maxPriorityFeePerGas,
199
+ nonce,
200
+ to,
201
+ value,
202
+ ...extract(rest, { formatter })
203
+ },
204
+ {
205
+ formatter: formatter || formatTransactionRequest
206
+ }
207
+ );
208
+ const hash = await client.request({
209
+ method: "eth_sendTransaction",
210
+ params: [request_]
211
+ });
212
+ return hash;
213
+ }
214
+
215
+ // src/actions/wallet/signMessage.ts
216
+ async function signMessage(client, { from, data: data_ }) {
217
+ let data;
218
+ if (typeof data_ === "string") {
219
+ if (!data_.startsWith("0x"))
220
+ throw new BaseError(
221
+ `data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
222
+ {
223
+ docsPath: "/TODO"
224
+ }
225
+ );
226
+ data = data_;
227
+ } else {
228
+ data = encodeHex(data_);
229
+ }
230
+ const signed = await client.request({
231
+ method: "personal_sign",
232
+ params: [data, from]
233
+ });
234
+ return signed;
235
+ }
236
+
237
+ // src/actions/wallet/switchChain.ts
238
+ async function switchChain(client, { id }) {
239
+ await client.request({
240
+ method: "wallet_switchEthereumChain",
241
+ params: [
242
+ {
243
+ chainId: numberToHex(id)
244
+ }
245
+ ]
246
+ });
247
+ }
248
+
249
+ // src/actions/wallet/watchAsset.ts
250
+ async function watchAsset(client, params) {
251
+ const added = await client.request({
252
+ method: "wallet_watchAsset",
253
+ params: [params]
254
+ });
255
+ return added;
256
+ }
257
+
258
+ // src/actions/public/deployContract.ts
259
+ function deployContract(walletClient, { abi, args, bytecode, ...request }) {
260
+ const calldata = encodeDeployData({
261
+ abi,
262
+ args,
263
+ bytecode
264
+ });
265
+ return sendTransaction(walletClient, {
266
+ ...request,
267
+ data: calldata
268
+ });
269
+ }
270
+
126
271
  // src/actions/public/estimateGas.ts
127
272
  async function estimateGas(client, {
128
273
  blockNumber,
@@ -228,6 +373,18 @@ async function getBlockTransactionCount(client, {
228
373
  return hexToNumber(count);
229
374
  }
230
375
 
376
+ // src/actions/public/getBytecode.ts
377
+ async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
378
+ const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
379
+ const hex = await client.request({
380
+ method: "eth_getCode",
381
+ params: [address, blockNumberHex || blockTag]
382
+ });
383
+ if (hex === "0x")
384
+ return void 0;
385
+ return hex;
386
+ }
387
+
231
388
  // src/actions/public/getChainId.ts
232
389
  async function getChainId(client) {
233
390
  const chainIdHex = await client.request({ method: "eth_chainId" });
@@ -892,145 +1049,28 @@ async function stopImpersonatingAccount(client, { address }) {
892
1049
  });
893
1050
  }
894
1051
 
895
- // src/actions/wallet/addChain.ts
896
- async function addChain(client, chain) {
897
- const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
898
- await client.request({
899
- method: "wallet_addEthereumChain",
900
- params: [
901
- {
902
- chainId: numberToHex(id),
903
- chainName: name,
904
- nativeCurrency,
905
- rpcUrls: rpcUrls.default.http,
906
- blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
907
- }
908
- ]
909
- });
910
- }
911
-
912
- // src/actions/wallet/getAccounts.ts
913
- async function getAccounts(client) {
914
- const addresses = await client.request({ method: "eth_accounts" });
915
- return addresses.map((address) => checksumAddress(address));
916
- }
917
-
918
- // src/actions/wallet/getPermissions.ts
919
- async function getPermissions(client) {
920
- const permissions = await client.request({ method: "wallet_getPermissions" });
921
- return permissions;
922
- }
923
-
924
- // src/actions/wallet/requestAccounts.ts
925
- async function requestAccounts(client) {
926
- const addresses = await client.request({ method: "eth_requestAccounts" });
927
- return addresses.map((address) => getAddress(address));
928
- }
929
-
930
- // src/actions/wallet/requestPermissions.ts
931
- async function requestPermissions(client, permissions) {
932
- return client.request({
933
- method: "wallet_requestPermissions",
934
- params: [permissions]
935
- });
936
- }
937
-
938
- // src/actions/wallet/sendTransaction.ts
939
- async function sendTransaction(client, {
940
- chain,
941
- from,
942
- accessList,
943
- data,
944
- gas,
945
- gasPrice,
946
- maxFeePerGas,
947
- maxPriorityFeePerGas,
948
- nonce,
949
- to,
950
- value,
951
- ...rest
952
- }) {
953
- if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
954
- throw new InvalidGasArgumentsError();
955
- const request_ = format(
956
- {
957
- from,
958
- accessList,
959
- data,
960
- gas,
961
- gasPrice,
962
- maxFeePerGas,
963
- maxPriorityFeePerGas,
964
- nonce,
965
- to,
966
- value,
967
- ...rest
968
- },
969
- {
970
- formatter: chain?.formatters?.transactionRequest || formatTransactionRequest
971
- }
972
- );
973
- const hash = await client.request({
974
- method: "eth_sendTransaction",
975
- params: [request_]
976
- });
977
- return hash;
978
- }
979
-
980
- // src/actions/wallet/signMessage.ts
981
- async function signMessage(client, { from, data: data_ }) {
982
- let data;
983
- if (typeof data_ === "string") {
984
- if (!data_.startsWith("0x"))
985
- throw new BaseError(
986
- `data ("${data_}") must be a hex value. Encode it first to a hex with the \`encodeHex\` util.`,
987
- {
988
- docsPath: "/TODO"
989
- }
990
- );
991
- data = data_;
992
- } else {
993
- data = encodeHex(data_);
994
- }
995
- const signed = await client.request({
996
- method: "personal_sign",
997
- params: [data, from]
998
- });
999
- return signed;
1000
- }
1001
-
1002
- // src/actions/wallet/switchChain.ts
1003
- async function switchChain(client, { id }) {
1004
- await client.request({
1005
- method: "wallet_switchEthereumChain",
1006
- params: [
1007
- {
1008
- chainId: numberToHex(id)
1009
- }
1010
- ]
1011
- });
1012
- }
1013
-
1014
- // src/actions/wallet/watchAsset.ts
1015
- async function watchAsset(client, params) {
1016
- const added = await client.request({
1017
- method: "wallet_watchAsset",
1018
- params: [params]
1019
- });
1020
- return added;
1021
- }
1022
-
1023
1052
  export {
1024
1053
  call,
1025
1054
  callContract,
1026
1055
  createPendingTransactionFilter,
1027
1056
  createBlockFilter,
1057
+ addChain,
1058
+ getAccounts,
1059
+ getPermissions,
1060
+ requestAccounts,
1061
+ requestPermissions,
1062
+ sendTransaction,
1063
+ signMessage,
1064
+ switchChain,
1065
+ watchAsset,
1066
+ deployContract,
1028
1067
  estimateGas,
1029
1068
  getBalance,
1030
1069
  getBlock,
1031
1070
  getBlockNumberCache,
1032
1071
  getBlockNumber,
1033
1072
  getBlockTransactionCount,
1073
+ getBytecode,
1034
1074
  getChainId,
1035
1075
  getFeeHistory,
1036
1076
  getFilterChanges,
@@ -1071,14 +1111,5 @@ export {
1071
1111
  setNonce,
1072
1112
  setStorageAt,
1073
1113
  snapshot,
1074
- stopImpersonatingAccount,
1075
- addChain,
1076
- getAccounts,
1077
- getPermissions,
1078
- requestAccounts,
1079
- requestPermissions,
1080
- sendTransaction,
1081
- signMessage,
1082
- switchChain,
1083
- watchAsset
1114
+ stopImpersonatingAccount
1084
1115
  };