@epoch-protocol/epoch-commons-sdk 0.2.1 → 0.2.2

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.
@@ -7,10 +7,10 @@ function invalid(message) {
7
7
  function isHex(value) {
8
8
  return typeof value === "string" && /^0x(?:[0-9a-fA-F]{2})*$/.test(value);
9
9
  }
10
- function address(value, field) {
10
+ function address(value, field, allowZero = false) {
11
11
  if (typeof value !== "string" ||
12
12
  !/^0x[0-9a-fA-F]{40}$/.test(value) ||
13
- /^0x0{40}$/i.test(value)) {
13
+ (!allowZero && /^0x0{40}$/i.test(value))) {
14
14
  return invalid(`${field} must be a non-zero address`);
15
15
  }
16
16
  return value.toLowerCase();
@@ -46,7 +46,7 @@ function decodeEntry(value) {
46
46
  return invalid("poolKey must be an object");
47
47
  }
48
48
  const key = entry.poolKey;
49
- const currency0 = address(key.currency0, "poolKey.currency0");
49
+ const currency0 = address(key.currency0, "poolKey.currency0", true);
50
50
  const currency1 = address(key.currency1, "poolKey.currency1");
51
51
  if (currency0 >= currency1) {
52
52
  return invalid("poolKey.currency0 must sort before poolKey.currency1");
@@ -56,7 +56,7 @@ function decodeEntry(value) {
56
56
  return invalid("poolKey.fee is outside the v4 fee range");
57
57
  }
58
58
  const tickSpacing = integer(key.tickSpacing, "poolKey.tickSpacing", 1, 32767);
59
- const hooks = address(key.hooks, "poolKey.hooks");
59
+ const hooks = address(key.hooks, "poolKey.hooks", true);
60
60
  const hookData = entry.hookData === undefined ? "0x" : entry.hookData;
61
61
  if (!isHex(hookData))
62
62
  return invalid("hookData must be even-length hex");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-protocol/epoch-commons-sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "SDK for interacting with Epoch Commons Protocol",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",