diff --git a/examples/starknet-react-next/src/components/DelegateAccount.tsx b/examples/starknet-react-next/src/components/DelegateAccount.tsx index 8772cac9f..9862bbcc5 100644 --- a/examples/starknet-react-next/src/components/DelegateAccount.tsx +++ b/examples/starknet-react-next/src/components/DelegateAccount.tsx @@ -29,7 +29,7 @@ export const DelegateAccount = () => { setDelegateAddress(delegate?.toString() || ""); setIsDelegateSupported(true); } catch (e: any) { - console.log(e) + console.log(e); // controller doesnt support delegateAccount, ignore } }, [account, chainId, cartridgeConnector]); @@ -76,12 +76,16 @@ export const DelegateAccount = () => { type="text" min-width="420px" value={delegateAddressInput} - onChange={(e:any ) => setDelegateAddressInput(e.target.value)} + onChange={(e: any) => setDelegateAddressInput(e.target.value)} /> + +
Not supported!
diff --git a/packages/connector/src/index.ts b/packages/connector/src/index.ts index e0693ea89..a8edcef6c 100644 --- a/packages/connector/src/index.ts +++ b/packages/connector/src/index.ts @@ -68,6 +68,10 @@ class ControllerConnector extends Connector { return await this.controller.delegateAccount(); } + async openSetDelegate(address: string) { + return await this.controller.openSetDelegate(address) + } + async openMenu() { return await this.controller.openMenu(); } diff --git a/packages/controller/src/index.ts b/packages/controller/src/index.ts index 9afc97f27..c7cf58c86 100644 --- a/packages/controller/src/index.ts +++ b/packages/controller/src/index.ts @@ -72,6 +72,20 @@ class Controller { return true; } + async openSetDelegate(address: string) { + if (!this.keychain || !this.modal) { + console.error(new NotReadyToConnect().message); + return null; + } + this.modal.open(); + const res = await this.keychain.openSetDelegate(address); + this.modal.close(); + if (res && (res as ConnectError).code === ResponseCodes.NOT_CONNECTED) { + return false; + } + return true; + } + private initModal() { if (typeof document === "undefined") return; diff --git a/packages/controller/src/types.ts b/packages/controller/src/types.ts index af13f5d32..aa8662c7d 100644 --- a/packages/controller/src/types.ts +++ b/packages/controller/src/types.ts @@ -87,6 +87,7 @@ export interface Keychain { ): Promise