starknet 5.19.5 → 5.19.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/dist/index.d.ts CHANGED
@@ -5,27 +5,82 @@ import * as json$1 from 'lossless-json';
5
5
  import * as starknet from '@scure/starknet';
6
6
 
7
7
  declare const IS_BROWSER: boolean;
8
+ /**
9
+ * Some functions recreated from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts
10
+ * enc-utils is not a dependency to avoid using `Buffer` which only works in node and not browsers
11
+ */
12
+ /**
13
+ * Convert array buffer to string
14
+ *
15
+ * *[internal usage]*
16
+ */
8
17
  declare function arrayBufferToString(array: ArrayBuffer): string;
18
+ /**
19
+ * Convert string to array buffer
20
+ *
21
+ * *[internal usage]*
22
+ */
9
23
  declare function stringToArrayBuffer(s: string): Uint8Array;
24
+ /**
25
+ * Convert string to array buffer (browser and node compatible)
26
+ */
10
27
  declare function atobUniversal(a: string): Uint8Array;
28
+ /**
29
+ * Convert array buffer to string (browser and node compatible)
30
+ */
11
31
  declare function btoaUniversal(b: ArrayBuffer): string;
32
+ /**
33
+ * Convert array buffer to hex-string
34
+ * @returns format: hex-string
35
+ */
12
36
  declare function buf2hex(buffer: Uint8Array): string;
13
37
  /**
14
- * Some function imported from https://github.com/pedrouid/enc-utils/blob/master/src/index.ts
15
- * enc-utils is no dependency to avoid using `Buffer` which just works in node and no browsers
38
+ * Remove hex prefix '0x' from hex-string
39
+ * @param hex hex-string
40
+ * @returns format: base16-string
16
41
  */
17
42
  declare function removeHexPrefix(hex: string): string;
43
+ /**
44
+ * Add hex prefix '0x' to base16-string
45
+ * @param hex base16-string
46
+ * @returns format: hex-string
47
+ */
18
48
  declare function addHexPrefix(hex: string): string;
49
+ /**
50
+ * Prepend string (default with '0')
51
+ */
19
52
  declare function padLeft(str: string, length: number, padding?: string): string;
20
- declare function calcByteLength(length: number, byteSize?: number): number;
53
+ /**
54
+ * Calculate byte length of string
55
+ *
56
+ * *[no internal usage]*
57
+ */
58
+ declare function calcByteLength(str: string, byteSize?: number): number;
59
+ /**
60
+ * Prepend '0' to string bytes
61
+ *
62
+ * *[no internal usage]*
63
+ */
21
64
  declare function sanitizeBytes(str: string, byteSize?: number, padding?: string): string;
65
+ /**
66
+ * Prepend '0' to hex-string bytes
67
+ *
68
+ * *[no internal usage]*
69
+ * @param hex hex-string
70
+ * @returns format: hex-string
71
+ */
22
72
  declare function sanitizeHex(hex: string): string;
73
+ /**
74
+ * Convert utf8-string to Uint8Array
75
+ *
76
+ * Implemented using TextEncoder to make it isomorphic
77
+ * @param str utf8-string
78
+ */
23
79
  declare function utf8ToArray(str: string): Uint8Array;
24
80
  /**
25
81
  * String transformation util
26
- * pascal case to screaming snake case
27
- * @param text string
28
- * @returns string
82
+ *
83
+ * Pascal case to screaming snake case
29
84
  */
30
85
  declare const pascalToSnake: (text: string) => string;
31
86
 
@@ -62,8 +117,16 @@ declare namespace encode {
62
117
  };
63
118
  }
64
119
 
120
+ /**
121
+ * Cairo Felt support storing max 31 character
122
+ */
123
+ declare const TEXT_TO_FELT_MAX_LEN = 31;
65
124
  declare const HEX_STR_TRANSACTION_VERSION_1 = "0x1";
66
125
  declare const HEX_STR_TRANSACTION_VERSION_2 = "0x2";
126
+ declare const BN_TRANSACTION_VERSION_1 = 1n;
127
+ declare const BN_TRANSACTION_VERSION_2 = 2n;
128
+ declare const BN_FEE_TRANSACTION_VERSION_1: bigint;
129
+ declare const BN_FEE_TRANSACTION_VERSION_2: bigint;
67
130
  declare const ZERO = 0n;
68
131
  declare const MASK_250: bigint;
69
132
  declare const MASK_251: bigint;
@@ -94,62 +157,44 @@ declare const UDC: {
94
157
  ADDRESS: string;
95
158
  ENTRYPOINT: string;
96
159
  };
97
- /**
98
- * The following is taken from https://github.com/starkware-libs/starkex-resources/blob/master/crypto/starkware/crypto/signature/pedersen_params.json but converted to hex, because JS is very bad handling big integers by default
99
- * Please do not edit until the JSON changes.
100
- */
101
- declare const FIELD_PRIME = "800000000000011000000000000000000000000000000000000000000000001";
102
- declare const FIELD_GEN = "3";
103
- declare const FIELD_SIZE = 251;
104
- declare const EC_ORDER = "800000000000010FFFFFFFFFFFFFFFFB781126DCAE7B2321E66A241ADC64D2F";
105
- declare const ALPHA = "1";
106
- declare const BETA = "6F21413EFBE40DE150E596D72F7A8C5609AD26C15C915C1F4CDFCB99CEE9E89";
107
- declare const MAX_ECDSA_VAL = "800000000000000000000000000000000000000000000000000000000000000";
108
- declare const CONSTANT_POINTS: string[][];
109
160
 
