starknet
Version:
JavaScript library for Starknet
1 lines • 1.08 MB
Source Map (JSON)
{"version":3,"sources":["../src/global/constants.ts","../src/types/api/index.ts","../src/types/api/jsonrpc.ts","../src/types/api/rpc.ts","../src/provider/types/spec.type.ts","../src/utils/encode.ts","../src/global/config.ts","../src/global/logger.type.ts","../src/global/logger.ts","../src/channel/rpc_0_9_0.ts","../src/types/lib/contract/index.ts","../src/types/calldata.ts","../src/contract/types/index.type.ts","../src/types/outsideExecution.ts","../src/utils/assert.ts","../src/utils/json.ts","../src/utils/batch/index.ts","../src/utils/num.ts","../src/utils/typed.ts","../src/utils/hash/selector.ts","../src/utils/shortString.ts","../src/utils/calldata/byteArray.ts","../src/utils/calldata/cairo.ts","../src/utils/helpers.ts","../src/utils/cairoDataTypes/felt.ts","../src/utils/cairoDataTypes/uint256.ts","../src/utils/cairoDataTypes/uint512.ts","../src/utils/calldata/enum/CairoCustomEnum.ts","../src/utils/calldata/enum/CairoOption.ts","../src/utils/calldata/enum/CairoResult.ts","../src/utils/calldata/formatter.ts","../src/utils/calldata/parser/interface.ts","../src/utils/cairoDataTypes/bytes31.ts","../src/utils/errors/rpc.ts","../src/utils/errors/index.ts","../src/utils/connect/buffer.ts","../src/utils/cairoDataTypes/uint32.ts","../src/utils/cairoDataTypes/byteArray.ts","../src/utils/cairoDataTypes/uint8.ts","../src/utils/cairoDataTypes/uint16.ts","../src/utils/cairoDataTypes/uint64.ts","../src/utils/cairoDataTypes/uint96.ts","../src/utils/cairoDataTypes/uint128.ts","../src/utils/cairoDataTypes/int8.ts","../src/utils/cairoDataTypes/int16.ts","../src/utils/cairoDataTypes/int32.ts","../src/utils/cairoDataTypes/int64.ts","../src/utils/cairoDataTypes/int128.ts","../src/utils/calldata/parser/parsingStrategy.ts","../src/utils/calldata/parser/parser-0-1.1.0.ts","../src/utils/calldata/parser/parser-2.0.0.ts","../src/utils/calldata/parser/index.ts","../src/utils/calldata/tuple.ts","../src/utils/cairoDataTypes/fixedArray.ts","../src/utils/calldata/propertyOrder.ts","../src/utils/calldata/requestParser.ts","../src/utils/calldata/responseParser.ts","../src/utils/calldata/validate.ts","../src/utils/calldata/index.ts","../src/utils/hash/index.ts","../src/utils/hash/transactionHash/v3.ts","../src/utils/hash/transactionHash/v2.ts","../src/utils/ec.ts","../src/utils/hash/transactionHash/index.ts","../src/utils/hash/classHash/util.ts","../src/utils/hash/classHash/pedersen.ts","../src/utils/hash/classHash/poseidon.ts","../src/utils/connect/blake.ts","../src/utils/hash/classHash/blake.ts","../src/utils/resolve.ts","../src/utils/hash/classHash/index.ts","../src/utils/stark/index.ts","../src/utils/contract.ts","../src/utils/eth.ts","../src/utils/connect/fetch.ts","../src/utils/provider.ts","../src/utils/transaction/index.ts","../src/utils/transaction/getCompiledCalldata.ts","../src/utils/transaction/transaction.ts","../src/channel/rpc_0_10_0.ts","../src/utils/eventEmitter.ts","../src/utils/connect/ws.ts","../src/channel/ws/subscription.ts","../src/channel/ws/ws_0_10.ts","../src/utils/responseParser/rpc.ts","../src/provider/modules/tip.ts","../src/utils/transactionReceipt/transactionReceipt.ts","../src/utils/typedData.ts","../src/utils/merkle.ts","../src/provider/modules/verifyMessageInStarknet.ts","../src/provider/modules/getGasPrices.ts","../src/provider/rpc.ts","../src/provider/extensions/default.ts","../src/utils/starknetId.ts","../src/provider/extensions/starknetId.ts","../src/provider/extensions/brotherId.ts","../src/provider/interface.ts","../src/provider/index.ts","../src/signer/interface.ts","../src/signer/default.ts","../src/signer/ethSigner.ts","../src/utils/uint256.ts","../src/signer/ledgerSigner111.ts","../src/utils/address.ts","../src/signer/ledgerSigner221.ts","../src/signer/ledgerSigner231.ts","../src/utils/outsideExecution.ts","../src/utils/src5.ts","../src/utils/paymaster.ts","../src/paymaster/rpc.ts","../src/paymaster/interface.ts","../src/paymaster/index.ts","../src/deployer/default.ts","../src/deployer/interface.ts","../src/deployer/index.ts","../src/account/default.ts","../src/account/interface.ts","../src/wallet/connect.ts","../src/wallet/account.ts","../src/wallet/connectV5.ts","../src/wallet/accountV5.ts","../src/utils/events/index.ts","../src/contract/default.ts","../src/contract/interface.ts","../src/utils/responseParser/interface.ts","../src/utils/units.ts"],"sourcesContent":["/* eslint-disable no-underscore-dangle */\nimport type { getEstimateFeeBulkOptions, getSimulateTransactionOptions } from '../types/lib';\nimport type { ResourceBoundsOverhead } from '../provider/types/spec.type';\nimport { BlockTag } from '../provider/types/spec.type';\nimport { ETransactionVersion } from '../types/api';\nimport { ValuesType } from '../types/helpers/valuesType';\nimport type { LogLevel } from './logger.type';\nimport type { TipType } from '../provider/modules/tip';\n\nexport { IS_BROWSER } from '../utils/encode';\n\n/**\n * Cairo Felt support storing max 31 character\n */\nexport const TEXT_TO_FELT_MAX_LEN = 31;\nexport const ZERO = 0n;\nexport const MASK_250 = 2n ** 250n - 1n; // 2 ** 250 - 1\nexport const MASK_31 = 2n ** 31n - 1n; // 2 ** 31 - 1\nexport const API_VERSION = ZERO;\nexport const PRIME = 2n ** 251n + 17n * 2n ** 192n + 1n;\n\n// based on: https://github.com/starkware-libs/cairo-lang/blob/v0.12.3/src/starkware/starknet/common/storage.cairo#L3\nexport const MAX_STORAGE_ITEM_SIZE = 256n;\nexport const ADDR_BOUND = 2n ** 251n - MAX_STORAGE_ITEM_SIZE;\n\nconst range = (min: bigint, max: bigint) => ({ min, max }) as const;\n\nexport const RANGE_FELT = range(ZERO, PRIME - 1n);\n\n// Unsigned integer ranges\nexport const RANGE_U8 = range(ZERO, 2n ** 8n - 1n);\nexport const RANGE_U16 = range(ZERO, 2n ** 16n - 1n);\nexport const RANGE_U32 = range(ZERO, 2n ** 32n - 1n);\nexport const RANGE_U64 = range(ZERO, 2n ** 64n - 1n);\nexport const RANGE_U96 = range(ZERO, 2n ** 96n - 1n);\nexport const RANGE_U128 = range(ZERO, 2n ** 128n - 1n);\n\n// Signed integer ranges\nexport const RANGE_I8 = range(-(2n ** 7n), 2n ** 7n - 1n);\nexport const RANGE_I16 = range(-(2n ** 15n), 2n ** 15n - 1n);\nexport const RANGE_I32 = range(-(2n ** 31n), 2n ** 31n - 1n);\nexport const RANGE_I64 = range(-(2n ** 63n), 2n ** 63n - 1n);\nexport const RANGE_I128 = range(-(2n ** 127n), 2n ** 127n - 1n);\n\nexport const LegacyUDC = {\n ADDRESS: '0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf',\n ENTRYPOINT: 'deployContract',\n} as const;\n\nexport const UDC = {\n ADDRESS: '0x02ceed65a4bd731034c01113685c831b01c15d7d432f71afb1cf1634b53a2125',\n ENTRYPOINT: 'deploy_contract',\n} as const;\n\nexport const OutsideExecutionCallerAny = '0x414e595f43414c4c4552'; // encodeShortString('ANY_CALLER')\nexport const SNIP9_V1_INTERFACE_ID =\n '0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181';\nexport const SNIP9_V2_INTERFACE_ID =\n '0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872';\n\n// Ledger signer\n// 0x80\nexport const HARDENING_BYTE = 128;\n// 0x80000000\nexport const HARDENING_4BYTES = 2147483648n;\n\n// NOTE: the enum alias exports are made so both the 'const' and 'type' are reachable in the published '.d.ts' file,\n// otherwise the last export hides the preceding export with the same name in this file\nconst _BaseUrl = {\n SN_MAIN: 'https://alpha-mainnet.starknet.io',\n SN_SEPOLIA: 'https://alpha-sepolia.starknet.io',\n} as const;\ntype _BaseUrl = ValuesType<typeof _BaseUrl>;\nexport { _BaseUrl as BaseUrl };\n\nconst _NetworkName = {\n SN_MAIN: 'SN_MAIN',\n SN_SEPOLIA: 'SN_SEPOLIA',\n} as const;\ntype _NetworkName = ValuesType<typeof _NetworkName>;\nexport { _NetworkName as NetworkName };\n\nconst _StarknetChainId = {\n SN_MAIN: '0x534e5f4d41494e', // encodeShortString('SN_MAIN'),\n SN_SEPOLIA: '0x534e5f5345504f4c4941', // encodeShortString('SN_SEPOLIA')\n} as const;\ntype _StarknetChainId = ValuesType<typeof _StarknetChainId>;\nexport { _StarknetChainId as StarknetChainId };\n\nconst _TransactionHashPrefix = {\n DECLARE: '0x6465636c617265', // encodeShortString('declare'),\n DEPLOY: '0x6465706c6f79', // encodeShortString('deploy'),\n DEPLOY_ACCOUNT: '0x6465706c6f795f6163636f756e74', // encodeShortString('deploy_account'),\n INVOKE: '0x696e766f6b65', // encodeShortString('invoke'),\n L1_HANDLER: '0x6c315f68616e646c6572', // encodeShortString('l1_handler'),\n} as const;\ntype _TransactionHashPrefix = ValuesType<typeof _TransactionHashPrefix>;\nexport { _TransactionHashPrefix as TransactionHashPrefix };\n\n/**\n * dot format rpc versions\n */\nconst _SupportedRpcVersion = {\n '0.9.0': '0.9.0',\n '0.10.0': '0.10.0',\n v0_9_0: '0.9.0',\n v0_10_0: '0.10.0',\n} as const;\ntype _SupportedRpcVersion = ValuesType<typeof _SupportedRpcVersion>;\nexport { _SupportedRpcVersion as SupportedRpcVersion };\n\nexport type SupportedTransactionVersion = typeof ETransactionVersion.V3;\nexport type SupportedCairoVersion = '1';\n\n/**\n * Channel method-specific options\n */\nexport type ChannelMethodOptions = {\n simulateTransaction: Omit<getSimulateTransactionOptions, 'blockIdentifier'>;\n getEstimateFee: Omit<getEstimateFeeBulkOptions, 'blockIdentifier'>;\n};\n\n/**\n * Channel default options\n */\nexport type ChannelDefaultOptions = {\n headers: Record<string, string>;\n blockIdentifier: BlockTag;\n retries: number;\n};\n\n/**\n * Channel defaults configuration\n */\nexport type ChannelDefaults = {\n options: ChannelDefaultOptions;\n methods: ChannelMethodOptions;\n};\n\n// Default initial global config\nexport const DEFAULT_GLOBAL_CONFIG: {\n logLevel: LogLevel;\n rpcVersion: _SupportedRpcVersion;\n transactionVersion: SupportedTransactionVersion;\n resourceBoundsOverhead: ResourceBoundsOverhead;\n defaultTipType: TipType;\n channelDefaults: ChannelDefaults;\n fetch: any;\n websocket: any;\n buffer: any;\n /**\n * Custom blake function\n * @param uint8Array - The uint8Array to hash\n * @returns The hash of the uint8Array\n * @example\n * ```typescript\n * config.set('blake', (uint8Array: Uint8Array) => {\n * return blake2s(uint8Array, { dkLen: 32 });\n * });\n * ```\n */\n blake: ((uint8Array: Uint8Array) => Uint8Array) | undefined;\n} = {\n rpcVersion: '0.10.0',\n transactionVersion: ETransactionVersion.V3, // Starknet 0.14.0 only V3 transactions\n logLevel: 'INFO',\n resourceBoundsOverhead: {\n l1_gas: {\n max_amount: 50,\n max_price_per_unit: 50,\n },\n l1_data_gas: {\n max_amount: 50,\n max_price_per_unit: 50,\n },\n l2_gas: {\n max_amount: 50,\n max_price_per_unit: 50,\n },\n },\n defaultTipType: 'recommendedTip',\n channelDefaults: {\n options: {\n headers: { 'Content-Type': 'application/json' },\n blockIdentifier: BlockTag.LATEST,\n retries: 200,\n },\n methods: {\n simulateTransaction: {\n skipValidate: true,\n skipFeeCharge: true,\n },\n getEstimateFee: {\n skipValidate: true,\n },\n },\n },\n fetch: undefined,\n websocket: undefined,\n buffer: undefined,\n blake: undefined,\n};\n\nexport const RPC_DEFAULT_NODES = {\n SN_MAIN: [`https://api.zan.top/public/starknet-mainnet/rpc/`],\n SN_SEPOLIA: [`https://api.zan.top/public/starknet-sepolia/rpc/`],\n} as const;\n\nexport const PAYMASTER_RPC_NODES = {\n SN_MAIN: [`https://starknet.paymaster.avnu.fi`],\n SN_SEPOLIA: [`https://sepolia.paymaster.avnu.fi`],\n} as const;\n\n// Default system messages\nexport const SYSTEM_MESSAGES = {\n legacyTxWarningMessage:\n 'You are using a deprecated transaction version (V0,V1,V2)!\\nUpdate to the latest V3 transactions!',\n legacyTxRPC08Message:\n 'RPC 0.8+ do not support legacy transactions, use RPC 0.8+ v3 transactions!',\n SWOldV3: 'RPC 0.7 V3 tx (improper resource bounds) not supported in RPC 0.8+',\n channelVersionMismatch:\n 'Channel specification version is not compatible with the connected node Specification Version',\n unsupportedSpecVersion:\n 'The connected node specification version is not supported by this library',\n maxFeeInV3: 'maxFee is not supported in V3 transactions, use resourceBounds instead',\n declareNonSierra: 'Declaring non Sierra (Cairo0)contract using RPC 0.8+',\n unsupportedMethodForRpcVersion: 'Unsupported method for RPC version',\n txEvictedFromMempool: 'Transaction TTL, evicted from the mempool, try to increase the tip',\n consensusFailed: 'Consensus failed to finalize the block proposal',\n txFailsBlockBuildingValidation: 'Transaction fails block building validation',\n};\n\nexport const SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS = '0.14.1' as const;\n","export * as JRPC from './jsonrpc';\n\nexport * as RPCSPEC09 from '@starknet-io/starknet-types-09';\nexport * as RPCSPEC010 from '@starknet-io/starknet-types-010';\n\nexport { PAYMASTER_API } from '@starknet-io/starknet-types-010';\n\n// Default export\n// alias for \"export * from '@starknet-io/starknet-types-09';\" which is done within ./rpc.ts\n// the extra level avoids a rollup issue that injects namespace merger JS code into the published .d.ts file\n//\n// eslint-disable-next-line\nexport * from './rpc';\n","export type RequestBody = {\n id: number | string;\n jsonrpc: '2.0';\n method: string;\n params?: {};\n};\n\nexport type ResponseBody = {\n id: number | string;\n jsonrpc: '2.0';\n} & (SuccessResponseBody | ErrorResponseBody);\n\nexport type SuccessResponseBody = {\n result: unknown;\n};\n\nexport type ErrorResponseBody = {\n error: Error;\n};\n\nexport type Error = {\n code: number;\n message: string;\n data?: unknown;\n};\n\nexport type WebSocketEvent = Omit<RequestBody, 'id'> & { params: {} };\n","// see explanation in ./index.ts\nexport * from '@starknet-io/starknet-types-010';\n","// this file aims to unify the RPC specification types used by the common Provider class\n\nimport { SimpleOneOf } from '../../types/helpers';\nimport { RPCSPEC09, RPCSPEC010 } from '../../types/api';\n\n// taken from type-fest\nexport type Simplify<T> = { [K in keyof T]: T[K] } & {};\n\n// taken from type-fest\nexport type RequiredKeysOf<T extends object> = Exclude<\n {\n [K in keyof T]: T extends Record<K, T[K]> ? K : never;\n }[keyof T],\n undefined\n>;\n\ntype ArrayElement<T> = T extends Array<infer U> ? U : never;\n\ntype MergeProperties<T1 extends Record<any, any>, T2 extends Record<any, any>> = {\n [K in RequiredKeysOf<T1> & RequiredKeysOf<T2>]: Merge<T1[K], T2[K]>;\n} & {\n [K in keyof T1 & keyof T2]?: Merge<T1[K], T2[K]>;\n} & {\n [K in Exclude<keyof T1, keyof T2>]?: T1[K];\n} & {\n [K in Exclude<keyof T2, keyof T1>]?: T2[K];\n};\n\n/**\n * type a = { w: bigint[]; x: bigint; y: string };\n type b = { w: number[]; x: number; z: string };\n type c = Merge<a, b>; // { w: (bigint | number)[] x: bigint | number; y?: string; z?: string; }\n\n NOTE: handling for ambiguous overlaps, such as a shared property being an array or object,\n is simplified to resolve to only one type since there shouldn't be such occurrences in the\n currently supported RPC specifications\n */\ntype Merge<T1, T2> = Simplify<\n T1 extends Array<any>\n ? T2 extends Array<any>\n ? Array<Merge<ArrayElement<T1>, ArrayElement<T2>>>\n : T1\n : T2 extends Array<any>\n ? T2\n : T1 extends object\n ? T2 extends object\n ? MergeProperties<T1, T2>\n : T1\n : T2 extends object\n ? T2\n : T1 | T2\n>;\n\n// Default exports for both RPCs\nexport type ETransactionVersion = RPCSPEC09.ETransactionVersion;\nexport const { ETransactionVersion } = RPCSPEC09;\n\nexport type ETransactionVersion2 = RPCSPEC09.ETransactionVersion2;\nexport const { ETransactionVersion2 } = RPCSPEC09;\n\nexport type ETransactionVersion3 = RPCSPEC09.ETransactionVersion3;\nexport const { ETransactionVersion3 } = RPCSPEC09;\n\n// MERGES\nexport type BLOCK_HASH = Merge<RPCSPEC010.BLOCK_HASH, RPCSPEC09.BLOCK_HASH>;\nexport type BLOCK_NUMBER = Merge<RPCSPEC010.BLOCK_NUMBER, RPCSPEC09.BLOCK_NUMBER>;\nexport type FELT = Merge<RPCSPEC010.FELT, RPCSPEC09.FELT>;\nexport type TXN_HASH = Merge<RPCSPEC010.TXN_HASH, RPCSPEC09.TXN_HASH>;\n\nexport type PRICE_UNIT = Merge<RPCSPEC010.PRICE_UNIT, RPCSPEC09.PRICE_UNIT>;\nexport type RESOURCE_PRICE = Merge<RPCSPEC010.RESOURCE_PRICE, RPCSPEC09.RESOURCE_PRICE>;\nexport type SIMULATION_FLAG = Merge<RPCSPEC010.SIMULATION_FLAG, RPCSPEC09.SIMULATION_FLAG>;\n\nexport type STATE_UPDATE = Merge<RPCSPEC010.STATE_UPDATE, RPCSPEC09.STATE_UPDATE>;\n/* export type PENDING_STATE_UPDATE = Merge<\n RPCSPEC010.PENDING_STATE_UPDATE,\n RPCSPEC09.PRE_CONFIRMED_STATE_UPDATE\n>; */\nexport type PRE_CONFIRMED_STATE_UPDATE = Merge<\n RPCSPEC010.PRE_CONFIRMED_STATE_UPDATE,\n RPCSPEC09.PRE_CONFIRMED_STATE_UPDATE\n>;\n// TODO: Can we remove all of this ?\n/* export type INVOKE_TXN_RECEIPT = IsInBlock<RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'INVOKE'>>;\nexport type DECLARE_TXN_RECEIPT = IsInBlock<RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'DECLARE'>>;\nexport type DEPLOY_ACCOUNT_TXN_RECEIPT = IsInBlock<\n RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'DEPLOY_ACCOUNT'>\n>;\nexport type L1_HANDLER_TXN_RECEIPT = IsInBlock<RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'L1_HANDLER'>>; */\n\n/* export type PENDING_INVOKE_TXN_RECEIPT = RPCSPEC08.IsPending<\n RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'INVOKE'>\n>;\nexport type PENDING_DECLARE_TXN_RECEIPT = RPCSPEC08.IsPending<\n RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'DECLARE'>\n>;\nexport type PENDING_DEPLOY_ACCOUNT_TXN_RECEIPT = RPCSPEC08.IsPending<\n RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'DEPLOY_ACCOUNT'>\n>;\nexport type PENDING_L1_HANDLER_TXN_RECEIPT = RPCSPEC08.IsPending<\n RPCSPEC08.IsType<RPCSPEC08.TransactionReceipt, 'L1_HANDLER'>\n>; */\n//\n\nexport type BlockWithTxHashes = Merge<RPCSPEC010.BlockWithTxHashes, RPCSPEC09.BlockWithTxHashes>;\nexport type ContractClassPayload = Merge<RPCSPEC010.ContractClass, RPCSPEC09.ContractClass>;\nexport type DeclaredTransaction = Merge<\n RPCSPEC010.DeclaredTransaction,\n RPCSPEC09.DeclaredTransaction\n>;\nexport type InvokedTransaction = Merge<RPCSPEC010.InvokedTransaction, RPCSPEC09.InvokedTransaction>;\nexport type DeployedAccountTransaction = Merge<\n RPCSPEC010.DeployedAccountTransaction,\n RPCSPEC09.DeployedAccountTransaction\n>;\n\nexport type L1_HANDLER_TXN = RPCSPEC010.L1_HANDLER_TXN;\nexport type EDataAvailabilityMode = RPCSPEC010.EDataAvailabilityMode;\nexport const { EDataAvailabilityMode } = RPCSPEC010;\nexport type EDAMode = RPCSPEC010.EDAMode;\nexport const { EDAMode } = RPCSPEC010;\nexport type EmittedEvent = Merge<RPCSPEC010.EmittedEvent, RPCSPEC09.EmittedEvent>;\nexport type Event = Merge<RPCSPEC010.Event, RPCSPEC09.Event>;\n\n/* export type PendingReceipt = Merge<\n RPCSPEC010.TransactionReceiptPendingBlock,\n RPCSPEC09.TransactionReceiptPreConfirmedBlock\n>; */\nexport type Receipt = Merge<\n RPCSPEC010.TransactionReceiptProductionBlock,\n RPCSPEC09.TransactionReceiptProductionBlock\n>;\n\n/**\n * original response from estimate fee without parsing\n */\nexport type FeeEstimate = Merge<RPCSPEC010.FEE_ESTIMATE, RPCSPEC09.FEE_ESTIMATE>;\nexport type ApiEstimateFeeResponse = FeeEstimate[]; // 0.8 and 0.9\n\nexport function isRPC08Plus_ResourceBounds(\n entry: ResourceBounds\n): entry is RPCSPEC010.ResourceBounds {\n return 'l1_data_gas' in entry;\n}\n\nexport function isRPC08Plus_ResourceBoundsBN(entry: ResourceBoundsBN): entry is ResourceBoundsBN {\n return 'l1_data_gas' in entry;\n}\n\nexport type ResourceBounds = Merge<RPCSPEC010.ResourceBounds, RPCSPEC09.ResourceBounds>; // same sa rpc0.8\n\nexport type EventFilter = RPCSPEC09.EventFilter;\n\n/**\n * Represents percentage overhead for each resource bound\n * numerical 50 means 50% overhead\n */\nexport type ResourceBoundsOverhead = {\n [K in keyof ResourceBounds]: ResourceBounds[K] extends object\n ? {\n [P in keyof ResourceBounds[K]]: number;\n }\n : number;\n};\n\n/**\n * Resource bounds in big number format\n */\nexport type ResourceBoundsBN = {\n [K in keyof ResourceBounds]: ResourceBounds[K] extends object\n ? {\n [P in keyof ResourceBounds[K]]: bigint;\n }\n : number;\n};\n\nexport type SimulateTransaction = SimpleOneOf<\n RPCSPEC09.SimulateTransaction,\n RPCSPEC010.SimulateTransaction\n>;\nexport type SimulateTransactionResponse = SimpleOneOf<\n RPCSPEC09.SimulateTransactionResponse,\n RPCSPEC010.SimulateTransactionResponse\n>;\n\nexport type TransactionTrace = SimpleOneOf<\n RPCSPEC09.TRANSACTION_TRACE,\n RPCSPEC010.TRANSACTION_TRACE\n>;\n\nexport type TransactionWithHash = Merge<\n RPCSPEC010.TransactionWithHash,\n RPCSPEC09.TransactionWithHash\n>;\n\nexport type TransactionReceipt = Merge<RPCSPEC010.TransactionReceipt, RPCSPEC09.TransactionReceipt>;\nexport type Methods = RPCSPEC010.Methods;\nexport type TXN_STATUS = Merge<RPCSPEC010.TXN_STATUS, RPCSPEC09.TXN_STATUS>;\nexport type TXN_EXECUTION_STATUS = Merge<\n RPCSPEC010.TXN_EXECUTION_STATUS,\n RPCSPEC09.TXN_EXECUTION_STATUS\n>;\nexport type TransactionStatus = Merge<RPCSPEC010.TransactionStatus, RPCSPEC09.TransactionStatus>;\nexport type ETransactionStatus = RPCSPEC010.ETransactionStatus;\nexport const { ETransactionStatus } = RPCSPEC010;\nexport type ETransactionExecutionStatus = RPCSPEC010.ETransactionExecutionStatus;\nexport const { ETransactionExecutionStatus } = RPCSPEC010;\n// export type TRANSACTION_TRACE = Merge<RPCSPEC08.TRANSACTION_TRACE, RPCSPEC09.TRANSACTION_TRACE>;\nexport type FEE_ESTIMATE = Merge<RPCSPEC010.FEE_ESTIMATE, RPCSPEC09.FEE_ESTIMATE>;\nexport type EVENTS_CHUNK = Merge<RPCSPEC010.EVENTS_CHUNK, RPCSPEC09.EVENTS_CHUNK>;\n\nexport type TransactionType = RPCSPEC09.ETransactionType;\nexport const { ETransactionType: TransactionType } = RPCSPEC09;\n\nexport type BlockStatus = RPCSPEC09.EBlockStatus;\nexport const { EBlockStatus: BlockStatus } = RPCSPEC09;\n\nexport type TransactionFinalityStatus = RPCSPEC09.ETransactionFinalityStatus;\nexport const { ETransactionFinalityStatus: TransactionFinalityStatus } = RPCSPEC09;\n\nexport type TransactionExecutionStatus = RPCSPEC09.ETransactionExecutionStatus;\nexport const { ETransactionExecutionStatus: TransactionExecutionStatus } = RPCSPEC09;\n\nexport type BlockTag = RPCSPEC09.EBlockTag;\nexport const { EBlockTag: BlockTag } = RPCSPEC09;\n","import { base64 } from '@scure/base';\n\nexport const IS_BROWSER = typeof window !== 'undefined';\n\nconst STRING_ZERO = '0';\n\n/**\n * Some functions recreated from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts\n * enc-utils is not a dependency to avoid using `Buffer` which only works in node and not browsers\n */\n\n/**\n * Convert array buffer to string\n *\n * *[internal usage]*\n *\n * @param {ArrayBuffer} array The ArrayBuffer to convert to string.\n * @returns {string} The converted string.\n *\n * @example\n * ```typescript\n * const buffer = new ArrayBuffer(5);\n * const view = new Uint8Array(buffer);\n * [72, 101, 108, 108, 111].forEach((x, idx) => view[idx] = x);\n * const result = encode.arrayBufferToString(buffer);\n * // result = \"Hello\"\n * ```\n */\nexport function arrayBufferToString(array: ArrayBuffer): string {\n return new Uint8Array(array).reduce((data, byte) => data + String.fromCharCode(byte), '');\n}\n\n/**\n * Convert utf8-string to Uint8Array\n *\n * *[internal usage]*\n *\n * @param {string} str The UTF-8 string to convert.\n * @returns {Uint8Array} The encoded Uint8Array.\n *\n * @example\n * ```typescript\n * const myString = 'Hi';\n * const result = encode.utf8ToArray(myString);\n * // result = Uint8Array(2) [ 72, 105 ]\n * ```\n */\nexport function utf8ToUint8Array(str: string): Uint8Array {\n return new TextEncoder().encode(str);\n}\n\n/**\n * @deprecated use utf8ToUint8Array instead\n */\nexport const utf8ToArray = utf8ToUint8Array;\n\n/**\n * Convert utf8-string to bigint\n *\n * @param str The UTF-8 string to convert.\n * @returns The converted bigint.\n */\nexport function utf8ToBigInt(str: string): bigint {\n return uint8ArrayToBigInt(utf8ToUint8Array(str));\n}\n\n/**\n * Convert string to array buffer (browser and node compatible)\n *\n * @param {string} a The Base64 encoded string to convert.\n * @returns {Uint8Array} The decoded Uint8Array.\n *\n * @example\n * ```typescript\n * const base64String = 'SGVsbG8='; // 'Hello' in Base64\n * const result = encode.atobUniversal(base64String);\n * // result = Uint8Array(5) [ 72, 101, 108, 108, 111 ]\n * ```\n */\nexport function atobUniversal(a: string): Uint8Array {\n return base64.decode(a);\n}\n\n/**\n * Convert array buffer to string (browser and node compatible)\n *\n * @param {ArrayBuffer} b The Array buffer.\n * @returns {string} The Base64 encoded string.\n *\n * @example\n * ```typescript\n * const buffer = new Uint8Array([72, 101, 108, 108, 111]); // Array with ASCII values for 'Hello'\n * const result = encode.btoaUniversal(buffer);\n * // result = \"SGVsbG8=\"\n * ```\n */\nexport function btoaUniversal(b: ArrayBuffer): string {\n return base64.encode(new Uint8Array(b));\n}\n\n/**\n * Convert array buffer to hex-string\n *\n * @param {Uint8Array} buffer The encoded Uint8Array.\n * @returns {string} The hex-string\n *\n * @example\n * ```typescript\n * const buffer = new Uint8Array([72, 101, 108, 108, 111]); // Array with ASCII values for 'Hello'\n * const result = encode.buf2hex(buffer);\n * // result = \"48656c6c6f\"\n * ```\n */\nexport function buf2hex(buffer: Uint8Array): string {\n return buffer.reduce((r, x) => r + x.toString(16).padStart(2, '0'), '');\n}\n\n/**\n * Remove hex prefix '0x' from hex-string\n * @param hex hex-string\n * @returns {string} The hex-string\n *\n * @example\n * ```typescript\n * const hexStringWithPrefix = '0x48656c6c6f';\n * const result = encode.removeHexPrefix(hexStringWithPrefix);\n * // result: \"48656c6c6f\"\n * ```\n */\nexport function removeHexPrefix(hex: string): string {\n return hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;\n}\n\n/**\n * Add hex prefix '0x' to base16-string\n * @param hex base16-string\n * @returns {string} The hex-string\n *\n * @example\n * ```typescript\n * const plainHexString = '48656c6c6f';\n * const result = encode.addHexPrefix(plainHexString);\n * // result: \"0x48656c6c6f\"\n * ```\n */\nexport function addHexPrefix(hex: string): string {\n return `0x${removeHexPrefix(hex)}`;\n}\n\n/**\n * Prepend or append to string\n *\n * *[internal usage]*\n *\n * Pads a string to a certain length with a specific string.\n * The padding can be applied either to the left or the right of the input string.\n *\n * @param {string} str The string to pad.\n * @param {number} length The target length for the padded string.\n * @param {boolean} left Set to true to add padding to the left, false to add it to the right.\n * @param {string} [padding='0'] The string to use for padding. Defaults to '0'.\n * @returns {string} The padded string.\n *\n * @example\n * ```typescript\n * const myString = 'hello';\n * const result = padString(myString, 10, true);\n * // result = '00000hello'\n * ```\n */\nfunction padString(\n str: string,\n length: number,\n left: boolean,\n padding: string = STRING_ZERO\n): string {\n const diff = length - str.length;\n let result = str;\n if (diff > 0) {\n const pad = padding.repeat(diff);\n result = left ? pad + str : str + pad;\n }\n return result;\n}\n\n/**\n * Prepend string (default with '0')\n *\n * Pads a string to a certain length with a specific string.\n * The padding can be applied only to the left of the input string.\n *\n * @param {string} str The string to pad.\n * @param {number} length The target length for the padded string.\n * @param {string} [padding='0'] The string to use for padding. Defaults to '0'.\n * @returns {string} The padded string.\n * @example\n * ```typescript\n * const myString = '1A3F';\n * const result = encode.padLeft(myString, 10);\n * // result: '0000001A3F'\n * ```\n */\nexport function padLeft(str: string, length: number, padding: string = STRING_ZERO): string {\n return padString(str, length, true, padding);\n}\n\n/**\n * Calculate byte length of string\n *\n * *[no internal usage]*\n *\n * Calculates the byte length of a string based on a specified byte size.\n * The function rounds up the byte count to the nearest multiple of the specified byte size.\n *\n * @param {string} str The string whose byte length is to be calculated.\n * @param {number} [byteSize='8'] The size of the byte block to round up to. Defaults to 8.\n * @returns {number} The calculated byte length, rounded to the nearest multiple of byteSize.\n *\n * @example\n * ```typescript\n * const myString = 'Hello';\n * const result = encode.calcByteLength(myString, 4);\n * // result = 8 (rounded up to the nearest multiple of 4)\n *\n * ```\n */\nexport function calcByteLength(str: string, byteSize: number = 8): number {\n const { length } = str;\n const remainder = length % byteSize;\n return remainder ? ((length - remainder) / byteSize) * byteSize + byteSize : length;\n}\n\n/**\n * Prepend '0' to string bytes\n *\n * *[no internal usage]*\n *\n *\n * * Prepends padding to the left of a string to ensure it matches a specific byte length.\n * The function uses a specified padding character and rounds up the string length to the nearest multiple of `byteSize`.\n *\n * @param {string} str The string to be padded.\n * @param {number} [byteSize='8'] The byte block size to which the string length should be rounded up. Defaults to 8.\n * @param {string} [padding='0'] The character to use for padding. Defaults to '0'.\n * @returns {string} The padded string.\n *\n * @example\n * ```typescript\n * const myString = '123';\n * const result = encode.sanitizeBytes(myString);\n * // result: '00000123' (padded to 8 characters)\n * ```\n */\nexport function sanitizeBytes(\n str: string,\n byteSize: number = 8,\n padding: string = STRING_ZERO\n): string {\n return padLeft(str, calcByteLength(str, byteSize), padding);\n}\n\n/**\n * Sanitizes a hex-string by removing any existing '0x' prefix, padding the string with '0' to ensure it has even length,\n * and then re-adding the '0x' prefix.\n *\n * *[no internal usage]*\n * @param {string} hex hex-string\n * @returns {string} format: hex-string\n *\n * @example\n * ```typescript\n * const unevenHex = '0x23abc';\n * const result = encode.sanitizeHex(unevenHex);\n * // result = '0x023abc' (padded to ensure even length)\n * ```\n */\nexport function sanitizeHex(hex: string): string {\n const hexWithoutPrefix = removeHexPrefix(hex);\n const sanitizedHex = sanitizeBytes(hexWithoutPrefix, 2);\n return sanitizedHex ? addHexPrefix(sanitizedHex) : sanitizedHex;\n}\n\n/**\n * String transformation util\n *\n * Pascal case to screaming snake case\n *\n * @param {string} text The PascalCase string to convert.\n * @returns {string} The converted snake_case string in uppercase.\n *\n * @example\n * ```typescript\n * const pascalString = 'PascalCaseExample';\n * const result = encode.pascalToSnake(pascalString);\n * // result: 'PASCAL_CASE_EXAMPLE'\n * ```\n */\nexport const pascalToSnake = (text: string): string =>\n /[a-z]/.test(text)\n ? text\n .split(/(?=[A-Z])/)\n .join('_')\n .toUpperCase()\n : text;\n\n/**\n * Combine multiple Uint8Arrays into one.\n * Useful for wallet path creation.\n * @param {Uint8Array[]} uint8arrays An array of Uint8Array.\n * @returns {Uint8Array} all the Uint8Arrays joined.\n * @example\n * ```typescript\n * const path0buff = new Uint8Array([128, 0, 10, 85]);\n * const path1buff = new Uint8Array([71, 65, 233, 201]);\n * const result = encode.concatenateArrayBuffer([path0buff, path1buff]);\n * // result = Uint8Array(8) [128, 0, 10, 85, 71, 65, 233, 201]\n * ```\n */\nexport function concatenateArrayBuffer(uint8arrays: Uint8Array[]): Uint8Array {\n const totalLength = uint8arrays.reduce((total, uint8array) => total + uint8array.byteLength, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n uint8arrays.forEach((uint8array) => {\n result.set(uint8array, offset);\n offset += uint8array.byteLength;\n });\n return result;\n}\n\n/**\n * Convert hex string to Uint8Array\n *\n * @param {string} hex The hex string to convert (with or without '0x' prefix)\n * @returns {Uint8Array} The converted byte array\n * @throws {Error} If the string contains non-hexadecimal characters\n *\n * @example\n * ```typescript\n * const hexString = '0x48656c6c6f';\n * const result = encode.hexStringToUint8Array(hexString);\n * // result = Uint8Array(5) [ 72, 101, 108, 108, 111 ]\n * ```\n */\nexport function hexStringToUint8Array(hex: string): Uint8Array {\n // Validate hex string (only 0-9, a-f, A-F allowed) regardless of prefix\n if (!isHexString(addHexPrefix(hex))) {\n throw new Error(`Invalid hex string: \"${hex}\"`);\n }\n // Pad to even length without prefix\n const paddedHex = removeHexPrefix(sanitizeHex(hex));\n // Create Uint8Array directly\n const bytes = new Uint8Array(paddedHex.length / 2);\n for (let i = 0; i < paddedHex.length; i += 2) {\n bytes[i / 2] = parseInt(paddedHex.substring(i, i + 2), 16);\n }\n return bytes;\n}\n\n/**\n * Check if string is a hex string (starts with 0x/0X followed by hex digits)\n * @param hex string to check\n * @returns true if hex string\n */\nfunction isHexString(hex: string): boolean {\n return /^0[xX][0-9a-fA-F]*$/.test(hex);\n}\n\n/**\n * Check if string contains only decimal digits\n * @param str string to check\n * @returns true if decimal string\n */\nfunction isDecimalString(str: string): boolean {\n return /^[0-9]+$/.test(str);\n}\n\n/**\n * Convert any string to Uint8Array\n *\n * Handles three types of strings:\n * - Hex strings (e.g., '0x123f') - converts hex bytes to Uint8Array\n * - Decimal strings (e.g., '124324332') - converts decimal number to bytes\n * - Text strings (e.g., 'I am cool ☥') - converts UTF-8 text to bytes\n *\n * @param {string} str The string to convert\n * @returns {Uint8Array} The converted byte array\n *\n * @example\n * ```typescript\n * // Hex string\n * const hex = stringToUint8Array('0x48656c6c6f');\n * // result = Uint8Array(5) [ 72, 101, 108, 108, 111 ]\n *\n * // Decimal string\n * const decimal = stringToUint8Array('256');\n * // result = Uint8Array(2) [ 1, 0 ]\n *\n * // Text string\n * const text = stringToUint8Array('Hello ☥');\n * // result = UTF-8 encoded bytes\n * ```\n */\nexport function stringToUint8Array(str: string): Uint8Array {\n // Check if it's a hex string\n if (isHexString(str)) {\n return hexStringToUint8Array(str);\n }\n\n // Check if it's a decimal string\n if (isDecimalString(str)) {\n // Convert decimal string to bigint then to bytes\n const value = BigInt(str);\n return bigIntToUint8Array(value);\n }\n\n // Otherwise treat as UTF-8 text\n return utf8ToUint8Array(str);\n}\n\n/**\n * Convert bigint to Uint8Array (big-endian)\n *\n * @param {bigint} value The bigint value to convert (must be non-negative)\n * @returns {Uint8Array} The converted byte array in big-endian byte order\n * @throws {Error} If value is negative\n *\n * @example\n * ```typescript\n * const value = 256n; // 0x0100\n * const result = encode.bigIntToUint8Array(value);\n * // result = Uint8Array([1, 0]) - big-endian, MSB first\n * ```\n */\nexport function bigIntToUint8Array(value: bigint): Uint8Array {\n // Validate non-negative\n if (value < 0n) {\n throw new Error(`Cannot convert negative bigint ${value} to Uint8Array`);\n }\n\n // Special case for 0\n if (value === 0n) {\n return new Uint8Array([0]);\n }\n\n // Convert to hex string without '0x' prefix\n let hex = value.toString(16);\n // Pad to even length\n if (hex.length % 2 !== 0) {\n hex = `0${hex}`;\n }\n // Create Uint8Array from hex\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);\n }\n return bytes;\n}\n\n/**\n * Convert Uint8Array to bigint (big-endian)\n *\n * @param {Uint8Array} data The Uint8Array to convert (interpreted as big-endian)\n * @returns {bigint} The converted bigint value\n *\n * @example\n * ```typescript\n * const data = new Uint8Array([1, 0]); // Big-endian representation\n * const result = encode.uint8ArrayToBigInt(data);\n * // result = 256n (0x0100)\n * ```\n */\nexport function uint8ArrayToBigInt(data: Uint8Array): bigint {\n if (!data || data.length === 0) {\n return 0n;\n }\n // Convert Uint8Array to hex string\n let hex = '0x';\n for (let i = 0; i < data.length; i += 1) {\n hex += data[i].toString(16).padStart(2, '0');\n }\n return BigInt(hex);\n}\n","import { DEFAULT_GLOBAL_CONFIG } from './constants';\n\ntype DefaultConfig = typeof DEFAULT_GLOBAL_CONFIG;\ntype CustomConfig = { [key: string]: any };\n\ntype ConfigData = DefaultConfig & CustomConfig;\n\nclass Configuration {\n private static instance: Configuration;\n\n private config!: ConfigData;\n\n private constructor() {\n this.initialize();\n }\n\n private initialize(): void {\n this.config = { ...DEFAULT_GLOBAL_CONFIG };\n }\n\n public static getInstance(): Configuration {\n if (!Configuration.instance) {\n Configuration.instance = new Configuration();\n }\n return Configuration.instance;\n }\n\n /**\n * Get a nested value from an object using a dot-notation path\n * @param obj - The object to traverse\n * @param path - The dot-notation path (e.g., 'a.b.c')\n * @returns The value at the path, or undefined if not found\n */\n private getNestedValue(obj: any, path: string): any {\n const keys = path.split('.');\n return keys.reduce((current, key) => {\n if (current === null || current === undefined) {\n return undefined;\n }\n return current[key];\n }, obj);\n }\n\n /**\n * Set a nested value in an object using a dot-notation path\n * @param obj - The object to modify\n * @param path - The dot-notation path (e.g., 'a.b.c')\n * @param value - The value to set\n */\n private setNestedValue(obj: any, path: string, value: any): void {\n const keys = path.split('.');\n const lastKey = keys.pop()!;\n\n const target = keys.reduce((current, key) => {\n if (!(key in current) || typeof current[key] !== 'object' || current[key] === null) {\n // eslint-disable-next-line no-param-reassign\n current[key] = {};\n }\n return current[key];\n }, obj);\n\n target[lastKey] = value;\n }\n\n public get<K extends keyof DefaultConfig>(key: K): DefaultConfig[K];\n public get(key: string, defaultValue?: any): any;\n public get(key: string, defaultValue?: any) {\n // Check if it's a nested path (contains a dot)\n if (key.includes('.')) {\n const value = this.getNestedValue(this.config, key);\n return value ?? defaultValue;\n }\n return this.config[key] ?? defaultValue;\n }\n\n public set<K extends keyof DefaultConfig>(key: K, value: DefaultConfig[K]): void;\n public set(key: string, value: any): void;\n public set(key: string, value: any): void {\n // Check if it's a nested path (contains a dot)\n if (key.includes('.')) {\n this.setNestedValue(this.config, key, value);\n } else {\n this.config[key] = value;\n }\n }\n\n public update(configData: Partial<DefaultConfig> & CustomConfig): void {\n this.config = {\n ...this.config,\n ...configData,\n };\n }\n\n public getAll(): ConfigData {\n return { ...this.config };\n }\n\n public reset(): void {\n this.initialize();\n }\n\n public delete<K extends keyof DefaultConfig>(key: K): void;\n public delete(key: string): void;\n public delete(key: string): void {\n delete this.config[key];\n }\n\n public hasKey<K extends keyof DefaultConfig>(key: K): boolean;\n public hasKey(key: string): boolean;\n public hasKey(key: string): boolean {\n return key in this.config;\n }\n}\n\n// Export a single instance\nexport const config = Configuration.getInstance();\n","import { ValuesType } from '../types/helpers/valuesType';\n\nexport const LogLevelIndex = {\n DEBUG: 5,\n INFO: 4,\n WARN: 3,\n ERROR: 2,\n FATAL: 1,\n OFF: 0,\n};\n\nexport type LogLevelIndex = ValuesType<typeof LogLevelIndex>;\n\nexport type LogLevel = keyof typeof LogLevelIndex;\n","/* eslint-disable no-console */\nimport { config } from './config';\nimport { LogLevelIndex, LogLevel } from './logger.type';\n\ninterface LogMessage {\n level: LogLevel;\n message: string;\n timestamp: string;\n data?: any;\n}\n/**\n * Logging class providing different levels of log\n */\nclass Logger {\n private static instance: Logger;\n\n private config: typeof config;\n\n private constructor() {\n this.config = config;\n }\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n private getTimestamp(): string {\n return new Date().toISOString();\n }\n\n private shouldLog(messageLevel: LogLevelIndex): boolean {\n const configLevel = this.config.get('logLevel', 'INFO');\n return messageLevel <= LogLevelIndex[configLevel as LogLevel];\n }\n\n private formatMessage(logMessage: LogMessage): string {\n const { level, message, timestamp, data } = logMessage;\n let formattedMessage = `[${timestamp}] ${level}: ${message}`;\n\n if (data) {\n try {\n formattedMessage += `\\n${JSON.stringify(data, null, 2)}`;\n } catch (error) {\n formattedMessage += `\\n[JSON.stringify Error/Circular]: ${error}`;\n }\n }\n\n return formattedMessage;\n }\n\n private log(level: LogLevel, message: string, data?: any): void {\n if (!this.shouldLog(LogLevelIndex[level])) {\n return;\n }\n\n const logMessage: LogMessage = {\n level,\n message,\n timestamp: this.getTimestamp(),\n data,\n };\n\n const formattedMessage = this.formatMessage(logMessage);\n\n switch (level) {\n case 'DEBUG':\n console.debug(formattedMessage);\n break;\n case 'INFO':\n console.info(formattedMessage);\n break;\n case 'WARN':\n console.warn(formattedMessage);\n break;\n case 'ERROR':\n case 'FATAL':\n console.error(formattedMessage);\n break;\n case 'OFF':\n // Do nothing when logging is off\n break;\n default:\n console.log(formattedMessage); // Default fallback for unknown log levels\n break;\n }\n }\n\n /**\n * debug will be displayed when LogLevel level is set to DEBUG(5)\n */\n public debug(message: string, data?: any): void {\n this.log('DEBUG', message, data);\n }\n\n /**\n * info will be displayed when LogLevel level is set to DEBUG(5), INFO(4)\n */\n public info(message: string, data?: any): void {\n this.log('INFO', message, data);\n }\n\n /**\n * warn will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3)\n */\n public warn(message: string, data?: any): void {\n this.log('WARN', message, data);\n }\n\n /**\n * error will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3), ERROR(2)\n */\n public error(message: string, data?: any): void {\n this.log('ERROR', message, data);\n }\n\n /**\n * fatal will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3), ERROR(2), FATAL(1)\n */\n public fatal(message: string, data?: any): void {\n this.log('FATAL', message, data);\n }\n\n /**\n * Set the logging level you would like system to display\n * * 5 DEBUG - show all logs\n * * 4 INFO\n * * 3 WARN\n * * 2 ERROR\n * * 1 FATAL\n * * 0 OFF - disable logs\n */\n public setLogLevel(level: LogLevel): void {\n this.config.set('logLevel', level);\n }\n\n public getLogLevel(): LogLevel {\n return this.config.get('logLevel', 'INFO');\n }\n\n /**\n *\n * @returns logs levels displayed on the configured LogLevel\n */\n public getEnabledLogLevels() {\n return Object.keys(LogLevelIndex).filter((s) => {\n return this.shouldLog(LogLevelIndex[s as LogLevel]) && s !== 'OFF';\n });\n }\n}\n\n// Export a single instance\n/**\n * Logger instance, use for the system logging.\n * Higher the logger level index, higher the LogLevel required to display log.\n * Default should be INFO\n *\n * DEBUG: 5,\n * INFO: 4,\n * WARN: 3,\n * ERROR: 2,\n * FATAL: 1,\n */\nexport const logger = Logger.getInstance();\n","import {\n NetworkName,\n StarknetChainId,\n SupportedRpcVersion,\n SYSTEM_MESSAGES,\n} from '../global/constants';\nimport {\n AccountInvocationItem,\n AccountInvocations,\n BigNumberish,\n BlockIdentifier,\n BlockTag,\n Call,\n DeclareContractTransaction,\n DeployAccountContractTransaction,\n getEstimateFeeBulkOptions,\n getSimulateTransactionOptions,\n Invocation,\n InvocationsDetailsWithNonce,\n isRPC08Plus_ResourceBoundsBN,\n RPC_ERROR,\n RpcProviderOptions,\n waitForTransactionOptions,\n type fastWaitForTransactionOptions,\n} from '../types';\nimport assert from '../utils/assert';\nimport { ETransactionType, JRPC, RPCSPEC09 as RPC } from '../types/api';\nimport { BatchClient } from '../utils/batch';\nimport { CallData } from '../utils/calldata';\nimport { isSierra } from '../utils/contract';\nimport { LibraryError, RpcError } from '../utils/errors';\nimport { validateAndParseEthAddress } from '../utils/eth';\nimport fetch from '../utils/connect/fetch';\nimport { getSelector, getSelectorFromName } from '../utils/hash';\nimport { stringify } from '../utils/json';\nimport { isNumber } from '../utils/typed';\nimport {\n bigNumberishArrayToHexadecimalStringArray,\n getHexStringArray,\n toHex,\n toStorageKey,\n} from '../utils/num';\nimport { Block, getDefaultNodeUrl, wait } from '../utils/provider';\nimport { isSupportedSpecVersion, isV3Tx, isVersion } from '../utils/resolve';\nimport {\n decompressProgram,\n signatureToHexArray,\n resourceBoundsToHexString,\n toTransactionVersion,\n} from '../utils/stark';\nimport { getVersionsByType } from '../utils/transaction';\nimport { logger } from '../global/logger';\nimport { config } from '../global/config';\n// TODO: check if we can filet type before entering to this method, as so to specify here only RPC 0.8 types\n\nexport class RpcChannel {\n readonly id = 'RPC090';\n\n /**\n * RPC specification version this Channel class implements\n */\n readonly channelSpecVersion: SupportedRpcVersion = SupportedRpcVersion.v0_9_0;\n\n public nodeUrl: string;\n\n public headers: object;\n\n public requestId: number;\n\n readonly blockIdentifier: BlockIdentifier;\n\n readonly retries: number;\n\n readonly waitMode: boolean; // behave like web2 rpc and return when tx is processed\n\n private chainId?: StarknetChainId;\n\n /**\n * RPC specification version of the connected node\n */\n private specVersion?: SupportedRpcVersion;\n\n private transactionRetryIntervalFallback?: number;\n\n private batchClient?: BatchClient<RPC.Methods>;\n\n private baseFetch: NonNullable<RpcProviderOptions['baseFetch']>;\n\n constructor(optionsOrProvider?: RpcProviderOptions) {\n const {\n baseFetch,\n batch,\n blockIdentifier,\n chainId,\n headers,\n nodeUrl,\n retries,\n specVersion,\n transactionRetryIntervalFallback,\n waitMode,\n } = optionsOrProvider || {};\n if (Object.values(NetworkName).includes(nodeUrl as NetworkName)) {\n this.nodeUrl = getDefaultNodeUrl(\n nodeUrl as NetworkName,\n optionsOrProvider?.default,\n this.channelSpecVersion\n );\n } else if (nodeUrl) {\n this.nodeUrl = nodeUrl;\n } else {\n this.nodeUrl = getDefaultNodeUrl(\n undefined,\n optionsOrProvider?.default,\n this.channelSpecVersion\n );\n }\n const channelDefaults = config.get('channelDefaults');\n this.baseFetch = baseFetch || config.get('fetch') || fetch;\n this.blockIdentifier = blockIdentifier ?? channelDefaults.options.blockIdentifier;\n this.chainId = chainId;\n this.headers = { ...channelDefaults.options.headers, ...headers };\n this.retries = retries ?? channelDefaults.options.retries;\n this.specVersion = specVersion;\n this.transactionRetryIntervalFallback = transactionRetryIntervalFallback;\n this.waitMode = waitMode ?? false;\n\n this.requestId = 0;\n\n if (isNumber(batch)) {\n this.batchClient = new BatchClient<RPC.Methods>({\n nodeUrl: this.nodeUrl,\n headers: this.headers,\n interval: batch,\n baseFetch: this.baseFetch,\n rpcMethods: {} as RPC.Methods, // Type information only, not used at runtime\n });\n }\n\n logger.debug('Using Channel', this.id);\n }\n\n public readSpecVersion() {\n return this.specVersion;\n }\n\n private get transactionRetryIntervalDefault() {\n return this.transactionRetryIntervalFallback ?? 5000;\n }\n\n public setChainId(chainId: StarknetChainId) {\n this.chainId = chainId;\n }\n\n public fetch(method: string, params?: object, id: string | number = 0) {\n const rpcRequestBody: JRPC.RequestBody = {\n id,\n jsonrpc: '2.0',\n method,\n ...(params && { params }),\n };\n return this.baseFetch(this.nodeUrl, {\n method: 'POST',\n body: stringify(rpcRequestBody),\n headers: this.headers as Record<string, string>,\n });\n }\n\n protected errorHandler(method: string, params: any, rpcError?: JRPC.Error, otherError?: any) {\n if (rpcError) {\n throw new RpcError(rpcError as RPC_ERROR, method, params);\n }\n if (otherError instanceof LibraryError) {\n throw otherError;\n }\n if (otherError) {\n throw Error(otherError.message);\n }\n }\n\n protected async fetchEndpoint<T extends keyof RPC.Methods>(\n method: T,\n params?: RPC.M