From bcc0c2f69410c267c072747c4ca36988af6d9427 Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Wed, 5 Apr 2023 14:14:46 +0200 Subject: [PATCH 1/5] move some data-format and contract types to web3-types --- .../web3_plugin_guide/plugin_authors.md | 4 +- .../src/web3_subscription_manager.ts | 4 +- packages/web3-core/src/web3_subscriptions.ts | 3 +- .../unit/web3_subscription_manager.test.ts | 2 +- packages/web3-eth-contract/src/contract.ts | 22 +-- packages/web3-eth-contract/src/encoding.ts | 18 +- .../web3-eth-contract/src/log_subscription.ts | 6 +- packages/web3-eth-contract/src/types.ts | 167 +---------------- packages/web3-eth-contract/src/utils.ts | 10 +- .../web3-eth-contract/test/fixtures/erc20.ts | 4 +- .../web3-eth-contract/test/fixtures/erc721.ts | 4 +- .../test/integration/contract_events.test.ts | 3 +- .../local_account/contract_erc721.test.ts | 3 +- .../contract_overloaded_methods.test.ts | 3 +- packages/web3-eth-ens/src/ens.ts | 8 +- packages/web3-eth-ens/src/registry.ts | 6 +- packages/web3-eth-ens/src/resolver.ts | 6 +- .../test/integration/ens.events.test.ts | 4 +- .../web3-eth-ens/test/integration/ens.test.ts | 4 +- .../test/integration/resolver.test.ts | 4 +- packages/web3-eth-ens/test/unit/ens.test.ts | 4 +- .../src/rpc_method_wrappers.ts | 4 +- .../test/unit/eth_personal.test.ts | 2 +- packages/web3-eth/src/constants.ts | 2 +- packages/web3-eth/src/index.ts | 2 +- packages/web3-eth/src/rpc_method_wrappers.ts | 11 +- packages/web3-eth/src/types.ts | 4 +- .../src/utils/decode_signed_transaction.ts | 9 +- .../src/utils/detect_transaction_type.ts | 4 +- .../web3-eth/src/utils/format_transaction.ts | 11 +- .../web3-eth/src/utils/get_revert_reason.ts | 10 +- .../src/utils/get_transaction_error.ts | 9 +- .../src/utils/get_transaction_gas_pricing.ts | 11 +- .../utils/prepare_transaction_for_signing.ts | 4 +- .../web3-eth/src/utils/transaction_builder.ts | 6 +- .../src/utils/wait_for_transaction_receipt.ts | 5 +- .../src/utils/watch_transaction_by_pooling.ts | 3 +- .../watch_transaction_by_subscription.ts | 3 +- .../watch_transaction_for_confirmations.ts | 3 +- packages/web3-eth/src/validation.ts | 2 +- packages/web3-eth/src/web3_eth.ts | 4 +- .../test/fixtures/detect_transaction_type.ts | 3 +- .../test/fixtures/format_transaction.ts | 3 +- .../test/fixtures/rpc_methods_wrappers.ts | 10 +- .../validate_transaction_for_signing.ts | 3 +- .../web3_eth_methods_with_parameters.ts | 4 +- .../integration/block/rpc.getBlock.test.ts | 3 +- .../block/rpc.getTransactionCount.test.ts | 3 +- .../test/integration/defaults.test.ts | 10 +- .../defaults.transactionBlockTimeout.test.ts | 2 +- packages/web3-eth/test/integration/helper.ts | 9 +- .../web3-eth/test/integration/rpc.test.ts | 15 +- .../integration/watch_transaction.test.ts | 2 +- .../watch_transaction_polling.test.ts | 2 +- .../web3_eth/send_signed_transaction.test.ts | 12 +- .../test/unit/format_transaction.test.ts | 2 +- .../unit/rpc_method_wrappers/call.test.ts | 10 +- .../createAccessList.test.ts | 4 +- .../rpc_method_wrappers/estimate_gas.test.ts | 10 +- .../fixtures/createAccessList.ts | 9 +- .../fixtures/return_formats.ts | 2 +- .../fixtures/sign_transaction.ts | 3 +- .../rpc_method_wrappers/get_balance.test.ts | 10 +- .../rpc_method_wrappers/get_block.test.ts | 11 +- .../get_block_number.test.ts | 4 +- .../get_block_transaction_count.test.ts | 11 +- .../get_block_uncle_count.test.ts | 11 +- .../rpc_method_wrappers/get_chain_id.test.ts | 4 +- .../unit/rpc_method_wrappers/get_code.test.ts | 10 +- .../get_fee_history.test.ts | 10 +- .../rpc_method_wrappers/get_gas_price.test.ts | 4 +- .../rpc_method_wrappers/get_hash_rate.test.ts | 4 +- .../unit/rpc_method_wrappers/get_logs.test.ts | 4 +- .../get_pending_transactions.test.ts | 3 +- .../rpc_method_wrappers/get_proof.test.ts | 10 +- .../get_storage_at.test.ts | 10 +- .../get_transaction.test.ts | 4 +- .../get_transaction_count.test.ts | 10 +- .../get_transaction_from_block.test.ts | 11 +- .../get_transaction_receipt.test.ts | 4 +- .../rpc_method_wrappers/get_uncle.test.ts | 11 +- .../send_signed_transaction.test.ts | 4 +- .../send_transaction.test.ts | 4 +- .../unit/rpc_method_wrappers/sign.test.ts | 4 +- .../sign_transaction.test.ts | 8 +- .../test/unit/utils/get_revert_reason.test.ts | 2 +- .../watch_transaction_by_polling.test.ts | 4 +- ...atch_transaction_for_confirmations.test.ts | 4 +- packages/web3-net/src/net.ts | 3 +- packages/web3-net/src/rpc_method_wrappers.ts | 4 +- .../test/fixtures/rpc_method_wrappers.ts | 2 +- .../test/fixtures/web3_net_methods.ts | 2 +- packages/web3-types/src/data_format_types.ts | 62 +++++++ packages/web3-types/src/eth_contract_types.ts | 175 ++++++++++++++++++ packages/web3-types/src/index.ts | 2 + packages/web3-utils/src/formatter.ts | 46 +---- .../web3-utils/test/fixtures/formatter.ts | 3 +- .../web3-utils/test/unit/formatter.test.ts | 15 +- packages/web3/src/accounts.ts | 4 +- packages/web3/src/web3.ts | 10 +- packages/web3/test/unit/web3.test.ts | 3 +- scripts/system_tests_utils.ts | 3 +- .../src/contract_method_wrappers.ts | 4 +- .../unit/contract_method_wrappers.test.ts | 2 +- 104 files changed, 608 insertions(+), 427 deletions(-) create mode 100644 packages/web3-types/src/data_format_types.ts create mode 100644 packages/web3-types/src/eth_contract_types.ts diff --git a/docs/docs/guides/web3_plugin_guide/plugin_authors.md b/docs/docs/guides/web3_plugin_guide/plugin_authors.md index 147ad337815..146614c1d4e 100644 --- a/docs/docs/guides/web3_plugin_guide/plugin_authors.md +++ b/docs/docs/guides/web3_plugin_guide/plugin_authors.md @@ -156,8 +156,8 @@ A workaround for this issue is available, below is an example of it: import { Web3Context, Web3PluginBase } from 'web3-core'; import { ContractAbi } from 'web3-eth-abi'; import Contract from 'web3-eth-contract'; -import { Address } from 'web3-types'; -import { DataFormat, DEFAULT_RETURN_FORMAT, format } from 'web3-utils'; +import { Address, DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-types'; +import { format } from 'web3-utils'; import { ERC20TokenAbi } from './ERC20Token'; diff --git a/packages/web3-core/src/web3_subscription_manager.ts b/packages/web3-core/src/web3_subscription_manager.ts index e2ca88b9ef0..efc6059f45b 100644 --- a/packages/web3-core/src/web3_subscription_manager.ts +++ b/packages/web3-core/src/web3_subscription_manager.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Web3APISpec } from 'web3-types'; +import { DataFormat, DEFAULT_RETURN_FORMAT, Web3APISpec } from 'web3-types'; import { ProviderError, SubscriptionError } from 'web3-errors'; -import { isNullish, DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { isNullish } from 'web3-utils'; import { isSupportSubscriptions } from './utils'; import { Web3RequestManager, Web3RequestManagerEvent } from './web3_request_manager'; import { Web3SubscriptionConstructor } from './web3_subscriptions'; diff --git a/packages/web3-core/src/web3_subscriptions.ts b/packages/web3-core/src/web3_subscriptions.ts index ef4293ebd82..a2f5d31b5b3 100644 --- a/packages/web3-core/src/web3_subscriptions.ts +++ b/packages/web3-core/src/web3_subscriptions.ts @@ -16,7 +16,6 @@ along with web3.js. If not, see . */ // eslint-disable-next-line max-classes-per-file -import { DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-utils'; import { HexString, BlockOutput, @@ -27,6 +26,8 @@ import { Log, JsonRpcNotification, JsonRpcSubscriptionResult, + DataFormat, + DEFAULT_RETURN_FORMAT, } from 'web3-types'; import { jsonRpc } from 'web3-utils'; import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter'; diff --git a/packages/web3-core/test/unit/web3_subscription_manager.test.ts b/packages/web3-core/test/unit/web3_subscription_manager.test.ts index 4505a814252..cf2d120ddee 100644 --- a/packages/web3-core/test/unit/web3_subscription_manager.test.ts +++ b/packages/web3-core/test/unit/web3_subscription_manager.test.ts @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT } from 'web3-types'; import { Web3RequestManagerEvent } from '../../src/web3_request_manager'; import { Web3SubscriptionManager } from '../../src/web3_subscription_manager'; import { ExampleSubscription } from './fixtures/example_subscription'; diff --git a/packages/web3-eth-contract/src/contract.ts b/packages/web3-eth-contract/src/contract.ts index 567b0738345..6a82e18abe6 100644 --- a/packages/web3-eth-contract/src/contract.ts +++ b/packages/web3-eth-contract/src/contract.ts @@ -63,14 +63,17 @@ import { HexString, LogsInput, Mutable, -} from 'web3-types'; -import { + ContractAbiWithSignature, + ContractEventOptions, + ContractInitOptions, + ContractOptions, + EventLog, + NonPayableCallOptions, + PayableCallOptions, DataFormat, DEFAULT_RETURN_FORMAT, - format, - isDataFormat, - toChecksumAddress, -} from 'web3-utils'; +} from 'web3-types'; +import { format, isDataFormat, toChecksumAddress } from 'web3-utils'; import { isNullish, validator, @@ -83,15 +86,8 @@ import { ALL_EVENTS_ABI } from './constants'; import { decodeEventABI, decodeMethodReturn, encodeEventABI, encodeMethodABI } from './encoding'; import { LogsSubscription } from './log_subscription'; import { - ContractAbiWithSignature, - ContractEventOptions, - ContractInitOptions, - ContractOptions, - EventLog, - NonPayableCallOptions, NonPayableMethodObject, NonPayableTxOptions, - PayableCallOptions, PayableMethodObject, PayableTxOptions, Web3ContractContext, diff --git a/packages/web3-eth-contract/src/encoding.ts b/packages/web3-eth-contract/src/encoding.ts index 7e02f3a4e1b..92b9eed888b 100644 --- a/packages/web3-eth-contract/src/encoding.ts +++ b/packages/web3-eth-contract/src/encoding.ts @@ -15,25 +15,25 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { - DataFormat, - DEFAULT_RETURN_FORMAT, - FMT_BYTES, - FMT_NUMBER, - format, - isNullish, -} from 'web3-utils'; +import { format, isNullish } from 'web3-utils'; import { AbiConstructorFragment, AbiEventFragment, AbiFunctionFragment, + ContractAbiWithSignature, + ContractOptions, + EventLog, LogsInput, BlockNumberOrTag, Filter, HexString, Topic, Numbers, + FMT_NUMBER, + FMT_BYTES, + DataFormat, + DEFAULT_RETURN_FORMAT, } from 'web3-types'; import { @@ -50,8 +50,6 @@ import { import { blockSchema, logSchema } from 'web3-eth'; import { Web3ContractError } from 'web3-errors'; -// eslint-disable-next-line import/no-cycle -import { ContractAbiWithSignature, ContractOptions, EventLog } from './types'; export const encodeEventABI = ( { address }: ContractOptions, diff --git a/packages/web3-eth-contract/src/log_subscription.ts b/packages/web3-eth-contract/src/log_subscription.ts index d2b16834036..f80ab00db6e 100644 --- a/packages/web3-eth-contract/src/log_subscription.ts +++ b/packages/web3-eth-contract/src/log_subscription.ts @@ -15,14 +15,12 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { AbiEventFragment, LogsInput, HexString, Topic } from 'web3-types'; +import { AbiEventFragment, LogsInput, HexString, Topic, DataFormat } from 'web3-types'; import { Web3RequestManager, Web3Subscription } from 'web3-core'; // eslint-disable-next-line import/no-cycle -import { DataFormat } from 'web3-utils'; -// eslint-disable-next-line import/no-cycle +import { ContractAbiWithSignature, EventLog } from 'web3-types'; import { decodeEventABI } from './encoding'; // eslint-disable-next-line import/no-cycle -import { ContractAbiWithSignature, EventLog } from './types'; /** * LogSubscription to be used to subscribe to events logs. diff --git a/packages/web3-eth-contract/src/types.ts b/packages/web3-eth-contract/src/types.ts index 48c9ae94560..89a7ddbcd86 100644 --- a/packages/web3-eth-contract/src/types.ts +++ b/packages/web3-eth-contract/src/types.ts @@ -19,177 +19,20 @@ import { Web3ContextInitOptions, Web3PromiEvent } from 'web3-core'; import { NewHeadsSubscription, SendTransactionEvents } from 'web3-eth'; import { AccessListResult, - AbiFragment, - Address, BlockNumberOrTag, - Bytes, - ContractAbi, EthExecutionAPI, HexString, - HexString32Bytes, Numbers, - SupportedProviders, TransactionReceipt, - Uint, + NonPayableCallOptions, + PayableCallOptions, + DataFormat, + DEFAULT_RETURN_FORMAT, + FormatType, } from 'web3-types'; -import { DataFormat, DEFAULT_RETURN_FORMAT, FormatType } from 'web3-utils'; // eslint-disable-next-line import/no-cycle import { LogsSubscription } from './log_subscription'; -export type { TransactionReceipt } from 'web3-types'; -export type ContractAbiWithSignature = ReadonlyArray; - -export interface EventLog { - readonly event: string; - readonly id?: string; - readonly logIndex?: bigint | number | string; - readonly transactionIndex?: bigint | number | string; - readonly transactionHash?: HexString32Bytes; - readonly blockHash?: HexString32Bytes; - readonly blockNumber?: bigint | number | string; - readonly address: string; - readonly topics: HexString[]; - readonly data: HexString; - readonly raw?: { data: string; topics: unknown[] }; - readonly returnValues: Record; - readonly signature?: HexString; -} - -export interface ContractEventOptions { - /** - * Let you filter events by indexed parameters, e.g. `{filter: {myNumber: [12,13]}}` means all events where `myNumber` is `12` or `13`. - */ - filter?: Record; - /** - * The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as `earliest`, `latest`, `pending`, `safe` or `finalized` can also be used. For specific range use {@link Contract.getPastEvents}. - */ - fromBlock?: BlockNumberOrTag; - /** - * This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as “or” operation between the given nested topics. - */ - topics?: string[]; -} - -export interface ContractOptions { - /** - * The maximum gas provided for a transaction (gas limit). - */ - readonly gas?: Uint; - /** - * The gas price in wei to use for transactions. - */ - readonly gasPrice?: Uint; - /** - * The address transactions should be made from. - */ - readonly from?: Address; - /** - * The byte code of the contract. Used when the contract gets {@link Contract.deploy | deployed} - */ - readonly input?: Bytes; - /** - * The {@doclink glossary/json_interface | json interface} object derived from the [ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) of this contract. - * - * Re-setting this will regenerate the methods and events of the contract instance. - * - * ```ts - * myContract.options.jsonInterface; - * > [{ - * "type":"function", - * "name":"foo", - * "inputs": [{"name":"a","type":"uint256"}], - * "outputs": [{"name":"b","type":"address"}], - * "signature": "0x...", - * },{ - * "type":"event", - * "name":"Event", - * "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}], - * "signature": "0x...", - * }] - * - * // Set a new ABI interface - * // Note: the "signature" of every function and event's ABI is not needed to be provided when assigning. - * // It will be calculated and set automatically inside the setter. - * myContract.options.jsonInterface = [...]; - * ``` - */ - get jsonInterface(): ContractAbiWithSignature; - set jsonInterface(value: ContractAbi); - - /** - * The address used for this contract instance. All transactions generated by web3.js from this contract will contain this address as the `to`. - * - * The address will be stored in lowercase. - * - * ```ts - * myContract.options.address; - * > '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae' - * - * // set a new address - * myContract.options.address = '0x1234FFDD...'; - * ``` - */ - address?: Address; // All transactions generated by web3.js from this contract will contain this address as the "to". -} - -export interface ContractInitOptions { - /** - * The maximum gas provided for a transaction (gas limit). - */ - readonly gas?: Uint; - readonly gasLimit?: Uint; - /** - * The gas price in wei to use for transactions. - */ - readonly gasPrice?: Uint; - /** - * The address transactions should be made from - */ - readonly from?: Address; - /** - * The byte code of the contract. Used when the contract gets {@link Contract.deploy | deployed} - */ - readonly data?: Bytes; - readonly input?: Bytes; - - readonly provider?: SupportedProviders | string; - /** - * If `true`, the defaults of the contract instance will be updated automatically based on the changes of the context used to instantiate the contract. - */ - readonly syncWithContext?: boolean; -} - -export interface NonPayableCallOptions { - nonce?: HexString; - chainId?: HexString; - /** - * The address the call `transaction` should be made from. For calls the `from` property is optional however it is - * highly recommended to explicitly set it or it may default to address(0) depending on your node or provider. - */ - from?: Address; - to?: Address; - data?: HexString; - input?: HexString; - /** - * The maximum gas provided for this call “transaction” (gas limit) - */ - gas?: string; - maxPriorityFeePerGas?: HexString; - maxFeePerGas?: HexString; - /** - * The gas price in wei to use for this call `transaction`. - */ - gasPrice?: string; - type?: string | number; -} - -export interface PayableCallOptions extends NonPayableCallOptions { - /** - * - */ - value?: string; -} - export type NonPayableTxOptions = NonPayableCallOptions; export type PayableTxOptions = PayableCallOptions; diff --git a/packages/web3-eth-contract/src/utils.ts b/packages/web3-eth-contract/src/utils.ts index 250825eaa30..4c41a8a60d3 100644 --- a/packages/web3-eth-contract/src/utils.ts +++ b/packages/web3-eth-contract/src/utils.ts @@ -22,16 +22,14 @@ import { TransactionWithSenderAPI, TransactionCall, HexString, -} from 'web3-types'; -import { isNullish, mergeDeep, toHex } from 'web3-utils'; -import { encodeMethodABI } from './encoding'; -import { NonPayableCallOptions, PayableCallOptions, ContractOptions, - Web3ContractContext, ContractInitOptions, -} from './types'; +} from 'web3-types'; +import { isNullish, mergeDeep, toHex } from 'web3-utils'; +import { encodeMethodABI } from './encoding'; +import { Web3ContractContext } from './types'; export const getSendTxParams = ({ abi, diff --git a/packages/web3-eth-contract/test/fixtures/erc20.ts b/packages/web3-eth-contract/test/fixtures/erc20.ts index cf4b595ec8d..1d20f3eb246 100644 --- a/packages/web3-eth-contract/test/fixtures/erc20.ts +++ b/packages/web3-eth-contract/test/fixtures/erc20.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Address, Numbers } from 'web3-types'; +import { Address, ContractEventOptions, Numbers } from 'web3-types'; import { LogsSubscription } from '../../src/log_subscription'; -import { ContractEventOptions, PayableMethodObject, NonPayableMethodObject } from '../../src/types'; +import { PayableMethodObject, NonPayableMethodObject } from '../../src/types'; export interface Erc20Interface { methods: { diff --git a/packages/web3-eth-contract/test/fixtures/erc721.ts b/packages/web3-eth-contract/test/fixtures/erc721.ts index 36c87289c24..74ebd00749a 100644 --- a/packages/web3-eth-contract/test/fixtures/erc721.ts +++ b/packages/web3-eth-contract/test/fixtures/erc721.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Address, Numbers } from 'web3-types'; +import { Address, ContractEventOptions, Numbers } from 'web3-types'; import { LogsSubscription } from '../../src/log_subscription'; -import { ContractEventOptions, NonPayableMethodObject, PayableMethodObject } from '../../src/types'; +import { NonPayableMethodObject, PayableMethodObject } from '../../src/types'; export interface Erc721Interface { methods: { diff --git a/packages/web3-eth-contract/test/integration/contract_events.test.ts b/packages/web3-eth-contract/test/integration/contract_events.test.ts index 209a918c05f..8b035af8e8b 100644 --- a/packages/web3-eth-contract/test/integration/contract_events.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_events.test.ts @@ -15,7 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Contract, EventLog } from '../../src'; +import { EventLog } from 'web3-types'; +import { Contract } from '../../src'; import { BasicAbi, BasicBytecode } from '../shared_fixtures/build/Basic'; import { processAsync } from '../shared_fixtures/utils'; import { diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts index b9ad5b2ac0d..6741b15e034 100644 --- a/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts +++ b/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts @@ -19,7 +19,8 @@ along with web3.js. If not, see . import Web3 from 'web3'; // eslint-disable-next-line import/no-extraneous-dependencies import { Web3Account } from 'web3-eth-accounts'; -import { Contract, EventLog } from '../../../src'; +import { EventLog } from 'web3-types'; +import { Contract } from '../../../src'; import { ERC721TokenAbi, ERC721TokenBytecode } from '../../shared_fixtures/build/ERC721Token'; import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils'; import { toUpperCaseHex } from '../../shared_fixtures/utils'; diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts index 75e32107d35..e3686798624 100644 --- a/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts +++ b/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts @@ -19,8 +19,9 @@ along with web3.js. If not, see . import Web3 from 'web3'; // eslint-disable-next-line import/no-extraneous-dependencies import { Web3Account } from 'web3-eth-accounts'; +import { EventLog } from 'web3-types'; import { utf8ToHex } from 'web3-utils'; -import { Contract, EventLog } from '../../../src'; +import { Contract } from '../../../src'; import { ERC721TokenAbi, ERC721TokenBytecode } from '../../shared_fixtures/build/ERC721Token'; import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils'; import { toUpperCaseHex } from '../../shared_fixtures/utils'; diff --git a/packages/web3-eth-ens/src/ens.ts b/packages/web3-eth-ens/src/ens.ts index 5466a7e29f5..fbe695f9510 100644 --- a/packages/web3-eth-ens/src/ens.ts +++ b/packages/web3-eth-ens/src/ens.ts @@ -29,9 +29,13 @@ import { EthExecutionAPI, TransactionReceipt, Web3NetAPI, + NonPayableCallOptions, + DEFAULT_RETURN_FORMAT, + FormatType, + FMT_NUMBER, + DataFormat, } from 'web3-types'; -import { DEFAULT_RETURN_FORMAT, FormatType, FMT_NUMBER, DataFormat } from 'web3-utils'; -import { NonPayableCallOptions, Contract } from 'web3-eth-contract'; +import { Contract } from 'web3-eth-contract'; import { PublicResolverAbi } from './abi/ens/PublicResolver'; import { Registry } from './registry'; diff --git a/packages/web3-eth-ens/src/registry.ts b/packages/web3-eth-ens/src/registry.ts index cc24ba7f5a2..6128e6abafc 100644 --- a/packages/web3-eth-ens/src/registry.ts +++ b/packages/web3-eth-ens/src/registry.ts @@ -15,10 +15,10 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Contract, NonPayableCallOptions } from 'web3-eth-contract'; -import { DataFormat, DEFAULT_RETURN_FORMAT, format, sha3Raw } from 'web3-utils'; +import { Contract } from 'web3-eth-contract'; +import { format, sha3Raw } from 'web3-utils'; import { isHexStrict } from 'web3-validator'; -import { Address } from 'web3-types'; +import { Address, DataFormat, DEFAULT_RETURN_FORMAT, NonPayableCallOptions } from 'web3-types'; import { Web3ContextObject } from 'web3-core'; import { ENSRegistryAbi } from './abi/ens/ENSRegistry'; import { PublicResolverAbi } from './abi/ens/PublicResolver'; diff --git a/packages/web3-eth-ens/src/resolver.ts b/packages/web3-eth-ens/src/resolver.ts index 7b669845f35..f8cff758796 100644 --- a/packages/web3-eth-ens/src/resolver.ts +++ b/packages/web3-eth-ens/src/resolver.ts @@ -15,11 +15,11 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { sha3, isNullish, format, DEFAULT_RETURN_FORMAT, DataFormat } from 'web3-utils'; -import { Contract, NonPayableCallOptions } from 'web3-eth-contract'; +import { sha3, isNullish, format } from 'web3-utils'; +import { Contract } from 'web3-eth-contract'; import { ResolverMethodMissingError } from 'web3-errors'; import { isHexStrict } from 'web3-validator'; -import { Address } from 'web3-types'; +import { Address, DataFormat, DEFAULT_RETURN_FORMAT, NonPayableCallOptions } from 'web3-types'; import { interfaceIds, methodsInInterface } from './config'; import { Registry } from './registry'; import { PublicResolverAbi } from './abi/ens/PublicResolver'; diff --git a/packages/web3-eth-ens/test/integration/ens.events.test.ts b/packages/web3-eth-ens/test/integration/ens.events.test.ts index 94333047dd3..ccc34f1160c 100644 --- a/packages/web3-eth-ens/test/integration/ens.events.test.ts +++ b/packages/web3-eth-ens/test/integration/ens.events.test.ts @@ -17,10 +17,10 @@ along with web3.js. If not, see . /* eslint-disable @typescript-eslint/no-unused-vars */ import { Contract, PayableTxOptions } from 'web3-eth-contract'; -import { sha3, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { sha3 } from 'web3-utils'; import { getBlock } from 'web3-eth'; -import { Address, Bytes } from 'web3-types'; +import { Address, Bytes, DEFAULT_RETURN_FORMAT } from 'web3-types'; import { ENS } from '../../src'; import { namehash } from '../../src/utils'; diff --git a/packages/web3-eth-ens/test/integration/ens.test.ts b/packages/web3-eth-ens/test/integration/ens.test.ts index 82433eeb602..cc39fa38303 100644 --- a/packages/web3-eth-ens/test/integration/ens.test.ts +++ b/packages/web3-eth-ens/test/integration/ens.test.ts @@ -17,10 +17,10 @@ along with web3.js. If not, see . /* eslint-disable @typescript-eslint/no-unused-vars */ import { Contract, PayableTxOptions } from 'web3-eth-contract'; -import { sha3, toChecksumAddress, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { sha3, toChecksumAddress } from 'web3-utils'; import { getBlock } from 'web3-eth'; -import { Address, Bytes, TransactionReceipt } from 'web3-types'; +import { Address, Bytes, TransactionReceipt, DEFAULT_RETURN_FORMAT } from 'web3-types'; import { ENS } from '../../src'; import { namehash } from '../../src/utils'; diff --git a/packages/web3-eth-ens/test/integration/resolver.test.ts b/packages/web3-eth-ens/test/integration/resolver.test.ts index 8b50fd89e2c..189770475f9 100644 --- a/packages/web3-eth-ens/test/integration/resolver.test.ts +++ b/packages/web3-eth-ens/test/integration/resolver.test.ts @@ -17,10 +17,10 @@ along with web3.js. If not, see . /* eslint-disable @typescript-eslint/no-unused-vars */ import { Contract, PayableTxOptions } from 'web3-eth-contract'; -import { sha3, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { sha3 } from 'web3-utils'; import Web3Eth from 'web3-eth'; -import { Address, Bytes } from 'web3-types'; +import { Address, Bytes, DEFAULT_RETURN_FORMAT } from 'web3-types'; import { ENS } from '../../src'; import { namehash } from '../../src/utils'; diff --git a/packages/web3-eth-ens/test/unit/ens.test.ts b/packages/web3-eth-ens/test/unit/ens.test.ts index 51da01e984f..42ac36b2ffe 100644 --- a/packages/web3-eth-ens/test/unit/ens.test.ts +++ b/packages/web3-eth-ens/test/unit/ens.test.ts @@ -18,8 +18,8 @@ along with web3.js. If not, see . import { Web3Context, Web3ContextObject, Web3PromiEvent } from 'web3-core'; import { Contract } from 'web3-eth-contract'; import { ENSNetworkNotSyncedError, ENSUnsupportedNetworkError } from 'web3-errors'; -import { sha3Raw, DEFAULT_RETURN_FORMAT } from 'web3-utils'; -import { Block } from 'web3-types'; +import { sha3Raw } from 'web3-utils'; +import { Block, DEFAULT_RETURN_FORMAT } from 'web3-types'; import { registryAddresses } from '../../src/config'; import { PublicResolverAbi } from '../../src/abi/ens/PublicResolver'; diff --git a/packages/web3-eth-personal/src/rpc_method_wrappers.ts b/packages/web3-eth-personal/src/rpc_method_wrappers.ts index ec15d963529..51491714881 100644 --- a/packages/web3-eth-personal/src/rpc_method_wrappers.ts +++ b/packages/web3-eth-personal/src/rpc_method_wrappers.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3RequestManager } from 'web3-core'; -import { ETH_DATA_FORMAT, toChecksumAddress, utf8ToHex } from 'web3-utils'; +import { toChecksumAddress, utf8ToHex } from 'web3-utils'; import { formatTransaction } from 'web3-eth'; -import { Address, EthPersonalAPI, HexString, Transaction } from 'web3-types'; +import { Address, EthPersonalAPI, ETH_DATA_FORMAT, HexString, Transaction } from 'web3-types'; import { validator, isHexStrict } from 'web3-validator'; import { personalRpcMethods } from 'web3-rpc-methods'; diff --git a/packages/web3-eth-personal/test/unit/eth_personal.test.ts b/packages/web3-eth-personal/test/unit/eth_personal.test.ts index 50bb9d3ab12..fc2d545da10 100644 --- a/packages/web3-eth-personal/test/unit/eth_personal.test.ts +++ b/packages/web3-eth-personal/test/unit/eth_personal.test.ts @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { ETH_DATA_FORMAT } from 'web3-utils'; +import { ETH_DATA_FORMAT } from 'web3-types'; import * as utils from 'web3-utils'; import * as eth from 'web3-eth'; import * as validator from 'web3-validator'; diff --git a/packages/web3-eth/src/constants.ts b/packages/web3-eth/src/constants.ts index 28671a898d7..428c7204170 100644 --- a/packages/web3-eth/src/constants.ts +++ b/packages/web3-eth/src/constants.ts @@ -14,6 +14,6 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { FMT_BYTES, FMT_NUMBER } from 'web3-utils'; +import { FMT_BYTES, FMT_NUMBER } from 'web3-types'; export const NUMBER_DATA_FORMAT = { bytes: FMT_BYTES.HEX, number: FMT_NUMBER.NUMBER } as const; diff --git a/packages/web3-eth/src/index.ts b/packages/web3-eth/src/index.ts index 3bdd91ac87e..989e19efe12 100644 --- a/packages/web3-eth/src/index.ts +++ b/packages/web3-eth/src/index.ts @@ -22,7 +22,7 @@ along with web3.js. If not, see . * ```ts * import { Web3Context } from 'web3-core'; * import { BlockTags } from 'web3-types'; - * import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; + * import { DEFAULT_RETURN_FORMAT } from 'web3-types'; * import { getBalance} from 'web3-eth'; * * getBalance( diff --git a/packages/web3-eth/src/rpc_method_wrappers.ts b/packages/web3-eth/src/rpc_method_wrappers.ts index a84e795328d..d2823656462 100644 --- a/packages/web3-eth/src/rpc_method_wrappers.ts +++ b/packages/web3-eth/src/rpc_method_wrappers.ts @@ -45,15 +45,6 @@ import { AccessListResult, } from 'web3-types'; import { Web3Context, Web3PromiEvent } from 'web3-core'; -import { - ETH_DATA_FORMAT, - FormatType, - DataFormat, - DEFAULT_RETURN_FORMAT, - format, - hexToBytes, - bytesToBuffer, -} from 'web3-utils'; import { isBlockTag, isBytes, isNullish, isString } from 'web3-validator'; import { ContractExecutionError, @@ -66,6 +57,8 @@ import { import { ethRpcMethods } from 'web3-rpc-methods'; import defaultImport, * as fullImport from '@ethereumjs/tx'; +import { DataFormat, DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FormatType } from 'web3-types'; +import { bytesToBuffer, format, hexToBytes } from 'web3-utils'; import { decodeSignedTransaction } from './utils/decode_signed_transaction'; import { accountSchema, diff --git a/packages/web3-eth/src/types.ts b/packages/web3-eth/src/types.ts index fc9b5121543..e2adc874ff2 100644 --- a/packages/web3-eth/src/types.ts +++ b/packages/web3-eth/src/types.ts @@ -23,6 +23,9 @@ import { InvalidResponseError, } from 'web3-errors'; import { + FormatType, + ETH_DATA_FORMAT, + DataFormat, Bytes, ContractAbi, HexString, @@ -30,7 +33,6 @@ import { Transaction, TransactionReceipt, } from 'web3-types'; -import { DataFormat, ETH_DATA_FORMAT, FormatType } from 'web3-utils'; export type InternalTransaction = FormatType; diff --git a/packages/web3-eth/src/utils/decode_signed_transaction.ts b/packages/web3-eth/src/utils/decode_signed_transaction.ts index a36879fc255..d77188e7e7f 100644 --- a/packages/web3-eth/src/utils/decode_signed_transaction.ts +++ b/packages/web3-eth/src/utils/decode_signed_transaction.ts @@ -15,8 +15,13 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import defaultImport, * as fullImport from '@ethereumjs/tx'; -import { HexStringBytes, SignedTransactionInfoAPI, TransactionSignedAPI } from 'web3-types'; -import { bytesToHex, DataFormat, format, hexToBytes, keccak256 } from 'web3-utils'; +import { + DataFormat, + HexStringBytes, + SignedTransactionInfoAPI, + TransactionSignedAPI, +} from 'web3-types'; +import { format, hexToBytes, bytesToHex, keccak256 } from 'web3-utils'; import { detectRawTransactionType } from './detect_transaction_type'; import { formatTransaction } from './format_transaction'; diff --git a/packages/web3-eth/src/utils/detect_transaction_type.ts b/packages/web3-eth/src/utils/detect_transaction_type.ts index 2e354cceaa6..9c4eae68e93 100644 --- a/packages/web3-eth/src/utils/detect_transaction_type.ts +++ b/packages/web3-eth/src/utils/detect_transaction_type.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { ETH_DATA_FORMAT, format, toHex } from 'web3-utils'; +import { format, toHex } from 'web3-utils'; import { TransactionTypeParser, Web3Context } from 'web3-core'; -import { EthExecutionAPI, Transaction } from 'web3-types'; +import { EthExecutionAPI, Transaction, ETH_DATA_FORMAT } from 'web3-types'; import { isNullish } from 'web3-validator'; import { InternalTransaction } from '../types'; diff --git a/packages/web3-eth/src/utils/format_transaction.ts b/packages/web3-eth/src/utils/format_transaction.ts index bf5b2894d98..ddc7d9b85a8 100644 --- a/packages/web3-eth/src/utils/format_transaction.ts +++ b/packages/web3-eth/src/utils/format_transaction.ts @@ -15,17 +15,10 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { - bytesToBuffer, - mergeDeep, - DataFormat, - DEFAULT_RETURN_FORMAT, - format, - FormatType, -} from 'web3-utils'; -import { Transaction } from 'web3-types'; +import { Transaction, DataFormat, DEFAULT_RETURN_FORMAT, FormatType } from 'web3-types'; import { isNullish, ValidationSchemaInput } from 'web3-validator'; import { TransactionDataAndInputError } from 'web3-errors'; +import { mergeDeep, bytesToBuffer, format } from 'web3-utils'; import { transactionSchema } from '../schemas'; export function formatTransaction< diff --git a/packages/web3-eth/src/utils/get_revert_reason.ts b/packages/web3-eth/src/utils/get_revert_reason.ts index 095a7e0fc31..fbbe60a132e 100644 --- a/packages/web3-eth/src/utils/get_revert_reason.ts +++ b/packages/web3-eth/src/utils/get_revert_reason.ts @@ -18,8 +18,14 @@ along with web3.js. If not, see . import { Web3Context } from 'web3-core'; import { ContractExecutionError, Eip838ExecutionError, InvalidResponseError } from 'web3-errors'; import { decodeContractErrorData, isAbiErrorFragment } from 'web3-eth-abi'; -import { AbiErrorFragment, ContractAbi, EthExecutionAPI, TransactionCall } from 'web3-types'; -import { DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { + AbiErrorFragment, + ContractAbi, + DataFormat, + DEFAULT_RETURN_FORMAT, + EthExecutionAPI, + TransactionCall, +} from 'web3-types'; // eslint-disable-next-line import/no-cycle import { call } from '../rpc_method_wrappers'; diff --git a/packages/web3-eth/src/utils/get_transaction_error.ts b/packages/web3-eth/src/utils/get_transaction_error.ts index 2623ec53845..a416fa9b1a5 100644 --- a/packages/web3-eth/src/utils/get_transaction_error.ts +++ b/packages/web3-eth/src/utils/get_transaction_error.ts @@ -21,8 +21,13 @@ import { TransactionRevertInstructionError, TransactionRevertWithCustomError, } from 'web3-errors'; -import { ContractAbi, TransactionCall, TransactionReceipt } from 'web3-types'; -import { DataFormat, FormatType } from 'web3-utils'; +import { + DataFormat, + FormatType, + ContractAbi, + TransactionCall, + TransactionReceipt, +} from 'web3-types'; import { RevertReason, RevertReasonWithCustomError } from '../types'; // eslint-disable-next-line import/no-cycle import { getRevertReason, parseTransactionError } from './get_revert_reason'; diff --git a/packages/web3-eth/src/utils/get_transaction_gas_pricing.ts b/packages/web3-eth/src/utils/get_transaction_gas_pricing.ts index af14af48a8b..a1d235f3d63 100644 --- a/packages/web3-eth/src/utils/get_transaction_gas_pricing.ts +++ b/packages/web3-eth/src/utils/get_transaction_gas_pricing.ts @@ -15,11 +15,18 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { FormatType, DataFormat, format, ETH_DATA_FORMAT } from 'web3-utils'; import { Web3Context } from 'web3-core'; -import { EthExecutionAPI, Numbers, Transaction } from 'web3-types'; +import { + EthExecutionAPI, + Numbers, + Transaction, + DataFormat, + FormatType, + ETH_DATA_FORMAT, +} from 'web3-types'; import { isNullish } from 'web3-validator'; import { Eip1559NotSupportedError, UnsupportedTransactionTypeError } from 'web3-errors'; +import { format } from 'web3-utils'; // eslint-disable-next-line import/no-cycle import { getBlock, getGasPrice } from '../rpc_method_wrappers'; import { InternalTransaction } from '../types'; diff --git a/packages/web3-eth/src/utils/prepare_transaction_for_signing.ts b/packages/web3-eth/src/utils/prepare_transaction_for_signing.ts index 2aa99552246..530b6f35968 100644 --- a/packages/web3-eth/src/utils/prepare_transaction_for_signing.ts +++ b/packages/web3-eth/src/utils/prepare_transaction_for_signing.ts @@ -26,9 +26,11 @@ import { PopulatedUnsignedTransaction, Transaction, ValidChains, + FormatType, + ETH_DATA_FORMAT, } from 'web3-types'; import { Web3Context } from 'web3-core'; -import { FormatType, ETH_DATA_FORMAT, toNumber } from 'web3-utils'; +import { toNumber } from 'web3-utils'; import { isNullish } from 'web3-validator'; import { validateTransactionForSigning } from '../validation'; import { formatTransaction } from './format_transaction'; diff --git a/packages/web3-eth/src/utils/transaction_builder.ts b/packages/web3-eth/src/utils/transaction_builder.ts index 22069295f62..76d4615fa13 100644 --- a/packages/web3-eth/src/utils/transaction_builder.ts +++ b/packages/web3-eth/src/utils/transaction_builder.ts @@ -15,7 +15,6 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FormatType, format, DataFormat } from 'web3-utils'; import { EthExecutionAPI, Address, @@ -29,6 +28,10 @@ import { Common, Web3NetAPI, Numbers, + DataFormat, + DEFAULT_RETURN_FORMAT, + FormatType, + ETH_DATA_FORMAT, } from 'web3-types'; import { Web3Context } from 'web3-core'; import { privateKeyToAddress } from 'web3-eth-accounts'; @@ -41,6 +44,7 @@ import { TransactionDataAndInputError, UnableToPopulateNonceError, } from 'web3-errors'; +import { format } from 'web3-utils'; import { NUMBER_DATA_FORMAT } from '../constants'; // eslint-disable-next-line import/no-cycle import { getChainId, getTransactionCount } from '../rpc_method_wrappers'; diff --git a/packages/web3-eth/src/utils/wait_for_transaction_receipt.ts b/packages/web3-eth/src/utils/wait_for_transaction_receipt.ts index 5352b562434..1f66210059c 100644 --- a/packages/web3-eth/src/utils/wait_for_transaction_receipt.ts +++ b/packages/web3-eth/src/utils/wait_for_transaction_receipt.ts @@ -17,9 +17,10 @@ along with web3.js. If not, see . import { Web3Context } from 'web3-core'; import { TransactionPollingTimeoutError } from 'web3-errors'; -import { EthExecutionAPI, Bytes, TransactionReceipt } from 'web3-types'; -import { DataFormat, rejectIfTimeout, pollTillDefined } from 'web3-utils'; +import { EthExecutionAPI, Bytes, TransactionReceipt, DataFormat } from 'web3-types'; +// eslint-disable-next-line import/no-cycle +import { pollTillDefined, rejectIfTimeout } from 'web3-utils'; // eslint-disable-next-line import/no-cycle import { rejectIfBlockTimeout } from './reject_if_block_timeout'; // eslint-disable-next-line import/no-cycle diff --git a/packages/web3-eth/src/utils/watch_transaction_by_pooling.ts b/packages/web3-eth/src/utils/watch_transaction_by_pooling.ts index fb7977a4fec..1c81ed31d3f 100644 --- a/packages/web3-eth/src/utils/watch_transaction_by_pooling.ts +++ b/packages/web3-eth/src/utils/watch_transaction_by_pooling.ts @@ -16,9 +16,10 @@ along with web3.js. If not, see . */ import { Bytes, EthExecutionAPI, TransactionReceipt } from 'web3-types'; import { Web3Context, Web3PromiEvent } from 'web3-core'; -import { DataFormat, format, numberToHex } from 'web3-utils'; +import { format, numberToHex } from 'web3-utils'; import { ethRpcMethods } from 'web3-rpc-methods'; +import { DataFormat } from 'web3-types'; import { SendSignedTransactionEvents, SendTransactionEvents } from '../types'; import { transactionReceiptSchema } from '../schemas'; diff --git a/packages/web3-eth/src/utils/watch_transaction_by_subscription.ts b/packages/web3-eth/src/utils/watch_transaction_by_subscription.ts index d638989d5f8..101c8bb22d6 100644 --- a/packages/web3-eth/src/utils/watch_transaction_by_subscription.ts +++ b/packages/web3-eth/src/utils/watch_transaction_by_subscription.ts @@ -15,8 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Bytes, Numbers, BlockHeaderOutput, TransactionReceipt } from 'web3-types'; -import { DataFormat, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { DataFormat } from 'web3-types'; import { NewHeadsSubscription } from '../web3_subscriptions'; import { transactionReceiptSchema } from '../schemas'; import { WaitProps, watchTransactionByPolling } from './watch_transaction_by_pooling'; diff --git a/packages/web3-eth/src/utils/watch_transaction_for_confirmations.ts b/packages/web3-eth/src/utils/watch_transaction_for_confirmations.ts index 0979b33d936..eb230b28ca4 100644 --- a/packages/web3-eth/src/utils/watch_transaction_for_confirmations.ts +++ b/packages/web3-eth/src/utils/watch_transaction_for_confirmations.ts @@ -16,13 +16,14 @@ along with web3.js. If not, see . */ import { Bytes, EthExecutionAPI, Web3BaseProvider, TransactionReceipt } from 'web3-types'; import { Web3Context, Web3PromiEvent } from 'web3-core'; -import { DataFormat, format } from 'web3-utils'; +import { format } from 'web3-utils'; import { isNullish } from 'web3-validator'; import { TransactionMissingReceiptOrBlockHashError, TransactionReceiptMissingBlockNumberError, } from 'web3-errors'; +import { DataFormat } from 'web3-types'; import { transactionReceiptSchema } from '../schemas'; import { watchTransactionByPolling, diff --git a/packages/web3-eth/src/validation.ts b/packages/web3-eth/src/validation.ts index 9d2f5d8f0bc..9daab4f48cf 100644 --- a/packages/web3-eth/src/validation.ts +++ b/packages/web3-eth/src/validation.ts @@ -25,8 +25,8 @@ import { TransactionLegacyUnsignedAPI, Transaction, TransactionWithSenderAPI, + ETH_DATA_FORMAT, } from 'web3-types'; -import { ETH_DATA_FORMAT } from 'web3-utils'; import { isAddress, isHexStrict, isHexString32Bytes, isNullish, isUInt } from 'web3-validator'; import { ChainMismatchError, diff --git a/packages/web3-eth/src/web3_eth.ts b/packages/web3-eth/src/web3_eth.ts index 293c3b52dcf..3f4738fceb8 100644 --- a/packages/web3-eth/src/web3_eth.ts +++ b/packages/web3-eth/src/web3_eth.ts @@ -35,10 +35,12 @@ import { TransactionWithToLocalWalletIndex, TransactionWithFromAndToLocalWalletIndex, TransactionForAccessList, + DataFormat, + DEFAULT_RETURN_FORMAT, } from 'web3-types'; import { isSupportedProvider, Web3Context, Web3ContextInitOptions } from 'web3-core'; import { TransactionNotFound } from 'web3-errors'; -import { toChecksumAddress, DataFormat, DEFAULT_RETURN_FORMAT, isNullish } from 'web3-utils'; +import { toChecksumAddress, isNullish } from 'web3-utils'; import { ethRpcMethods } from 'web3-rpc-methods'; import * as rpcMethodsWrappers from './rpc_method_wrappers'; diff --git a/packages/web3-eth/test/fixtures/detect_transaction_type.ts b/packages/web3-eth/test/fixtures/detect_transaction_type.ts index 632a3a2244d..37e45d9eb55 100644 --- a/packages/web3-eth/test/fixtures/detect_transaction_type.ts +++ b/packages/web3-eth/test/fixtures/detect_transaction_type.ts @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { ETH_DATA_FORMAT, FormatType } from 'web3-utils'; -import { Transaction } from 'web3-types'; +import { ETH_DATA_FORMAT, FormatType, Transaction } from 'web3-types'; export const transactionType0x0: FormatType[] = [ { diff --git a/packages/web3-eth/test/fixtures/format_transaction.ts b/packages/web3-eth/test/fixtures/format_transaction.ts index 871c885ff3c..93be07fd20a 100644 --- a/packages/web3-eth/test/fixtures/format_transaction.ts +++ b/packages/web3-eth/test/fixtures/format_transaction.ts @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { FMT_BYTES, FMT_NUMBER, FormatType, DEFAULT_RETURN_FORMAT } from 'web3-utils'; -import { Transaction } from 'web3-types'; +import { FormatType, Transaction, DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER } from 'web3-types'; export const bytesAsHexStringTransaction: FormatType< Transaction, diff --git a/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts b/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts index 8b7c72abceb..02f877d9988 100644 --- a/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts +++ b/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts @@ -15,8 +15,14 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, DEFAULT_RETURN_FORMAT, FMT_NUMBER } from 'web3-utils'; -import { Numbers, Uint, TransactionWithSenderAPI } from 'web3-types'; +import { + DataFormat, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + Numbers, + Uint, + TransactionWithSenderAPI, +} from 'web3-types'; // Array consists of: returnType parameter, mock RPC result, expected output export const getHashRateValidData: [DataFormat, Numbers, Numbers][] = [ diff --git a/packages/web3-eth/test/fixtures/validate_transaction_for_signing.ts b/packages/web3-eth/test/fixtures/validate_transaction_for_signing.ts index 7f9f16f1c6a..f22d5ac60cc 100644 --- a/packages/web3-eth/test/fixtures/validate_transaction_for_signing.ts +++ b/packages/web3-eth/test/fixtures/validate_transaction_for_signing.ts @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Transaction } from 'web3-types'; -import { FMT_BYTES, FMT_NUMBER, FormatType } from 'web3-utils'; +import { Transaction, FMT_BYTES, FMT_NUMBER, FormatType } from 'web3-types'; import { ChainIdMismatchError, CommonOrChainAndHardforkError, diff --git a/packages/web3-eth/test/fixtures/web3_eth_methods_with_parameters.ts b/packages/web3-eth/test/fixtures/web3_eth_methods_with_parameters.ts index 5977695a058..5ff78e14f73 100644 --- a/packages/web3-eth/test/fixtures/web3_eth_methods_with_parameters.ts +++ b/packages/web3-eth/test/fixtures/web3_eth_methods_with_parameters.ts @@ -15,8 +15,10 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, DEFAULT_RETURN_FORMAT, FMT_NUMBER } from 'web3-utils'; import { + DataFormat, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, Address, BlockNumberOrTag, BlockTags, diff --git a/packages/web3-eth/test/integration/block/rpc.getBlock.test.ts b/packages/web3-eth/test/integration/block/rpc.getBlock.test.ts index 53892c16c57..1a8cef5851c 100644 --- a/packages/web3-eth/test/integration/block/rpc.getBlock.test.ts +++ b/packages/web3-eth/test/integration/block/rpc.getBlock.test.ts @@ -14,8 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { FMT_BYTES, FMT_NUMBER } from 'web3-utils'; -import { TransactionReceipt, Transaction } from 'web3-types'; +import { TransactionReceipt, Transaction, FMT_BYTES, FMT_NUMBER } from 'web3-types'; // eslint-disable-next-line import/no-extraneous-dependencies import { Contract } from 'web3-eth-contract'; import { validator } from 'web3-validator'; diff --git a/packages/web3-eth/test/integration/block/rpc.getTransactionCount.test.ts b/packages/web3-eth/test/integration/block/rpc.getTransactionCount.test.ts index 140309d8c6b..056967d08a1 100644 --- a/packages/web3-eth/test/integration/block/rpc.getTransactionCount.test.ts +++ b/packages/web3-eth/test/integration/block/rpc.getTransactionCount.test.ts @@ -14,8 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { FMT_BYTES, FMT_NUMBER } from 'web3-utils'; -import { TransactionReceipt } from 'web3-types'; +import { TransactionReceipt, FMT_BYTES, FMT_NUMBER } from 'web3-types'; // eslint-disable-next-line import/no-extraneous-dependencies import { Contract } from 'web3-eth-contract'; import { Web3Eth } from '../../../src'; diff --git a/packages/web3-eth/test/integration/defaults.test.ts b/packages/web3-eth/test/integration/defaults.test.ts index 72d1f334ea2..18fa6e60c98 100644 --- a/packages/web3-eth/test/integration/defaults.test.ts +++ b/packages/web3-eth/test/integration/defaults.test.ts @@ -16,9 +16,15 @@ along with web3.js. If not, see . */ // eslint-disable-next-line import/no-extraneous-dependencies import { Contract } from 'web3-eth-contract'; -import { hexToNumber, numberToHex, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { hexToNumber, numberToHex } from 'web3-utils'; import { TransactionBuilder, TransactionTypeParser, Web3Context, Web3PromiEvent } from 'web3-core'; -import { Hardfork, TransactionReceipt, ValidChains, Web3BaseProvider } from 'web3-types'; +import { + Hardfork, + TransactionReceipt, + ValidChains, + Web3BaseProvider, + DEFAULT_RETURN_FORMAT, +} from 'web3-types'; import { detectTransactionType, prepareTransactionForSigning, diff --git a/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts b/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts index a3eb35fd2ba..67e2bba1718 100644 --- a/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts +++ b/packages/web3-eth/test/integration/defaults.transactionBlockTimeout.test.ts @@ -14,7 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT } from 'web3-types'; import { Web3PromiEvent } from 'web3-core'; import { TransactionReceipt } from 'web3-types'; import { TransactionBlockTimeoutError } from 'web3-errors'; diff --git a/packages/web3-eth/test/integration/helper.ts b/packages/web3-eth/test/integration/helper.ts index ea867af551e..b836e8cded0 100644 --- a/packages/web3-eth/test/integration/helper.ts +++ b/packages/web3-eth/test/integration/helper.ts @@ -14,8 +14,13 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { AbiEventFragment, Block, TransactionInfo, TransactionReceipt } from 'web3-types'; -import { FMT_NUMBER } from 'web3-utils'; +import { + AbiEventFragment, + Block, + TransactionInfo, + TransactionReceipt, + FMT_NUMBER, +} from 'web3-types'; // eslint-disable-next-line import/no-extraneous-dependencies import Web3 from 'web3'; import { BasicAbi } from '../shared_fixtures/build/Basic'; diff --git a/packages/web3-eth/test/integration/rpc.test.ts b/packages/web3-eth/test/integration/rpc.test.ts index 13e4d02c40a..95319cb615a 100644 --- a/packages/web3-eth/test/integration/rpc.test.ts +++ b/packages/web3-eth/test/integration/rpc.test.ts @@ -15,17 +15,16 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { AbiEventFragment, TransactionReceipt, TransactionInfo } from 'web3-types'; -// eslint-disable-next-line import/no-extraneous-dependencies -import { Contract, decodeEventABI } from 'web3-eth-contract'; import { - hexToNumber, - hexToString, - numberToHex, + AbiEventFragment, + TransactionReceipt, + TransactionInfo, FMT_BYTES, FMT_NUMBER, - getStorageSlotNumForLongString, -} from 'web3-utils'; +} from 'web3-types'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { Contract, decodeEventABI } from 'web3-eth-contract'; +import { hexToNumber, hexToString, numberToHex, getStorageSlotNumForLongString } from 'web3-utils'; // eslint-disable-next-line import/no-extraneous-dependencies import { Web3Eth } from '../../src'; diff --git a/packages/web3-eth/test/integration/watch_transaction.test.ts b/packages/web3-eth/test/integration/watch_transaction.test.ts index 995daf46a74..4f3efc82237 100644 --- a/packages/web3-eth/test/integration/watch_transaction.test.ts +++ b/packages/web3-eth/test/integration/watch_transaction.test.ts @@ -14,7 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT } from 'web3-types'; import { TransactionReceipt } from 'web3-types'; import { Web3PromiEvent } from 'web3-core'; import { Web3Account } from 'web3-eth-accounts'; diff --git a/packages/web3-eth/test/integration/watch_transaction_polling.test.ts b/packages/web3-eth/test/integration/watch_transaction_polling.test.ts index ef67ce5bc70..e26b1de47e2 100644 --- a/packages/web3-eth/test/integration/watch_transaction_polling.test.ts +++ b/packages/web3-eth/test/integration/watch_transaction_polling.test.ts @@ -14,7 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT } from 'web3-types'; import { Web3PromiEvent } from 'web3-core'; import { TransactionReceipt } from 'web3-types'; import { Web3Eth, SendTransactionEvents } from '../../src'; diff --git a/packages/web3-eth/test/integration/web3_eth/send_signed_transaction.test.ts b/packages/web3-eth/test/integration/web3_eth/send_signed_transaction.test.ts index 685ec8842bf..99aa95d0197 100644 --- a/packages/web3-eth/test/integration/web3_eth/send_signed_transaction.test.ts +++ b/packages/web3-eth/test/integration/web3_eth/send_signed_transaction.test.ts @@ -19,8 +19,16 @@ along with web3.js. If not, see . // error for Transaction Error Scenarios tests /* eslint-disable jest/no-conditional-expect */ -import { Address, Bytes, SignedTransactionInfoAPI, Transaction } from 'web3-types'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format, hexToNumber } from 'web3-utils'; +import { + Address, + Bytes, + SignedTransactionInfoAPI, + Transaction, + FMT_BYTES, + FMT_NUMBER, + DEFAULT_RETURN_FORMAT, +} from 'web3-types'; +import { format, hexToNumber } from 'web3-utils'; import { isHexStrict } from 'web3-validator'; import { Web3Eth, InternalTransaction, transactionSchema } from '../../../src'; import { diff --git a/packages/web3-eth/test/unit/format_transaction.test.ts b/packages/web3-eth/test/unit/format_transaction.test.ts index b61db25bf88..180649e001c 100644 --- a/packages/web3-eth/test/unit/format_transaction.test.ts +++ b/packages/web3-eth/test/unit/format_transaction.test.ts @@ -14,7 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER } from 'web3-types'; import { formatTransaction } from '../../src/utils/format_transaction'; import { bytesAsHexStringTransaction, diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/call.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/call.test.ts index 963e6308ebc..648f96f4c5b 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/call.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/call.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { + Web3EthExecutionAPI, + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; import { ethRpcMethods } from 'web3-rpc-methods'; import { call } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/createAccessList.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/createAccessList.test.ts index 8aa132c705b..056a32e0d9f 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/createAccessList.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/createAccessList.test.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { Web3EthExecutionAPI, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER } from 'web3-types'; import { isNullish } from 'web3-validator'; -import { ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; import { ethRpcMethods } from 'web3-rpc-methods'; import { createAccessList } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/estimate_gas.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/estimate_gas.test.ts index e34b7c94727..0a68cb8428c 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/estimate_gas.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/estimate_gas.test.ts @@ -16,8 +16,14 @@ along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; import { isNullish } from 'web3-validator'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { estimateGas } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/createAccessList.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/createAccessList.ts index 9876a417447..1984c34c50a 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/createAccessList.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/createAccessList.ts @@ -14,8 +14,13 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { BlockNumberOrTag, BlockTags, TransactionForAccessList } from 'web3-types'; -import { DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { + BlockNumberOrTag, + BlockTags, + DataFormat, + DEFAULT_RETURN_FORMAT, + TransactionForAccessList, +} from 'web3-types'; export const mockRpcResponse = '{"accessList":[{"address":"0x15859bdf5aff2080a9968f6a410361e9598df62f","storageKeys":["0x0000000000000000000000000000000000000000000000000000000000000000"]}],"gasUsed":"0x7671"}'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/return_formats.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/return_formats.ts index 0109e7d093e..4a2f97eab90 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/return_formats.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/return_formats.ts @@ -14,7 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, FMT_BYTES, FMT_NUMBER } from 'web3-utils'; +import { DataFormat, FMT_BYTES, FMT_NUMBER } from 'web3-types'; export const returnFormats: DataFormat[] = [ { number: FMT_NUMBER.NUMBER, bytes: FMT_BYTES.HEX }, diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/sign_transaction.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/sign_transaction.ts index 4ce7e54c155..76b96ca80ed 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/sign_transaction.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/fixtures/sign_transaction.ts @@ -19,8 +19,9 @@ import { SignedTransactionInfoAPI, Transaction, TransactionSignedAPI, + FMT_BYTES, + FMT_NUMBER, } from 'web3-types'; -import { FMT_BYTES, FMT_NUMBER } from 'web3-utils'; import { decodeSignedTransaction } from '../../../../src/utils/decode_signed_transaction'; const rawLegacyTransaction: Transaction = { diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_balance.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_balance.test.ts index d66cfe9d66a..4754ca84ca9 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_balance.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_balance.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getBalance } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block.test.ts index 9820314250c..c5284849cec 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block.test.ts @@ -15,9 +15,16 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Bytes, + Web3EthExecutionAPI, +} from 'web3-types'; import { isBytes, isNullish } from 'web3-validator'; -import { Bytes, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getBlock } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_number.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_number.test.ts index b3a0b6d8907..a6be7406ca5 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_number.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_number.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getBlockNumber } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_transaction_count.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_transaction_count.test.ts index 23318ecbf5f..4dd1a33dd49 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_transaction_count.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_transaction_count.test.ts @@ -15,9 +15,16 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Bytes, + Web3EthExecutionAPI, +} from 'web3-types'; import { isBytes, isNullish } from 'web3-validator'; -import { Bytes, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getBlockTransactionCount } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_uncle_count.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_uncle_count.test.ts index 00fabbf6435..e2d5c0e2d07 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_uncle_count.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_block_uncle_count.test.ts @@ -15,9 +15,16 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Bytes, + Web3EthExecutionAPI, +} from 'web3-types'; import { isBytes, isNullish } from 'web3-validator'; -import { Bytes, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getBlockUncleCount } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_chain_id.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_chain_id.test.ts index c6b258c5747..ca7153130ed 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_chain_id.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_chain_id.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getChainId } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_code.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_code.test.ts index 69446031fad..068a1020cd3 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_code.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_code.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getCode } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_fee_history.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_fee_history.test.ts index 9fe3d81461d..aa005c21ef5 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_fee_history.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_fee_history.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getFeeHistory } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_gas_price.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_gas_price.test.ts index 90d27461fd0..2f226660825 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_gas_price.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_gas_price.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getGasPrice } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_hash_rate.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_hash_rate.test.ts index 5b187d7814b..a1d67dcb9ae 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_hash_rate.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_hash_rate.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getHashRate } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_logs.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_logs.test.ts index ae9b8b48d99..c51c5e5b31c 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_logs.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_logs.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getLogs } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_pending_transactions.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_pending_transactions.test.ts index c13d54627ed..756a2e15fda 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_pending_transactions.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_pending_transactions.test.ts @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getPendingTransactions } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_proof.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_proof.test.ts index df98218aba8..62c16a3c12f 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_proof.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_proof.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getProof } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_storage_at.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_storage_at.test.ts index cfda2820915..0fe677c4a83 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_storage_at.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_storage_at.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getStorageAt } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction.test.ts index d0a0040b0ec..cd0d0576d80 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getTransaction } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_count.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_count.test.ts index a15a3fbf2ab..07a66e2d7ba 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_count.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_count.test.ts @@ -15,9 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Web3EthExecutionAPI, +} from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getTransactionCount } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_from_block.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_from_block.test.ts index 4ae40862e02..22f2f2061e7 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_from_block.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_from_block.test.ts @@ -15,8 +15,15 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Bytes, Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Bytes, + Web3EthExecutionAPI, +} from 'web3-types'; import { isBytes, isNullish } from 'web3-validator'; import { ethRpcMethods } from 'web3-rpc-methods'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_receipt.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_receipt.test.ts index cce0ab95ef3..0cd87410794 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_receipt.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_transaction_receipt.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getTransactionReceipt } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/get_uncle.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/get_uncle.test.ts index d7e23fdc2ca..da0c73ac0fb 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/get_uncle.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/get_uncle.test.ts @@ -15,9 +15,16 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { + ETH_DATA_FORMAT, + DEFAULT_RETURN_FORMAT, + FMT_NUMBER, + FMT_BYTES, + Bytes, + Web3EthExecutionAPI, +} from 'web3-types'; import { isBytes, isNullish } from 'web3-validator'; -import { Bytes, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { getUncle } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/send_signed_transaction.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/send_signed_transaction.test.ts index 9e2589ebd92..5b6254d3c69 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/send_signed_transaction.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/send_signed_transaction.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { sendSignedTransaction } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/send_transaction.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/send_transaction.test.ts index d381dc1d104..3be8182cd33 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/send_transaction.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/send_transaction.test.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, format } from 'web3-utils'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT, Web3EthExecutionAPI } from 'web3-types'; import { isNullish } from 'web3-validator'; -import { Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { sendTransaction } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/sign.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/sign.test.ts index 840dd86d12a..3ff4a2414bb 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/sign.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/sign.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { sign } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/rpc_method_wrappers/sign_transaction.test.ts b/packages/web3-eth/test/unit/rpc_method_wrappers/sign_transaction.test.ts index 8ad54c0166a..68364142d32 100644 --- a/packages/web3-eth/test/unit/rpc_method_wrappers/sign_transaction.test.ts +++ b/packages/web3-eth/test/unit/rpc_method_wrappers/sign_transaction.test.ts @@ -15,9 +15,13 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, ETH_DATA_FORMAT } from 'web3-utils'; +import { + DEFAULT_RETURN_FORMAT, + ETH_DATA_FORMAT, + SignedTransactionInfoAPI, + Web3EthExecutionAPI, +} from 'web3-types'; import { isString } from 'web3-validator'; -import { SignedTransactionInfoAPI, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { signTransaction } from '../../../src/rpc_method_wrappers'; diff --git a/packages/web3-eth/test/unit/utils/get_revert_reason.test.ts b/packages/web3-eth/test/unit/utils/get_revert_reason.test.ts index 7ae0b6493b0..061837f4c54 100644 --- a/packages/web3-eth/test/unit/utils/get_revert_reason.test.ts +++ b/packages/web3-eth/test/unit/utils/get_revert_reason.test.ts @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT } from 'web3-types'; import * as RpcMethodWrappers from '../../../src/rpc_method_wrappers'; import * as GetRevertReason from '../../../src/utils/get_revert_reason'; diff --git a/packages/web3-eth/test/unit/utils/watch_transaction_by_polling.test.ts b/packages/web3-eth/test/unit/utils/watch_transaction_by_polling.test.ts index 12d63a2cc77..5a44db457e8 100644 --- a/packages/web3-eth/test/unit/utils/watch_transaction_by_polling.test.ts +++ b/packages/web3-eth/test/unit/utils/watch_transaction_by_polling.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, format } from 'web3-utils'; -import { Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import * as rpcMethodWrappers from '../../../src/rpc_method_wrappers'; import * as WaitForTransactionReceipt from '../../../src/utils/wait_for_transaction_receipt'; diff --git a/packages/web3-eth/test/unit/utils/watch_transaction_for_confirmations.test.ts b/packages/web3-eth/test/unit/utils/watch_transaction_for_confirmations.test.ts index 2072381a42e..21f630c8bd1 100644 --- a/packages/web3-eth/test/unit/utils/watch_transaction_for_confirmations.test.ts +++ b/packages/web3-eth/test/unit/utils/watch_transaction_for_confirmations.test.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { Web3Context, Web3PromiEvent } from 'web3-core'; -import { DEFAULT_RETURN_FORMAT, format } from 'web3-utils'; -import { TransactionReceipt, Web3EthExecutionAPI } from 'web3-types'; +import { format } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT, TransactionReceipt, Web3EthExecutionAPI } from 'web3-types'; import { ethRpcMethods } from 'web3-rpc-methods'; import { TransactionMissingReceiptOrBlockHashError, diff --git a/packages/web3-net/src/net.ts b/packages/web3-net/src/net.ts index 311f3cf0bc5..b5ea60f6c2a 100644 --- a/packages/web3-net/src/net.ts +++ b/packages/web3-net/src/net.ts @@ -14,9 +14,8 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, DEFAULT_RETURN_FORMAT } from 'web3-utils'; import { Web3Context } from 'web3-core'; -import { Web3NetAPI } from 'web3-types'; +import { DataFormat, DEFAULT_RETURN_FORMAT, Web3NetAPI } from 'web3-types'; import * as rpcMethodsWrappers from './rpc_method_wrappers'; diff --git a/packages/web3-net/src/rpc_method_wrappers.ts b/packages/web3-net/src/rpc_method_wrappers.ts index 6ba1a37d958..0a1fd618011 100644 --- a/packages/web3-net/src/rpc_method_wrappers.ts +++ b/packages/web3-net/src/rpc_method_wrappers.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, format } from 'web3-utils'; +import { format } from 'web3-utils'; import { Web3Context } from 'web3-core'; -import { Web3NetAPI } from 'web3-types'; +import { DataFormat, Web3NetAPI } from 'web3-types'; import { netRpcMethods } from 'web3-rpc-methods'; export async function getId( diff --git a/packages/web3-net/test/fixtures/rpc_method_wrappers.ts b/packages/web3-net/test/fixtures/rpc_method_wrappers.ts index 123ce56e437..0e76bcdd39b 100644 --- a/packages/web3-net/test/fixtures/rpc_method_wrappers.ts +++ b/packages/web3-net/test/fixtures/rpc_method_wrappers.ts @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, FMT_BYTES, FMT_NUMBER } from 'web3-utils'; +import { DataFormat, FMT_BYTES, FMT_NUMBER } from 'web3-types'; export const getIdValidData: [DataFormat, any, any][] = [ [{ number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX }, '3', '0x3'], diff --git a/packages/web3-net/test/fixtures/web3_net_methods.ts b/packages/web3-net/test/fixtures/web3_net_methods.ts index 3d74b3f9d5a..cd79009ffd4 100644 --- a/packages/web3-net/test/fixtures/web3_net_methods.ts +++ b/packages/web3-net/test/fixtures/web3_net_methods.ts @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { DataFormat, FMT_BYTES, FMT_NUMBER } from 'web3-utils'; +import { DataFormat, FMT_BYTES, FMT_NUMBER } from 'web3-types'; export const getDataFormat: DataFormat[] = [ { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX }, diff --git a/packages/web3-types/src/data_format_types.ts b/packages/web3-types/src/data_format_types.ts new file mode 100644 index 00000000000..e7c4b7aaa30 --- /dev/null +++ b/packages/web3-types/src/data_format_types.ts @@ -0,0 +1,62 @@ +/* +This file is part of web3.js. + +web3.js is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +web3.js is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with web3.js. If not, see . +*/ + +import { Bytes, HexString, Numbers } from './primitives_types'; + +export enum FMT_NUMBER { + NUMBER = 'NUMBER_NUMBER', + HEX = 'NUMBER_HEX', + STR = 'NUMBER_STR', + BIGINT = 'NUMBER_BIGINT', +} + +export type NumberTypes = { + [FMT_NUMBER.NUMBER]: number; + [FMT_NUMBER.HEX]: HexString; + [FMT_NUMBER.STR]: string; + [FMT_NUMBER.BIGINT]: bigint; +}; + +export enum FMT_BYTES { + HEX = 'BYTES_HEX', + BUFFER = 'BYTES_BUFFER', + UINT8ARRAY = 'BYTES_UINT8ARRAY', +} + +export type ByteTypes = { + [FMT_BYTES.HEX]: HexString; + [FMT_BYTES.BUFFER]: Buffer; + [FMT_BYTES.UINT8ARRAY]: Uint8Array; +}; + +export type DataFormat = { + readonly number: FMT_NUMBER; + readonly bytes: FMT_BYTES; +}; + +export const DEFAULT_RETURN_FORMAT = { number: FMT_NUMBER.BIGINT, bytes: FMT_BYTES.HEX } as const; +export const ETH_DATA_FORMAT = { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX } as const; + +export type FormatType = number extends Extract + ? NumberTypes[F['number']] | Exclude + : Buffer extends Extract + ? ByteTypes[F['bytes']] | Exclude + : T extends object | undefined + ? { + [P in keyof T]: FormatType; + } + : T; diff --git a/packages/web3-types/src/eth_contract_types.ts b/packages/web3-types/src/eth_contract_types.ts new file mode 100644 index 00000000000..1646ebb8dfc --- /dev/null +++ b/packages/web3-types/src/eth_contract_types.ts @@ -0,0 +1,175 @@ +/* +This file is part of web3.js. + +web3.js is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +web3.js is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with web3.js. If not, see . +*/ + +import { Address, BlockNumberOrTag, HexString32Bytes, Uint } from './eth_types'; +import { AbiFragment, ContractAbi } from './eth_abi_types'; +import { SupportedProviders } from './web3_base_provider'; +import { Bytes, HexString } from './primitives_types'; +import { EthExecutionAPI } from './apis/eth_execution_api'; + +export type ContractAbiWithSignature = ReadonlyArray; + +export interface EventLog { + readonly event: string; + readonly id?: string; + readonly logIndex?: bigint | number | string; + readonly transactionIndex?: bigint | number | string; + readonly transactionHash?: HexString32Bytes; + readonly blockHash?: HexString32Bytes; + readonly blockNumber?: bigint | number | string; + readonly address: string; + readonly topics: HexString[]; + readonly data: HexString; + readonly raw?: { data: string; topics: unknown[] }; + readonly returnValues: Record; + readonly signature?: HexString; +} + +export interface ContractEventOptions { + /** + * Let you filter events by indexed parameters, e.g. `{filter: {myNumber: [12,13]}}` means all events where `myNumber` is `12` or `13`. + */ + filter?: Record; + /** + * The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as `earliest`, `latest`, `pending`, `safe` or `finalized` can also be used. For specific range use {@link Contract.getPastEvents}. + */ + fromBlock?: BlockNumberOrTag; + /** + * This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as “or” operation between the given nested topics. + */ + topics?: string[]; +} + +export interface ContractOptions { + /** + * The maximum gas provided for a transaction (gas limit). + */ + readonly gas?: Uint; + /** + * The gas price in wei to use for transactions. + */ + readonly gasPrice?: Uint; + /** + * The address transactions should be made from. + */ + readonly from?: Address; + /** + * The byte code of the contract. Used when the contract gets {@link Contract.deploy | deployed} + */ + readonly input?: Bytes; + /** + * The {@doclink glossary/json_interface | json interface} object derived from the [ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) of this contract. + * + * Re-setting this will regenerate the methods and events of the contract instance. + * + * ```ts + * myContract.options.jsonInterface; + * > [{ + * "type":"function", + * "name":"foo", + * "inputs": [{"name":"a","type":"uint256"}], + * "outputs": [{"name":"b","type":"address"}], + * "signature": "0x...", + * },{ + * "type":"event", + * "name":"Event", + * "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}], + * "signature": "0x...", + * }] + * + * // Set a new ABI interface + * // Note: the "signature" of every function and event's ABI is not needed to be provided when assigning. + * // It will be calculated and set automatically inside the setter. + * myContract.options.jsonInterface = [...]; + * ``` + */ + get jsonInterface(): ContractAbiWithSignature; + set jsonInterface(value: ContractAbi); + + /** + * The address used for this contract instance. All transactions generated by web3.js from this contract will contain this address as the `to`. + * + * The address will be stored in lowercase. + * + * ```ts + * myContract.options.address; + * > '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae' + * + * // set a new address + * myContract.options.address = '0x1234FFDD...'; + * ``` + */ + address?: Address; // All transactions generated by web3.js from this contract will contain this address as the "to". +} + +export interface ContractInitOptions { + /** + * The maximum gas provided for a transaction (gas limit). + */ + readonly gas?: Uint; + readonly gasLimit?: Uint; + /** + * The gas price in wei to use for transactions. + */ + readonly gasPrice?: Uint; + /** + * The address transactions should be made from + */ + readonly from?: Address; + /** + * The byte code of the contract. Used when the contract gets {@link Contract.deploy | deployed} + */ + readonly data?: Bytes; + readonly input?: Bytes; + + readonly provider?: SupportedProviders | string; + /** + * If `true`, the defaults of the contract instance will be updated automatically based on the changes of the context used to instantiate the contract. + */ + readonly syncWithContext?: boolean; +} + +export interface NonPayableCallOptions { + nonce?: HexString; + chainId?: HexString; + /** + * The address the call `transaction` should be made from. For calls the `from` property is optional however it is + * highly recommended to explicitly set it or it may default to address(0) depending on your node or provider. + */ + from?: Address; + to?: Address; + data?: HexString; + input?: HexString; + /** + * The maximum gas provided for this call “transaction” (gas limit) + */ + gas?: string; + maxPriorityFeePerGas?: HexString; + maxFeePerGas?: HexString; + /** + * The gas price in wei to use for this call `transaction`. + */ + gasPrice?: string; + type?: string | number; +} + +export interface PayableCallOptions extends NonPayableCallOptions { + /** + * + */ + value?: string; +} diff --git a/packages/web3-types/src/index.ts b/packages/web3-types/src/index.ts index 5756acbdb65..7036bfd397f 100644 --- a/packages/web3-types/src/index.ts +++ b/packages/web3-types/src/index.ts @@ -20,8 +20,10 @@ export * from './apis/eth_execution_api'; export * from './apis/web3_eth_execution_api'; export * from './apis/web3_net_api'; export * from './apis/eth_personal_api'; +export * from './data_format_types'; export * from './eth_types'; export * from './eth_abi_types'; +export * from './eth_contract_types'; export * from './json_rpc_types'; export * from './primitives_types'; export * from './utility_types'; diff --git a/packages/web3-utils/src/formatter.ts b/packages/web3-utils/src/formatter.ts index 16cb74958d9..db6960154a3 100644 --- a/packages/web3-utils/src/formatter.ts +++ b/packages/web3-utils/src/formatter.ts @@ -15,63 +15,19 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import { FormatterError } from 'web3-errors'; -import { Bytes, HexString, Numbers } from 'web3-types'; +import { Bytes, DataFormat, FMT_BYTES, FMT_NUMBER, FormatType } from 'web3-types'; import { isNullish, isObject, JsonSchema, utils, ValidationSchemaInput } from 'web3-validator'; import { bytesToBuffer, bytesToHex, numberToHex, toBigInt } from './converters'; import { mergeDeep } from './objects'; const { parseBaseType } = utils; -export enum FMT_NUMBER { - NUMBER = 'NUMBER_NUMBER', - HEX = 'NUMBER_HEX', - STR = 'NUMBER_STR', - BIGINT = 'NUMBER_BIGINT', -} - -export type NumberTypes = { - [FMT_NUMBER.NUMBER]: number; - [FMT_NUMBER.HEX]: HexString; - [FMT_NUMBER.STR]: string; - [FMT_NUMBER.BIGINT]: bigint; -}; - -export enum FMT_BYTES { - HEX = 'BYTES_HEX', - BUFFER = 'BYTES_BUFFER', - UINT8ARRAY = 'BYTES_UINT8ARRAY', -} - -export type ByteTypes = { - [FMT_BYTES.HEX]: HexString; - [FMT_BYTES.BUFFER]: Buffer; - [FMT_BYTES.UINT8ARRAY]: Uint8Array; -}; - -export type DataFormat = { - readonly number: FMT_NUMBER; - readonly bytes: FMT_BYTES; -}; - -export const DEFAULT_RETURN_FORMAT = { number: FMT_NUMBER.BIGINT, bytes: FMT_BYTES.HEX } as const; -export const ETH_DATA_FORMAT = { number: FMT_NUMBER.HEX, bytes: FMT_BYTES.HEX } as const; - export const isDataFormat = (dataFormat: unknown): dataFormat is DataFormat => typeof dataFormat === 'object' && !isNullish(dataFormat) && 'number' in dataFormat && 'bytes' in dataFormat; -export type FormatType = number extends Extract - ? NumberTypes[F['number']] | Exclude - : Buffer extends Extract - ? ByteTypes[F['bytes']] | Exclude - : T extends object | undefined - ? { - [P in keyof T]: FormatType; - } - : T; - /** * Finds the schema that corresponds to a specific data path within a larger JSON schema. * It works by iterating over the dataPath array and traversing the JSON schema one step at a time until it reaches the end of the path. diff --git a/packages/web3-utils/test/fixtures/formatter.ts b/packages/web3-utils/test/fixtures/formatter.ts index b28d3dd5b1a..02c9567a2ef 100644 --- a/packages/web3-utils/test/fixtures/formatter.ts +++ b/packages/web3-utils/test/fixtures/formatter.ts @@ -14,7 +14,8 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { FMT_NUMBER, FMT_BYTES } from '../../src/formatter'; + +import { FMT_NUMBER, FMT_BYTES } from 'web3-types'; export const isDataFormatValid: [any, boolean][] = [ [{ number: 'number', bytes: 'number' }, true], diff --git a/packages/web3-utils/test/unit/formatter.test.ts b/packages/web3-utils/test/unit/formatter.test.ts index 3a95a4d3872..38171943a5b 100644 --- a/packages/web3-utils/test/unit/formatter.test.ts +++ b/packages/web3-utils/test/unit/formatter.test.ts @@ -14,18 +14,19 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Address, Bytes, HexString, Numbers } from 'web3-types'; -import { expectTypeOf, typecheck } from '@humeris/espresso-shot'; -import { isDataFormatValid, convertScalarValueValid } from '../fixtures/formatter'; import { + Address, + Bytes, DEFAULT_RETURN_FORMAT, FMT_BYTES, FMT_NUMBER, - format, FormatType, - isDataFormat, - convertScalarValue, -} from '../../src/formatter'; + HexString, + Numbers, +} from 'web3-types'; +import { expectTypeOf, typecheck } from '@humeris/espresso-shot'; +import { isDataFormatValid, convertScalarValueValid } from '../fixtures/formatter'; +import { format, isDataFormat, convertScalarValue } from '../../src/formatter'; type TestTransactionInfoType = { readonly blockHash?: Bytes; diff --git a/packages/web3/src/accounts.ts b/packages/web3/src/accounts.ts index 040368fcfc4..1078b224319 100644 --- a/packages/web3/src/accounts.ts +++ b/packages/web3/src/accounts.ts @@ -15,8 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { EthExecutionAPI, Bytes, Transaction, KeyStore } from 'web3-types'; -import { ETH_DATA_FORMAT, format } from 'web3-utils'; +import { EthExecutionAPI, Bytes, Transaction, KeyStore, ETH_DATA_FORMAT } from 'web3-types'; +import { format } from 'web3-utils'; import { Web3Context } from 'web3-core'; import { prepareTransactionForSigning } from 'web3-eth'; import { diff --git a/packages/web3/src/web3.ts b/packages/web3/src/web3.ts index 5e7c63fb7d2..9e939c16f99 100644 --- a/packages/web3/src/web3.ts +++ b/packages/web3/src/web3.ts @@ -17,14 +17,20 @@ along with web3.js. If not, see . // eslint-disable-next-line max-classes-per-file import { Web3Context } from 'web3-core'; import Web3Eth, { registeredSubscriptions } from 'web3-eth'; -import Contract, { ContractInitOptions } from 'web3-eth-contract'; +import Contract from 'web3-eth-contract'; import { ENS, registryAddresses } from 'web3-eth-ens'; import Iban from 'web3-eth-iban'; import Personal from 'web3-eth-personal'; import Net from 'web3-net'; import * as utils from 'web3-utils'; import { isNullish } from 'web3-utils'; -import { Address, ContractAbi, EthExecutionAPI, SupportedProviders } from 'web3-types'; +import { + Address, + ContractAbi, + ContractInitOptions, + EthExecutionAPI, + SupportedProviders, +} from 'web3-types'; import { InvalidMethodParamsError } from 'web3-errors'; import abi from './abi'; import { initAccountsForContext } from './accounts'; diff --git a/packages/web3/test/unit/web3.test.ts b/packages/web3/test/unit/web3.test.ts index 2876c340ec8..3d520f38e36 100644 --- a/packages/web3/test/unit/web3.test.ts +++ b/packages/web3/test/unit/web3.test.ts @@ -15,7 +15,8 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Contract, ContractInitOptions } from 'web3-eth-contract'; +import { Contract } from 'web3-eth-contract'; +import { ContractInitOptions } from 'web3-types'; import { Web3 } from '../../src/web3'; describe('Web3 object', () => { diff --git a/scripts/system_tests_utils.ts b/scripts/system_tests_utils.ts index a4d7227a02b..3446602f18c 100644 --- a/scripts/system_tests_utils.ts +++ b/scripts/system_tests_utils.ts @@ -16,7 +16,7 @@ along with web3.js. If not, see . */ // eslint-disable-next-line import/no-extraneous-dependencies -import { ETH_DATA_FORMAT, format, SocketProvider } from 'web3-utils'; +import { format, SocketProvider } from 'web3-utils'; // eslint-disable-next-line import/no-extraneous-dependencies import { create, @@ -43,6 +43,7 @@ import { ProviderRpcError, JsonRpcSubscriptionResult, JsonRpcNotification, + ETH_DATA_FORMAT, } from 'web3-types'; // eslint-disable-next-line import/no-extraneous-dependencies import { Personal } from 'web3-eth-personal'; diff --git a/tools/web3-plugin-example/src/contract_method_wrappers.ts b/tools/web3-plugin-example/src/contract_method_wrappers.ts index 25ff000c8bc..492c4bf0bc3 100644 --- a/tools/web3-plugin-example/src/contract_method_wrappers.ts +++ b/tools/web3-plugin-example/src/contract_method_wrappers.ts @@ -16,8 +16,8 @@ along with web3.js. If not, see . */ import { Web3PluginBase } from 'web3-core'; import Contract from 'web3-eth-contract'; -import { Address, ContractAbi, Numbers } from 'web3-types'; -import { DataFormat, DEFAULT_RETURN_FORMAT, format, numberToHex } from 'web3-utils'; +import { Address, ContractAbi, DataFormat, DEFAULT_RETURN_FORMAT, Numbers } from 'web3-types'; +import { format, numberToHex } from 'web3-utils'; import { ERC20TokenAbi } from './ERC20Token'; import { Web3Context } from './reexported_web3_context'; diff --git a/tools/web3-plugin-example/test/unit/contract_method_wrappers.test.ts b/tools/web3-plugin-example/test/unit/contract_method_wrappers.test.ts index 7de66b31ec8..f5998f5ab1f 100644 --- a/tools/web3-plugin-example/test/unit/contract_method_wrappers.test.ts +++ b/tools/web3-plugin-example/test/unit/contract_method_wrappers.test.ts @@ -15,7 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ import Web3 from 'web3'; -import { DEFAULT_RETURN_FORMAT } from 'web3-utils'; +import { DEFAULT_RETURN_FORMAT } from 'web3-types'; import { ContractMethodWrappersPlugin } from '../../src/contract_method_wrappers'; import { ERC20TokenAbi } from '../../src/ERC20Token'; From b88f2e8ac40b5718a8dbf8ac6701155442ce1bba Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Fri, 7 Apr 2023 01:42:53 +0200 Subject: [PATCH 2/5] at `signTransaction` use `Transaction` instead of `Record` --- packages/web3-core/src/types.ts | 5 ++--- packages/web3-core/src/web3_context.ts | 6 +++--- packages/web3-eth-accounts/src/account.ts | 3 ++- packages/web3-eth/src/rpc_method_wrappers.ts | 2 +- packages/web3-eth/src/utils/transaction_builder.ts | 8 ++++---- packages/web3-types/src/eth_types.ts | 2 -- packages/web3-types/src/web3_base_wallet.ts | 3 ++- scripts/system_tests_utils.ts | 4 ++-- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/web3-core/src/types.ts b/packages/web3-core/src/types.ts index 1ab6d43c7a4..bf98c60880e 100644 --- a/packages/web3-core/src/types.ts +++ b/packages/web3-core/src/types.ts @@ -15,7 +15,6 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { HexString } from 'web3-types'; +import { HexString, Transaction } from 'web3-types'; -// TODO: When we have `web3-types` package we can share TransactionType -export type TransactionTypeParser = (transaction: Record) => HexString | undefined; +export type TransactionTypeParser = (transaction: Transaction) => HexString | undefined; diff --git a/packages/web3-core/src/web3_context.ts b/packages/web3-core/src/web3_context.ts index 961b54d682e..1d14df25a78 100644 --- a/packages/web3-core/src/web3_context.ts +++ b/packages/web3-core/src/web3_context.ts @@ -24,6 +24,7 @@ import { HexString, EthExecutionAPI, Web3BaseProvider, + Transaction, } from 'web3-types'; import { isNullish } from 'web3-utils'; import { ExistingPluginNamespaceError } from 'web3-errors'; @@ -368,11 +369,10 @@ export class Web3Context< } // To avoid cycle dependency declare this type in this file -// TODO: When we have `web3-types` package we can share TransactionType export type TransactionBuilder = < - ReturnType = Record, + ReturnType = Transaction, >(options: { - transaction: Record; + transaction: Transaction; web3Context: Web3Context; privateKey?: HexString | Buffer; }) => Promise; diff --git a/packages/web3-eth-accounts/src/account.ts b/packages/web3-eth-accounts/src/account.ts index 16c9c985616..1249822beb9 100644 --- a/packages/web3-eth-accounts/src/account.ts +++ b/packages/web3-eth-accounts/src/account.ts @@ -42,6 +42,7 @@ import { PBKDF2SHA256Params, ScryptParams, KeyStore, + Transaction, } from 'web3-types'; import { bytesToBuffer, @@ -590,7 +591,7 @@ export const privateKeyToAccount = (privateKey: Bytes, ignoreLength?: boolean): address: privateKeyToAddress(privateKeyBuffer), privateKey: bytesToHex(privateKeyBuffer), // eslint-disable-next-line @typescript-eslint/no-unused-vars - signTransaction: (_tx: Record) => { + signTransaction: (_tx: Transaction) => { throw new TransactionSigningError('Do not have network access to sign the transaction'); }, sign: (data: Record | string) => diff --git a/packages/web3-eth/src/rpc_method_wrappers.ts b/packages/web3-eth/src/rpc_method_wrappers.ts index d2823656462..63a6558e8e6 100644 --- a/packages/web3-eth/src/rpc_method_wrappers.ts +++ b/packages/web3-eth/src/rpc_method_wrappers.ts @@ -1147,7 +1147,7 @@ export function sendTransaction< if (wallet) { const signedTransaction = await wallet.signTransaction( - transactionFormatted as Record, + transactionFormatted, ); transactionHash = await trySendTransaction( diff --git a/packages/web3-eth/src/utils/transaction_builder.ts b/packages/web3-eth/src/utils/transaction_builder.ts index 76d4615fa13..11a51d99368 100644 --- a/packages/web3-eth/src/utils/transaction_builder.ts +++ b/packages/web3-eth/src/utils/transaction_builder.ts @@ -124,8 +124,8 @@ export const getTransactionType = ( // Keep in mind that the order the properties of populateTransaction get populated matters // as some of the properties are dependent on others -export async function defaultTransactionBuilder>(options: { - transaction: Record; +export async function defaultTransactionBuilder(options: { + transaction: Transaction; web3Context: Web3Context; privateKey?: HexString | Buffer; }): Promise { @@ -232,7 +232,7 @@ export async function defaultTransactionBuilder>(options: { +export const transactionBuilder = async (options: { transaction: Transaction; web3Context: Web3Context; privateKey?: HexString | Buffer; @@ -240,5 +240,5 @@ export const transactionBuilder = async >(o }) => (options.web3Context.transactionBuilder ?? defaultTransactionBuilder)({ ...options, - transaction: options.transaction as unknown as Record, + transaction: options.transaction, }) as unknown as ReturnType; diff --git a/packages/web3-types/src/eth_types.ts b/packages/web3-types/src/eth_types.ts index dcacfba0048..1389fdaa720 100644 --- a/packages/web3-types/src/eth_types.ts +++ b/packages/web3-types/src/eth_types.ts @@ -217,8 +217,6 @@ export interface SyncOutput { readonly pulledStates?: Numbers; } -export type Receipt = Record; - // https://github.com/ethereum/execution-apis/blob/main/src/schemas/filter.json#L28 export interface Filter { readonly fromBlock?: BlockNumberOrTag; diff --git a/packages/web3-types/src/web3_base_wallet.ts b/packages/web3-types/src/web3_base_wallet.ts index 773a2324aab..e8021b00d52 100644 --- a/packages/web3-types/src/web3_base_wallet.ts +++ b/packages/web3-types/src/web3_base_wallet.ts @@ -14,6 +14,7 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ +import { Transaction } from './eth_types'; import { HexString } from './primitives_types'; export type Cipher = 'aes-128-ctr' | 'aes-128-cbc' | 'aes-256-cbc'; @@ -63,7 +64,7 @@ export interface Web3BaseWalletAccount { [key: string]: unknown; readonly address: string; readonly privateKey: string; - readonly signTransaction: (tx: Record) => Promise<{ + readonly signTransaction: (tx: Transaction) => Promise<{ readonly messageHash: HexString; readonly r: HexString; readonly s: HexString; diff --git a/scripts/system_tests_utils.ts b/scripts/system_tests_utils.ts index 3446602f18c..5f60b458f9b 100644 --- a/scripts/system_tests_utils.ts +++ b/scripts/system_tests_utils.ts @@ -333,7 +333,7 @@ export const getSystemTestAccounts = async (): Promise => export const signTxAndSendEIP1559 = async ( provider: unknown, - tx: Record, + tx: Transaction, privateKey: string, ) => { const web3 = new Web3(provider as Web3BaseProvider); @@ -351,7 +351,7 @@ export const signTxAndSendEIP1559 = async ( export const signTxAndSendEIP2930 = async ( provider: unknown, - tx: Record, + tx: Transaction, privateKey: string, ) => { const web3 = new Web3(provider as Web3BaseProvider); From 17be9dd1a3dd840c4c98ec8c0f0b8ea5a2101328 Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 11 Apr 2023 02:56:36 +0200 Subject: [PATCH 3/5] update CHANGELOG.md files --- packages/web3-core/CHANGELOG.md | 1 + packages/web3-eth-accounts/CHANGELOG.md | 1 + packages/web3-eth-contract/CHANGELOG.md | 1 + packages/web3-eth/CHANGELOG.md | 1 + packages/web3-types/CHANGELOG.md | 3 +++ packages/web3-utils/CHANGELOG.md | 4 ++++ 6 files changed, 11 insertions(+) diff --git a/packages/web3-core/CHANGELOG.md b/packages/web3-core/CHANGELOG.md index fb64d3c4438..043d0fcfcd6 100644 --- a/packages/web3-core/CHANGELOG.md +++ b/packages/web3-core/CHANGELOG.md @@ -93,6 +93,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - If a transaction object with a `data` property is passed to `txInputOptionsFormatter`, it will now be replaced with `input` (#5915) +- The types `TransactionTypeParser` and `TransactionBuilder` are now utilizing the type `Transaction` for the transaction object. (#5993) ### Removed diff --git a/packages/web3-eth-accounts/CHANGELOG.md b/packages/web3-eth-accounts/CHANGELOG.md index 4e2814d7d1e..c98dad915a5 100644 --- a/packages/web3-eth-accounts/CHANGELOG.md +++ b/packages/web3-eth-accounts/CHANGELOG.md @@ -81,3 +81,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Moved @ethereumjs/tx, @ethereumjs/common code to our source code (#5963) +- The method `signTransaction` returned by `privateKeyToAccount` is now accepting the type `Transaction` for its argument. (#5993) diff --git a/packages/web3-eth-contract/CHANGELOG.md b/packages/web3-eth-contract/CHANGELOG.md index 14ee50e9469..c03b72c9802 100644 --- a/packages/web3-eth-contract/CHANGELOG.md +++ b/packages/web3-eth-contract/CHANGELOG.md @@ -247,6 +247,7 @@ const transactionHash = receipt.transactionHash; - `getSendTxParams` will now return `input` instead of `data` in returned transaction parameters object (#5915) - `Contract` constructor will now thrown new `ContractTransactionDataAndInputError` if both `data` and `input` are passed in `ContractInitOptions` for `Contract` constructor (#5915) +- The types `ContractAbiWithSignature`, `EventLog`, `ContractEventOptions`, `ContractOptions`, `ContractInitOptions` and `PayableCallOptions` moved to `web3-types`. (#5993) ### Removed diff --git a/packages/web3-eth/CHANGELOG.md b/packages/web3-eth/CHANGELOG.md index 09fd61d5211..141ac5a8936 100644 --- a/packages/web3-eth/CHANGELOG.md +++ b/packages/web3-eth/CHANGELOG.md @@ -118,6 +118,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `signTransaction` will now return `gas` instead of `gasLimit` for returned transaction object regardless of what property name the provider uses (#5915) - `formatTransaction` will now replace `data` transaction property with `input` (#5915) - `isTransactionCall` will now check if `value.input` `isHexStrict` if provided (#5915) +- The functions `defaultTransactionBuilder` and `transactionBuilder` are now utilizing the type `Transaction` for the transaction object. (#5993) ### Added diff --git a/packages/web3-types/CHANGELOG.md b/packages/web3-types/CHANGELOG.md index 63492df7691..8849f76aace 100644 --- a/packages/web3-types/CHANGELOG.md +++ b/packages/web3-types/CHANGELOG.md @@ -88,3 +88,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - `data` property in `TransactionOutput` was renamed to `input` (#5915) +- The method `signTransaction` inside `Web3BaseWalletAccount` is now utilizing the type `Transaction` for its argument. (#5993) +- The types `FMT_NUMBER`, `NumberTypes`, `FMT_BYTES`, `ByteTypes`, `DataFormat`, `DEFAULT_RETURN_FORMAT`, `ETH_DATA_FORMAT` and `FormatType` moved from `web3-utils`. (#5993) +- The types `ContractAbiWithSignature`, `EventLog`, `ContractEventOptions`, `ContractOptions`, `ContractInitOptions` and `PayableCallOptions` are moved from `web3-eth-contract`. (#5993) diff --git a/packages/web3-utils/CHANGELOG.md b/packages/web3-utils/CHANGELOG.md index 13df2c6ec3d..c3ae0cf8e36 100644 --- a/packages/web3-utils/CHANGELOG.md +++ b/packages/web3-utils/CHANGELOG.md @@ -96,6 +96,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added source files (#5956) - Added hybrid build (ESM and CJS) of library (#5904) +### Changed + +- The types `FMT_NUMBER`, `NumberTypes`, `FMT_BYTES`, `ByteTypes`, `DataFormat`, `DEFAULT_RETURN_FORMAT`, `ETH_DATA_FORMAT` and `FormatType` moved to `web3-types`. (#5993) + ### Removed - Removed dependencies @ethereumjs/tx, @ethereumjs/common (#5963) From 1b779ec1e69556fd1d05d0c397d85ff5f498886f Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Tue, 11 Apr 2023 17:43:19 +0200 Subject: [PATCH 4/5] move back some local types to web3-eth-contract --- packages/web3-eth-contract/CHANGELOG.md | 2 +- packages/web3-eth-contract/src/contract.ts | 8 +- packages/web3-eth-contract/src/encoding.ts | 6 +- .../web3-eth-contract/src/log_subscription.ts | 2 +- packages/web3-eth-contract/src/types.ts | 101 ++++++++++++++++++ packages/web3-eth-contract/src/utils.ts | 3 +- packages/web3-types/CHANGELOG.md | 2 +- packages/web3-types/src/eth_contract_types.ts | 98 +---------------- 8 files changed, 113 insertions(+), 109 deletions(-) diff --git a/packages/web3-eth-contract/CHANGELOG.md b/packages/web3-eth-contract/CHANGELOG.md index c03b72c9802..da862462aaf 100644 --- a/packages/web3-eth-contract/CHANGELOG.md +++ b/packages/web3-eth-contract/CHANGELOG.md @@ -247,7 +247,7 @@ const transactionHash = receipt.transactionHash; - `getSendTxParams` will now return `input` instead of `data` in returned transaction parameters object (#5915) - `Contract` constructor will now thrown new `ContractTransactionDataAndInputError` if both `data` and `input` are passed in `ContractInitOptions` for `Contract` constructor (#5915) -- The types `ContractAbiWithSignature`, `EventLog`, `ContractEventOptions`, `ContractOptions`, `ContractInitOptions` and `PayableCallOptions` moved to `web3-types`. (#5993) +- The types `ContractInitOptions`, `NonPayableCallOptions` and `PayableCallOptions` are moved to `web3-types`. (#5993) ### Removed diff --git a/packages/web3-eth-contract/src/contract.ts b/packages/web3-eth-contract/src/contract.ts index 6a82e18abe6..36ec032045f 100644 --- a/packages/web3-eth-contract/src/contract.ts +++ b/packages/web3-eth-contract/src/contract.ts @@ -63,11 +63,7 @@ import { HexString, LogsInput, Mutable, - ContractAbiWithSignature, - ContractEventOptions, ContractInitOptions, - ContractOptions, - EventLog, NonPayableCallOptions, PayableCallOptions, DataFormat, @@ -86,6 +82,10 @@ import { ALL_EVENTS_ABI } from './constants'; import { decodeEventABI, decodeMethodReturn, encodeEventABI, encodeMethodABI } from './encoding'; import { LogsSubscription } from './log_subscription'; import { + ContractAbiWithSignature, + ContractEventOptions, + ContractOptions, + EventLog, NonPayableMethodObject, NonPayableTxOptions, PayableMethodObject, diff --git a/packages/web3-eth-contract/src/encoding.ts b/packages/web3-eth-contract/src/encoding.ts index 92b9eed888b..d40c5a85a0a 100644 --- a/packages/web3-eth-contract/src/encoding.ts +++ b/packages/web3-eth-contract/src/encoding.ts @@ -21,9 +21,6 @@ import { AbiConstructorFragment, AbiEventFragment, AbiFunctionFragment, - ContractAbiWithSignature, - ContractOptions, - EventLog, LogsInput, BlockNumberOrTag, Filter, @@ -51,6 +48,9 @@ import { blockSchema, logSchema } from 'web3-eth'; import { Web3ContractError } from 'web3-errors'; +// eslint-disable-next-line import/no-cycle +import { ContractOptions, ContractAbiWithSignature, EventLog } from './types'; + export const encodeEventABI = ( { address }: ContractOptions, event: AbiEventFragment & { signature: string }, diff --git a/packages/web3-eth-contract/src/log_subscription.ts b/packages/web3-eth-contract/src/log_subscription.ts index f80ab00db6e..1863f891c4d 100644 --- a/packages/web3-eth-contract/src/log_subscription.ts +++ b/packages/web3-eth-contract/src/log_subscription.ts @@ -18,9 +18,9 @@ along with web3.js. If not, see . import { AbiEventFragment, LogsInput, HexString, Topic, DataFormat } from 'web3-types'; import { Web3RequestManager, Web3Subscription } from 'web3-core'; // eslint-disable-next-line import/no-cycle -import { ContractAbiWithSignature, EventLog } from 'web3-types'; import { decodeEventABI } from './encoding'; // eslint-disable-next-line import/no-cycle +import { EventLog, ContractAbiWithSignature } from './types'; /** * LogSubscription to be used to subscribe to events logs. diff --git a/packages/web3-eth-contract/src/types.ts b/packages/web3-eth-contract/src/types.ts index 89a7ddbcd86..005936f0662 100644 --- a/packages/web3-eth-contract/src/types.ts +++ b/packages/web3-eth-contract/src/types.ts @@ -29,6 +29,12 @@ import { DataFormat, DEFAULT_RETURN_FORMAT, FormatType, + AbiFragment, + Address, + Bytes, + ContractAbi, + HexString32Bytes, + Uint, } from 'web3-types'; // eslint-disable-next-line import/no-cycle import { LogsSubscription } from './log_subscription'; @@ -36,6 +42,101 @@ import { LogsSubscription } from './log_subscription'; export type NonPayableTxOptions = NonPayableCallOptions; export type PayableTxOptions = PayableCallOptions; +export type ContractAbiWithSignature = ReadonlyArray; + +export interface EventLog { + readonly event: string; + readonly id?: string; + readonly logIndex?: bigint | number | string; + readonly transactionIndex?: bigint | number | string; + readonly transactionHash?: HexString32Bytes; + readonly blockHash?: HexString32Bytes; + readonly blockNumber?: bigint | number | string; + readonly address: string; + readonly topics: HexString[]; + readonly data: HexString; + readonly raw?: { data: string; topics: unknown[] }; + readonly returnValues: Record; + readonly signature?: HexString; +} + +export interface ContractEventOptions { + /** + * Let you filter events by indexed parameters, e.g. `{filter: {myNumber: [12,13]}}` means all events where `myNumber` is `12` or `13`. + */ + filter?: Record; + /** + * The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as `earliest`, `latest`, `pending`, `safe` or `finalized` can also be used. For specific range use {@link Contract.getPastEvents}. + */ + fromBlock?: BlockNumberOrTag; + /** + * This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as “or” operation between the given nested topics. + */ + topics?: string[]; +} + +export interface ContractOptions { + /** + * The maximum gas provided for a transaction (gas limit). + */ + readonly gas?: Uint; + /** + * The gas price in wei to use for transactions. + */ + readonly gasPrice?: Uint; + /** + * The address transactions should be made from. + */ + readonly from?: Address; + /** + * The byte code of the contract. Used when the contract gets {@link Contract.deploy | deployed} + */ + readonly input?: Bytes; + /** + * The {@doclink glossary/json_interface | json interface} object derived from the [ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) of this contract. + * + * Re-setting this will regenerate the methods and events of the contract instance. + * + * ```ts + * myContract.options.jsonInterface; + * > [{ + * "type":"function", + * "name":"foo", + * "inputs": [{"name":"a","type":"uint256"}], + * "outputs": [{"name":"b","type":"address"}], + * "signature": "0x...", + * },{ + * "type":"event", + * "name":"Event", + * "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}], + * "signature": "0x...", + * }] + * + * // Set a new ABI interface + * // Note: the "signature" of every function and event's ABI is not needed to be provided when assigning. + * // It will be calculated and set automatically inside the setter. + * myContract.options.jsonInterface = [...]; + * ``` + */ + get jsonInterface(): ContractAbiWithSignature; + set jsonInterface(value: ContractAbi); + + /** + * The address used for this contract instance. All transactions generated by web3.js from this contract will contain this address as the `to`. + * + * The address will be stored in lowercase. + * + * ```ts + * myContract.options.address; + * > '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae' + * + * // set a new address + * myContract.options.address = '0x1234FFDD...'; + * ``` + */ + address?: Address; // All transactions generated by web3.js from this contract will contain this address as the "to". +} + export interface NonPayableMethodObject { arguments: Inputs; /** diff --git a/packages/web3-eth-contract/src/utils.ts b/packages/web3-eth-contract/src/utils.ts index 4c41a8a60d3..b52f8d8f755 100644 --- a/packages/web3-eth-contract/src/utils.ts +++ b/packages/web3-eth-contract/src/utils.ts @@ -24,12 +24,11 @@ import { HexString, NonPayableCallOptions, PayableCallOptions, - ContractOptions, ContractInitOptions, } from 'web3-types'; import { isNullish, mergeDeep, toHex } from 'web3-utils'; import { encodeMethodABI } from './encoding'; -import { Web3ContractContext } from './types'; +import { ContractOptions, Web3ContractContext } from './types'; export const getSendTxParams = ({ abi, diff --git a/packages/web3-types/CHANGELOG.md b/packages/web3-types/CHANGELOG.md index 8849f76aace..392f2ad306a 100644 --- a/packages/web3-types/CHANGELOG.md +++ b/packages/web3-types/CHANGELOG.md @@ -90,4 +90,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `data` property in `TransactionOutput` was renamed to `input` (#5915) - The method `signTransaction` inside `Web3BaseWalletAccount` is now utilizing the type `Transaction` for its argument. (#5993) - The types `FMT_NUMBER`, `NumberTypes`, `FMT_BYTES`, `ByteTypes`, `DataFormat`, `DEFAULT_RETURN_FORMAT`, `ETH_DATA_FORMAT` and `FormatType` moved from `web3-utils`. (#5993) -- The types `ContractAbiWithSignature`, `EventLog`, `ContractEventOptions`, `ContractOptions`, `ContractInitOptions` and `PayableCallOptions` are moved from `web3-eth-contract`. (#5993) +- The types `ContractInitOptions`, `NonPayableCallOptions` and `PayableCallOptions` are moved from `web3-eth-contract`. (#5993) diff --git a/packages/web3-types/src/eth_contract_types.ts b/packages/web3-types/src/eth_contract_types.ts index 1646ebb8dfc..4d9fd5bd81b 100644 --- a/packages/web3-types/src/eth_contract_types.ts +++ b/packages/web3-types/src/eth_contract_types.ts @@ -15,107 +15,11 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Address, BlockNumberOrTag, HexString32Bytes, Uint } from './eth_types'; -import { AbiFragment, ContractAbi } from './eth_abi_types'; +import { Address, Uint } from './eth_types'; import { SupportedProviders } from './web3_base_provider'; import { Bytes, HexString } from './primitives_types'; import { EthExecutionAPI } from './apis/eth_execution_api'; -export type ContractAbiWithSignature = ReadonlyArray; - -export interface EventLog { - readonly event: string; - readonly id?: string; - readonly logIndex?: bigint | number | string; - readonly transactionIndex?: bigint | number | string; - readonly transactionHash?: HexString32Bytes; - readonly blockHash?: HexString32Bytes; - readonly blockNumber?: bigint | number | string; - readonly address: string; - readonly topics: HexString[]; - readonly data: HexString; - readonly raw?: { data: string; topics: unknown[] }; - readonly returnValues: Record; - readonly signature?: HexString; -} - -export interface ContractEventOptions { - /** - * Let you filter events by indexed parameters, e.g. `{filter: {myNumber: [12,13]}}` means all events where `myNumber` is `12` or `13`. - */ - filter?: Record; - /** - * The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as `earliest`, `latest`, `pending`, `safe` or `finalized` can also be used. For specific range use {@link Contract.getPastEvents}. - */ - fromBlock?: BlockNumberOrTag; - /** - * This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as “or” operation between the given nested topics. - */ - topics?: string[]; -} - -export interface ContractOptions { - /** - * The maximum gas provided for a transaction (gas limit). - */ - readonly gas?: Uint; - /** - * The gas price in wei to use for transactions. - */ - readonly gasPrice?: Uint; - /** - * The address transactions should be made from. - */ - readonly from?: Address; - /** - * The byte code of the contract. Used when the contract gets {@link Contract.deploy | deployed} - */ - readonly input?: Bytes; - /** - * The {@doclink glossary/json_interface | json interface} object derived from the [ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) of this contract. - * - * Re-setting this will regenerate the methods and events of the contract instance. - * - * ```ts - * myContract.options.jsonInterface; - * > [{ - * "type":"function", - * "name":"foo", - * "inputs": [{"name":"a","type":"uint256"}], - * "outputs": [{"name":"b","type":"address"}], - * "signature": "0x...", - * },{ - * "type":"event", - * "name":"Event", - * "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}], - * "signature": "0x...", - * }] - * - * // Set a new ABI interface - * // Note: the "signature" of every function and event's ABI is not needed to be provided when assigning. - * // It will be calculated and set automatically inside the setter. - * myContract.options.jsonInterface = [...]; - * ``` - */ - get jsonInterface(): ContractAbiWithSignature; - set jsonInterface(value: ContractAbi); - - /** - * The address used for this contract instance. All transactions generated by web3.js from this contract will contain this address as the `to`. - * - * The address will be stored in lowercase. - * - * ```ts - * myContract.options.address; - * > '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae' - * - * // set a new address - * myContract.options.address = '0x1234FFDD...'; - * ``` - */ - address?: Address; // All transactions generated by web3.js from this contract will contain this address as the "to". -} - export interface ContractInitOptions { /** * The maximum gas provided for a transaction (gas limit). From a095170f460f1ade4de27a353c4873da0264a3fa Mon Sep 17 00:00:00 2001 From: Muhammad-Altabba <24407834+Muhammad-Altabba@users.noreply.github.com> Date: Wed, 12 Apr 2023 18:21:19 +0200 Subject: [PATCH 5/5] fix few imports at tests after merging code --- packages/web3-eth-contract/test/fixtures/erc20.ts | 4 ++-- packages/web3-eth-contract/test/fixtures/erc721.ts | 4 ++-- .../test/integration/contract_events.test.ts | 3 +-- .../test/integration/local_account/contract_erc721.test.ts | 3 +-- .../local_account/contract_overloaded_methods.test.ts | 3 +-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/web3-eth-contract/test/fixtures/erc20.ts b/packages/web3-eth-contract/test/fixtures/erc20.ts index 1d20f3eb246..cf4b595ec8d 100644 --- a/packages/web3-eth-contract/test/fixtures/erc20.ts +++ b/packages/web3-eth-contract/test/fixtures/erc20.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Address, ContractEventOptions, Numbers } from 'web3-types'; +import { Address, Numbers } from 'web3-types'; import { LogsSubscription } from '../../src/log_subscription'; -import { PayableMethodObject, NonPayableMethodObject } from '../../src/types'; +import { ContractEventOptions, PayableMethodObject, NonPayableMethodObject } from '../../src/types'; export interface Erc20Interface { methods: { diff --git a/packages/web3-eth-contract/test/fixtures/erc721.ts b/packages/web3-eth-contract/test/fixtures/erc721.ts index 74ebd00749a..36c87289c24 100644 --- a/packages/web3-eth-contract/test/fixtures/erc721.ts +++ b/packages/web3-eth-contract/test/fixtures/erc721.ts @@ -15,9 +15,9 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { Address, ContractEventOptions, Numbers } from 'web3-types'; +import { Address, Numbers } from 'web3-types'; import { LogsSubscription } from '../../src/log_subscription'; -import { NonPayableMethodObject, PayableMethodObject } from '../../src/types'; +import { ContractEventOptions, NonPayableMethodObject, PayableMethodObject } from '../../src/types'; export interface Erc721Interface { methods: { diff --git a/packages/web3-eth-contract/test/integration/contract_events.test.ts b/packages/web3-eth-contract/test/integration/contract_events.test.ts index 8b035af8e8b..209a918c05f 100644 --- a/packages/web3-eth-contract/test/integration/contract_events.test.ts +++ b/packages/web3-eth-contract/test/integration/contract_events.test.ts @@ -15,8 +15,7 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { EventLog } from 'web3-types'; -import { Contract } from '../../src'; +import { Contract, EventLog } from '../../src'; import { BasicAbi, BasicBytecode } from '../shared_fixtures/build/Basic'; import { processAsync } from '../shared_fixtures/utils'; import { diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts index 6741b15e034..b9ad5b2ac0d 100644 --- a/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts +++ b/packages/web3-eth-contract/test/integration/local_account/contract_erc721.test.ts @@ -19,8 +19,7 @@ along with web3.js. If not, see . import Web3 from 'web3'; // eslint-disable-next-line import/no-extraneous-dependencies import { Web3Account } from 'web3-eth-accounts'; -import { EventLog } from 'web3-types'; -import { Contract } from '../../../src'; +import { Contract, EventLog } from '../../../src'; import { ERC721TokenAbi, ERC721TokenBytecode } from '../../shared_fixtures/build/ERC721Token'; import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils'; import { toUpperCaseHex } from '../../shared_fixtures/utils'; diff --git a/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts b/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts index e3686798624..75e32107d35 100644 --- a/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts +++ b/packages/web3-eth-contract/test/integration/local_account/contract_overloaded_methods.test.ts @@ -19,9 +19,8 @@ along with web3.js. If not, see . import Web3 from 'web3'; // eslint-disable-next-line import/no-extraneous-dependencies import { Web3Account } from 'web3-eth-accounts'; -import { EventLog } from 'web3-types'; import { utf8ToHex } from 'web3-utils'; -import { Contract } from '../../../src'; +import { Contract, EventLog } from '../../../src'; import { ERC721TokenAbi, ERC721TokenBytecode } from '../../shared_fixtures/build/ERC721Token'; import { getSystemTestProvider, createLocalAccount } from '../../fixtures/system_test_utils'; import { toUpperCaseHex } from '../../shared_fixtures/utils';