starknet 11.0.1 → 11.0.2
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 +6 -0
- package/dist/index.d.ts +315 -112
- package/dist/index.global.js +289 -110
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +289 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -615,6 +615,21 @@ declare const BlockTag: {
|
|
|
615
615
|
type WeierstrassSignatureType = weierstrass.ECDSASignature;
|
|
616
616
|
type ArraySignatureType = string[];
|
|
617
617
|
type Signature = ArraySignatureType | WeierstrassSignatureType;
|
|
618
|
+
/**
|
|
619
|
+
* A number, in any of the three forms JavaScript carries one : a `number`, a `bigint`, or a
|
|
620
|
+
* `string` spelling it in decimal or in `0x` hexadecimal.
|
|
621
|
+
*
|
|
622
|
+
* The type itself accepts any string ; `num.isBigNumberish` is the check made at runtime. A number
|
|
623
|
+
* or a bigint may be negative, whereas a string is unsigned : `'-1'` is text to the library, except
|
|
624
|
+
* for the signed integer types `i8` to `i128`, which read it as -1.
|
|
625
|
+
* @example
|
|
626
|
+
* ```typescript
|
|
627
|
+
* const decimals: BigNumberish = 18;
|
|
628
|
+
* const amount: BigNumberish = 10n ** 18n;
|
|
629
|
+
* // the selector of balanceOf
|
|
630
|
+
* const selector: BigNumberish = '0x2e4263afad30923c891518314c3c95dbe830a16874e8abc5777a9a20b54c76e';
|
|
631
|
+
* ```
|
|
632
|
+
*/
|
|
618
633
|
type BigNumberish = string | number | bigint;
|
|
619
634
|
type ByteArray = {
|
|
620
635
|
data: BigNumberish[];
|
|
@@ -4167,7 +4182,7 @@ declare class CairoBool {
|
|
|
4167
4182
|
/**
|
|
4168
4183
|
* Build from a boolean, or from the numbers 0 and 1.
|
|
4169
4184
|
* @param {BigNumberish | boolean} data the value to carry : a boolean, 0 or 1
|
|
4170
|
-
* @throws {Error} when the value is text,
|
|
4185
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or a number other than 0 or 1
|
|
4171
4186
|
* @example
|
|
4172
4187
|
* ```typescript
|
|
4173
4188
|
* const result = new CairoBool(false).toApiRequest();
|
|
@@ -4226,16 +4241,19 @@ declare class CairoBool {
|
|
|
4226
4241
|
/**
|
|
4227
4242
|
* Throw unless the value can be carried by a bool.
|
|
4228
4243
|
*
|
|
4229
|
-
* Text is refused first, then
|
|
4230
|
-
*
|
|
4231
|
-
*
|
|
4244
|
+
* Text is refused first, then a number with a decimal part. A number or a bigint is read as it
|
|
4245
|
+
* is, so that a negative one reaches the last check. Anything else is read as a felt252 — which
|
|
4246
|
+
* is what refuses a null, an object or an unsupported type. The value is finally checked to be
|
|
4247
|
+
* one of the only two numbers a bool can hold.
|
|
4232
4248
|
* @param {BigNumberish | boolean} data the value to check
|
|
4233
|
-
* @throws {Error} when the value is text,
|
|
4249
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or a number other than 0 or 1
|
|
4234
4250
|
* @example
|
|
4235
4251
|
* ```typescript
|
|
4236
4252
|
* CairoBool.validate(true); // passes
|
|
4237
4253
|
* CairoBool.validate(2);
|
|
4238
4254
|
* // throws Error("Only values 0 or 1 are possible in a core::bool, received 2")
|
|
4255
|
+
* CairoBool.validate(-1);
|
|
4256
|
+
* // throws Error("Only values 0 or 1 are possible in a core::bool, received -1")
|
|
4239
4257
|
* ```
|
|
4240
4258
|
*/
|
|
4241
4259
|
static validate(data: BigNumberish | boolean | unknown): void;
|
|
@@ -4378,7 +4396,7 @@ declare class CairoUint512 {
|
|
|
4378
4396
|
* A `Uint512` object is accepted here too : it already carries the four limbs, and each is
|
|
4379
4397
|
* checked as a u128 rather than the whole being cut again.
|
|
4380
4398
|
* @param {BigNumberish | Uint512} bigNumberish the value to carry, within [0, 2^512 - 1]
|
|
4381
|
-
* @throws {Error} when the value is null, undefined, of an unread type, or out of range
|
|
4399
|
+
* @throws {Error} when the value is null, undefined, text, `'0x'`, of an unread type, a decimal number, or out of range
|
|
4382
4400
|
* @example
|
|
4383
4401
|
* ```typescript
|
|
4384
4402
|
* const result = new CairoUint512(255).toApiRequest();
|
|
@@ -4392,7 +4410,7 @@ declare class CairoUint512 {
|
|
|
4392
4410
|
* @param {BigNumberish} limb1 bits 128 to 255
|
|
4393
4411
|
* @param {BigNumberish} limb2 bits 256 to 383
|
|
4394
4412
|
* @param {BigNumberish} limb3 bits 384 to 511
|
|
4395
|
-
* @throws {Error} when any limb is
|
|
4413
|
+
* @throws {Error} when any limb is null, undefined, text, `'0x'`, not a number, a decimal number, or outside the u128 range
|
|
4396
4414
|
* @example
|
|
4397
4415
|
* ```typescript
|
|
4398
4416
|
* const result = new CairoUint512(7, 0, 0, 64).toBigInt() === 2n ** 390n + 7n;
|
|
@@ -4404,16 +4422,22 @@ declare class CairoUint512 {
|
|
|
4404
4422
|
* Throw unless a whole value can be represented as a u512, and give back its number.
|
|
4405
4423
|
*
|
|
4406
4424
|
* A string is only accepted while it spells a number, in base 10 or 16 : one that does not is
|
|
4407
|
-
* refused
|
|
4425
|
+
* refused as text, and `'0x'`, which holds no digit, is refused too. So is an object, a `Uint512`
|
|
4426
|
+
* one included : its four limbs are checked by {@link CairoUint512.validateProps}, which is what
|
|
4427
|
+
* the constructor calls for it.
|
|
4408
4428
|
* @param {BigNumberish} bigNumberish the value to check
|
|
4409
4429
|
* @returns {bigint} the value as a number, once accepted
|
|
4410
|
-
* @throws {Error} when the value is null, undefined, of an unread type, or out of range
|
|
4430
|
+
* @throws {Error} when the value is null, undefined, text, `'0x'`, of an unread type, a decimal number, or out of range
|
|
4411
4431
|
* @example
|
|
4412
4432
|
* ```typescript
|
|
4413
4433
|
* const result = CairoUint512.validate(255);
|
|
4414
4434
|
* // result = 255n
|
|
4415
4435
|
* CairoUint512.validate(-1);
|
|
4416
4436
|
* // throws Error("bigNumberish is smaller than UINT_512_MIN.")
|
|
4437
|
+
* CairoUint512.validate('abc');
|
|
4438
|
+
* // throws Error("Invalid input: a u512 cannot be built from text")
|
|
4439
|
+
* CairoUint512.validate(1.5);
|
|
4440
|
+
* // throws Error("Invalid input: decimal numbers are not supported, only integers")
|
|
4417
4441
|
* ```
|
|
4418
4442
|
*/
|
|
4419
4443
|
static validate(bigNumberish: BigNumberish | unknown): bigint;
|
|
@@ -4427,13 +4451,17 @@ declare class CairoUint512 {
|
|
|
4427
4451
|
* @param {BigNumberish} limb2 bits 256 to 383
|
|
4428
4452
|
* @param {BigNumberish} limb3 bits 384 to 511
|
|
4429
4453
|
* @returns {{limb0: bigint, limb1: bigint, limb2: bigint, limb3: bigint}} the four limbs as numbers
|
|
4430
|
-
* @throws {Error} when any limb is outside the u128 range
|
|
4454
|
+
* @throws {Error} when any limb is null, undefined, text, `'0x'`, not a number, a decimal number, or outside the u128 range
|
|
4431
4455
|
* @example
|
|
4432
4456
|
* ```typescript
|
|
4433
4457
|
* const result = CairoUint512.validateProps(7, 0, 0, 64);
|
|
4434
4458
|
* // result = { limb0: 7n, limb1: 0n, limb2: 0n, limb3: 64n }
|
|
4435
4459
|
* CairoUint512.validateProps(-1, 0, 0, 0);
|
|
4436
4460
|
* // throws Error("limb0 is not in the range of a u128 number")
|
|
4461
|
+
* CairoUint512.validateProps(1.5, 0, 0, 0);
|
|
4462
|
+
* // throws Error("limb0 must be an integer")
|
|
4463
|
+
* CairoUint512.validateProps('abc', 0, 0, 0);
|
|
4464
|
+
* // throws Error("limb0 cannot be built from text")
|
|
4437
4465
|
* ```
|
|
4438
4466
|
*/
|
|
4439
4467
|
static validateProps(limb0: BigNumberish, limb1: BigNumberish, limb2: BigNumberish, limb3: BigNumberish): {
|
|
@@ -4582,7 +4610,7 @@ declare class CairoUint8 {
|
|
|
4582
4610
|
* otherwise. Text therefore only fits here while it is a single ASCII character : two characters
|
|
4583
4611
|
* already make a number past 255.
|
|
4584
4612
|
* @param {BigNumberish | boolean} data the value to carry, within [0, 255]
|
|
4585
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
4613
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
4586
4614
|
* @example
|
|
4587
4615
|
* ```typescript
|
|
4588
4616
|
* const result = new CairoUint8('a').toApiRequest();
|
|
@@ -4656,11 +4684,11 @@ declare class CairoUint8 {
|
|
|
4656
4684
|
/**
|
|
4657
4685
|
* Throw unless the value can be carried by a u8.
|
|
4658
4686
|
*
|
|
4659
|
-
*
|
|
4660
|
-
* an array, a number with a decimal part, and a value outside [0, 255]. A text string reaches
|
|
4687
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
4688
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [0, 255]. A text string reaches
|
|
4661
4689
|
* that last check as the number its bytes spell, so `'ab'` is refused for being out of range.
|
|
4662
4690
|
* @param {BigNumberish | boolean} data the value to check
|
|
4663
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
4691
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
4664
4692
|
* @example
|
|
4665
4693
|
* ```typescript
|
|
4666
4694
|
* CairoUint8.validate(44); // passes
|
|
@@ -4760,7 +4788,7 @@ declare class CairoUint16 {
|
|
|
4760
4788
|
* otherwise. Text therefore only fits here up to 2 ASCII characters : one more already
|
|
4761
4789
|
* makes a number past 65535.
|
|
4762
4790
|
* @param {BigNumberish | boolean} data the value to carry, within [0, 65535]
|
|
4763
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
4791
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
4764
4792
|
* @example
|
|
4765
4793
|
* ```typescript
|
|
4766
4794
|
* const result = new CairoUint16('ab').toApiRequest();
|
|
@@ -4832,11 +4860,11 @@ declare class CairoUint16 {
|
|
|
4832
4860
|
/**
|
|
4833
4861
|
* Throw unless the value can be carried by a u16.
|
|
4834
4862
|
*
|
|
4835
|
-
*
|
|
4836
|
-
* an array, a number with a decimal part, and a value outside [0, 65535]. A text string reaches
|
|
4863
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
4864
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [0, 65535]. A text string reaches
|
|
4837
4865
|
* that last check as the number its bytes spell, so `'abc'` is refused for being out of range.
|
|
4838
4866
|
* @param {BigNumberish | boolean} data the value to check
|
|
4839
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
4867
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
4840
4868
|
* @example
|
|
4841
4869
|
* ```typescript
|
|
4842
4870
|
* CairoUint16.validate(300); // passes
|
|
@@ -4936,7 +4964,7 @@ declare class CairoUint32 {
|
|
|
4936
4964
|
* otherwise. Text therefore only fits here up to 4 ASCII characters : one more already
|
|
4937
4965
|
* makes a number past 4294967295.
|
|
4938
4966
|
* @param {BigNumberish | boolean} data the value to carry, within [0, 4294967295]
|
|
4939
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
4967
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
4940
4968
|
* @example
|
|
4941
4969
|
* ```typescript
|
|
4942
4970
|
* const result = new CairoUint32('abcd').toApiRequest();
|
|
@@ -5008,11 +5036,11 @@ declare class CairoUint32 {
|
|
|
5008
5036
|
/**
|
|
5009
5037
|
* Throw unless the value can be carried by a u32.
|
|
5010
5038
|
*
|
|
5011
|
-
*
|
|
5012
|
-
* an array, a number with a decimal part, and a value outside [0, 4294967295]. A text string reaches
|
|
5039
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
5040
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [0, 4294967295]. A text string reaches
|
|
5013
5041
|
* that last check as the number its bytes spell, so `'abcde'` is refused for being out of range.
|
|
5014
5042
|
* @param {BigNumberish | boolean} data the value to check
|
|
5015
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5043
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5016
5044
|
* @example
|
|
5017
5045
|
* ```typescript
|
|
5018
5046
|
* CairoUint32.validate(70000); // passes
|
|
@@ -5112,7 +5140,7 @@ declare class CairoUint64 {
|
|
|
5112
5140
|
* otherwise. Text therefore only fits here up to 8 ASCII characters : one more already
|
|
5113
5141
|
* makes a number past 18446744073709551615.
|
|
5114
5142
|
* @param {BigNumberish | boolean} data the value to carry, within [0, 18446744073709551615]
|
|
5115
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5143
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5116
5144
|
* @example
|
|
5117
5145
|
* ```typescript
|
|
5118
5146
|
* const result = new CairoUint64('abcdefgh').toApiRequest();
|
|
@@ -5184,11 +5212,11 @@ declare class CairoUint64 {
|
|
|
5184
5212
|
/**
|
|
5185
5213
|
* Throw unless the value can be carried by a u64.
|
|
5186
5214
|
*
|
|
5187
|
-
*
|
|
5188
|
-
* an array, a number with a decimal part, and a value outside [0, 18446744073709551615]. A text string reaches
|
|
5215
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
5216
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [0, 18446744073709551615]. A text string reaches
|
|
5189
5217
|
* that last check as the number its bytes spell, so `'abcdefghi'` is refused for being out of range.
|
|
5190
5218
|
* @param {BigNumberish | boolean} data the value to check
|
|
5191
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5219
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5192
5220
|
* @example
|
|
5193
5221
|
* ```typescript
|
|
5194
5222
|
* CairoUint64.validate(5000000000); // passes
|
|
@@ -5301,7 +5329,7 @@ declare class CairoUint96 {
|
|
|
5301
5329
|
* otherwise. Text therefore only fits here up to 12 ASCII characters : one more already
|
|
5302
5330
|
* makes a number past 79228162514264337593543950335.
|
|
5303
5331
|
* @param {BigNumberish | boolean} data the value to carry, within [0, 79228162514264337593543950335]
|
|
5304
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5332
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5305
5333
|
* @example
|
|
5306
5334
|
* ```typescript
|
|
5307
5335
|
* const result = new CairoUint96('abcdefghijkl').toApiRequest();
|
|
@@ -5373,11 +5401,11 @@ declare class CairoUint96 {
|
|
|
5373
5401
|
/**
|
|
5374
5402
|
* Throw unless the value can be carried by a u96.
|
|
5375
5403
|
*
|
|
5376
|
-
*
|
|
5377
|
-
* an array, a number with a decimal part, and a value outside [0, 79228162514264337593543950335]. A text string reaches
|
|
5404
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
5405
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [0, 79228162514264337593543950335]. A text string reaches
|
|
5378
5406
|
* that last check as the number its bytes spell, so `'abcdefghijklm'` is refused for being out of range.
|
|
5379
5407
|
* @param {BigNumberish | boolean} data the value to check
|
|
5380
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5408
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5381
5409
|
* @example
|
|
5382
5410
|
* ```typescript
|
|
5383
5411
|
* CairoUint96.validate(5000000000); // passes
|
|
@@ -5484,7 +5512,7 @@ declare class CairoUint128 {
|
|
|
5484
5512
|
* otherwise. Text therefore only fits here up to 16 ASCII characters : one more already
|
|
5485
5513
|
* makes a number past 340282366920938463463374607431768211455.
|
|
5486
5514
|
* @param {BigNumberish | boolean} data the value to carry, within [0, 340282366920938463463374607431768211455]
|
|
5487
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5515
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5488
5516
|
* @example
|
|
5489
5517
|
* ```typescript
|
|
5490
5518
|
* const result = new CairoUint128('abcdefghijklmnop').toApiRequest();
|
|
@@ -5556,11 +5584,11 @@ declare class CairoUint128 {
|
|
|
5556
5584
|
/**
|
|
5557
5585
|
* Throw unless the value can be carried by a u128.
|
|
5558
5586
|
*
|
|
5559
|
-
*
|
|
5560
|
-
* an array, a number with a decimal part, and a value outside [0, 340282366920938463463374607431768211455]. A text string reaches
|
|
5587
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
5588
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [0, 340282366920938463463374607431768211455]. A text string reaches
|
|
5561
5589
|
* that last check as the number its bytes spell, so `'abcdefghijklmnopq'` is refused for being out of range.
|
|
5562
5590
|
* @param {BigNumberish | boolean} data the value to check
|
|
5563
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5591
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5564
5592
|
* @example
|
|
5565
5593
|
* ```typescript
|
|
5566
5594
|
* CairoUint128.validate(5000000000); // passes
|
|
@@ -5622,6 +5650,10 @@ declare class CairoUint128 {
|
|
|
5622
5650
|
* `'97'` and `'0x61'` give the same i8. A string that reads as text rather than as a
|
|
5623
5651
|
* number is taken for its UTF-8 bytes, which is why `'a'` is 97 and not a rejected input.
|
|
5624
5652
|
*
|
|
5653
|
+
* A minus sign in front of a number is read as a sign, not as text : `'-5'` is -5, as `-5` and
|
|
5654
|
+
* `-5n` are. Only the signed integers read a string this way — for every other type, `'-5'` is
|
|
5655
|
+
* text, encoded or refused as such.
|
|
5656
|
+
*
|
|
5625
5657
|
* An already built instance is **not** an accepted input : handed back to the constructor it is
|
|
5626
5658
|
* seen as an object and refused. Inside the library it is `unwrapCairoScalar` that reduces an
|
|
5627
5659
|
* instance to its number before an abi slot receives it.
|
|
@@ -5632,6 +5664,11 @@ declare class CairoUint128 {
|
|
|
5632
5664
|
* new CairoInt8('97').toBigInt(); // 97n
|
|
5633
5665
|
* new CairoInt8('0x61').toBigInt(); // 97n
|
|
5634
5666
|
* new CairoInt8('a').toBigInt(); // 97n the UTF-8 bytes of the text
|
|
5667
|
+
*
|
|
5668
|
+
* // a negative value, reached three ways
|
|
5669
|
+
* new CairoInt8(-5).toBigInt(); // -5n
|
|
5670
|
+
* new CairoInt8('-5').toBigInt(); // -5n
|
|
5671
|
+
* new CairoInt8('-0x5').toBigInt(); // -5n a sign, not the text "-0x5"
|
|
5635
5672
|
* ```
|
|
5636
5673
|
*/
|
|
5637
5674
|
declare class CairoInt8 {
|
|
@@ -5656,15 +5693,17 @@ declare class CairoInt8 {
|
|
|
5656
5693
|
/**
|
|
5657
5694
|
* Build from a number, a string or a boolean, refusing anything out of the i8 range.
|
|
5658
5695
|
*
|
|
5659
|
-
* A string is read as a number when it spells one — decimal or hexadecimal
|
|
5660
|
-
* otherwise. Text therefore only fits here up to a single
|
|
5661
|
-
* makes a number past 127.
|
|
5696
|
+
* A string is read as a number when it spells one — decimal or hexadecimal, with or without a
|
|
5697
|
+
* leading minus sign — and as UTF-8 text otherwise. Text therefore only fits here up to a single
|
|
5698
|
+
* ASCII character : one more already makes a number past 127.
|
|
5662
5699
|
* @param {BigNumberish | boolean} data the value to carry, within [-128, 127]
|
|
5663
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5700
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5664
5701
|
* @example
|
|
5665
5702
|
* ```typescript
|
|
5666
5703
|
* const result = new CairoInt8('a').toApiRequest();
|
|
5667
5704
|
* // result = ["97"]
|
|
5705
|
+
* const result2 = new CairoInt8('-5').toApiRequest();
|
|
5706
|
+
* // result2 = ["3618502788666131213697322783095070105623107215331596699973092056135872020476"]
|
|
5668
5707
|
* ```
|
|
5669
5708
|
*/
|
|
5670
5709
|
constructor(data: BigNumberish | boolean | unknown);
|
|
@@ -5673,6 +5712,9 @@ declare class CairoInt8 {
|
|
|
5673
5712
|
*
|
|
5674
5713
|
* Nothing here refuses a value : `validate` is what reads this number and decides. So an input
|
|
5675
5714
|
* far outside the i8 range comes back untouched rather than raising.
|
|
5715
|
+
*
|
|
5716
|
+
* A minus sign in front of a number makes it negative rather than text : `'-5'` and `'-0x5'` are
|
|
5717
|
+
* both -5. This holds for the signed integers only — for any other type, such a string is text.
|
|
5676
5718
|
* @param {BigNumberish | boolean} data the value to convert
|
|
5677
5719
|
* @returns {bigint} the number the input spells, of whatever size
|
|
5678
5720
|
* @example
|
|
@@ -5681,6 +5723,8 @@ declare class CairoInt8 {
|
|
|
5681
5723
|
* // result = 97n
|
|
5682
5724
|
* const result2 = CairoInt8.__processData('ab');
|
|
5683
5725
|
* // result2 = 24930n (past the i8 range, and returned all the same)
|
|
5726
|
+
* const result3 = CairoInt8.__processData('-0x5');
|
|
5727
|
+
* // result3 = -5n (a negative number, not the text "-0x5")
|
|
5684
5728
|
* ```
|
|
5685
5729
|
*/
|
|
5686
5730
|
static __processData(data: BigNumberish | boolean | unknown): bigint;
|
|
@@ -5742,11 +5786,12 @@ declare class CairoInt8 {
|
|
|
5742
5786
|
/**
|
|
5743
5787
|
* Throw unless the value can be carried by an i8.
|
|
5744
5788
|
*
|
|
5745
|
-
*
|
|
5746
|
-
* an array, a number with a decimal part, and a value outside [-128, 127]. A text string
|
|
5747
|
-
* that last check as the number its bytes spell, so `'ab'` is refused for being out of
|
|
5789
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
5790
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [-128, 127]. A text string
|
|
5791
|
+
* reaches that last check as the number its bytes spell, so `'ab'` is refused for being out of
|
|
5792
|
+
* range.
|
|
5748
5793
|
* @param {BigNumberish | boolean} data the value to check
|
|
5749
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5794
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5750
5795
|
* @example
|
|
5751
5796
|
* ```typescript
|
|
5752
5797
|
* CairoInt8.validate(5); // passes
|
|
@@ -5809,6 +5854,10 @@ declare class CairoInt8 {
|
|
|
5809
5854
|
* `'24930'` and `'0x6162'` give the same i16. A string that reads as text rather than as a
|
|
5810
5855
|
* number is taken for its UTF-8 bytes, which is why `'ab'` is 24930 and not a rejected input.
|
|
5811
5856
|
*
|
|
5857
|
+
* A minus sign in front of a number is read as a sign, not as text : `'-5'` is -5, as `-5` and
|
|
5858
|
+
* `-5n` are. Only the signed integers read a string this way — for every other type, `'-5'` is
|
|
5859
|
+
* text, encoded or refused as such.
|
|
5860
|
+
*
|
|
5812
5861
|
* An already built instance is **not** an accepted input : handed back to the constructor it is
|
|
5813
5862
|
* seen as an object and refused. Inside the library it is `unwrapCairoScalar` that reduces an
|
|
5814
5863
|
* instance to its number before an abi slot receives it.
|
|
@@ -5819,6 +5868,11 @@ declare class CairoInt8 {
|
|
|
5819
5868
|
* new CairoInt16('24930').toBigInt(); // 24930n
|
|
5820
5869
|
* new CairoInt16('0x6162').toBigInt(); // 24930n
|
|
5821
5870
|
* new CairoInt16('ab').toBigInt(); // 24930n the UTF-8 bytes of the text
|
|
5871
|
+
*
|
|
5872
|
+
* // a negative value, reached three ways
|
|
5873
|
+
* new CairoInt16(-5).toBigInt(); // -5n
|
|
5874
|
+
* new CairoInt16('-5').toBigInt(); // -5n
|
|
5875
|
+
* new CairoInt16('-0x5').toBigInt(); // -5n a sign, not the text "-0x5"
|
|
5822
5876
|
* ```
|
|
5823
5877
|
*/
|
|
5824
5878
|
declare class CairoInt16 {
|
|
@@ -5843,15 +5897,17 @@ declare class CairoInt16 {
|
|
|
5843
5897
|
/**
|
|
5844
5898
|
* Build from a number, a string or a boolean, refusing anything out of the i16 range.
|
|
5845
5899
|
*
|
|
5846
|
-
* A string is read as a number when it spells one — decimal or hexadecimal
|
|
5847
|
-
* otherwise. Text therefore only fits here up to 2 ASCII
|
|
5848
|
-
* makes a number past 32767.
|
|
5900
|
+
* A string is read as a number when it spells one — decimal or hexadecimal, with or without a
|
|
5901
|
+
* leading minus sign — and as UTF-8 text otherwise. Text therefore only fits here up to 2 ASCII
|
|
5902
|
+
* characters : one more already makes a number past 32767.
|
|
5849
5903
|
* @param {BigNumberish | boolean} data the value to carry, within [-32768, 32767]
|
|
5850
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5904
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5851
5905
|
* @example
|
|
5852
5906
|
* ```typescript
|
|
5853
5907
|
* const result = new CairoInt16('ab').toApiRequest();
|
|
5854
5908
|
* // result = ["24930"]
|
|
5909
|
+
* const result2 = new CairoInt16('-5').toApiRequest();
|
|
5910
|
+
* // result2 = ["3618502788666131213697322783095070105623107215331596699973092056135872020476"]
|
|
5855
5911
|
* ```
|
|
5856
5912
|
*/
|
|
5857
5913
|
constructor(data: BigNumberish | boolean | unknown);
|
|
@@ -5860,6 +5916,9 @@ declare class CairoInt16 {
|
|
|
5860
5916
|
*
|
|
5861
5917
|
* Nothing here refuses a value : `validate` is what reads this number and decides. So an input
|
|
5862
5918
|
* far outside the i16 range comes back untouched rather than raising.
|
|
5919
|
+
*
|
|
5920
|
+
* A minus sign in front of a number makes it negative rather than text : `'-5'` and `'-0x5'` are
|
|
5921
|
+
* both -5. This holds for the signed integers only — for any other type, such a string is text.
|
|
5863
5922
|
* @param {BigNumberish | boolean} data the value to convert
|
|
5864
5923
|
* @returns {bigint} the number the input spells, of whatever size
|
|
5865
5924
|
* @example
|
|
@@ -5868,6 +5927,8 @@ declare class CairoInt16 {
|
|
|
5868
5927
|
* // result = 24930n
|
|
5869
5928
|
* const result2 = CairoInt16.__processData('abc');
|
|
5870
5929
|
* // result2 = 6382179n (past the i16 range, and returned all the same)
|
|
5930
|
+
* const result3 = CairoInt16.__processData('-0x5');
|
|
5931
|
+
* // result3 = -5n (a negative number, not the text "-0x5")
|
|
5871
5932
|
* ```
|
|
5872
5933
|
*/
|
|
5873
5934
|
static __processData(data: BigNumberish | boolean | unknown): bigint;
|
|
@@ -5929,11 +5990,11 @@ declare class CairoInt16 {
|
|
|
5929
5990
|
/**
|
|
5930
5991
|
* Throw unless the value can be carried by an i16.
|
|
5931
5992
|
*
|
|
5932
|
-
*
|
|
5933
|
-
* an array, a number with a decimal part, and a value outside [-32768, 32767]. A text string reaches
|
|
5993
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
5994
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [-32768, 32767]. A text string reaches
|
|
5934
5995
|
* that last check as the number its bytes spell, so `'abc'` is refused for being out of range.
|
|
5935
5996
|
* @param {BigNumberish | boolean} data the value to check
|
|
5936
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
5997
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
5937
5998
|
* @example
|
|
5938
5999
|
* ```typescript
|
|
5939
6000
|
* CairoInt16.validate(300); // passes
|
|
@@ -5996,6 +6057,10 @@ declare class CairoInt16 {
|
|
|
5996
6057
|
* `'1633837924'` and `'0x61626364'` give the same i32. A string that reads as text rather than as a
|
|
5997
6058
|
* number is taken for its UTF-8 bytes, which is why `'abcd'` is 1633837924 and not a rejected input.
|
|
5998
6059
|
*
|
|
6060
|
+
* A minus sign in front of a number is read as a sign, not as text : `'-5'` is -5, as `-5` and
|
|
6061
|
+
* `-5n` are. Only the signed integers read a string this way — for every other type, `'-5'` is
|
|
6062
|
+
* text, encoded or refused as such.
|
|
6063
|
+
*
|
|
5999
6064
|
* An already built instance is **not** an accepted input : handed back to the constructor it is
|
|
6000
6065
|
* seen as an object and refused. Inside the library it is `unwrapCairoScalar` that reduces an
|
|
6001
6066
|
* instance to its number before an abi slot receives it.
|
|
@@ -6006,6 +6071,11 @@ declare class CairoInt16 {
|
|
|
6006
6071
|
* new CairoInt32('1633837924').toBigInt(); // 1633837924n
|
|
6007
6072
|
* new CairoInt32('0x61626364').toBigInt(); // 1633837924n
|
|
6008
6073
|
* new CairoInt32('abcd').toBigInt(); // 1633837924n the UTF-8 bytes of the text
|
|
6074
|
+
*
|
|
6075
|
+
* // a negative value, reached three ways
|
|
6076
|
+
* new CairoInt32(-5).toBigInt(); // -5n
|
|
6077
|
+
* new CairoInt32('-5').toBigInt(); // -5n
|
|
6078
|
+
* new CairoInt32('-0x5').toBigInt(); // -5n a sign, not the text "-0x5"
|
|
6009
6079
|
* ```
|
|
6010
6080
|
*/
|
|
6011
6081
|
declare class CairoInt32 {
|
|
@@ -6030,15 +6100,17 @@ declare class CairoInt32 {
|
|
|
6030
6100
|
/**
|
|
6031
6101
|
* Build from a number, a string or a boolean, refusing anything out of the i32 range.
|
|
6032
6102
|
*
|
|
6033
|
-
* A string is read as a number when it spells one — decimal or hexadecimal
|
|
6034
|
-
* otherwise. Text therefore only fits here up to 4 ASCII
|
|
6035
|
-
* makes a number past 2147483647.
|
|
6103
|
+
* A string is read as a number when it spells one — decimal or hexadecimal, with or without a
|
|
6104
|
+
* leading minus sign — and as UTF-8 text otherwise. Text therefore only fits here up to 4 ASCII
|
|
6105
|
+
* characters : one more already makes a number past 2147483647.
|
|
6036
6106
|
* @param {BigNumberish | boolean} data the value to carry, within [-2147483648, 2147483647]
|
|
6037
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
6107
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
6038
6108
|
* @example
|
|
6039
6109
|
* ```typescript
|
|
6040
6110
|
* const result = new CairoInt32('abcd').toApiRequest();
|
|
6041
6111
|
* // result = ["1633837924"]
|
|
6112
|
+
* const result2 = new CairoInt32('-5').toApiRequest();
|
|
6113
|
+
* // result2 = ["3618502788666131213697322783095070105623107215331596699973092056135872020476"]
|
|
6042
6114
|
* ```
|
|
6043
6115
|
*/
|
|
6044
6116
|
constructor(data: BigNumberish | boolean | unknown);
|
|
@@ -6047,6 +6119,9 @@ declare class CairoInt32 {
|
|
|
6047
6119
|
*
|
|
6048
6120
|
* Nothing here refuses a value : `validate` is what reads this number and decides. So an input
|
|
6049
6121
|
* far outside the i32 range comes back untouched rather than raising.
|
|
6122
|
+
*
|
|
6123
|
+
* A minus sign in front of a number makes it negative rather than text : `'-5'` and `'-0x5'` are
|
|
6124
|
+
* both -5. This holds for the signed integers only — for any other type, such a string is text.
|
|
6050
6125
|
* @param {BigNumberish | boolean} data the value to convert
|
|
6051
6126
|
* @returns {bigint} the number the input spells, of whatever size
|
|
6052
6127
|
* @example
|
|
@@ -6055,6 +6130,8 @@ declare class CairoInt32 {
|
|
|
6055
6130
|
* // result = 1633837924n
|
|
6056
6131
|
* const result2 = CairoInt32.__processData('abcde');
|
|
6057
6132
|
* // result2 = 418262508645n (past the i32 range, and returned all the same)
|
|
6133
|
+
* const result3 = CairoInt32.__processData('-0x5');
|
|
6134
|
+
* // result3 = -5n (a negative number, not the text "-0x5")
|
|
6058
6135
|
* ```
|
|
6059
6136
|
*/
|
|
6060
6137
|
static __processData(data: BigNumberish | boolean | unknown): bigint;
|
|
@@ -6116,11 +6193,11 @@ declare class CairoInt32 {
|
|
|
6116
6193
|
/**
|
|
6117
6194
|
* Throw unless the value can be carried by an i32.
|
|
6118
6195
|
*
|
|
6119
|
-
*
|
|
6120
|
-
* an array, a number with a decimal part, and a value outside [-2147483648, 2147483647]. A text string reaches
|
|
6196
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
6197
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [-2147483648, 2147483647]. A text string reaches
|
|
6121
6198
|
* that last check as the number its bytes spell, so `'abcde'` is refused for being out of range.
|
|
6122
6199
|
* @param {BigNumberish | boolean} data the value to check
|
|
6123
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
6200
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
6124
6201
|
* @example
|
|
6125
6202
|
* ```typescript
|
|
6126
6203
|
* CairoInt32.validate(70000); // passes
|
|
@@ -6183,6 +6260,10 @@ declare class CairoInt32 {
|
|
|
6183
6260
|
* `'7017280452245743464'` and `'0x6162636465666768'` give the same i64. A string that reads as text rather than as a
|
|
6184
6261
|
* number is taken for its UTF-8 bytes, which is why `'abcdefgh'` is 7017280452245743464 and not a rejected input.
|
|
6185
6262
|
*
|
|
6263
|
+
* A minus sign in front of a number is read as a sign, not as text : `'-5'` is -5, as `-5` and
|
|
6264
|
+
* `-5n` are. Only the signed integers read a string this way — for every other type, `'-5'` is
|
|
6265
|
+
* text, encoded or refused as such.
|
|
6266
|
+
*
|
|
6186
6267
|
* An already built instance is **not** an accepted input : handed back to the constructor it is
|
|
6187
6268
|
* seen as an object and refused. Inside the library it is `unwrapCairoScalar` that reduces an
|
|
6188
6269
|
* instance to its number before an abi slot receives it.
|
|
@@ -6193,6 +6274,11 @@ declare class CairoInt32 {
|
|
|
6193
6274
|
* new CairoInt64('7017280452245743464').toBigInt(); // 7017280452245743464n
|
|
6194
6275
|
* new CairoInt64('0x6162636465666768').toBigInt(); // 7017280452245743464n
|
|
6195
6276
|
* new CairoInt64('abcdefgh').toBigInt(); // 7017280452245743464n the UTF-8 bytes of the text
|
|
6277
|
+
*
|
|
6278
|
+
* // a negative value, reached three ways
|
|
6279
|
+
* new CairoInt64(-5).toBigInt(); // -5n
|
|
6280
|
+
* new CairoInt64('-5').toBigInt(); // -5n
|
|
6281
|
+
* new CairoInt64('-0x5').toBigInt(); // -5n a sign, not the text "-0x5"
|
|
6196
6282
|
* ```
|
|
6197
6283
|
*/
|
|
6198
6284
|
declare class CairoInt64 {
|
|
@@ -6217,15 +6303,17 @@ declare class CairoInt64 {
|
|
|
6217
6303
|
/**
|
|
6218
6304
|
* Build from a number, a string or a boolean, refusing anything out of the i64 range.
|
|
6219
6305
|
*
|
|
6220
|
-
* A string is read as a number when it spells one — decimal or hexadecimal
|
|
6221
|
-
* otherwise. Text therefore only fits here up to 8 ASCII
|
|
6222
|
-
* makes a number past 9223372036854775807.
|
|
6306
|
+
* A string is read as a number when it spells one — decimal or hexadecimal, with or without a
|
|
6307
|
+
* leading minus sign — and as UTF-8 text otherwise. Text therefore only fits here up to 8 ASCII
|
|
6308
|
+
* characters : one more already makes a number past 9223372036854775807.
|
|
6223
6309
|
* @param {BigNumberish | boolean} data the value to carry, within [-9223372036854775808, 9223372036854775807]
|
|
6224
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
6310
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
6225
6311
|
* @example
|
|
6226
6312
|
* ```typescript
|
|
6227
6313
|
* const result = new CairoInt64('abcdefgh').toApiRequest();
|
|
6228
6314
|
* // result = ["7017280452245743464"]
|
|
6315
|
+
* const result2 = new CairoInt64('-5').toApiRequest();
|
|
6316
|
+
* // result2 = ["3618502788666131213697322783095070105623107215331596699973092056135872020476"]
|
|
6229
6317
|
* ```
|
|
6230
6318
|
*/
|
|
6231
6319
|
constructor(data: BigNumberish | boolean | unknown);
|
|
@@ -6234,6 +6322,9 @@ declare class CairoInt64 {
|
|
|
6234
6322
|
*
|
|
6235
6323
|
* Nothing here refuses a value : `validate` is what reads this number and decides. So an input
|
|
6236
6324
|
* far outside the i64 range comes back untouched rather than raising.
|
|
6325
|
+
*
|
|
6326
|
+
* A minus sign in front of a number makes it negative rather than text : `'-5'` and `'-0x5'` are
|
|
6327
|
+
* both -5. This holds for the signed integers only — for any other type, such a string is text.
|
|
6237
6328
|
* @param {BigNumberish | boolean} data the value to convert
|
|
6238
6329
|
* @returns {bigint} the number the input spells, of whatever size
|
|
6239
6330
|
* @example
|
|
@@ -6242,6 +6333,8 @@ declare class CairoInt64 {
|
|
|
6242
6333
|
* // result = 7017280452245743464n
|
|
6243
6334
|
* const result2 = CairoInt64.__processData('abcdefghi');
|
|
6244
6335
|
* // result2 = 1796423795774910326889n (past the i64 range, and returned all the same)
|
|
6336
|
+
* const result3 = CairoInt64.__processData('-0x5');
|
|
6337
|
+
* // result3 = -5n (a negative number, not the text "-0x5")
|
|
6245
6338
|
* ```
|
|
6246
6339
|
*/
|
|
6247
6340
|
static __processData(data: BigNumberish | boolean | unknown): bigint;
|
|
@@ -6303,11 +6396,11 @@ declare class CairoInt64 {
|
|
|
6303
6396
|
/**
|
|
6304
6397
|
* Throw unless the value can be carried by an i64.
|
|
6305
6398
|
*
|
|
6306
|
-
*
|
|
6307
|
-
* an array, a number with a decimal part, and a value outside [-9223372036854775808, 9223372036854775807]. A text string reaches
|
|
6399
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
6400
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [-9223372036854775808, 9223372036854775807]. A text string reaches
|
|
6308
6401
|
* that last check as the number its bytes spell, so `'abcdefghi'` is refused for being out of range.
|
|
6309
6402
|
* @param {BigNumberish | boolean} data the value to check
|
|
6310
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
6403
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
6311
6404
|
* @example
|
|
6312
6405
|
* ```typescript
|
|
6313
6406
|
* CairoInt64.validate(5000000000); // passes
|
|
@@ -6370,6 +6463,10 @@ declare class CairoInt64 {
|
|
|
6370
6463
|
* `'129445976596022050476432668810952994672'` and `'0x6162636465666768696a6b6c6d6e6f70'` give the same i128. A string that reads as text rather than as a
|
|
6371
6464
|
* number is taken for its UTF-8 bytes, which is why `'abcdefghijklmnop'` is 129445976596022050476432668810952994672 and not a rejected input.
|
|
6372
6465
|
*
|
|
6466
|
+
* A minus sign in front of a number is read as a sign, not as text : `'-5'` is -5, as `-5` and
|
|
6467
|
+
* `-5n` are. Only the signed integers read a string this way — for every other type, `'-5'` is
|
|
6468
|
+
* text, encoded or refused as such.
|
|
6469
|
+
*
|
|
6373
6470
|
* An already built instance is **not** an accepted input : handed back to the constructor it is
|
|
6374
6471
|
* seen as an object and refused. Inside the library it is `unwrapCairoScalar` that reduces an
|
|
6375
6472
|
* instance to its number before an abi slot receives it.
|
|
@@ -6380,6 +6477,11 @@ declare class CairoInt64 {
|
|
|
6380
6477
|
* new CairoInt128('129445976596022050476432668810952994672').toBigInt(); // 129445976596022050476432668810952994672n
|
|
6381
6478
|
* new CairoInt128('0x6162636465666768696a6b6c6d6e6f70').toBigInt(); // 129445976596022050476432668810952994672n
|
|
6382
6479
|
* new CairoInt128('abcdefghijklmnop').toBigInt(); // 129445976596022050476432668810952994672n the UTF-8 bytes of the text
|
|
6480
|
+
*
|
|
6481
|
+
* // a negative value, reached three ways
|
|
6482
|
+
* new CairoInt128(-5).toBigInt(); // -5n
|
|
6483
|
+
* new CairoInt128('-5').toBigInt(); // -5n
|
|
6484
|
+
* new CairoInt128('-0x5').toBigInt(); // -5n a sign, not the text "-0x5"
|
|
6383
6485
|
* ```
|
|
6384
6486
|
*/
|
|
6385
6487
|
declare class CairoInt128 {
|
|
@@ -6404,15 +6506,17 @@ declare class CairoInt128 {
|
|
|
6404
6506
|
/**
|
|
6405
6507
|
* Build from a number, a string or a boolean, refusing anything out of the i128 range.
|
|
6406
6508
|
*
|
|
6407
|
-
* A string is read as a number when it spells one — decimal or hexadecimal
|
|
6408
|
-
* otherwise. Text therefore only fits here up to 16 ASCII
|
|
6409
|
-
* makes a number past 170141183460469231731687303715884105727.
|
|
6509
|
+
* A string is read as a number when it spells one — decimal or hexadecimal, with or without a
|
|
6510
|
+
* leading minus sign — and as UTF-8 text otherwise. Text therefore only fits here up to 16 ASCII
|
|
6511
|
+
* characters : one more already makes a number past 170141183460469231731687303715884105727.
|
|
6410
6512
|
* @param {BigNumberish | boolean} data the value to carry, within [-170141183460469231731687303715884105728, 170141183460469231731687303715884105727]
|
|
6411
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
6513
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
6412
6514
|
* @example
|
|
6413
6515
|
* ```typescript
|
|
6414
6516
|
* const result = new CairoInt128('abcdefghijklmnop').toApiRequest();
|
|
6415
6517
|
* // result = ["129445976596022050476432668810952994672"]
|
|
6518
|
+
* const result2 = new CairoInt128('-5').toApiRequest();
|
|
6519
|
+
* // result2 = ["3618502788666131213697322783095070105623107215331596699973092056135872020476"]
|
|
6416
6520
|
* ```
|
|
6417
6521
|
*/
|
|
6418
6522
|
constructor(data: BigNumberish | boolean | unknown);
|
|
@@ -6421,6 +6525,9 @@ declare class CairoInt128 {
|
|
|
6421
6525
|
*
|
|
6422
6526
|
* Nothing here refuses a value : `validate` is what reads this number and decides. So an input
|
|
6423
6527
|
* far outside the i128 range comes back untouched rather than raising.
|
|
6528
|
+
*
|
|
6529
|
+
* A minus sign in front of a number makes it negative rather than text : `'-5'` and `'-0x5'` are
|
|
6530
|
+
* both -5. This holds for the signed integers only — for any other type, such a string is text.
|
|
6424
6531
|
* @param {BigNumberish | boolean} data the value to convert
|
|
6425
6532
|
* @returns {bigint} the number the input spells, of whatever size
|
|
6426
6533
|
* @example
|
|
@@ -6429,6 +6536,8 @@ declare class CairoInt128 {
|
|
|
6429
6536
|
* // result = 129445976596022050476432668810952994672n
|
|
6430
6537
|
* const result2 = CairoInt128.__processData('abcdefghijklmnopq');
|
|
6431
6538
|
* // result2 = 33138170008581644921966763215603966636145n (past the i128 range, and returned all the same)
|
|
6539
|
+
* const result3 = CairoInt128.__processData('-0x5');
|
|
6540
|
+
* // result3 = -5n (a negative number, not the text "-0x5")
|
|
6432
6541
|
* ```
|
|
6433
6542
|
*/
|
|
6434
6543
|
static __processData(data: BigNumberish | boolean | unknown): bigint;
|
|
@@ -6490,11 +6599,11 @@ declare class CairoInt128 {
|
|
|
6490
6599
|
/**
|
|
6491
6600
|
* Throw unless the value can be carried by an i128.
|
|
6492
6601
|
*
|
|
6493
|
-
*
|
|
6494
|
-
* an array, a number with a decimal part, and a value outside [-170141183460469231731687303715884105728, 170141183460469231731687303715884105727]. A text string reaches
|
|
6602
|
+
* Five things are refused, each with its own message : a null or undefined value, an object or
|
|
6603
|
+
* an array, a number with a decimal part, `'0x'`, and a value outside [-170141183460469231731687303715884105728, 170141183460469231731687303715884105727]. A text string reaches
|
|
6495
6604
|
* that last check as the number its bytes spell, so `'abcdefghijklmnopq'` is refused for being out of range.
|
|
6496
6605
|
* @param {BigNumberish | boolean} data the value to check
|
|
6497
|
-
* @throws {Error} when the value is null, undefined, an object, a decimal number, or out of range
|
|
6606
|
+
* @throws {Error} when the value is null, undefined, an object, a decimal number, `'0x'`, or out of range
|
|
6498
6607
|
* @example
|
|
6499
6608
|
* ```typescript
|
|
6500
6609
|
* CairoInt128.validate(5000000000); // passes
|
|
@@ -7973,6 +8082,10 @@ declare const RANGE_CONTRACT_ADDRESS: {
|
|
|
7973
8082
|
readonly min: bigint;
|
|
7974
8083
|
readonly max: bigint;
|
|
7975
8084
|
};
|
|
8085
|
+
declare const RANGE_CLASS_HASH: {
|
|
8086
|
+
readonly min: bigint;
|
|
8087
|
+
readonly max: bigint;
|
|
8088
|
+
};
|
|
7976
8089
|
declare const LegacyUDC: {
|
|
7977
8090
|
readonly ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf";
|
|
7978
8091
|
readonly ENTRYPOINT: "deployContract";
|
|
@@ -8113,6 +8226,7 @@ declare const constants_MAX_STORAGE_ITEM_SIZE: typeof MAX_STORAGE_ITEM_SIZE;
|
|
|
8113
8226
|
declare const constants_OutsideExecutionCallerAny: typeof OutsideExecutionCallerAny;
|
|
8114
8227
|
declare const constants_PAYMASTER_RPC_NODES: typeof PAYMASTER_RPC_NODES;
|
|
8115
8228
|
declare const constants_PRIME: typeof PRIME;
|
|
8229
|
+
declare const constants_RANGE_CLASS_HASH: typeof RANGE_CLASS_HASH;
|
|
8116
8230
|
declare const constants_RANGE_CONTRACT_ADDRESS: typeof RANGE_CONTRACT_ADDRESS;
|
|
8117
8231
|
declare const constants_RANGE_ETH_ADDRESS: typeof RANGE_ETH_ADDRESS;
|
|
8118
8232
|
declare const constants_RANGE_FELT: typeof RANGE_FELT;
|
|
@@ -8139,7 +8253,7 @@ declare const constants_TEXT_TO_FELT_MAX_LEN: typeof TEXT_TO_FELT_MAX_LEN;
|
|
|
8139
8253
|
declare const constants_UDC: typeof UDC;
|
|
8140
8254
|
declare const constants_ZERO: typeof ZERO;
|
|
8141
8255
|
declare namespace constants {
|
|
8142
|
-
export { constants_ADDR_BOUND as ADDR_BOUND, constants_API_VERSION as API_VERSION, type constants_ChannelDefaultOptions as ChannelDefaultOptions, type constants_ChannelDefaults as ChannelDefaults, type constants_ChannelMethodOptions as ChannelMethodOptions, constants_DEFAULT_GLOBAL_CONFIG as DEFAULT_GLOBAL_CONFIG, constants_HARDENING_4BYTES as HARDENING_4BYTES, constants_HARDENING_BYTE as HARDENING_BYTE, constants_IS_BROWSER as IS_BROWSER, constants_LegacyUDC as LegacyUDC, constants_MASK_250 as MASK_250, constants_MASK_31 as MASK_31, constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE, _NetworkName as NetworkName, constants_OutsideExecutionCallerAny as OutsideExecutionCallerAny, constants_PAYMASTER_RPC_NODES as PAYMASTER_RPC_NODES, constants_PRIME as PRIME, constants_RANGE_CONTRACT_ADDRESS as RANGE_CONTRACT_ADDRESS, constants_RANGE_ETH_ADDRESS as RANGE_ETH_ADDRESS, constants_RANGE_FELT as RANGE_FELT, constants_RANGE_I128 as RANGE_I128, constants_RANGE_I16 as RANGE_I16, constants_RANGE_I32 as RANGE_I32, constants_RANGE_I64 as RANGE_I64, constants_RANGE_I8 as RANGE_I8, constants_RANGE_U128 as RANGE_U128, constants_RANGE_U16 as RANGE_U16, constants_RANGE_U32 as RANGE_U32, constants_RANGE_U64 as RANGE_U64, constants_RANGE_U8 as RANGE_U8, constants_RANGE_U96 as RANGE_U96, constants_RPC_DEFAULT_NODES as RPC_DEFAULT_NODES, constants_SNIP9_V1_INTERFACE_ID as SNIP9_V1_INTERFACE_ID, constants_SNIP9_V2_INTERFACE_ID as SNIP9_V2_INTERFACE_ID, constants_SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS as SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS, constants_SYSTEM_MESSAGES as SYSTEM_MESSAGES, _StarknetChainId as StarknetChainId, type constants_SupportedCairoVersion as SupportedCairoVersion, _SupportedRpcVersion as SupportedRpcVersion, type constants_SupportedRpcVersion0_10 as SupportedRpcVersion0_10, type constants_SupportedTransactionVersion as SupportedTransactionVersion, constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN, _TransactionHashPrefix as TransactionHashPrefix, constants_UDC as UDC, constants_ZERO as ZERO };
|
|
8256
|
+
export { constants_ADDR_BOUND as ADDR_BOUND, constants_API_VERSION as API_VERSION, type constants_ChannelDefaultOptions as ChannelDefaultOptions, type constants_ChannelDefaults as ChannelDefaults, type constants_ChannelMethodOptions as ChannelMethodOptions, constants_DEFAULT_GLOBAL_CONFIG as DEFAULT_GLOBAL_CONFIG, constants_HARDENING_4BYTES as HARDENING_4BYTES, constants_HARDENING_BYTE as HARDENING_BYTE, constants_IS_BROWSER as IS_BROWSER, constants_LegacyUDC as LegacyUDC, constants_MASK_250 as MASK_250, constants_MASK_31 as MASK_31, constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE, _NetworkName as NetworkName, constants_OutsideExecutionCallerAny as OutsideExecutionCallerAny, constants_PAYMASTER_RPC_NODES as PAYMASTER_RPC_NODES, constants_PRIME as PRIME, constants_RANGE_CLASS_HASH as RANGE_CLASS_HASH, constants_RANGE_CONTRACT_ADDRESS as RANGE_CONTRACT_ADDRESS, constants_RANGE_ETH_ADDRESS as RANGE_ETH_ADDRESS, constants_RANGE_FELT as RANGE_FELT, constants_RANGE_I128 as RANGE_I128, constants_RANGE_I16 as RANGE_I16, constants_RANGE_I32 as RANGE_I32, constants_RANGE_I64 as RANGE_I64, constants_RANGE_I8 as RANGE_I8, constants_RANGE_U128 as RANGE_U128, constants_RANGE_U16 as RANGE_U16, constants_RANGE_U32 as RANGE_U32, constants_RANGE_U64 as RANGE_U64, constants_RANGE_U8 as RANGE_U8, constants_RANGE_U96 as RANGE_U96, constants_RPC_DEFAULT_NODES as RPC_DEFAULT_NODES, constants_SNIP9_V1_INTERFACE_ID as SNIP9_V1_INTERFACE_ID, constants_SNIP9_V2_INTERFACE_ID as SNIP9_V2_INTERFACE_ID, constants_SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS as SN_VERSION_IMPLEMENTING_BLAKE_FOR_COMPILED_CLASS, constants_SYSTEM_MESSAGES as SYSTEM_MESSAGES, _StarknetChainId as StarknetChainId, type constants_SupportedCairoVersion as SupportedCairoVersion, _SupportedRpcVersion as SupportedRpcVersion, type constants_SupportedRpcVersion0_10 as SupportedRpcVersion0_10, type constants_SupportedTransactionVersion as SupportedTransactionVersion, constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN, _TransactionHashPrefix as TransactionHashPrefix, constants_UDC as UDC, constants_ZERO as ZERO };
|
|
8143
8257
|
}
|
|
8144
8258
|
|
|
8145
8259
|
/** What a {@link SubscriptionChannel} needs: a socket to borrow, and how much to buffer. */
|
|
@@ -11306,13 +11420,17 @@ declare const isHexString: typeof isHex;
|
|
|
11306
11420
|
/**
|
|
11307
11421
|
* Convert BigNumberish to bigint
|
|
11308
11422
|
*
|
|
11423
|
+
* `'0x'`, which holds no digit, is refused with its own message rather than with `BigInt`'s.
|
|
11309
11424
|
* @param {BigNumberish} value value to convert
|
|
11310
11425
|
* @returns {BigInt} converted value
|
|
11426
|
+
* @throws {Error} when the value is `'0x'`, or anything else `BigInt` cannot read
|
|
11311
11427
|
* @example
|
|
11312
11428
|
* ```typescript
|
|
11313
11429
|
* const str = '123';
|
|
11314
11430
|
* const result = toBigInt(str);
|
|
11315
11431
|
* // result = 123n
|
|
11432
|
+
* toBigInt('0x');
|
|
11433
|
+
* // throws Error("Invalid input: '0x' holds no hexadecimal digit")
|
|
11316
11434
|
* ```
|
|
11317
11435
|
*/
|
|
11318
11436
|
declare function toBigInt(value: BigNumberish): bigint;
|
|
@@ -11390,22 +11508,22 @@ declare function toHex64(number: BigNumberish): string;
|
|
|
11390
11508
|
*/
|
|
11391
11509
|
declare function hexToDecimalString(hex: string): string;
|
|
11392
11510
|
/**
|
|
11393
|
-
* Asserts input is
|
|
11511
|
+
* Asserts input is within [lowerBound, upperBound], both bounds included.
|
|
11394
11512
|
*
|
|
11395
|
-
* The `inputName` parameter
|
|
11513
|
+
* The `inputName` parameter names the input in the assertion message.
|
|
11396
11514
|
* @param input Value to check
|
|
11397
|
-
* @param lowerBound Lower bound value
|
|
11398
|
-
* @param upperBound Upper bound value
|
|
11515
|
+
* @param lowerBound Lower bound value, included
|
|
11516
|
+
* @param upperBound Upper bound value, included
|
|
11399
11517
|
* @param inputName Name of the input for error message
|
|
11400
11518
|
* @throws Error if input is out of range
|
|
11401
11519
|
* @example
|
|
11402
11520
|
* ```typescript
|
|
11403
11521
|
* const input1:BigNumberish = 10;
|
|
11404
|
-
* assertInRange(input1, 5, 20, '
|
|
11522
|
+
* assertInRange(input1, 5, 20, 'amount')
|
|
11405
11523
|
*
|
|
11406
11524
|
* const input2: BigNumberish = 25;
|
|
11407
|
-
* assertInRange(input2, 5, 20, '
|
|
11408
|
-
* // throws Error:
|
|
11525
|
+
* assertInRange(input2, 5, 20, 'amount');
|
|
11526
|
+
* // throws Error: Value is out of amount range [5, 20]
|
|
11409
11527
|
* ```
|
|
11410
11528
|
*/
|
|
11411
11529
|
declare function assertInRange(input: BigNumberish, lowerBound: BigNumberish, upperBound: BigNumberish, inputName?: string): void;
|
|
@@ -11557,16 +11675,48 @@ declare function addPercent(number: BigNumberish, percent: number): bigint;
|
|
|
11557
11675
|
* ```
|
|
11558
11676
|
*/
|
|
11559
11677
|
declare function stringToSha256ToArrayBuff4(str: string): Uint8Array;
|
|
11678
|
+
/**
|
|
11679
|
+
* Test if a value is a `0x` prefix with no digit after it.
|
|
11680
|
+
*
|
|
11681
|
+
* `'0x'` is hexadecimal in form — it is how an EVM tool writes empty data — but it spells no
|
|
11682
|
+
* number : `BigInt('0x')` throws, `isBigNumberish` refuses it, and so does every Cairo type.
|
|
11683
|
+
* @param {unknown} value the value to test
|
|
11684
|
+
* @returns {boolean} true for `'0x'` and `'0X'`, false for anything else
|
|
11685
|
+
* @example
|
|
11686
|
+
* ```typescript
|
|
11687
|
+
* const result = num.isEmptyHex('0x');
|
|
11688
|
+
* // result = true
|
|
11689
|
+
* const result2 = num.isEmptyHex('0x0');
|
|
11690
|
+
* // result2 = false
|
|
11691
|
+
* ```
|
|
11692
|
+
*/
|
|
11693
|
+
declare function isEmptyHex(value: unknown): boolean;
|
|
11560
11694
|
/**
|
|
11561
11695
|
* Checks if a given value is of BigNumberish type.
|
|
11562
|
-
* 234, 234n, "234"
|
|
11696
|
+
* 234, 234n, "234" and "0xea" are valid ; a boolean is not, nor a string that spells no number —
|
|
11697
|
+
* `'0x'` included, which holds no digit.
|
|
11698
|
+
*
|
|
11699
|
+
* A number or a bigint passes whatever its sign, and a number whatever its decimal part : `-1`,
|
|
11700
|
+
* `-1n` and `1.5` are all accepted here, and it is the Cairo type receiving the value that refuses
|
|
11701
|
+
* what it cannot hold. A string is unsigned : it passes as decimal digits or as `0x` hexadecimal
|
|
11702
|
+
* only, so `'-1'` and `'1.5'` do not — to the library, such a string is text. The signed integer
|
|
11703
|
+
* classes, `CairoInt8` to `CairoInt128`, are the one place where a leading minus sign is read as a
|
|
11704
|
+
* sign.
|
|
11563
11705
|
* @param {unknown} input a value
|
|
11564
11706
|
* @returns {boolean} true if type of input is `BigNumberish`
|
|
11565
11707
|
* @example
|
|
11566
11708
|
* ```typescript
|
|
11567
11709
|
* const res = num.isBigNumberish("ZERO");
|
|
11568
11710
|
* // res = false
|
|
11569
|
-
*
|
|
11711
|
+
* const res2 = num.isBigNumberish(-1);
|
|
11712
|
+
* // res2 = true
|
|
11713
|
+
* const res3 = num.isBigNumberish('-1');
|
|
11714
|
+
* // res3 = false (a string is unsigned : this one is text)
|
|
11715
|
+
* const res4 = num.isBigNumberish(1.5);
|
|
11716
|
+
* // res4 = true (a number is not checked for a decimal part)
|
|
11717
|
+
* const res5 = num.isBigNumberish('0x');
|
|
11718
|
+
* // res5 = false (hexadecimal in form, but no digit)
|
|
11719
|
+
* ```
|
|
11570
11720
|
*/
|
|
11571
11721
|
declare function isBigNumberish(input: unknown): input is BigNumberish;
|
|
11572
11722
|
/**
|
|
@@ -11590,6 +11740,7 @@ declare const num_getNext: typeof getNext;
|
|
|
11590
11740
|
declare const num_hexToBytes: typeof hexToBytes;
|
|
11591
11741
|
declare const num_hexToDecimalString: typeof hexToDecimalString;
|
|
11592
11742
|
declare const num_isBigNumberish: typeof isBigNumberish;
|
|
11743
|
+
declare const num_isEmptyHex: typeof isEmptyHex;
|
|
11593
11744
|
declare const num_isHex: typeof isHex;
|
|
11594
11745
|
declare const num_isHexString: typeof isHexString;
|
|
11595
11746
|
declare const num_isStringWholeNumber: typeof isStringWholeNumber;
|
|
@@ -11602,7 +11753,7 @@ declare const num_toHexString: typeof toHexString;
|
|
|
11602
11753
|
declare const num_toStorageKey: typeof toStorageKey;
|
|
11603
11754
|
declare const num_tryToBigInt: typeof tryToBigInt;
|
|
11604
11755
|
declare namespace num {
|
|
11605
|
-
export { num_addPercent as addPercent, num_assertInRange as assertInRange, num_bigNumberishArrayToDecimalStringArray as bigNumberishArrayToDecimalStringArray, num_bigNumberishArrayToHexadecimalStringArray as bigNumberishArrayToHexadecimalStringArray, num_cleanHex as cleanHex, num_getDecimalString as getDecimalString, num_getHexString as getHexString, num_getHexStringArray as getHexStringArray, num_getNext as getNext, num_hexToBytes as hexToBytes, num_hexToDecimalString as hexToDecimalString, num_isBigNumberish as isBigNumberish, num_isHex as isHex, num_isHexString as isHexString, num_isStringWholeNumber as isStringWholeNumber, num_stringToSha256ToArrayBuff4 as stringToSha256ToArrayBuff4, num_toBigInt as toBigInt, num_toCairoBool as toCairoBool, num_toHex as toHex, num_toHex64 as toHex64, num_toHexString as toHexString, num_toStorageKey as toStorageKey, num_tryToBigInt as tryToBigInt };
|
|
11756
|
+
export { num_addPercent as addPercent, num_assertInRange as assertInRange, num_bigNumberishArrayToDecimalStringArray as bigNumberishArrayToDecimalStringArray, num_bigNumberishArrayToHexadecimalStringArray as bigNumberishArrayToHexadecimalStringArray, num_cleanHex as cleanHex, num_getDecimalString as getDecimalString, num_getHexString as getHexString, num_getHexStringArray as getHexStringArray, num_getNext as getNext, num_hexToBytes as hexToBytes, num_hexToDecimalString as hexToDecimalString, num_isBigNumberish as isBigNumberish, num_isEmptyHex as isEmptyHex, num_isHex as isHex, num_isHexString as isHexString, num_isStringWholeNumber as isStringWholeNumber, num_stringToSha256ToArrayBuff4 as stringToSha256ToArrayBuff4, num_toBigInt as toBigInt, num_toCairoBool as toCairoBool, num_toHex as toHex, num_toHex64 as toHex64, num_toHexString as toHexString, num_toStorageKey as toStorageKey, num_tryToBigInt as tryToBigInt };
|
|
11606
11757
|
}
|
|
11607
11758
|
|
|
11608
11759
|
/**
|
|
@@ -13644,7 +13795,7 @@ declare class CairoUint256 {
|
|
|
13644
13795
|
* A `Uint256` object is accepted here too : it already carries `low` and `high`, and both are
|
|
13645
13796
|
* checked as u128 rather than the whole being cut again.
|
|
13646
13797
|
* @param {BigNumberish | Uint256} data the value to carry, within [0, 2^256 - 1]
|
|
13647
|
-
* @throws {Error} when the value is null, undefined, of an unread type, or out of range
|
|
13798
|
+
* @throws {Error} when the value is null, undefined, text, `'0x'`, of an unread type, a decimal number, or out of range
|
|
13648
13799
|
* @example
|
|
13649
13800
|
* ```typescript
|
|
13650
13801
|
* const result = new CairoUint256(2n ** 130n + 5n).toApiRequest();
|
|
@@ -13656,7 +13807,7 @@ declare class CairoUint256 {
|
|
|
13656
13807
|
* Build from the two halves as they arrive, already cut (Api response).
|
|
13657
13808
|
* @param {BigNumberish} low the bottom 128 bits
|
|
13658
13809
|
* @param {BigNumberish} high the top 128 bits
|
|
13659
|
-
* @throws {Error} when either half is
|
|
13810
|
+
* @throws {Error} when either half is null, undefined, text, `'0x'`, not a number, a decimal number, or outside the u128 range
|
|
13660
13811
|
* @example
|
|
13661
13812
|
* ```typescript
|
|
13662
13813
|
* const result = new CairoUint256(5, 4).toBigInt();
|
|
@@ -13668,16 +13819,22 @@ declare class CairoUint256 {
|
|
|
13668
13819
|
* Throw unless a whole value can be represented as a u256, and give back its number.
|
|
13669
13820
|
*
|
|
13670
13821
|
* A string is only accepted while it spells a number, in base 10 or 16 : one that does not is
|
|
13671
|
-
* refused
|
|
13822
|
+
* refused as text, and `'0x'`, which holds no digit, is refused too. So is an object, a `Uint256`
|
|
13823
|
+
* one included : its two halves are checked by {@link CairoUint256.validateProps}, which is what
|
|
13824
|
+
* the constructor calls for it.
|
|
13672
13825
|
* @param {BigNumberish} bigNumberish the value to check
|
|
13673
13826
|
* @returns {bigint} the value as a number, once accepted
|
|
13674
|
-
* @throws {Error} when the value is null, undefined, of an unread type, or out of range
|
|
13827
|
+
* @throws {Error} when the value is null, undefined, text, `'0x'`, of an unread type, a decimal number, or out of range
|
|
13675
13828
|
* @example
|
|
13676
13829
|
* ```typescript
|
|
13677
13830
|
* const result = CairoUint256.validate(255);
|
|
13678
13831
|
* // result = 255n
|
|
13679
13832
|
* CairoUint256.validate(-1);
|
|
13680
13833
|
* // throws Error("bigNumberish is smaller than UINT_256_MIN")
|
|
13834
|
+
* CairoUint256.validate('abc');
|
|
13835
|
+
* // throws Error("Invalid input: a u256 cannot be built from text")
|
|
13836
|
+
* CairoUint256.validate(1.5);
|
|
13837
|
+
* // throws Error("Invalid input: decimal numbers are not supported, only integers")
|
|
13681
13838
|
* ```
|
|
13682
13839
|
*/
|
|
13683
13840
|
static validate(bigNumberish: BigNumberish | unknown): bigint;
|
|
@@ -13689,13 +13846,17 @@ declare class CairoUint256 {
|
|
|
13689
13846
|
* @param {BigNumberish} low the bottom 128 bits
|
|
13690
13847
|
* @param {BigNumberish} high the top 128 bits
|
|
13691
13848
|
* @returns {{low: bigint, high: bigint}} the two halves as numbers
|
|
13692
|
-
* @throws {Error} when either half is outside the u128 range
|
|
13849
|
+
* @throws {Error} when either half is null, undefined, text, `'0x'`, not a number, a decimal number, or outside the u128 range
|
|
13693
13850
|
* @example
|
|
13694
13851
|
* ```typescript
|
|
13695
13852
|
* const result = CairoUint256.validateProps(5, 4);
|
|
13696
13853
|
* // result = { low: 5n, high: 4n }
|
|
13697
13854
|
* CairoUint256.validateProps(-1, 4);
|
|
13698
13855
|
* // throws Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX")
|
|
13856
|
+
* CairoUint256.validateProps(1.5, 4);
|
|
13857
|
+
* // throws Error("low must be an integer")
|
|
13858
|
+
* CairoUint256.validateProps('abc', 4);
|
|
13859
|
+
* // throws Error("low cannot be built from text")
|
|
13699
13860
|
* ```
|
|
13700
13861
|
*/
|
|
13701
13862
|
static validateProps(low: BigNumberish, high: BigNumberish): {
|
|
@@ -14107,11 +14268,19 @@ declare class CairoFixedArray {
|
|
|
14107
14268
|
* The bytes are held right-aligned in a fixed 31-byte buffer, so the length of the input is not
|
|
14108
14269
|
* recoverable from the value — `'0x41'` and `'0x0041'` give the same bytes31. Reach for
|
|
14109
14270
|
* `CairoByteArray` when the byte count has to survive.
|
|
14271
|
+
*
|
|
14272
|
+
* `'0x'` holds no byte at all, and is the same bytes31 as the empty string `''`. Where a number
|
|
14273
|
+
* type refuses `'0x'`, a type made of bytes reads it as empty bytes, which is how an EVM tool
|
|
14274
|
+
* writes them.
|
|
14110
14275
|
* @example
|
|
14111
14276
|
* ```typescript
|
|
14112
14277
|
* // the same five characters, read two ways
|
|
14113
14278
|
* new CairoBytes31('12345').toHexString(); // "0x3039" the number 12345
|
|
14114
14279
|
* CairoBytes31.fromText('12345').toHexString(); // "0x3132333435" the text '12345'
|
|
14280
|
+
*
|
|
14281
|
+
* // no byte at all, written two ways
|
|
14282
|
+
* new CairoBytes31('').toApiRequest(); // ["0"]
|
|
14283
|
+
* new CairoBytes31('0x').toApiRequest(); // ["0"]
|
|
14115
14284
|
* ```
|
|
14116
14285
|
*/
|
|
14117
14286
|
declare class CairoBytes31 {
|
|
@@ -14442,16 +14611,18 @@ declare class CairoFelt252 {
|
|
|
14442
14611
|
/**
|
|
14443
14612
|
* Throw unless the value can be carried by a felt252.
|
|
14444
14613
|
*
|
|
14445
|
-
* Null, undefined
|
|
14446
|
-
* message, then the value is converted and its range checked. A negative number does not
|
|
14447
|
-
* that range check : converting it fails earlier, and the message comes from the conversion.
|
|
14614
|
+
* Null, undefined, any type this class does not read, and `'0x'` are refused first, each with its
|
|
14615
|
+
* own message, then the value is converted and its range checked. A negative number does not
|
|
14616
|
+
* reach that range check : converting it fails earlier, and the message comes from the conversion.
|
|
14448
14617
|
* @param {BigNumberish | boolean} data the value to check
|
|
14449
|
-
* @throws {Error} when the value is null, undefined, of an unread type, or outside [0, P)
|
|
14618
|
+
* @throws {Error} when the value is null, undefined, of an unread type, `'0x'`, or outside [0, P)
|
|
14450
14619
|
* @example
|
|
14451
14620
|
* ```typescript
|
|
14452
14621
|
* CairoFelt252.validate('Hello'); // passes
|
|
14453
14622
|
* CairoFelt252.validate({});
|
|
14454
14623
|
* // throws Error("Unsupported data type 'object' for felt252. Expected string, number, bigint, or boolean")
|
|
14624
|
+
* CairoFelt252.validate('0x');
|
|
14625
|
+
* // throws Error("Invalid input: '0x' holds no hexadecimal digit")
|
|
14455
14626
|
* CairoFelt252.validate(-1);
|
|
14456
14627
|
* // throws Error("Cannot convert negative bigint -1 to Uint8Array")
|
|
14457
14628
|
* ```
|
|
@@ -14509,6 +14680,10 @@ declare class CairoFelt252 {
|
|
|
14509
14680
|
* A ByteArray is **not** Cairo's string type. It carries bytes, and text is only one of the things
|
|
14510
14681
|
* those bytes can mean — which is why the constructor reads a string the way calldata does, and why
|
|
14511
14682
|
* text has a door of its own, {@link CairoByteArray.fromText}.
|
|
14683
|
+
*
|
|
14684
|
+
* `'0x'` holds no byte at all, and is the same ByteArray as the empty string `''`. Where a number
|
|
14685
|
+
* type refuses `'0x'`, a type made of bytes reads it as empty bytes, which is how an EVM tool
|
|
14686
|
+
* writes them.
|
|
14512
14687
|
* @example
|
|
14513
14688
|
* ```typescript
|
|
14514
14689
|
* // the same four characters, read four ways
|
|
@@ -14516,6 +14691,10 @@ declare class CairoFelt252 {
|
|
|
14516
14691
|
* new CairoByteArray('12345').toHexString(); // "0x3039" the number 12345
|
|
14517
14692
|
* new CairoByteArray('0x4142').toHexString(); // "0x4142" the bytes 0x41 0x42
|
|
14518
14693
|
* CairoByteArray.fromText('12345').toHexString(); // "0x3132333435" the text '12345'
|
|
14694
|
+
*
|
|
14695
|
+
* // no byte at all, written two ways
|
|
14696
|
+
* new CairoByteArray('').toApiRequest(); // ["0", "0", "0"]
|
|
14697
|
+
* new CairoByteArray('0x').toApiRequest(); // ["0", "0", "0"]
|
|
14519
14698
|
* ```
|
|
14520
14699
|
*/
|
|
14521
14700
|
declare class CairoByteArray {
|
|
@@ -14851,7 +15030,7 @@ declare class CairoEthAddress {
|
|
|
14851
15030
|
/**
|
|
14852
15031
|
* Build from a number or a numeric string, refusing text and anything wider than 160 bits.
|
|
14853
15032
|
* @param {BigNumberish | boolean} data the address to carry, within [0, 2^160 - 1]
|
|
14854
|
-
* @throws {Error} when the value is text,
|
|
15033
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of the EthAddress range
|
|
14855
15034
|
* @example
|
|
14856
15035
|
* ```typescript
|
|
14857
15036
|
* const result = new CairoEthAddress('0x1234').toApiRequest();
|
|
@@ -14898,10 +15077,12 @@ declare class CairoEthAddress {
|
|
|
14898
15077
|
* Throw unless the value can be carried by an EthAddress.
|
|
14899
15078
|
*
|
|
14900
15079
|
* Text is refused first, since an address spelled as words is a mistake rather than a value to
|
|
14901
|
-
* encode
|
|
14902
|
-
*
|
|
15080
|
+
* encode, then a number with a decimal part. A number or a bigint is read as it is, so that a
|
|
15081
|
+
* negative one reaches the range check below. Anything else is read as a felt252 — which is what
|
|
15082
|
+
* refuses a null, an object or an unsupported type. The value is finally checked against the 160
|
|
15083
|
+
* bits an Ethereum address occupies.
|
|
14903
15084
|
* @param {BigNumberish | boolean} data the value to check
|
|
14904
|
-
* @throws {Error} when the value is text,
|
|
15085
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of the EthAddress range
|
|
14905
15086
|
* @example
|
|
14906
15087
|
* ```typescript
|
|
14907
15088
|
* CairoEthAddress.validate('0x1234'); // passes
|
|
@@ -14909,6 +15090,8 @@ declare class CairoEthAddress {
|
|
|
14909
15090
|
* // throws Error("Invalid input: an EthAddress cannot be built from text")
|
|
14910
15091
|
* CairoEthAddress.validate(2n ** 160n);
|
|
14911
15092
|
* // throws Error("Value is out of EthAddress range [0, 1461501637330902918203684832716283019655932542975]")
|
|
15093
|
+
* CairoEthAddress.validate(-1);
|
|
15094
|
+
* // throws Error("Value is out of EthAddress range [0, 1461501637330902918203684832716283019655932542975]")
|
|
14912
15095
|
* ```
|
|
14913
15096
|
*/
|
|
14914
15097
|
static validate(data: BigNumberish | boolean | unknown): void;
|
|
@@ -15070,13 +15253,17 @@ declare class CairoSecp256k1Point {
|
|
|
15070
15253
|
* the constructor needs it, and computing it twice would mean splitting a 512-bit value twice.
|
|
15071
15254
|
* @param {BigNumberish} input the 512-bit value to check
|
|
15072
15255
|
* @returns {bigint} the value, once checked
|
|
15073
|
-
* @throws {Error} when the value is null, undefined, of an unread type, or outside [0, 2^512 - 1]
|
|
15256
|
+
* @throws {Error} when the value is null, undefined, text, `'0x'`, of an unread type, a decimal number, or outside [0, 2^512 - 1]
|
|
15074
15257
|
* @example
|
|
15075
15258
|
* ```typescript
|
|
15076
15259
|
* const result = CairoSecp256k1Point.validate('0x1234');
|
|
15077
15260
|
* // result = 4660n
|
|
15078
15261
|
* CairoSecp256k1Point.validate(SECP256K1_POINT_MAX + 1n);
|
|
15079
15262
|
* // throws Error("input is bigger than SECP256K1_POINT_MAX")
|
|
15263
|
+
* CairoSecp256k1Point.validate('abc');
|
|
15264
|
+
* // throws Error("Invalid input: a Secp256k1Point cannot be built from text")
|
|
15265
|
+
* CairoSecp256k1Point.validate(1.5);
|
|
15266
|
+
* // throws Error("Invalid input: decimal numbers are not supported, only integers")
|
|
15080
15267
|
* ```
|
|
15081
15268
|
*/
|
|
15082
15269
|
static validate(input: BigNumberish | unknown): bigint;
|
|
@@ -15087,13 +15274,17 @@ declare class CairoSecp256k1Point {
|
|
|
15087
15274
|
* @param {BigNumberish} yLow the low 128 bits of y
|
|
15088
15275
|
* @param {BigNumberish} yHigh the high 128 bits of y
|
|
15089
15276
|
* @returns {{xLow: bigint, xHigh: bigint, yLow: bigint, yHigh: bigint}} the four limbs, checked
|
|
15090
|
-
* @throws {Error} when a limb is null, undefined, not a number, negative, or wider than 128 bits
|
|
15277
|
+
* @throws {Error} when a limb is null, undefined, text, `'0x'`, not a number, a decimal number, negative, or wider than 128 bits
|
|
15091
15278
|
* @example
|
|
15092
15279
|
* ```typescript
|
|
15093
15280
|
* const result = CairoSecp256k1Point.validateProps(1, 2, 3, 4);
|
|
15094
15281
|
* // result = { xLow: 1n, xHigh: 2n, yLow: 3n, yHigh: 4n }
|
|
15095
15282
|
* CairoSecp256k1Point.validateProps(1, 2, 3, 2n ** 128n);
|
|
15096
15283
|
* // throws Error("yHigh must fit in 128 bits")
|
|
15284
|
+
* CairoSecp256k1Point.validateProps(1.5, 2, 3, 4);
|
|
15285
|
+
* // throws Error("xLow must be an integer")
|
|
15286
|
+
* CairoSecp256k1Point.validateProps('abc', 2, 3, 4);
|
|
15287
|
+
* // throws Error("xLow cannot be built from text")
|
|
15097
15288
|
* ```
|
|
15098
15289
|
*/
|
|
15099
15290
|
static validateProps(xLow: BigNumberish, xHigh: BigNumberish, yLow: BigNumberish, yHigh: BigNumberish): {
|
|
@@ -15209,9 +15400,9 @@ declare class CairoSecp256k1Point {
|
|
|
15209
15400
|
* A Cairo `core::starknet::class_hash::ClassHash` : the hash identifying a declared class.
|
|
15210
15401
|
*
|
|
15211
15402
|
* On the wire it is a field element like any other, so what this class adds over
|
|
15212
|
-
* {@link CairoFelt252} is the bound the
|
|
15213
|
-
*
|
|
15214
|
-
* the
|
|
15403
|
+
* {@link CairoFelt252} is the bound of the Cairo `ClassHash` type : [0, 2^251), the same range as
|
|
15404
|
+
* the Cairo type of an address, and narrower than the field. The 252-bit bound the RPC spec states
|
|
15405
|
+
* is looser, and never the one that binds.
|
|
15215
15406
|
*
|
|
15216
15407
|
* A number, a bigint, a decimal string and a hexadecimal string are all read as the same number.
|
|
15217
15408
|
* Text is **not** an accepted input : a class hash spelled as words is a mistake, not a value.
|
|
@@ -15243,9 +15434,9 @@ declare class CairoClassHash {
|
|
|
15243
15434
|
*/
|
|
15244
15435
|
static abiSelector: "core::starknet::class_hash::ClassHash";
|
|
15245
15436
|
/**
|
|
15246
|
-
* Build from a number or a numeric string, refusing text and anything
|
|
15247
|
-
* @param {BigNumberish | boolean} data the hash to carry, within [0, 2^
|
|
15248
|
-
* @throws {Error} when the value is text,
|
|
15437
|
+
* Build from a number or a numeric string, refusing text and anything outside the ClassHash range.
|
|
15438
|
+
* @param {BigNumberish | boolean} data the hash to carry, within [0, 2^251 - 1]
|
|
15439
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of the ClassHash range
|
|
15249
15440
|
* @example
|
|
15250
15441
|
* ```typescript
|
|
15251
15442
|
* const result = new CairoClassHash('0x1234').toApiRequest();
|
|
@@ -15291,16 +15482,21 @@ declare class CairoClassHash {
|
|
|
15291
15482
|
/**
|
|
15292
15483
|
* Throw unless the value can be carried by a ClassHash.
|
|
15293
15484
|
*
|
|
15294
|
-
* Text is refused first, then
|
|
15295
|
-
*
|
|
15296
|
-
* a
|
|
15485
|
+
* Text is refused first, then a number with a decimal part. A number or a bigint is read as it
|
|
15486
|
+
* is, so that a negative one reaches the range check. Anything else is read as a felt252 — which
|
|
15487
|
+
* is what refuses a null, an object or an unsupported type. The value is finally checked against
|
|
15488
|
+
* the range of the Cairo `ClassHash` type, [0, 2^251), which is narrower than the field.
|
|
15297
15489
|
* @param {BigNumberish | boolean} data the value to check
|
|
15298
|
-
* @throws {Error} when the value is text,
|
|
15490
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of the ClassHash range
|
|
15299
15491
|
* @example
|
|
15300
15492
|
* ```typescript
|
|
15301
15493
|
* CairoClassHash.validate('0x1234'); // passes
|
|
15302
15494
|
* CairoClassHash.validate('abc');
|
|
15303
15495
|
* // throws Error("Invalid input: a ClassHash cannot be built from text")
|
|
15496
|
+
* CairoClassHash.validate(2n ** 251n);
|
|
15497
|
+
* // throws Error("Value is out of ClassHash range [0, 3618502788666131106986593281521497120414687020801267626233049500247285301247]")
|
|
15498
|
+
* CairoClassHash.validate(-1);
|
|
15499
|
+
* // throws Error("Value is out of ClassHash range [0, 3618502788666131106986593281521497120414687020801267626233049500247285301247]")
|
|
15304
15500
|
* ```
|
|
15305
15501
|
*/
|
|
15306
15502
|
static validate(data: BigNumberish | boolean | unknown): void;
|
|
@@ -15387,7 +15583,7 @@ declare class CairoContractAddress {
|
|
|
15387
15583
|
/**
|
|
15388
15584
|
* Build from a number or a numeric string, refusing text and anything wider than 252 bits.
|
|
15389
15585
|
* @param {BigNumberish | boolean} data the address to carry, within [0, 2^252 - 1]
|
|
15390
|
-
* @throws {Error} when the value is text,
|
|
15586
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of range
|
|
15391
15587
|
* @example
|
|
15392
15588
|
* ```typescript
|
|
15393
15589
|
* const result = new CairoContractAddress('0x1234').toApiRequest();
|
|
@@ -15433,11 +15629,12 @@ declare class CairoContractAddress {
|
|
|
15433
15629
|
/**
|
|
15434
15630
|
* Throw unless the value can be carried by a ContractAddress.
|
|
15435
15631
|
*
|
|
15436
|
-
* Text is refused first, then
|
|
15437
|
-
*
|
|
15438
|
-
* is
|
|
15632
|
+
* Text is refused first, then a number with a decimal part. A number or a bigint is read as it
|
|
15633
|
+
* is, so that a negative one reaches the range check. Anything else is read as a felt252 — which
|
|
15634
|
+
* is what refuses a null, an object or an unsupported type. The value is finally checked against
|
|
15635
|
+
* the bound an address has, which is narrower than the field.
|
|
15439
15636
|
* @param {BigNumberish | boolean} data the value to check
|
|
15440
|
-
* @throws {Error} when the value is text,
|
|
15637
|
+
* @throws {Error} when the value is text, a decimal number, not a felt252 input, or out of range
|
|
15441
15638
|
* @example
|
|
15442
15639
|
* ```typescript
|
|
15443
15640
|
* CairoContractAddress.validate('0x1234'); // passes
|
|
@@ -15445,6 +15642,8 @@ declare class CairoContractAddress {
|
|
|
15445
15642
|
* // throws Error("Invalid input: a ContractAddress cannot be built from text")
|
|
15446
15643
|
* CairoContractAddress.validate(2n ** 251n);
|
|
15447
15644
|
* // throws Error("Value is out of ContractAddress range [0, 3618502788666131106986593281521497120414687020801267626233049500247285300991]")
|
|
15645
|
+
* CairoContractAddress.validate(-1);
|
|
15646
|
+
* // throws Error("Value is out of ContractAddress range [0, 3618502788666131106986593281521497120414687020801267626233049500247285300991]")
|
|
15448
15647
|
* ```
|
|
15449
15648
|
*/
|
|
15450
15649
|
static validate(data: BigNumberish | boolean | unknown): void;
|
|
@@ -17066,12 +17265,14 @@ declare function addAddressPadding(address: BigNumberish): string;
|
|
|
17066
17265
|
/**
|
|
17067
17266
|
* Check the validity of a Starknet address, and format it as a hex number: '0x' and 64 characters, adding leading zeros if necessary.
|
|
17068
17267
|
*
|
|
17268
|
+
* A string is read as hexadecimal, with or without its `0x` prefix — so `'31'` is 0x31 — and one
|
|
17269
|
+
* holding anything but hexadecimal digits, `'0x'` included, is refused as a malformed address.
|
|
17069
17270
|
* @param {BigNumberish} address
|
|
17070
17271
|
* @returns {string} Hex string: 0x followed by 64 characters. No upper case characters in the response.
|
|
17071
17272
|
* @throws address argument must be a valid address inside the address range bound
|
|
17072
17273
|
* @example
|
|
17073
17274
|
* ```typescript
|
|
17074
|
-
* const result = [31, 0x1f, '31', '0x1f', '0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf'].map(
|
|
17275
|
+
* const result = [31, 0x1f, '31', '0x1f', '0x90591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf'].map(validateAndParseAddress);
|
|
17075
17276
|
* // result = [
|
|
17076
17277
|
* // '0x000000000000000000000000000000000000000000000000000000000000001f',
|
|
17077
17278
|
* // '0x000000000000000000000000000000000000000000000000000000000000001f',
|
|
@@ -17079,6 +17280,8 @@ declare function addAddressPadding(address: BigNumberish): string;
|
|
|
17079
17280
|
* // '0x000000000000000000000000000000000000000000000000000000000000001f',
|
|
17080
17281
|
* // '0x0000090591d9fa3efc87067d95a643f8455e0b8190eb8cb7bfd39e4fb7571fdf'
|
|
17081
17282
|
* // ]
|
|
17283
|
+
* validateAndParseAddress('test');
|
|
17284
|
+
* // throws Error("Invalid Address Format")
|
|
17082
17285
|
* ```
|
|
17083
17286
|
*/
|
|
17084
17287
|
declare function validateAndParseAddress(address: BigNumberish): string;
|