viem 0.0.1-alpha.11 → 0.0.1-alpha.13

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, bk 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 GetFeeHistoryArgs, q as GetFeeHistoryResponse, r as GetFilterChangesArgs, s as GetFilterChangesResponse, t as GetFilterLogsArgs, u as GetFilterLogsResponse, v as GetGasPriceResponse, w as GetPermissionsResponse, x as GetTransactionArgs, y as GetTransactionConfirmationsArgs, z as GetTransactionConfirmationsResponse, A as GetTransactionCountArgs, B as GetTransactionCountResponse, H as GetTransactionReceiptArgs, I as GetTransactionReceiptResponse, F as GetTransactionResponse, J as ImpersonateAccountArgs, K as IncreaseTimeArgs, M as MineArgs, O as OnBlock, L as OnBlockNumber, N as OnBlockNumberResponse, P as OnBlockResponse, Q as OnTransactions, R as OnTransactionsResponse, bi as ReplacementReason, bj as ReplacementResponse, T as RequestPermissionsResponse, S as ResetArgs, U as RevertArgs, V as SendTransactionArgs, W as SendTransactionResponse, X as SendUnsignedTransactionArgs, Y as SendUnsignedTransactionResponse, Z as SetBalanceArgs, _ as SetBlockGasLimitArgs, a3 as SetBlockTimestampIntervalArgs, $ as SetCodeArgs, a0 as SetCoinbaseArgs, a1 as SetIntervalMiningArgs, a2 as SetMinGasPriceArgs, a5 as SetNextBlockBaseFeePerGasArgs, a4 as SetNextBlockTimestampArgs, a6 as SetNonceArgs, a7 as SetStorageAtArgs, a8 as SignMessageArgs, a9 as SignMessageResponse, aa as StopImpersonatingAccountArgs, ab as SwitchChainArgs, ac as UninstallFilterArgs, ad as UninstallFilterResponse, ae as WaitForTransactionReceiptArgs, af as WaitForTransactionReceiptResponse, ag as WatchAssetArgs, ah as WatchAssetResponse, ai as WatchBlockNumberArgs, aj as WatchBlocksArgs, ak as WatchPendingTransactionsArgs, al as addChain, am as call, an as callContract, ao as createBlockFilter, ap as createPendingTransactionFilter, aq as deployContract, ar as dropTransaction, as as estimateGas, at as getAccounts, au as getAutomine, av as getBalance, aw as getBlock, ax as getBlockNumber, bh as getBlockNumberCache, ay as getBlockTransactionCount, az as getChainId, aA as getFeeHistory, aB as getFilterChanges, aC as getFilterLogs, aD as getGasPrice, aE as getPermissions, aF as getTransaction, aG as getTransactionConfirmations, aH as getTransactionCount, aI as getTransactionReceipt, aJ as getTxpoolContent, aK as getTxpoolStatus, aL as impersonateAccount, aM as increaseTime, aN as inspectTxpool, aO as mine, aP as removeBlockTimestampInterval, aR as requestAccounts, aS as requestPermissions, aQ as reset, aT as revert, aU as sendTransaction, aV as sendUnsignedTransaction, aW as setAutomine, aX as setBalance, aY as setBlockGasLimit, aZ as setBlockTimestampInterval, a_ as setCode, a$ as setCoinbase, b0 as setIntervalMining, b1 as setLoggingEnabled, b2 as setMinGasPrice, b3 as setNextBlockBaseFeePerGas, b4 as setNextBlockTimestamp, b5 as setNonce, b6 as setStorageAt, b7 as signMessage, b8 as snapshot, b9 as stopImpersonatingAccount, ba as switchChain, bb as uninstallFilter, bc as waitForTransactionReceipt, bd as watchAsset, be as watchBlockNumber, bf as watchBlocks, bg as watchPendingTransactions } from '../stopImpersonatingAccount-70c4a70c.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,9 +59,9 @@
59
59
 
60
60
 
61
61
 
62
- var _chunkPEAG3TICjs = require('../chunk-PEAG3TIC.js');
63
- require('../chunk-35OJIFIW.js');
64
62
 
63
+ var _chunkOHOJCVQDjs = require('../chunk-OHOJCVQD.js');
64
+ require('../chunk-AGF7GU6G.js');
65
65
 
66
66
 
67
67
 
@@ -122,4 +122,6 @@ require('../chunk-35OJIFIW.js');
122
122
 
123
123
 
124
124
 