110
- declare const constants_ALPHA: typeof ALPHA;
111
161
  declare const constants_API_VERSION: typeof API_VERSION;
112
- declare const constants_BETA: typeof BETA;
162
+ declare const constants_BN_FEE_TRANSACTION_VERSION_1: typeof BN_FEE_TRANSACTION_VERSION_1;
163
+ declare const constants_BN_FEE_TRANSACTION_VERSION_2: typeof BN_FEE_TRANSACTION_VERSION_2;
164
+ declare const constants_BN_TRANSACTION_VERSION_1: typeof BN_TRANSACTION_VERSION_1;
165
+ declare const constants_BN_TRANSACTION_VERSION_2: typeof BN_TRANSACTION_VERSION_2;
113
166
  type constants_BaseUrl = BaseUrl;
114
167
  declare const constants_BaseUrl: typeof BaseUrl;
115
- declare const constants_CONSTANT_POINTS: typeof CONSTANT_POINTS;
116
- declare const constants_EC_ORDER: typeof EC_ORDER;
117
- declare const constants_FIELD_GEN: typeof FIELD_GEN;
118
- declare const constants_FIELD_PRIME: typeof FIELD_PRIME;
119
- declare const constants_FIELD_SIZE: typeof FIELD_SIZE;
120
168
  declare const constants_HEX_STR_TRANSACTION_VERSION_1: typeof HEX_STR_TRANSACTION_VERSION_1;
121
169
  declare const constants_HEX_STR_TRANSACTION_VERSION_2: typeof HEX_STR_TRANSACTION_VERSION_2;
122
170
  declare const constants_IS_BROWSER: typeof IS_BROWSER;
123
171
  declare const constants_MASK_250: typeof MASK_250;
124
172
  declare const constants_MASK_251: typeof MASK_251;
125
- declare const constants_MAX_ECDSA_VAL: typeof MAX_ECDSA_VAL;
126
173
  type constants_NetworkName = NetworkName;
127
174
  declare const constants_NetworkName: typeof NetworkName;
128
175
  type constants_StarknetChainId = StarknetChainId;
129
176
  declare const constants_StarknetChainId: typeof StarknetChainId;
177
+ declare const constants_TEXT_TO_FELT_MAX_LEN: typeof TEXT_TO_FELT_MAX_LEN;
130
178
  type constants_TransactionHashPrefix = TransactionHashPrefix;
131
179
  declare const constants_TransactionHashPrefix: typeof TransactionHashPrefix;
132
180
  declare const constants_UDC: typeof UDC;
133
181
  declare const constants_ZERO: typeof ZERO;
