viem 1.19.3 → 1.19.5

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 (84) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/_cjs/chains/celo/serializers.js +1 -1
  3. package/_cjs/chains/celo/serializers.js.map +1 -1
  4. package/_cjs/chains/celo/utils.js +6 -4
  5. package/_cjs/chains/celo/utils.js.map +1 -1
  6. package/_cjs/chains/definitions/aurora.js +6 -0
  7. package/_cjs/chains/definitions/aurora.js.map +1 -1
  8. package/_cjs/chains/definitions/bscTestnet.js +2 -2
  9. package/_cjs/chains/definitions/bscTestnet.js.map +1 -1
  10. package/_cjs/chains/definitions/shibarium.js +35 -0
  11. package/_cjs/chains/definitions/shibarium.js.map +1 -0
  12. package/_cjs/chains/index.js +4 -2
  13. package/_cjs/chains/index.js.map +1 -1
  14. package/_cjs/errors/node.js +11 -11
  15. package/_cjs/errors/node.js.map +1 -1
  16. package/_cjs/errors/rpc.js +18 -18
  17. package/_cjs/errors/rpc.js.map +1 -1
  18. package/_cjs/utils/unit/formatEther.js.map +1 -1
  19. package/_cjs/utils/unit/formatGwei.js.map +1 -1
  20. package/_cjs/utils/unit/formatUnits.js.map +1 -1
  21. package/_cjs/utils/unit/parseEther.js.map +1 -1
  22. package/_cjs/utils/unit/parseGwei.js.map +1 -1
  23. package/_cjs/utils/unit/parseUnits.js.map +1 -1
  24. package/_esm/chains/celo/serializers.js +1 -1
  25. package/_esm/chains/celo/serializers.js.map +1 -1
  26. package/_esm/chains/celo/utils.js +16 -5
  27. package/_esm/chains/celo/utils.js.map +1 -1
  28. package/_esm/chains/definitions/aurora.js +6 -0
  29. package/_esm/chains/definitions/aurora.js.map +1 -1
  30. package/_esm/chains/definitions/bscTestnet.js +2 -2
  31. package/_esm/chains/definitions/bscTestnet.js.map +1 -1
  32. package/_esm/chains/definitions/shibarium.js +32 -0
  33. package/_esm/chains/definitions/shibarium.js.map +1 -0
  34. package/_esm/chains/index.js +1 -0
  35. package/_esm/chains/index.js.map +1 -1
  36. package/_esm/errors/node.js +22 -11
  37. package/_esm/errors/node.js.map +1 -1
  38. package/_esm/errors/rpc.js +36 -18
  39. package/_esm/errors/rpc.js.map +1 -1
  40. package/_esm/utils/unit/formatEther.js +11 -0
  41. package/_esm/utils/unit/formatEther.js.map +1 -1
  42. package/_esm/utils/unit/formatGwei.js +11 -0
  43. package/_esm/utils/unit/formatGwei.js.map +1 -1
  44. package/_esm/utils/unit/formatUnits.js +11 -0
  45. package/_esm/utils/unit/formatUnits.js.map +1 -1
  46. package/_esm/utils/unit/parseEther.js +11 -0
  47. package/_esm/utils/unit/parseEther.js.map +1 -1
  48. package/_esm/utils/unit/parseGwei.js +11 -0
  49. package/_esm/utils/unit/parseGwei.js.map +1 -1
  50. package/_esm/utils/unit/parseUnits.js +11 -0
  51. package/_esm/utils/unit/parseUnits.js.map +1 -1
  52. package/_types/chains/celo/utils.d.ts.map +1 -1
  53. package/_types/chains/definitions/aurora.d.ts +6 -0
  54. package/_types/chains/definitions/aurora.d.ts.map +1 -1
  55. package/_types/chains/definitions/bscTestnet.d.ts +2 -2
  56. package/_types/chains/definitions/shibarium.d.ts +35 -0
  57. package/_types/chains/definitions/shibarium.d.ts.map +1 -0
  58. package/_types/chains/index.d.ts +1 -0
  59. package/_types/chains/index.d.ts.map +1 -1
  60. package/_types/utils/unit/formatEther.d.ts +11 -0
  61. package/_types/utils/unit/formatEther.d.ts.map +1 -1
  62. package/_types/utils/unit/formatGwei.d.ts +11 -0
  63. package/_types/utils/unit/formatGwei.d.ts.map +1 -1
  64. package/_types/utils/unit/formatUnits.d.ts +11 -0
  65. package/_types/utils/unit/formatUnits.d.ts.map +1 -1
  66. package/_types/utils/unit/parseEther.d.ts +11 -0
  67. package/_types/utils/unit/parseEther.d.ts.map +1 -1
  68. package/_types/utils/unit/parseGwei.d.ts +11 -0
  69. package/_types/utils/unit/parseGwei.d.ts.map +1 -1
  70. package/_types/utils/unit/parseUnits.d.ts +11 -0
  71. package/_types/utils/unit/parseUnits.d.ts.map +1 -1
  72. package/chains/celo/serializers.ts +1 -1
  73. package/chains/celo/utils.ts +16 -3
  74. package/chains/definitions/aurora.ts +6 -0
  75. package/chains/definitions/bscTestnet.ts +2 -2
  76. package/chains/definitions/shibarium.ts +32 -0
  77. package/chains/index.ts +1 -0
  78. package/package.json +1 -1
  79. package/utils/unit/formatEther.ts +11 -0
  80. package/utils/unit/formatGwei.ts +11 -0
  81. package/utils/unit/formatUnits.ts +11 -0
  82. package/utils/unit/parseEther.ts +11 -0
  83. package/utils/unit/parseGwei.ts +11 -0
  84. package/utils/unit/parseUnits.ts +11 -0
