starknet 11.0.0-beta.4 → 11.0.0-beta.6

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
+ # [11.0.0-beta.6](https://github.com/starknet-io/starknet.js/compare/v11.0.0-beta.5...v11.0.0-beta.6) (2026-08-25)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **calldata:** text reaches a ByteArray, whatever it spells ([509c9f8](https://github.com/starknet-io/starknet.js/commit/509c9f80f02ef1f5751bcdbd45a8612c2479f6f8))
6
+
7
+ # [11.0.0-beta.5](https://github.com/starknet-io/starknet.js/compare/v11.0.0-beta.4...v11.0.0-beta.5) (2026-08-24)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **calldata:** long string chunks stay text, at any ABI depth ([06638d9](https://github.com/starknet-io/starknet.js/commit/06638d9b7317caf3e20087c9f92a05a499157213))
12
+
1
13
  # [11.0.0-beta.4](https://github.com/starknet-io/starknet.js/compare/v11.0.0-beta.3...v11.0.0-beta.4) (2026-08-21)
2
14
 
3
15
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -10351,11 +10351,82 @@ declare class CairoFixedArray {
10351
10351
  static isTypeFixedArray(type: string): boolean;
10352
10352
  }
10353
10353
 
10354
+ /**
10355
+ * A Cairo `core::bytes_31::bytes31` : up to 31 bytes, carried in a single felt252.
10356
+ *
10357
+ * The bytes are held right-aligned in a fixed 31-byte buffer, so the length of the input is not
10358
+ * recoverable from the value — `'0x41'` and `'0x0041'` give the same bytes31. Reach for
10359
+ * `CairoByteArray` when the byte count has to survive.
10360
+ * @example
10361
+ * ```typescript
10362
+ * // the same five characters, read two ways
10363
+ * new CairoBytes31('12345').toHexString(); // "0x3039" the number 12345
10364
+ * CairoBytes31.fromText('12345').toHexString(); // "0x3132333435" the text '12345'
10365
+ * ```
10366
+ */
10354
10367
  declare class CairoBytes31 {
10368
+ /**
10369
+ * How many bytes a bytes31 holds, which is also the width of a `ByteArray` word.
10370
+ * @example
10371
+ * ```typescript
10372
+ * const result = CairoBytes31.MAX_BYTE_SIZE;
10373
+ * // result = 31
10374
+ * ```
10375
+ */
10355
10376
  static MAX_BYTE_SIZE: 31;
10377
+ /**
10378
+ * The bytes, always exactly 31 of them.
10379
+ *
10380
+ * A shorter input is right-aligned and the leading bytes left at zero, so this buffer does not
10381
+ * record how long that input was.
10382
+ * @example
10383
+ * ```typescript
10384
+ * const result = new CairoBytes31('0x41').data.length;
10385
+ * // result = 31 (the byte 0x41 sits last, at index 30)
10386
+ * ```
10387
+ */
10356
10388
  data: Uint8Array;
10389
+ /**
10390
+ * The abi type this class serializes.
10391
+ * @example
10392
+ * ```typescript
10393
+ * const result = CairoBytes31.abiSelector;
10394
+ * // result = "core::bytes_31::bytes31"
10395
+ * ```
10396
+ */
10357
10397
  static abiSelector: "core::bytes_31::bytes31";
10398
+ /**
10399
+ * Build from a single value, right-aligned in 31 bytes.
10400
+ *
10401
+ * A string is read the way calldata reads it : `'0x41'` as the byte 0x41, `'12345'` as the number
10402
+ * 12345, anything else as UTF-8 text. A string that spells a number therefore becomes that
10403
+ * number, with no error raised — use {@link CairoBytes31.fromText} when the argument is text.
10404
+ *
10405
+ * A value that is already a CairoBytes31 is adopted as it stands, its bytes copied rather than
10406
+ * read a second time.
10407
+ * @param {string | Uint8Array | Buffer | CairoBytes31} data the value to carry, 31 bytes at most
10408
+ * @throws {Error} when the value needs more than 31 bytes
10409
+ * @example
10410
+ * ```typescript
10411
+ * const result = new CairoBytes31('Hello').toApiRequest();
10412
+ * // result = ["310939249775"]
10413
+ * ```
10414
+ */
10358
10415
  constructor(data: string | Uint8Array | Buffer | unknown);
10416
+ /**
10417
+ * Turn any accepted input into its bytes, before they are right-aligned by the constructor.
10418
+ *
10419
+ * The returned length is the length of the input, not 31 : `validate` reads it to decide whether
10420
+ * the value fits. An input that is already a CairoBytes31 comes back as a copy of its 31 bytes.
10421
+ * @param {Uint8Array | string | Buffer | CairoBytes31} data the value to convert
10422
+ * @returns {Uint8Array} the bytes, of whatever length the input implied
10423
+ * @throws {Error} when the input is of a type this class does not read
10424
+ * @example
10425
+ * ```typescript
10426
+ * const result = CairoBytes31.__processData('0x4142').length;
10427
+ * // result = 2 (where CairoBytes31.__processData('Hello').length is 5)
10428
+ * ```
10429
+ */
10359
10430
  static __processData(data: Uint8Array | string | Buffer | unknown): Uint8Array;
10360
10431
  /**
10361
10432
  * Build from text, with no interpretation of what the text looks like.
@@ -10372,19 +10443,116 @@ declare class CairoBytes31 {
10372
10443
  * ```
10373
10444
  */
10374
10445
  static fromText(text: string): CairoBytes31;
10446
+ /**
10447
+ * Serialize to the single felt a contract call carries.
10448
+ * @returns {string[]} one decimal-string felt, flagged as compiled
10449
+ * @example
10450
+ * ```typescript
10451
+ * const result = CairoBytes31.fromText('Hello').toApiRequest();
10452
+ * // result = ["310939249775"]
10453
+ * ```
10454
+ */
10375
10455
  toApiRequest(): string[];
10456
+ /**
10457
+ * The 31 bytes read as one big-endian number.
10458
+ *
10459
+ * The padding zeros weigh nothing, so this is the same number whether the input was `'0x41'` or
10460
+ * `'0x0041'`.
10461
+ * @returns {bigint} the bytes as a number, 0n when they are all zero
10462
+ * @example
10463
+ * ```typescript
10464
+ * const result = CairoBytes31.fromText('Hello').toBigInt();
10465
+ * // result = 310939249775n
10466
+ * ```
10467
+ */
10376
10468
  toBigInt(): bigint;
10469
+ /**
10470
+ * Read the bytes back as UTF-8 text, leading zero bytes dropped.
10471
+ *
10472
+ * Those zeros are the padding that fills the buffer, and nothing tells them apart from a zero
10473
+ * byte the caller meant to carry — so a text opening on a NUL does not survive the round trip.
10474
+ * Reach for `CairoByteArray` when it has to.
10475
+ * @returns {string} the bytes decoded as UTF-8, without their leading zeros
10476
+ * @example
10477
+ * ```typescript
10478
+ * const result = CairoBytes31.fromText('12345').decodeUtf8();
10479
+ * // result = "12345"
10480
+ * const result2 = new CairoBytes31('12345').decodeUtf8();
10481
+ * // result2 = "09" (the number 12345 is the two bytes 0x30 0x39)
10482
+ * ```
10483
+ */
10377
10484
  decodeUtf8(): string;
10378
10485
  /**
10379
- * @param padded flag for including leading zeros
10486
+ * The bytes in hexadecimal.
10487
+ *
10488
+ * Bare, the leading zeros are dropped, which is the form a node returns for a felt. Padded, all
10489
+ * 31 bytes are written out, which is the form a `ByteArray` data word takes.
10490
+ * @param {'padded'} [padded] write the 31 bytes in full, leading zeros included
10491
+ * @returns {string} the bytes as a 0x-prefixed hex string
10492
+ * @example
10493
+ * ```typescript
10494
+ * const result = new CairoBytes31('Hello').toHexString();
10495
+ * // result = "0x48656c6c6f"
10496
+ * const result2 = new CairoBytes31('Hello').toHexString('padded');
10497
+ * // result2 = "0x000000000000000000000000000000000000000000000000000048656c6c6f"
10498
+ * ```
10380
10499
  */
10381
10500
  toHexString(padded?: 'padded'): string;
10501
+ /**
10502
+ * Throw unless the value fits in 31 bytes.
10503
+ *
10504
+ * Length is all it weighs. Deciding it means converting the value first, so an input of a type
10505
+ * this class does not read raises from `__processData` instead, with that method's message.
10506
+ * @param {Uint8Array | string | Buffer | CairoBytes31} data the value to check
10507
+ * @throws {Error} when the value needs more than 31 bytes, or is of an unread type
10508
+ * @example
10509
+ * ```typescript
10510
+ * CairoBytes31.validate('Hello'); // passes
10511
+ * CairoBytes31.validate('x'.repeat(32));
10512
+ * // throws Error("Data is too long: 32 bytes (max 31 bytes)")
10513
+ * ```
10514
+ */
10382
10515
  static validate(data: Uint8Array | string | Buffer | unknown): void;
10383
- static is(data: Uint8Array | string | Buffer): boolean;
10384
10516
  /**
10385
- * Check if provided abi type is this data type
10517
+ * Can this value be carried by a CairoBytes31?
10518
+ *
10519
+ * The non-throwing form of {@link CairoBytes31.validate}, so a value of an unread type answers
10520
+ * false here just as an over-long one does.
10521
+ * @param {Uint8Array | string | Buffer | CairoBytes31} data the value to test
10522
+ * @returns {boolean} true when the value fits in a bytes31
10523
+ * @example
10524
+ * ```typescript
10525
+ * const result = CairoBytes31.is('Hello');
10526
+ * // result = true
10527
+ * const result2 = CairoBytes31.is('x'.repeat(32));
10528
+ * // result2 = false
10529
+ * ```
10530
+ */
10531
+ static is(data: Uint8Array | string | Buffer | unknown): boolean;
10532
+ /**
10533
+ * Is this abi type the one this class serializes?
10534
+ * @param {string} abiType the abi type to test
10535
+ * @returns {boolean} true for `core::bytes_31::bytes31`
10536
+ * @example
10537
+ * ```typescript
10538
+ * const result = CairoBytes31.isAbiType('core::bytes_31::bytes31');
10539
+ * // result = true
10540
+ * ```
10386
10541
  */
10387
10542
  static isAbiType(abiType: string): boolean;
10543
+ /**
10544
+ * Read one bytes31 off a contract response, advancing the iterator past it.
10545
+ *
10546
+ * One felt is consumed, so successive calls read successive return values.
10547
+ * @param {Iterator<string>} responseIterator the response felts, positioned on this bytes31
10548
+ * @returns {CairoBytes31} the bytes31 that was read
10549
+ * @example
10550
+ * ```typescript
10551
+ * const response = ['310939249775'];
10552
+ * const result = CairoBytes31.factoryFromApiResponse(response.values()).decodeUtf8();
10553
+ * // result = "Hello"
10554
+ * ```
10555
+ */
10388
10556
  static factoryFromApiResponse(responseIterator: Iterator<string>): CairoBytes31;
10389
10557
  }
