@boostxyz/sdk 8.0.0-canary.0 → 8.0.0-canary.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.
Files changed (106) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +1 -1
  3. package/dist/Actions/EventAction.cjs +1 -1
  4. package/dist/Actions/EventAction.cjs.map +1 -1
  5. package/dist/Actions/EventAction.d.ts +19 -0
  6. package/dist/Actions/EventAction.d.ts.map +1 -1
  7. package/dist/Actions/EventAction.js +209 -204
  8. package/dist/Actions/EventAction.js.map +1 -1
  9. package/dist/{AllowList-CWqAYlwr.js → AllowList-DQf-8HQC.js} +30 -30
  10. package/dist/{AllowList-CWqAYlwr.js.map → AllowList-DQf-8HQC.js.map} +1 -1
  11. package/dist/{AllowList-Lpqz7tn9.cjs → AllowList-DaX239DR.cjs} +2 -2
  12. package/dist/{AllowList-Lpqz7tn9.cjs.map → AllowList-DaX239DR.cjs.map} +1 -1
  13. package/dist/AllowLists/AllowList.cjs +1 -1
  14. package/dist/AllowLists/AllowList.js +3 -3
  15. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  16. package/dist/AllowLists/SimpleAllowList.js +4 -4
  17. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  18. package/dist/AllowLists/SimpleDenyList.js +3 -3
  19. package/dist/Auth/PassthroughAuth.cjs +1 -1
  20. package/dist/Auth/PassthroughAuth.js +2 -2
  21. package/dist/BoostCore.cjs +2 -2
  22. package/dist/BoostCore.cjs.map +1 -1
  23. package/dist/BoostCore.d.ts +35 -0
  24. package/dist/BoostCore.d.ts.map +1 -1
  25. package/dist/BoostCore.js +75 -75
  26. package/dist/BoostRegistry.cjs +1 -1
  27. package/dist/BoostRegistry.js +13 -13
  28. package/dist/{Budget-BPPXnBAK.js → Budget-LnAQ_Slw.js} +40 -40
  29. package/dist/{Budget-BPPXnBAK.js.map → Budget-LnAQ_Slw.js.map} +1 -1
  30. package/dist/{Budget-rZm-AY09.cjs → Budget-WIB8IJoM.cjs} +2 -2
  31. package/dist/{Budget-rZm-AY09.cjs.map → Budget-WIB8IJoM.cjs.map} +1 -1
  32. package/dist/Budgets/Budget.cjs +1 -1
  33. package/dist/Budgets/Budget.js +2 -2
  34. package/dist/Budgets/ManagedBudget.cjs +1 -1
  35. package/dist/Budgets/ManagedBudget.js +25 -25
  36. package/dist/Deployable/DeployableTarget.cjs +1 -1
  37. package/dist/Deployable/DeployableTarget.js +3 -3
  38. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  39. package/dist/Deployable/DeployableTargetWithRBAC.js +21 -21
  40. package/dist/{Incentive-D1sYPD0W.js → Incentive-D_IBex5V.js} +22 -22
  41. package/dist/{Incentive-D1sYPD0W.js.map → Incentive-D_IBex5V.js.map} +1 -1
  42. package/dist/{Incentive-Bse5BKbF.cjs → Incentive-gT7z-4v3.cjs} +2 -2
  43. package/dist/{Incentive-Bse5BKbF.cjs.map → Incentive-gT7z-4v3.cjs.map} +1 -1
  44. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  45. package/dist/Incentives/AllowListIncentive.js +13 -13
  46. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  47. package/dist/Incentives/CGDAIncentive.js +43 -43
  48. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  49. package/dist/Incentives/ERC20Incentive.js +16 -16
  50. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.cjs +1 -1
  51. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentive.js +35 -35
  52. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs +1 -1
  53. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.cjs.map +1 -1
  54. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.d.ts.map +1 -1
  55. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js +146 -161
  56. package/dist/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.js.map +1 -1
  57. package/dist/Incentives/ERC20VariableCriteriaIncentive.cjs +1 -1
  58. package/dist/Incentives/ERC20VariableCriteriaIncentive.js +7 -7
  59. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs +1 -1
  60. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.cjs.map +1 -1
  61. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.d.ts.map +1 -1
  62. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js +103 -118
  63. package/dist/Incentives/ERC20VariableCriteriaIncentiveV2.js.map +1 -1
  64. package/dist/Incentives/ERC20VariableIncentive.cjs +1 -1
  65. package/dist/Incentives/ERC20VariableIncentive.js +9 -9
  66. package/dist/Incentives/Incentive.cjs +1 -1
  67. package/dist/Incentives/Incentive.js +2 -2
  68. package/dist/Incentives/PointsIncentive.cjs +1 -1
  69. package/dist/Incentives/PointsIncentive.js +16 -16
  70. package/dist/{SimpleDenyList-BtEUdiAj.js → SimpleDenyList-CtdXM49y.js} +7 -7
  71. package/dist/{SimpleDenyList-BtEUdiAj.js.map → SimpleDenyList-CtdXM49y.js.map} +1 -1
  72. package/dist/{SimpleDenyList-DEoMIYhE.cjs → SimpleDenyList-D5AoBdVi.cjs} +2 -2
  73. package/dist/{SimpleDenyList-DEoMIYhE.cjs.map → SimpleDenyList-D5AoBdVi.cjs.map} +1 -1
  74. package/dist/{Validator-Kpvmj9Bs.js → Validator-BEUqV28V.js} +27 -27
  75. package/dist/{Validator-Kpvmj9Bs.js.map → Validator-BEUqV28V.js.map} +1 -1
  76. package/dist/{Validator-DHS4vjSa.cjs → Validator-FxcxYKhR.cjs} +2 -2
  77. package/dist/{Validator-DHS4vjSa.cjs.map → Validator-FxcxYKhR.cjs.map} +1 -1
  78. package/dist/Validators/LimitedSignerValidator.cjs +1 -1
  79. package/dist/Validators/LimitedSignerValidator.js +4 -4
  80. package/dist/Validators/SignerValidator.cjs +1 -1
  81. package/dist/Validators/SignerValidator.js +8 -8
  82. package/dist/Validators/Validator.cjs +1 -1
  83. package/dist/Validators/Validator.js +2 -2
  84. package/dist/deployments-DimWVnA4.cjs +2 -0
  85. package/dist/deployments-DimWVnA4.cjs.map +1 -0
  86. package/dist/deployments-Dw5Suk_D.js +158 -0
  87. package/dist/deployments-Dw5Suk_D.js.map +1 -0
  88. package/dist/deployments.json +69 -107
  89. package/dist/generated-Cf82M-QP.cjs +3 -0
  90. package/dist/generated-Cf82M-QP.cjs.map +1 -0
  91. package/dist/{generated-D6oDILUw.js → generated-krkFnwbV.js} +290 -247
  92. package/dist/generated-krkFnwbV.js.map +1 -0
  93. package/dist/index.cjs +1 -1
  94. package/dist/index.js +165 -164
  95. package/package.json +1 -1
  96. package/src/Actions/EventAction.test.ts +100 -71
  97. package/src/Actions/EventAction.ts +57 -30
  98. package/src/Incentives/ERC20PeggedVariableCriteriaIncentiveV2.ts +13 -41
  99. package/src/Incentives/ERC20VariableCriteriaIncentiveV2.ts +13 -41
  100. package/dist/deployments-Coa8CGi2.js +0 -194
  101. package/dist/deployments-Coa8CGi2.js.map +0 -1
  102. package/dist/deployments-Dgzcz4Ev.cjs +0 -2
  103. package/dist/deployments-Dgzcz4Ev.cjs.map +0 -1
  104. package/dist/generated-BzLYuFx3.cjs +0 -3
  105. package/dist/generated-BzLYuFx3.cjs.map +0 -1
  106. package/dist/generated-D6oDILUw.js.map +0 -1
