Rebrand: polkadot → pezkuwi, substrate → bizinikiwi, kusama → dicle

This commit is contained in:
Kurdistan Tech Ministry committed 2026-01-07 02:29:40 +03:00
commit d5f038faea
1383 files changed
+1088018

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
// Copyright 2017-2025 @pezkuwi/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { EventRecord, Hash, SignedBlock } from '@pezkuwi/types/interfaces';
import type { DeriveApi } from '../types.js';
import { combineLatest, map, switchMap } from 'rxjs';
import { memo } from '../util/index.js';
interface Result {
block: SignedBlock;
events: EventRecord[];
}
/**
* @name events
* @param {Hash} at Block hash to query at.
* @description Retrieves the block information alongside its events at a given block hash
* @example
* ```javascript
* const blockHash = api.registry.createType(
* "Hash",
* "0xf1dc2efe8265be67deea5e91b05a98a7f9f81f66854e92825cf36f541beb7af6"
* );
* const { events, block } = await api.derive.tx.events(blockHash);
* ```
*/
export function events (instanceId: string, api: DeriveApi): (at: Hash) => Observable<Result> {
return memo(instanceId, (blockHash: Hash) =>
combineLatest([
api.rpc.chain.getBlock(blockHash),
api.queryAt(blockHash).pipe(
switchMap((queryAt) =>
queryAt.system.events()
)
)
]).pipe(
map(([block, events]) => ({ block, events }))
)
);
}