fix: make entries accept args for double maps (#1864)

This commit is contained in:
Jeremías Díaz
2020-02-15 17:51:01 +01:00
committed by GitHub
parent b069710008
commit 2c3eee4c67
3 changed files with 26 additions and 12 deletions
+9 -1
View File
@@ -77,9 +77,17 @@ function generateModule (allDefs: object, registry: Registry, { name, storage }:
.concat(isStrict ? '' : indent(6)('[index: string]: QueryableStorageEntry<ApiType>;'))
.concat(storage.unwrap().items.map((storageEntry): string => {
const [args, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
let entryType = 'AugmentedQuery';
const entryTypeArgs: string[] = ['ApiType', `(${args}) => Observable<${returnType}>`];
if (storageEntry.type.isDoubleMap) {
entryType = `${entryType}DoubleMap`;
const firstKeyTypes = /^key1: (.*), key2/.exec(args)![1];
entryTypeArgs.push(firstKeyTypes);
}
return createDocComments(6, storageEntry.documentation) +
indent(6)(`${stringLowerFirst(storageEntry.name.toString())}: AugmentedQuery<ApiType, (${args}) => Observable<${returnType}>> & QueryableStorageEntry<ApiType>;`);
indent(6)(`${stringLowerFirst(storageEntry.name.toString())}: ${entryType}<${entryTypeArgs.join(', ')}> & QueryableStorageEntry<ApiType>;`);
}))
.concat([indent(4)('};')]);
}