Skip to content

Commit

Permalink
feat(core): add setstate action
Browse files Browse the repository at this point in the history
  • Loading branch information
stephancill committed Jan 15, 2024
1 parent 1813e71 commit b2ed00a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/core/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -171,6 +177,7 @@ export type ModAction =
| AddEmbedAction
| SetInputAction
| OpenLinkAction
| SetStateAction
| EthPersonalSignAction
| SendEthTransactionAction
| ExitAction;
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ export interface OpenLinkActionResolver {
events: OpenLinkActionResolverEvents
): void;
}
export interface SetStateActionResolver {
ref: string;
value: string;
}

export type EthPersonalSignActionResolverInit = {
data: EthPersonalSignData;
Expand Down Expand Up @@ -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<void>((resolve) => {
setTimeout(() => {
Expand Down

0 comments on commit b2ed00a

Please sign in to comment.