@@ -1,4 +1,15 @@
1
1
  import { type FormatUnitsErrorType } from './formatUnits.js';
2
2
  export type FormatGweiErrorType = FormatUnitsErrorType;
3
+ /**
4
+ * Converts numerical wei to a string representation of gwei.
5
+ *
6
+ * - Docs: https://viem.sh/docs/utilities/formatGwei.html
7
+ *
8
+ * @example
9
+ * import { formatGwei } from 'viem'
10
+ *
11
+ * formatGwei(1000000000n)
12
+ * // '1'
13
+ */
3
14
  export declare function formatGwei(wei: bigint, unit?: 'wei'): string;
4
15
  //# sourceMappingURL=formatGwei.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatGwei.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAe,MAAM,kBAAkB,CAAA;AAEzE,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEtD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE1D"}
1
+ {"version":3,"file":"formatGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatGwei.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,oBAAoB,EAAe,MAAM,kBAAkB,CAAA;AAEzE,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAA;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE1D"}
@@ -1,4 +1,15 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
2
  export type FormatUnitsErrorType = ErrorType;
3
+ /**
4
+ * Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number..
5
+ *
6
+ * - Docs: https://viem.sh/docs/utilities/formatUnits.html
7
+ *
8
+ * @example
9
+ * import { formatUnits } from 'viem'
10
+ *
11
+ * formatUnits(420000000000n, 9)
12
+ * // '420'
13
+ */
3
14
  export declare function formatUnits(value: bigint, decimals: number): string;
4
15
  //# sourceMappingURL=formatUnits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAA;AAE5C,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAgB1D"}
1
+ {"version":3,"file":"formatUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/formatUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,MAAM,oBAAoB,GAAG,SAAS,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAgB1D"}
@@ -1,5 +1,16 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
2
  import { type ParseUnitsErrorType } from './parseUnits.js';
3
3
  export type ParseEtherErrorType = ParseUnitsErrorType | ErrorType;
4
+ /**
5
+ * Converts a string representation of ether to numerical wei.
6
+ *
7
+ * - Docs: https://viem.sh/docs/utilities/parseEther.html
8
+ *
9
+ * @example
10
+ * import { parseEther } from 'viem'
11
+ *
12
+ * parseEther('420')
13
+ * // 420000000000000000000n
14
+ */
4
15
  export declare function parseEther(ether: string, unit?: 'wei' | 'gwei'): bigint;
