Skip to content

Commit 94b09f0

Browse files
sammccordgithub-actions[bot]
authored andcommittedAug 16, 2024

File tree

5 files changed

+45
-11
lines changed

5 files changed

+45
-11
lines changed
 

‎apps/questdk/src/filter/filters.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ type OperatorKey = keyof typeof operators
3131
* @param filter - The set of filters to apply.
3232
* @returns True if all filters pass, false otherwise.
3333
*/
34-
export const handleAnd = (context: TransactionEIP1559 | Record<string, unknown>, filter: Filter[]): boolean => {
34+
export const handleAnd = (
35+
context: TransactionEIP1559 | Record<string, unknown>,
36+
filter: Filter[],
37+
): boolean => {
3538
for (let i = 0; i < filter.length; i++) {
3639
if (!apply(context, filter[i] as FilterObject)) {
3740
return false
@@ -46,7 +49,10 @@ export const handleAnd = (context: TransactionEIP1559 | Record<string, unknown>,
4649
* @param filter - The set of filters to apply.
4750
* @returns True if any filter passes, false otherwise.
4851
*/
49-
export const handleOr = (context: TransactionEIP1559 | Record<string, unknown>, filter: Filter[]): boolean => {
52+
export const handleOr = (
53+
context: TransactionEIP1559 | Record<string, unknown>,
54+
filter: Filter[],
55+
): boolean => {
5056
for (let i = 0; i < filter.length; i++) {
5157
if (apply(context, filter[i] as FilterObject)) {
5258
return true
@@ -169,7 +175,10 @@ export const handleLast = (
169175
* @param filter - An object containing the index and the condition to check.
170176
* @returns True if the value at the nth index meets the condition, false otherwise.
171177
*/
172-
export const handleNth = (context: Array<TransactionEIP1559 | Record<string, unknown>>, filter: NthFilter): boolean => {
178+
export const handleNth = (
179+
context: Array<TransactionEIP1559 | Record<string, unknown>>,
180+
filter: NthFilter,
181+
): boolean => {
173182
const { index, value } = filter
174183

175184
if (Number(index) < 0 || Number(index) >= context.length) {
@@ -195,7 +204,10 @@ export const handleRegex = (context: string, filter: string): boolean => {
195204
* @param filter - An object containing the bitmask and the value to compare against.
196205
* @returns True if the masked context is equal to the value, false otherwise.
197206
*/
198-
export const handleBitmask = (context: bigint | boolean | number | string, filter: BitmaskFilter): boolean => {
207+
export const handleBitmask = (
208+
context: bigint | boolean | number | string,
209+
filter: BitmaskFilter,
210+
): boolean => {
199211
const maskedContext = BigInt(context) & BigInt(filter.bitmask)
200212
if (typeof filter.value === 'object') {
201213
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -292,9 +304,14 @@ export const handleAbstractAbiDecode = (
292304
* @param filter - The filter containing the ABI parameters.
293305
* @returns The decoded ABI parameters.
294306
*/
295-
export const handleAbiParamDecode = (context: ByteArray | Hex, filter: AbiParamFilter) => {
307+
export const handleAbiParamDecode = (
308+
context: ByteArray | Hex,
309+
filter: AbiParamFilter,
310+
) => {
296311
try {
297-
const params = parseAbiParameters(filter.$abiParams.join(', ')) as AbiParameter[]
312+
const params = parseAbiParameters(
313+
filter.$abiParams.join(', '),
314+
) as AbiParameter[]
298315
const args = decodeAbiParameters(params, context)
299316
const namedArgs = params.reduce(
300317
(acc: Record<string, unknown>, param: AbiParameter, index) => {

‎packages/balancer/src/utils.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ export const buildAmountQuery = (
3535
if (amountOut) {
3636
let condition: FilterOperator | undefined
3737
if (typeof amountOut === 'object') {
38-
const [operator, value] = Object.entries(amountOut)[0] as [string, (bigint | boolean | number | string)]
38+
const [operator, value] = Object.entries(amountOut)[0] as [
39+
string,
40+
bigint | boolean | number | string,
41+
]
3942
switch (operator) {
4043
case '$gte':
4144
condition = { $lte: BigInt(-value) }

‎packages/orbit/src/utils.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ export function getUnlockTime(
99
const now = Math.floor(new Date().getTime() / 1000)
1010

1111
if (typeof duration === 'object') {
12-
const [operator, value] = Object.entries(duration)[0] as [string, (string | number | bigint | boolean)]
12+
const [operator, value] = Object.entries(duration)[0] as [
13+
string,
14+
string | number | bigint | boolean,
15+
]
1316
return { [operator]: BigInt(value) + BigInt(now) }
1417
}
1518
return { $gte: BigInt(duration) + BigInt(now) }

‎packages/utils/src/types/actions.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {
44
type SimulateContractReturnType,
55
type TransactionRequest,
66
} from 'viem'
7-
import { FilterOperatorSchema, NumericSchema, type FilterOperator, type TransactionFilter } from './filters'
7+
import {
8+
FilterOperatorSchema,
9+
NumericSchema,
10+
type FilterOperator,
11+
type TransactionFilter,
12+
} from './filters'
813
import { PluginActionNotImplementedError } from '../errors'
914
import type { MintIntentParams } from './intents'
1015
import { ZodSchema, z } from 'zod'

‎packages/vela/src/utils.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export function getAmountPacked(
3636
if (amount === undefined) return undefined
3737
const multiplier = BigInt(2 ** 128) * BigInt(10 ** 12)
3838
if (typeof amount === 'object') {
39-
const [operator, value] = Object.entries(amount)[0] as [string, (string | number | bigint | boolean)]
39+
const [operator, value] = Object.entries(amount)[0] as [
40+
string,
41+
string | number | bigint | boolean,
42+
]
4043
if (operator === '$lte' || operator === '$lt') {
4144
return { [operator]: (BigInt(value) + 1n) * multiplier }
4245
}
@@ -95,7 +98,10 @@ export function getAmount(amount: Amount): FilterOperator | undefined {
9598
if (amount === undefined) return undefined
9699
const multiplier = BigInt(10 ** 12)
97100
if (typeof amount === 'object') {
98-
const [operator, value] = Object.entries(amount)[0] as [string, (string | number | bigint | boolean)]
101+
const [operator, value] = Object.entries(amount)[0] as [
102+
string,
103+
string | number | bigint | boolean,
104+
]
99105
if (operator === '$lte' || operator === '$lt') {
100106
return { [operator]: (BigInt(value) + 1n) * multiplier }
101107
}

0 commit comments

Comments
 (0)
Please sign in to comment.