Update api.derive to use api.queryMulti (#911)
* session api.queryMulti * Make a single subscription to retrieve all session info * Adjustments * WIP * Seems mostly comprehensive, need to full test e2e * e2e tests for operations * Allow "create from empty" * skip * Remove comment * Remove ancient ?'s * Update types.ts
This commit is contained in:
@@ -45,20 +45,26 @@ export class ReferendumInfoExtended extends ReferendumInfo {
|
||||
}
|
||||
}
|
||||
|
||||
export function constructInfo (index: BN | number, optionInfo?: Option<ReferendumInfo>): Option<ReferendumInfoExtended> {
|
||||
const info = optionInfo
|
||||
? optionInfo.unwrapOr(null)
|
||||
: null;
|
||||
|
||||
return new Option<ReferendumInfoExtended>(
|
||||
ReferendumInfoExtended,
|
||||
isNull(info)
|
||||
? null
|
||||
: new ReferendumInfoExtended(info, index)
|
||||
);
|
||||
}
|
||||
|
||||
export function referendumInfo (api: ApiInterface$Rx) {
|
||||
return (index: BN | number): Observable<Option<ReferendumInfoExtended>> => {
|
||||
return (api.query.democracy.referendumInfoOf(index) as Observable<Option<ReferendumInfo>>)
|
||||
.pipe(
|
||||
map((optionInfo) => {
|
||||
const info = optionInfo.unwrapOr(null);
|
||||
|
||||
return new Option<ReferendumInfoExtended>(
|
||||
ReferendumInfoExtended,
|
||||
isNull(info)
|
||||
? null
|
||||
: new ReferendumInfoExtended(info, index)
|
||||
);
|
||||
}),
|
||||
map((optionInfo) =>
|
||||
constructInfo(index, optionInfo)
|
||||
),
|
||||
drr()
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user