starknet 6.23.1 → 6.24.1

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,16 @@
1
+ ## [6.24.1](https://github.com/starknet-io/starknet.js/compare/v6.24.0...v6.24.1) (2025-03-20)
2
+
3
+ ### Bug Fixes
4
+
5
+ - repair snip-12 enum type nested dependency ([#1289](https://github.com/starknet-io/starknet.js/issues/1289)) ([1cd4219](https://github.com/starknet-io/starknet.js/commit/1cd4219df5e61a676bc58ba8c8673269695fc2db))
6
+
7
+ # [6.24.0](https://github.com/starknet-io/starknet.js/compare/v6.23.1...v6.24.0) (2025-03-12)
8
+
9
+ ### Features
10
+
11
+ - add simulate and estimate fee utility methods for outside execution ([#1327](https://github.com/starknet-io/starknet.js/issues/1327)) ([3668b01](https://github.com/starknet-io/starknet.js/commit/3668b01c4f63969bb0770ee6120fe3eac72d0335))
12
+ - implement cairo fixed array support ([#1310](https://github.com/starknet-io/starknet.js/issues/1310)) ([45df63e](https://github.com/starknet-io/starknet.js/commit/45df63e7bb7f7cb2de2e98900387b1c44a95f257))
13
+
1
14
  ## [6.23.1](https://github.com/starknet-io/starknet.js/compare/v6.23.0...v6.23.1) (2025-02-05)
2
15
 
3
16
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -7279,7 +7279,7 @@ declare function getOutsideCall(call: Call): OutsideCall;
7279
7279
  */
7280
7280
  declare function getTypedData(chainId: string, options: OutsideExecutionOptions, nonce: BigNumberish, myCalls: Call[], version: OutsideExecutionVersion): TypedData;
7281
7281
  /**
7282
- * Builds a CallData for the execute_from_outside() entrypoint.
7282
+ * Builds a Calldata for the execute_from_outside() entrypoint.
7283
7283
  * @param {OutsideTransaction} outsideTransaction an object that contains all the data for a Outside Execution.
7284
7284
  * @returns {Calldata} The Calldata related to this Outside transaction
7285
7285
  * @example
@@ -7303,12 +7303,39 @@ declare function getTypedData(chainId: string, options: OutsideExecutionOptions,
7303
7303
  * ```
7304
7304
  */
7305
7305
  declare function buildExecuteFromOutsideCallData(outsideTransaction: OutsideTransaction): Calldata;
7306
+ /**
7307
+ * Builds a Call for execute(), estimateFee() and simulateTransaction() functions.
7308
+ * @param {AllowArray<OutsideTransaction>} outsideTransaction an object that contains all the data for an Outside Execution.
7309
+ * @returns {Call[]} The Call related to this Outside transaction
7310
+ * @example
7311
+ * ```typescript
7312
+ * const outsideTransaction: OutsideTransaction = {
7313
+ * outsideExecution: {
7314
+ * caller: '0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691',
7315
+ * nonce: '0x7d0b4b4fce4b236e63d2bb5fc321935d52935cd3b268248cf9cf29c496bd0ae',
7316
+ * execute_after: 500, execute_before: 600,
7317
+ * calls: [{ to: '0x678', selector: '0x890', calldata: [12, 13] }],
7318
+ * },
7319
+ * signature: ['0x123', '0x456'],
7320
+ * signerAddress: '0x3b278ebae434f283f9340587a7f2dd4282658ac8e03cb9b0956db23a0a83657',
7321
+ * version: EOutsideExecutionVersion.V2,
7322
+ * };
7323
+ *
7324
+ * const result: Call[] = outsideExecution.buildExecuteFromOutsideCall(outsideTransaction);
7325
+ * // result = [{contractAddress: '0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691',
7326
+ * // entrypoint: 'execute_from_outside_v2',
7327
+ * // calldata: [ ... ],
7328
+ * // }]
7329
+ * ```
7330
+ */
7331
+ declare function buildExecuteFromOutsideCall(outsideTransaction: AllowArray<OutsideTransaction>): Call[];
7306
7332
 
7333
+ declare const outsideExecution_buildExecuteFromOutsideCall: typeof buildExecuteFromOutsideCall;
7307
7334
  declare const outsideExecution_buildExecuteFromOutsideCallData: typeof buildExecuteFromOutsideCallData;
7308
7335
  declare const outsideExecution_getOutsideCall: typeof getOutsideCall;
7309
7336
  declare const outsideExecution_getTypedData: typeof getTypedData;
7310
7337
  declare namespace outsideExecution {
7311
- export { outsideExecution_buildExecuteFromOutsideCallData as buildExecuteFromOutsideCallData, outsideExecution_getOutsideCall as getOutsideCall, outsideExecution_getTypedData as getTypedData };
7338
+ export { outsideExecution_buildExecuteFromOutsideCall as buildExecuteFromOutsideCall, outsideExecution_buildExecuteFromOutsideCallData as buildExecuteFromOutsideCallData, outsideExecution_getOutsideCall as getOutsideCall, outsideExecution_getTypedData as getTypedData };
7312
7339
  }
7313
7340
 
7314
7341
  /**
@@ -7443,6 +7470,102 @@ declare class CairoUint512 {
7443
7470
  toApiRequest(): string[];
7444
7471
  }
7445
7472
 
7473
+ declare class CairoFixedArray {
7474
+ /**
7475
+ * JS array representing a Cairo fixed array.
7476
+ */
7477
+ readonly content: any[];
7478
+ /**
7479
+ * Cairo fixed array type.
7480
+ */
7481
+ readonly arrayType: string;
7482
+ /**
7483
+ * Create an instance representing a Cairo fixed Array.
7484
+ * @param {any[]} content JS array representing a Cairo fixed array.
7485
+ * @param {string} arrayType Cairo fixed array type.
7486
+ */
7487
+ constructor(content: any[], arrayType: string);
7488
+ /**
7489
+ * Retrieves the array size from the given type string representing a Cairo fixed array.
7490
+ * @param {string} type - The Cairo fixed array type.
7491
+ * @returns {number} The array size.
7492
+ * @example
7493
+ * ```typescript
7494
+ * const result = CairoFixedArray.getFixedArraySize("[core::integer::u32; 8]");
7495
+ * // result = 8
7496
+ * ```
7497
+ */
7498
+ static getFixedArraySize(type: string): number;
7499
+ /**
7500
+ * Retrieves the Cairo fixed array size from the CairoFixedArray instance.
7501
+ * @returns {number} The fixed array size.
7502
+ * @example
7503
+ * ```typescript
7504
+ * const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
7505
+ * const result = fArray.getFixedArraySize();
7506
+ * // result = 3
7507
+ * ```
7508
+ */
7509
+ getFixedArraySize(): number;
7510
+ /**
7511
+ * Retrieve the Cairo content type from a Cairo fixed array type.
7512
+ * @param {string} type - The type string.
7513
+ * @returns {string} The fixed-array type.
7514
+ * @example
7515
+ * ```typescript
7516
+ * const result = CairoFixedArray.getFixedArrayType("[core::integer::u32; 8]");
7517
+ * // result = "core::integer::u32"
7518
+ * ```
7519
+ */
7520
+ static getFixedArrayType: (type: string) => string;
7521
+ /**
7522
+ * Retrieve the Cairo content type of the Cairo fixed array.
7523
+ * @returns {string} The fixed-array content type.
7524
+ * @example
7525
+ * ```typescript
7526
+ * const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
7527
+ * const result = fArray.getFixedArrayType();
7528
+ * // result = "core::integer::u32"
7529
+ * ```
7530
+ */
7531
+ getFixedArrayType(): string;
7532
+ /**
7533
+ * Create an object from a Cairo fixed array.
7534
+ * Be sure to have an array length conform to the ABI.
7535
+ * To be used with CallData.compile().
7536
+ * @param {Array<any>} input JS array representing a Cairo fixed array.
7537
+ * @returns {Object} a specific struct representing a fixed Array.
7538
+ * @example
7539
+ * ```typescript
7540
+ * const result = CairoFixedArray.compile([10,20,30]);
7541
+ * // result = { '0': 10, '1': 20, '2': 30 }
7542
+ * ```
7543
+ */
7544
+ static compile(input: Array<any>): Object;
7545
+ /**
7546
+ * Generate an object from the Cairo fixed array instance.
7547
+ * To be used with CallData.compile().
7548
+ * @returns a specific struct representing a fixed array.
7549
+ * @example
7550
+ * ```typescript
7551
+ * const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
7552
+ * const result = fArray.compile();
7553
+ * // result = { '0': 10, '1': 20, '2': 30 }
7554
+ * ```
7555
+ */
7556
+ compile(): Object;
7557
+ /**
7558
+ * Checks if the given Cairo type is a fixed-array type.
7559
+ *
7560
+ * @param {string} type - The type to check.
7561
+ * @returns - `true` if the type is a fixed array type, `false` otherwise.
7562
+ * ```typescript
7563
+ * const result = CairoFixedArray.isTypeFixedArray("[core::integer::u32; 8]");
7564
+ * // result = true
7565
+ */
7566
+ static isTypeFixedArray(type: string): boolean;
7567
+ }
7568
+
7446
7569
  /**
7447
7570
  * Format a hex number to '0x' and 64 characters, adding leading zeros if necessary.
7448
7571
  *
@@ -8168,4 +8291,4 @@ declare const logger: Logger;
8168
8291
  /** @deprecated prefer the 'num' naming */
8169
8292
  declare const number: typeof num;
8170
8293
 
8171
- 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 };
8294
+ 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, CairoFixedArray, 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 };
@@ -3212,6 +3212,7 @@ var starknet = (() => {
3212
3212
  BlockStatus: () => BlockStatus,
3213
3213
  BlockTag: () => BlockTag,
3214
3214
  CairoCustomEnum: () => CairoCustomEnum,
3215
+ CairoFixedArray: () => CairoFixedArray,
3215
3216
  CairoOption: () => CairoOption,
3216
3217
  CairoOptionVariant: () => CairoOptionVariant,
3217
3218
  CairoResult: () => CairoResult,
@@ -8601,6 +8602,151 @@ ${indent}}` : "}";
8601
8602
  return isCairo1Type(type) ? extractCairo1Tuple(type) : extractCairo0Tuple(type);
8602
8603
  }
8603
8604
 
8605
+ // src/utils/cairoDataTypes/fixedArray.ts
8606
+ var CairoFixedArray = class _CairoFixedArray {
8607
+ /**
8608
+ * JS array representing a Cairo fixed array.
8609
+ */
8610
+ content;
8611
+ /**
8612
+ * Cairo fixed array type.
8613
+ */
8614
+ arrayType;
8615
+ /**
8616
+ * Create an instance representing a Cairo fixed Array.
8617
+ * @param {any[]} content JS array representing a Cairo fixed array.
8618
+ * @param {string} arrayType Cairo fixed array type.
8619
+ */
8620
+ constructor(content, arrayType) {
8621
+ assert(
8622
+ _CairoFixedArray.isTypeFixedArray(arrayType),
8623
+ `The type ${arrayType} is not a Cairo fixed array. Needs [type; length].`
8624
+ );
8625
+ try {
8626
+ _CairoFixedArray.getFixedArrayType(arrayType);
8627
+ } catch {
8628
+ throw new Error(
8629
+ `The type ${arrayType} do not includes any content type. Needs [type; length].`
8630
+ );
8631
+ }
8632
+ try {
8633
+ _CairoFixedArray.getFixedArraySize(arrayType);
8634
+ } catch {
8635
+ throw new Error(
8636
+ `The type ${arrayType} type do not includes any length. Needs [type; length].`
8637
+ );
8638
+ }
8639
+ assert(
8640
+ _CairoFixedArray.getFixedArraySize(arrayType) === content.length,
8641
+ `The ABI type ${arrayType} is expecting ${_CairoFixedArray.getFixedArraySize(arrayType)} items. ${content.length} items provided.`
8642
+ );
8643
+ this.content = content;
8644
+ this.arrayType = arrayType;
8645
+ }
8646
+ /**
8647
+ * Retrieves the array size from the given type string representing a Cairo fixed array.
8648
+ * @param {string} type - The Cairo fixed array type.
8649
+ * @returns {number} The array size.
8650
+ * @example
8651
+ * ```typescript
8652
+ * const result = CairoFixedArray.getFixedArraySize("[core::integer::u32; 8]");
8653
+ * // result = 8
8654
+ * ```
8655
+ */
8656
+ static getFixedArraySize(type) {
8657
+ const matchArray = type.match(/(?<=; )\d+(?=\])/);
8658
+ if (matchArray === null)
8659
+ throw new Error(`ABI type ${type} do not includes a valid number after ';' character.`);
8660
+ return Number(matchArray[0]);
8661
+ }
8662
+ /**
8663
+ * Retrieves the Cairo fixed array size from the CairoFixedArray instance.
8664
+ * @returns {number} The fixed array size.
8665
+ * @example
8666
+ * ```typescript
8667
+ * const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
8668
+ * const result = fArray.getFixedArraySize();
8669
+ * // result = 3
8670
+ * ```
8671
+ */
8672
+ getFixedArraySize() {
8673
+ return _CairoFixedArray.getFixedArraySize(this.arrayType);
8674
+ }
8675
+ /**
8676
+ * Retrieve the Cairo content type from a Cairo fixed array type.
8677
+ * @param {string} type - The type string.
8678
+ * @returns {string} The fixed-array type.
8679
+ * @example
8680
+ * ```typescript
8681
+ * const result = CairoFixedArray.getFixedArrayType("[core::integer::u32; 8]");
8682
+ * // result = "core::integer::u32"
8683
+ * ```
8684
+ */
8685
+ static getFixedArrayType = (type) => {
8686
+ const matchArray = type.match(/(?<=\[).+(?=;)/);
8687
+ if (matchArray === null)
8688
+ throw new Error(`ABI type ${type} do not includes a valid type of data.`);
8689
+ return matchArray[0];
8690
+ };
8691
+ /**
8692
+ * Retrieve the Cairo content type of the Cairo fixed array.
8693
+ * @returns {string} The fixed-array content type.
8694
+ * @example
8695
+ * ```typescript
8696
+ * const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
8697
+ * const result = fArray.getFixedArrayType();
8698
+ * // result = "core::integer::u32"
8699
+ * ```
8700
+ */
8701
+ getFixedArrayType() {
8702
+ return _CairoFixedArray.getFixedArrayType(this.arrayType);
8703
+ }
8704
+ /**
8705
+ * Create an object from a Cairo fixed array.
8706
+ * Be sure to have an array length conform to the ABI.
8707
+ * To be used with CallData.compile().
8708
+ * @param {Array<any>} input JS array representing a Cairo fixed array.
8709
+ * @returns {Object} a specific struct representing a fixed Array.
8710
+ * @example
8711
+ * ```typescript
8712
+ * const result = CairoFixedArray.compile([10,20,30]);
8713
+ * // result = { '0': 10, '1': 20, '2': 30 }
8714
+ * ```
8715
+ */
8716
+ static compile(input) {
8717
+ return input.reduce((acc, item, idx) => {
8718
+ acc[idx] = item;
8719
+ return acc;
8720
+ }, {});
8721
+ }
8722
+ /**
8723
+ * Generate an object from the Cairo fixed array instance.
8724
+ * To be used with CallData.compile().
8725
+ * @returns a specific struct representing a fixed array.
8726
+ * @example
8727
+ * ```typescript
8728
+ * const fArray = new CairoFixedArray([10,20,30], "[core::integer::u32; 3]");
8729
+ * const result = fArray.compile();
8730
+ * // result = { '0': 10, '1': 20, '2': 30 }
8731
+ * ```
8732
+ */
8733
+ compile() {
8734
+ return _CairoFixedArray.compile(this.content);
8735
+ }
8736
+ /**
8737
+ * Checks if the given Cairo type is a fixed-array type.
8738
+ *
8739
+ * @param {string} type - The type to check.
8740
+ * @returns - `true` if the type is a fixed array type, `false` otherwise.
8741
+ * ```typescript
8742
+ * const result = CairoFixedArray.isTypeFixedArray("[core::integer::u32; 8]");
8743
+ * // result = true
8744
+ */
8745
+ static isTypeFixedArray(type) {
8746
+ return /^\[.*;\s.*\]$/.test(type) && /(?<=\[).+(?=;)/.test(type) && /(?<=; )\d+(?=\])/.test(type);
8747
+ }
8748
+ };
8749
+
8604
8750
  // src/utils/calldata/propertyOrder.ts
8605
8751
  function errorU256(key) {
8606
8752
  return Error(
@@ -8614,6 +8760,9 @@ ${indent}}` : "}";
8614
8760
  }
8615
8761
  function orderPropsByAbi(unorderedObject, abiOfObject, structs, enums) {
8616
8762
  const orderInput = (unorderedItem, abiType) => {
8763
+ if (CairoFixedArray.isTypeFixedArray(abiType)) {
8764
+ return orderFixedArray(unorderedItem, abiType);
8765
+ }
8617
8766
  if (isTypeArray(abiType)) {
8618
8767
  return orderArray(unorderedItem, abiType);
8619
8768
  }
@@ -8688,6 +8837,24 @@ ${indent}}` : "}";
8688
8837
  }
8689
8838
  return myArray.map((myElem) => orderInput(myElem, typeInArray));
8690
8839
  }
8840
+ function orderFixedArray(input, abiParam) {
8841
+ const typeInFixedArray = CairoFixedArray.getFixedArrayType(abiParam);
8842
+ const arraySize = CairoFixedArray.getFixedArraySize(abiParam);
8843
+ if (Array.isArray(input)) {
8844
+ if (arraySize !== input.length) {
8845
+ throw new Error(
8846
+ `ABI type ${abiParam}: array provided do not includes ${arraySize} items. ${input.length} items provided.`
8847
+ );
8848
+ }
8849
+ return input.map((myElem) => orderInput(myElem, typeInFixedArray));
8850
+ }
8851
+ if (arraySize !== Object.keys(input).length) {
8852
+ throw new Error(
8853
+ `ABI type ${abiParam}: object provided do not includes ${arraySize} properties. ${Object.keys(input).length} items provided.`
8854
+ );
8855
+ }
8856
+ return orderInput(input, typeInFixedArray);
8857
+ }
8691
8858
  function orderTuple(unorderedObject2, abiParam) {
8692
8859
  const typeList = extractTupleMemberTypes(abiParam);
8693
8860
  const orderedObject2 = typeList.reduce((orderedObject, abiTypeCairoX, index) => {
@@ -8823,6 +8990,25 @@ ${indent}}` : "}";
8823
8990
  if (element === void 0) {
8824
8991
  throw Error(`Missing parameter for type ${type}`);
8825
8992
  }
8993
+ if (CairoFixedArray.isTypeFixedArray(type)) {
8994
+ const arrayType = CairoFixedArray.getFixedArrayType(type);
8995
+ let values = [];
8996
+ if (Array.isArray(element)) {
8997
+ const array = new CairoFixedArray(element, type);
8998
+ values = array.content;
8999
+ } else if (typeof element === "object") {
9000
+ values = Object.values(element);
9001
+ assert(
9002
+ values.length === CairoFixedArray.getFixedArraySize(type),
9003
+ `ABI type ${type}: object provided do not includes ${CairoFixedArray.getFixedArraySize(type)} items. ${values.length} items provided.`
9004
+ );
9005
+ } else {
9006
+ throw new Error(`ABI type ${type}: not an Array representing a cairo.fixedArray() provided.`);
9007
+ }
9008
+ return values.reduce((acc, it) => {
9009
+ return acc.concat(parseCalldataValue(it, arrayType, structs, enums));
9010
+ }, []);
9011
+ }
8826
9012
  if (Array.isArray(element)) {
8827
9013
  const result = [];
8828
9014
  result.push(felt(element.length));
@@ -8950,7 +9136,13 @@ ${indent}}` : "}";
8950
9136
  const { name, type } = input;
8951
9137
  let { value } = argsIterator.next();
8952
9138
  switch (true) {
8953
- // Array
9139
+ // Fixed array
9140
+ case CairoFixedArray.isTypeFixedArray(type):
9141
+ if (!Array.isArray(value) && !(typeof value === "object")) {
9142
+ throw Error(`ABI expected parameter ${name} to be an array or an object, got ${value}`);
9143
+ }
9144
+ return parseCalldataValue(value, input.type, structs, enums);
9145
+ // Normal Array
8954
9146
  case isTypeArray(type):
8955
9147
  if (!Array.isArray(value) && !isText(value)) {
8956
9148
  throw Error(`ABI expected parameter ${name} to be array or long string, got ${value}`);
@@ -9046,6 +9238,15 @@ ${indent}}` : "}";
9046
9238
  };
9047
9239
  return stringFromByteArray(myByteArray);
9048
9240
  }
9241
+ if (CairoFixedArray.isTypeFixedArray(element.type)) {
9242
+ const parsedDataArr = [];
9243
+ const el = { name: "", type: CairoFixedArray.getFixedArrayType(element.type) };
9244
+ const arraySize = CairoFixedArray.getFixedArraySize(element.type);
9245
+ while (parsedDataArr.length < arraySize) {
9246
+ parsedDataArr.push(parseResponseValue(responseIterator, el, structs, enums));
9247
+ }
9248
+ return parsedDataArr;
9249
+ }
9049
9250
  if (isTypeArray(element.type)) {
9050
9251
  const parsedDataArr = [];
9051
9252
  const el = { name: "", type: getArrayType(element.type) };
@@ -9131,6 +9332,8 @@ ${indent}}` : "}";
9131
9332
  return parseResponseValue(responseIterator, output, structs, enums);
9132
9333
  case (enums && isTypeEnum(type, enums)):
9133
9334
  return parseResponseValue(responseIterator, output, structs, enums);
9335
+ case CairoFixedArray.isTypeFixedArray(type):
9336
+ return parseResponseValue(responseIterator, output, structs, enums);
9134
9337
  case isTypeArray(type):
9135
9338
  if (isCairo1Type(type)) {
9136
9339
  return parseResponseValue(responseIterator, output, structs, enums);
@@ -9333,12 +9536,28 @@ ${indent}}` : "}";
9333
9536
  var validateTuple = (parameter, input) => {
9334
9537
  assert(isObject2(parameter), `Validate: arg ${input.name} should be a tuple (defined as object)`);
9335
9538
  };
9336
- var validateArray = (parameter, input, structs, enums) => {
9337
- const baseType = getArrayType(input.type);
9338
- if (isTypeFelt(baseType) && isLongText(parameter)) {
9539
+ var validateArray = (parameterArray, input, structs, enums) => {
9540
+ const isNormalArray = isTypeArray(input.type);
9541
+ const baseType = isNormalArray ? getArrayType(input.type) : CairoFixedArray.getFixedArrayType(input.type);
9542
+ if (isNormalArray && isTypeFelt(baseType) && isLongText(parameterArray)) {
9339
9543
  return;
9340
9544
  }
9341
- assert(Array.isArray(parameter), `Validate: arg ${input.name} should be an Array`);
9545
+ let parameter = [];
9546
+ if (isNormalArray) {
9547
+ assert(Array.isArray(parameterArray), `Validate: arg ${input.name} should be an Array`);
9548
+ parameter = parameterArray;
9549
+ } else {
9550
+ switch (true) {
9551
+ case Array.isArray(parameterArray):
9552
+ parameter = parameterArray;
9553
+ break;
9554
+ case typeof parameterArray === "object":
9555
+ parameter = Object.values(parameterArray);
9556
+ break;
9557
+ default:
9558
+ throw new Error(`Validate: arg ${input.name} should be an Array or an object.`);
9559
+ }
9560
+ }
9342
9561
  switch (true) {
9343
9562
  case isTypeFelt(baseType):
9344
9563
  parameter.forEach((param) => validateFelt(param, input));
@@ -9428,7 +9647,7 @@ ${indent}}` : "}";
9428
9647
  case isTypeByteArray(input.type):
9429
9648
  validateByteArray(parameter, input);
9430
9649
  break;
9431
- case isTypeArray(input.type):
9650
+ case (isTypeArray(input.type) || CairoFixedArray.isTypeFixedArray(input.type)):
9432
9651
  validateArray(parameter, input, structs, enums);
9433
9652
  break;
9434
9653
  case isTypeStruct(input.type, structs):
@@ -16693,30 +16912,35 @@ ${JSON.stringify(data, null, 2)}`;
16693
16912
  return type.type === "merkletree";
16694
16913
  }
16695
16914
  function getDependencies(types, type, dependencies = [], contains = "", revision = TypedDataRevision.LEGACY) {
16915
+ let dependencyTypes = [type];
16696
16916
  if (type[type.length - 1] === "*") {
16697
- type = type.slice(0, -1);
16917
+ dependencyTypes = [type.slice(0, -1)];
16698
16918
  } else if (revision === TypedDataRevision.ACTIVE) {
16699
16919
  if (type === "enum") {
16700
- type = contains;
16920
+ dependencyTypes = [contains];
16701
16921
  } else if (type.match(/^\(.*\)$/)) {
16702
- type = type.slice(1, -1);
16703
- }
16704
- }
16705
- if (dependencies.includes(type) || !types[type]) {
16706
- return dependencies;
16707
- }
16708
- return [
16709
- type,
16710
- ...types[type].reduce(
16711
- (previous, t) => [
16712
- ...previous,
16713
- ...getDependencies(types, t.type, previous, t.contains, revision).filter(
16714
- (dependency) => !previous.includes(dependency)
16922
+ dependencyTypes = type.slice(1, -1).split(",").map((depType) => depType[depType.length - 1] === "*" ? depType.slice(0, -1) : depType);
16923
+ }
16924
+ }
16925
+ return dependencyTypes.filter((t) => !dependencies.includes(t) && types[t]).reduce(
16926
+ // This comment prevents prettier from rolling everything here into a single line.
16927
+ (p, depType) => [
16928
+ ...p,
16929
+ ...[
16930
+ depType,
16931
+ ...types[depType].reduce(
16932
+ (previous, t) => [
16933
+ ...previous,
16934
+ ...getDependencies(types, t.type, previous, t.contains, revision).filter(
16935
+ (dependency) => !previous.includes(dependency)
16936
+ )
16937
+ ],
16938
+ []
16715
16939
  )
16716
- ],
16717
- []
16718
- )
16719
- ];
16940
+ ].filter((dependency) => !p.includes(dependency))
16941
+ ],
16942
+ []
16943
+ );
16720
16944
  }
16721
16945
  function getMerkleTreeType(types, ctx) {
16722
16946
  if (ctx.parent && ctx.key) {
@@ -19198,6 +19422,7 @@ ${JSON.stringify(data, null, 2)}`;
19198
19422
  // src/utils/outsideExecution.ts
19199
19423
  var outsideExecution_exports = {};
19200
19424
  __export(outsideExecution_exports, {
19425
+ buildExecuteFromOutsideCall: () => buildExecuteFromOutsideCall,
19201
19426
  buildExecuteFromOutsideCallData: () => buildExecuteFromOutsideCallData,
19202
19427
  getOutsideCall: () => getOutsideCall,
19203
19428
  getTypedData: () => getTypedData
@@ -19269,6 +19494,25 @@ ${JSON.stringify(data, null, 2)}`;
19269
19494
  signature: formattedSignature
19270
19495
  });
19271
19496
  }
19497
+ function buildExecuteFromOutsideCall(outsideTransaction) {
19498
+ const myOutsideTransactions = Array.isArray(outsideTransaction) ? outsideTransaction : [outsideTransaction];
19499
+ const multiCall = myOutsideTransactions.map((outsideTx) => {
19500
+ let entrypoint;
19501
+ if (outsideTx.version === "1" /* V1 */) {
19502
+ entrypoint = "execute_from_outside";
19503
+ } else if (outsideTx.version === "2" /* V2 */) {
19504
+ entrypoint = "execute_from_outside_v2";
19505
+ } else {
19506
+ throw new Error("Unsupported OutsideExecution version");
19507
+ }
19508
+ return {
19509
+ contractAddress: toHex(outsideTx.signerAddress),
19510
+ entrypoint,
19511
+ calldata: buildExecuteFromOutsideCallData(outsideTx)
19512
+ };
19513
+ });
19514
+ return multiCall;
19515
+ }
19272
19516
 
19273
19517
  // src/utils/src5.ts
19274
19518
  var src5_exports = {};
@@ -19826,22 +20070,7 @@ ${JSON.stringify(data, null, 2)}`;
19826
20070
  * ```
19827
20071
  */
19828
20072
  async executeFromOutside(outsideTransaction, opts) {
19829
- const myOutsideTransactions = Array.isArray(outsideTransaction) ? outsideTransaction : [outsideTransaction];
19830
- const multiCall = myOutsideTransactions.map((outsideTx) => {
19831
- let entrypoint;
19832
- if (outsideTx.version === "1" /* V1 */) {
19833
- entrypoint = "execute_from_outside";
19834
- } else if (outsideTx.version === "2" /* V2 */) {
19835
- entrypoint = "execute_from_outside_v2";
19836
- } else {
19837
- throw new Error("Unsupported OutsideExecution version");
19838
- }
19839
- return {
19840
- contractAddress: toHex(outsideTx.signerAddress),
19841
- entrypoint,
19842
- calldata: buildExecuteFromOutsideCallData(outsideTx)
19843
- };
19844
- });
20073
+ const multiCall = buildExecuteFromOutsideCall(outsideTransaction);
19845
20074
  return this.execute(multiCall, opts);
19846
20075
  }
19847
20076
  /*