From c790cb59bbfa3bb2e1b3a25ab62b6d7579c61059 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 14 Aug 2019 21:23:48 +0200 Subject: [PATCH] Expand toJSON for storage fn (used in memoizee) (#1311) --- .../api-metadata/src/storage/fromMetadata/createFunction.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/api-metadata/src/storage/fromMetadata/createFunction.ts b/packages/api-metadata/src/storage/fromMetadata/createFunction.ts index 61510df7f4..41b70979b4 100644 --- a/packages/api-metadata/src/storage/fromMetadata/createFunction.ts +++ b/packages/api-metadata/src/storage/fromMetadata/createFunction.ts @@ -100,7 +100,10 @@ export default function createFunction ({ meta, method, prefix, section }: Creat storageFn.method = stringLowerFirst(method); storageFn.prefix = prefix; storageFn.section = section; - storageFn.toJSON = (): any => meta.toJSON(); + + // explicitly add the actual method in the toJSON, this gets used to determine caching and without it + // instances (e.g. collective) will not work since it is only matched on param meta + storageFn.toJSON = (): any => ({ ...(meta.toJSON() as any), storage: { method, prefix, section } }); if (meta.type.isMap && meta.type.asMap.isLinked) { const headHash = new U8a(hasher(`head of ${stringKey}`));