@@ -41,12 +41,10 @@ import {
41
41
  transactionSenderClaimant,
42
42
  packFieldIndexes,
43
43
  unpackFieldIndexes,
44
- packCriteriaFieldIndexes,
45
- unpackCriteriaFieldIndexes,
46
- isCriteriaFieldIndexTuple,
47
44
  packClaimantFieldIndexes,
48
45
  decodeAndReorderLogArgs,
49
- ActionClaimant
46
+ ActionClaimant,
47
+ getScalarValue,
50
48
  } from "./EventAction";
51
49
  import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
52
50
  import { getTransactionReceipt } from "@wagmi/core";
@@ -1519,89 +1517,120 @@ describe('decodeAndReorderLogArgs', () => {
1519
1517
  });
1520
1518
 
1521
1519
  describe("criteria field index tuple support", () => {
1522
- describe("packCriteriaFieldIndexes", () => {
1523
- test("packs two indices into a single value", () => {
1524
- const packed = packCriteriaFieldIndexes([3, 5])
1525
- expect(packed).toBeGreaterThanOrEqual(32);
1526
- expect(packed).toBeLessThanOrEqual(253);
1527
- });
1520
+ test("extracts scalar value from single-level tuple", () => {
1521
+ const args = [123n, [456n, 789n], 999n];
1522
+ const fieldIndex = packFieldIndexes([1, 0]);
1523
+ const result = getScalarValue(args, fieldIndex);
1524
+ expect(result).toBe(456n);
1525
+ });
1528
1526
 
1529
- test("throws error if any index exceeds the allowed range (0-13)", () => {
1530
- expect(() => packCriteriaFieldIndexes([14, 5])).toThrowError(
1531
- "Tuple indices must be between 0-13"
1532
- );
1527
+ test("extracts scalar value from two-level nested tuple", () => {
1528
+ const args = [
1529
+ 100n,
1530
+ [
1531
+ 200n,
1532
+ [300n, 400n, 500n],
1533
+ 600n
1534
+ ],
1535
+ 700n
1536
+ ];
1537
+ const fieldIndex = packFieldIndexes([1, 1, 2]);
1533
1538
 
1534
- expect(() => packCriteriaFieldIndexes([5, 14])).toThrowError(
1535
- "Tuple indices must be between 0-13"
1536
- );
1539
+ const result = getScalarValue(args, fieldIndex);
1540
+ expect(result).toBe(500n);
1541
+ });
1537
1542
 
1538
- expect(() => packCriteriaFieldIndexes([-1, 5])).toThrowError(
1539
- "Tuple indices must be between 0-13"
1540
- );
1541
- });
1543
+ test("extracts scalar value from three-level nested tuple", () => {
1544
+ const args = [
1545
+ [
1546
+ [
1547
+ [111n, 222n],
1548
+ [333n, 444n]
1549
+ ],
1550
+ 555n
1551
+ ],
1552
+ 666n
1553
+ ];
1554
+ const fieldIndex = packFieldIndexes([0, 0, 1, 1]);
1542
1555
 
1543
- test("different input pairs result in different packed values", () => {
1544
- const packed1 = packCriteriaFieldIndexes([1, 2]);
1545
- const packed2 = packCriteriaFieldIndexes([2, 1]);
1546
- const packed3 = packCriteriaFieldIndexes([1, 3]);
1556
+ const result = getScalarValue(args, fieldIndex);
1557
+ expect(result).toBe(444n);
1558
+ });
1547
1559
 
1548
- expect(packed1).not.toBe(packed2);
1549
- expect(packed1).not.toBe(packed3);
1550
- expect(packed2).not.toBe(packed3);
1551
- });
1560
+ test("extracts scalar value from four-level nested tuple (max depth)", () => {
1561
+ const args = [
1562
+ [
1563
+ [
1564
+ [
1565
+ [1n, 2n, 3n],
1566
+ [4n, 5n, 6n]
1567
+ ],
1568
+ [[7n, 8n], [9n, 10n]]
1569
+ ]
1570
+ ]
1571
+ ];
1572
+ const fieldIndex = packFieldIndexes([0, 0, 0, 1, 2]);
1573
+
1574
+ const result = getScalarValue(args, fieldIndex);
1575
+ expect(result).toBe(6n);
1552
1576
  });
1553
1577
 
1554
- describe("unpackCriteriaFieldIndexes", () => {
1555
- test("unpacks tuple index values (>= 32) correctly", () => {
1556
- const packed = packCriteriaFieldIndexes([4, 7]);
1578
+ test("throws error when field index unpacks to empty array", () => {
1579
+ const args = [123n, 456n];
1580
+ const fieldIndex = 0xFFFFFFF;
1557
1581
 
1558
- const result = unpackCriteriaFieldIndexes(packed);
1559
- expect(result.length).toBe(2);
1560
- expect(result).toEqual([4, 7]);
1561
- });
1582
+ expect(() => getScalarValue(args, fieldIndex)).toThrowError(
1583
+ "Failed to unpack any indexes from fieldIndex"
1584
+ );
1585
+ });
1562
1586
 
1563
- test("throws error if packed value is out of valid range", () => {
1564
- expect(() => unpackCriteriaFieldIndexes(15)).toThrowError(
1565
- "Field index must be between 32-253"
1566
- );
1567
-
1568
- expect(() => unpackCriteriaFieldIndexes(254)).toThrowError(
1569
- "Field index must be between 32-253"
1570
- );
1587
+ test("throws error when accessing non-array at intermediate level", () => {
1588
+ const args = [123n, 'not-an-array', 789n];
1589
+ const fieldIndex = packFieldIndexes([1, 0]);
1571
1590
 
1572
- expect(() => unpackCriteriaFieldIndexes(-1)).toThrowError(
1573
- "Field index must be between 32-253"
1574
- );
1575
- });
1591
+ expect(() => getScalarValue(args, fieldIndex)).toThrowError(
1592
+ "Expected array at level 1, but got string"
1593
+ );
1576
1594
  });
1577
1595
 
1578
- describe("isCriteriaFieldIndexTuple", () => {
1579
- test("correctly identifies tuple indices vs simple indices", () => {
1580
- // Test with simple index (< 32)
1581
- expect(isCriteriaFieldIndexTuple(15)).toBe(false);
1596
+ test("returns early if bigint is found at intermediate level", () => {
1597
+ const args = [123n, 456n, 789n];
1598
+ const fieldIndex = packFieldIndexes([1, 0]);
1582
1599
 
1583
- // Test with tuple index (>= 32)
1584
- const packed = packCriteriaFieldIndexes([2, 3]);
1585
- expect(isCriteriaFieldIndexTuple(packed)).toBe(true);
1600
+ const result = getScalarValue(args, fieldIndex);
1601
+ expect(result).toBe(456n);
1602
+ });
1586
1603
 
1587
- // Test edge cases
1588
- expect(isCriteriaFieldIndexTuple(0)).toBe(false);
1589
- expect(isCriteriaFieldIndexTuple(31)).toBe(false);
1590
- expect(isCriteriaFieldIndexTuple(32)).toBe(true);
1591
- });
1604
+ test("throws error when index is out of bounds", () => {
1605
+ const args = [[100n, 200n], [300n]];
1606
+ const fieldIndex = packFieldIndexes([1, 5]);
1607
+
1608
+ expect(() => getScalarValue(args, fieldIndex)).toThrowError(
1609
+ "Index 5 is out of bounds at level 1. Array length is 1"
1610
+ );
1592
1611
  });
1593
1612
 
1594
- describe("criteria field index functions in practice", () => {
1595
- test("round-trip packing and unpacking preserves the original values", () => {
1596
- for (let i = 0; i <= 13; i++) {
1597
- for (let j = 0; j <= 13; j++) {
1598
- const original: [number, number] = [i, j];
1599
- const packed = packCriteriaFieldIndexes(original);
1600
- const unpacked = unpackCriteriaFieldIndexes(packed);
1601
- expect(unpacked).toEqual(original);
1602
- }
1603
- }
1604
- });
1613
+ test("throws error when final value is not a bigint", () => {
1614
+ const args = [["hello", "world"], [123n, 456n]];
1615
+ const fieldIndex = packFieldIndexes([0, 0]);
1616
+
1617
+ expect(() => getScalarValue(args, fieldIndex)).toThrowError(
1618
+ "Expected bigint at final position, but got string"
1619
+ );
1620
+ });
1621
+
1622
+ test("handles direct field access (single index)", () => {
1623
+ const args = [111n, 222n, 333n];
1624
+ const fieldIndex = packFieldIndexes([2]);
1625
+
1626
+ const result = getScalarValue(args, fieldIndex);
1627
+ expect(result).toBe(333n);
1628
+ });
1629
+
1630
+ test("throws error for index exceeding max field index", () => {
1631
+ expect(() => packFieldIndexes([0, 64])).toThrowError(
1632
+ "Index 64 exceeds the maximum allowed value"
1633
+ );
1605
1634
  });
1606
1635
  });
1607
1636
 
@@ -1945,6 +1945,8 @@ export function decodeAndReorderLogArgs(event: AbiEvent, log: Log) {
1945
1945
  }
1946
1946
 
1947
1947
  /**
1948
+ * @deprecated Do not use CriteriaFieldIndex methods. Use {@link packFieldIndexes} instead.
1949
+ *
1948
1950
  * IMPORTANT: For variable incentive criteria use only.
1949
1951
  * Do NOT use for action steps - use {@link packFieldIndexes} instead.
1950
1952
  *
@@ -1977,6 +1979,8 @@ export function packCriteriaFieldIndexes([firstIndex, secondIndex]: [
1977
1979
  }
1978
1980
 
1979
1981
  /**
1982
+ * @deprecated Do not use CriteriaFieldIndex methods. Use {@link unpackFieldIndexes} instead.
1983
+ *
1980
1984
  * Unpacks a uint8 packed index value into an array of indices.
1981
1985
  *
1982
1986
  * @export
@@ -1997,6 +2001,8 @@ export function unpackCriteriaFieldIndexes(packed: number): [number, number] {
1997
2001
  }
1998
2002
 
1999
2003
  /**
2004
+ * @deprecated Do not use CriteriaFieldIndex methods. Use {@link packFieldIndexes} instead.
2005
+ *
2000
2006
  * Determines if a fieldIndex represents a tuple index (value >= 32) or a normal field index.
2001
2007
  *
2002
2008
  * @export
@@ -2038,55 +2044,76 @@ export function unpackClaimantFieldIndexes(packed: number): [number, number] {
2038
2044
  }
2039
2045
 
2040
2046
  /**
2041
- * Extracts a scalar value from a tuple within event or function arguments.
2042
- * This is used for incentive criteria when determining reward amounts.
2047
+ * Extracts a scalar value from event or function arguments using a field index.
2048
+ * Supports both direct field access and nested tuple access (up to 4 levels).
2043
2049
  *
2044
2050
  * @export
2045
2051
  * @param {unknown[]} args - The decoded arguments from an event or function call
2046
- * @param {number} fieldIndex - The tuple-encoded index
2052
+ * @param {number} fieldIndex - The packed field index (supports both direct and nested access)
2047
2053
  * @returns {bigint} The extracted scalar value as a bigint
2048
2054
  * @throws {DecodedArgsError} If arguments are missing or cannot be converted to bigint
2049
2055
  */
2050
- export function getScalarValueFromTuple(
2051
- args: unknown[],
2052
- fieldIndex: number,
2053
- ): bigint {
2054
- if (!isCriteriaFieldIndexTuple(fieldIndex)) {
2056
+ export function getScalarValue(args: unknown[], fieldIndex: number): bigint {
2057
+ const indexes = unpackFieldIndexes(fieldIndex);
2058
+
2059
+ if (indexes.length === 0) {
2055
2060
  throw new DecodedArgsError(
2056
- `Field index ${fieldIndex} is invalid. Expected index >= 32`,
2061
+ `Failed to unpack any indexes from fieldIndex ${fieldIndex}`,
2057
2062
  );
2058
2063
  }
2059
2064
 
2060
- const [index0, index1] = unpackCriteriaFieldIndexes(fieldIndex);
2065
+ let scalarValue: unknown = args;
2061
2066
 
2062
- if (index0 === undefined || index1 === undefined) {
2063
- throw new DecodedArgsError(
2064
- `Failed to unpack field indexes from ${fieldIndex}`,
2065
- );
2066
- }
2067
+ for (let level = 0; level < indexes.length; level++) {
2068
+ const idx = indexes[level];
2067
2069
 
2068
- if (!args || args.length <= index0) {
2069
- throw new DecodedArgsError(`Decoded args missing item at index ${index0}`);
2070
- }
2070
+ if (idx === undefined) {
2071
+ throw new DecodedArgsError(`Undefined index at level ${level}`);
2072
+ }
2071
2073
 
2072
- const tuple = args[index0];
2073
- if (!tuple || !Array.isArray(tuple)) {
2074
- throw new DecodedArgsError(
2075
- `Expected array at index ${index0}, but got ${typeof tuple}`,
2076
- );
2077
- }
2078
- if (tuple.length <= index1) {
2079
- throw new DecodedArgsError(
2080
- `index ${index1} is out of bounds. tuple length is ${tuple.length}`,
2081
- );
2074
+ if (typeof scalarValue === 'bigint') {
2075
+ return scalarValue;
2076
+ }
2077
+
2078
+ if (!Array.isArray(scalarValue)) {
2079
+ throw new DecodedArgsError(
2080
+ `Expected array at level ${level}, but got ${typeof scalarValue}`,
2081
+ );
2082
+ }
2083
+
2084
+ if (idx >= scalarValue.length) {
2085
+ throw new DecodedArgsError(
2086
+ `Index ${idx} is out of bounds at level ${level}. Array length is ${scalarValue.length}`,
2087
+ );
2088
+ }
2089
+
2090
+ scalarValue = scalarValue[idx];
2082
2091
  }
2083
2092
 
2084
- const scalarValue = tuple[index1] as unknown;
2085
2093
  if (typeof scalarValue !== 'bigint') {
2086
2094
  throw new DecodedArgsError(
2087
- `Expected bigint at tuple index ${index1}, but got ${typeof scalarValue}`,
2095
+ `Expected bigint at final position, but got ${typeof scalarValue}`,
2088
2096
  );
2089
2097
  }
2090
2098
 
2091
2099
  return scalarValue;
2092
2100
  }
2101
+
2102
+ /**
2103
+ * @deprecated Use {@link getScalarValue} instead.
2104
+ *
2105
+ * Extracts a scalar value from a tuple within event or function arguments.
2106
+ * This is used for incentive criteria when determining reward amounts.
2107
+ *
2108
+ * @export
2109
+ * @param {unknown[]} args - The decoded arguments from an event or function call
2110
+ * @param {number} fieldIndex - The tuple-encoded index
2111
+ * @returns {bigint} The extracted scalar value as a bigint
2112
+ * @throws {DecodedArgsError} If arguments are missing or cannot be converted to bigint
2113
+ */
2114
+ export function getScalarValueFromTuple(
2115
+ args: unknown[],
2116
+ fieldIndex: number,
2117
+ ): bigint {
2118
+ return getScalarValue(args, fieldIndex);
2119
+ }
@@ -38,8 +38,7 @@ import { ERC20PeggedVariableCriteriaIncentiveV2 as ERC20PeggedVariableCriteriaIn
38
38
  import {
39
39
  SignatureType,
40
40
  decodeAndReorderLogArgs,
41
- getScalarValueFromTuple,
42
- isCriteriaFieldIndexTuple,
41
+ getScalarValue,
43
42
  } from '../Actions/EventAction';
44
43
  import type {
45
44
  DeployableOptions,
@@ -269,17 +268,13 @@ export class ERC20PeggedVariableCriteriaIncentiveV2 extends DeployableTarget<
269
268
 
270
269
  if (signatureMatchingLogs.length > 0) {
271
270
  for (const log of signatureMatchingLogs) {
272
- if (isCriteriaFieldIndexTuple(criteria.fieldIndex)) {
273
- return getScalarValueFromTuple(
271
+ try {
272
+ return getScalarValue(
274
273
  log.args as unknown[],
275
274
  criteria.fieldIndex,
276
275
  );
277
- }
278
- const scalarValue = log.args
279
- ? (log.args as string[])[criteria.fieldIndex]
280
- : undefined;
281
- if (scalarValue !== undefined) {
282
- return BigInt(scalarValue);
276
+ } catch {
277
+ continue;
283
278
  }
284
279
  }
285
280
  }
@@ -315,23 +310,10 @@ export class ERC20PeggedVariableCriteriaIncentiveV2 extends DeployableTarget<
315
310
  );
316
311
  }
317
312
 
318
- if (isCriteriaFieldIndexTuple(criteria.fieldIndex)) {
319
- return getScalarValueFromTuple(
320
- decodedEvents[0]?.args as unknown[],
321
- criteria.fieldIndex,
322
- );
323
- }
324
-
325
- const scalarValue =
326
- decodedEvents[0] && decodedEvents[0].args
327
- ? (decodedEvents[0].args as string[])[criteria.fieldIndex]
328
- : undefined;
329
- if (scalarValue === undefined) {
330
- throw new DecodedArgsError(
331
- `Decoded argument at index ${criteria.fieldIndex} is undefined`,
332
- );
333
- }
334
- return BigInt(scalarValue);
313
+ return getScalarValue(
314
+ decodedEvents[0]?.args as unknown[],
315
+ criteria.fieldIndex,
316
+ );
335
317
  } catch (e) {
336
318
  throw new DecodedArgsError(
337
319
  `Failed to decode event log for signature ${criteria.signature}: ${(e as Error).message}`,
@@ -351,20 +333,10 @@ export class ERC20PeggedVariableCriteriaIncentiveV2 extends DeployableTarget<
351
333
  data: transaction.input,
352
334
  });
353
335
 
354
- if (isCriteriaFieldIndexTuple(criteria.fieldIndex)) {
355
- return getScalarValueFromTuple(
356
- decodedFunction.args as unknown[],
357
- criteria.fieldIndex,
358
- );
359
- }
360
-
361
- const scalarValue = decodedFunction.args[criteria.fieldIndex] as string;
362
- if (scalarValue === undefined || scalarValue === null) {
363
- throw new DecodedArgsError(
364
- `Decoded argument at index ${criteria.fieldIndex} is undefined`,
365
- );
366
- }
367
- return BigInt(scalarValue);
336
+ return getScalarValue(
337
+ decodedFunction.args as unknown[],
338
+ criteria.fieldIndex,
339
+ );
368
340
  } catch (e) {
369
341
  throw new DecodedArgsError(
370
342
  `Failed to decode function data for signature ${criteria.signature}: ${(e as Error).message}`,
@@ -24,8 +24,7 @@ import {
24
24
  SignatureType,
25
25
  ValueType,
26
26
  decodeAndReorderLogArgs,
27
- getScalarValueFromTuple,
28
- isCriteriaFieldIndexTuple,
27
+ getScalarValue,
29
28
  } from '../Actions/EventAction';
30
29
  import type {
31
30
  DeployableOptions,
@@ -283,17 +282,13 @@ export class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<
283
282
 
284
283
  if (signatureMatchingLogs.length > 0) {
285
284
  for (const log of signatureMatchingLogs) {
286
- if (isCriteriaFieldIndexTuple(criteria.fieldIndex)) {
287
- return getScalarValueFromTuple(
285
+ try {
286
+ return getScalarValue(
288
287
  log.args as unknown[],
289
288
  criteria.fieldIndex,
290
289
  );
291
- }
292
- const scalarValue = log.args
293
- ? (log.args as string[])[criteria.fieldIndex]
294
- : undefined;
295
- if (scalarValue !== undefined) {
296
- return BigInt(scalarValue);
290
+ } catch {
291
+ continue;
297
292
  }
298
293
  }
299
294
  }
@@ -329,23 +324,10 @@ export class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<
329
324
  );
330
325
  }
331
326
 
332
- if (isCriteriaFieldIndexTuple(criteria.fieldIndex)) {
333
- return getScalarValueFromTuple(
334
- decodedEvents[0]?.args as unknown[],
335
- criteria.fieldIndex,
336
- );
337
- }
338
-
339
- const scalarValue =
340
- decodedEvents[0] && decodedEvents[0].args
341
- ? (decodedEvents[0].args as string[])[criteria.fieldIndex]
342
- : undefined;
343
- if (scalarValue === undefined) {
344
- throw new DecodedArgsError(
345
- `Decoded argument at index ${criteria.fieldIndex} is undefined`,
346
- );
347
- }
348
- return BigInt(scalarValue);
327
+ return getScalarValue(
328
+ decodedEvents[0]?.args as unknown[],
329
+ criteria.fieldIndex,
330
+ );
349
331
  } catch (e) {
350
332
  throw new DecodedArgsError(
351
333
  `Failed to decode event log for signature ${criteria.signature}: ${(e as Error).message}`,
@@ -365,20 +347,10 @@ export class ERC20VariableCriteriaIncentiveV2 extends ERC20VariableIncentive<
365
347
  data: transaction.input,
366
348
  });
367
349
 
368
- if (isCriteriaFieldIndexTuple(criteria.fieldIndex)) {
369
- return getScalarValueFromTuple(
370
- decodedFunction.args as unknown[],
371
- criteria.fieldIndex,
372
- );
373
- }
374
-
375
- const scalarValue = decodedFunction.args[criteria.fieldIndex] as string;
376
- if (scalarValue === undefined || scalarValue === null) {
377
- throw new DecodedArgsError(
378
- `Decoded argument at index ${criteria.fieldIndex} is undefined`,
379
- );
380
- }
381
- return BigInt(scalarValue);
350
+ return getScalarValue(
351
+ decodedFunction.args as unknown[],
352
+ criteria.fieldIndex,
353
+ );
382
354
  } catch (e) {
383
355
  throw new DecodedArgsError(
384
356
  `Failed to decode function data for signature ${criteria.signature}: ${(e as Error).message}`,