starknet 6.21.2 → 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,15 @@
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
+
7
+ # [6.22.0](https://github.com/starknet-io/starknet.js/compare/v6.21.2...v6.22.0) (2025-01-29)
8
+
9
+ ### Features
10
+
11
+ - units utils ([#1277](https://github.com/starknet-io/starknet.js/issues/1277)) ([26037e9](https://github.com/starknet-io/starknet.js/commit/26037e92c4cdfa220c29fd1147beae7408d8d004))
12
+
1
13
  ## [6.21.2](https://github.com/starknet-io/starknet.js/compare/v6.21.1...v6.21.2) (2025-01-29)
2
14
 
3
15
  ### Bug Fixes
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;
@@ -7944,6 +7964,16 @@ declare function extractContractHashes(payload: DeclareContractPayload): Complet
7944
7964
  */
7945
7965
  declare function contractClassResponseToLegacyCompiledContract(ccr: ContractClassResponse): LegacyCompiledContract;
7946
7966
 
7967
+ /**
7968
+ * Convert strk to fri or fri to strk
7969
+ * @example
7970
+ * ```typescript
7971
+ * units(1000n, 'fri') // '0.000000000000001' strk
7972
+ * units('1', 'strk') // '1000000000000000000' fri
7973
+ * ```
7974
+ */
7975
+ declare function units(amount: string | bigint, simbol?: 'fri' | 'strk'): string;
7976
+
7947
7977
  /**
7948
7978
  * Request Permission for wallet account, return addresses that are allowed by user
7949
7979
  * @param {boolean} [silent_mode=false] false: request user interaction allowance. true: return only pre-allowed
@@ -8043,6 +8073,87 @@ declare namespace connect {
8043
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 };
8044
8074
  }
8045
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
+
8046
8157
  /**
8047
8158
  * Main
8048
8159
  */
@@ -8050,4 +8161,4 @@ declare namespace connect {
8050
8161
  /** @deprecated prefer the 'num' naming */
8051
8162
  declare const number: typeof num;
8052
8163
 
8053
- 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, 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,
@@ -3303,6 +3306,7 @@ var starknet = (() => {
3303
3306
  typedData: () => typedData_exports,
3304
3307
  types: () => types_exports,
3305
3308
  uint256: () => uint256_exports,
3309
+ units: () => units,
3306
3310
  v2hash: () => v2_exports,
3307
3311
  v3hash: () => v3_exports,
3308
3312
  validateAndParseAddress: () => validateAndParseAddress,
@@ -3310,12 +3314,13 @@ var starknet = (() => {
3310
3314
  wallet: () => connect_exports
3311
3315
  });
3312
3316
 
3313
- // src/constants.ts
3317
+ // src/global/constants.ts
3314
3318
  var constants_exports = {};
3315
3319
  __export(constants_exports, {
3316
3320
  ADDR_BOUND: () => ADDR_BOUND,
3317
3321
  API_VERSION: () => API_VERSION,
3318
3322
  BaseUrl: () => BaseUrl,
3323
+ DEFAULT_GLOBAL_CONFIG: () => DEFAULT_GLOBAL_CONFIG,
3319
3324
  FeeMarginPercentage: () => FeeMarginPercentage,
3320
3325
  HARDENING_4BYTES: () => HARDENING_4BYTES,
3321
3326
  HARDENING_BYTE: () => HARDENING_BYTE,
@@ -3333,6 +3338,7 @@ var starknet = (() => {
3333
3338
  RPC_NODES: () => RPC_NODES,
3334
3339
  SNIP9_V1_INTERFACE_ID: () => SNIP9_V1_INTERFACE_ID,
3335
3340
  SNIP9_V2_INTERFACE_ID: () => SNIP9_V2_INTERFACE_ID,
3341
+ SYSTEM_MESSAGES: () => SYSTEM_MESSAGES,
3336
3342
  StarknetChainId: () => StarknetChainId,
3337
3343
  TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
3338
3344
  TRANSACTION_VERSION: () => ETransactionVersion4,
@@ -3841,7 +3847,7 @@ var starknet = (() => {
3841
3847
  return result;
3842
3848
  }
3843
3849
 
3844
- // src/constants.ts
3850
+ // src/global/constants.ts
3845
3851
  var TEXT_TO_FELT_MAX_LEN = 31;
3846
3852
  var ZERO = 0n;
3847
3853
  var MASK_250 = 2n ** 250n - 1n;
@@ -3903,6 +3909,13 @@ var starknet = (() => {
3903
3909
  var SNIP9_V2_INTERFACE_ID = "0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872";
3904
3910
  var HARDENING_BYTE = 128;
3905
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
+ };
3906
3919
 
3907
3920
  // src/channel/rpc_0_6.ts
3908
3921
  var rpc_0_6_exports = {};
@@ -3928,7 +3941,7 @@ var starknet = (() => {
3928
3941
  return NUMBER_REGEX.test(value);
3929
3942
  }
3930
3943
  var NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
3931
- function isSafeNumber(value, config2) {
3944
+ function isSafeNumber(value, config3) {
3932
3945
  const num = Number.parseFloat(value);
3933
3946
  const str = String(num);
3934
3947
  const v = extractSignificantDigits(value);
@@ -3936,7 +3949,7 @@ var starknet = (() => {
3936
3949
  if (v === s) {
3937
3950
  return true;
3938
3951
  }
3939
- if (config2?.approx === true) {
3952
+ if (config3?.approx === true) {
3940
3953
  const requiredDigits = 14;
3941
3954
  if (!isInteger(value) && s.length >= requiredDigits && v.startsWith(s.substring(0, requiredDigits))) {
3942
3955
  return true;
@@ -14762,6 +14775,184 @@ ${indent}}` : "}";
14762
14775
  validBlockTags: () => validBlockTags,
14763
14776
  wait: () => wait
14764
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
14765
14956
  function wait(delay) {
14766
14957
  return new Promise((res) => {
14767
14958
  setTimeout(res, delay);
@@ -14787,7 +14978,7 @@ ${indent}}` : "}";
14787
14978
  }
14788
14979
  var getDefaultNodeUrl = (networkName, mute = false) => {
14789
14980
  if (!mute) {
14790
- 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!");
14791
14982
  }
14792
14983
  const nodes = RPC_NODES[networkName ?? "SN_SEPOLIA" /* SN_SEPOLIA */];
14793
14984
  const randIdx = Math.floor(Math.random() * nodes.length);
@@ -15342,6 +15533,10 @@ ${indent}}` : "}";
15342
15533
  nonce: toHex(details.nonce)
15343
15534
  }
15344
15535
  });
15536
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15537
+ version: rpcspec_0_6_exports.ETransactionVersion.V1,
15538
+ type: rpcspec_0_6_exports.ETransactionType.INVOKE
15539
+ });
15345
15540
  } else {
15346
15541
  promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
15347
15542
  invoke_transaction: {
@@ -15380,6 +15575,10 @@ ${indent}}` : "}";
15380
15575
  nonce: toHex(details.nonce)
15381
15576
  }
15382
15577
  });
15578
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15579
+ version: rpcspec_0_6_exports.ETransactionVersion.V1,
15580
+ type: rpcspec_0_6_exports.ETransactionType.DECLARE
15581
+ });
15383
15582
  } else if (isSierra(contract) && !isV3Tx(details)) {
15384
15583
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15385
15584
  declare_transaction: {
@@ -15398,6 +15597,10 @@ ${indent}}` : "}";
15398
15597
  nonce: toHex(details.nonce)
15399
15598
  }
15400
15599
  });
15600
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15601
+ version: rpcspec_0_6_exports.ETransactionVersion.V2,
15602
+ type: rpcspec_0_6_exports.ETransactionType.DECLARE
15603
+ });
15401
15604
  } else if (isSierra(contract) && isV3Tx(details)) {
15402
15605
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15403
15606
  declare_transaction: {
@@ -15441,6 +15644,10 @@ ${indent}}` : "}";
15441
15644
  nonce: toHex(details.nonce)
15442
15645
  }
15443
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
+ });
15444
15651
  } else {
15445
15652
  promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
15446
15653
  deploy_account_transaction: {
@@ -15513,6 +15720,10 @@ ${indent}}` : "}";
15513
15720
  nonce: toHex(invocation.nonce),
15514
15721
  max_fee: toHex(invocation.maxFee || 0)
15515
15722
  };
15723
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
15724
+ version: invocation.version,
15725
+ type: invocation.type
15726
+ });
15516
15727
  } else {
15517
15728
  details = {
15518
15729
  signature: signatureToHexArray(invocation.signature),
@@ -15909,6 +16120,10 @@ ${indent}}` : "}";
15909
16120
  nonce: toHex(details.nonce)
15910
16121
  }
15911
16122
  });
16123
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16124
+ version: esm_exports.ETransactionVersion.V1,
16125
+ type: esm_exports.ETransactionType.INVOKE
16126
+ });
15912
16127
  } else {
15913
16128
  promise = this.fetchEndpoint("starknet_addInvokeTransaction", {
15914
16129
  invoke_transaction: {
@@ -15947,6 +16162,10 @@ ${indent}}` : "}";
15947
16162
  nonce: toHex(details.nonce)
15948
16163
  }
15949
16164
  });
16165
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16166
+ version: esm_exports.ETransactionVersion.V1,
16167
+ type: esm_exports.ETransactionType.DECLARE
16168
+ });
15950
16169
  } else if (isSierra(contract) && !isV3Tx(details)) {
15951
16170
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15952
16171
  declare_transaction: {
@@ -15965,6 +16184,10 @@ ${indent}}` : "}";
15965
16184
  nonce: toHex(details.nonce)
15966
16185
  }
15967
16186
  });
16187
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16188
+ version: esm_exports.ETransactionVersion.V2,
16189
+ type: esm_exports.ETransactionType.DECLARE
16190
+ });
15968
16191
  } else if (isSierra(contract) && isV3Tx(details)) {
15969
16192
  promise = this.fetchEndpoint("starknet_addDeclareTransaction", {
15970
16193
  declare_transaction: {
@@ -16008,6 +16231,10 @@ ${indent}}` : "}";
16008
16231
  nonce: toHex(details.nonce)
16009
16232
  }
16010
16233
  });
16234
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16235
+ version: esm_exports.ETransactionVersion.V1,
16236
+ type: esm_exports.ETransactionType.DEPLOY_ACCOUNT
16237
+ });
16011
16238
  } else {
16012
16239
  promise = this.fetchEndpoint("starknet_addDeployAccountTransaction", {
16013
16240
  deploy_account_transaction: {
@@ -16080,6 +16307,10 @@ ${indent}}` : "}";
16080
16307
  nonce: toHex(invocation.nonce),
16081
16308
  max_fee: toHex(invocation.maxFee || 0)
16082
16309
  };
16310
+ logger.warn(SYSTEM_MESSAGES.legacyTxWarningMessage, {
16311
+ version: invocation.version,
16312
+ type: invocation.type
16313
+ });
16083
16314
  } else {
16084
16315
  details = {
16085
16316
  signature: signatureToHexArray(invocation.signature),
@@ -19893,7 +20124,7 @@ ${indent}}` : "}";
19893
20124
  this.channel.setChainId(res);
19894
20125
  });
19895
20126
  if (!address.length) {
19896
- console.warn(
20127
+ logger.warn(
19897
20128
  "@deprecated Use static method WalletAccount.connect or WalletAccount.connectSilent instead. Constructor {@link WalletAccount.(format:2)}."
19898
20129
  );
19899
20130
  requestAccounts(this.walletProvider).then(([accountAddress]) => {
@@ -20135,7 +20366,7 @@ ${indent}}` : "}";
20135
20366
  this.callData.validate(ValidateType.CALL, method, args);
20136
20367
  return this.callData.compile(method, args);
20137
20368
  }
20138
- console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20369
+ logger.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20139
20370
  return args;
20140
20371
  });
