Skip to content

Commit

Permalink
complete docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mfornos committed Jun 29, 2023
1 parent f950d46 commit c1232c2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ source.pipe(

// Maps the events with
// block and extrinsic context
mapEventsWithContext(),
extractEventsWithTx(),

// Filters over the events
mongoFilter(eventsQuery),
Expand Down
12 changes: 7 additions & 5 deletions packages/core/src/operators/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SignedBlockExtended>)
: Observable<TxWithIdAndEvent> => {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/subjects/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions packages/pallets/contracts/src/operators/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 12 additions & 5 deletions packages/pallets/contracts/src/operators/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit c1232c2

Please sign in to comment.