viem 0.0.1-alpha.30 → 0.0.1-alpha.32

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.
Files changed (48) hide show
  1. package/dist/chains.js +46 -46
  2. package/dist/chains.mjs +1 -1
  3. package/dist/{chunk-ZX4U6QKQ.js → chunk-4TDJALZ6.js} +75 -75
  4. package/dist/{chunk-EAD66IDC.js → chunk-DEF2SWG2.js} +54 -28
  5. package/dist/chunk-DEF2SWG2.js.map +1 -0
  6. package/dist/{chunk-EYRMK2SV.mjs → chunk-HJBIOX2W.mjs} +2 -2
  7. package/dist/{chunk-VOK5ALIT.js → chunk-K3Q7U5IY.js} +15 -15
  8. package/dist/{chunk-NPFW67BV.js → chunk-NZUM6QVJ.js} +22 -22
  9. package/dist/{chunk-25AJVKAT.mjs → chunk-P76FCR36.mjs} +55 -29
  10. package/dist/chunk-P76FCR36.mjs.map +1 -0
  11. package/dist/{chunk-AO7KQBK3.mjs → chunk-QPXAI2W5.mjs} +2 -2
  12. package/dist/{chunk-BHMSFL4W.js → chunk-S3HZ74MN.js} +14 -14
  13. package/dist/{chunk-23UHN6UC.mjs → chunk-ZIH5V7HU.mjs} +3 -3
  14. package/dist/{chunk-IP3NSE7H.mjs → chunk-ZZWYDER3.mjs} +2 -2
  15. package/dist/contract.d.ts +1 -1
  16. package/dist/contract.js +4 -4
  17. package/dist/contract.mjs +3 -3
  18. package/dist/{createPublicClient-99be385b.d.ts → createPublicClient-2187596f.d.ts} +1 -1
  19. package/dist/ens.d.ts +1 -1
  20. package/dist/ens.js +4 -4
  21. package/dist/ens.mjs +3 -3
  22. package/dist/index.d.ts +20 -5
  23. package/dist/index.js +97 -91
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +16 -10
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/{parseGwei-e299cf13.d.ts → parseGwei-308eada9.d.ts} +10 -7
  28. package/dist/public.d.ts +2 -2
  29. package/dist/public.js +3 -3
  30. package/dist/public.mjs +2 -2
  31. package/dist/test.js +3 -3
  32. package/dist/test.mjs +2 -2
  33. package/dist/utils/index.d.ts +4 -4
  34. package/dist/utils/index.js +4 -2
  35. package/dist/utils/index.mjs +7 -5
  36. package/dist/wallet.js +3 -3
  37. package/dist/wallet.mjs +2 -2
  38. package/package.json +1 -1
  39. package/dist/chunk-25AJVKAT.mjs.map +0 -1
  40. package/dist/chunk-EAD66IDC.js.map +0 -1
  41. /package/dist/{chunk-ZX4U6QKQ.js.map → chunk-4TDJALZ6.js.map} +0 -0
  42. /package/dist/{chunk-EYRMK2SV.mjs.map → chunk-HJBIOX2W.mjs.map} +0 -0
  43. /package/dist/{chunk-VOK5ALIT.js.map → chunk-K3Q7U5IY.js.map} +0 -0
  44. /package/dist/{chunk-NPFW67BV.js.map → chunk-NZUM6QVJ.js.map} +0 -0
  45. /package/dist/{chunk-AO7KQBK3.mjs.map → chunk-QPXAI2W5.mjs.map} +0 -0
  46. /package/dist/{chunk-BHMSFL4W.js.map → chunk-S3HZ74MN.js.map} +0 -0
  47. /package/dist/{chunk-23UHN6UC.mjs.map → chunk-ZIH5V7HU.mjs.map} +0 -0
  48. /package/dist/{chunk-IP3NSE7H.mjs.map → chunk-ZZWYDER3.mjs.map} +0 -0
@@ -11,7 +11,7 @@
11
11
 
12
12
 
13
13
 
14
- var _chunkEAD66IDCjs = require('./chunk-EAD66IDC.js');
14
+ var _chunkDEF2SWG2js = require('./chunk-DEF2SWG2.js');
15
15
 
