Skip to content

Commit

Permalink
chore: store owner address from iframe response
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalavedra committed Dec 30, 2024
1 parent 8a76aac commit 9c7360f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
3 changes: 0 additions & 3 deletions examples/apps/auth-sample/src/hooks/useOpenfort.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
EmbeddedState,
ShieldAuthType,
ThirdPartyOAuthProvider,
TokenType,
TypedDataDomain,
TypedDataField,
type AuthPlayerResponse,
type Provider,
type RecoveryMethod,
type ShieldAuthentication,
Expand Down
6 changes: 5 additions & 1 deletion sdk/src/configuration/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -24,6 +27,7 @@ export class Account {
accountObj.type,
accountObj.address,
accountObj.chainId,
accountObj.ownerAddress,
);
}

Expand Down
12 changes: 11 additions & 1 deletion sdk/src/iframe/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/manager/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/src/openfort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export class Openfort {
*
* @returns An AuthResponse object containing authentication details.
*/
public async registerGuest(): Promise<AuthResponse> {
public async signUpGuest(): Promise<AuthResponse> {
const previousAuth = Authentication.fromStorage(this.storage);
const result = await this.authManager.registerGuest();
if (previousAuth && previousAuth.player !== result.player.id) {
Expand Down Expand Up @@ -652,6 +652,7 @@ export class Openfort {
return {
chainId: account.chainId,
address: account.address,
ownerAddress: account.ownerAddress,
accountType: account.type as AccountType,
};
}
Expand Down
1 change: 1 addition & 0 deletions sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type SessionKey = {

export type CurrentAccount = {
address: string;
ownerAddress: string;
accountType: AccountType;
chainId: number
};
Expand Down

0 comments on commit 9c7360f

Please sign in to comment.