10390
10558
 
@@ -10431,34 +10599,201 @@ declare class CairoUint32 {
10431
10599
  static factoryFromApiResponse(responseIterator: Iterator<string>): CairoUint32;
10432
10600
  }
10433
10601
 
10602
+ /**
10603
+ * A Cairo `core::byte_array::ByteArray` : an arbitrary sequence of bytes, cut into words of 31.
10604
+ *
10605
+ * A ByteArray is **not** Cairo's string type. It carries bytes, and text is only one of the things
10606
+ * those bytes can mean — which is why the constructor reads a string the way calldata does, and why
10607
+ * text has a door of its own, {@link CairoByteArray.fromText}.
10608
+ * @example
10609
+ * ```typescript
10610
+ * // the same four characters, read four ways
10611
+ * new CairoByteArray('Hello').toHexString(); // "0x48656c6c6f" text, nothing else fits
10612
+ * new CairoByteArray('12345').toHexString(); // "0x3039" the number 12345
10613
+ * new CairoByteArray('0x4142').toHexString(); // "0x4142" the bytes 0x41 0x42
10614
+ * CairoByteArray.fromText('12345').toHexString(); // "0x3132333435" the text '12345'
10615
+ * ```
10616
+ */
10434
10617
  declare class CairoByteArray {
10435
10618
  /**
10436
- * entire dataset
10619
+ * The complete words, 31 bytes each.
10620
+ *
10621
+ * Bytes that do not fill a whole word are not here, but in {@link CairoByteArray.pending_word}.
10622
+ * @example
10623
+ * ```typescript
10624
+ * const result = CairoByteArray.fromText('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567').data.length;
10625
+ * // result = 1 (33 bytes : one full word of 31, and 2 bytes left pending)
10626
+ * ```
10437
10627
  */
10438
10628
  data: CairoBytes31[];
10439
10629
  /**
10440
- * cairo specific implementation helper
10630
+ * The bytes left over after the last complete word, held as a felt252.
10631
+ *
10632
+ * Its value alone does not say how many bytes it holds — a leading zero byte is invisible in a
10633
+ * number — which is what {@link CairoByteArray.pending_word_len} is for.
10634
+ * @example
10635
+ * ```typescript
10636
+ * const text = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567';
10637
+ * const result = CairoByteArray.fromText(text).pending_word.toHexString();
10638
+ * // result = "0x3637" (the two characters '67' left after the first word)
10639
+ * ```
10441
10640
  */
10442
10641
  pending_word: CairoFelt252;
10443
10642
  /**
10444
- * cairo specific implementation helper
10643
+ * How many bytes {@link CairoByteArray.pending_word} holds, from 0 to 30.
10644
+ *
10645
+ * The contract reads this length, so the same pending word under two lengths is two different
10646
+ * values : `0x41` on one byte is `A`, on two bytes it is a NUL followed by `A`.
10647
+ * @example
10648
+ * ```typescript
10649
+ * const result = new CairoByteArray('0x0041').pending_word_len.toBigInt();
10650
+ * // result = 2n (where new CairoByteArray('0x41') gives 1n, for the same pending word)
10651
+ * ```
10445
10652
  */
10446
10653
  pending_word_len: CairoUint32;
10654
+ /**
10655
+ * The abi type this class serializes.
10656
+ * @example
10657
+ * ```typescript
10658
+ * const result = CairoByteArray.abiSelector;
10659
+ * // result = "core::byte_array::ByteArray"
10660
+ * ```
10661
+ */
10447
10662
  static abiSelector: "core::byte_array::ByteArray";
10448
10663
  /**
10449
- * byteArray from typed components
10664
+ * Build from components that are already typed, the form an api response arrives in.
10665
+ * @param {CairoBytes31[]} data the complete 31-byte words
10666
+ * @param {CairoFelt252} pendingWord the bytes left after the last complete word
10667
+ * @param {CairoUint32} pendingWordLen how many bytes `pendingWord` holds
10668
+ * @example
10669
+ * ```typescript
10670
+ * const pending = new CairoFelt252('0x48656c6c6f');
10671
+ * const result = new CairoByteArray([], pending, new CairoUint32(5)).decodeUtf8();
10672
+ * // result = "Hello"
10673
+ * ```
10450
10674
  */
10451
10675
  constructor(data: CairoBytes31[], pendingWord: CairoFelt252, pendingWordLen: CairoUint32);
10452
- constructor(data: BigNumberish | Buffer | Uint8Array | unknown);
10453
- static __processData(inData: BigNumberish | Buffer | Uint8Array | unknown): {
10676
+ /**
10677
+ * Build from a single value, cut into words of 31 bytes.
10678
+ *
10679
+ * A string is read the way calldata reads it : `'0x41'` as the byte 0x41, `'12345'` as the number
10680
+ * 12345, anything else as UTF-8 text. A string that spells a number therefore becomes that
10681
+ * number, with no error raised — use {@link CairoByteArray.fromText} when the argument is text.
10682
+ *
10683
+ * A value that is already a ByteArray — an instance, or the object returned by
10684
+ * `byteArrayFromString` — is adopted as it stands, its words never cut again.
10685
+ * @param {BigNumberish | Buffer | Uint8Array | ByteArray} data the value to carry
10686
+ * @example
10687
+ * ```typescript
10688
+ * const result = new CairoByteArray('Hello').toApiRequest();
10689
+ * // result = ["0", "310939249775", "5"]
10690
+ * const components = { data: [], pending_word: '0x41', pending_word_len: 1 };
10691
+ * const result2 = new CairoByteArray(components).decodeUtf8();
10692
+ * // result2 = "A"
10693
+ * ```
10694
+ */
10695
+ constructor(data: BigNumberish | Buffer | Uint8Array | ByteArray | unknown);
10696
+ /**
10697
+ * Turn any accepted input into the three components of a ByteArray.
10698
+ *
10699
+ * Shared by both constructor paths. An input that is already a ByteArray is adopted rather than
10700
+ * cut again, so a pending word declared longer than its content keeps that declared length.
10701
+ * @param {BigNumberish | Buffer | Uint8Array | ByteArray} inData the value to convert
10702
+ * @returns {object} the `data`, `pending_word` and `pending_word_len` components
10703
+ * @example
10704
+ * ```typescript
10705
+ * const result = CairoByteArray.__processData('Hello').pending_word_len.toBigInt();
10706
+ * // result = 5n
10707
+ * ```
10708
+ */
10709
+ static __processData(inData: BigNumberish | Buffer | Uint8Array | ByteArray | unknown): {
10454
10710
  data: CairoBytes31[];
10455
10711
  pending_word: CairoFelt252;
10456
10712
  pending_word_len: CairoUint32;
10457
10713
  };
10714
+ /**
10715
+ * Build from text, with no interpretation of what the text looks like.
10716
+ *
10717
+ * The constructor reads a string the way calldata does — `'0x1a'` as two hexadecimal bytes,
10718
+ * `'12345'` as a decimal number — because a ByteArray is a byte sequence, not Cairo's string
10719
+ * type, and spelling those bytes in hexadecimal is a legitimate way to fill one. Here there is
10720
+ * no such ambiguity: the argument is text, and its UTF-8 bytes are the value.
10721
+ * @param {string} text the text to encode
10722
+ * @returns {CairoByteArray} the UTF-8 bytes of the text, cut into 31-byte words
10723
+ * @example
10724
+ * ```typescript
10725
+ * const result = CairoByteArray.fromText('12345').toHexString();
10726
+ * // result = "0x3132333435" (the text, where the constructor would read the number 0x3039)
10727
+ * const result2 = CairoByteArray.fromText('0x4142').toHexString();
10728
+ * // result2 = "0x307834313432" (six characters, where the constructor would read the bytes "AB")
10729
+ * ```
10730
+ */
10731
+ static fromText(text: string): CairoByteArray;
10732
+ /**
10733
+ * Serialize to the felt sequence a contract call carries : the number of complete words, each of
10734
+ * them, then the pending word and its length.
10735
+ * @returns {string[]} the decimal-string felts, flagged as compiled
10736
+ * @example
10737
+ * ```typescript
10738
+ * const result = CairoByteArray.fromText('Hello').toApiRequest();
10739
+ * // result = ["0", "310939249775", "5"]
10740
+ * ```
10741
+ */
10458
10742
  toApiRequest(): string[];
10743
+ /**
10744
+ * Read the bytes back as UTF-8 text.
10745
+ *
10746
+ * The words are concatenated before decoding, so a multi-byte character split across two of them
10747
+ * survives. Bytes that are not valid UTF-8 come back as replacement characters rather than as an
10748
+ * error, so succeeding here does not prove the ByteArray was carrying text.
10749
+ * @returns {string} the bytes decoded as UTF-8
10750
+ * @example
10751
+ * ```typescript
10752
+ * const result = CairoByteArray.fromText('héllo').decodeUtf8();
10753
+ * // result = "héllo" (5 characters, 6 bytes)
10754
+ * const result2 = new CairoByteArray('12345').decodeUtf8();
10755
+ * // result2 = "09" (the number 12345 is the two bytes 0x30 0x39)
10756
+ * ```
10757
+ */
10459
10758
  decodeUtf8(): string;
10759
+ /**
10760
+ * The whole byte sequence read as one big-endian number.
10761
+ *
10762
+ * A number has no room for a leading zero byte, so that byte is lost here. Use
10763
+ * {@link CairoByteArray.toHexString} when the byte count matters.
10764
+ * @returns {bigint} the bytes as a number, 0n when there are none
10765
+ * @example
10766
+ * ```typescript
10767
+ * const result = CairoByteArray.fromText('Hello').toBigInt();
10768
+ * // result = 310939249775n
10769
+ * const result2 = new CairoByteArray('0x0041').toBigInt();
10770
+ * // result2 = 65n (two bytes in, one byte out - toHexString keeps both)
10771
+ * ```
10772
+ */
10460
10773
  toBigInt(): bigint;
10774
+ /**
10775
+ * The whole byte sequence in hexadecimal, leading zero bytes included.
10776
+ *
10777
+ * This is the faithful view : two hex digits per byte, whatever their value. An empty ByteArray
10778
+ * and one holding a single zero byte both read as a zero here, which is the one case this form
10779
+ * does not separate.
10780
+ * @returns {string} the bytes as a 0x-prefixed hex string, "0x0" when there are none
10781
+ * @example
10782
+ * ```typescript
10783
+ * const result = new CairoByteArray('0x0041').toHexString();
10784
+ * // result = "0x0041" (where toBigInt() gives 65n, having dropped the first byte)
10785
+ * ```
10786
+ */
10461
10787
  toHexString(): string;
10788
+ /**
10789
+ * The whole byte sequence as a Buffer, leading zero bytes included.
10790
+ * @returns {Buffer} a copy of the bytes, empty when there are none
10791
+ * @example
10792
+ * ```typescript
10793
+ * const result = CairoByteArray.fromText('Hello').toBuffer().toString('hex');
10794
+ * // result = "48656c6c6f"
10795
+ * ```
10796
+ */
10462
10797
  toBuffer(): any;
10463
10798
  /**
10464
10799
  * Compute the Pedersen hash of this ByteArray, following OpenZeppelin's `hash_byte_array` algorithm.
@@ -10477,26 +10812,96 @@ declare class CairoByteArray {
10477
10812
  */
10478
10813
  hash(): string;
10479
10814
  /**
10480
- * returns an array of all the data chunks and the pending word
10481
- * when concatenated, represents the original bytes sequence
10815
+ * The words as raw byte buffers : every complete word, then the pending one.
10816
+ *
10817
+ * Concatenating them gives the original byte sequence back. A complete word is always 31 bytes,
10818
+ * while the last buffer holds exactly `pending_word_len` bytes — zero-padded on the left when the
10819
+ * pending word is shorter than its declared length. A pending length of 0 yields no last buffer.
10820
+ * @returns {Uint8Array[]} one buffer per word, in order
10821
+ * @example
10822
+ * ```typescript
10823
+ * const text = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567';
10824
+ * const result = CairoByteArray.fromText(text).toElements().map((word) => word.length);
10825
+ * // result = [31, 2]
10826
+ * ```
10482
10827
  */
10483
10828
  toElements(): Uint8Array[];
10484
10829
  /**
10485
- * Private helper to check if the CairoByteArray is properly initialized
10830
+ * Throw unless the three components are present.
10831
+ *
10832
+ * They are declared with a definite assignment assertion, so TypeScript does not catch an
10833
+ * instance whose components were never filled, or one overwritten after construction. Every
10834
+ * method that reads them calls this first.
10835
+ * @throws {Error} when any of the three components is missing
10836
+ * @example
10837
+ * ```typescript
10838
+ * const byteArray = new CairoByteArray('test');
10839
+ * (byteArray as any).data = undefined;
10840
+ * byteArray.toApiRequest();
10841
+ * // throws Error("CairoByteArray is not properly initialized")
10842
+ * ```
10486
10843
  */
10487
10844
  private assertInitialized;
10488
- static validate(data: Uint8Array | Buffer | BigNumberish | unknown): void;
10489
10845
  /**
10490
- * Check if the provided data is a valid CairoByteArray
10846
+ * Throw unless the value is of a kind this class can carry.
10847
+ *
10848
+ * Called by the constructor, and called directly by the calldata validator before a contract
10849
+ * call — so a value refused here never reaches serialization. It weighs the kind of the value,
10850
+ * not its contents : a ByteArray object holding unusable components passes here and fails later,
10851
+ * when those components are adopted.
10852
+ * @param {Uint8Array | Buffer | BigNumberish | ByteArray} data the value to check
10853
+ * @throws {Error} when the value is of a kind this class does not carry
10854
+ * @example
10855
+ * ```typescript
10856
+ * CairoByteArray.validate('12345'); // passes, and will be read as the number 12345
10857
+ * CairoByteArray.validate(new Uint8Array(2)); // passes
10858
+ * CairoByteArray.validate(-1);
10859
+ * // throws Error("Invalid input for CairoByteArray: negative numbers are not supported")
10860
+ * ```
10861
+ */
10862
+ static validate(data: Uint8Array | Buffer | BigNumberish | ByteArray | unknown): void;
10863
+ /**
10864
+ * Can this value be carried by a CairoByteArray?
10491
10865
  *
10492
- * @param data - The data to check
10493
- * @returns True if the data is a valid CairoByteArray, false otherwise
10866
+ * The non-throwing form of {@link CairoByteArray.validate}, with the same reach : it answers on
10867
+ * the kind of the value, not on the usability of its contents.
10868
+ * @param {any} data the value to test
10869
+ * @returns {boolean} true when the value is of a kind this class can carry
10870
+ * @example
10871
+ * ```typescript
10872
+ * const result = CairoByteArray.is('12345');
10873
+ * // result = true
10874
+ * const result2 = CairoByteArray.is({ data: 'ABC' });
10875
+ * // result2 = false (an object, and not the three components of a ByteArray)
10876
+ * ```
10494
10877
  */
10495
10878
  static is(data: any): boolean;
10496
10879
  /**
10497
- * Check if provided abi type is this data type
10880
+ * Is this abi type the one this class serializes?
10881
+ * @param {string} abiType the abi type to test
10882
+ * @returns {boolean} true for `core::byte_array::ByteArray`
10883
+ * @example
10884
+ * ```typescript
10885
+ * const result = CairoByteArray.isAbiType('core::byte_array::ByteArray');
10886
+ * // result = true
10887
+ * ```
10498
10888
  */
10499
10889
  static isAbiType(abiType: string): boolean;
10890
+ /**
10891
+ * Read one ByteArray off a contract response, advancing the iterator past it.
10892
+ *
10893
+ * The felts are consumed in the order a contract emits them : how many complete words follow,
10894
+ * those words, then the pending word and its length. The iterator is left on the next value, so
10895
+ * successive calls read successive return values.
10896
+ * @param {Iterator<string>} responseIterator the response felts, positioned on this ByteArray
10897
+ * @returns {CairoByteArray} the ByteArray that was read
10898
+ * @example
10899
+ * ```typescript
10900
+ * const response = ['0', '310939249775', '5'];
10901
+ * const result = CairoByteArray.factoryFromApiResponse(response.values()).decodeUtf8();
10902
+ * // result = "Hello"
10903
+ * ```
10904
+ */
10500
10905
  static factoryFromApiResponse(responseIterator: Iterator<string>): CairoByteArray;
10501
10906
  }
10502
10907