5
16
  //# sourceMappingURL=parseEther.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseEther.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseEther.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAA;AAEtE,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEjE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,MAAc,UAErE"}
1
+ {"version":3,"file":"parseEther.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseEther.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAA;AAEtE,MAAM,MAAM,mBAAmB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEjE;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAK,GAAG,MAAc,UAErE"}
@@ -1,5 +1,16 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
2
  import { type ParseUnitsErrorType } from './parseUnits.js';
3
3
  export type ParseGweiErrorType = ParseUnitsErrorType | ErrorType;
4
+ /**
5
+ * Converts a string representation of gwei to numerical wei.
6
+ *
7
+ * - Docs: https://viem.sh/docs/utilities/parseGwei.html
8
+ *
9
+ * @example
10
+ * import { parseGwei } from 'viem'
11
+ *
12
+ * parseGwei('420')
13
+ * // 420000000000n
14
+ */
4
15
  export declare function parseGwei(ether: string, unit?: 'wei'): bigint;
5
16
  //# sourceMappingURL=parseGwei.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseGwei.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAA;AAEtE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEhE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE3D"}
1
+ {"version":3,"file":"parseGwei.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseGwei.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,iBAAiB,CAAA;AAEtE,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,SAAS,CAAA;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,KAAa,UAE3D"}
@@ -1,4 +1,15 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
2
  export type ParseUnitsErrorType = ErrorType;
3
+ /**
4
+ * Multiplies a string representation of a number by a given exponent of base 10 (10exponent).
5
+ *
6
+ * - Docs: https://viem.sh/docs/utilities/parseUnits.html
7
+ *
8
+ * @example
9
+ * import { parseUnits } from 'viem'
10
+ *
11
+ * parseUnits('420', 9)
12
+ * // 420000000000n
13
+ */
3
14
  export declare function parseUnits(value: string, decimals: number): bigint;
4
15
  //# sourceMappingURL=parseUnits.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE3C,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAqCzD"}
1
+ {"version":3,"file":"parseUnits.d.ts","sourceRoot":"","sources":["../../../utils/unit/parseUnits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAqCzD"}
@@ -231,7 +231,7 @@ export function assertTransactionCIP64(
231
231
  )
232
232
  throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas })
233
233
 
