@merkl/api 0.18.13 → 0.18.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.
@@ -1,6 +1,12 @@
1
1
  import { isSupportedChain } from "@sdk";
2
2
  import { utils } from "ethers";
3
3
  import { InvalidParameter, UnsupportedNetwork } from "./error";
4
+ /**
5
+ * Use this function to throw an error if the address is invalid
6
+ * and normalize the address to its checksum version
7
+ *
8
+ * @dev Usage: params.address = throwOnInvalidAddress(params.address);
9
+ */
4
10
  export const throwOnInvalidRequiredAddress = (address) => {
5
11
  try {
6
12
  if (!address)
@@ -11,6 +17,14 @@ export const throwOnInvalidRequiredAddress = (address) => {
11
17
  throw new InvalidParameter(`Address ${address} is invalid`);
12
18
  }
13
19
  };
20
+ /**
21
+ * Use this function to throw an error if the address is invalid
22
+ * and normalize the address to its checksum version
23
+ *
24
+ * Address can be null or undefined
25
+ *
26
+ * @dev Usage: params.address = throwOnInvalidAddress(params.address);
27
+ */
14
28
  export const throwOnInvalidAddress = (address) => {
15
29
  try {
16
30
  if (!address)
@@ -21,6 +35,9 @@ export const throwOnInvalidAddress = (address) => {
21
35
  throw new InvalidParameter(`Address ${address} is invalid`);
22
36
  }
23
37
  };
38
+ /**
39
+ * Use this function to throw an error if the chainId is not supported by Merkl
40
+ */
24
41
  export const throwOnUnsupportedChainId = (chainId) => {
25
42
  if (chainId && !isSupportedChain(chainId, "merkl"))
26
43
  throw new UnsupportedNetwork(chainId);