Skip to content

Commit

Permalink
cleanup variables
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed May 21, 2024
1 parent 35094ad commit 8dc5bf9
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/Web3Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
ADAPTER_EVENTS,
ADAPTER_STATUS,
CHAIN_NAMESPACES,
ChainNamespaceType,
checkIfTokenIsExpired,
CustomChainConfig,
getSavedToken,
Expand Down Expand Up @@ -57,10 +56,6 @@ class Web3Auth extends SafeEventEmitter implements IWeb3Auth {

private privKeyProvider: PrivateKeyProvider | null = null;

private chainConfig: Partial<CustomChainConfig> | null = null;

private currentChainNamespace: ChainNamespaceType;

private sessionManager!: OpenloginSessionManager<SessionData>;

private currentStorage!: BrowserStorage;
Expand Down Expand Up @@ -116,10 +111,8 @@ class Web3Auth extends SafeEventEmitter implements IWeb3Auth {
) {
throw WalletInitializationError.invalidParams("provider should have chainConfig and should be initialized with chainId and chainNamespace");
}
this.chainConfig = this.coreOptions.chainConfig;
this.currentChainNamespace = this.chainConfig.chainNamespace;

const storageKey = `${this.baseStorageKey}_${this.currentChainNamespace === CHAIN_NAMESPACES.SOLANA ? "solana" : "eip"}_${this.coreOptions.usePnPKey ? "pnp" : "core_kit"}`;
const storageKey = `${this.baseStorageKey}_${this.coreOptions.chainConfig.chainNamespace === CHAIN_NAMESPACES.SOLANA ? "solana" : "eip"}_${this.coreOptions.usePnPKey ? "pnp" : "core_kit"}`;
this.currentStorage = BrowserStorage.getInstance(storageKey, this.coreOptions.storageKey);
this.nodeDetailManagerInstance = new NodeDetailManager({ network: this.coreOptions.web3AuthNetwork });
this.authInstance = new Torus({
Expand Down Expand Up @@ -168,7 +161,7 @@ class Web3Auth extends SafeEventEmitter implements IWeb3Auth {
const { userInfo } = this.state;
if (userInfo?.idToken) return { idToken: userInfo.idToken };

const { chainNamespace, chainId } = this.chainConfig || {};
const { chainNamespace, chainId } = this.coreOptions.chainConfig || {};
if (!this.authInstance || !this.privKeyProvider || !this.nodeDetailManagerInstance) throw WalletInitializationError.notReady();
const accounts = await this.privKeyProvider.provider.request<unknown, string[]>({
method: "eth_accounts",
Expand Down Expand Up @@ -380,7 +373,7 @@ class Web3Auth extends SafeEventEmitter implements IWeb3Auth {
const pnpPrivKey = subkey(finalPrivKey, Buffer.from(this.coreOptions.clientId, "base64"));
finalPrivKey = pnpPrivKey.padStart(64, "0");
}
if (this.currentChainNamespace === CHAIN_NAMESPACES.SOLANA) {
if (this.coreOptions.chainConfig.chainNamespace === CHAIN_NAMESPACES.SOLANA) {
if (!this.privKeyProvider.getEd25519Key) {
throw WalletLoginError.fromCode(5000, "Private key provider is not valid, Missing getEd25519Key function");
}
Expand Down

0 comments on commit 8dc5bf9

Please sign in to comment.