Skip to content

Commit

Permalink
Merge pull request #57 from multiversx/tm/updates/linting
Browse files Browse the repository at this point in the history
Linting
  • Loading branch information
arhtudormorar authored Dec 24, 2024
2 parents 5ebb1d2 + ac09af2 commit a5a14db
Show file tree
Hide file tree
Showing 29 changed files with 88 additions and 425 deletions.
25 changes: 17 additions & 8 deletions src/apiCalls/transactions/getTransactionsByHashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import { TRANSACTIONS_ENDPOINT } from 'apiCalls/endpoints';

import { networkSelector } from 'store/selectors';
import { getState } from 'store/store';
import {
TransactionBatchStatusesEnum,
TransactionServerStatusesEnum
} from 'types/enums.types';
import { ServerTransactionType } from 'types/serverTransactions.types';
import {
GetTransactionsByHashesReturnType,
PendingTransactionsType
Expand All @@ -14,7 +19,7 @@ export const getTransactionsByHashes = async (
const { apiAddress } = networkSelector(getState());
const hashes = pendingTransactions.map((tx) => tx.hash);

const { data: responseData } = await axios.get(
const { data: responseData } = await axios.get<ServerTransactionType[]>(
`${apiAddress}/${TRANSACTIONS_ENDPOINT}`,
{
params: {
Expand All @@ -26,19 +31,23 @@ export const getTransactionsByHashes = async (

return pendingTransactions.map(({ hash, previousStatus }) => {
const txOnNetwork = responseData.find(
(txResponse: any) => txResponse?.txHash === hash //TODO: add NetworkTransactionType
(txResponse: ServerTransactionType) => txResponse?.txHash === hash
);

return {
hash,
data: txOnNetwork?.data,
data: txOnNetwork?.data ?? '',
invalidTransaction: txOnNetwork == null,
status: txOnNetwork?.status,
results: txOnNetwork?.results,
sender: txOnNetwork?.sender,
receiver: txOnNetwork?.receiver,
status: txOnNetwork?.status as
| TransactionServerStatusesEnum
| TransactionBatchStatusesEnum,
results: txOnNetwork?.results ?? [],
sender: txOnNetwork?.sender ?? '',
receiver: txOnNetwork?.receiver ?? '',
previousStatus,
hasStatusChanged: txOnNetwork && txOnNetwork.status !== previousStatus
hasStatusChanged: Boolean(
txOnNetwork && txOnNetwork.status !== previousStatus
)
};
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import {
ILedgerConnectModalData,
LedgerConnectEventsEnum
} from 'core/providers/strategies/LedgerProviderStrategy/types';

export interface IEventBus {
publish(event: string, data: any): void;
}
import { IEventBus } from 'types/manager.types';

const notInitializedError = () => new Error('Event bus not initialized');

export class LedgerConnectStateManager<T extends IEventBus = IEventBus> {
private static instance: LedgerConnectStateManager<IEventBus> | null = null;
export class LedgerConnectStateManager<
T extends
IEventBus<ILedgerConnectModalData> = IEventBus<ILedgerConnectModalData>
> {
private static instance: LedgerConnectStateManager<
IEventBus<ILedgerConnectModalData>
> | null = null;
public readonly addressesPerPage = 10;

private eventBus: T = {
Expand Down Expand Up @@ -64,7 +66,7 @@ export class LedgerConnectStateManager<T extends IEventBus = IEventBus> {
this.resetData();
}

public static getInstance<U extends IEventBus>(
public static getInstance<U extends IEventBus<ILedgerConnectModalData>>(
eventBus?: U
): LedgerConnectStateManager<U> | null {
if (!eventBus) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IEventBus } from 'types/manager.types';
import { NftEnumType } from 'types/tokens.types';
import {
FungibleTransactionType,
Expand All @@ -6,15 +7,15 @@ import {
TokenType
} from './types/signTransactionsModal.types';

interface IEventBus {
publish(event: string, data: any): void;
}

const notInitializedError = () => new Error('Event bus not initialized');

export class SignTransactionsStateManager<T extends IEventBus = IEventBus> {
private static instance: SignTransactionsStateManager<IEventBus> | null =
null;
export class SignTransactionsStateManager<
T extends
IEventBus<ISignTransactionsModalData> = IEventBus<ISignTransactionsModalData>
> {
private static instance: SignTransactionsStateManager<
IEventBus<ISignTransactionsModalData>
> | null = null;
public readonly addressesPerPage = 10;

private eventBus: T = {
Expand All @@ -38,7 +39,7 @@ export class SignTransactionsStateManager<T extends IEventBus = IEventBus> {
this.resetData();
}

public static getInstance<U extends IEventBus>(
public static getInstance<U extends IEventBus<ISignTransactionsModalData>>(
eventBus?: U
): SignTransactionsStateManager<U> | null {
if (!eventBus) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/managers/ToastManager/types/toast.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
TransactionBatchStatusesEnum,
TransactionServerStatusesEnum
} from 'types';
} from 'types/enums.types';

export enum TransactionsDefaultTitles {
success = 'Transaction successful',
Expand Down
4 changes: 1 addition & 3 deletions src/core/managers/TransactionManager/TransactionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ export class TransactionManager {
const parsedTransactions = signedTransactions.map((transaction) =>
this.parseSignedTransaction(transaction)
);
const sessionId = createTrackedTransactionsSession({
transactions: parsedTransactions
});
const sessionId = createTrackedTransactionsSession(parsedTransactions);
if (!options.disableToasts) {
addTransactionToast(sessionId);
}
Expand Down
1 change: 1 addition & 0 deletions src/core/methods/account/getWebviewToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getWindowLocation } from 'utils/window/getWindowLocation';

// TODO: also get from store
// TODO: is this still needed? Maybe drop support and use postMessage
export function getWebviewToken() {
const { search } = getWindowLocation();
const urlSearchParams = new URLSearchParams(search) as any;
Expand Down
3 changes: 3 additions & 0 deletions src/core/methods/initApp/initApp.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ type BaseDappConfigType = {
* If set to `NativeAuthConfigType`, will set the native auth configuration.
*/
nativeAuth?: boolean | NativeAuthConfigType;
/**
* Customize exising providers
*/
providers?: {
crossWindow?: CrossWindowConfig;
walletConnect?: WalletConnectConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import {
TransactionBatchStatusesEnum,
TransactionServerStatusesEnum
} from 'types/enums.types';
import { ServerTransactionType } from 'types/serverTransactions.types';
import { SmartContractResult } from 'types/transactions.types';
import {
ResultType,
ServerTransactionType
} from 'types/serverTransactions.types';

export function manageFailedTransactions({
results,
hash,
sessionId
}: {
results: SmartContractResult[];
results: ResultType[];
hash: string;
sessionId: string;
}) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/providers/DappProvider/DappProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
VerifyMessageReturnType
} from './helpers/signMessage/verifyMessage';
import {
signTransactions,
signTransactionsWithProvider,
SignTransactionsOptionsType
} from './helpers/signTransactions/signTransactions';
} from './helpers/signTransactions/signTransactionsWithProvider';

export class DappProvider {
private provider: IProvider;
Expand Down Expand Up @@ -53,7 +53,7 @@ export class DappProvider {
transactions: Transaction[],
options?: SignTransactionsOptionsType
): Promise<Transaction[]> {
const signedTransactions = await signTransactions({
const signedTransactions = await signTransactionsWithProvider({
provider: this.provider,
transactions,
options
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SignTransactionsType = {
options?: SignTransactionsOptionsType;
};

export async function signTransactions({
export async function signTransactionsWithProvider({
provider,
transactions,
options = {}
Expand Down
2 changes: 0 additions & 2 deletions src/core/providers/helpers/emptyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {
} from 'core/providers/types/providerFactory.types';
import { EngineTypes } from 'utils/walletconnect/__sdkWalletconnectProvider';

export const DAPP_INIT_ROUTE = '/dapp/init';

const notInitializedError = (caller: string) => {
return `Unable to perform ${caller}, Provider not initialized`;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CrossWindowProvider } from 'lib/sdkWebWalletCrossWindowProvider';
import { crossWindowConfigSelector } from 'store/selectors';
import { networkSelector } from 'store/selectors/networkSelectors';
import { getState } from 'store/store';
import { ProviderErrorsEnum } from 'types';
import { ProviderErrorsEnum } from 'types/provider.types';
import { createModalElement } from 'utils/createModalElement';

type CrossWindowProviderProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IProvider } from 'core/providers/types/providerFactory.types';
import { PendingTransactionsModal } from 'lib/sdkDappCoreUi';
import { networkSelector } from 'store/selectors/networkSelectors';
import { getState } from 'store/store';
import { ProviderErrorsEnum } from 'types';
import { ProviderErrorsEnum } from 'types/provider.types';
import { createModalElement } from 'utils/createModalElement';
import { IFrameProviderType } from './types';

Expand Down
Loading

0 comments on commit a5a14db

Please sign in to comment.