33
44import type { Observable } from 'rxjs' ;
55import type { ApiInterfaceRx } from '@polkadot/api/types' ;
6- import type { Option , u64 , Vec } from '@polkadot/types' ;
7- import type { BlockNumber , Hash , ReferendumIndex , Scheduled } from '@polkadot/types/interfaces' ;
6+ import type { Option , Vec } from '@polkadot/types' ;
7+ import type { BlockNumber , Hash , ReferendumIndex } from '@polkadot/types/interfaces' ;
8+ import type { PalletSchedulerScheduledV2 } from '@polkadot/types/lookup' ;
89import type { ITuple } from '@polkadot/types/types' ;
910import type { DeriveDispatch , DeriveProposalImage } from '../types' ;
1011
@@ -42,7 +43,7 @@ function queryQueue (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
4243 ) ;
4344}
4445
45- function schedulerEntries ( api : ApiInterfaceRx ) : Observable < [ BlockNumber [ ] , ( Option < Scheduled > [ ] | null ) [ ] ] > {
46+ function schedulerEntries ( api : ApiInterfaceRx ) : Observable < [ BlockNumber [ ] , ( Option < PalletSchedulerScheduledV2 > [ ] | null ) [ ] ] > {
4647 // We don't get entries, but rather we get the keys (triggered via finished referendums) and
4748 // the subscribe to those keys - this means we pickup when the schedulers actually executes
4849 // at a block, the entry for that block will become empty
@@ -56,11 +57,11 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Opt
5657 return blockNumbers . length
5758 ? combineLatest ( [
5859 of ( blockNumbers ) ,
59- // this should simply be api.query.scheduler.agenda.multi<Vec<Option<Scheduled>>> ,
60+ // this should simply be api.query.scheduler.agenda.multi,
6061 // however we have had cases on Darwinia where the indices have moved around after an
6162 // upgrade, which results in invalid on-chain data
6263 combineLatest ( blockNumbers . map ( ( blockNumber ) =>
63- api . query . scheduler . agenda < Vec < Option < Scheduled > > > ( blockNumber ) . pipe (
64+ api . query . scheduler . agenda ( blockNumber ) . pipe (
6465 // this does create an issue since it discards all at that block
6566 catchError ( ( ) => of ( null ) )
6667 )
@@ -86,7 +87,7 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
8687 const id = scheduled . maybeId . unwrap ( ) . toHex ( ) ;
8788
8889 if ( id . startsWith ( DEMOCRACY_ID ) ) {
89- const [ , index ] = api . registry . createType < ITuple < [ u64 , ReferendumIndex ] > > ( '(u64, ReferendumIndex)' , id ) ;
90+ const [ , index ] = api . registry . createType ( '(u64, ReferendumIndex)' , id ) ;
9091 const imageHash = scheduled . call . args [ 0 ] as Hash ;
9192
9293 result . push ( { at, imageHash, index } ) ;
0 commit comments