234
- if (isPresent(feeCurrency) && !feeCurrency?.startsWith('0x')) {
234
+ if (isPresent(feeCurrency) && !isAddress(feeCurrency)) {
235
235
  throw new BaseError(
236
236
  '`feeCurrency` MUST be a token address for CIP-64 transactions.',
237
237
  )
@@ -43,7 +43,9 @@ export function isCIP42(
43
43
  transaction: CeloTransactionSerializable | CeloTransactionRequest,
44
44
  ): transaction is TransactionSerializableCIP42 {
45
45
  // Enable end-user to force the tx to be considered as a cip42
46
- if (transaction.type) return transaction.type === 'cip42'
46
+ if (transaction.type === 'cip42') {
47
+ return true
48
+ }
47
49
 
48
50
  return (
49
51
  isEIP1559(transaction) &&
@@ -56,8 +58,19 @@ export function isCIP42(
56
58
  export function isCIP64(
57
59
  transaction: CeloTransactionSerializable | CeloTransactionRequest,
58
60
  ): transaction is TransactionSerializableCIP64 {
59
- // Enable end-user to force the tx to be considered as a cip64
60
- if (transaction.type) return transaction.type === 'cip64'
61
+ /*
62
+ * Enable end user to force the tx to be considered as a CIP-64.
63
+ *
64
+ * The preliminary type will be determined as "eip1559" by src/utils/transaction/getTransactionType.ts
65
+ * and so we need the logic below to check for the specific value instead of checking if just any
66
+ * transaction type is provided. If that's anything else than "cip64" then we need to reevaluate the
67
+ * type based on the transaction fields.
68
+ *
69
+ * Modify with caution and according to https://github.com/celo-org/celo-proposals/blob/master/CIPs/cip-0064.md
70
+ */
71
+ if (transaction.type === 'cip64') {
72
+ return true
73
+ }
61
74
 
62
75
  return (
63
76
  isEIP1559(transaction) &&
@@ -18,4 +18,10 @@ export const aurora = /*#__PURE__*/ defineChain({
18
18
  etherscan: { name: 'Aurorascan', url: 'https://aurorascan.dev' },
19
19
  default: { name: 'Aurorascan', url: 'https://aurorascan.dev' },
20
20
  },
21
+ contracts: {
22
+ multicall3: {
23
+ address: '0xca11bde05977b3631167028862be2a173976ca11',
24
+ blockCreated: 62907816,
25
+ },
26
+ },
21
27
  })
@@ -10,8 +10,8 @@ export const bscTestnet = /*#__PURE__*/ defineChain({
10
10
  symbol: 'tBNB',
11
11
  },
12
12
  rpcUrls: {
13
- default: { http: ['https://data-seed-prebsc-1-s1.binance.org:8545'] },
14
- public: { http: ['https://data-seed-prebsc-1-s1.binance.org:8545'] },
13
+ default: { http: ['https://data-seed-prebsc-1-s1.bnbchain.org:8545'] },
14
+ public: { http: ['https://data-seed-prebsc-1-s1.bnbchain.org:8545'] },
15
15
  },
16
16
  blockExplorers: {
17
17
  etherscan: { name: 'BscScan', url: 'https://testnet.bscscan.com' },
@@ -0,0 +1,32 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const shibarium = /*#__PURE__*/ defineChain({
4
+ id: 109,
5
+ name: 'Shibarium',
6
+ network: 'shibarium',
7
+ nativeCurrency: { name: 'Bone', symbol: 'BONE', decimals: 18 },
8
+ rpcUrls: {
9
+ default: {
10
+ http: ['https://rpc.shibrpc.com'],
11
+ },
12
+ public: {
13
+ http: ['https://rpc.shibrpc.com'],
14
+ },
15
+ },
16
+ blockExplorers: {
17
+ etherscan: {
18
+ name: 'Blockscout',
19
+ url: 'https://shibariumscan.io',
20
+ },
21
+ default: {
22
+ name: 'Blockscout',
23
+ url: 'https://shibariumscan.io',
24
+ },
25
+ },
26
+ contracts: {
27
+ multicall3: {
28
+ address: '0x864Bf681ADD6052395188A89101A1B37d3B4C961',
29
+ blockCreated: 265900,
30
+ },
31
+ },
32
+ })
package/chains/index.ts CHANGED
@@ -137,6 +137,7 @@ export { songbird } from './definitions/songbird.js'
137
137
  export { songbirdTestnet } from './definitions/songbirdTestnet.js'
138
138
  export { spicy } from './definitions/spicy.js'
139
139
  export { shardeumSphinx } from './definitions/shardeumSphinx.js'
140
+ export { shibarium } from './definitions/shibarium.js'
140
141
  export { syscoin } from './definitions/syscoin.js'
141
142
  export { syscoinTestnet } from './definitions/syscoinTestnet.js'
142
143
  export { taraxa } from './definitions/taraxa.js'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "1.19.3",
4
+ "version": "1.19.5",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -4,6 +4,17 @@ import { type FormatUnitsErrorType, formatUnits } from './formatUnits.js'
4
4
 
5
5
  export type FormatEtherErrorType = FormatUnitsErrorType
6
6
 
7
+ /**
8
+ * Converts numerical wei to a string representation of ether.
9
+ *
10
+ * - Docs: https://viem.sh/docs/utilities/formatEther.html
11
+ *
12
+ * @example
13
+ * import { formatEther } from 'viem'
14
+ *
15
+ * formatEther(1000000000000000000n)
16
+ * // '1'
17
+ */
7
18
  export function formatEther(wei: bigint, unit: 'wei' | 'gwei' = 'wei') {
8
19
  return formatUnits(wei, etherUnits[unit])
9
20
  }
@@ -4,6 +4,17 @@ import { type FormatUnitsErrorType, formatUnits } from './formatUnits.js'
4
4
 
5
5
  export type FormatGweiErrorType = FormatUnitsErrorType
6
6
 
7
+ /**
8
+ * Converts numerical wei to a string representation of gwei.
9
+ *
10
+ * - Docs: https://viem.sh/docs/utilities/formatGwei.html
11
+ *
12
+ * @example
13
+ * import { formatGwei } from 'viem'
14
+ *
15
+ * formatGwei(1000000000n)
16
+ * // '1'
17
+ */
7
18
  export function formatGwei(wei: bigint, unit: 'wei' = 'wei') {
8
19
  return formatUnits(wei, gweiUnits[unit])
9
20
  }
@@ -2,6 +2,17 @@ import type { ErrorType } from '../../errors/utils.js'
2
2
 
3
3
  export type FormatUnitsErrorType = ErrorType
4
4
 
5
+ /**
6
+ * Divides a number by a given exponent of base 10 (10exponent), and formats it into a string representation of the number..
7
+ *
8
+ * - Docs: https://viem.sh/docs/utilities/formatUnits.html
9
+ *
10
+ * @example
11
+ * import { formatUnits } from 'viem'
12
+ *
13
+ * formatUnits(420000000000n, 9)
14
+ * // '420'
15
+ */
5
16
  export function formatUnits(value: bigint, decimals: number) {
6
17
  let display = value.toString()
7
18
 
@@ -5,6 +5,17 @@ import { type ParseUnitsErrorType, parseUnits } from './parseUnits.js'
5
5
 
6
6
  export type ParseEtherErrorType = ParseUnitsErrorType | ErrorType
7
7
 
8
+ /**
9
+ * Converts a string representation of ether to numerical wei.
10
+ *
11
+ * - Docs: https://viem.sh/docs/utilities/parseEther.html
12
+ *
13
+ * @example
14
+ * import { parseEther } from 'viem'
15
+ *
16
+ * parseEther('420')
17
+ * // 420000000000000000000n
18
+ */
8
19
  export function parseEther(ether: string, unit: 'wei' | 'gwei' = 'wei') {
9
20
  return parseUnits(ether, etherUnits[unit])
10
21
  }
@@ -5,6 +5,17 @@ import { type ParseUnitsErrorType, parseUnits } from './parseUnits.js'
5
5
 
6
6
  export type ParseGweiErrorType = ParseUnitsErrorType | ErrorType
7
7
 
8
+ /**
9
+ * Converts a string representation of gwei to numerical wei.
10
+ *
11
+ * - Docs: https://viem.sh/docs/utilities/parseGwei.html
12
+ *
13
+ * @example
14
+ * import { parseGwei } from 'viem'
15
+ *
16
+ * parseGwei('420')
17
+ * // 420000000000n
18
+ */
8
19
  export function parseGwei(ether: string, unit: 'wei' = 'wei') {
9
20
  return parseUnits(ether, gweiUnits[unit])
10
21
  }
@@ -2,6 +2,17 @@ import type { ErrorType } from '../../errors/utils.js'
2
2
 
3
3
  export type ParseUnitsErrorType = ErrorType
4
4
 
5
+ /**
6
+ * Multiplies a string representation of a number by a given exponent of base 10 (10exponent).
7
+ *
8
+ * - Docs: https://viem.sh/docs/utilities/parseUnits.html
9
+ *
10
+ * @example
11
+ * import { parseUnits } from 'viem'
12
+ *
13
+ * parseUnits('420', 9)
14
+ * // 420000000000n
15
+ */
5
16
  export function parseUnits(value: string, decimals: number) {
6
17
  let [integer, fraction = '0'] = value.split('.')
7
18