diff --git a/.changeset/thirty-knives-glow.md b/.changeset/thirty-knives-glow.md new file mode 100644 index 000000000..925b1d3c9 --- /dev/null +++ b/.changeset/thirty-knives-glow.md @@ -0,0 +1,6 @@ +--- +"@rabbitholegg/questdk": patch +"@rabbitholegg/questdk-plugin-mux": patch +--- + +allow for more general transaction typing, fix mux tests diff --git a/apps/questdk/src/filter/filters.ts b/apps/questdk/src/filter/filters.ts index dc94d1568..cf313a814 100644 --- a/apps/questdk/src/filter/filters.ts +++ b/apps/questdk/src/filter/filters.ts @@ -11,7 +11,6 @@ import type { import { type AbiFunction, type Address, - type TransactionEIP1559, decodeAbiParameters, decodeFunctionData, getAbiItem, @@ -22,6 +21,7 @@ import { AbiParameter, ByteArray, Hex, + Transaction, } from 'viem' type OperatorKey = keyof typeof operators @@ -32,7 +32,7 @@ type OperatorKey = keyof typeof operators * @returns True if all filters pass, false otherwise. */ export const handleAnd = ( - context: TransactionEIP1559 | Record, + context: Transaction | Record, filter: Filter[], ): boolean => { for (let i = 0; i < filter.length; i++) { @@ -50,7 +50,7 @@ export const handleAnd = ( * @returns True if any filter passes, false otherwise. */ export const handleOr = ( - context: TransactionEIP1559 | Record, + context: Transaction | Record, filter: Filter[], ): boolean => { for (let i = 0; i < filter.length; i++) { @@ -68,7 +68,7 @@ export const handleOr = ( * @returns True if any filter passes, false otherwise. */ export const handleSome = ( - context: Array>, + context: Array>, filter: TransactionFilter | FilterObject, ): boolean => { for (let i = 0; i < context.length; i++) { @@ -150,7 +150,7 @@ export const handleGreaterThanOrEqual = ( * @returns The result of applying the filter. */ export const handleFirst = ( - context: Array>, + context: Array>, filter: TransactionFilter | FilterObject, ): boolean => { return apply(context[0], filter) @@ -163,7 +163,7 @@ export const handleFirst = ( * @returns The result of applying the filter. */ export const handleLast = ( - context: Array>, + context: Array>, filter: TransactionFilter | FilterObject, ): boolean => { return apply(context[context.length - 1], filter) @@ -176,7 +176,7 @@ export const handleLast = ( * @returns True if the value at the nth index meets the condition, false otherwise. */ export const handleNth = ( - context: Array>, + context: Array>, filter: NthFilter, ): boolean => { const { index, value } = filter @@ -361,10 +361,10 @@ const operators = { * @returns True if all filters pass, false otherwise. */ export function apply( - originalContext: TransactionEIP1559 | Record, + originalContext: Transaction | Record, filters: TransactionFilter | FilterObject, ): boolean { - let context: TransactionEIP1559 | Record = originalContext + let context: Transaction | Record = originalContext if (typeof filters === 'object') { if ('$abi' in filters) { const processedContext = handleAbiDecode(context, filters as AbiFilter) diff --git a/packages/mux/src/test-transactions.ts b/packages/mux/src/test-transactions.ts index 965a7e366..7679acdd7 100644 --- a/packages/mux/src/test-transactions.ts +++ b/packages/mux/src/test-transactions.ts @@ -11,7 +11,7 @@ export const MUX_ETH_MARKET_LONG: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0x4786055f865c301c46d64de5c9b124ec1a97ef1efc1bcbd1030a0100000000000000000000000000000000000000000000000000000000000000000000038d7ea4c680000000000000000000000000000000000000000000000000009fbd82c3c72240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065c6b238', - value: '1000000000000000', + value: BigInt('1000000000000000'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -30,7 +30,7 @@ const MUX_ARB_LIMIT_LONG: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0x4786055f865c301c46d64de5c9b124ec1a97ef1efc1bcbd10a0301000000000000000000000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000000775f05a07400000000000000000000000000000000000000000000000008b7b8c4ba968140000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000065c6b5eb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065c6b5eb', - value: '0', + value: BigInt(0), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -49,7 +49,7 @@ const MUX_DAI_MARKET_SHORT: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0x4786055f865c301c46d64de5c9b124ec1a97ef1efc1bcbd10203000000000000000000000000000000000000000000000000000000000000000000004a1b7db51c960000000000000000000000000000000000000000000000000000009f295cd5f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065c6b8c3', - value: '0', + value: BigInt('0'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -68,7 +68,7 @@ const GMX_V1_MARKET_ETH_LONG: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0x92644c39000000000000000000000000000000000000000000000000000000000000000100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000000000000000100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000000000000000000000000000000fa1c6d5030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000071afd498d000000000000000000000000000000000000000000000000003846bd518406d0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000', - value: '4580000000000001', + value: BigInt('4580000000000001'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -87,7 +87,7 @@ const GMX_V2_MARKET_USDCE_LONG: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0x92644c39000000000000000000000000000000000000000000000000000000000000000100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab100000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab10000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000000000000000000000000000000000000000a7d8c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c34a9fdf9acb000000000000000000000000000000000000000000000005dea4fd6ddfdc32a400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000', - value: '180000000000000', + value: BigInt('180000000000000'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -107,7 +107,7 @@ const GMX_V2_LIMIT_WBTC_LONG: TestParams = { hash: '0x9fb4a0394ff01c7a5ed180272970b50fddee509baced24d6667fb8e944a6790b', input: '0x92644c3900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f0000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000095989200000000000000000000000000000000000000000000bad652a98addfdcc8c8c00000000000000000000000000000000000000000000098758b21e60d35800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000', - value: '180000000000000', + value: BigInt('180000000000000'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -126,7 +126,7 @@ const GMX_V2_MULTICALL_USDCE_MARKET: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0xac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000c4606c70120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee63360000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc800000000000000000000000000000000000000000000000000000000026232f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4b8444d820000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee633600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000005543df729c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003242393236300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee633600000000000000000000000000000000000000000000000000000000000000016d757870726f746f636f6c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001e45102a7080000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000026232f000000000000000000000000000000000000000000000000000000000025c18d400000000000000000000000000000000000000000000000000000000011d4393000000000000000000000000000000000000b858710425e477bbdf0c7a7dd000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093d5b805587e50000000000000000000000000000000000000000000000000005543df729c000000000000000000000000000000000000000000000000000000000000007a12000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000042ff970a61a04b1ca14834a43f5de4533ebddb5cc80001f42f2a2543b76a4166549f7aab2e75bef0aefc5b0f000bb8af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - value: '1500000000000000', + value: BigInt('1500000000000000'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -144,7 +144,7 @@ const GMX_V2_MULTICALL_USDCE_LIMIT: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0xac9650d80000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000c4606c70120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee63360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ff970a61a04b1ca14834a43f5de4533ebddb5cc80000000000000000000000000000000000000000000000000000000001312d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a4b8444d820000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee633600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005543df729c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003042393236300000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000070d95587d40a2caf56bd97485ab3eec10bee633600000000000000000000000000000000000000000000000000000000000000006d757870726f746f636f6c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001c45102a708000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000001312d0000000000000000000000000000000000000000000000000000000000012e1fc0000000000000000000000000000000000000000000000000000000000021327f0000000000000000000000000000000000001573731da25af9d52ebf3c43e800000000000000000000000000000000000000000000000000000940f5fa3f180000000000000000000000000000000000000000000000000000092945701062000000000000000000000000000000000000000000000000000005543df729c000000000000000000000000000000000000000000000000000000000000007a1200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000002bff970a61a04b1ca14834a43f5de4533ebddb5cc8000064af88d065e77c8cc2239327c5edb3a432268e58310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', - value: '1500000000000000', + value: BigInt('1500000000000000'), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -162,7 +162,7 @@ const GNS_MARKET_LONG: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0xfb4b71bb000000000000000000000000865c301c46d64de5c9b124ec1a97ef1efc1bcbd1000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0b6ccf4be560000000000000000000000000000000000000000000000000000000017c2b31879e0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000960000000000000000000000000000000000000000000000000000192d156281c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002540be40000000000000000000000000010c2cbfe29f4f5e4c24d54d36c8f283a61eb0c2f', - value: '0', + value: BigInt(0), }, params: { chainId: Chains.ARBITRUM_ONE, @@ -181,7 +181,7 @@ const GNS_LIMIT_SHORT: TestParams = { from: '0x865c301c46d64de5c9b124ec1a97ef1efc1bcbd1', input: '0xfb4b71bb000000000000000000000000865c301c46d64de5c9b124ec1a97ef1efc1bcbd1000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002c0b6ccf4be560000000000000000000000000000000000000000000000000000000017c1895250000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009600000000000000000000000000000000000000000000000000001654a4ec18000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000002540be40000000000000000000000000010c2cbfe29f4f5e4c24d54d36c8f283a61eb0c2f', - value: '0', + value: BigInt(0), }, params: { chainId: Chains.ARBITRUM_ONE, diff --git a/packages/mux/src/utils.ts b/packages/mux/src/utils.ts index 358e4b228..9db8e18df 100644 --- a/packages/mux/src/utils.ts +++ b/packages/mux/src/utils.ts @@ -1,5 +1,5 @@ import type { ActionParams } from '@rabbitholegg/questdk' -import { type Address, type Hash } from 'viem' +import { TransactionEIP1559, type Address } from 'viem' export enum Chains { ETHEREUM = 1, @@ -17,23 +17,14 @@ export enum Chains { SCROLL = 534352, } -interface Transaction { - chainId: number - from: Address - hash?: Hash - input: string - to: Address - value: string -} - export interface TestCase { - transaction: Transaction + transaction: Partial params: T description: string } export type TestParams = { - transaction: Transaction + transaction: Partial params: T }