starknet 6.22.0 → 6.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [6.23.0](https://github.com/starknet-io/starknet.js/compare/v6.22.0...v6.23.0) (2025-01-29)
2
+
3
+ ### Features
4
+
5
+ - logger, config, deprecate legacy tx ([#1302](https://github.com/starknet-io/starknet.js/issues/1302)) ([d0ffbcc](https://github.com/starknet-io/starknet.js/commit/d0ffbcc9bef8b6069f79644d3b54667b3d75dbf2))
6
+
1
7
  # [6.22.0](https://github.com/starknet-io/starknet.js/compare/v6.21.2...v6.22.0) (2025-01-29)
2
8
 
3
9
  ### Features
package/dist/index.d.ts CHANGED
@@ -1352,6 +1352,17 @@ var index$3 = /*#__PURE__*/_mergeNamespaces({
1352
1352
  RPCSPEC07: RPCSPEC07
1353
1353
  }, [RPCSPEC07]);
1354
1354
 
1355
+ declare const LogLevelIndex: {
1356
+ DEBUG: number;
1357
+ INFO: number;
1358
+ WARN: number;
1359
+ ERROR: number;
1360
+ FATAL: number;
1361
+ OFF: number;
1362
+ };
1363
+ type LogLevelIndex = ValuesType<typeof LogLevelIndex>;
1364
+ type LogLevel = keyof typeof LogLevelIndex;
1365
+
1355
1366
  declare const IS_BROWSER: boolean;
1356
1367
  /**
1357
1368
  * Some functions recreated from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts
@@ -1654,11 +1665,19 @@ declare const SNIP9_V1_INTERFACE_ID = "0x68cfd18b92d1907b8ba3cc324900277f5a36220
1654
1665
  declare const SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
1655
1666
  declare const HARDENING_BYTE = 128;
1656
1667
  declare const HARDENING_4BYTES = 2147483648n;
1668
+ declare const DEFAULT_GLOBAL_CONFIG: {
1669
+ legacyMode: boolean;
1670
+ logLevel: LogLevel;
1671
+ };
1672
+ declare const SYSTEM_MESSAGES: {
1673
+ legacyTxWarningMessage: string;
1674
+ };
1657
1675
 
1658
1676
  declare const constants_ADDR_BOUND: typeof ADDR_BOUND;
1659
1677
  declare const constants_API_VERSION: typeof API_VERSION;
1660
1678
  type constants_BaseUrl = BaseUrl;
1661
1679
  declare const constants_BaseUrl: typeof BaseUrl;
1680
+ declare const constants_DEFAULT_GLOBAL_CONFIG: typeof DEFAULT_GLOBAL_CONFIG;
1662
1681
  type constants_FeeMarginPercentage = FeeMarginPercentage;
1663
1682
  declare const constants_FeeMarginPercentage: typeof FeeMarginPercentage;
1664
1683
  declare const constants_HARDENING_4BYTES: typeof HARDENING_4BYTES;
@@ -1678,6 +1697,7 @@ declare const constants_RPC_DEFAULT_VERSION: typeof RPC_DEFAULT_VERSION;
1678
1697
  declare const constants_RPC_NODES: typeof RPC_NODES;
1679
1698
  declare const constants_SNIP9_V1_INTERFACE_ID: typeof SNIP9_V1_INTERFACE_ID;
1680
1699
  declare const constants_SNIP9_V2_INTERFACE_ID: typeof SNIP9_V2_INTERFACE_ID;
1700
+ declare const constants_SYSTEM_MESSAGES: typeof SYSTEM_MESSAGES;
1681
1701
  type constants_StarknetChainId = StarknetChainId;
1682
1702
  declare const constants_StarknetChainId: typeof StarknetChainId;
1683
1703
  declare const constants_TEXT_TO_FELT_MAX_LEN: typeof TEXT_TO_FELT_MAX_LEN;
@@ -1686,7 +1706,7 @@ declare const constants_TransactionHashPrefix: typeof TransactionHashPrefix;
1686
1706
  declare const constants_UDC: typeof UDC;
1687
1707
  declare const constants_ZERO: typeof ZERO;
1688
1708
  declare namespace constants {
1689
- export { constants_ADDR_BOUND as ADDR_BOUND, constants_API_VERSION as API_VERSION, constants_BaseUrl as BaseUrl, constants_FeeMarginPercentage as FeeMarginPercentage, constants_HARDENING_4BYTES as HARDENING_4BYTES, constants_HARDENING_BYTE as HARDENING_BYTE, constants_IS_BROWSER as IS_BROWSER, constants_MASK_250 as MASK_250, constants_MASK_31 as MASK_31, constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE, constants_NetworkName as NetworkName, constants_OutsideExecutionCallerAny as OutsideExecutionCallerAny, constants_PRIME as PRIME, constants_RANGE_FELT as RANGE_FELT, constants_RANGE_I128 as RANGE_I128, constants_RANGE_U128 as RANGE_U128, constants_RPC_DEFAULT_VERSION as RPC_DEFAULT_VERSION, constants_RPC_NODES as RPC_NODES, constants_SNIP9_V1_INTERFACE_ID as SNIP9_V1_INTERFACE_ID, constants_SNIP9_V2_INTERFACE_ID as SNIP9_V2_INTERFACE_ID, constants_StarknetChainId as StarknetChainId, constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN, ETransactionVersion$1 as TRANSACTION_VERSION, constants_TransactionHashPrefix as TransactionHashPrefix, constants_UDC as UDC, constants_ZERO as ZERO };
1709
+ export { constants_ADDR_BOUND as ADDR_BOUND, constants_API_VERSION as API_VERSION, constants_BaseUrl as BaseUrl, constants_DEFAULT_GLOBAL_CONFIG as DEFAULT_GLOBAL_CONFIG, constants_FeeMarginPercentage as FeeMarginPercentage, constants_HARDENING_4BYTES as HARDENING_4BYTES, constants_HARDENING_BYTE as HARDENING_BYTE, constants_IS_BROWSER as IS_BROWSER, constants_MASK_250 as MASK_250, constants_MASK_31 as MASK_31, constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE, constants_NetworkName as NetworkName, constants_OutsideExecutionCallerAny as OutsideExecutionCallerAny, constants_PRIME as PRIME, constants_RANGE_FELT as RANGE_FELT, constants_RANGE_I128 as RANGE_I128, constants_RANGE_U128 as RANGE_U128, constants_RPC_DEFAULT_VERSION as RPC_DEFAULT_VERSION, constants_RPC_NODES as RPC_NODES, constants_SNIP9_V1_INTERFACE_ID as SNIP9_V1_INTERFACE_ID, constants_SNIP9_V2_INTERFACE_ID as SNIP9_V2_INTERFACE_ID, constants_SYSTEM_MESSAGES as SYSTEM_MESSAGES, constants_StarknetChainId as StarknetChainId, constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN, ETransactionVersion$1 as TRANSACTION_VERSION, constants_TransactionHashPrefix as TransactionHashPrefix, constants_UDC as UDC, constants_ZERO as ZERO };
1690
1710
  }
1691
1711
 
1692
1712
  declare const ec_weierstrass: typeof weierstrass;
@@ -8053,6 +8073,87 @@ declare namespace connect {
8053
8073
  export { connect_addDeclareTransaction as addDeclareTransaction, connect_addInvokeTransaction as addInvokeTransaction, connect_addStarknetChain as addStarknetChain, connect_deploymentData as deploymentData, connect_getPermissions as getPermissions, connect_onAccountChange as onAccountChange, connect_onNetworkChanged as onNetworkChanged, connect_requestAccounts as requestAccounts, connect_requestChainId as requestChainId, connect_signMessage as signMessage, connect_supportedSpecs as supportedSpecs, connect_switchStarknetChain as switchStarknetChain, connect_watchAsset as watchAsset };
8054
8074
  }
8055
8075
 
8076
+ type ConfigData = {
8077
+ [key: string]: any;
8078
+ } & typeof DEFAULT_GLOBAL_CONFIG;
8079
+ declare class Configuration {
8080
+ private static instance;
8081
+ private config;
8082
+ private constructor();
8083
+ private initialize;
8084
+ static getInstance(): Configuration;
8085
+ get<K extends keyof ConfigData>(key: K, defaultValue?: ConfigData[K]): ConfigData[K] | undefined;
8086
+ set<K extends keyof ConfigData>(key: K, value: ConfigData[K]): void;
8087
+ update(configData: Partial<ConfigData>): void;
8088
+ getAll(): ConfigData;
8089
+ reset(): void;
8090
+ delete(key: keyof ConfigData): void;
8091
+ hasKey(key: keyof ConfigData): boolean;
8092
+ }
8093
+ declare const config: Configuration;
8094
+
8095
+ /**
8096
+ * Logging class providing different levels of log
8097
+ */
8098
+ declare class Logger {
8099
+ private static instance;
8100
+ private config;
8101
+ private constructor();
8102
+ static getInstance(): Logger;
8103
+ private getTimestamp;
8104
+ private shouldLog;
8105
+ private formatMessage;
8106
+ private log;
8107
+ /**
8108
+ * debug will be displayed when LogLevel level is set to DEBUG(5)
8109
+ */
8110
+ debug(message: string, data?: any): void;
8111
+ /**
8112
+ * info will be displayed when LogLevel level is set to DEBUG(5), INFO(4)
8113
+ */
8114
+ info(message: string, data?: any): void;
8115
+ /**
8116
+ * warn will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3)
8117
+ */
8118
+ warn(message: string, data?: any): void;
8119
+ /**
8120
+ * error will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3), ERROR(2)
8121
+ */
8122
+ error(message: string, data?: any): void;
8123
+ /**
8124
+ * fatal will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3), ERROR(2), FATAL(1)
8125
+ */
8126
+ fatal(message: string, data?: any): void;
8127
+ /**
8128
+ * Set the logging level you would like system to display
8129
+ * * 5 DEBUG - show all logs
8130
+ * * 4 INFO
8131
+ * * 3 WARN
8132
+ * * 2 ERROR
8133
+ * * 1 FATAL
8134
+ * * 0 OFF - disable logs
8135
+ */
8136
+ setLogLevel(level: LogLevel): void;
8137
+ getLogLevel(): LogLevel;
8138
+ /**
8139
+ *
8140
+ * @returns logs levels displayed on the configured LogLevel
8141
+ */
8142
+ getEnabledLogLevels(): string[];
8143
+ }
8144
+ /**
8145
+ * Logger instance, use for the system logging.
8146
+ * Higher the logger level index, higher the LogLevel required to display log.
8147
+ * Default should be INFO
8148
+ *
8149
+ * DEBUG: 5,
8150
+ * INFO: 4,
8151
+ * WARN: 3,
8152
+ * ERROR: 2,
8153
+ * FATAL: 1,
8154
+ */
8155
+ declare const logger: Logger;
8156
+
8056
8157
  /**
8057
8158
  * Main
8058
8159
  */
@@ -8060,4 +8161,4 @@ declare namespace connect {
8060
8161
  /** @deprecated prefer the 'num' naming */
8061
8162
  declare const number: typeof num;
8062
8163
 
8063
- export { type Abi, type AbiEntry, type AbiEnum, type AbiEnums, type AbiEvent, type AbiEvents, type AbiInterfaces, type AbiStruct, type AbiStructs, Account, AccountInterface, type AccountInvocationItem, type AccountInvocations, type AccountInvocationsFactoryDetails, type AllowArray, type Args, type ArgsOrCalldata, type ArgsOrCalldataWithOptions, type ArraySignatureType, type AsyncContractFunction, BatchClient, type BatchClientOptions, type BigNumberish, type Block$1 as Block, type BlockIdentifier, type BlockNumber, BlockStatus, BlockTag, type BlockWithTxHashes, type Builtins, type ByteArray, type ByteCode, type CairoAssembly, type CairoContract, CairoCustomEnum, type CairoEnum, type CairoEnumRaw, type CairoEvent, type CairoEventDefinition, type CairoEventVariant, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoUint256, CairoUint512, type CairoVersion, type Call, type CallContractResponse, CallData, type CallDetails, type CallOptions, type CallStruct, type Calldata, type CompiledContract, type CompiledSierra, type CompiledSierraCasm, type CompilerVersion, type CompleteDeclareContractPayload, type CompressedProgram, Contract, type ContractClass, type ContractClassIdentifier, type ContractClassPayload, type ContractClassResponse, type ContractEntryPointFields, ContractFactory, type ContractFactoryParams, type ContractFunction, ContractInterface, type ContractOptions, type ContractVersion, CustomError, type DeclareAndDeployContractPayload, type DeclareContractPayload, type DeclareContractResponse, type DeclareContractTransaction, type DeclareDeployUDCResponse, type DeclareSignerDetails, type DeclareTransactionReceiptResponse, type DeployAccountContractPayload, type DeployAccountContractTransaction, type DeployAccountSignerDetails, type DeployAccountTransactionReceiptResponse, type DeployContractResponse, type DeployContractUDCResponse, type DeployTransactionReceiptResponse, type Details, ETH_ADDRESS, EntryPointType, type EntryPointsByType, type EstimateFee, type EstimateFeeAction, type EstimateFeeBulk, type EstimateFeeDetails, type EstimateFeeResponse, type EstimateFeeResponseBulk, EthSigner, type EventEntry, type FeeEstimate, type FunctionAbi, type GetBlockResponse, type GetTransactionReceiptResponse, type GetTransactionResponse, type GetTxReceiptResponseWithoutHelper, type HexCalldata, type InterfaceAbi, type Invocation, type Invocations, type InvocationsDetails, type InvocationsDetailsWithNonce, type InvocationsSignerDetails, type InvokeFunctionResponse, type InvokeOptions, type InvokeTransactionReceiptResponse, type L1HandlerTransactionReceiptResponse, type LedgerPathCalculation, LedgerSigner111 as LedgerSigner, LedgerSigner111, LedgerSigner221, type LegacyCompiledContract, type LegacyContractClass, type LegacyEvent, LibraryError, Literal, type MessageToL1, type MultiDeployContractResponse, type MultiType, NON_ZERO_PREFIX, type Nonce, type OptionalPayload, type OutsideCall, type OutsideExecution, type OutsideExecutionOptions, OutsideExecutionTypesV1, OutsideExecutionTypesV2, OutsideExecutionVersion, type OutsideTransaction, type ParsedEvent, type ParsedEvents, type ParsedStruct, type PendingBlock, type PendingStateUpdate, type Program, RpcProvider as Provider, ProviderInterface, type ProviderOptions, type PythonicHints, index$3 as RPC, rpc_0_6 as RPC06, rpc_0_7 as RPC07, RPCResponseParser, type RPC_ERROR, type RPC_ERROR_SET, type RawArgs, type RawArgsArray, type RawArgsObject, type RawCalldata, ReceiptTx, type RejectedTransactionReceiptResponse, ResponseParser, type Result, type RevertedTransactionReceiptResponse, RpcChannel, RpcError, RpcProvider, type RpcProviderOptions, type SIMULATION_FLAG, type SierraContractClass, type SierraContractEntryPointFields, type SierraEntryPointsByType, type SierraProgramDebugInfo, type Signature, Signer, SignerInterface, type SimulateTransactionDetails, type SimulateTransactionResponse, type SimulatedTransaction, type SimulationFlags, type StarkProfile, type StateUpdate, type StateUpdateResponse, type Storage, type SuccessfulTransactionReceiptResponse, TransactionExecutionStatus, TransactionFinalityStatus, type TransactionReceipt, type TransactionReceiptCallbacks, type TransactionReceiptCallbacksDefault, type TransactionReceiptCallbacksDefined, type TransactionReceiptStatus, type TransactionReceiptUtilityInterface, type TransactionReceiptValue, TransactionStatus, type TransactionStatusReceiptSets, TransactionType, type Tupled, type TypedContractV2, UINT_128_MAX, UINT_128_MIN, UINT_256_HIGH_MAX, UINT_256_HIGH_MIN, UINT_256_LOW_MAX, UINT_256_LOW_MIN, UINT_256_MAX, UINT_256_MIN, UINT_512_MAX, UINT_512_MIN, Uint, type Uint256, type Uint512, type UniversalDeployerContractPayload, type UniversalDetails, type UniversalSuggestedFee, type V2DeclareSignerDetails, type V2DeployAccountSignerDetails, type V2InvocationsSignerDetails, type V3DeclareSignerDetails, type V3DeployAccountSignerDetails, type V3InvocationsSignerDetails, type V3TransactionDetails, ValidateType, WalletAccount, type WeierstrassSignatureType, addAddressPadding, byteArray, cairo, constants, contractClassResponseToLegacyCompiledContract, defaultProvider, ec, encode, eth, index as events, extractContractHashes, fixProto, fixStack, getCalldata, getChecksumAddress, type getContractVersionOptions, type getEstimateFeeBulkOptions, getLedgerPathBuffer111 as getLedgerPathBuffer, getLedgerPathBuffer111, getLedgerPathBuffer221, type getSimulateTransactionOptions, index$1 as hash, isSierra, json, merkle, num, number, outsideExecution, parseCalldataField, provider, selector, shortString, splitArgsAndOptions, src5, stark, starknetId, transaction, typedData, index$2 as types, uint256$1 as uint256, units, v2 as v2hash, v3 as v3hash, validateAndParseAddress, validateChecksumAddress, type waitForTransactionOptions, connect as wallet };
8164
+ export { type Abi, type AbiEntry, type AbiEnum, type AbiEnums, type AbiEvent, type AbiEvents, type AbiInterfaces, type AbiStruct, type AbiStructs, Account, AccountInterface, type AccountInvocationItem, type AccountInvocations, type AccountInvocationsFactoryDetails, type AllowArray, type Args, type ArgsOrCalldata, type ArgsOrCalldataWithOptions, type ArraySignatureType, type AsyncContractFunction, BatchClient, type BatchClientOptions, type BigNumberish, type Block$1 as Block, type BlockIdentifier, type BlockNumber, BlockStatus, BlockTag, type BlockWithTxHashes, type Builtins, type ByteArray, type ByteCode, type CairoAssembly, type CairoContract, CairoCustomEnum, type CairoEnum, type CairoEnumRaw, type CairoEvent, type CairoEventDefinition, type CairoEventVariant, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoUint256, CairoUint512, type CairoVersion, type Call, type CallContractResponse, CallData, type CallDetails, type CallOptions, type CallStruct, type Calldata, type CompiledContract, type CompiledSierra, type CompiledSierraCasm, type CompilerVersion, type CompleteDeclareContractPayload, type CompressedProgram, Contract, type ContractClass, type ContractClassIdentifier, type ContractClassPayload, type ContractClassResponse, type ContractEntryPointFields, ContractFactory, type ContractFactoryParams, type ContractFunction, ContractInterface, type ContractOptions, type ContractVersion, CustomError, type DeclareAndDeployContractPayload, type DeclareContractPayload, type DeclareContractResponse, type DeclareContractTransaction, type DeclareDeployUDCResponse, type DeclareSignerDetails, type DeclareTransactionReceiptResponse, type DeployAccountContractPayload, type DeployAccountContractTransaction, type DeployAccountSignerDetails, type DeployAccountTransactionReceiptResponse, type DeployContractResponse, type DeployContractUDCResponse, type DeployTransactionReceiptResponse, type Details, ETH_ADDRESS, EntryPointType, type EntryPointsByType, type EstimateFee, type EstimateFeeAction, type EstimateFeeBulk, type EstimateFeeDetails, type EstimateFeeResponse, type EstimateFeeResponseBulk, EthSigner, type EventEntry, type FeeEstimate, type FunctionAbi, type GetBlockResponse, type GetTransactionReceiptResponse, type GetTransactionResponse, type GetTxReceiptResponseWithoutHelper, type HexCalldata, type InterfaceAbi, type Invocation, type Invocations, type InvocationsDetails, type InvocationsDetailsWithNonce, type InvocationsSignerDetails, type InvokeFunctionResponse, type InvokeOptions, type InvokeTransactionReceiptResponse, type L1HandlerTransactionReceiptResponse, type LedgerPathCalculation, LedgerSigner111 as LedgerSigner, LedgerSigner111, LedgerSigner221, type LegacyCompiledContract, type LegacyContractClass, type LegacyEvent, LibraryError, Literal, type LogLevel, LogLevelIndex, type MessageToL1, type MultiDeployContractResponse, type MultiType, NON_ZERO_PREFIX, type Nonce, type OptionalPayload, type OutsideCall, type OutsideExecution, type OutsideExecutionOptions, OutsideExecutionTypesV1, OutsideExecutionTypesV2, OutsideExecutionVersion, type OutsideTransaction, type ParsedEvent, type ParsedEvents, type ParsedStruct, type PendingBlock, type PendingStateUpdate, type Program, RpcProvider as Provider, ProviderInterface, type ProviderOptions, type PythonicHints, index$3 as RPC, rpc_0_6 as RPC06, rpc_0_7 as RPC07, RPCResponseParser, type RPC_ERROR, type RPC_ERROR_SET, type RawArgs, type RawArgsArray, type RawArgsObject, type RawCalldata, ReceiptTx, type RejectedTransactionReceiptResponse, ResponseParser, type Result, type RevertedTransactionReceiptResponse, RpcChannel, RpcError, RpcProvider, type RpcProviderOptions, type SIMULATION_FLAG, type SierraContractClass, type SierraContractEntryPointFields, type SierraEntryPointsByType, type SierraProgramDebugInfo, type Signature, Signer, SignerInterface, type SimulateTransactionDetails, type SimulateTransactionResponse, type SimulatedTransaction, type SimulationFlags, type StarkProfile, type StateUpdate, type StateUpdateResponse, type Storage, type SuccessfulTransactionReceiptResponse, TransactionExecutionStatus, TransactionFinalityStatus, type TransactionReceipt, type TransactionReceiptCallbacks, type TransactionReceiptCallbacksDefault, type TransactionReceiptCallbacksDefined, type TransactionReceiptStatus, type TransactionReceiptUtilityInterface, type TransactionReceiptValue, TransactionStatus, type TransactionStatusReceiptSets, TransactionType, type Tupled, type TypedContractV2, UINT_128_MAX, UINT_128_MIN, UINT_256_HIGH_MAX, UINT_256_HIGH_MIN, UINT_256_LOW_MAX, UINT_256_LOW_MIN, UINT_256_MAX, UINT_256_MIN, UINT_512_MAX, UINT_512_MIN, Uint, type Uint256, type Uint512, type UniversalDeployerContractPayload, type UniversalDetails, type UniversalSuggestedFee, type V2DeclareSignerDetails, type V2DeployAccountSignerDetails, type V2InvocationsSignerDetails, type V3DeclareSignerDetails, type V3DeployAccountSignerDetails, type V3InvocationsSignerDetails, type V3TransactionDetails, ValidateType, WalletAccount, type WeierstrassSignatureType, addAddressPadding, byteArray, cairo, config, constants, contractClassResponseToLegacyCompiledContract, defaultProvider, ec, encode, eth, index as events, extractContractHashes, fixProto, fixStack, getCalldata, getChecksumAddress, type getContractVersionOptions, type getEstimateFeeBulkOptions, getLedgerPathBuffer111 as getLedgerPathBuffer, getLedgerPathBuffer111, getLedgerPathBuffer221, type getSimulateTransactionOptions, index$1 as hash, isSierra, json, logger, merkle, num, number, outsideExecution, parseCalldataField, provider, selector, shortString, splitArgsAndOptions, src5, stark, starknetId, transaction, typedData, index$2 as types, uint256$1 as uint256, units, v2 as v2hash, v3 as v3hash, validateAndParseAddress, validateChecksumAddress, type waitForTransactionOptions, connect as wallet };
@@ -3231,6 +3231,7 @@ var starknet = (() => {
3231
3231
  LedgerSigner221: () => LedgerSigner221,
3232
3232
  LibraryError: () => LibraryError,
3233
3233
  Literal: () => Literal,
3234
+ LogLevelIndex: () => LogLevelIndex,
3234
3235
  NON_ZERO_PREFIX: () => NON_ZERO_PREFIX,
3235
3236
  OutsideExecutionTypesV1: () => OutsideExecutionTypesV1,
3236
3237
  OutsideExecutionTypesV2: () => OutsideExecutionTypesV2,
@@ -3269,6 +3270,7 @@ var starknet = (() => {
3269
3270
  addAddressPadding: () => addAddressPadding,
3270
3271
  byteArray: () => byteArray_exports,
3271
3272
  cairo: () => cairo_exports,
3273
+ config: () => config2,
3272
3274
  constants: () => constants_exports,
3273
3275
  contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
3274
3276
  defaultProvider: () => defaultProvider,
@@ -3287,6 +3289,7 @@ var starknet = (() => {
3287
3289
  hash: () => hash_exports,
3288
3290
  isSierra: () => isSierra,
3289
3291
  json: () => json_exports,
3292
+ logger: () => logger,
3290
3293
  merkle: () => merkle_exports,
3291
3294
  num: () => num_exports,
3292
3295
  number: () => number,
@@ -3311,12 +3314,13 @@ var starknet = (() => {
3311
3314
  wallet: () => connect_exports
3312
3315
  });
3313
3316
 
3314
- // src/constants.ts
3317
+ // src/global/constants.ts
3315
3318
  var constants_exports = {};
3316
3319
  __export(constants_exports, {
3317
3320
  ADDR_BOUND: () => ADDR_BOUND,
3318
3321
  API_VERSION: () => API_VERSION,
3319
3322
  BaseUrl: () => BaseUrl,
3323
+ DEFAULT_GLOBAL_CONFIG: () => DEFAULT_GLOBAL_CONFIG,
3320
3324
  FeeMarginPercentage: () => FeeMarginPercentage,
3321
3325
  HARDENING_4BYTES: () => HARDENING_4BYTES,
3322
3326
  HARDENING_BYTE: () => HARDENING_BYTE,
@@ -3334,6 +3338,7 @@ var starknet = (() => {
3334
3338
  RPC_NODES: () => RPC_NODES,
3335
3339
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
3336
3340
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
3341
+ SYSTEM_MESSAGES: () => SYSTEM_MESSAGES,
3337
3342
  StarknetChainId: () => StarknetChainId,
3338
3343
  TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
3339
3344
  TRANSACTION_VERSION: () => ETransactionVersion4,
@@ -3842,7 +3847,7 @@ var starknet = (() => {
3842
3847
  return result;
3843
3848
  }
3844
3849
 
3845
- // src/constants.ts
3850
+ // src/global/constants.ts
3846
3851
  var TEXT_TO_FELT_MAX_LEN = 31;
3847
3852
  var ZERO = 0n;
3848
3853
  var MASK_250 = 2n ** 250n - 1n;
@@ -3904,6 +3909,13 @@ var starknet = (() => {
3904
3909
  var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
3905
3910
  var HARDENING_BYTE = 128;
3906
3911
  var HARDENING_4BYTES = 2147483648n;
3912
+ var DEFAULT_GLOBAL_CONFIG = {
3913
+ legacyMode: false,
3914
+ logLevel: "INFO"
3915
+ };
3916
+ var SYSTEM_MESSAGES = {
3917
+ legacyTxWarningMessage: "You are using a deprecated transaction version (V0,V1,V2)!\nUpdate to the latest V3 transactions!"
3918
+ };
3907
3919
 
3908
3920
  // src/channel/rpc_0_6.ts
3909
3921
  var rpc_0_6_exports = {};
@@ -3929,7 +3941,7 @@ var starknet = (() => {
3929
3941
  return NUMBER_REGEX.test(value);
3930
3942
  }
3931
3943
  var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
3932
- function isSafeNumber(value, config2) {
3944
+ function isSafeNumber(value, config3) {
3933
3945
  const num = Number.parseFloat(value);
3934
3946
  const str = String(num);
3935
3947
  const v = extractSignificantDigits(value);
@@ -3937,7 +3949,7 @@ var starknet = (() => {
3937
3949
  if (v === s) {
3938
3950
  return true;
3939
3951
  }
3940
- if (config2?.approx === true) {
3952
+ if (config3?.approx === true) {
3941
3953
  const requiredDigits = 14;
3942
3954
  if (!isInteger(value) && s.length >= requiredDigits && v.startsWith(s.substring(0, requiredDigits))) {
3943
3955
  return true;
@@ -14763,6 +14775,184 @@ ${indent}}` : "}";
14763
14775
  validBlockTags: () => validBlockTags,
14764
14776
  wait: () => wait
14765
14777
  });
14778
+
14779
+ // src/global/config.ts
14780
+ var Configuration = class _Configuration {
14781
+ static instance;
14782
+ config;
14783
+ constructor() {
14784
+ this.initialize();
14785
+ }
14786
+ initialize() {
14787
+ this.config = { ...DEFAULT_GLOBAL_CONFIG };
14788
+ }
14789
+ static getInstance() {
14790
+ if (!_Configuration.instance) {
14791
+ _Configuration.instance = new _Configuration();
14792
+ }
14793
+ return _Configuration.instance;
14794
+ }
14795
+ get(key, defaultValue) {
14796
+ return this.config[key] ?? defaultValue;
14797
+ }
14798
+ set(key, value) {
14799
+ this.config[key] = value;
14800
+ }
14801
+ update(configData) {
14802
+ this.config = {
14803
+ ...this.config,
14804
+ ...configData
14805
+ };
14806
+ }
14807
+ getAll() {
14808
+ return { ...this.config };
14809
+ }
14810
+ reset() {
14811
+ this.initialize();
14812
+ }
14813
+ delete(key) {
14814
+ delete this.config[key];
14815
+ }
14816
+ hasKey(key) {
14817
+ return key in this.config;
14818
+ }
14819
+ };
14820
+ var config2 = Configuration.getInstance();
14821
+
14822
+ // src/global/logger.type.ts
14823
+ var LogLevelIndex = {
14824
+ DEBUG: 5,
14825
+ INFO: 4,
14826
+ WARN: 3,
14827
+ ERROR: 2,
14828
+ FATAL: 1,
14829
+ OFF: 0
14830
+ };
14831
+
14832
+ // src/global/logger.ts
14833
+ var Logger = class _Logger {
14834
+ static instance;
14835
+ config;
14836
+ constructor() {
14837
+ this.config = config2;
14838
+ }
14839
+ static getInstance() {
14840
+ if (!_Logger.instance) {
14841
+ _Logger.instance = new _Logger();
14842
+ }
14843
+ return _Logger.instance;
14844
+ }
14845
+ getTimestamp() {
14846
+ return (/* @__PURE__ */ new Date()).toISOString();
14847
+ }
14848
+ shouldLog(messageLevel) {
14849
+ const configLevel = this.config.get("logLevel", "INFO");
14850
+ return messageLevel <= LogLevelIndex[configLevel];
14851
+ }
14852
+ formatMessage(logMessage) {
14853
+ const { level, message, timestamp, data } = logMessage;
14854
+ let formattedMessage = `[${timestamp}] ${level}: ${message}`;
14855
+ if (data) {
14856
+ try {
14857
+ formattedMessage += `
14858
+ ${JSON.stringify(data, null, 2)}`;
14859
+ } catch (error2) {
14860
+ formattedMessage += `
14861
+ [JSON.stringify Error/Circular]: ${error2}`;
14862
+ }
14863
+ }
14864
+ return formattedMessage;
14865
+ }
14866
+ log(level, message, data) {
14867
+ if (!this.shouldLog(LogLevelIndex[level])) {
14868
+ return;
14869
+ }
14870
+ const logMessage = {
14871
+ level,
14872
+ message,
14873
+ timestamp: this.getTimestamp(),
14874
+ data
14875
+ };
14876
+ const formattedMessage = this.formatMessage(logMessage);
14877
+ switch (level) {
14878
+ case "DEBUG":
14879
+ console.debug(formattedMessage);
14880
+ break;
14881
+ case "INFO":
14882
+ console.info(formattedMessage);
14883
+ break;
14884
+ case "WARN":
14885
+ console.warn(formattedMessage);
14886
+ break;
14887
+ case "ERROR":
14888
+ case "FATAL":
14889
+ console.error(formattedMessage);
14890
+ break;
14891
+ case "OFF":
14892
+ break;
14893
+ default:
14894
+ console.log(formattedMessage);
14895
+ break;
14896
+ }
14897
+ }
14898
+ /**
14899
+ * debug will be displayed when LogLevel level is set to DEBUG(5)
14900
+ */
14901
+ debug(message, data) {
14902
+ this.log("DEBUG", message, data);
14903
+ }
14904
+ /**
14905
+ * info will be displayed when LogLevel level is set to DEBUG(5), INFO(4)
14906
+ */
14907
+ info(message, data) {
14908
+ this.log("INFO", message, data);
14909
+ }
14910
+ /**
14911
+ * warn will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3)
14912
+ */
14913
+ warn(message, data) {
14914
+ this.log("WARN", message, data);
14915
+ }
14916
+ /**
14917
+ * error will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3), ERROR(2)
14918
+ */
14919
+ error(message, data) {
14920
+ this.log("ERROR", message, data);
14921
+ }
14922
+ /**
14923
+ * fatal will be displayed when LogLevel level is set to DEBUG(5), INFO(4), WARN(3), ERROR(2), FATAL(1)
14924
+ */
14925
+ fatal(message, data) {
14926
+ this.log("FATAL", message, data);
14927
+ }
14928
+ /**
14929
+ * Set the logging level you would like system to display
14930
+ * * 5 DEBUG - show all logs
14931
+ * * 4 INFO
14932
+ * * 3 WARN
14933
+ * * 2 ERROR
14934
+ * * 1 FATAL
14935
+ * * 0 OFF - disable logs
14936
+ */
14937
+ setLogLevel(level) {
14938
+ this.config.set("logLevel", level);
14939
+ }
14940
+ getLogLevel() {
14941
+ return this.config.get("logLevel", "INFO");
14942
+ }
14943
+ /**
14944
+ *
14945
+ * @returns logs levels displayed on the configured LogLevel
14946
+ */
14947
+ getEnabledLogLevels() {
14948
+ return Object.keys(LogLevelIndex).filter((s) => {
14949
+ return this.shouldLog(LogLevelIndex[s]) && s !== "OFF";
14950
+ });
14951
+ }
14952
+ };
14953
+ var logger = Logger.getInstance();
14954
+
14955
+ // src/utils/provider.ts
14766
14956
  function wait(delay) {
14767
14957
  return new Promise((res) => {
14768
14958
  setTimeout(res, delay);
@@ -14788,7 +14978,7 @@ ${indent}}` : "}";
14788
14978
  }
14789
14979
  var getDefaultNodeUrl = (networkName, mute = false) => {
14790
14980
  if (!mute) {
14791
- console.warn("Using default public node url, please provide nodeUrl in provider options!");
14981
+ logger.info("Using default public node url, please provide nodeUrl in provider options!");
14792
14982
  }
14793
14983
  const nodes = RPC_NODES[networkName ?? "SN_SEPOLIA" /* SN_SEPOLIA */];
14794
14984
  const randIdx = Math.floor(Math.random() * nodes.length);
@@ -15343,6 +15533,10 @@ ${indent}}` : "}";
15343
15533
  nonce: toHex(details.nonce)
15344
15534
  }
15345
15535
  });
15536
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15537
+ version: rpcspec_0_6_exports.ETransactionVersion.V1,
15538
+ type: rpcspec_0_6_exports.ETransactionType.INVOKE
15539
+ });
15346
15540
  } else {
15347
15541
  promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
15348
15542
  invoke_transaction: {
@@ -15381,6 +15575,10 @@ ${indent}}` : "}";
15381
15575
  nonce: toHex(details.nonce)
15382
15576
  }
15383
15577
  });
15578
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15579
+ version: rpcspec_0_6_exports.ETransactionVersion.V1,
15580
+ type: rpcspec_0_6_exports.ETransactionType.DECLARE
15581
+ });
15384
15582
  } else if (isSierra(contract) && !isV3Tx(details)) {
15385
15583
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15386
15584
  declare_transaction: {
@@ -15399,6 +15597,10 @@ ${indent}}` : "}";
15399
15597
  nonce: toHex(details.nonce)
15400
15598
  }
15401
15599
  });
15600
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15601
+ version: rpcspec_0_6_exports.ETransactionVersion.V2,
15602
+ type: rpcspec_0_6_exports.ETransactionType.DECLARE
15603
+ });
15402
15604
  } else if (isSierra(contract) && isV3Tx(details)) {
15403
15605
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15404
15606
  declare_transaction: {
@@ -15442,6 +15644,10 @@ ${indent}}` : "}";
15442
15644
  nonce: toHex(details.nonce)
15443
15645
  }
15444
15646
  });
15647
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15648
+ version: rpcspec_0_6_exports.ETransactionVersion.V1,
15649
+ type: rpcspec_0_6_exports.ETransactionType.DEPLOY_ACCOUNT
15650
+ });
15445
15651
  } else {
15446
15652
  promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
15447
15653
  deploy_account_transaction: {
@@ -15514,6 +15720,10 @@ ${indent}}` : "}";
15514
15720
  nonce: toHex(invocation.nonce),
15515
15721
  max_fee: toHex(invocation.maxFee || 0)
15516
15722
  };
15723
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15724
+ version: invocation.version,
15725
+ type: invocation.type
15726
+ });
15517
15727
  } else {
15518
15728
  details = {
15519
15729
  signature: signatureToHexArray(invocation.signature),
@@ -15910,6 +16120,10 @@ ${indent}}` : "}";
15910
16120
  nonce: toHex(details.nonce)
15911
16121
  }
15912
16122
  });
16123
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16124
+ version: esm_exports.ETransactionVersion.V1,
16125
+ type: esm_exports.ETransactionType.INVOKE
16126
+ });
15913
16127
  } else {
15914
16128
  promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
15915
16129
  invoke_transaction: {
@@ -15948,6 +16162,10 @@ ${indent}}` : "}";
15948
16162
  nonce: toHex(details.nonce)
15949
16163
  }
15950
16164
  });
16165
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16166
+ version: esm_exports.ETransactionVersion.V1,
16167
+ type: esm_exports.ETransactionType.DECLARE
16168
+ });
15951
16169
  } else if (isSierra(contract) && !isV3Tx(details)) {
15952
16170
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15953
16171
  declare_transaction: {
@@ -15966,6 +16184,10 @@ ${indent}}` : "}";
15966
16184
  nonce: toHex(details.nonce)
15967
16185
  }
15968
16186
  });
16187
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16188
+ version: esm_exports.ETransactionVersion.V2,
16189
+ type: esm_exports.ETransactionType.DECLARE
16190
+ });
15969
16191
  } else if (isSierra(contract) && isV3Tx(details)) {
15970
16192
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15971
16193
  declare_transaction: {
@@ -16009,6 +16231,10 @@ ${indent}}` : "}";
16009
16231
  nonce: toHex(details.nonce)
16010
16232
  }
16011
16233
  });
16234
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16235
+ version: esm_exports.ETransactionVersion.V1,
16236
+ type: esm_exports.ETransactionType.DEPLOY_ACCOUNT
16237
+ });
16012
16238
  } else {
16013
16239
  promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
16014
16240
  deploy_account_transaction: {
@@ -16081,6 +16307,10 @@ ${indent}}` : "}";
16081
16307
  nonce: toHex(invocation.nonce),
16082
16308
  max_fee: toHex(invocation.maxFee || 0)
16083
16309
  };
16310
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16311
+ version: invocation.version,
16312
+ type: invocation.type
16313
+ });
16084
16314
  } else {
16085
16315
  details = {
16086
16316
  signature: signatureToHexArray(invocation.signature),
@@ -19894,7 +20124,7 @@ ${indent}}` : "}";
19894
20124
  this.channel.setChainId(res);
19895
20125
  });
19896
20126
  if (!address.length) {
19897
- console.warn(
20127
+ logger.warn(
19898
20128
  "@deprecated Use static method WalletAccount.connect or WalletAccount.connectSilent instead. Constructor {@link WalletAccount.(format:2)}."
19899
20129
  );
19900
20130
  requestAccounts(this.walletProvider).then(([accountAddress]) => {
@@ -20136,7 +20366,7 @@ ${indent}}` : "}";
20136
20366
  this.callData.validate(ValidateType.CALL, method, args);
20137
20367
  return this.callData.compile(method, args);
20138
20368
  }
