From b2ed00a758d52093b180a46f99f00c832db59eec Mon Sep 17 00:00:00 2001 From: Stephan Cilliers <5469870+stephancill@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:52:21 +0200 Subject: [PATCH] feat(core): add setstate action --- packages/core/src/manifest.ts | 7 +++++++ packages/core/src/renderer.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/core/src/manifest.ts b/packages/core/src/manifest.ts index 3e47b32c..20bc11ee 100644 --- a/packages/core/src/manifest.ts +++ b/packages/core/src/manifest.ts @@ -130,6 +130,12 @@ type OpenLinkAction = BaseAction & { url: string; }; +type SetStateAction = BaseAction & { + type: "SETSTATE"; + ref: string; + value: string; +}; + export type EthPersonalSignData = { statement: string; version: string; @@ -171,6 +177,7 @@ export type ModAction = | AddEmbedAction | SetInputAction | OpenLinkAction + | SetStateAction | EthPersonalSignAction | SendEthTransactionAction | ExitAction; diff --git a/packages/core/src/renderer.ts b/packages/core/src/renderer.ts index 62551011..a4003c25 100644 --- a/packages/core/src/renderer.ts +++ b/packages/core/src/renderer.ts @@ -272,6 +272,10 @@ export interface OpenLinkActionResolver { events: OpenLinkActionResolverEvents ): void; } +export interface SetStateActionResolver { + ref: string; + value: string; +} export type EthPersonalSignActionResolverInit = { data: EthPersonalSignData; @@ -855,6 +859,11 @@ export class Renderer { }; break; } + case "SETSTATE": { + set(this.refs, action.ref, this.replaceInlineContext(action.value)); + this.onTreeChange(); + break; + } case "web3.eth.personal.sign": { const promise = new Promise((resolve) => { setTimeout(() => {