20141
20372
  return this.providerOrAccount.callContract(
@@ -20162,7 +20393,7 @@ ${indent}}` : "}";
20162
20393
  this.callData.validate(ValidateType.INVOKE, method, args);
20163
20394
  return this.callData.compile(method, args);
20164
20395
  }
20165
- console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
20396
+ logger.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
20166
20397
  return args;
20167
20398
  });
20168
20399
  const invocation = {
@@ -20177,7 +20408,7 @@ ${indent}}` : "}";
20177
20408
  });
20178
20409
  }
20179
20410
  if (!nonce) throw new Error(`Nonce is required when invoking a function without an account`);
20180
- 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.`);
20181
20412
  return this.providerOrAccount.invokeFunction(
20182
20413
  {
20183
20414
  ...invocation,
@@ -20290,7 +20521,7 @@ ${indent}}` : "}";
20290
20521
  this.CallData.validate(ValidateType.DEPLOY, "constructor", param);
20291
20522
  return this.CallData.compile("constructor", param);
20292
20523
  }
20293
- console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20524
+ logger.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
20294
20525
  return param;
20295
20526
  });
20296
20527
  const {
@@ -20334,6 +20565,32 @@ ${indent}}` : "}";
20334
20565
  var ResponseParser = class {
20335
20566
  };
20336
20567
 
20568
+ // src/utils/units.ts
20569
+ function units(amount, simbol = "fri") {
20570
+ if (simbol === "strk") {
20571
+ let numStr = "";
20572
+ if (typeof amount === "bigint") numStr = amount.toString();
20573
+ else if (typeof amount === "string") {
20574
+ if (isHex2(amount)) {
20575
+ numStr = BigInt(amount).toString();
20576
+ } else {
20577
+ numStr = amount;
20578
+ }
20579
+ }
20580
+ const [integer, decimal = "0"] = numStr.split(".");
20581
+ const pdec = decimal.padEnd(18, "0");
20582
+ return `${integer}${pdec}`.replace(/\b0+/g, "");
20583
+ }
20584
+ const bis = BigInt(amount).toString();
20585
+ let strk;
20586
+ if (bis.length <= 18) {
20587
+ strk = `0.${bis.padStart(18, "0")}`;
20588
+ } else {
20589
+ strk = `${bis.slice(0, bis.length - 18)}.${bis.slice(bis.length - 18)}`;
20590
+ }
20591
+ return strk.replace(/(\.[0-9]*[1-9])0+$|\.0*$/, "$1");
20592
+ }
20593
+
20337
20594
  // src/index.ts
20338
20595
  var number = num_exports;
20339
20596
  return __toCommonJS(src_exports);