125
- exports.addChain = _chunkPEAG3TICjs.addChain; exports.call = _chunkPEAG3TICjs.call; exports.callContract = _chunkPEAG3TICjs.callContract; exports.createBlockFilter = _chunkPEAG3TICjs.createBlockFilter; exports.createPendingTransactionFilter = _chunkPEAG3TICjs.createPendingTransactionFilter; exports.dropTransaction = _chunkPEAG3TICjs.dropTransaction; exports.estimateGas = _chunkPEAG3TICjs.estimateGas; exports.getAccounts = _chunkPEAG3TICjs.getAccounts; exports.getAutomine = _chunkPEAG3TICjs.getAutomine; exports.getBalance = _chunkPEAG3TICjs.getBalance; exports.getBlock = _chunkPEAG3TICjs.getBlock; exports.getBlockNumber = _chunkPEAG3TICjs.getBlockNumber; exports.getBlockNumberCache = _chunkPEAG3TICjs.getBlockNumberCache; exports.getBlockTransactionCount = _chunkPEAG3TICjs.getBlockTransactionCount; exports.getChainId = _chunkPEAG3TICjs.getChainId; exports.getFeeHistory = _chunkPEAG3TICjs.getFeeHistory; exports.getFilterChanges = _chunkPEAG3TICjs.getFilterChanges; exports.getFilterLogs = _chunkPEAG3TICjs.getFilterLogs; exports.getGasPrice = _chunkPEAG3TICjs.getGasPrice; exports.getPermissions = _chunkPEAG3TICjs.getPermissions; exports.getTransaction = _chunkPEAG3TICjs.getTransaction; exports.getTransactionConfirmations = _chunkPEAG3TICjs.getTransactionConfirmations; exports.getTransactionCount = _chunkPEAG3TICjs.getTransactionCount; exports.getTransactionReceipt = _chunkPEAG3TICjs.getTransactionReceipt; exports.getTxpoolContent = _chunkPEAG3TICjs.getTxpoolContent; exports.getTxpoolStatus = _chunkPEAG3TICjs.getTxpoolStatus; exports.impersonateAccount = _chunkPEAG3TICjs.impersonateAccount; exports.increaseTime = _chunkPEAG3TICjs.increaseTime; exports.inspectTxpool = _chunkPEAG3TICjs.inspectTxpool; exports.mine = _chunkPEAG3TICjs.mine; exports.removeBlockTimestampInterval = _chunkPEAG3TICjs.removeBlockTimestampInterval; exports.requestAccounts = _chunkPEAG3TICjs.requestAccounts; exports.requestPermissions = _chunkPEAG3TICjs.requestPermissions; exports.reset = _chunkPEAG3TICjs.reset; exports.revert = _chunkPEAG3TICjs.revert; exports.sendTransaction = _chunkPEAG3TICjs.sendTransaction; exports.sendUnsignedTransaction = _chunkPEAG3TICjs.sendUnsignedTransaction; exports.setAutomine = _chunkPEAG3TICjs.setAutomine; exports.setBalance = _chunkPEAG3TICjs.setBalance; exports.setBlockGasLimit = _chunkPEAG3TICjs.setBlockGasLimit; exports.setBlockTimestampInterval = _chunkPEAG3TICjs.setBlockTimestampInterval; exports.setCode = _chunkPEAG3TICjs.setCode; exports.setCoinbase = _chunkPEAG3TICjs.setCoinbase; exports.setIntervalMining = _chunkPEAG3TICjs.setIntervalMining; exports.setLoggingEnabled = _chunkPEAG3TICjs.setLoggingEnabled; exports.setMinGasPrice = _chunkPEAG3TICjs.setMinGasPrice; exports.setNextBlockBaseFeePerGas = _chunkPEAG3TICjs.setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = _chunkPEAG3TICjs.setNextBlockTimestamp; exports.setNonce = _chunkPEAG3TICjs.setNonce; exports.setStorageAt = _chunkPEAG3TICjs.setStorageAt; exports.signMessage = _chunkPEAG3TICjs.signMessage; exports.snapshot = _chunkPEAG3TICjs.snapshot; exports.stopImpersonatingAccount = _chunkPEAG3TICjs.stopImpersonatingAccount; exports.switchChain = _chunkPEAG3TICjs.switchChain; exports.uninstallFilter = _chunkPEAG3TICjs.uninstallFilter; exports.waitForTransactionReceipt = _chunkPEAG3TICjs.waitForTransactionReceipt; exports.watchAsset = _chunkPEAG3TICjs.watchAsset; exports.watchBlockNumber = _chunkPEAG3TICjs.watchBlockNumber; exports.watchBlocks = _chunkPEAG3TICjs.watchBlocks; exports.watchPendingTransactions = _chunkPEAG3TICjs.watchPendingTransactions;
125
+
126
+
127
+ exports.addChain = _chunkOHOJCVQDjs.addChain; exports.call = _chunkOHOJCVQDjs.call; exports.callContract = _chunkOHOJCVQDjs.callContract; exports.createBlockFilter = _chunkOHOJCVQDjs.createBlockFilter; exports.createPendingTransactionFilter = _chunkOHOJCVQDjs.createPendingTransactionFilter; exports.deployContract = _chunkOHOJCVQDjs.deployContract; exports.dropTransaction = _chunkOHOJCVQDjs.dropTransaction; exports.estimateGas = _chunkOHOJCVQDjs.estimateGas; exports.getAccounts = _chunkOHOJCVQDjs.getAccounts; exports.getAutomine = _chunkOHOJCVQDjs.getAutomine; exports.getBalance = _chunkOHOJCVQDjs.getBalance; exports.getBlock = _chunkOHOJCVQDjs.getBlock; exports.getBlockNumber = _chunkOHOJCVQDjs.getBlockNumber; exports.getBlockNumberCache = _chunkOHOJCVQDjs.getBlockNumberCache; exports.getBlockTransactionCount = _chunkOHOJCVQDjs.getBlockTransactionCount; exports.getChainId = _chunkOHOJCVQDjs.getChainId; exports.getFeeHistory = _chunkOHOJCVQDjs.getFeeHistory; exports.getFilterChanges = _chunkOHOJCVQDjs.getFilterChanges; exports.getFilterLogs = _chunkOHOJCVQDjs.getFilterLogs; exports.getGasPrice = _chunkOHOJCVQDjs.getGasPrice; exports.getPermissions = _chunkOHOJCVQDjs.getPermissions; exports.getTransaction = _chunkOHOJCVQDjs.getTransaction; exports.getTransactionConfirmations = _chunkOHOJCVQDjs.getTransactionConfirmations; exports.getTransactionCount = _chunkOHOJCVQDjs.getTransactionCount; exports.getTransactionReceipt = _chunkOHOJCVQDjs.getTransactionReceipt; exports.getTxpoolContent = _chunkOHOJCVQDjs.getTxpoolContent; exports.getTxpoolStatus = _chunkOHOJCVQDjs.getTxpoolStatus; exports.impersonateAccount = _chunkOHOJCVQDjs.impersonateAccount; exports.increaseTime = _chunkOHOJCVQDjs.increaseTime; exports.inspectTxpool = _chunkOHOJCVQDjs.inspectTxpool; exports.mine = _chunkOHOJCVQDjs.mine; exports.removeBlockTimestampInterval = _chunkOHOJCVQDjs.removeBlockTimestampInterval; exports.requestAccounts = _chunkOHOJCVQDjs.requestAccounts; exports.requestPermissions = _chunkOHOJCVQDjs.requestPermissions; exports.reset = _chunkOHOJCVQDjs.reset; exports.revert = _chunkOHOJCVQDjs.revert; exports.sendTransaction = _chunkOHOJCVQDjs.sendTransaction; exports.sendUnsignedTransaction = _chunkOHOJCVQDjs.sendUnsignedTransaction; exports.setAutomine = _chunkOHOJCVQDjs.setAutomine; exports.setBalance = _chunkOHOJCVQDjs.setBalance; exports.setBlockGasLimit = _chunkOHOJCVQDjs.setBlockGasLimit; exports.setBlockTimestampInterval = _chunkOHOJCVQDjs.setBlockTimestampInterval; exports.setCode = _chunkOHOJCVQDjs.setCode; exports.setCoinbase = _chunkOHOJCVQDjs.setCoinbase; exports.setIntervalMining = _chunkOHOJCVQDjs.setIntervalMining; exports.setLoggingEnabled = _chunkOHOJCVQDjs.setLoggingEnabled; exports.setMinGasPrice = _chunkOHOJCVQDjs.setMinGasPrice; exports.setNextBlockBaseFeePerGas = _chunkOHOJCVQDjs.setNextBlockBaseFeePerGas; exports.setNextBlockTimestamp = _chunkOHOJCVQDjs.setNextBlockTimestamp; exports.setNonce = _chunkOHOJCVQDjs.setNonce; exports.setStorageAt = _chunkOHOJCVQDjs.setStorageAt; exports.signMessage = _chunkOHOJCVQDjs.signMessage; exports.snapshot = _chunkOHOJCVQDjs.snapshot; exports.stopImpersonatingAccount = _chunkOHOJCVQDjs.stopImpersonatingAccount; exports.switchChain = _chunkOHOJCVQDjs.switchChain; exports.uninstallFilter = _chunkOHOJCVQDjs.uninstallFilter; exports.waitForTransactionReceipt = _chunkOHOJCVQDjs.waitForTransactionReceipt; exports.watchAsset = _chunkOHOJCVQDjs.watchAsset; exports.watchBlockNumber = _chunkOHOJCVQDjs.watchBlockNumber; exports.watchBlocks = _chunkOHOJCVQDjs.watchBlocks; exports.watchPendingTransactions = _chunkOHOJCVQDjs.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,
@@ -59,14 +60,15 @@ import {
59
60
  watchBlockNumber,
60
61
  watchBlocks,
61
62
  watchPendingTransactions
62
- } from "../chunk-JXGK2LUM.mjs";
63
- import "../chunk-DY4MSK2M.mjs";
63
+ } from "../chunk-NJ5NFIT4.mjs";
64
+ import "../chunk-4XV4JRFM.mjs";
64
65
  export {
65
66
  addChain,
66
67
  call,
67
68
  callContract,
68
69
  createBlockFilter,
69
70
  createPendingTransactionFilter,
71
+ deployContract,
70
72
  dropTransaction,
71
73
  estimateGas,
72
74
  getAccounts,
package/dist/chains.js CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunk35OJIFIWjs = require('./chunk-35OJIFIW.js');
6
+ var _chunkAGF7GU6Gjs = require('./chunk-AGF7GU6G.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: _chunk35OJIFIWjs.formatBlock });
52
- var defineTransaction = defineFormatter({ format: _chunk35OJIFIWjs.formatTransaction });
51
+ var defineBlock = defineFormatter({ format: _chunkAGF7GU6Gjs.formatBlock });
52
+ var defineTransaction = defineFormatter({ format: _chunkAGF7GU6Gjs.formatTransaction });
53
53
  var defineTransactionRequest = defineFormatter({
54
- format: _chunk35OJIFIWjs.formatTransactionRequest
54
+ format: _chunkAGF7GU6Gjs.formatTransactionRequest
55
55
  });
56
56
  var defineTransactionReceipt = defineFormatter({
57
- format: _chunk35OJIFIWjs.formatTransactionReceipt
57
+ format: _chunkAGF7GU6Gjs.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-DY4MSK2M.mjs";
6
+ } from "./chunk-4XV4JRFM.mjs";
7
7
 
8
8
  // src/chains.ts
9
9
  import {
@@ -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.11",
12
+ version: "0.0.1-alpha.13",
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",
@@ -26,7 +26,6 @@ var package_default = {
26
26
  playground: "pnpm --filter playground-dev dev",
27
27
  "playground:benchmark": "pnpm --filter playground-benchmark dev",
28
28
  postinstall: "pnpm dev",
29
- postpublish: "pnpm ts-node scripts/restore-package-json.ts",
30
29
  preinstall: "npx only-allow pnpm",
31
30
  prepublishOnly: "pnpm ts-node scripts/generate-package-json.ts",
32
31
  prepare: "npx simple-git-hooks",
@@ -2092,6 +2091,20 @@ function formatBlock(block) {
2092
2091
  };
2093
2092
  }
2094
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 (value?.hasOwnProperty(key)) {
2101
+ ;
2102
+ data[key] = value[key];
2103
+ }
2104
+ return data;
2105
+ }, {});
2106
+ }
2107
+
2095
2108
  // src/utils/formatters/feeHistory.ts
2096
2109
  function formatFeeHistory(feeHistory) {
2097
2110
  return {
@@ -2591,6 +2604,7 @@ export {
2591
2604
  transactionType,
2592
2605
  formatTransaction,
2593
2606
  formatBlock,
2607
+ extract,
2594
2608
  formatFeeHistory,
2595
2609
  format3 as format,
2596
2610
  formatLog,
@@ -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.11",
12
+ version: "0.0.1-alpha.13",
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",
@@ -26,7 +26,6 @@ var package_default = {
26
26
  playground: "pnpm --filter playground-dev dev",
27
27
  "playground:benchmark": "pnpm --filter playground-benchmark dev",
28
28
  postinstall: "pnpm dev",
29
- postpublish: "pnpm ts-node scripts/restore-package-json.ts",
30
29
  preinstall: "npx only-allow pnpm",
31
30
  prepublishOnly: "pnpm ts-node scripts/generate-package-json.ts",
32
31
  prepare: "npx simple-git-hooks",
@@ -2092,13 +2091,27 @@ function formatBlock(block) {
2092
2091
  };
2093
2092
  }
2094
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
+
2095
2108
  // src/utils/formatters/feeHistory.ts
2096
2109
  function formatFeeHistory(feeHistory) {
2097
2110
  return {
2098
2111
  baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),
2099
2112
  gasUsedRatio: feeHistory.gasUsedRatio,
2100
2113
  oldestBlock: BigInt(feeHistory.oldestBlock),
2101
- 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(
2102
2115
  (reward) => reward.map((value) => BigInt(value))
2103
2116
  )])
2104
2117
  };
@@ -2249,7 +2262,7 @@ function withTimeout(fn, {
2249
2262
  }
2250
2263
  }, timeout);
2251
2264
  }
