Return array from enumset (#305)
This commit is contained in:
@@ -47,7 +47,16 @@ export default class ApiQueries extends ApiBase {
|
||||
}
|
||||
|
||||
getAccountEnumSet = (index: AccountIndex | BN | number): Observable<Array<AccountId> | undefined> => {
|
||||
return this.rawStorage(storage.balances.enumSet, index);
|
||||
return this
|
||||
.rawStorage(storage.balances.enumSet, index)
|
||||
.pipe(
|
||||
// @ts-ignore After upgrade to 6.3.2
|
||||
map((accounts: Vector<AccountId> = []) =>
|
||||
accounts.map((accountId) =>
|
||||
accountId
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
nextAccountEnumSet = (): Observable<AccountIndex | undefined> => {
|
||||
|
||||
@@ -78,15 +78,15 @@ export default class Vector<
|
||||
}, Compact.encodeU8a(this.length, DEFAULT_LENGTH_BITS).length);
|
||||
}
|
||||
|
||||
filter (fn: (item: T, index?: number) => any): Array<T> {
|
||||
filter (fn: (item: T, index: number) => any): Array<T> {
|
||||
return this.raw.filter(fn);
|
||||
}
|
||||
|
||||
find (fn: (item: T, index?: number) => any): T | undefined {
|
||||
find (fn: (item: T, index: number) => any): T | undefined {
|
||||
return this.raw.find(fn);
|
||||
}
|
||||
|
||||
forEach (fn: (item: T, index?: number) => any): any {
|
||||
forEach (fn: (item: T, index: number) => any): any {
|
||||
return this.raw.forEach(fn);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ export default class Vector<
|
||||
return this.raw[index];
|
||||
}
|
||||
|
||||
map<O> (fn: (item: T, index?: number) => O): Array<O> {
|
||||
map<O> (fn: (item: T, index: number) => O): Array<O> {
|
||||
return this.raw.map(fn);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ export default class Vector<
|
||||
this.raw.push(item);
|
||||
}
|
||||
|
||||
reduce<O> (fn: (result: O, item: T, index?: number) => O, initial: O): O {
|
||||
reduce<O> (fn: (result: O, item: T, index: number) => O, initial: O): O {
|
||||
return this.raw.reduce(fn, initial);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user