From 9c7360f79696403f703f68805493e7e021e67d00 Mon Sep 17 00:00:00 2001 From: Jaume Alavedra Date: Mon, 30 Dec 2024 20:10:32 +0100 Subject: [PATCH] chore: store owner address from iframe response --- examples/apps/auth-sample/src/hooks/useOpenfort.tsx | 3 --- sdk/src/configuration/account.ts | 6 +++++- sdk/src/iframe/types.ts | 12 +++++++++++- sdk/src/manager/signer.ts | 2 +- sdk/src/openfort.ts | 3 ++- sdk/src/types.ts | 1 + 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/examples/apps/auth-sample/src/hooks/useOpenfort.tsx b/examples/apps/auth-sample/src/hooks/useOpenfort.tsx index 1fd1445..0ba22a8 100644 --- a/examples/apps/auth-sample/src/hooks/useOpenfort.tsx +++ b/examples/apps/auth-sample/src/hooks/useOpenfort.tsx @@ -1,11 +1,8 @@ import { EmbeddedState, ShieldAuthType, - ThirdPartyOAuthProvider, - TokenType, TypedDataDomain, TypedDataField, - type AuthPlayerResponse, type Provider, type RecoveryMethod, type ShieldAuthentication, diff --git a/sdk/src/configuration/account.ts b/sdk/src/configuration/account.ts index 4f9989f..3adc6ed 100644 --- a/sdk/src/configuration/account.ts +++ b/sdk/src/configuration/account.ts @@ -5,12 +5,15 @@ export class Account { address: string; + ownerAddress: string; + chainId: number; - constructor(type: string, address: string, chainId: number) { + constructor(type: string, address: string, chainId: number, ownerAddress: string) { this.type = type; this.address = address; this.chainId = chainId; + this.ownerAddress = ownerAddress; } public static fromStorage(storage: IStorage): Account | null { @@ -24,6 +27,7 @@ export class Account { accountObj.type, accountObj.address, accountObj.chainId, + accountObj.ownerAddress, ); } diff --git a/sdk/src/iframe/types.ts b/sdk/src/iframe/types.ts index 083da4a..c910650 100644 --- a/sdk/src/iframe/types.ts +++ b/sdk/src/iframe/types.ts @@ -349,17 +349,27 @@ export class ConfigureResponse implements IConfigureResponse { accountType: string; + ownerAddress: string; + action: Event = Event.CONFIGURED; version: string | null; - constructor(uuid: string, deviceID: string, accountType: string, chainId: number, address: string) { + constructor( + uuid: string, + deviceID: string, + accountType: string, + chainId: number, + address: string, + ownerAddress: string, + ) { this.success = true; this.deviceID = deviceID; this.uuid = uuid; this.accountType = accountType; this.chainId = chainId; this.address = address; + this.ownerAddress = ownerAddress; this.version = null; } } diff --git a/sdk/src/manager/signer.ts b/sdk/src/manager/signer.ts index 4bbcf34..3d4175c 100644 --- a/sdk/src/manager/signer.ts +++ b/sdk/src/manager/signer.ts @@ -150,7 +150,7 @@ export class SignerManager { SignerManager.storage.save(StorageKeys.SIGNER, JSON.stringify(signerConfiguration)); const resp = await iframeManager.configure(iframeConfiguration); - new Account(resp.accountType, resp.address, resp.chainId).save(this.storage); + new Account(resp.accountType, resp.address, resp.chainId, resp.ownerAddress).save(this.storage); return new EmbeddedSigner(iframeManager, iframeConfiguration, this.storage); } diff --git a/sdk/src/openfort.ts b/sdk/src/openfort.ts index 3b2fd89..d2c06ab 100644 --- a/sdk/src/openfort.ts +++ b/sdk/src/openfort.ts @@ -276,7 +276,7 @@ export class Openfort { * * @returns An AuthResponse object containing authentication details. */ - public async registerGuest(): Promise { + public async signUpGuest(): Promise { const previousAuth = Authentication.fromStorage(this.storage); const result = await this.authManager.registerGuest(); if (previousAuth && previousAuth.player !== result.player.id) { @@ -652,6 +652,7 @@ export class Openfort { return { chainId: account.chainId, address: account.address, + ownerAddress: account.ownerAddress, accountType: account.type as AccountType, }; } diff --git a/sdk/src/types.ts b/sdk/src/types.ts index ec3c157..11524c1 100644 --- a/sdk/src/types.ts +++ b/sdk/src/types.ts @@ -23,6 +23,7 @@ export type SessionKey = { export type CurrentAccount = { address: string; + ownerAddress: string; accountType: AccountType; chainId: number };