2252
- resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _39 => _39.signal]) }));
2265
+ resolve(await fn({ signal: _optionalChain([controller, 'optionalAccess', _41 => _41.signal]) }));
2253
2266
  } catch (err) {
2254
2267
  if (err.name === "AbortError")
2255
2268
  reject(errorInstance);
@@ -2290,8 +2303,8 @@ async function http(url, {
2290
2303
  ),
2291
2304
  {
2292
2305
  delay: ({ count, data: data2 }) => {
2293
- const retryAfter = _optionalChain([data2, 'optionalAccess', _40 => _40.headers, 'access', _41 => _41.get, 'call', _42 => _42("Retry-After")]);
2294
- 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/)]))
2295
2308
  return parseInt(retryAfter) * 1e3;
2296
2309
  return ~~((Math.random() + 0.5) * (1 << count)) * retryDelay;
2297
2310
  },
@@ -2306,7 +2319,7 @@ async function http(url, {
2306
2319
  }
2307
2320
  );
2308
2321
  let data;
2309
- 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")])) {
2310
2323
  data = await response.json();
2311
2324
  } else {
2312
2325
  data = await response.text();
@@ -2384,15 +2397,15 @@ function webSocket(socket, {
2384
2397
  if (typeof message.id === "number" && id_ !== message.id)
2385
2398
  return;
2386
2399
  if (message.error) {
2387
- _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 }))]);
2388
2401
  } else {
2389
- _optionalChain([onData, 'optionalCall', _51 => _51(message)]);
2402
+ _optionalChain([onData, 'optionalCall', _53 => _53(message)]);
2390
2403
  }
