diff --git a/README.md b/README.md index d3aba92..4dd34fb 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ source.pipe( // Maps the events with // block and extrinsic context - mapEventsWithContext(), + extractEventsWithTx(), // Filters over the events mongoFilter(eventsQuery), diff --git a/packages/core/src/operators/filter.ts b/packages/core/src/operators/filter.ts index 94dd294..3b297f8 100644 --- a/packages/core/src/operators/filter.ts +++ b/packages/core/src/operators/filter.ts @@ -9,14 +9,16 @@ import { ControlQuery, Criteria } from '../index.js'; import { EventWithId, TxWithIdAndEvent } from '../types/interfaces.js'; /** + * Filters extrinsics based on the provided criteria. * - * @param extrinsicsCriteria - * @returns + * It extracts extrinsics with events from the given block, + * flattens batch calls if needed and applies the filter criteria. + * + * @param extrinsicsCriteria The criteria to filter extrinsics. + * @returns An observable that emits filtered extrinsics with identifier and event information. */ export function filterExtrinsics( - extrinsicsCriteria : Criteria = { - dispatchError: { $exists: false } - } + extrinsicsCriteria: Criteria ) { return (source: Observable) : Observable => { diff --git a/packages/core/src/subjects/query.ts b/packages/core/src/subjects/query.ts index e44648e..71c7c9d 100644 --- a/packages/core/src/subjects/query.ts +++ b/packages/core/src/subjects/query.ts @@ -62,9 +62,9 @@ export class ControlQuery } /** - * - * @param obj - * @returns + * Checks if an object is an instance of `ControlQuery`. + * @param obj The object to check. + * @returns `true` if the object is an instance of `ControlQuery`, `false` otherwise. */ static isControlQuery(obj: ControlQuery | Criteria): obj is ControlQuery { return obj.change !== undefined; diff --git a/packages/pallets/contracts/src/operators/contracts.ts b/packages/pallets/contracts/src/operators/contracts.ts index b3fa409..e897b84 100644 --- a/packages/pallets/contracts/src/operators/contracts.ts +++ b/packages/pallets/contracts/src/operators/contracts.ts @@ -21,8 +21,8 @@ function getArgValueFromTx(extrinsic: types.ExtrinsicWithId, name: string) { * Returns an Observable that filters for contract call extrinsics based on the given address * and decodes the contract message based on the provided ABI. * - * @param abiJson - The ABI of the contract as a JSON object or string. - * @param address - The address of the contract. + * @param abi The ABI of the contract as a JSON object or string. + * @param address The contract address or an array of addresses. * @returns An Observable that emits ContractMessageWithTx objects. */ export function contractMessages(abi: Abi, address: AddressParam ) { @@ -54,9 +54,9 @@ export function contractMessages(abi: Abi, address: AddressParam ) { * Returns an Observable that filters for contract instantiations based on the given code hash * and decodes the contract constructor based on the provided ABI. * - * @param api - The ApiPromise instance for the network. - * @param abi - The contract ABI. - * @param codeHash - The contract code hash. + * @param api The ApiPromise instance for the network. + * @param abi The contract ABI. + * @param codeHash The contract code hash. * * @returns An observable that emits the decoded contract constructor with associated block event and transaction. */ @@ -123,8 +123,8 @@ export function contractConstructors(api: ApiPromise, abi: Abi, codeHash: string /** * Returns an Observable that filters and maps contract events based on the given ABI and address. * - * @param abiJson - The ABI of the contract as a JSON object or string. - * @param address - The address of the contract. + * @param abi The ABI of the contract as a JSON object or string. + * @param address The contract address or an array of addresses. * @returns An Observable that emits ContractEventWithBlockEvent objects. */ export function contractEvents( diff --git a/packages/pallets/contracts/src/operators/filter.ts b/packages/pallets/contracts/src/operators/filter.ts index ff25c95..9dd8f3a 100644 --- a/packages/pallets/contracts/src/operators/filter.ts +++ b/packages/pallets/contracts/src/operators/filter.ts @@ -16,7 +16,13 @@ import { ContractEventWithBlockEvent, ContractMessageWithTx } from '../types/int import { AddressParam } from '../types/types.js'; /** + * Filters contract calls based on the provided criteria. * + * @param abi The ABI of the contract as a JSON object or string. + * @param address The contract address or an array of addresses. + * @param callsCriteria The criteria to filter contract calls. + * @param extrinsicsCriteria - (Optional) Criteria for filtering extrinsics. Defaults to `{ dispatchError: { $exists: false } }`. + * @returns An observable that emits filtered contract calls. */ export function filterContractCalls( abi: Abi, @@ -43,12 +49,13 @@ export function filterContractCalls( } /** + * Filters contract events based on the provided criteria. * - * @param abi - * @param address - * @param eventsCriteria - * @param extrinsicsCriteria - * @returns + * @param abi The ABI of the contract as a JSON object or string. + * @param address The contract address or an array of addresses. + * @param eventsCriteria The criteria to filter contract events. + * @param extrinsicsCriteria - (Optional) Criteria for filtering extrinsics. Defaults to `{ dispatchError: { $exists: false } }`. + * @returns An observable that emits filtered contract events. */ export function filterContractEvents( abi: Abi,