diff --git a/packages/grid_client/src/storage/tfkvstore.ts b/packages/grid_client/src/storage/tfkvstore.ts index df49f9bd36..8ae87690df 100644 --- a/packages/grid_client/src/storage/tfkvstore.ts +++ b/packages/grid_client/src/storage/tfkvstore.ts @@ -15,16 +15,33 @@ class TFKVStoreBackend implements BackendStorageInterface { this.client = new TFClient(url, mnemonic, storeSecret, keypairType); } + private async cleanFragments(key: string, start: number) { + let k = `${key}.${start}`; + let value = await this.client.kvStore.get({ key: k }); + if (!value) { + return []; + } + const extrinsics: SubmittableExtrinsic<"promise", ISubmittableResult>[] = []; + while (value) { + extrinsics.push(await this.client.kvStore.delete({ key: k })); + start++; + k = `${key}.${start}`; + value = await this.client.kvStore.get({ key: k }); + } + return extrinsics; + } + @crop async set(key: string, value: string) { if (!value || value === '""') { return await this.remove(key); } - const extrinsics: SubmittableExtrinsic<"promise", ISubmittableResult>[] = []; + let extrinsics: SubmittableExtrinsic<"promise", ISubmittableResult>[] = []; const splits = this.split(key, value); for (const k of Object.keys(splits)) { extrinsics.push(await this.client.kvStore.set({ key: k, value: splits[k] })); } + extrinsics = extrinsics.concat(await this.cleanFragments(key, Object.keys(splits).length)); return extrinsics; } @@ -52,15 +69,9 @@ class TFKVStoreBackend implements BackendStorageInterface { if (!value) { return; } - let i = 0; - let val = value; - const extrinsics: SubmittableExtrinsic<"promise", ISubmittableResult>[] = []; - while (val) { - extrinsics.push(await this.client.kvStore.delete({ key })); - i++; - key = `${key}.${i}`; - val = await this.client.kvStore.get({ key }); - } + + const extrinsics: SubmittableExtrinsic<"promise", ISubmittableResult>[] = await this.cleanFragments(key, 1); + extrinsics.push(await this.client.kvStore.delete({ key })); return extrinsics; } diff --git a/packages/playground/src/components/copy_input_wrapper.vue b/packages/playground/src/components/copy_input_wrapper.vue index d35dd9cd30..321b13848f 100644 --- a/packages/playground/src/components/copy_input_wrapper.vue +++ b/packages/playground/src/components/copy_input_wrapper.vue @@ -1,9 +1,13 @@ diff --git a/packages/playground/src/components/input_tooltip.vue b/packages/playground/src/components/input_tooltip.vue index 98260297c3..41915b3b65 100644 --- a/packages/playground/src/components/input_tooltip.vue +++ b/packages/playground/src/components/input_tooltip.vue @@ -1,6 +1,6 @@