Return array from enumset (#305)

This commit is contained in:
Jaco Greeff
2018-10-15 23:48:00 +02:00
committed by GitHub
parent 3f388a3474
commit f31c35e48e
2 changed files with 15 additions and 6 deletions
+10 -1
View File
@@ -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> => {
+5 -5
View File
@@ -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);
}