Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: opportunistic selectedAddress restore #312

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/controllers/TorusController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ export default class TorusController extends BaseController<TorusControllerConfi
const keyState: KeyState = {
priv_key: ecc_privateKey.toString("hex"),
pub_key: ecc_publicKey.toString("hex"),
sol_pub_key: saveState.publicKey,
};

try {
Expand Down Expand Up @@ -1344,9 +1345,12 @@ export default class TorusController extends BaseController<TorusControllerConfi
: {
priv_key: "",
pub_key: "",
sol_pub_key: "",
};

if (keyState.priv_key && keyState.pub_key) {
// opportunistic login
this.preferencesController.setSelectedAddress(keyState.sol_pub_key);
const metadata = await this.storageLayer?.getMetadata({ privKey: new BN(keyState.priv_key, "hex") });

const decryptedState = metadata as OpenLoginBackendState;
Expand Down
1 change: 1 addition & 0 deletions src/utils/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export type OpenLoginPopupResponse = {
export interface KeyState {
priv_key: string;
pub_key: string;
sol_pub_key: string;
}

export interface OpenLoginBackendState {
Expand Down