2391
2404
  if (body.method === "eth_subscribe" && typeof message.result === "string") {
2392
2405
  socket.subscriptions.set(message.result, callback);
2393
2406
  }
2394
2407
  if (body.method === "eth_unsubscribe") {
2395
- 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]]));
2396
2409
  }
2397
2410
  };
2398
2411
  socket.requests.set(id_, callback);
@@ -2616,4 +2629,5 @@ function parseGwei(ether, unit = "wei") {
2616
2629
 
2617
2630
 
2618
2631
 
2619
- 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;
@@ -3,7 +3,7 @@ import {
3
3
  buildRequest,
4
4
  getSocket,
5
5
  rpc
6
- } from "./chunk-DY4MSK2M.mjs";
6
+ } from "./chunk-4XV4JRFM.mjs";
7
7
 
8
8
  // src/clients/transports/createTransport.ts
9
9
  function createTransport(config, value) {
@@ -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-DY4MSK2M.mjs";
28
+ } from "./chunk-4XV4JRFM.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,
@@ -892,139 +1037,21 @@ async function stopImpersonatingAccount(client, { address }) {
892
1037
  });
893
1038
  }
894
1039
 
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
1040
  export {
1024
1041
  call,
1025
1042
  callContract,
1026
1043
  createPendingTransactionFilter,
1027
1044
  createBlockFilter,
1045
+ addChain,
1046
+ getAccounts,
1047
+ getPermissions,
1048
+ requestAccounts,
1049
+ requestPermissions,
1050
+ sendTransaction,
1051
+ signMessage,
1052
+ switchChain,
1053
+ watchAsset,
1054
+ deployContract,
1028
1055
  estimateGas,
1029
1056
  getBalance,
1030
1057
  getBlock,
@@ -1071,14 +1098,5 @@ export {
1071
1098
  setNonce,
1072
1099
  setStorageAt,
1073
1100
  snapshot,
1074
- stopImpersonatingAccount,
1075
- addChain,
1076
- getAccounts,
1077
- getPermissions,
1078
- requestAccounts,
1079
- requestPermissions,
1080
- sendTransaction,
1081
- signMessage,
1082
- switchChain,
1083
- watchAsset
1101
+ stopImpersonatingAccount
1084
1102
  };