134
182
  declare namespace constants {
135
183
  export {
136
- constants_ALPHA as ALPHA,
137
184
  constants_API_VERSION as API_VERSION,
138
- constants_BETA as BETA,
185
+ constants_BN_FEE_TRANSACTION_VERSION_1 as BN_FEE_TRANSACTION_VERSION_1,
186
+ constants_BN_FEE_TRANSACTION_VERSION_2 as BN_FEE_TRANSACTION_VERSION_2,
187
+ constants_BN_TRANSACTION_VERSION_1 as BN_TRANSACTION_VERSION_1,
188
+ constants_BN_TRANSACTION_VERSION_2 as BN_TRANSACTION_VERSION_2,
139
189
  constants_BaseUrl as BaseUrl,
140
- constants_CONSTANT_POINTS as CONSTANT_POINTS,
141
- constants_EC_ORDER as EC_ORDER,
142
- constants_FIELD_GEN as FIELD_GEN,
143
- constants_FIELD_PRIME as FIELD_PRIME,
144
- constants_FIELD_SIZE as FIELD_SIZE,
145
190
  constants_HEX_STR_TRANSACTION_VERSION_1 as HEX_STR_TRANSACTION_VERSION_1,
146
191
  constants_HEX_STR_TRANSACTION_VERSION_2 as HEX_STR_TRANSACTION_VERSION_2,
147
192
  constants_IS_BROWSER as IS_BROWSER,
148
193
  constants_MASK_250 as MASK_250,
149
194
  constants_MASK_251 as MASK_251,
150
- constants_MAX_ECDSA_VAL as MAX_ECDSA_VAL,
151
195
  constants_NetworkName as NetworkName,
152
196
  constants_StarknetChainId as StarknetChainId,
197
+ constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN,
153
198
  constants_TransactionHashPrefix as TransactionHashPrefix,
154
199
  constants_UDC as UDC,
155
200
  constants_ZERO as ZERO,
@@ -3510,9 +3555,7 @@ declare class Account extends Provider implements AccountInterface {
3510
3555
  * First check if contract is already declared, if not declare it
3511
3556
  * If contract already declared returned transaction_hash is ''.
3512
3557
  * Method will pass even if contract is already declared
3513
- * @param payload DeclareContractPayload
3514
- * @param transactionsDetail (optional) InvocationsDetails = \{\}
3515
- * @returns DeclareContractResponse
3558
+ * @param transactionsDetail (optional)
3516
3559
  */
3517
3560
  declareIfNot(payload: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
3518
3561
  declare(payload: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
@@ -3640,9 +3683,6 @@ declare const splitArgsAndOptions: (args: ArgsOrCalldataWithOptions) => {
3640
3683
  options?: undefined;
3641
3684
  };
3642
3685
  declare function getCalldata(args: RawArgs, callback: Function): Calldata;
3643
- /**
3644
- * Not used at the moment
3645
- */
3646
3686
  declare class Contract implements ContractInterface {
3647
3687
  abi: Abi;
3648
3688
  address: string;
@@ -3714,55 +3754,56 @@ declare class ContractFactory {
3714
3754
  constructor(params: ContractFactoryParams);
3715
3755
  /**
3716
3756
  * Deploys contract and returns new instance of the Contract
3717
- * If contract is not declared it will first declare it, and then deploy
3718
3757
  *
3719
- * @param args - Array of the constructor arguments for deployment
3720
- * @param options (optional) Object - parseRequest, parseResponse, addressSalt
3721
- * @returns deployed Contract
3758
+ * If contract is not declared it will first declare it, and then deploy
3722
3759
  */
3723
3760
  deploy(...args: ArgsOrCalldataWithOptions): Promise<Contract>;
3724
3761
  /**
3725
3762
  * Attaches to new Account
3726
3763
  *
3727
- * @param account - new Provider or Account to attach to
3728
- * @returns ContractFactory
3764
+ * @param account - new Account to attach to
3729
3765
  */
3730
3766
  connect(account: AccountInterface): ContractFactory;
3731
3767
  /**
3732
3768
  * Attaches current abi and account to the new address
3733
- *
3734
- * @param address - Contract address
3735
- * @returns Contract
3736
3769
  */
3737
3770
  attach(address: string): Contract;
3738
3771
  }
3739
3772
 
3740
3773
  /**
3741
- * Keccak hash BigNumberish value
3742
- * @param value BigNumberish
3743
- * @returns string - hexadecimal string
3774
+ * Calculate hex-string keccak hash for a given BigNumberish
3775
+ *
3776
+ * BigNumberish -> hex-string keccak hash
3777
+ * @returns format: hex-string
3744
3778
  */
3745
3779
  declare function keccakBn(value: BigNumberish): string;
3746
3780
  /**
3747
- * Function to get the starknet keccak hash from a string
3781
+ * Calculate bigint keccak hash for a given string
3782
+ *
3783
+ * String -> bigint keccak hash
3748
3784
  *
3749
3785
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/public/abi.py#L17-L22)
3750
- * @param value - string you want to get the starknetKeccak hash from
3751
- * @returns starknet keccak hash as BigNumber
3786
+ * @param str the value you want to get the keccak hash from
3787
+ * @returns starknet keccak hash as BigInt
3752
3788
  */
3753
- declare function starknetKeccak(value: string): bigint;
3789
+ declare function starknetKeccak(str: string): bigint;
3754
3790
  /**
3755
- * Function to get the hex selector from a given function name
3791
+ * Calculate hex-string selector for a given abi-function-name
3792
+ *
3793
+ * Abi-function-name -> hex-string selector
3756
3794
  *
3757
3795
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/public/abi.py#L25-L26)
3758
- * @param funcName - selectors abi function name
3759
- * @returns hex selector of given abi function name
3796
+ * @param funcName ascii-string of 'abi function name'
3797
+ * @returns format: hex-string; selector for 'abi function name'
3760
3798
  */
3761
3799
  declare function getSelectorFromName(funcName: string): string;
3762
3800
  /**
3763
- * Function to get hex selector from function name, decimal string or hex string
3764
- * @param value hex string | decimal string | string
3765
- * @returns Hex selector
3801
+ * Calculate hex-string selector from abi-function-name, decimal string or hex string
3802
+ *
3803
+ * ('abi-function-name' or dec-string or hex-string) -> hex-string selector
3804
+ *
3805
+ * @param value hex-string | dec-string | ascii-string
3806
+ * @returns format: hex-string
3766
3807
  */
3767
3808
  declare function getSelector(value: string): string;
3768
3809
 
@@ -3784,30 +3825,80 @@ declare const transactionVersion_2 = 2n;
3784
3825
  declare const feeTransactionVersion: bigint;
3785
3826
  declare const feeTransactionVersion_2: bigint;
3786
3827
  /**
3787
- * Return versions based on version type, default transaction versions
3788
- * @param versionType 'fee' | 'transaction'
3789
- * @returns versions { v1: bigint; v2: bigint; }
3828
+ * Return transaction versions based on version type, default version type is 'transaction'
3790
3829
  */
3791
3830
  declare function getVersionsByType(versionType?: 'fee' | 'transaction'): {
3792
3831
  v1: bigint;
3793
3832
  v2: bigint;
3794
3833
  };
3834
+ /**
3835
+ * Compute pedersen hash from data
3836
+ * @returns format: hex-string - pedersen hash
3837
+ */
3795
3838
  declare function computeHashOnElements(data: BigNumberish[]): string;
3839
+ /**
3840
+ * Calculate transaction pedersen hash for common properties
3841
+ *
3842
+ * Following implementation is based on this python [implementation #](https://github.com/starkware-libs/cairo-lang/blob/b614d1867c64f3fb2cf4a4879348cfcf87c3a5a7/src/starkware/starknet/core/os/transaction_hash/transaction_hash.py)
3843
+ * @returns format: hex-string
3844
+ */
3796
3845
  declare function calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish, contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: RawCalldata, maxFee: BigNumberish, chainId: StarknetChainId, additionalData?: BigNumberish[]): string;
3846
+ /**
3847
+ * Calculate deploy transaction hash
3848
+ * @returns format: hex-string
3849
+ */
3797
3850
  declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: RawCalldata, version: BigNumberish, chainId: StarknetChainId, constructorName?: string): string;
3851
+ /**
3852
+ * Calculate declare transaction hash
3853
+ * @param classHash hex-string
3854
+ * @param compiledClassHash hex-string
3855
+ * @returns format: hex-string
3856
+ */
3798
3857
  declare function calculateDeclareTransactionHash(classHash: string, senderAddress: BigNumberish, version: BigNumberish, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish, compiledClassHash?: string): string;
3858
+ /**
3859
+ * Calculate deploy_account transaction hash
3860
+ * @returns format: hex-string
3861
+ */
3799
3862
  declare function calculateDeployAccountTransactionHash(contractAddress: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, salt: BigNumberish, version: BigNumberish, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
3863
+ /**
3864
+ * Calculate invoke transaction hash
3865
+ * @returns format: hex-string
3866
+ */
3800
3867
  declare function calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, calldata: RawCalldata, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
3868
+ /**
3869
+ * Calculate contract address from class hash
3870
+ * @returns format: hex-string
3871
+ */
3801
3872
  declare function calculateContractAddressFromHash(salt: BigNumberish, classHash: BigNumberish, constructorCalldata: RawArgs, deployerAddress: BigNumberish): string;
3873
+ /**
3874
+ * Format json-string to conform starknet json-string
3875
+ * @param json json-string
3876
+ * @returns format: json-string
3877
+ */
3802
3878
  declare function formatSpaces(json: string): string;
3879
+ /**
3880
+ * Compute hinted class hash for legacy compiled contract (Cairo 0)
3881
+ * @returns format: hex-string
3882
+ */
3803
3883
  declare function computeHintedClassHash(compiledContract: LegacyCompiledContract): string;
3884
+ /**
3885
+ * Computes the class hash for legacy compiled contract (Cairo 0)
3886
+ * @returns format: hex-string
3887
+ */
3804
3888
  declare function computeLegacyContractClassHash(contract: LegacyCompiledContract | string): string;
3889
+ /**
3890
+ * Compute compiled class hash for contract (Cairo 1)
3891
+ * @returns format: hex-string
3892
+ */
3805
3893
  declare function computeCompiledClassHash(casm: CompiledSierraCasm): string;
3894
+ /**
3895
+ * Compute sierra contract class hash (Cairo 1)
3896
+ * @returns format: hex-string
3897
+ */
3806
3898
  declare function computeSierraContractClassHash(sierra: CompiledSierra): string;
3807
3899
  /**
3808
3900
  * Compute ClassHash (sierra or legacy) based on provided contract
3809
- * @param contract CompiledContract | CompiledSierra | string
3810
- * @returns HexString ClassHash
3901
+ * @returns format: hex-string
3811
3902
  */
3812
3903
  declare function computeContractClassHash(contract: CompiledContract | string): string;
3813
3904
 
@@ -3861,8 +3952,26 @@ declare namespace hash {
3861
3952
  };
3862
3953
  }
3863
3954
 
3955
+ /**
3956
+ * Convert JSON string to JSON object
3957
+ *
3958
+ * NOTE: the String() wrapping is used so the behavior conforms to JSON.parse()
3959
+ * which can accept simple data types but is not represented in the default typing
3960
+ * @param x JSON string
3961
+ */
3864
3962
  declare const parse: (x: string) => any;
3963
+ /**
3964
+ * Convert JSON string to JSON object with all numbers as bigint
3965
+ * @param x JSON string
3966
+ */
3865
3967
  declare const parseAlwaysAsBig: (x: string) => any;
3968
+ /**
3969
+ * Convert JSON object to JSON string
3970
+ *
3971
+ * NOTE: the not-null assertion is used so the return type conforms to JSON.stringify()
3972
+ * which can also return undefined but is not represented in the default typing
3973
+ * @returns JSON string
3974
+ */
3866
3975
  declare const stringify: (value: json$1.JavaScriptValue, replacer?: any, space?: string | number | undefined, numberStringifiers?: json$1.NumberStringifier[] | undefined) => string;
3867
3976
  /** @deprecated equivalent to 'stringify', alias will be removed */
3868
3977
  declare const stringifyAlwaysAsBig: (value: json$1.JavaScriptValue, replacer?: any, space?: string | number | undefined, numberStringifiers?: json$1.NumberStringifier[] | undefined) => string;
@@ -3880,37 +3989,93 @@ declare namespace json {
3880
3989
  };
3881
3990
  }
3882
3991
 
3992
+ /**
3993
+ * Test if string is hex-string
3994
+ * @param hex hex-string
3995
+ */
3883
3996
  declare function isHex(hex: string): boolean;
3997
+ /**
3998
+ * Convert BigNumberish to bigint
3999
+ */
3884
4000
  declare function toBigInt(value: BigNumberish): bigint;
4001
+ /**
4002
+ * Test if value is bigint
4003
+ */
3885
4004
  declare function isBigInt(value: any): value is bigint;
4005
+ /**
4006
+ * Convert BigNumberish to hex-string
4007
+ * @returns format: hex-string
4008
+ */
3886
4009
  declare function toHex(number: BigNumberish): string;
3887
4010
  /**
3888
- * Convert BigNumberish to STORAGE_KEY
3889
- * Same as toHex but conforming pattern STORAGE_KEY pattern ^0x0[0-7]{1}[a-fA-F0-9]{0,62}$
3890
- * A storage key. Represented as up to 62 hex digits, 3 bits, and 5 leading zeroes.
3891
- * 0x0 + [0-7] + 62 hex = 0x + 64 hex
3892
- * @param number BigNumberish
4011
+ * Alias of ToHex
4012
+ */
4013
+ declare const toHexString: typeof toHex;
4014
+ /**
4015
+ * Convert BigNumberish to storage-key-string
4016
+ *
4017
+ * Same as toHex but conforming to the STORAGE_KEY pattern `^0x0[0-7]{1}[a-fA-F0-9]{0,62}$`.
4018
+ *
4019
+ * A storage key is represented as up to 62 hex digits, 3 bits, and 5 leading zeroes:
4020
+ * `0x0 + [0-7] + 62 hex = 0x + 64 hex`
4021
+ * @returns format: storage-key-string
3893
4022
  */
3894
4023
  declare function toStorageKey(number: BigNumberish): string;
4024
+ /**
4025
+ * Convert hexadecimal string to decimal string
4026
+ * @param hex hex-string
4027
+ * @returns format: decimal string
4028
+ */
3895
4029
  declare function hexToDecimalString(hex: string): string;
3896
4030
  /**
3897
- * Remove hex string leading zero and lower case '0x01A'.. -> '0x1a..'
3898
- * @param hex string
4031
+ * Remove hex string leading zero and lowercase it
4032
+ * @example '0x01A...' -> '0x1a..'
4033
+ * @param hex hex-string
4034
+ * @returns format: hex-string
3899
4035
  */
3900
4036
  declare const cleanHex: (hex: string) => string;
4037
+ /**
4038
+ * Asserts input is equal to or greater then lowerBound and lower then upperBound.
4039
+ *
4040
+ * The `inputName` parameter is used in the assertion message.
4041
+ */
3901
4042
  declare function assertInRange(input: BigNumberish, lowerBound: BigNumberish, upperBound: BigNumberish, inputName?: string): void;
4043
+ /**
4044
+ * Convert BigNumberish array to decimal string array
4045
+ * @returns format: decimal string array
4046
+ */
3902
4047
  declare function bigNumberishArrayToDecimalStringArray(rawCalldata: BigNumberish[]): string[];
4048
+ /**
4049
+ * Convert BigNumberish array to hexadecimal string array
4050
+ * @returns format: hex-string array
4051
+ */
3903
4052
  declare function bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[];
4053
+ /**
4054
+ * Test if string is whole number (0,1,2,3...)
4055
+ */
3904
4056
  declare const isStringWholeNumber: (value: string) => boolean;
3905
- declare const toHexString: (value: string) => string;
4057
+ /**
4058
+ * Convert string to decimal string
4059
+ * @returns format: decimal string
4060
+ */
3906
4061
  declare function getDecimalString(value: string): string;
4062
+ /**
4063
+ * Convert string to hexadecimal string
4064
+ * @returns format: hex-string
4065
+ */
3907
4066
  declare function getHexString(value: string): string;
4067
+ /**
4068
+ * Convert string array to hex-string array
4069
+ * @returns format: hex-string array
4070
+ */
3908
4071
  declare function getHexStringArray(value: Array<string>): string[];
4072
+ /**
4073
+ * Convert boolean to "0" or "1"
4074
+ */
3909
4075
  declare const toCairoBool: (value: boolean) => string;
3910
4076
  /**
3911
- * Convert a hex string to an array of Bytes (Uint8Array)
3912
- * @param value hex string
3913
- * @returns an array of Bytes
4077
+ * Convert hex-string to an array of Bytes (Uint8Array)
4078
+ * @param value hex-string
3914
4079
  */
3915
4080
  declare function hexToBytes(value: string): Uint8Array;
3916
4081
 
@@ -3958,39 +4123,33 @@ declare namespace num {
3958
4123
  /**
3959
4124
  * Transforms a list of Calls, each with their own calldata, into
3960
4125
  * two arrays: one with the entrypoints, and one with the concatenated calldata.
3961
- * @param calls
3962
- * @returns
3963
4126
  */
3964
4127
  declare const transformCallsToMulticallArrays: (calls: Call[]) => {
3965
4128
  callArray: ParsedStruct[];
3966
4129
  calldata: Calldata;
3967
4130
  };
3968
4131
  /**
3969
- * Transforms a list of calls in the full flattened calldata expected
3970
- * by the __execute__ protocol.
3971
- * @param calls
3972
- * @returns
4132
+ * Transforms a list of calls into the Cairo 0 `__execute__` calldata.
3973
4133
  */
3974
4134
  declare const fromCallsToExecuteCalldata: (calls: Call[]) => Calldata;
4135
+ /**
4136
+ * Transforms a list of calls into the Cairo 0 `__execute__` calldata including nonce.
4137
+ *
4138
+ * @deprecated
4139
+ */
3975
4140
  declare const fromCallsToExecuteCalldataWithNonce: (calls: Call[], nonce: BigNumberish) => Calldata;
3976
4141
  /**
3977
4142
  * Format Data inside Calls
3978
- * @param calls Call[]
3979
- * @returns CallStruct
4143
+ *
4144
+ * @deprecated Not required for getting execute Calldata
3980
4145
  */
3981
4146
  declare const transformCallsToMulticallArrays_cairo1: (calls: Call[]) => CallStruct[];
3982
4147
  /**
3983
- * Transforms a list of calls in the full flattened calldata expected
3984
- * by the __execute__ protocol.
3985
- * @param calls
3986
- * @returns Calldata
4148
+ * Transforms a list of calls into the Cairo 1 `__execute__` calldata.
3987
4149
  */
3988
4150
  declare const fromCallsToExecuteCalldata_cairo1: (calls: Call[]) => Calldata;
3989
4151
  /**
3990
- *
3991
- * @param calls Call array
3992
- * @param cairoVersion Defaults to 0
3993
- * @returns string[] of calldata
4152
+ * Create `__execute__` Calldata from Calls based on Cairo versions
3994
4153
  */
3995
4154
  declare const getExecuteCalldata: (calls: Call[], cairoVersion?: CairoVersion) => Calldata;
3996
4155
 
@@ -4012,25 +4171,44 @@ declare namespace transaction {
4012
4171
  }
4013
4172
 
4014
4173
  /**
4015
- * Function to compress compiled cairo program
4174
+ * Compress compiled Cairo program
4016
4175
  *
4017
4176
  * [Reference](https://github.com/starkware-libs/cairo-lang/blob/master/src/starkware/starknet/services/api/gateway/transaction.py#L54-L58)
4018
- * @param jsonProgram - json file representing the compiled cairo program
4019
- * @returns Compressed cairo program
4177
+ * @param jsonProgram Representing the compiled cairo program
4020
4178
  */
4021
4179
  declare function compressProgram(jsonProgram: Program | string): CompressedProgram;
4022
4180
  /**
4023
- * Function to decompress compressed compiled cairo program
4024
- *
4025
- * @param base64 CompressedProgram
4026
- * @returns parsed decompressed compiled cairo program
4181
+ * Decompress compressed compiled Cairo program
4182
+ * @param base64 Compressed program
4183
+ * @returns Parsed decompressed compiled Cairo program
4027
4184
  */
4028
4185
  declare function decompressProgram(base64: CompressedProgram): any;
4186
+ /**
4187
+ * Random Address based on random keyPair
4188
+ */
4029
4189
  declare function randomAddress(): string;
4190
+ /**
4191
+ * Lowercase and hex prefix string
4192
+ *
4193
+ * @deprecated Not used internally, naming is confusing based on functionality
4194
+ */
4030
4195
  declare function makeAddress(input: string): string;
4196
+ /**
4197
+ * Format Signature to standard type (hex array)
4198
+ * @returns Custom hex array or weierstrass.SignatureType hex array
4199
+ */
4031
4200
  declare function formatSignature(sig?: Signature): ArraySignatureType;
4201
+ /**
4202
+ * Format Signature to decimal string array
4203
+ */
4032
4204
  declare function signatureToDecimalArray(sig?: Signature): ArraySignatureType;
4205
+ /**
4206
+ * Format Signature to hex string array
4207
+ */
4033
4208
  declare function signatureToHexArray(sig?: Signature): ArraySignatureType;
4209
+ /**
4210
+ * Convert estimated fee to max fee with overhead
4211
+ */
4034
4212
  declare function estimatedFeeToMaxFee(estimatedFee: BigNumberish, overhead?: number): bigint;
4035
4213
 
4036
4214
  declare const stark_compressProgram: typeof compressProgram;
@@ -4059,10 +4237,32 @@ declare class MerkleTree {
4059
4237
  branches: string[][];
4060
4238
  root: string;
4061
4239
  constructor(leafHashes: string[]);
4240
+ /**
4241
+ * Create Merkle tree
4242
+ * @param leaves hex-string array
4243
+ * @returns format: hex-string; Merkle tree root
4244
+ */
4062
4245
  private build;
4246
+ /**
4247
+ * Create pedersen hash from a and b
4248
+ * @returns format: hex-string
4249
+ */
4063
4250
  static hash(a: string, b: string): string;
4251
+ /**
4252
+ * Return path to leaf
4253
+ * @param leaf hex-string
4254
+ * @param branch hex-string array
4255
+ * @param hashPath hex-string array
4256
+ * @returns format: hex-string array
4257
+ */
4064
4258
  getProof(leaf: string, branch?: string[], hashPath?: string[]): string[];
4065
4259
  }
4260
+ /**
4261
+ * Test Merkle tree path
4262
+ * @param root hex-string
4263
+ * @param leaf hex-string
4264
+ * @param path hex-string array
4265
+ */
4066
4266
  declare function proofMerklePath(root: string, leaf: string, path: string[]): boolean;
4067
4267
 
4068
4268
  type merkle_MerkleTree = MerkleTree;
@@ -4075,11 +4275,20 @@ declare namespace merkle {
4075
4275
  };
4076
4276
  }
4077
4277
 
4078
- declare function uint256ToBN(uint256: Uint256): bigint;
4079
4278
  declare const UINT_128_MAX: bigint;
4080
4279
  declare const UINT_256_MAX: bigint;
4280
+ /**
4281
+ * Convert Uint256 to bigint
4282
+ */
4283
+ declare function uint256ToBN(uint256: Uint256): bigint;
4284
+ /**
4285
+ * Test BigNumberish is smaller or equal 2**256-1
4286
+ */
4081
4287
  declare function isUint256(bn: BigNumberish): boolean;
4082
- declare function bnToUint256(bignumber: BigNumberish): Uint256;
4288
+ /**
4289
+ * Convert BigNumberish (string | number | bigint) to Uint256 (hex)
4290
+ */
4291
+ declare function bnToUint256(bn: BigNumberish): Uint256;
4083
4292
 
4084
4293
  declare const uint256$1_UINT_128_MAX: typeof UINT_128_MAX;
4085
4294
  declare const uint256$1_UINT_256_MAX: typeof UINT_256_MAX;
@@ -4098,41 +4307,54 @@ declare namespace uint256$1 {
4098
4307
  };
4099
4308
  }
4100
4309
 
4310
+ /**
4311
+ * Test if string contains only ASCII characters (string can be ascii text)
4312
+ */
4101
4313
  declare function isASCII(str: string): boolean;
4314
+ /**
4315
+ * Test if string is a Cairo short string (string has less or equal 31 characters)
4316
+ */
4102
4317
  declare function isShortString(str: string): boolean;
4103
- declare function isDecimalString(decim: string): boolean;
4104
4318
  /**
4105
- * check if value is string text, and not string-hex, string-number
4106
- * @param val any
4107
- * @returns boolean
4319
+ * Test if string contains only numbers (string can be converted to decimal number)
4320
+ */
4321
+ declare function isDecimalString(str: string): boolean;
4322
+ /**
4323
+ * Test if value is a free-from string text, and not a hex string or number string
4108
4324
  */
4109
4325
  declare function isText(val: any): boolean;
4326
+ /**
4327
+ * Test if value is short text
4328
+ */
4110
4329
  declare const isShortText: (val: any) => boolean;
4330
+ /**
4331
+ * Test if value is long text
4332
+ */
4111
4333
  declare const isLongText: (val: any) => boolean;
4334
+ /**
4335
+ * Split long text into short strings
4336
+ */
4112
4337
  declare function splitLongString(longStr: string): string[];
4113
4338
  /**
4114
- * Convert an ASCII string to an hexadecimal string.
4115
- * @param str - ASCII string -
4116
- * 31 characters maxi. Ex : "uri/item23.jpg"
4117
- * @returns a string representing an Hex number 248 bits max.
4118
- * @Example
4339
+ * Convert an ASCII string to a hexadecimal string.
4340
+ * @param str short string (ASCII string, 31 characters max)
4341
+ * @returns format: hex-string; 248 bits max
4342
+ * @example
4119
4343
  * ```typescript
4120
4344
  * const myEncodedString: string = encodeShortString("uri/pict/t38.jpg");
4345
+ * // return hex string (ex."0x7572692f706963742f7433382e6a7067")
4121
4346
  * ```
4122
- * returns : string : "0x7572692f706963742f7433382e6a7067"
4123
4347
  */
4124
4348
  declare function encodeShortString(str: string): string;
4125
4349
  /**
4126
- * Convert an hexadecimal or decimal string to an ASCII string.
4127
- * @param str - string - representing a 248 bits max number.
4128
- *
4129
- * Ex : hex : "0x1A4F64EA56" or decimal : "236942575435676423"
4130
- * @returns a string with 31 characters max.
4131
- * @Example
4350
+ * Convert a hexadecimal or decimal string to an ASCII string.
4351
+ * @param str representing a 248 bit max number (ex. "0x1A4F64EA56" or "236942575435676423")
4352
+ * @returns format: short string; 31 characters max
4353
+ * @example
4132
4354
  * ```typescript
4133
4355
  * const myDecodedString: string = decodeShortString("0x7572692f706963742f7433382e6a7067");
4356
+ * // return string (ex."uri/pict/t38.jpg")
4134
4357
  * ```
4135
- * return : string : "uri/pict/t38.jpg"
4136
4358
  */
4137
4359
  declare function decodeShortString(str: string): string;
4138
4360
 
@@ -4177,55 +4399,29 @@ interface Context {
4177
4399
  declare const getDependencies: (types: TypedData['types'], type: string, dependencies?: string[]) => string[];
4178
4400
  /**
4179
4401
  * Encode a type to a string. All dependant types are alphabetically sorted.
4180
- *
4181
- * @param {TypedData} typedData
4182
- * @param {string} type
4183
- * @return {string}
4184
4402
  */
4185
4403
  declare const encodeType: (types: TypedData['types'], type: string) => string;
4186
4404
  /**
4187
4405
  * Get a type string as hash.
4188
- *
4189
- * @param {TypedData} typedData
4190
- * @param {string} type
4191
- * @return {string}
4192
4406
  */
4193
4407
  declare const getTypeHash: (types: TypedData['types'], type: string) => string;
4194
4408
  /**
4195
4409
  * Encodes a single value to an ABI serialisable string, number or Buffer. Returns the data as tuple, which consists of
4196
4410
  * an array of ABI compatible types, and an array of corresponding values.
4197
- *
4198
- * @param {TypedData} typedData
4199
- * @param {string} type
4200
- * @param {any} data
4201
- * @returns {[string, string]}
4202
4411
  */
4203
4412
  declare const encodeValue: (types: TypedData['types'], type: string, data: unknown, ctx?: Context) => [string, string];
4204
4413
  /**
4205
4414
  * Encode the data to an ABI encoded Buffer. The data should be a key -> value object with all the required values. All
4206
4415
  * dependant types are automatically encoded.
4207
- *
4208
- * @param {TypedData} typedData
4209
- * @param {string} type
4210
- * @param {Record<string, any>} data
4211
4416
  */
4212
4417
  declare const encodeData: <T extends TypedData>(types: T["types"], type: string, data: T["message"]) => string[][];
4213
4418
  /**
4214
4419
  * Get encoded data as a hash. The data should be a key -> value object with all the required values. All dependant
4215
4420
  * types are automatically encoded.
4216
- *
4217
- * @param {TypedData} typedData
4218
- * @param {string} type
4219
- * @param {Record<string, any>} data
4220
- * @return {Buffer}
4221
4421
  */
4222
4422
  declare const getStructHash: <T extends TypedData>(types: T["types"], type: string, data: T["message"]) => string;
4223
4423
  /**
4224
4424
  * Get the EIP-191 encoded message to sign, from the typedData object.
4225
- *
4226
- * @param {TypedData} typedData
4227
- * @param {BigNumberish} account
4228
- * @return {string}
4229
4425
  */
4230
4426
  declare const getMessageHash: (typedData: TypedData, account: BigNumberish) => string;
4231
4427
 
@@ -4282,8 +4478,21 @@ declare namespace starknetId {
4282
4478
  };
4283
4479
  }
4284
4480
 
4481
+ /**
4482
+ * Helper - Async Sleep for 'delay' time
4483
+ */
4285
4484
  declare function wait(delay: number): Promise<unknown>;
4485
+ /**
4486
+ * Create Sierra Contract Class from a given Compiled Sierra
4487
+ *
4488
+ * CompiledSierra -> SierraContractClass
4489
+ */
4286
4490
  declare function createSierraContractClass(contract: CompiledSierra): SierraContractClass;
4491
+ /**
4492
+ * Create Contract Class from a given CompiledContract or string
4493
+ *
4494
+ * (CompiledContract or string) -> ContractClass
4495
+ */
4287
4496
  declare function parseContract(contract: CompiledContract | string): ContractClass$1;
4288
4497
 
4289
4498
  declare const provider_createSierraContractClass: typeof createSierraContractClass;
@@ -4323,8 +4532,6 @@ declare function validateChecksumAddress(address: string): boolean;
4323
4532
 
4324
4533
  /**
4325
4534
  * Loosely validate a URL `string`.
4326
- * @param {String} s
4327
- * @return {Boolean}
4328
4535
  */
4329
4536
  declare function isUrl(s?: string): boolean;
4330
4537
  declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
@@ -4367,8 +4574,7 @@ declare const isTypeEthAddress: (type: string) => boolean;
4367
4574
  declare const isCairo1Type: (type: string) => boolean;
4368
4575
  declare const getArrayType: (type: string) => string;
4369
4576
  /**
4370
- * tells if an ABI comes from a Cairo 1 contract
4371
- *
4577
+ * Test if an ABI comes from a Cairo 1 contract
4372
4578
  * @param abi representing the interface of a Cairo contract
4373
4579
  * @returns TRUE if it is an ABI from a Cairo1 contract
4374
4580
  * @example
@@ -4378,20 +4584,29 @@ declare const getArrayType: (type: string) => string;
4378
4584
  */
4379
4585
  declare function isCairo1Abi(abi: Abi): boolean;
4380
4586
  /**
4381
- * named tuple are described as js object {}
4382
- * struct types are described as js object {}
4383
- * array types are described as js array []
4587
+ * named tuple cairo type is described as js object {}
4588
+ * struct cairo type are described as js object {}
4589
+ * array cairo type are described as js array []
4384
4590
  */
4385
4591
  /**
4386
- * Uint256 cairo type (helper for common struct type)
4592
+ * Create Uint256 Cairo type (helper for common struct type)
4593
+ * @example
4594
+ * ```typescript
4595
+ * uint256('892349863487563453485768723498');
4596
+ * ```
4387
4597
  */
4388
4598
  declare const uint256: (it: BigNumberish) => Uint256;
4389
4599
  /**
4390
- * unnamed tuple cairo type (helper same as common struct type)
4600
+ * Create unnamed tuple Cairo type (helper same as common struct type)
4601
+ * @example
4602
+ * ```typescript
4603
+ * tuple(1,'0x101',16);
4604
+ * ```
4391
4605
  */
4392
4606
  declare const tuple: (...args: (BigNumberish | object | boolean)[]) => Record<number, BigNumberish | object | boolean>;
4393
4607
  /**
4394
- * felt cairo type
4608
+ * Create felt Cairo type (cairo type helper)
4609
+ * @returns format: felt-string
4395
4610
  */
4396
4611
  declare function felt(it: BigNumberish): string;
4397
4612
 
@@ -4521,16 +4736,13 @@ declare function isSierra(contract: CairoContract | string): contract is SierraC
4521
4736
  declare function extractContractHashes(payload: DeclareContractPayload): CompleteDeclareContractPayload;
4522
4737
  /**
4523
4738
  * Helper to redeclare response Cairo0 contract
4524
- * @param ccr ContractClassResponse
4525
- * @returns LegacyCompiledContract
4526
4739
  */
4527
4740
  declare function contractClassResponseToLegacyCompiledContract(ccr: ContractClassResponse): LegacyCompiledContract;
4528
4741
 
4529
4742
  /**
4530
4743
  * Parse Transaction Receipt Event from UDC invoke transaction and
4531
- * create DeployContractResponse compatibile response with adition of UDC Event data
4744
+ * create DeployContractResponse compatible response with addition of the UDC Event data
4532
4745
  *
4533
- * @param txReceipt
4534
4746
  * @returns DeployContractResponse | UDC Event Response data
4535
4747
  */
4536
4748
  declare function parseUDCEvent(txReceipt: InvokeTransactionReceiptResponse): {