20139
- console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20369
+ logger.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20140
20370
  return args;
20141
20371
  });
20142
20372
  return this.providerOrAccount.callContract(
@@ -20163,7 +20393,7 @@ ${indent}}` : "}";
20163
20393
  this.callData.validate(ValidateType.INVOKE, method, args);
20164
20394
  return this.callData.compile(method, args);
20165
20395
  }
20166
- console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
20396
+ logger.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
20167
20397
  return args;
20168
20398
  });
20169
20399
  const invocation = {
@@ -20178,7 +20408,7 @@ ${indent}}` : "}";
20178
20408
  });
20179
20409
  }
20180
20410
  if (!nonce) throw new Error(`Nonce is required when invoking a function without an account`);
20181
- console.warn(`Invoking ${method} without an account. This will not work on a public node.`);
20411
+ logger.warn(`Invoking ${method} without an account. This will not work on a public node.`);
20182
20412
  return this.providerOrAccount.invokeFunction(
20183
20413
  {
20184
20414
  ...invocation,
@@ -20291,7 +20521,7 @@ ${indent}}` : "}";
20291
20521
  this.CallData.validate(ValidateType.DEPLOY, "constructor", param);
20292
20522
  return this.CallData.compile("constructor", param);
20293
20523
  }
20294
- console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20524
+ logger.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20295
20525
  return param;
20296
20526
  });
20297
20527
  const {