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.
@@ -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/clients/transports/createTransport.ts
9
9
  function createTransport(config, value) {
@@ -60,13 +60,13 @@ function http(url, { key = "http", name = "HTTP JSON-RPC" } = {}) {
60
60
  return ({ chain }) => {
61
61
  const url_ = url || _optionalChain([chain, 'optionalAccess', _ => _.rpcUrls, 'access', _2 => _2.default, 'access', _3 => _3.http, 'access', _4 => _4[0]]);
62
62
  if (!url_)
63
- throw new (0, _chunkA3PVAH22js.UrlRequiredError)();
63
+ throw new (0, _chunk6Z62LPKBjs.UrlRequiredError)();
64
64
  return createTransport(
65
65
  {
66
66
  key,
67
67
  name,
68
68
  async request({ method, params }) {
69
- const { result } = await _chunkA3PVAH22js.rpc.http(url_, {
69
+ const { result } = await _chunk6Z62LPKBjs.rpc.http(url_, {
70
70
  body: {
71
71
  method,
72
72
  params
@@ -91,14 +91,14 @@ function webSocket(url, {
91
91
  return ({ chain }) => {
92
92
  const url_ = url || _optionalChain([chain, 'optionalAccess', _5 => _5.rpcUrls, 'access', _6 => _6.default, 'access', _7 => _7.webSocket, 'optionalAccess', _8 => _8[0]]);
93
93
  if (!url_)
94
- throw new (0, _chunkA3PVAH22js.UrlRequiredError)();
94
+ throw new (0, _chunk6Z62LPKBjs.UrlRequiredError)();
95
95
  return createTransport(
96
96
  {
97
97
  key,
98
98
  name,
99
99
  async request({ method, params }) {
100
- const socket = await _chunkA3PVAH22js.getSocket.call(void 0, url_);
101
- const { result } = await _chunkA3PVAH22js.rpc.webSocketAsync(socket, {
100
+ const socket = await _chunk6Z62LPKBjs.getSocket.call(void 0, url_);
101
+ const { result } = await _chunk6Z62LPKBjs.rpc.webSocketAsync(socket, {
102
102
  body: { method, params }
103
103
  });
104
104
  return result;
@@ -107,12 +107,12 @@ function webSocket(url, {
107
107
  },
108
108
  {
109
109
  getSocket() {
110
- return _chunkA3PVAH22js.getSocket.call(void 0, url_);
110
+ return _chunk6Z62LPKBjs.getSocket.call(void 0, url_);
111
111
  },
112
112
  async subscribe({ params, onData, onError }) {
113
- const socket = await _chunkA3PVAH22js.getSocket.call(void 0, url_);
113
+ const socket = await _chunk6Z62LPKBjs.getSocket.call(void 0, url_);
114
114
  const { result: subscriptionId } = await new Promise(
115
- (resolve, reject) => _chunkA3PVAH22js.rpc.webSocket(socket, {
115
+ (resolve, reject) => _chunk6Z62LPKBjs.rpc.webSocket(socket, {
116
116
  body: {
117
117
  method: "eth_subscribe",
118
118
  params
@@ -134,7 +134,7 @@ function webSocket(url, {
134
134
  subscriptionId,
135
135
  async unsubscribe() {
136
136
  return new Promise(
137
- (resolve, reject) => _chunkA3PVAH22js.rpc.webSocket(socket, {
137
+ (resolve, reject) => _chunk6Z62LPKBjs.rpc.webSocket(socket, {
138
138
  body: {
139
139
  method: "eth_unsubscribe",
140
140
  params: [subscriptionId]
@@ -181,7 +181,7 @@ function createClient({
181
181
  key,
182
182
  name,
183
183
  pollingInterval,
184
- request: _chunkA3PVAH22js.buildRequest.call(void 0, config.request),
184
+ request: _chunk6Z62LPKBjs.buildRequest.call(void 0, config.request),
185
185
  transport: { ...config, ...value },
186
186
  type,
187
187
  uid: uid()
@@ -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,6 +2091,20 @@ 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 (value?.hasOwnProperty(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 {
@@ -2590,6 +2604,7 @@ export {
2590
2604
  transactionType,
2591
2605
  formatTransaction,
2592
2606
  formatBlock,
2607
+ extract,
2593
2608
  formatFeeHistory,
2594
2609
  format3 as format,
2595
2610
  formatLog,