16
16
  // src/actions/wallet/addChain.ts
17
17
  async function addChain(client, { chain }) {
@@ -20,7 +20,7 @@ async function addChain(client, { chain }) {
20
20
  method: "wallet_addEthereumChain",
21
21
  params: [
22
22
  {
23
- chainId: _chunkEAD66IDCjs.numberToHex.call(void 0, id),
23
+ chainId: _chunkDEF2SWG2js.numberToHex.call(void 0, id),
24
24
  chainName: name,
25
25
  nativeCurrency,
26
26
  rpcUrls: rpcUrls.default.http,
@@ -33,7 +33,7 @@ async function addChain(client, { chain }) {
33
33
  // src/actions/wallet/getAccounts.ts
34
34
  async function getAccounts(client) {
35
35
  const addresses = await client.request({ method: "eth_accounts" });
36
- return addresses.map((address) => _chunkEAD66IDCjs.checksumAddress.call(void 0, address));
36
+ return addresses.map((address) => _chunkDEF2SWG2js.checksumAddress.call(void 0, address));
37
37
  }
38
38
 
39
39
  // src/actions/wallet/getPermissions.ts
@@ -45,7 +45,7 @@ async function getPermissions(client) {
45
45
  // src/actions/wallet/requestAccounts.ts
46
46
  async function requestAccounts(client) {
47
47
  const addresses = await client.request({ method: "eth_requestAccounts" });
48
- return addresses.map((address) => _chunkEAD66IDCjs.getAddress.call(void 0, address));
48
+ return addresses.map((address) => _chunkDEF2SWG2js.getAddress.call(void 0, address));
49
49
  }
50
50
 
51
51
  // src/actions/wallet/requestPermissions.ts
@@ -73,9 +73,9 @@ async function sendTransaction(client, args) {
73
73
  ...rest
74
74
  } = args;
75
75
  try {
76
- _chunkEAD66IDCjs.assertRequest.call(void 0, args);
76
+ _chunkDEF2SWG2js.assertRequest.call(void 0, args);
77
77
  const formatter = _optionalChain([chain, 'optionalAccess', _ => _.formatters, 'optionalAccess', _2 => _2.transactionRequest]);
78
- const request_ = _chunkEAD66IDCjs.format.call(void 0,
78
+ const request_ = _chunkDEF2SWG2js.format.call(void 0,
79
79
  {
80
80
  from,
81
81
  accessList,
@@ -88,10 +88,10 @@ async function sendTransaction(client, args) {
88
88
  to,
89
89
  value,
90
90
  // Pick out extra data that might exist on the chain's transaction request type.
91
- ..._chunkEAD66IDCjs.extract.call(void 0, rest, { formatter })
91
+ ..._chunkDEF2SWG2js.extract.call(void 0, rest, { formatter })
92
92
  },
93
93
  {
94
- formatter: formatter || _chunkEAD66IDCjs.formatTransactionRequest
94
+ formatter: formatter || _chunkDEF2SWG2js.formatTransactionRequest
95
95
  }
96
96
  );
97
97
  const hash = await client.request({
@@ -100,7 +100,7 @@ async function sendTransaction(client, args) {
100
100
  });
101
101
  return hash;
102
102
  } catch (err) {
103
- throw _chunkEAD66IDCjs.getTransactionError.call(void 0, err, args);
103
+ throw _chunkDEF2SWG2js.getTransactionError.call(void 0, err, args);
104
104
  }
105
105
  }
106
106
 
@@ -109,7 +109,7 @@ async function signMessage(client, { from, data: data_ }) {
109
109
  let data;
110
110
  if (typeof data_ === "string") {
111
111
  if (!data_.startsWith("0x"))
112
- throw new (0, _chunkEAD66IDCjs.BaseError)(
112
+ throw new (0, _chunkDEF2SWG2js.BaseError)(
113
113
  `data ("${data_}") must be a hex value. Encode it first to a hex with the \`toHex\` util.`,
114
114
  {
115
115
  docsPath: "/TODO"
@@ -117,7 +117,7 @@ async function signMessage(client, { from, data: data_ }) {
117
117
  );
118
118
  data = data_;
119
119
  } else {
120
- data = _chunkEAD66IDCjs.toHex.call(void 0, data_);
120
+ data = _chunkDEF2SWG2js.toHex.call(void 0, data_);
121
121
  }
122
122
  const signed = await client.request({
123
123
  method: "personal_sign",
@@ -132,7 +132,7 @@ async function switchChain(client, { id }) {
132
132
  method: "wallet_switchEthereumChain",
133
133
  params: [
134
134
  {
135
- chainId: _chunkEAD66IDCjs.numberToHex.call(void 0, id)
135
+ chainId: _chunkDEF2SWG2js.numberToHex.call(void 0, id)
136
136
  }
137
137
  ]
138
138
  });
@@ -155,7 +155,7 @@ async function writeContract(client, {
155
155
  functionName,
156
156
  ...request
157
157
  }) {
158
- const data = _chunkEAD66IDCjs.encodeFunctionData.call(void 0, {
158
+ const data = _chunkDEF2SWG2js.encodeFunctionData.call(void 0, {
159
159
  abi,
160
160
  args,
161
161
  functionName
@@ -170,7 +170,7 @@ async function writeContract(client, {
170
170
 
171
171
  // src/actions/wallet/deployContract.ts
172
172
  function deployContract(walletClient, { abi, args, bytecode, ...request }) {
173
- const calldata = _chunkEAD66IDCjs.encodeDeployData.call(void 0, {
173
+ const calldata = _chunkDEF2SWG2js.encodeDeployData.call(void 0, {
174
174
  abi,
175
175
  args,
176
176
  bytecode
@@ -194,4 +194,4 @@ function deployContract(walletClient, { abi, args, bytecode, ...request }) {
194
194
 
195
195
 
196
196
  exports.addChain = addChain; exports.deployContract = deployContract; exports.getAccounts = getAccounts; exports.getPermissions = getPermissions; exports.requestAccounts = requestAccounts; exports.requestPermissions = requestPermissions; exports.sendTransaction = sendTransaction; exports.signMessage = signMessage; exports.switchChain = switchChain; exports.watchAsset = watchAsset; exports.writeContract = writeContract;
197
- //# sourceMappingURL=chunk-VOK5ALIT.js.map
197
+ //# sourceMappingURL=chunk-K3Q7U5IY.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkZX4U6QKQjs = require('./chunk-ZX4U6QKQ.js');
3
+ var _chunk4TDJALZ6js = require('./chunk-4TDJALZ6.js');
4
4
 
5
5
 
6
6
 
@@ -13,27 +13,27 @@ var _chunkZX4U6QKQjs = require('./chunk-ZX4U6QKQ.js');
13
13
 
14
14
 
15
15
 
16
- var _chunkEAD66IDCjs = require('./chunk-EAD66IDC.js');
16
+ var _chunkDEF2SWG2js = require('./chunk-DEF2SWG2.js');
17
17
 
18
18
  // src/utils/ens/labelhash.ts
19
19
  function labelhash(label) {
20
20
  let result = new Uint8Array(32).fill(0);
21
21
  if (!label)
22
- return _chunkEAD66IDCjs.bytesToHex.call(void 0, result);
23
- return _chunkEAD66IDCjs.keccak256.call(void 0, _chunkEAD66IDCjs.stringToBytes.call(void 0, label));
22
+ return _chunkDEF2SWG2js.bytesToHex.call(void 0, result);
23
+ return _chunkDEF2SWG2js.keccak256.call(void 0, _chunkDEF2SWG2js.stringToBytes.call(void 0, label));
24
24
  }
25
25
 
26
26
  // src/utils/ens/namehash.ts
27
27
  function namehash(name) {
28
28
  let result = new Uint8Array(32).fill(0);
29
29
  if (!name)
30
- return _chunkEAD66IDCjs.bytesToHex.call(void 0, result);
30
+ return _chunkDEF2SWG2js.bytesToHex.call(void 0, result);
31
31
  const labels = name.split(".");
32
32
  for (let i = labels.length - 1; i >= 0; i -= 1) {
33
- const hashed = _chunkEAD66IDCjs.keccak256.call(void 0, _chunkEAD66IDCjs.stringToBytes.call(void 0, labels[i]), "bytes");
34
- result = _chunkEAD66IDCjs.keccak256.call(void 0, _chunkEAD66IDCjs.concat.call(void 0, [result, hashed]), "bytes");
33
+ const hashed = _chunkDEF2SWG2js.keccak256.call(void 0, _chunkDEF2SWG2js.stringToBytes.call(void 0, labels[i]), "bytes");
34
+ result = _chunkDEF2SWG2js.keccak256.call(void 0, _chunkDEF2SWG2js.concat.call(void 0, [result, hashed]), "bytes");
35
35
  }
36
- return _chunkEAD66IDCjs.bytesToHex.call(void 0, result);
36
+ return _chunkDEF2SWG2js.bytesToHex.call(void 0, result);
37
37
  }
38
38
 
39
39
  // src/utils/ens/packetToBytes.ts
@@ -41,7 +41,7 @@ function packetToBytes(packet) {
41
41
  function length(value2) {
42
42
  if (value2 === "." || value2 === "..")
43
43
  return 1;
44
- return _chunkEAD66IDCjs.toBytes.call(void 0, value2.replace(/^\.|\.$/gm, "")).length + 2;
44
+ return _chunkDEF2SWG2js.toBytes.call(void 0, value2.replace(/^\.|\.$/gm, "")).length + 2;
45
45
  }
46
46
  const bytes = new Uint8Array(length(packet));
47
47
  const value = packet.replace(/^\.|\.$/gm, "");
@@ -50,7 +50,7 @@ function packetToBytes(packet) {
50
50
  let offset = 0;
51
51
  const list = value.split(".");
52
52
  for (let i = 0; i < list.length; i++) {
53
- const encoded = _chunkEAD66IDCjs.toBytes.call(void 0, list[i]);
53
+ const encoded = _chunkDEF2SWG2js.toBytes.call(void 0, list[i]);
54
54
  bytes[offset] = encoded.length;
55
55
  bytes.set(encoded, offset + 1);
56
56
  offset += encoded.length + 1;
@@ -73,12 +73,12 @@ async function getEnsAddress(client, {
73
73
  );
74
74
  const contract = _optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.contracts, 'optionalAccess', _3 => _3.ensUniversalResolver]);
75
75
  if (!contract)
76
- throw new (0, _chunkEAD66IDCjs.ChainDoesNotSupportContract)({
76
+ throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
77
77
  chain: client.chain,
78
78
  contract: { name: "ensUniversalResolver" }
79
79
  });
80
80
  if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
81
- throw new (0, _chunkEAD66IDCjs.ChainDoesNotSupportContract)({
81
+ throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
82
82
  blockNumber,
83
83
  chain: client.chain,
84
84
  contract: {
@@ -88,7 +88,7 @@ async function getEnsAddress(client, {
88
88
  });
89
89
  universalResolverAddress = contract.address;
90
90
  }
91
- const res = await _chunkZX4U6QKQjs.readContract.call(void 0, client, {
91
+ const res = await _chunk4TDJALZ6js.readContract.call(void 0, client, {
92
92
  address: universalResolverAddress,
93
93
  abi: [
94
94
  {
@@ -107,8 +107,8 @@ async function getEnsAddress(client, {
107
107
  ],
108
108
  functionName: "resolve",
109
109
  args: [
110
- _chunkEAD66IDCjs.toHex.call(void 0, packetToBytes(name)),
111
- _chunkEAD66IDCjs.encodeFunctionData.call(void 0, {
110
+ _chunkDEF2SWG2js.toHex.call(void 0, packetToBytes(name)),
111
+ _chunkDEF2SWG2js.encodeFunctionData.call(void 0, {
112
112
  abi: [
113
113
  {
114
114
  name: "addr",
@@ -125,7 +125,7 @@ async function getEnsAddress(client, {
125
125
  blockNumber,
126
126
  blockTag
127
127
  });
128
- return _chunkEAD66IDCjs.decodeFunctionResult.call(void 0, {
128
+ return _chunkDEF2SWG2js.decodeFunctionResult.call(void 0, {
129
129
  abi: [
130
130
  {
131
131
  name: "addr",
@@ -155,12 +155,12 @@ async function getEnsName(client, {
155
155
  );
156
156
  const contract = _optionalChain([client, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.contracts, 'optionalAccess', _6 => _6.ensUniversalResolver]);
157
157
  if (!contract)
158
- throw new (0, _chunkEAD66IDCjs.ChainDoesNotSupportContract)({
158
+ throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
159
159
  chain: client.chain,
160
160
  contract: { name: "ensUniversalResolver" }
161
161
  });
162
162
  if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
163
- throw new (0, _chunkEAD66IDCjs.ChainDoesNotSupportContract)({
163
+ throw new (0, _chunkDEF2SWG2js.ChainDoesNotSupportContract)({
164
164
  blockNumber,
165
165
  chain: client.chain,
166
166
  contract: {
@@ -172,7 +172,7 @@ async function getEnsName(client, {
172
172
  }
173
173
  const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
174
174
  try {
175
- const res = await _chunkZX4U6QKQjs.readContract.call(void 0, client, {
175
+ const res = await _chunk4TDJALZ6js.readContract.call(void 0, client, {
176
176
  address: universalResolverAddress,
177
177
  abi: [
178
178
  {
@@ -189,13 +189,13 @@ async function getEnsName(client, {
189
189
  }
190
190
  ],
191
191
  functionName: "reverse",
192
- args: [_chunkEAD66IDCjs.toHex.call(void 0, packetToBytes(reverseNode))],
192
+ args: [_chunkDEF2SWG2js.toHex.call(void 0, packetToBytes(reverseNode))],
193
193
  blockNumber,
194
194
  blockTag
195
195
  });
196
196
  return res[0];
197
197
  } catch (error) {
198
- if (error instanceof _chunkEAD66IDCjs.ContractFunctionExecutionError && error.cause.reason === _chunkEAD66IDCjs.panicReasons[50])
198
+ if (error instanceof _chunkDEF2SWG2js.ContractFunctionExecutionError && error.cause.reason === _chunkDEF2SWG2js.panicReasons[50])
199
199
  return null;
200
200
  throw error;
201
201
  }
@@ -207,4 +207,4 @@ async function getEnsName(client, {
207
207
 
208
208
 
209
209
  exports.labelhash = labelhash; exports.namehash = namehash; exports.getEnsAddress = getEnsAddress; exports.getEnsName = getEnsName;
210
- //# sourceMappingURL=chunk-NPFW67BV.js.map
210
+ //# sourceMappingURL=chunk-NZUM6QVJ.js.map
@@ -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.30",
12
+ version: "0.0.1-alpha.32",
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",
@@ -168,7 +168,7 @@ var package_default = {
168
168
  },
169
169
  pnpm: {
170
170
  patchedDependencies: {
171
- "vitepress@1.0.0-alpha.34": "patches/vitepress@1.0.0-alpha.34.patch"
171
+ "vitepress@1.0.0-alpha.47": "patches/vitepress@1.0.0-alpha.47.patch"
172
172
  }
173
173
  }
174
174
  };
@@ -1219,6 +1219,24 @@ var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
1219
1219
  __publicField(this, "code", -32006);
1220
1220
  }
1221
1221
  };
1222
+ var UserRejectedRequestError = class extends RpcRequestError {
1223
+ constructor(err) {
1224
+ super(err, {
1225
+ shortMessage: "User rejected the request."
1226
+ });
1227
+ __publicField(this, "name", "UserRejectedRequestError");
1228
+ __publicField(this, "code", 4001);
1229
+ }
1230
+ };
1231
+ var SwitchChainError = class extends RpcRequestError {
1232
+ constructor(err) {
1233
+ super(err, {
1234
+ shortMessage: "An error occurred when attempting to switch chain."
1235
+ });
1236
+ __publicField(this, "name", "SwitchChainError");
1237
+ __publicField(this, "code", 4902);
1238
+ }
1239
+ };
1222
1240
  var UnknownRpcError = class extends RequestError {
1223
1241
  constructor(err) {
1224
1242
  super(err, {
@@ -1757,11 +1775,11 @@ function hashFunction(def) {
1757
1775
  return hash(`${name}(${params.map(({ type }) => type).join(",")})`);
1758
1776
  }
1759
1777
 
1760
- // src/utils/hash/getEventSignature.ts
1761
- var getEventSignature = (event) => hashFunction(event);
1778
+ // src/utils/hash/getEventSelector.ts
1779
+ var getEventSelector = (event) => hashFunction(event);
1762
1780
 
1763
- // src/utils/hash/getFunctionSignature.ts
1764
- var getFunctionSignature = (fn) => slice(hashFunction(fn), 0, 4);
1781
+ // src/utils/hash/getFunctionSelector.ts
1782
+ var getFunctionSelector = (fn) => slice(hashFunction(fn), 0, 4);
1765
1783
 
1766
1784
  // src/utils/address/isAddress.ts
1767
1785
  var addressRegex = /^0x[a-fA-F0-9]{40}$/;
@@ -2245,7 +2263,7 @@ function decodeErrorResult({
2245
2263
  throw new AbiDecodingZeroDataError();
2246
2264
  const abi_ = [...abi || [], solidityError, solidityPanic];
2247
2265
  const abiItem = abi_.find(
2248
- (x) => x.type === "error" && signature === getFunctionSignature(formatAbiItem(x))
2266
+ (x) => x.type === "error" && signature === getFunctionSelector(formatAbiItem(x))
2249
2267
  );
2250
2268
  if (!abiItem)
2251
2269
  throw new AbiErrorSignatureNotFoundError(signature, {
@@ -2266,7 +2284,7 @@ function decodeEventLog({
2266
2284
  }) {
2267
2285
  const [signature, ...argTopics] = topics;
2268
2286
  const abiItem = abi.find(
2269
- (x) => signature === getEventSignature(formatAbiItem(x))
2287
+ (x) => signature === getEventSelector(formatAbiItem(x))
2270
2288
  );
2271
2289
  if (!(abiItem && "name" in abiItem))
2272
2290
  throw new AbiEventSignatureNotFoundError(signature, {
@@ -2317,7 +2335,7 @@ function decodeTopic({ param, value }) {
2317
2335
  function decodeFunctionData({ abi, data }) {
2318
2336
  const signature = slice(data, 0, 4);
2319
2337
  const description = abi.find(
2320
- (x) => signature === getFunctionSignature(formatAbiItem(x))
2338
+ (x) => signature === getFunctionSelector(formatAbiItem(x))
2321
2339
  );
2322
2340
  if (!description)
2323
2341
  throw new AbiFunctionSignatureNotFoundError(signature, {
@@ -2462,7 +2480,7 @@ function encodeErrorResult({ abi, errorName, args }) {
2462
2480
  if (!description)
2463
2481
  throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
2464
2482
  const definition = formatAbiItem(description);
2465
- const signature = getFunctionSignature(definition);
2483
+ const signature = getFunctionSelector(definition);
2466
2484
  let data = "0x";
2467
2485
  if (args && args.length > 0) {
2468
2486
  if (!("inputs" in description && description.inputs))
@@ -2480,7 +2498,7 @@ function encodeEventTopics({ abi, eventName, args }) {
2480
2498
  docsPath: "/docs/contract/encodeEventTopics"
2481
2499
  });
2482
2500
  const definition = formatAbiItem(abiItem);
2483
- const signature = getEventSignature(definition);
2501
+ const signature = getEventSelector(definition);
2484
2502
  let topics = [];
2485
2503
  if (args && "inputs" in abiItem) {
2486
2504
  const args_ = Array.isArray(args) ? args : abiItem.inputs?.map((x) => args[x.name]) ?? [];
@@ -2515,7 +2533,7 @@ function encodeFunctionData({ abi, args, functionName }) {
2515
2533
  docsPath: "/docs/contract/encodeFunctionData"
2516
2534
  });
2517
2535
  const definition = formatAbiItem(description);
2518
- const signature = getFunctionSignature(definition);
2536
+ const signature = getFunctionSelector(definition);
2519
2537
  const data = "inputs" in description && description.inputs ? encodeAbi({
2520
2538
  params: description.inputs,
2521
2539
  values: args ?? []
@@ -2710,6 +2728,10 @@ function buildRequest(request, {
2710
2728
  throw new LimitExceededRpcError(err);
2711
2729
  if (err.code === -32006)
2712
2730
  throw new JsonRpcVersionUnsupportedError(err);
2731
+ if (err.code === 4001)
2732
+ throw new UserRejectedRequestError(err);
2733
+ if (err.code === 4902)
2734
+ throw new SwitchChainError(err);
2713
2735
  if (err_ instanceof BaseError)
2714
2736
  throw err_;
2715
2737
  throw new UnknownRpcError(err);
@@ -3022,29 +3044,31 @@ function getTransactionError(err, {
3022
3044
  import WebSocket from "isomorphic-ws";
3023
3045
 
3024
3046
  // src/utils/stringify.ts
3025
- function stringify(value) {
3026
- return JSON.stringify(
3027
- value,
3028
- (_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
3029
- );
3030
- }
3047
+ var stringify = (value, replacer, space) => JSON.stringify(
3048
+ value,
3049
+ (key, value_) => {
3050
+ const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
3051
+ return typeof replacer === "function" ? replacer(key, value2) : value2;
3052
+ },
3053
+ space
3054
+ );
3031
3055
 
3032
3056
  // src/utils/rpc.ts
3033
3057
  var id = 0;
3034
- async function http(url, {
3035
- body,
3036
- timeout = 1e4
3037
- }) {
3058
+ async function http(url, { body, fetchOptions = {}, timeout = 1e4 }) {
3059
+ const { headers, method, signal: signal_ } = fetchOptions;
3038
3060
  try {
3039
3061
  const response = await withTimeout(
3040
3062
  async ({ signal }) => {
3041
3063
  const response2 = await fetch(url, {
3064
+ ...fetchOptions,
3065
+ body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
3042
3066
  headers: {
3067
+ ...headers,
3043
3068
  "Content-Type": "application/json"
3044
3069
  },
3045
- method: "POST",
3046
- body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
3047
- signal: timeout > 0 ? signal : void 0
3070
+ method: method || "POST",
3071
+ signal: signal_ || (timeout > 0 ? signal : void 0)
3048
3072
  });
3049
3073
  return response2;
3050
3074
  },
@@ -3206,11 +3230,11 @@ function formatUnit(value, decimals) {
3206
3230
  const negative = display.startsWith("-");
3207
3231
  if (negative)
3208
3232
  display = display.slice(1);
3233
+ display = display.padStart(decimals, "0");
3209
3234
  let [integer, fraction] = [
3210
3235
  display.slice(0, display.length - decimals),
3211
3236
  display.slice(display.length - decimals)
3212
3237
  ];
3213
- fraction = fraction.padStart(decimals, "0");
3214
3238
  fraction = fraction.replace(/(0+)$/, "");
3215
3239
  return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
3216
3240
  }
@@ -3326,6 +3350,8 @@ export {
3326
3350
  MethodNotSupportedRpcError,
3327
3351
  LimitExceededRpcError,
3328
3352
  JsonRpcVersionUnsupportedError,
3353
+ UserRejectedRequestError,
3354
+ SwitchChainError,
3329
3355
  UnknownRpcError,
3330
3356
  HttpRequestError,
3331
3357
  WebSocketRequestError,
@@ -3370,8 +3396,8 @@ export {
3370
3396
  extractFunctionParams,
3371
3397
  extractFunctionType,
3372
3398
  keccak256,
3373
- getEventSignature,
3374
- getFunctionSignature,
3399
+ getEventSelector,
3400
+ getFunctionSelector,
3375
3401
  isAddress,
3376
3402
  checksumAddress,
3377
3403
  getAddress,
@@ -3433,4 +3459,4 @@ export {
3433
3459
  parseEther,
3434
3460
  parseGwei
3435
3461
  };
3436
- //# sourceMappingURL=chunk-25AJVKAT.mjs.map
3462
+ //# sourceMappingURL=chunk-P76FCR36.mjs.map