viem 0.0.0-main.20231115T222931 → 0.0.0-main.20231119T230454

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 (56) hide show
  1. package/_cjs/chains/definitions/aurora.js +6 -0
  2. package/_cjs/chains/definitions/aurora.js.map +1 -1
  3. package/_cjs/errors/node.js +11 -11
  4. package/_cjs/errors/node.js.map +1 -1
  5. package/_cjs/errors/rpc.js +18 -18
  6. package/_cjs/errors/rpc.js.map +1 -1
  7. package/_cjs/errors/version.js +1 -1
  8. package/_cjs/utils/unit/formatEther.js.map +1 -1
  9. package/_cjs/utils/unit/formatGwei.js.map +1 -1
  10. package/_cjs/utils/unit/formatUnits.js.map +1 -1
  11. package/_cjs/utils/unit/parseEther.js.map +1 -1
  12. package/_cjs/utils/unit/parseGwei.js.map +1 -1
  13. package/_cjs/utils/unit/parseUnits.js.map +1 -1
  14. package/_esm/chains/definitions/aurora.js +6 -0
  15. package/_esm/chains/definitions/aurora.js.map +1 -1
  16. package/_esm/errors/node.js +22 -11
  17. package/_esm/errors/node.js.map +1 -1
  18. package/_esm/errors/rpc.js +36 -18
  19. package/_esm/errors/rpc.js.map +1 -1
  20. package/_esm/errors/version.js +1 -1
  21. package/_esm/utils/unit/formatEther.js +11 -0
  22. package/_esm/utils/unit/formatEther.js.map +1 -1
  23. package/_esm/utils/unit/formatGwei.js +11 -0
  24. package/_esm/utils/unit/formatGwei.js.map +1 -1
  25. package/_esm/utils/unit/formatUnits.js +11 -0
  26. package/_esm/utils/unit/formatUnits.js.map +1 -1
  27. package/_esm/utils/unit/parseEther.js +11 -0
  28. package/_esm/utils/unit/parseEther.js.map +1 -1
  29. package/_esm/utils/unit/parseGwei.js +11 -0
  30. package/_esm/utils/unit/parseGwei.js.map +1 -1
  31. package/_esm/utils/unit/parseUnits.js +11 -0
  32. package/_esm/utils/unit/parseUnits.js.map +1 -1
  33. package/_types/chains/definitions/aurora.d.ts +6 -0
  34. package/_types/chains/definitions/aurora.d.ts.map +1 -1
  35. package/_types/errors/version.d.ts +1 -1
  36. package/_types/utils/unit/formatEther.d.ts +11 -0
  37. package/_types/utils/unit/formatEther.d.ts.map +1 -1
  38. package/_types/utils/unit/formatGwei.d.ts +11 -0
  39. package/_types/utils/unit/formatGwei.d.ts.map +1 -1
  40. package/_types/utils/unit/formatUnits.d.ts +11 -0
  41. package/_types/utils/unit/formatUnits.d.ts.map +1 -1
  42. package/_types/utils/unit/parseEther.d.ts +11 -0
  43. package/_types/utils/unit/parseEther.d.ts.map +1 -1
  44. package/_types/utils/unit/parseGwei.d.ts +11 -0
  45. package/_types/utils/unit/parseGwei.d.ts.map +1 -1
  46. package/_types/utils/unit/parseUnits.d.ts +11 -0
  47. package/_types/utils/unit/parseUnits.d.ts.map +1 -1
  48. package/chains/definitions/aurora.ts +6 -0
  49. package/errors/version.ts +1 -1
  50. package/package.json +1 -1
  51. package/utils/unit/formatEther.ts +11 -0
  52. package/utils/unit/formatGwei.ts +11 -0
  53. package/utils/unit/formatUnits.ts +11 -0
  54. package/utils/unit/parseEther.ts +11 -0
  55. package/utils/unit/parseGwei.ts +11 -0
  56. package/utils/unit/parseUnits.ts +11 -0
@@ -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"}
@@ -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
  })
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '0.0.0-main.20231115T222931'
1
+ export const version = '0.0.0-main.20231119T230454'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "0.0.0-main.20231115T222931",
4
+ "version": "0.0.0-main.20231119T230454",
5
5
  "type": "module",
6
6
  "main": "./_cjs/index.js",
7
7
  "module": "./_esm/index.js",
@@ -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