starknet 9.3.0 → 9.4.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 +15 -0
- package/dist/index.d.ts +62 -1
- package/dist/index.global.js +191 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +168 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +172 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [9.4.0](https://github.com/starknet-io/starknet.js/compare/v9.3.0...v9.4.0) (2026-02-06)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- add ci release permissions to the top calling workflow not just \_release ([1e9376c](https://github.com/starknet-io/starknet.js/commit/1e9376cff1c79b8403b2b37f7205635689928a8c))
|
|
6
|
+
- audit package fix ([e34813e](https://github.com/starknet-io/starknet.js/commit/e34813ea466ac0efd08fff8810af2cdab75c89c5))
|
|
7
|
+
- fix to trigger release ([87dc498](https://github.com/starknet-io/starknet.js/commit/87dc498e846ce4a3711d152501f68fb3a3d8beb6))
|
|
8
|
+
- iffe shim plugin skip packing fs and path ([8dcb136](https://github.com/starknet-io/starknet.js/commit/8dcb136fcb2c1216ed4cb643a388812d6b2bdf22))
|
|
9
|
+
- is file system available log ([23524ec](https://github.com/starknet-io/starknet.js/commit/23524ec7a9717be69bacd021ff60e26c8bf0d1a4))
|
|
10
|
+
- resolve relative and absolute path ([9b69257](https://github.com/starknet-io/starknet.js/commit/9b69257c96e166726e5e4243690262fe7d5ceec7))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- contractLoader ([e4e837e](https://github.com/starknet-io/starknet.js/commit/e4e837e3393d6fb5db1eb20e699bde80efee57c4))
|
|
15
|
+
|
|
1
16
|
# [9.3.0](https://github.com/starknet-io/starknet.js/compare/v9.2.2...v9.3.0) (2025-12-19)
|
|
2
17
|
|
|
3
18
|
### Features
|
package/dist/index.d.ts
CHANGED
|
@@ -9395,6 +9395,67 @@ declare class CallData {
|
|
|
9395
9395
|
decodeParameters(typeCairo: AllowArray<string>, response: string[]): AllowArray<CallResult>;
|
|
9396
9396
|
}
|
|
9397
9397
|
|
|
9398
|
+
type LoadedContract = {
|
|
9399
|
+
sierra: CompiledSierra;
|
|
9400
|
+
casm: CairoAssembly;
|
|
9401
|
+
compiler?: string;
|
|
9402
|
+
compiledClassHash?: never;
|
|
9403
|
+
} | {
|
|
9404
|
+
sierra: CompiledSierra;
|
|
9405
|
+
casm?: never;
|
|
9406
|
+
compiler?: string;
|
|
9407
|
+
compiledClassHash: string;
|
|
9408
|
+
};
|
|
9409
|
+
/**
|
|
9410
|
+
* Helper function to check if filesystem access is available (Node.js environment)
|
|
9411
|
+
* @return {boolean} - Returns true if running in Node.js with fs module available
|
|
9412
|
+
*/
|
|
9413
|
+
declare function isFileSystemAvailable(): boolean;
|
|
9414
|
+
/**
|
|
9415
|
+
* Loads a Cairo contract from filesystem (Node.js) or File object (browser).
|
|
9416
|
+
*
|
|
9417
|
+
* **Node.js usage:**
|
|
9418
|
+
* Accepts a directory path or a direct path to a .sierra.json or .casm file.
|
|
9419
|
+
* - If a directory is provided: searches for .sierra.json and .casm files
|
|
9420
|
+
* - If a file path is provided: loads that file and attempts to find the complementary file
|
|
9421
|
+
* - If compiledClassHash is provided: .casm file is optional
|
|
9422
|
+
* - If compiledClassHash is NOT provided: .casm file is required
|
|
9423
|
+
*
|
|
9424
|
+
* **Browser usage:**
|
|
9425
|
+
* Accepts a File object (from file input or drag-and-drop).
|
|
9426
|
+
* - Returns a Promise that resolves to LoadedContract
|
|
9427
|
+
* - Automatically detects .sierra.json and .casm files
|
|
9428
|
+
* - Can accept a single .sierra.json or .casm file, or multiple files
|
|
9429
|
+
* - If compiledClassHash is provided: .casm file is optional
|
|
9430
|
+
*
|
|
9431
|
+
* @param {string | File | File[]} input - Path (Node.js) or File/File[] (browser)
|
|
9432
|
+
* @param {string} [compiledClassHash] - Optional compiled class hash. If provided, .casm file becomes optional
|
|
9433
|
+
* @return {LoadedContract | Promise<LoadedContract>} - Contract data (sync in Node.js, async in browser)
|
|
9434
|
+
* @throws {Error} - If no .sierra.json file is found, or if .casm is missing when compiledClassHash is not provided
|
|
9435
|
+
*
|
|
9436
|
+
* @example
|
|
9437
|
+
* ```typescript
|
|
9438
|
+
* // Node.js: Load from directory (requires .casm)
|
|
9439
|
+
* const contract = contractLoader('./contracts/my_contract');
|
|
9440
|
+
*
|
|
9441
|
+
* // Node.js: Load with compiledClassHash (no .casm needed)
|
|
9442
|
+
* const contract = contractLoader('./contracts/my_contract', '0x1234...');
|
|
9443
|
+
*
|
|
9444
|
+
* // Node.js: Load from .sierra.json file
|
|
9445
|
+
* const contract = contractLoader('./contracts/my_contract.sierra.json');
|
|
9446
|
+
*
|
|
9447
|
+
* // Browser: Load from file input
|
|
9448
|
+
* const fileInput = document.querySelector('input[type="file"]');
|
|
9449
|
+
* const contract = await contractLoader(fileInput.files[0]);
|
|
9450
|
+
*
|
|
9451
|
+
* // Browser: Load with compiledClassHash (no .casm needed)
|
|
9452
|
+
* const contract = await contractLoader(sierraFile, '0x1234...');
|
|
9453
|
+
* ```
|
|
9454
|
+
*/
|
|
9455
|
+
declare function contractLoader(contractPath: string, compiledClassHash?: string): LoadedContract;
|
|
9456
|
+
declare function contractLoader(file: File, compiledClassHash?: string): Promise<LoadedContract>;
|
|
9457
|
+
declare function contractLoader(files: File[], compiledClassHash?: string): Promise<LoadedContract>;
|
|
9458
|
+
|
|
9398
9459
|
/**
|
|
9399
9460
|
* Checks if a given contract is in Sierra (Safe Intermediate Representation) format.
|
|
9400
9461
|
*
|
|
@@ -9770,4 +9831,4 @@ declare class Logger {
|
|
|
9770
9831
|
*/
|
|
9771
9832
|
declare const logger: Logger;
|
|
9772
9833
|
|
|
9773
|
-
export { type Abi, type AbiEntry, type AbiEntryType, type AbiEnum, type AbiEnums, type AbiEvent, type AbiEvents, type AbiInterfaces, AbiParser1, AbiParser2, AbiParserInterface, type AbiStruct, type AbiStructs, Account, AccountInterface, type AccountInvocationItem, type AccountInvocations, type AccountInvocationsFactoryDetails, type AccountOptions, type AllowArray, type ApiEstimateFeeResponse, type Args, type ArgsOrCalldata, type ArgsOrCalldataWithOptions, type ArraySignatureType, type AsyncContractFunction, type BLOCK_HASH, type BLOCK_NUMBER, 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, CairoByteArray, CairoBytes31, type CairoContract, CairoCustomEnum, type CairoEnum, type CairoEnumRaw, type CairoEvent, type CairoEventDefinition, type CairoEventVariant, CairoFelt, CairoFelt252, CairoFixedArray, CairoInt128, CairoInt16, CairoInt32, CairoInt64, CairoInt8, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoUint128, CairoUint16, CairoUint256, CairoUint32, CairoUint512, CairoUint64, CairoUint8, CairoUint96, type CairoVersion, type Call, type CallContractResponse, CallData, type CallDetails, type CallOptions, type CallResult, type Calldata, type CommonContractOptions, type CompiledContract, type CompiledSierra, type CompiledSierraCasm, type CompilerVersion, type CompleteDeclareContractPayload, type CompressedProgram, Contract, type ContractClass, type ContractClassIdentifier, type ContractClassPayload, type ContractClassResponse, type ContractEntryPointFields, type ContractFunction, ContractInterface, type ContractOptions, type ContractVersion, type DeclareAndDeployContractPayload, type DeclareContractPayload, type DeclareContractResponse, type DeclareContractTransaction, type DeclareDeployUDCResponse, type DeclareSignerDetails, type DeclareTransactionReceiptResponse, type DeclaredTransaction, type DeployAccountContractPayload, type DeployAccountContractTransaction, type DeployAccountSignerDetails, type DeployAccountTransactionReceiptResponse, type DeployAndInvokeTransaction, type DeployContractResponse, type DeployContractUDCResponse, type DeployTransaction, type DeployTransactionReceiptResponse, type DeployedAccountTransaction, Deployer, type DeployerCall, DeployerInterface, type Details, EDAMode, EDataAvailabilityMode, ETH_ADDRESS, ETransactionExecutionStatus, ETransactionStatus, ETransactionVersion, ETransactionVersion2, ETransactionVersion3, type EVENTS_CHUNK, type EmittedEvent, EntryPointType, type EntryPointsByType, type ErrorReceiptResponseHelper, type EstimateFeeBulk, type EstimateFeeResponseBulkOverhead, type EstimateFeeResponseOverhead, EthSigner, type Event$1 as Event, type EventEntry, type EventFilter, type ExecutableDeployAndInvokeTransaction, type ExecutableDeployTransaction, type ExecutableInvokeTransaction, type ExecutableUserInvoke, type ExecutableUserTransaction, type ExecuteOptions, type ExecutionParameters, type FEE_ESTIMATE, type FELT, type FactoryParams, type FeeEstimate, type FeeMode, type FormatResponse, type FunctionAbi, type GasPrices, type GetBlockResponse, type GetTransactionReceiptResponse, type GetTransactionResponse, type GetTxReceiptResponseWithoutHelper, type HexCalldata, type Hint, Int, type InterfaceAbi, type Invocation, type Invocations, type InvocationsDetails, type InvocationsDetailsWithNonce, type InvocationsSignerDetails, type InvokeFunctionResponse, type InvokeTransaction, type InvokeTransactionReceiptResponse, type InvokedTransaction, type L1HandlerTransactionReceiptResponse, type L1_HANDLER_TXN, type LedgerPathCalculation, LedgerSigner111 as LedgerSigner, LedgerSigner111, LedgerSigner221, LedgerSigner231, type LegacyCompiledContract, type LegacyContractClass, type LegacyEvent, LibraryError, Literal, type LogLevel, LogLevelIndex, type Methods, type MultiDeployContractResponse, type MultiType, NON_ZERO_PREFIX, type Nonce, type OptionalPayload, type OutsideCall, type OutsideExecution, type OutsideExecutionOptions, OutsideExecutionTypesV1, OutsideExecutionTypesV2, OutsideExecutionVersion, type OutsideTransaction, type PRE_CONFIRMED_STATE_UPDATE, type PRICE_UNIT, type ParsedEvent, type ParsedEvents, type ParsedStruct, type ParsingStrategy, type PaymasterDetails, type PaymasterFeeEstimate, PaymasterInterface, type PaymasterOptions, PaymasterRpc, type PaymasterRpcOptions, type PaymasterTimeBounds, type PreConfirmedBlock, type PreConfirmedStateUpdate, type PreparedDeployAndInvokeTransaction, type PreparedDeployTransaction, type PreparedInvokeTransaction, type PreparedTransaction, type Program, RpcProvider as Provider, ProviderInterface, type ProviderOptions, type ProviderOrAccount, type PythonicHints, type RESOURCE_PRICE, index$4 as RPC, rpc_0_10_0 as RPC010, rpc_0_9_0 as RPC09, RPCResponseParser, type RPC_ERROR, type RPC_ERROR_SET, type RawArgs, type RawArgsArray, type RawArgsObject, type RawCalldata, type Receipt, ReceiptTx, type ReconnectOptions, type RequiredKeysOf, type ResourceBounds, type ResourceBoundsBN, type ResourceBoundsOverhead, ResponseParser, type RevertedTransactionReceiptResponse, type RevertedTransactionReceiptResponseHelper, RpcChannel, RpcError, RpcProvider, type RpcProviderOptions, type SIMULATION_FLAG, type STATE_UPDATE, type SierraContractClass, type SierraContractEntryPointFields, type SierraEntryPointsByType, type SierraProgramDebugInfo, type Signature, Signer, SignerInterface, type Simplify, type SimulateTransaction, type SimulateTransactionDetails, type SimulateTransactionOverhead, type SimulateTransactionOverheadResponse, type SimulateTransactionResponse, type SimulationFlags, type StarkProfile, type StateUpdate, type StateUpdateResponse, type Storage, type SubscribeEventsParams, type SubscribeNewHeadsParams, type SubscribeNewTransactionReceiptsParams, type SubscribeNewTransactionsParams, type SubscribeTransactionStatusParams, Subscription, type SubscriptionBlockIdentifier, type SubscriptionNewHeadsEvent, type SubscriptionNewTransactionEvent, type SubscriptionNewTransactionReceiptsEvent, type SubscriptionOptions, type SubscriptionStarknetEventsEvent, type SubscriptionTransactionStatusEvent, type SuccessfulTransactionReceiptResponse, type SuccessfulTransactionReceiptResponseHelper, type TXN_EXECUTION_STATUS, type TXN_HASH, type TXN_STATUS, TimeoutError, type TipAnalysisOptions, type TipEstimate, type TipType, type TokenData, TransactionExecutionStatus, TransactionFinalityStatus, type TransactionReceipt, type TransactionReceiptCallbacks, type TransactionReceiptCallbacksDefault, type TransactionReceiptCallbacksDefined, type TransactionReceiptStatus, type TransactionReceiptValue, type TransactionStatus, type TransactionStatusReceiptSets, type TransactionTrace, TransactionType, type TransactionWithHash, 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 UserInvoke, type UserTransaction, type V3DeclareSignerDetails, type V3DeployAccountSignerDetails, type V3InvocationsSignerDetails, type V3TransactionDetails, ValidateType, WalletAccount, WalletAccountV5, WebSocketChannel, type WebSocketModule, WebSocketNotConnectedError, type WebSocketOptions, type WeierstrassSignatureType, type WithOptions, addAddressPadding, byteArray, cairo, compareVersions, config, constants, contractClassResponseToLegacyCompiledContract, createAbiParser, createTransactionReceipt, defaultDeployer, defaultPaymaster, defaultProvider, ec, encode, eth, index as events, extractContractHashes, type fastExecuteResponse, fastParsingStrategy, type fastWaitForTransactionOptions, getAbiVersion, getChecksumAddress, type getContractVersionOptions, type getEstimateFeeBulkOptions, getGasPrices, getLedgerPathBuffer111 as getLedgerPathBuffer, getLedgerPathBuffer111, getLedgerPathBuffer221, type getSimulateTransactionOptions, getTipStatsFromBlocks, index$3 as hash, hdParsingStrategy, isAccount, isNoConstructorValid, isPreConfirmedBlock, isPreConfirmedStateUpdate, isPreConfirmedTransaction, isRPC08Plus_ResourceBounds, isRPC08Plus_ResourceBoundsBN, isSierra, isSupportedSpecVersion, isV3Tx, isVersion, json, legacyDeployer, logger, merkle, num, outsideExecution, parseCalldataField, paymaster, provider, selector, shortString, src5, index$1 as stark, starknetId, toAnyPatchVersion, toApiVersion, index$2 as transaction, typedData, uint256$1 as uint256, units, v2 as v2hash, v3 as v3hash, validateAndParseAddress, validateChecksumAddress, verifyMessageInStarknet, type waitForTransactionOptions, connect as wallet, connectV5 as walletV5 };
|
|
9834
|
+
export { type Abi, type AbiEntry, type AbiEntryType, type AbiEnum, type AbiEnums, type AbiEvent, type AbiEvents, type AbiInterfaces, AbiParser1, AbiParser2, AbiParserInterface, type AbiStruct, type AbiStructs, Account, AccountInterface, type AccountInvocationItem, type AccountInvocations, type AccountInvocationsFactoryDetails, type AccountOptions, type AllowArray, type ApiEstimateFeeResponse, type Args, type ArgsOrCalldata, type ArgsOrCalldataWithOptions, type ArraySignatureType, type AsyncContractFunction, type BLOCK_HASH, type BLOCK_NUMBER, 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, CairoByteArray, CairoBytes31, type CairoContract, CairoCustomEnum, type CairoEnum, type CairoEnumRaw, type CairoEvent, type CairoEventDefinition, type CairoEventVariant, CairoFelt, CairoFelt252, CairoFixedArray, CairoInt128, CairoInt16, CairoInt32, CairoInt64, CairoInt8, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoUint128, CairoUint16, CairoUint256, CairoUint32, CairoUint512, CairoUint64, CairoUint8, CairoUint96, type CairoVersion, type Call, type CallContractResponse, CallData, type CallDetails, type CallOptions, type CallResult, type Calldata, type CommonContractOptions, type CompiledContract, type CompiledSierra, type CompiledSierraCasm, type CompilerVersion, type CompleteDeclareContractPayload, type CompressedProgram, Contract, type ContractClass, type ContractClassIdentifier, type ContractClassPayload, type ContractClassResponse, type ContractEntryPointFields, type ContractFunction, ContractInterface, type ContractOptions, type ContractVersion, type DeclareAndDeployContractPayload, type DeclareContractPayload, type DeclareContractResponse, type DeclareContractTransaction, type DeclareDeployUDCResponse, type DeclareSignerDetails, type DeclareTransactionReceiptResponse, type DeclaredTransaction, type DeployAccountContractPayload, type DeployAccountContractTransaction, type DeployAccountSignerDetails, type DeployAccountTransactionReceiptResponse, type DeployAndInvokeTransaction, type DeployContractResponse, type DeployContractUDCResponse, type DeployTransaction, type DeployTransactionReceiptResponse, type DeployedAccountTransaction, Deployer, type DeployerCall, DeployerInterface, type Details, EDAMode, EDataAvailabilityMode, ETH_ADDRESS, ETransactionExecutionStatus, ETransactionStatus, ETransactionVersion, ETransactionVersion2, ETransactionVersion3, type EVENTS_CHUNK, type EmittedEvent, EntryPointType, type EntryPointsByType, type ErrorReceiptResponseHelper, type EstimateFeeBulk, type EstimateFeeResponseBulkOverhead, type EstimateFeeResponseOverhead, EthSigner, type Event$1 as Event, type EventEntry, type EventFilter, type ExecutableDeployAndInvokeTransaction, type ExecutableDeployTransaction, type ExecutableInvokeTransaction, type ExecutableUserInvoke, type ExecutableUserTransaction, type ExecuteOptions, type ExecutionParameters, type FEE_ESTIMATE, type FELT, type FactoryParams, type FeeEstimate, type FeeMode, type FormatResponse, type FunctionAbi, type GasPrices, type GetBlockResponse, type GetTransactionReceiptResponse, type GetTransactionResponse, type GetTxReceiptResponseWithoutHelper, type HexCalldata, type Hint, Int, type InterfaceAbi, type Invocation, type Invocations, type InvocationsDetails, type InvocationsDetailsWithNonce, type InvocationsSignerDetails, type InvokeFunctionResponse, type InvokeTransaction, type InvokeTransactionReceiptResponse, type InvokedTransaction, type L1HandlerTransactionReceiptResponse, type L1_HANDLER_TXN, type LedgerPathCalculation, LedgerSigner111 as LedgerSigner, LedgerSigner111, LedgerSigner221, LedgerSigner231, type LegacyCompiledContract, type LegacyContractClass, type LegacyEvent, LibraryError, Literal, type LoadedContract, type LogLevel, LogLevelIndex, type Methods, type MultiDeployContractResponse, type MultiType, NON_ZERO_PREFIX, type Nonce, type OptionalPayload, type OutsideCall, type OutsideExecution, type OutsideExecutionOptions, OutsideExecutionTypesV1, OutsideExecutionTypesV2, OutsideExecutionVersion, type OutsideTransaction, type PRE_CONFIRMED_STATE_UPDATE, type PRICE_UNIT, type ParsedEvent, type ParsedEvents, type ParsedStruct, type ParsingStrategy, type PaymasterDetails, type PaymasterFeeEstimate, PaymasterInterface, type PaymasterOptions, PaymasterRpc, type PaymasterRpcOptions, type PaymasterTimeBounds, type PreConfirmedBlock, type PreConfirmedStateUpdate, type PreparedDeployAndInvokeTransaction, type PreparedDeployTransaction, type PreparedInvokeTransaction, type PreparedTransaction, type Program, RpcProvider as Provider, ProviderInterface, type ProviderOptions, type ProviderOrAccount, type PythonicHints, type RESOURCE_PRICE, index$4 as RPC, rpc_0_10_0 as RPC010, rpc_0_9_0 as RPC09, RPCResponseParser, type RPC_ERROR, type RPC_ERROR_SET, type RawArgs, type RawArgsArray, type RawArgsObject, type RawCalldata, type Receipt, ReceiptTx, type ReconnectOptions, type RequiredKeysOf, type ResourceBounds, type ResourceBoundsBN, type ResourceBoundsOverhead, ResponseParser, type RevertedTransactionReceiptResponse, type RevertedTransactionReceiptResponseHelper, RpcChannel, RpcError, RpcProvider, type RpcProviderOptions, type SIMULATION_FLAG, type STATE_UPDATE, type SierraContractClass, type SierraContractEntryPointFields, type SierraEntryPointsByType, type SierraProgramDebugInfo, type Signature, Signer, SignerInterface, type Simplify, type SimulateTransaction, type SimulateTransactionDetails, type SimulateTransactionOverhead, type SimulateTransactionOverheadResponse, type SimulateTransactionResponse, type SimulationFlags, type StarkProfile, type StateUpdate, type StateUpdateResponse, type Storage, type SubscribeEventsParams, type SubscribeNewHeadsParams, type SubscribeNewTransactionReceiptsParams, type SubscribeNewTransactionsParams, type SubscribeTransactionStatusParams, Subscription, type SubscriptionBlockIdentifier, type SubscriptionNewHeadsEvent, type SubscriptionNewTransactionEvent, type SubscriptionNewTransactionReceiptsEvent, type SubscriptionOptions, type SubscriptionStarknetEventsEvent, type SubscriptionTransactionStatusEvent, type SuccessfulTransactionReceiptResponse, type SuccessfulTransactionReceiptResponseHelper, type TXN_EXECUTION_STATUS, type TXN_HASH, type TXN_STATUS, TimeoutError, type TipAnalysisOptions, type TipEstimate, type TipType, type TokenData, TransactionExecutionStatus, TransactionFinalityStatus, type TransactionReceipt, type TransactionReceiptCallbacks, type TransactionReceiptCallbacksDefault, type TransactionReceiptCallbacksDefined, type TransactionReceiptStatus, type TransactionReceiptValue, type TransactionStatus, type TransactionStatusReceiptSets, type TransactionTrace, TransactionType, type TransactionWithHash, 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 UserInvoke, type UserTransaction, type V3DeclareSignerDetails, type V3DeployAccountSignerDetails, type V3InvocationsSignerDetails, type V3TransactionDetails, ValidateType, WalletAccount, WalletAccountV5, WebSocketChannel, type WebSocketModule, WebSocketNotConnectedError, type WebSocketOptions, type WeierstrassSignatureType, type WithOptions, addAddressPadding, byteArray, cairo, compareVersions, config, constants, contractClassResponseToLegacyCompiledContract, contractLoader, createAbiParser, createTransactionReceipt, defaultDeployer, defaultPaymaster, defaultProvider, ec, encode, eth, index as events, extractContractHashes, type fastExecuteResponse, fastParsingStrategy, type fastWaitForTransactionOptions, getAbiVersion, getChecksumAddress, type getContractVersionOptions, type getEstimateFeeBulkOptions, getGasPrices, getLedgerPathBuffer111 as getLedgerPathBuffer, getLedgerPathBuffer111, getLedgerPathBuffer221, type getSimulateTransactionOptions, getTipStatsFromBlocks, index$3 as hash, hdParsingStrategy, isAccount, isFileSystemAvailable, isNoConstructorValid, isPreConfirmedBlock, isPreConfirmedStateUpdate, isPreConfirmedTransaction, isRPC08Plus_ResourceBounds, isRPC08Plus_ResourceBoundsBN, isSierra, isSupportedSpecVersion, isV3Tx, isVersion, json, legacyDeployer, logger, merkle, num, outsideExecution, parseCalldataField, paymaster, provider, selector, shortString, src5, index$1 as stark, starknetId, toAnyPatchVersion, toApiVersion, index$2 as transaction, typedData, uint256$1 as uint256, units, v2 as v2hash, v3 as v3hash, validateAndParseAddress, validateChecksumAddress, verifyMessageInStarknet, type waitForTransactionOptions, connect as wallet, connectV5 as walletV5 };
|
package/dist/index.global.js
CHANGED
|
@@ -4,6 +4,15 @@ var starknet = (() => {
|
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod2) => function __require2() {
|
|
14
|
+
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
15
|
+
};
|
|
7
16
|
var __export = (target, all) => {
|
|
8
17
|
for (var name in all)
|
|
9
18
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -18,6 +27,22 @@ var starknet = (() => {
|
|
|
18
27
|
};
|
|
19
28
|
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
|
20
29
|
|
|
30
|
+
// browser-node-shim:fs
|
|
31
|
+
var require_fs = __commonJS({
|
|
32
|
+
"browser-node-shim:fs"(exports, module) {
|
|
33
|
+
"use strict";
|
|
34
|
+
module.exports = void 0;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// browser-node-shim:path
|
|
39
|
+
var require_path = __commonJS({
|
|
40
|
+
"browser-node-shim:path"(exports, module) {
|
|
41
|
+
"use strict";
|
|
42
|
+
module.exports = void 0;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
21
46
|
// src/index.ts
|
|
22
47
|
var index_exports = {};
|
|
23
48
|
__export(index_exports, {
|
|
@@ -123,6 +148,7 @@ var starknet = (() => {
|
|
|
123
148
|
config: () => config,
|
|
124
149
|
constants: () => constants_exports,
|
|
125
150
|
contractClassResponseToLegacyCompiledContract: () => contractClassResponseToLegacyCompiledContract,
|
|
151
|
+
contractLoader: () => contractLoader,
|
|
126
152
|
createAbiParser: () => createAbiParser,
|
|
127
153
|
createTransactionReceipt: () => createTransactionReceipt,
|
|
128
154
|
defaultDeployer: () => defaultDeployer,
|
|
@@ -144,6 +170,7 @@ var starknet = (() => {
|
|
|
144
170
|
hash: () => hash_exports,
|
|
145
171
|
hdParsingStrategy: () => hdParsingStrategy,
|
|
146
172
|
isAccount: () => isAccount,
|
|
173
|
+
isFileSystemAvailable: () => isFileSystemAvailable,
|
|
147
174
|
isNoConstructorValid: () => isNoConstructorValid,
|
|
148
175
|
isPreConfirmedBlock: () => isPreConfirmedBlock,
|
|
149
176
|
isPreConfirmedStateUpdate: () => isPreConfirmedStateUpdate,
|
|
@@ -14402,6 +14429,170 @@ ${indent}}` : "}";
|
|
|
14402
14429
|
return convertStringToBigInt(resourceBounds);
|
|
14403
14430
|
}
|
|
14404
14431
|
|
|
14432
|
+
// src/utils/contractLoader.ts
|
|
14433
|
+
function isFileSystemAvailable() {
|
|
14434
|
+
try {
|
|
14435
|
+
return typeof __require !== "undefined" && typeof __require.resolve === "function";
|
|
14436
|
+
} catch {
|
|
14437
|
+
logger.info("isFileSystemAvailable: false");
|
|
14438
|
+
return false;
|
|
14439
|
+
}
|
|
14440
|
+
}
|
|
14441
|
+
function contractLoader(input, compiledClassHash) {
|
|
14442
|
+
if (typeof File !== "undefined" && (input instanceof File || Array.isArray(input))) {
|
|
14443
|
+
return loadFromFileAPI(input, compiledClassHash);
|
|
14444
|
+
}
|
|
14445
|
+
if (typeof input === "string") {
|
|
14446
|
+
if (!isFileSystemAvailable()) {
|
|
14447
|
+
throw new Error(
|
|
14448
|
+
'contractLoader with string paths is only available in Node.js environments. In browsers, please use File objects from <input type="file"> or drag-and-drop. Example: await contractLoader(fileInput.files[0])'
|
|
14449
|
+
);
|
|
14450
|
+
}
|
|
14451
|
+
return loadFromFileSystem(input, compiledClassHash);
|
|
14452
|
+
}
|
|
14453
|
+
throw new Error(
|
|
14454
|
+
"Invalid input type. Expected string (Node.js path) or File/File[] (browser File API)"
|
|
14455
|
+
);
|
|
14456
|
+
}
|
|
14457
|
+
function loadFromFileSystem(contractPath, compiledClassHash) {
|
|
14458
|
+
const fs = require_fs();
|
|
14459
|
+
const path = require_path();
|
|
14460
|
+
const resolvedPath = path.resolve(contractPath);
|
|
14461
|
+
let dirPath;
|
|
14462
|
+
let specifiedSierraFile;
|
|
14463
|
+
let specifiedCasmFile;
|
|
14464
|
+
const stats = fs.statSync(resolvedPath);
|
|
14465
|
+
if (stats.isFile()) {
|
|
14466
|
+
dirPath = path.dirname(resolvedPath);
|
|
14467
|
+
const fileName = path.basename(resolvedPath);
|
|
14468
|
+
if (fileName.endsWith(".sierra.json") || fileName.endsWith(".json") && !fileName.endsWith(".casm")) {
|
|
14469
|
+
specifiedSierraFile = fileName;
|
|
14470
|
+
} else if (fileName.endsWith(".casm")) {
|
|
14471
|
+
specifiedCasmFile = fileName;
|
|
14472
|
+
} else {
|
|
14473
|
+
throw new Error(
|
|
14474
|
+
`Invalid file type. Expected .json, .sierra.json, or .casm file, got: ${fileName}`
|
|
14475
|
+
);
|
|
14476
|
+
}
|
|
14477
|
+
} else if (stats.isDirectory()) {
|
|
14478
|
+
dirPath = resolvedPath;
|
|
14479
|
+
} else {
|
|
14480
|
+
throw new Error(`Path is neither a file nor a directory: ${contractPath}`);
|
|
14481
|
+
}
|
|
14482
|
+
const files = fs.readdirSync(dirPath);
|
|
14483
|
+
let sierraFile;
|
|
14484
|
+
let casmFile;
|
|
14485
|
+
if (specifiedSierraFile) {
|
|
14486
|
+
sierraFile = specifiedSierraFile;
|
|
14487
|
+
const baseName = sierraFile.replace(/\.sierra\.json$/, "").replace(/\.json$/, "");
|
|
14488
|
+
casmFile = files.find((f) => f === `${baseName}.casm`);
|
|
14489
|
+
} else if (specifiedCasmFile) {
|
|
14490
|
+
casmFile = specifiedCasmFile;
|
|
14491
|
+
const baseName = casmFile.replace(/\.casm$/, "");
|
|
14492
|
+
sierraFile = files.find((f) => f === `${baseName}.sierra.json`) || files.find((f) => f === `${baseName}.json`);
|
|
14493
|
+
} else {
|
|
14494
|
+
const sierraFiles = files.filter(
|
|
14495
|
+
(f) => f.endsWith(".sierra.json") || f.endsWith(".json") && !f.endsWith(".casm")
|
|
14496
|
+
);
|
|
14497
|
+
if (sierraFiles.length === 0) {
|
|
14498
|
+
throw new Error(`No .sierra.json file found in ${dirPath}. Sierra file is required.`);
|
|
14499
|
+
}
|
|
14500
|
+
if (sierraFiles.length > 1) {
|
|
14501
|
+
throw new Error(
|
|
14502
|
+
`Multiple .sierra.json files found in ${dirPath}: ${sierraFiles.join(", ")}. Please specify which file to use.`
|
|
14503
|
+
);
|
|
14504
|
+
}
|
|
14505
|
+
[sierraFile] = sierraFiles;
|
|
14506
|
+
const baseName = sierraFile.replace(/\.sierra\.json$/, "").replace(/\.json$/, "");
|
|
14507
|
+
casmFile = files.find((f) => f === `${baseName}.casm`);
|
|
14508
|
+
}
|
|
14509
|
+
if (!sierraFile) {
|
|
14510
|
+
throw new Error(`No .sierra.json file found in ${dirPath}. Sierra file is required.`);
|
|
14511
|
+
}
|
|
14512
|
+
const sierraPath = path.join(dirPath, sierraFile);
|
|
14513
|
+
const sierraContent = parse2(fs.readFileSync(sierraPath, "utf8"));
|
|
14514
|
+
if (casmFile) {
|
|
14515
|
+
const casmPath = path.join(dirPath, casmFile);
|
|
14516
|
+
const casmContent = parse2(fs.readFileSync(casmPath, "utf8"));
|
|
14517
|
+
return {
|
|
14518
|
+
sierra: sierraContent,
|
|
14519
|
+
casm: casmContent,
|
|
14520
|
+
compiler: casmContent.compiler_version
|
|
14521
|
+
};
|
|
14522
|
+
}
|
|
14523
|
+
if (!compiledClassHash) {
|
|
14524
|
+
throw new Error(
|
|
14525
|
+
`No .casm file found for ${sierraFile} and no compiledClassHash provided. Either provide a .casm file or pass compiledClassHash as second parameter.`
|
|
14526
|
+
);
|
|
14527
|
+
}
|
|
14528
|
+
return {
|
|
14529
|
+
sierra: sierraContent,
|
|
14530
|
+
compiledClassHash
|
|
14531
|
+
};
|
|
14532
|
+
}
|
|
14533
|
+
async function loadFromFileAPI(input, compiledClassHash) {
|
|
14534
|
+
const files = Array.isArray(input) ? input : [input];
|
|
14535
|
+
if (files.length === 0) {
|
|
14536
|
+
throw new Error("No files provided");
|
|
14537
|
+
}
|
|
14538
|
+
const sierraFiles = files.filter(
|
|
14539
|
+
(file) => file.name.endsWith(".sierra.json") || file.name.endsWith(".json") && !file.name.endsWith(".casm")
|
|
14540
|
+
);
|
|
14541
|
+
const casmFiles = files.filter((file) => file.name.endsWith(".casm"));
|
|
14542
|
+
if (sierraFiles.length > 1) {
|
|
14543
|
+
throw new Error(
|
|
14544
|
+
`Multiple .sierra.json files provided: ${sierraFiles.map((f) => f.name).join(", ")}. Please provide only one sierra file.`
|
|
14545
|
+
);
|
|
14546
|
+
}
|
|
14547
|
+
if (casmFiles.length > 1) {
|
|
14548
|
+
throw new Error(
|
|
14549
|
+
`Multiple .casm files provided: ${casmFiles.map((f) => f.name).join(", ")}. Please provide only one casm file.`
|
|
14550
|
+
);
|
|
14551
|
+
}
|
|
14552
|
+
const sierraFile = sierraFiles[0];
|
|
14553
|
+
const casmFile = casmFiles[0];
|
|
14554
|
+
if (!sierraFile) {
|
|
14555
|
+
throw new Error(
|
|
14556
|
+
`No .sierra.json file found in provided files. Sierra file is required. Provided files: ${files.map((f) => f.name).join(", ")}`
|
|
14557
|
+
);
|
|
14558
|
+
}
|
|
14559
|
+
const sierraContent = parse2(await readFileAsText(sierraFile));
|
|
14560
|
+
if (casmFile) {
|
|
14561
|
+
const casmContent = parse2(await readFileAsText(casmFile));
|
|
14562
|
+
return {
|
|
14563
|
+
sierra: sierraContent,
|
|
14564
|
+
casm: casmContent,
|
|
14565
|
+
compiler: casmContent.compiler_version
|
|
14566
|
+
};
|
|
14567
|
+
}
|
|
14568
|
+
if (!compiledClassHash) {
|
|
14569
|
+
throw new Error(
|
|
14570
|
+
"No .casm file found in provided files and no compiledClassHash provided. Either provide a .casm file or pass compiledClassHash as second parameter."
|
|
14571
|
+
);
|
|
14572
|
+
}
|
|
14573
|
+
return {
|
|
14574
|
+
sierra: sierraContent,
|
|
14575
|
+
compiledClassHash
|
|
14576
|
+
};
|
|
14577
|
+
}
|
|
14578
|
+
function readFileAsText(file) {
|
|
14579
|
+
return new Promise((resolve, reject) => {
|
|
14580
|
+
const reader = new FileReader();
|
|
14581
|
+
reader.onload = (event) => {
|
|
14582
|
+
const content = event.target?.result;
|
|
14583
|
+
if (typeof content === "string") {
|
|
14584
|
+
resolve(content);
|
|
14585
|
+
} else {
|
|
14586
|
+
reject(new Error(`Failed to read file ${file.name} as text`));
|
|
14587
|
+
}
|
|
14588
|
+
};
|
|
14589
|
+
reader.onerror = () => {
|
|
14590
|
+
reject(new Error(`Failed to read file ${file.name}: ${reader.error?.message}`));
|
|
14591
|
+
};
|
|
14592
|
+
reader.readAsText(file);
|
|
14593
|
+
});
|
|
14594
|
+
}
|
|
14595
|
+
|
|
14405
14596
|
// src/utils/contract.ts
|
|
14406
14597
|
function isSierra(contract) {
|
|
14407
14598
|
const compiledContract = isString(contract) ? parse2(contract) : contract;
|