starknet 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/index.d.ts +149 -20
- package/dist/index.global.js +173 -15
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +174 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -15
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# [5.6.0](https://github.com/0xs34n/starknet.js/compare/v5.5.0...v5.6.0) (2023-04-19)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- optional param in contract invoke ([da094e4](https://github.com/0xs34n/starknet.js/commit/da094e4172ed43ce93604e92adbba2a5ecb1498e))
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- cairo 1 bool ([52fed30](https://github.com/0xs34n/starknet.js/commit/52fed30f04b70bcce80f829dba6975101f6f3644))
|
|
10
|
+
- cairo1 array, fix invoke response, hash separate test ([4637cd7](https://github.com/0xs34n/starknet.js/commit/4637cd74481ba85b3164ddb93c258b9ca8b9b949))
|
|
11
|
+
- felt252 implementation ([3d20ea4](https://github.com/0xs34n/starknet.js/commit/3d20ea44b49d1c7ba90d8a46a307f54e737c3285))
|
|
12
|
+
- uint validate and parsing supprot ([c1acd29](https://github.com/0xs34n/starknet.js/commit/c1acd298d63758ba27fc20bcb4b0c00cca82078f))
|
|
13
|
+
|
|
1
14
|
# [5.5.0](https://github.com/0xs34n/starknet.js/compare/v5.4.2...v5.5.0) (2023-04-10)
|
|
2
15
|
|
|
3
16
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -462,7 +462,7 @@ declare type Overrides = {
|
|
|
462
462
|
maxFee?: BigNumberish;
|
|
463
463
|
nonce?: BigNumberish;
|
|
464
464
|
signature?: Signature;
|
|
465
|
-
parseRequest
|
|
465
|
+
parseRequest?: Boolean;
|
|
466
466
|
};
|
|
467
467
|
|
|
468
468
|
interface InvocationsSignerDetails extends Required<InvocationsDetails> {
|
|
@@ -487,7 +487,7 @@ declare type AsyncContractFunction<T = any> = (...args: Array<any>) => Promise<T
|
|
|
487
487
|
declare type ContractFunction = (...args: Array<any>) => any;
|
|
488
488
|
declare type Result = {
|
|
489
489
|
[key: string]: any;
|
|
490
|
-
};
|
|
490
|
+
} | Result[] | bigint | string | boolean;
|
|
491
491
|
|
|
492
492
|
declare type BlockIdentifier = BlockNumber | BigNumberish;
|
|
493
493
|
|
|
@@ -511,8 +511,8 @@ declare type TXN_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJ
|
|
|
511
511
|
declare type TXN_TYPE = 'DECLARE' | 'DEPLOY' | 'DEPLOY_ACCOUNT' | 'INVOKE' | 'L1_HANDLER';
|
|
512
512
|
declare type BLOCK_STATUS = 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
513
513
|
declare enum BLOCK_TAG {
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
latest = "latest",
|
|
515
|
+
pending = "pending"
|
|
516
516
|
}
|
|
517
517
|
declare type BLOCK_ID = {
|
|
518
518
|
block_hash: BLOCK_HASH;
|
|
@@ -2727,14 +2727,16 @@ declare class Contract implements ContractInterface {
|
|
|
2727
2727
|
};
|
|
2728
2728
|
readonly [key: string]: AsyncContractFunction | any;
|
|
2729
2729
|
private callData;
|
|
2730
|
+
private version;
|
|
2730
2731
|
/**
|
|
2731
2732
|
* Contract class to handle contract methods
|
|
2732
2733
|
*
|
|
2733
2734
|
* @param abi - Abi of the contract object
|
|
2734
2735
|
* @param address (optional) - address to connect to
|
|
2735
2736
|
* @param providerOrAccount (optional) - Provider or Account to attach to
|
|
2737
|
+
* @param cairoVersion (optional) - default '0', for Cairo 1 set '1'
|
|
2736
2738
|
*/
|
|
2737
|
-
constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface);
|
|
2739
|
+
constructor(abi: Abi, address: string, providerOrAccount?: ProviderInterface | AccountInterface, cairoVersion?: string);
|
|
2738
2740
|
attach(address: string): void;
|
|
2739
2741
|
connect(providerOrAccount: ProviderInterface | AccountInterface): void;
|
|
2740
2742
|
deployed(): Promise<Contract>;
|
|
@@ -3013,20 +3015,20 @@ declare const UINT_256_MAX: bigint;
|
|
|
3013
3015
|
declare function isUint256(bn: BigNumberish): boolean;
|
|
3014
3016
|
declare function bnToUint256(bignumber: BigNumberish): Uint256;
|
|
3015
3017
|
|
|
3016
|
-
type
|
|
3017
|
-
declare const
|
|
3018
|
-
declare const
|
|
3019
|
-
declare const
|
|
3020
|
-
declare const
|
|
3021
|
-
declare const
|
|
3022
|
-
declare namespace uint256 {
|
|
3018
|
+
type uint256$1_Uint256 = Uint256;
|
|
3019
|
+
declare const uint256$1_uint256ToBN: typeof uint256ToBN;
|
|
3020
|
+
declare const uint256$1_UINT_128_MAX: typeof UINT_128_MAX;
|
|
3021
|
+
declare const uint256$1_UINT_256_MAX: typeof UINT_256_MAX;
|
|
3022
|
+
declare const uint256$1_isUint256: typeof isUint256;
|
|
3023
|
+
declare const uint256$1_bnToUint256: typeof bnToUint256;
|
|
3024
|
+
declare namespace uint256$1 {
|
|
3023
3025
|
export {
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3026
|
+
uint256$1_Uint256 as Uint256,
|
|
3027
|
+
uint256$1_uint256ToBN as uint256ToBN,
|
|
3028
|
+
uint256$1_UINT_128_MAX as UINT_128_MAX,
|
|
3029
|
+
uint256$1_UINT_256_MAX as UINT_256_MAX,
|
|
3030
|
+
uint256$1_isUint256 as isUint256,
|
|
3031
|
+
uint256$1_bnToUint256 as bnToUint256,
|
|
3030
3032
|
};
|
|
3031
3033
|
}
|
|
3032
3034
|
|
|
@@ -3104,6 +3106,133 @@ declare function validateChecksumAddress(address: string): boolean;
|
|
|
3104
3106
|
declare function isUrl(s?: string): boolean;
|
|
3105
3107
|
declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
|
|
3106
3108
|
|
|
3109
|
+
declare enum Uint {
|
|
3110
|
+
u8 = "core::integer::u8",
|
|
3111
|
+
u16 = "core::integer::u16",
|
|
3112
|
+
u32 = "core::integer::u32",
|
|
3113
|
+
u64 = "core::integer::u64",
|
|
3114
|
+
u128 = "core::integer::u128",
|
|
3115
|
+
u256 = "core::integer::u256"
|
|
3116
|
+
}
|
|
3117
|
+
declare const isLen: (name: string) => boolean;
|
|
3118
|
+
declare const isTypeFelt: (type: string) => boolean;
|
|
3119
|
+
declare const isTypeArray: (type: string) => boolean;
|
|
3120
|
+
declare const isTypeTuple: (type: string) => boolean;
|
|
3121
|
+
declare const isTypeNamedTuple: (type: string) => boolean;
|
|
3122
|
+
declare const isTypeStruct: (type: string, structs: AbiStructs) => boolean;
|
|
3123
|
+
declare const isTypeUint: (type: string) => boolean;
|
|
3124
|
+
declare const isTypeBool: (type: string) => boolean;
|
|
3125
|
+
declare const isTypeContractAddress: (type: string) => boolean;
|
|
3126
|
+
declare const isCairo1Type: (type: string) => boolean;
|
|
3127
|
+
declare const getArrayType: (type: string) => string;
|
|
3128
|
+
/**
|
|
3129
|
+
* named tuple are described as js object {}
|
|
3130
|
+
* struct types are described as js object {}
|
|
3131
|
+
* array types are described as js array []
|
|
3132
|
+
*/
|
|
3133
|
+
/**
|
|
3134
|
+
* Uint256 cairo type (helper for common struct type)
|
|
3135
|
+
*/
|
|
3136
|
+
declare const uint256: (it: BigNumberish) => Uint256;
|
|
3137
|
+
/**
|
|
3138
|
+
* unnamed tuple cairo type (helper same as common struct type)
|
|
3139
|
+
*/
|
|
3140
|
+
declare const tuple: (...args: (BigNumberish | object)[]) => {
|
|
3141
|
+
[x: number]: object | BigNumberish;
|
|
3142
|
+
length: number;
|
|
3143
|
+
toString(): string;
|
|
3144
|
+
toLocaleString(): string;
|
|
3145
|
+
pop(): object | BigNumberish | undefined;
|
|
3146
|
+
push(...items: (object | BigNumberish)[]): number;
|
|
3147
|
+
concat(...items: ConcatArray<object | BigNumberish>[]): (object | BigNumberish)[];
|
|
3148
|
+
concat(...items: (object | BigNumberish | ConcatArray<object | BigNumberish>)[]): (object | BigNumberish)[];
|
|
3149
|
+
join(separator?: string | undefined): string;
|
|
3150
|
+
reverse(): (object | BigNumberish)[];
|
|
3151
|
+
shift(): object | BigNumberish | undefined;
|
|
3152
|
+
slice(start?: number | undefined, end?: number | undefined): (object | BigNumberish)[];
|
|
3153
|
+
sort(compareFn?: ((a: object | BigNumberish, b: object | BigNumberish) => number) | undefined): (object | BigNumberish)[];
|
|
3154
|
+
splice(start: number, deleteCount?: number | undefined): (object | BigNumberish)[];
|
|
3155
|
+
splice(start: number, deleteCount: number, ...items: (object | BigNumberish)[]): (object | BigNumberish)[];
|
|
3156
|
+
unshift(...items: (object | BigNumberish)[]): number;
|
|
3157
|
+
indexOf(searchElement: object | BigNumberish, fromIndex?: number | undefined): number;
|
|
3158
|
+
lastIndexOf(searchElement: object | BigNumberish, fromIndex?: number | undefined): number;
|
|
3159
|
+
every<S extends object | BigNumberish>(predicate: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => value is S, thisArg?: any): this is S[];
|
|
3160
|
+
every(predicate: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => unknown, thisArg?: any): boolean;
|
|
3161
|
+
some(predicate: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => unknown, thisArg?: any): boolean;
|
|
3162
|
+
forEach(callbackfn: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => void, thisArg?: any): void;
|
|
3163
|
+
map<U>(callbackfn: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => U, thisArg?: any): U[];
|
|
3164
|
+
filter<S_1 extends object | BigNumberish>(predicate: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => value is S_1, thisArg?: any): S_1[];
|
|
3165
|
+
filter(predicate: (value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => unknown, thisArg?: any): (object | BigNumberish)[];
|
|
3166
|
+
reduce(callbackfn: (previousValue: object | BigNumberish, currentValue: object | BigNumberish, currentIndex: number, array: (object | BigNumberish)[]) => object | BigNumberish): object | BigNumberish;
|
|
3167
|
+
reduce(callbackfn: (previousValue: object | BigNumberish, currentValue: object | BigNumberish, currentIndex: number, array: (object | BigNumberish)[]) => object | BigNumberish, initialValue: object | BigNumberish): object | BigNumberish;
|
|
3168
|
+
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: object | BigNumberish, currentIndex: number, array: (object | BigNumberish)[]) => U_1, initialValue: U_1): U_1;
|
|
3169
|
+
reduceRight(callbackfn: (previousValue: object | BigNumberish, currentValue: object | BigNumberish, currentIndex: number, array: (object | BigNumberish)[]) => object | BigNumberish): object | BigNumberish;
|
|
3170
|
+
reduceRight(callbackfn: (previousValue: object | BigNumberish, currentValue: object | BigNumberish, currentIndex: number, array: (object | BigNumberish)[]) => object | BigNumberish, initialValue: object | BigNumberish): object | BigNumberish;
|
|
3171
|
+
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: object | BigNumberish, currentIndex: number, array: (object | BigNumberish)[]) => U_2, initialValue: U_2): U_2;
|
|
3172
|
+
find<S_2 extends object | BigNumberish>(predicate: (this: void, value: object | BigNumberish, index: number, obj: (object | BigNumberish)[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
3173
|
+
find(predicate: (value: object | BigNumberish, index: number, obj: (object | BigNumberish)[]) => unknown, thisArg?: any): object | BigNumberish | undefined;
|
|
3174
|
+
findIndex(predicate: (value: object | BigNumberish, index: number, obj: (object | BigNumberish)[]) => unknown, thisArg?: any): number;
|
|
3175
|
+
fill(value: object | BigNumberish, start?: number | undefined, end?: number | undefined): (object | BigNumberish)[];
|
|
3176
|
+
copyWithin(target: number, start: number, end?: number | undefined): (object | BigNumberish)[];
|
|
3177
|
+
entries(): IterableIterator<[number, object | BigNumberish]>;
|
|
3178
|
+
keys(): IterableIterator<number>;
|
|
3179
|
+
values(): IterableIterator<object | BigNumberish>;
|
|
3180
|
+
includes(searchElement: object | BigNumberish, fromIndex?: number | undefined): boolean;
|
|
3181
|
+
flatMap<U_3, This = undefined>(callback: (this: This, value: object | BigNumberish, index: number, array: (object | BigNumberish)[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
|
3182
|
+
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
3183
|
+
[Symbol.iterator](): IterableIterator<object | BigNumberish>;
|
|
3184
|
+
[Symbol.unscopables](): {
|
|
3185
|
+
copyWithin: boolean;
|
|
3186
|
+
entries: boolean;
|
|
3187
|
+
fill: boolean;
|
|
3188
|
+
find: boolean;
|
|
3189
|
+
findIndex: boolean;
|
|
3190
|
+
keys: boolean;
|
|
3191
|
+
values: boolean;
|
|
3192
|
+
};
|
|
3193
|
+
at(index: number): object | BigNumberish | undefined;
|
|
3194
|
+
};
|
|
3195
|
+
/**
|
|
3196
|
+
* felt cairo type
|
|
3197
|
+
*/
|
|
3198
|
+
declare function felt(it: BigNumberish): string;
|
|
3199
|
+
|
|
3200
|
+
type cairo_Uint = Uint;
|
|
3201
|
+
declare const cairo_Uint: typeof Uint;
|
|
3202
|
+
declare const cairo_isLen: typeof isLen;
|
|
3203
|
+
declare const cairo_isTypeFelt: typeof isTypeFelt;
|
|
3204
|
+
declare const cairo_isTypeArray: typeof isTypeArray;
|
|
3205
|
+
declare const cairo_isTypeTuple: typeof isTypeTuple;
|
|
3206
|
+
declare const cairo_isTypeNamedTuple: typeof isTypeNamedTuple;
|
|
3207
|
+
declare const cairo_isTypeStruct: typeof isTypeStruct;
|
|
3208
|
+
declare const cairo_isTypeUint: typeof isTypeUint;
|
|
3209
|
+
declare const cairo_isTypeBool: typeof isTypeBool;
|
|
3210
|
+
declare const cairo_isTypeContractAddress: typeof isTypeContractAddress;
|
|
3211
|
+
declare const cairo_isCairo1Type: typeof isCairo1Type;
|
|
3212
|
+
declare const cairo_getArrayType: typeof getArrayType;
|
|
3213
|
+
declare const cairo_uint256: typeof uint256;
|
|
3214
|
+
declare const cairo_tuple: typeof tuple;
|
|
3215
|
+
declare const cairo_felt: typeof felt;
|
|
3216
|
+
declare namespace cairo {
|
|
3217
|
+
export {
|
|
3218
|
+
cairo_Uint as Uint,
|
|
3219
|
+
cairo_isLen as isLen,
|
|
3220
|
+
cairo_isTypeFelt as isTypeFelt,
|
|
3221
|
+
cairo_isTypeArray as isTypeArray,
|
|
3222
|
+
cairo_isTypeTuple as isTypeTuple,
|
|
3223
|
+
cairo_isTypeNamedTuple as isTypeNamedTuple,
|
|
3224
|
+
cairo_isTypeStruct as isTypeStruct,
|
|
3225
|
+
cairo_isTypeUint as isTypeUint,
|
|
3226
|
+
cairo_isTypeBool as isTypeBool,
|
|
3227
|
+
cairo_isTypeContractAddress as isTypeContractAddress,
|
|
3228
|
+
cairo_isCairo1Type as isCairo1Type,
|
|
3229
|
+
cairo_getArrayType as getArrayType,
|
|
3230
|
+
cairo_uint256 as uint256,
|
|
3231
|
+
cairo_tuple as tuple,
|
|
3232
|
+
cairo_felt as felt,
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3107
3236
|
declare class CallData {
|
|
3108
3237
|
abi: Abi;
|
|
3109
3238
|
protected readonly structs: AbiStructs;
|
|
@@ -3136,7 +3265,7 @@ declare class CallData {
|
|
|
3136
3265
|
* @param response - response from the method
|
|
3137
3266
|
* @return - parsed response corresponding to the abi
|
|
3138
3267
|
*/
|
|
3139
|
-
parse(method: string, response: string[]):
|
|
3268
|
+
parse(method: string, response: string[]): Result;
|
|
3140
3269
|
/**
|
|
3141
3270
|
* Format cairo method response data to native js values based on provided format schema
|
|
3142
3271
|
* @param method - cairo method name
|
|
@@ -3156,4 +3285,4 @@ declare class CallData {
|
|
|
3156
3285
|
/** @deprecated prefer the 'num' naming */
|
|
3157
3286
|
declare const number: typeof num;
|
|
3158
3287
|
|
|
3159
|
-
export { Abi, AbiEntry, AbiStructs, Account, AccountInterface, AllowArray, Args, ArraySignatureType, AsyncContractFunction, BlockNumber, BlockTag, Builtins, ByteCode, CairoAssembly, CairoContract, CairoVersion, Call, CallContractResponse, CallData, CallDetails, CallL1Handler, CallOptions, CallStruct, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompiledSierra, CompiledSierraCasm, CompleteDeclareContractPayload, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractEntryPointFields, ContractFactory, ContractFunction, ContractInterface, CustomError, DeclareAndDeployContractPayload, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, DeployContractUDCResponse, DeployedContractItem, Details, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HttpError, Invocation, InvocationBulk, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, Nonce, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, PythonicHints, RPC, RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, Sequencer, SequencerHttpMethod, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, SierraContractClass, SierraContractEntryPointFields, SierraEntryPointsByType, SierraProgramDebugInfo, Signature, Signer, SignerInterface, StateUpdateResponse, Status, Storage, Struct, StructAbi, TransactionBulk, TransactionSimulation, TransactionSimulationResponse, TransactionStatus, TransactionTraceResponse, TransactionType, Tupled, UniversalDeployerContractPayload, WeierstrassSignatureType, addAddressPadding, buildUrl, constants, defaultProvider, ec, encode, fixProto, fixStack, getChecksumAddress, hash, isUrl, json, merkle, num, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
|
|
3288
|
+
export { Abi, AbiEntry, AbiStructs, Account, AccountInterface, AllowArray, Args, ArraySignatureType, AsyncContractFunction, BlockNumber, BlockTag, Builtins, ByteCode, CairoAssembly, CairoContract, CairoVersion, Call, CallContractResponse, CallData, CallDetails, CallL1Handler, CallOptions, CallStruct, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompiledSierra, CompiledSierraCasm, CompleteDeclareContractPayload, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractEntryPointFields, ContractFactory, ContractFunction, ContractInterface, CustomError, DeclareAndDeployContractPayload, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, DeployContractUDCResponse, DeployedContractItem, Details, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HttpError, Invocation, InvocationBulk, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, Nonce, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, PythonicHints, RPC, RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, Sequencer, SequencerHttpMethod, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, SierraContractClass, SierraContractEntryPointFields, SierraEntryPointsByType, SierraProgramDebugInfo, Signature, Signer, SignerInterface, StateUpdateResponse, Status, Storage, Struct, StructAbi, TransactionBulk, TransactionSimulation, TransactionSimulationResponse, TransactionStatus, TransactionTraceResponse, TransactionType, Tupled, UniversalDeployerContractPayload, WeierstrassSignatureType, addAddressPadding, buildUrl, cairo, constants, defaultProvider, ec, encode, fixProto, fixStack, getChecksumAddress, hash, isUrl, json, merkle, num, number, shortString, stark, transaction, index as typedData, uint256$1 as uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
|
package/dist/index.global.js
CHANGED
|
@@ -630,6 +630,7 @@ var starknet = (() => {
|
|
|
630
630
|
TransactionType: () => TransactionType,
|
|
631
631
|
addAddressPadding: () => addAddressPadding,
|
|
632
632
|
buildUrl: () => buildUrl,
|
|
633
|
+
cairo: () => cairo_exports,
|
|
633
634
|
constants: () => constants_exports,
|
|
634
635
|
defaultProvider: () => defaultProvider,
|
|
635
636
|
ec: () => ec_exports,
|
|
@@ -5309,6 +5310,26 @@ var starknet = (() => {
|
|
|
5309
5310
|
]
|
|
5310
5311
|
];
|
|
5311
5312
|
|
|
5313
|
+
// src/utils/calldata/cairo.ts
|
|
5314
|
+
var cairo_exports = {};
|
|
5315
|
+
__export(cairo_exports, {
|
|
5316
|
+
Uint: () => Uint,
|
|
5317
|
+
felt: () => felt,
|
|
5318
|
+
getArrayType: () => getArrayType,
|
|
5319
|
+
isCairo1Type: () => isCairo1Type,
|
|
5320
|
+
isLen: () => isLen,
|
|
5321
|
+
isTypeArray: () => isTypeArray,
|
|
5322
|
+
isTypeBool: () => isTypeBool,
|
|
5323
|
+
isTypeContractAddress: () => isTypeContractAddress,
|
|
5324
|
+
isTypeFelt: () => isTypeFelt,
|
|
5325
|
+
isTypeNamedTuple: () => isTypeNamedTuple,
|
|
5326
|
+
isTypeStruct: () => isTypeStruct,
|
|
5327
|
+
isTypeTuple: () => isTypeTuple,
|
|
5328
|
+
isTypeUint: () => isTypeUint,
|
|
5329
|
+
tuple: () => tuple,
|
|
5330
|
+
uint256: () => uint256
|
|
5331
|
+
});
|
|
5332
|
+
|
|
5312
5333
|
// src/utils/num.ts
|
|
5313
5334
|
var num_exports = {};
|
|
5314
5335
|
__export(num_exports, {
|
|
@@ -5464,8 +5485,8 @@ var starknet = (() => {
|
|
|
5464
5485
|
isUint256: () => isUint256,
|
|
5465
5486
|
uint256ToBN: () => uint256ToBN
|
|
5466
5487
|
});
|
|
5467
|
-
function uint256ToBN(
|
|
5468
|
-
return (toBigInt(
|
|
5488
|
+
function uint256ToBN(uint2562) {
|
|
5489
|
+
return (toBigInt(uint2562.high) << 128n) + toBigInt(uint2562.low);
|
|
5469
5490
|
}
|
|
5470
5491
|
var UINT_128_MAX = (1n << 128n) - 1n;
|
|
5471
5492
|
var UINT_256_MAX = (1n << 256n) - 1n;
|
|
@@ -5483,13 +5504,41 @@ var starknet = (() => {
|
|
|
5483
5504
|
}
|
|
5484
5505
|
|
|
5485
5506
|
// src/utils/calldata/cairo.ts
|
|
5507
|
+
var Uint = /* @__PURE__ */ ((Uint2) => {
|
|
5508
|
+
Uint2["u8"] = "core::integer::u8";
|
|
5509
|
+
Uint2["u16"] = "core::integer::u16";
|
|
5510
|
+
Uint2["u32"] = "core::integer::u32";
|
|
5511
|
+
Uint2["u64"] = "core::integer::u64";
|
|
5512
|
+
Uint2["u128"] = "core::integer::u128";
|
|
5513
|
+
Uint2["u256"] = "core::integer::u256";
|
|
5514
|
+
return Uint2;
|
|
5515
|
+
})(Uint || {});
|
|
5486
5516
|
var isLen = (name) => /_len$/.test(name);
|
|
5487
|
-
var isTypeFelt = (type) => type === "felt";
|
|
5488
|
-
var
|
|
5489
|
-
var isTypeArray = (type) => /\*/.test(type);
|
|
5517
|
+
var isTypeFelt = (type) => type === "felt" || type === "core::felt252";
|
|
5518
|
+
var isTypeArray = (type) => /\*/.test(type) || type.includes("core::array::Array::");
|
|
5490
5519
|
var isTypeTuple = (type) => /^\(.*\)$/i.test(type);
|
|
5491
5520
|
var isTypeNamedTuple = (type) => /\(.*\)/i.test(type) && type.includes(":");
|
|
5492
5521
|
var isTypeStruct = (type, structs) => type in structs;
|
|
5522
|
+
var isTypeUint = (type) => Object.values(Uint).includes(type);
|
|
5523
|
+
var isTypeBool = (type) => type === "core::bool";
|
|
5524
|
+
var isTypeContractAddress = (type) => type === "core::starknet::contract_address::ContractAddress";
|
|
5525
|
+
var isCairo1Type = (type) => type.includes("core::");
|
|
5526
|
+
var getArrayType = (type) => {
|
|
5527
|
+
if (isCairo1Type(type)) {
|
|
5528
|
+
return type.substring(type.indexOf("<") + 1, type.indexOf(">"));
|
|
5529
|
+
}
|
|
5530
|
+
return type.replace("*", "");
|
|
5531
|
+
};
|
|
5532
|
+
var uint256 = (it) => {
|
|
5533
|
+
const bn = BigInt(it);
|
|
5534
|
+
if (!isUint256(bn))
|
|
5535
|
+
throw new Error("Number is too large");
|
|
5536
|
+
return {
|
|
5537
|
+
low: (bn & UINT_128_MAX).toString(10),
|
|
5538
|
+
high: (bn >> 128n).toString(10)
|
|
5539
|
+
};
|
|
5540
|
+
};
|
|
5541
|
+
var tuple = (...args) => ({ ...args });
|
|
5493
5542
|
function felt(it) {
|
|
5494
5543
|
if (isBigInt(it) || typeof it === "number" && Number.isInteger(it)) {
|
|
5495
5544
|
return it.toString();
|
|
@@ -11998,7 +12047,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
11998
12047
|
result
|
|
11999
12048
|
};
|
|
12000
12049
|
}
|
|
12001
|
-
function
|
|
12050
|
+
function extractCairo0Tuple(type) {
|
|
12002
12051
|
const cleanType = type.replace(/\s/g, "").slice(1, -1);
|
|
12003
12052
|
const { subTuple, result } = parseSubTuple(cleanType);
|
|
12004
12053
|
let recomposed = result.split(",").map((it) => {
|
|
@@ -12011,6 +12060,16 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12011
12060
|
}
|
|
12012
12061
|
return recomposed;
|
|
12013
12062
|
}
|
|
12063
|
+
function extractCairo1Tuple(type) {
|
|
12064
|
+
const cleanType = type.replace(/\s/g, "").slice(1, -1);
|
|
12065
|
+
return cleanType.split(",");
|
|
12066
|
+
}
|
|
12067
|
+
function extractTupleMemberTypes(type) {
|
|
12068
|
+
if (isCairo1Type(type)) {
|
|
12069
|
+
return extractCairo1Tuple(type);
|
|
12070
|
+
}
|
|
12071
|
+
return extractCairo0Tuple(type);
|
|
12072
|
+
}
|
|
12014
12073
|
|
|
12015
12074
|
// src/utils/calldata/requestParser.ts
|
|
12016
12075
|
function parseTuple(element, typeStr) {
|
|
@@ -12069,16 +12128,21 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12069
12128
|
}
|
|
12070
12129
|
const result = [];
|
|
12071
12130
|
result.push(felt(value.length));
|
|
12131
|
+
const arrayType = getArrayType(input.type);
|
|
12072
12132
|
return value.reduce((acc, el) => {
|
|
12073
|
-
if (
|
|
12133
|
+
if (isTypeFelt(arrayType) || isTypeUint(arrayType) || isTypeContractAddress(arrayType)) {
|
|
12074
12134
|
acc.push(felt(el));
|
|
12135
|
+
} else if (isTypeBool(arrayType) && typeof el === "boolean") {
|
|
12136
|
+
acc.push(el.toString());
|
|
12075
12137
|
} else {
|
|
12076
|
-
acc.push(...parseCalldataValue(el,
|
|
12138
|
+
acc.push(...parseCalldataValue(el, arrayType, structs));
|
|
12077
12139
|
}
|
|
12078
12140
|
return acc;
|
|
12079
12141
|
}, result);
|
|
12080
12142
|
case (isTypeStruct(type, structs) || isTypeTuple(type)):
|
|
12081
12143
|
return parseCalldataValue(value, type, structs);
|
|
12144
|
+
case isTypeBool(type):
|
|
12145
|
+
return value;
|
|
12082
12146
|
default:
|
|
12083
12147
|
return felt(value);
|
|
12084
12148
|
}
|
|
@@ -12111,8 +12175,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12111
12175
|
case isLen(name):
|
|
12112
12176
|
temp = responseIterator.next().value;
|
|
12113
12177
|
return BigInt(temp);
|
|
12178
|
+
case isTypeBool(type):
|
|
12179
|
+
temp = responseIterator.next().value;
|
|
12180
|
+
return Boolean(BigInt(temp));
|
|
12114
12181
|
case isTypeArray(type):
|
|
12115
12182
|
const parsedDataArr = [];
|
|
12183
|
+
if (isCairo1Type(type)) {
|
|
12184
|
+
responseIterator.next();
|
|
12185
|
+
let it = responseIterator.next();
|
|
12186
|
+
while (!it.done) {
|
|
12187
|
+
parsedDataArr.push(BigInt(it.value));
|
|
12188
|
+
it = responseIterator.next();
|
|
12189
|
+
}
|
|
12190
|
+
return parsedDataArr;
|
|
12191
|
+
}
|
|
12116
12192
|
if (parsedResult && parsedResult[`${name}_len`]) {
|
|
12117
12193
|
const arrLen = parsedResult[`${name}_len`];
|
|
12118
12194
|
while (parsedDataArr.length < arrLen) {
|
|
@@ -12134,7 +12210,66 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12134
12210
|
var validateFelt = (parameter, input) => {
|
|
12135
12211
|
assert2(
|
|
12136
12212
|
typeof parameter === "string" || typeof parameter === "number" || typeof parameter === "bigint",
|
|
12137
|
-
`Validate: arg ${input.name} should be a felt (
|
|
12213
|
+
`Validate: arg ${input.name} should be a felt typed as (String, Number or BigInt)`
|
|
12214
|
+
);
|
|
12215
|
+
};
|
|
12216
|
+
var validateUint = (parameter, input) => {
|
|
12217
|
+
if (typeof parameter === "number") {
|
|
12218
|
+
assert2(
|
|
12219
|
+
parameter <= Number.MAX_SAFE_INTEGER,
|
|
12220
|
+
`Validation: Parameter is to large to be typed as Number use (BigInt or String)`
|
|
12221
|
+
);
|
|
12222
|
+
}
|
|
12223
|
+
assert2(
|
|
12224
|
+
typeof parameter === "string" || typeof parameter === "number" || typeof parameter === "bigint",
|
|
12225
|
+
`Validate: arg ${input.name} of cairo type ${input.type} should be type (String, Number or BigInt)`
|
|
12226
|
+
);
|
|
12227
|
+
const param = toBigInt(parameter);
|
|
12228
|
+
switch (input.type) {
|
|
12229
|
+
case "core::integer::u8" /* u8 */:
|
|
12230
|
+
assert2(
|
|
12231
|
+
param >= 0n && param <= 255n,
|
|
12232
|
+
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0 - 255]`
|
|
12233
|
+
);
|
|
12234
|
+
break;
|
|
12235
|
+
case "core::integer::u16" /* u16 */:
|
|
12236
|
+
assert2(
|
|
12237
|
+
param >= 0n && param <= 65535n,
|
|
12238
|
+
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 65535]`
|
|
12239
|
+
);
|
|
12240
|
+
break;
|
|
12241
|
+
case "core::integer::u32" /* u32 */:
|
|
12242
|
+
assert2(
|
|
12243
|
+
param >= 0n && param <= 4294967295n,
|
|
12244
|
+
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 4294967295]`
|
|
12245
|
+
);
|
|
12246
|
+
break;
|
|
12247
|
+
case "core::integer::u64" /* u64 */:
|
|
12248
|
+
assert2(
|
|
12249
|
+
param >= 0n && param <= 2n ** 64n - 1n,
|
|
12250
|
+
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^64-1]`
|
|
12251
|
+
);
|
|
12252
|
+
break;
|
|
12253
|
+
case "core::integer::u128" /* u128 */:
|
|
12254
|
+
assert2(
|
|
12255
|
+
param >= 0n && param <= 2n ** 128n - 1n,
|
|
12256
|
+
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^128-1]`
|
|
12257
|
+
);
|
|
12258
|
+
break;
|
|
12259
|
+
case "core::integer::u256" /* u256 */:
|
|
12260
|
+
assert2(
|
|
12261
|
+
param >= 0n && param <= 2n ** 256n - 1n,
|
|
12262
|
+
`Validate: arg ${input.name} is ${input.type} 0 - 2^256-1`
|
|
12263
|
+
);
|
|
12264
|
+
break;
|
|
12265
|
+
default:
|
|
12266
|
+
break;
|
|
12267
|
+
}
|
|
12268
|
+
};
|
|
12269
|
+
var validateBool = (parameter, input) => {
|
|
12270
|
+
assert2(
|
|
12271
|
+
typeof parameter === "boolean",
|
|
12272
|
+
`Validate: arg ${input.name} of cairo type ${input.type} should be type (Boolean)`
|
|
12138
12273
|
);
|
|
12139
12274
|
};
|
|
12140
12275
|
var validateStruct = (parameter, input, structs) => {
|
|
@@ -12156,7 +12291,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12156
12291
|
);
|
|
12157
12292
|
};
|
|
12158
12293
|
var validateArray = (parameter, input, structs) => {
|
|
12159
|
-
const baseType = input.type
|
|
12294
|
+
const baseType = getArrayType(input.type);
|
|
12160
12295
|
if (isTypeFelt(baseType) && isLongText(parameter))
|
|
12161
12296
|
return;
|
|
12162
12297
|
assert2(Array.isArray(parameter), `Validate: arg ${input.name} should be an Array`);
|
|
@@ -12172,6 +12307,12 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12172
12307
|
(it) => validateStruct(it, { name: input.name, type: baseType }, structs)
|
|
12173
12308
|
);
|
|
12174
12309
|
break;
|
|
12310
|
+
case isTypeUint(baseType):
|
|
12311
|
+
parameter.forEach((param) => validateUint(param, input));
|
|
12312
|
+
break;
|
|
12313
|
+
case isTypeBool(baseType):
|
|
12314
|
+
parameter.forEach((param) => validateBool(param, input));
|
|
12315
|
+
break;
|
|
12175
12316
|
default:
|
|
12176
12317
|
throw new Error(
|
|
12177
12318
|
`Validate Unhandled: argument ${input.name}, type ${input.type}, value ${parameter}`
|
|
@@ -12187,6 +12328,14 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12187
12328
|
case isTypeFelt(input.type):
|
|
12188
12329
|
validateFelt(parameter, input);
|
|
12189
12330
|
break;
|
|
12331
|
+
case isTypeUint(input.type):
|
|
12332
|
+
validateUint(parameter, input);
|
|
12333
|
+
break;
|
|
12334
|
+
case isTypeBool(input.type):
|
|
12335
|
+
validateBool(parameter, input);
|
|
12336
|
+
break;
|
|
12337
|
+
case isTypeContractAddress(input.type):
|
|
12338
|
+
break;
|
|
12190
12339
|
case isTypeStruct(input.type, structs):
|
|
12191
12340
|
validateStruct(parameter, input, structs);
|
|
12192
12341
|
break;
|
|
@@ -12275,13 +12424,15 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12275
12424
|
parse(method, response) {
|
|
12276
12425
|
const { outputs } = this.abi.find((abi) => abi.name === method);
|
|
12277
12426
|
const responseIterator = response.flat()[Symbol.iterator]();
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12427
|
+
const parsed = outputs.flat().reduce((acc, output2, idx) => {
|
|
12428
|
+
const propName = output2.name ?? idx;
|
|
12429
|
+
acc[propName] = responseParser(responseIterator, output2, this.structs, acc);
|
|
12430
|
+
if (acc[propName] && acc[`${propName}_len`]) {
|
|
12431
|
+
delete acc[`${propName}_len`];
|
|
12282
12432
|
}
|
|
12283
12433
|
return acc;
|
|
12284
12434
|
}, {});
|
|
12435
|
+
return Object.keys(parsed).length === 1 && 0 in parsed ? parsed[0] : parsed;
|
|
12285
12436
|
}
|
|
12286
12437
|
format(method, response, format) {
|
|
12287
12438
|
const parsed = this.parse(method, response);
|
|
@@ -12353,13 +12504,20 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
12353
12504
|
return contract.estimate(functionAbi.name, args);
|
|
12354
12505
|
};
|
|
12355
12506
|
}
|
|
12507
|
+
var detectCairoVersion = (abi) => {
|
|
12508
|
+
if (!abi)
|
|
12509
|
+
return "0";
|
|
12510
|
+
return abi.find((it) => "state_mutability" in it) ? "1" : "0";
|
|
12511
|
+
};
|
|
12356
12512
|
var Contract = class {
|
|
12357
|
-
constructor(abi, address, providerOrAccount = defaultProvider) {
|
|
12513
|
+
constructor(abi, address, providerOrAccount = defaultProvider, cairoVersion = detectCairoVersion(abi)) {
|
|
12514
|
+
this.version = "0";
|
|
12358
12515
|
this.address = address && address.toLowerCase();
|
|
12359
12516
|
this.providerOrAccount = providerOrAccount;
|
|
12360
12517
|
this.callData = new CallData(abi);
|
|
12361
12518
|
this.structs = CallData.getAbiStruct(abi);
|
|
12362
12519
|
this.abi = abi;
|
|
12520
|
+
this.version = cairoVersion;
|
|
12363
12521
|
const options = { enumerable: true, value: {}, writable: false };
|
|
12364
12522
|
Object.defineProperties(this, {
|
|
12365
12523
|
functions: { enumerable: true, value: {}, writable: false },
|