Skip to content

Commit

Permalink
fix: removed the majority of the circular dependencies of the `networ…
Browse files Browse the repository at this point in the history
…k` package (#1379)

* fix: first commit

* fix: first commit

* fix: first commit

* fix: first commit

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: refactor of one of the folders

* fix: some more changes

* fix: some more changes

* fix: some more changes

* fix: some more changes

* fix: some more changes

* fix: as per the tests it should break in the casting

* fix: as per the tests it should break in the casting
  • Loading branch information
freemanzMrojo authored Oct 2, 2024
1 parent 62df51d commit 8ecb124
Show file tree
Hide file tree
Showing 199 changed files with 257 additions and 274 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"scripts": {
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts",
"check:circular-dependencies": "npx madge --exclude 'transaction/Clause.ts' --circular --extensions ts src",
"check:circular-dependencies": "npx madge --circular --extensions ts src",
"lint": "eslint --ext .ts src --ext .ts tests",
"format": "prettier --write src/**/*.ts tests/**/*.ts",
"test:unit": "rm -rf ./coverageUnit && jest --coverage --coverageDirectory=coverageUnit --group=unit",
Expand Down
1 change: 1 addition & 0 deletions packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"start-thor-solo": "echo 'Starting thor solo node ...' && docker compose up -d --wait && echo '\nThor solo node started ...'",
"stop-thor-solo": "echo 'Stopping thor solo node ...' && docker compose down && echo 'Thor solo node stopped ...'",
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts",
"check:circular-dependencies": "npx madge --exclude '^(provider/providers/vechain-provider/vechain-provider.ts|thor-client/contracts/model/contract.ts|thor-client/index.ts|provider/utils/formatter/blocks/index.ts|signer/signers/types.d.ts|provider/utils/helpers/transaction/transaction-helpers.ts|thor-client/contracts/model/contract-filter.ts)$' --circular --extensions ts src",
"lint": "eslint --ext .ts src --ext .ts tests",
"format": "prettier --write src/**/*.ts tests/**/*.ts solo-seeding/**/*.ts",
"test:unit": "rm -rf ./coverageUnit && UNIT=true jest --coverage --coverageDirectory=coverageUnit --group=unit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type ProviderInternalWalletAccount } from '../types';
import { type SignTransactionOptions } from '../../../../thor-client';
import { type SignTransactionOptions } from '../../../../thor-client/transactions/types';
import {
type AvailableVeChainProviders,
type VeChainSigner
} from '../../../../signer';
import { AbstractProviderInternalWallet } from '../abstract-wallet';
} from '../../../../signer/signers/types';
import { AbstractProviderInternalWallet } from '../abstract-wallet/abstract-provider-internal-wallet';

/**
* Provider internal Base wallet class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type SignTransactionOptions } from '../../../thor-client';
import { type SignTransactionOptions } from '../../../thor-client/transactions/types';
import {
type AvailableVeChainProviders,
type VeChainSigner
} from '../../../signer';
} from '../../../signer/signers';

/**
* Represent a single account in a provider internal wallet.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vechain_sdk_core_ethers } from '@vechain/sdk-core';
import { type HardhatVeChainProvider } from '../hardhat-provider';
import { type HardhatVeChainProvider } from '../hardhat-provider/hardhat-provider';
import {
type JsonRpcError,
type JsonRpcPayload,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VeChainProvider } from '../vechain-provider';
import { VeChainProvider } from '../vechain-provider/vechain-provider';
import type { EIP1193RequestArguments } from '../../eip1193';
import {
JSONRPCInternalError,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './vechain-provider';
export { VeChainProvider } from './vechain-provider';
export type * from './types.d';
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { HexInt } from '@vechain/sdk-core';
import {
JSONRPCInvalidParams,
JSONRPCMethodNotFound
} from '@vechain/sdk-errors';
import { EventEmitter } from 'events';
import { type VeChainSigner } from '../../../signer';
import {
type CompressedBlockDetail,
type ThorClient
} from '../../../thor-client';
import { type EventPoll, Poll, vnsUtils } from '../../../utils';
import {
type EIP1193ProviderMessage,
type EIP1193RequestArguments
} from '../../eip1193';
import {
JSONRPCInvalidParams,
JSONRPCMethodNotFound
} from '@vechain/sdk-errors';
import { type ProviderInternalWallet } from '../../helpers';
import {
ethGetLogs,
POLLING_INTERVAL,
Expand All @@ -18,14 +26,6 @@ import {
type SubscriptionEvent,
type SubscriptionManager
} from './types';
import { HexInt } from '@vechain/sdk-core';
import { type EventPoll, Poll, vnsUtils } from '../../../utils';
import {
type CompressedBlockDetail,
type ThorClient
} from '../../../thor-client';
import { type ProviderInternalWallet } from '../../helpers';
import type { VeChainSigner } from '../../../signer';

/**
* Our core provider class for VeChain
Expand Down
2 changes: 1 addition & 1 deletion packages/network/src/provider/utils/const/blocks/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hex } from '@vechain/sdk-core';
import { type BlockQuantityInputRPC } from '../../rpc-mapper';
import { type BlockQuantityInputRPC } from '../../rpc-mapper/types';

/**
* Get the correct block number for the given block number.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type TransactionRPC } from '../transactions';
import { type TransactionRPC } from '../transactions/types';

/**
* Return type of block header for RPC standard.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Hex, HexUInt, Quantity, ZERO_BYTES } from '@vechain/sdk-core';
import {
getNumberOfLogsAheadOfTransactionIntoBlockExpanded,
getTransactionIndexIntoBlock
} from '../../helpers';
} from '../../helpers/transaction/transaction-helpers';
import { blocksFormatter } from '../blocks';
import {
type ExpandedBlockDetail,
Expand Down
2 changes: 1 addition & 1 deletion packages/network/src/provider/utils/rpc-mapper/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './methods-map';
export * from './methods';
export * from './rpc-mapper';
export type * from './types.d';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';
import {
debugTraceTransaction,
type TraceOptionsRPC
} from '../debug_traceTransaction';
import { ethGetBlockByHash } from '../eth_getBlockByHash';
import { type TracerReturnTypeRPC } from '../../../../formatter';
import { type TracerReturnTypeRPC } from '../../../formatter/debug/types';

/**
* RPC Method debug_traceBlockByHash implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';
import {
debugTraceTransaction,
type TraceOptionsRPC
} from '../debug_traceTransaction';
import { type TracerReturnTypeRPC } from '../../../../formatter';
import { type TracerReturnTypeRPC } from '../../../formatter';
import { ethGetBlockByNumber } from '../eth_getBlockByNumber';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import {
type ThorClient,
type TraceReturnType,
type TracerName
} from '../../../../../../thor-client';
import {
JSONRPCInternalError,
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import {
debugFormatter,
type TracerReturnTypeRPC
} from '../../../../formatter';
type ThorClient,
type TraceReturnType,
type TracerName
} from '../../../../../thor-client';
import { debugFormatter, type TracerReturnTypeRPC } from '../../../formatter';

import { RPC_DOCUMENTATION_URL } from '../../../../../utils';
import { type TraceCallRPC, type TransactionObjectInput } from './types';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';

/**
* RPC Method debug_traceCall implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { ThorId } from '@vechain/sdk-core';
import { ethGetTransactionReceipt } from '../eth_getTransactionReceipt';
import {
debugFormatter,
type TracerReturnTypeRPC
} from '../../../../formatter';
import {
InvalidDataType,
JSONRPCInternalError,
Expand All @@ -14,8 +9,10 @@ import {
type ThorClient,
type TraceReturnType,
type TracerName
} from '../../../../../../thor-client';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
} from '../../../../../thor-client';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';
import { debugFormatter, type TracerReturnTypeRPC } from '../../../formatter';
import { ethGetTransactionReceipt } from '../eth_getTransactionReceipt';
import { type TraceOptionsRPC } from './types';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type VeChainProvider } from '../../../../../providers';
import { type VeChainProvider } from '../../../../providers/vechain-provider';

/**
* RPC Method eth_accounts implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JSONRPCInternalError, stringifyData } from '@vechain/sdk-errors';
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';

/**
* RPC Method eth_blockNumber implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import { getCorrectBlockNumberRPCToVeChain } from '../../../../const';
import { getCorrectBlockNumberRPCToVeChain } from '../../../const';
import { type TransactionObjectInput } from './types';
import { type BlockQuantityInputRPC } from '../../../types';
import { type BlockQuantityInputRPC } from '../../types';
import {
type SimulateTransactionClause,
type SimulateTransactionOptions,
type ThorClient
} from '../../../../../../thor-client';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
} from '../../../../../thor-client';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';

/**
* RPC Method eth_call implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';
import {
JSONRPCInternalError,
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import { CHAIN_ID } from '../../../../const';
import { CHAIN_ID } from '../../../const';
import { networkInfo } from '@vechain/sdk-core';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { type TransactionObjectInput } from './types';
import {
type SimulateTransactionClause,
type ThorClient
} from '../../../../../../thor-client';
import { getCorrectBlockNumberRPCToVeChain } from '../../../../const';
import { type BlockQuantityInputRPC } from '../../../types';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
} from '../../../../../thor-client';
import { getCorrectBlockNumberRPCToVeChain } from '../../../const';
import { type BlockQuantityInputRPC } from '../../types';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';

/**
* RPC Method eth_estimateGas implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';

/**
* RPC Method eth_gasPrice implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';
import {
JSONRPCInternalError,
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import type { BlockQuantityInputRPC } from '../../../types';
import { getCorrectBlockNumberRPCToVeChain } from '../../../../const';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
import type { BlockQuantityInputRPC } from '../../types';
import { getCorrectBlockNumberRPCToVeChain } from '../../../const';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';

/**
* RPC Method eth_getBalance implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ThorId } from '@vechain/sdk-core';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';
import { ethGetBlockByNumber } from '../eth_getBlockByNumber';
import {
JSONRPCInternalError,
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import { type BlocksRPC } from '../../../../formatter';
import { type ThorClient } from '../../../../../../thor-client';
import { type BlocksRPC } from '../../../formatter';
import { type ThorClient } from '../../../../../thor-client';

/**
* RPC Method eth_getBlockByHash implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { type ThorClient } from '../../../../../../thor-client';
import {
JSONRPCInternalError,
JSONRPCInvalidParams,
stringifyData
} from '@vechain/sdk-errors';
import { blocksFormatter, type BlocksRPC } from '../../../../formatter';
import { RPCMethodsMap } from '../../../rpc-mapper';
import {
getCorrectBlockNumberRPCToVeChain,
RPC_METHODS
} from '../../../../const';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
import { type ThorClient } from '../../../../../thor-client';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';
import { getCorrectBlockNumberRPCToVeChain } from '../../../const';
import { blocksFormatter, type BlocksRPC } from '../../../formatter';
import { ethChainId } from '../eth_chainId';

/**
* RPC Method eth_getBlockByNumber implementation
Expand Down Expand Up @@ -51,10 +48,9 @@ const ethGetBlockByNumber = async (
let chainId: string = '0x0';

// If the transaction detail flag is set, we need to get the chain id
if (isTxDetail)
chainId = (await RPCMethodsMap(thorClient)[RPC_METHODS.eth_chainId](
[]
)) as string;
if (isTxDetail) {
chainId = await ethChainId(thorClient);
}

const block = isTxDetail
? await thorClient.blocks.getBlockExpanded(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ThorClient } from '../../../../../../thor-client';
import { type ThorClient } from '../../../../../thor-client';
import {
JSONRPCInternalError,
JSONRPCInvalidParams,
Expand All @@ -7,10 +7,10 @@ import {
import {
type TransactionReceiptRPC,
type TransactionRPC
} from '../../../../formatter';
} from '../../../formatter';
import { ethGetBlockByNumber } from '../eth_getBlockByNumber';
import { ethGetTransactionReceipt } from '../eth_getTransactionReceipt';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';

/**
* RPC Method eth_getBlockReceipts implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { ThorClient } from '../../../../../../thor-client';
import type { ThorClient } from '../../../../../thor-client';
import { JSONRPCInvalidParams } from '@vechain/sdk-errors';
import { ethGetBlockByHash } from '../eth_getBlockByHash';
import { ThorId } from '@vechain/sdk-core';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';

/**
* RPC Method eth_getBlockTransactionCountByHash implementation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JSONRPCInvalidParams } from '@vechain/sdk-errors';
import { RPC_DOCUMENTATION_URL } from '../../../../../../utils';
import type { ThorClient } from '../../../../../../thor-client';
import { RPC_DOCUMENTATION_URL } from '../../../../../utils';
import type { ThorClient } from '../../../../../thor-client';
import { ethGetBlockByNumber } from '../eth_getBlockByNumber';

/**
Expand Down
Loading

1 comment on commit 8ecb124

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 97%
97.79% (4171/4265) 95.79% (1366/1426) 97.09% (870/896)
Title Tests Skipped Failures Errors Time
core 782 0 💤 0 ❌ 0 🔥 1m 50s ⏱️
network 731 0 💤 0 ❌ 0 🔥 4m 40s ⏱️
errors 42 0 💤 0 ❌ 0 🔥 18.328s ⏱️

Please sign in to comment.