@polkadot/types/interfaces#SessionIndex TypeScript Examples

The following examples show how to use @polkadot/types/interfaces#SessionIndex. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: useActionsQueue.ts    From crust-apps with Apache License 2.0 6 votes vote down vote up
export default function useActionsQueue (): QueuedAction[] {
  const { api } = useApi();
  const currentIndex = useCall<SessionIndex>(api.query.session.currentIndex);
  const nextActions = useCallMulti<ParaId[][]>(
    currentIndex
      ? INC.map((inc) => [api.query.paras.actionsQueue, currentIndex.add(inc)])
      : []
  );

  return useMemo(
    (): QueuedAction[] =>
      currentIndex && nextActions
        ? nextActions.filter((paraIds) => paraIds.length).map((paraIds, index) => ({
          paraIds,
          sessionIndex: currentIndex.add(INC[index])
        }))
        : [],
    [currentIndex, nextActions]
  );
}
Example #2
Source File: useProposals.ts    From crust-apps with Apache License 2.0 6 votes vote down vote up
function createResult (sessionIndex: SessionIndex, approvedIds: ParaId[], proposalKeys: { args: [ParaId] }[], scheduledProposals: [{ args: [SessionIndex] }, ParaId[]][]): Proposals {
  return {
    approvedIds,
    proposalIds: proposalKeys.map(({ args: [id] }) => id),
    scheduled: scheduledProposals
      .map(([{ args: [sessionIndex] }, scheduledIds]) => ({
        scheduledIds,
        sessionIndex
      }))
      .filter((s) => s.sessionIndex.gt(sessionIndex))
  };
}
Example #3
Source File: subscriber.ts    From polkadot-registrar-watcher with Apache License 2.0 5 votes vote down vote up
private sessionIndex: SessionIndex;
Example #4
Source File: subscriber.ts    From polkadot-watcher-csv-exporter with Apache License 2.0 5 votes vote down vote up
private sessionIndex: SessionIndex;
Example #5
Source File: subscriber.ts    From polkadot-watcher-csv-exporter with Apache License 2.0 5 votes vote down vote up
private _writeEraCSV = async (eraIndex: EraIndex, sessionIndex: SessionIndex, blockNumber: Compact<BlockNumber>): Promise<void> => {
      const network = this.chain.toString().toLowerCase()
      const request = {api:this.api,network,apiChunkSize:this.apiChunkSize,exportDir:this.exportDir,eraIndex,sessionIndex,blockNumber}
      const chainData = await gatherChainData(request, this.logger)
      await writeSessionCSV(request, chainData, this.logger)
      await writeEraCSV(request, chainData, this.logger)
    }
Example #6
Source File: subscriber.ts    From polkadot-watcher-csv-exporter with Apache License 2.0 5 votes vote down vote up
private _writeSessionCSV = async (eraIndex: EraIndex, sessionIndex: SessionIndex, blockNumber: Compact<BlockNumber>): Promise<void> => {
      const network = this.chain.toString().toLowerCase()
      const request = {api:this.api,network,apiChunkSize:this.apiChunkSize,exportDir:this.exportDir,eraIndex,sessionIndex,blockNumber}
      const chainData = await gatherChainData(request, this.logger)
      await writeSessionCSV(request, chainData, this.logger)
    }
Example #7
Source File: subscriber.ts    From polkadot-watcher-csv-exporter with Apache License 2.0 5 votes vote down vote up
private _handleEraChange = async (newEra: EraIndex, newSession: SessionIndex): Promise<void> =>{
      this.eraIndex = newEra
      await this._handleSessionChange(newSession)
    }
Example #8
Source File: subscriber.ts    From polkadot-watcher-csv-exporter with Apache License 2.0 5 votes vote down vote up
private _handleSessionChange = async (newSession: SessionIndex): Promise<void> =>{
      this.sessionIndex = newSession
      this._unlockCSVWwrite()
    }