Skip to content

Commit

Permalink
Project building
Browse files Browse the repository at this point in the history
  • Loading branch information
arhtudormorar committed Dec 5, 2024
1 parent 1966b1b commit ed1ea42
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/core/providers/ProviderFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class ProviderFactory {

default: {
this._customProviders.forEach(async (customProvider) => {
if (customProvider.name !== type) {
if (customProvider.type === type) {
createdProvider = await customProvider.constructor(config);
createdProvider.getType = () => type;
}
Expand All @@ -128,7 +128,7 @@ export class ProviderFactory {
const dappProvider = new DappProvider(createdProvider);

setAccountProvider(dappProvider);
setProviderType(type);
setProviderType(type as ProviderTypeEnum);

return dappProvider;
}
Expand Down
8 changes: 5 additions & 3 deletions src/core/providers/types/providerFactory.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface IProvider<T extends ProviderTypeEnum = ProviderTypeEnum>
}>;
logout: () => Promise<boolean>;
setShouldShowConsentPopup?: (shouldShow: boolean) => void;
getType: () => T;
getType: () => T[keyof T] | string;
getAddress(): Promise<string | undefined>;
// TODO will be removed as soon as the new login method is implemented in the same way for all providers
getTokenLoginSignature(): string | undefined;
Expand Down Expand Up @@ -52,8 +52,10 @@ export enum ProviderTypeEnum {
none = ''
}

export interface IProviderFactory {
type: ProviderTypeEnum;
export interface IProviderFactory<
T extends ProviderTypeEnum = ProviderTypeEnum
> {
type: T[keyof T];
config?: IProviderConfig;
}

Expand Down
4 changes: 3 additions & 1 deletion src/store/actions/loginInfo/loginInfoActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
import { getStore } from 'store/store';
import { TokenLoginType } from 'types/login.types';

export const setProviderType = (providerType: ProviderTypeEnum) =>
export const setProviderType = <T extends ProviderTypeEnum = ProviderTypeEnum>(
providerType: T
) =>
getStore().setState(({ loginInfo: state }) => {
state.providerType = providerType;
});
Expand Down
6 changes: 4 additions & 2 deletions src/store/actions/sharedActions/sharedActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { resetStore } from 'store/middleware/logoutMiddleware';
import { getStore } from '../../store';

export const logoutAction = () => getStore().setState(resetStore);
export interface LoginActionPayloadType {
export interface LoginActionPayloadType<
T extends ProviderTypeEnum = ProviderTypeEnum
> {
address: string;
providerType: ProviderTypeEnum;
providerType: T[keyof T];
}

export const loginAction = ({
Expand Down
6 changes: 4 additions & 2 deletions src/store/slices/loginInfo/loginInfo.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export interface LoginInfoType {
expires: number;
}

export interface LoginInfoSliceType {
providerType: ProviderTypeEnum | null;
export interface LoginInfoSliceType<
T extends ProviderTypeEnum = ProviderTypeEnum
> {
providerType: T[keyof T] | null;
walletConnectLogin: WalletConnectLoginType | null;
ledgerLogin: LedgerLoginType | null;
tokenLogin: TokenLoginType | null;
Expand Down

0 comments on commit ed1ea42

Please sign in to comment.