starknet 5.15.0 → 5.16.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 +14 -0
- package/dist/index.d.ts +49 -21
- package/dist/index.global.js +159 -43
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +162 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [5.16.0](https://github.com/0xs34n/starknet.js/compare/v5.15.1...v5.16.0) (2023-07-03)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- cairo1 version2 support ([e564033](https://github.com/0xs34n/starknet.js/commit/e564033273ac49e971bbf1db843fb3de236976c0))
|
|
6
|
+
- extract parser from CallData and Cairo ([b7eba2a](https://github.com/0xs34n/starknet.js/commit/b7eba2a1eada3dddb4dc0575c16ac76a42a78678))
|
|
7
|
+
- parsers ([cce9029](https://github.com/0xs34n/starknet.js/commit/cce90299e59e60090b568be14331378de3918924))
|
|
8
|
+
|
|
9
|
+
## [5.15.1](https://github.com/0xs34n/starknet.js/compare/v5.15.0...v5.15.1) (2023-06-29)
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- eradicate static strings ([597d2b5](https://github.com/0xs34n/starknet.js/commit/597d2b525709c0fa2607af70b6f8b6289fb32448))
|
|
14
|
+
|
|
1
15
|
# [5.15.0](https://github.com/0xs34n/starknet.js/compare/v5.14.1...v5.15.0) (2023-06-29)
|
|
2
16
|
|
|
3
17
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -391,7 +391,10 @@ declare enum BlockStatus {
|
|
|
391
391
|
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2",
|
|
392
392
|
REJECTED = "REJECTED"
|
|
393
393
|
}
|
|
394
|
-
|
|
394
|
+
declare enum BlockTag {
|
|
395
|
+
pending = "pending",
|
|
396
|
+
latest = "latest"
|
|
397
|
+
}
|
|
395
398
|
type BlockNumber = BlockTag | null | number;
|
|
396
399
|
/**
|
|
397
400
|
* hex string and BN are detected as block hashes
|
|
@@ -1877,6 +1880,20 @@ interface TypedData {
|
|
|
1877
1880
|
message: Record<string, unknown>;
|
|
1878
1881
|
}
|
|
1879
1882
|
|
|
1883
|
+
declare enum ValidateType {
|
|
1884
|
+
DEPLOY = "DEPLOY",
|
|
1885
|
+
CALL = "CALL",
|
|
1886
|
+
INVOKE = "INVOKE"
|
|
1887
|
+
}
|
|
1888
|
+
declare enum Uint {
|
|
1889
|
+
u8 = "core::integer::u8",
|
|
1890
|
+
u16 = "core::integer::u16",
|
|
1891
|
+
u32 = "core::integer::u32",
|
|
1892
|
+
u64 = "core::integer::u64",
|
|
1893
|
+
u128 = "core::integer::u128",
|
|
1894
|
+
u256 = "core::integer::u256"
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1880
1897
|
type index_Abi = Abi;
|
|
1881
1898
|
type index_AbiEntry = AbiEntry;
|
|
1882
1899
|
type index_AbiStructs = AbiStructs;
|
|
@@ -1895,6 +1912,7 @@ type index_BlockNumber = BlockNumber;
|
|
|
1895
1912
|
type index_BlockStatus = BlockStatus;
|
|
1896
1913
|
declare const index_BlockStatus: typeof BlockStatus;
|
|
1897
1914
|
type index_BlockTag = BlockTag;
|
|
1915
|
+
declare const index_BlockTag: typeof BlockTag;
|
|
1898
1916
|
type index_Builtins = Builtins;
|
|
1899
1917
|
type index_ByteCode = ByteCode;
|
|
1900
1918
|
type index_CairoAssembly = CairoAssembly;
|
|
@@ -2010,8 +2028,12 @@ type index_TransactionType = TransactionType;
|
|
|
2010
2028
|
declare const index_TransactionType: typeof TransactionType;
|
|
2011
2029
|
type index_Tupled = Tupled;
|
|
2012
2030
|
type index_TypedData = TypedData;
|
|
2031
|
+
type index_Uint = Uint;
|
|
2032
|
+
declare const index_Uint: typeof Uint;
|
|
2013
2033
|
type index_Uint256 = Uint256;
|
|
2014
2034
|
type index_UniversalDeployerContractPayload = UniversalDeployerContractPayload;
|
|
2035
|
+
type index_ValidateType = ValidateType;
|
|
2036
|
+
declare const index_ValidateType: typeof ValidateType;
|
|
2015
2037
|
type index_WeierstrassSignatureType = WeierstrassSignatureType;
|
|
2016
2038
|
type index_getEstimateFeeBulkOptions = getEstimateFeeBulkOptions;
|
|
2017
2039
|
type index_getSimulateTransactionOptions = getSimulateTransactionOptions;
|
|
@@ -2146,8 +2168,10 @@ declare namespace index {
|
|
|
2146
2168
|
index_TransactionType as TransactionType,
|
|
2147
2169
|
index_Tupled as Tupled,
|
|
2148
2170
|
index_TypedData as TypedData,
|
|
2171
|
+
index_Uint as Uint,
|
|
2149
2172
|
index_Uint256 as Uint256,
|
|
2150
2173
|
index_UniversalDeployerContractPayload as UniversalDeployerContractPayload,
|
|
2174
|
+
index_ValidateType as ValidateType,
|
|
2151
2175
|
index_WeierstrassSignatureType as WeierstrassSignatureType,
|
|
2152
2176
|
index_getEstimateFeeBulkOptions as getEstimateFeeBulkOptions,
|
|
2153
2177
|
index_getSimulateTransactionOptions as getSimulateTransactionOptions,
|
|
@@ -3169,7 +3193,7 @@ declare function getVersionsByType(versionType?: 'fee' | 'transaction'): {
|
|
|
3169
3193
|
};
|
|
3170
3194
|
declare function computeHashOnElements(data: BigNumberish[]): string;
|
|
3171
3195
|
declare function calculateTransactionHashCommon(txHashPrefix: TransactionHashPrefix, version: BigNumberish, contractAddress: BigNumberish, entryPointSelector: BigNumberish, calldata: RawCalldata, maxFee: BigNumberish, chainId: StarknetChainId, additionalData?: BigNumberish[]): string;
|
|
3172
|
-
declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: RawCalldata, version: BigNumberish, chainId: StarknetChainId): string;
|
|
3196
|
+
declare function calculateDeployTransactionHash(contractAddress: BigNumberish, constructorCalldata: RawCalldata, version: BigNumberish, chainId: StarknetChainId, constructorName?: string): string;
|
|
3173
3197
|
declare function calculateDeclareTransactionHash(classHash: string, senderAddress: BigNumberish, version: BigNumberish, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish, compiledClassHash?: string): string;
|
|
3174
3198
|
declare function calculateDeployAccountTransactionHash(contractAddress: BigNumberish, classHash: BigNumberish, constructorCalldata: RawCalldata, salt: BigNumberish, version: BigNumberish, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
|
|
3175
3199
|
declare function calculateTransactionHash(contractAddress: BigNumberish, version: BigNumberish, calldata: RawCalldata, maxFee: BigNumberish, chainId: StarknetChainId, nonce: BigNumberish): string;
|
|
@@ -3685,14 +3709,26 @@ declare function validateChecksumAddress(address: string): boolean;
|
|
|
3685
3709
|
declare function isUrl(s?: string): boolean;
|
|
3686
3710
|
declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
|
|
3687
3711
|
|
|
3688
|
-
declare
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3712
|
+
declare abstract class AbiParserInterface {
|
|
3713
|
+
/**
|
|
3714
|
+
* Helper to calculate inputs length from abi
|
|
3715
|
+
* @param abiMethod FunctionAbi
|
|
3716
|
+
* @return number
|
|
3717
|
+
*/
|
|
3718
|
+
abstract methodInputsLength(abiMethod: FunctionAbi): number;
|
|
3719
|
+
/**
|
|
3720
|
+
*
|
|
3721
|
+
* @param name string
|
|
3722
|
+
* @return FunctionAbi | undefined
|
|
3723
|
+
*/
|
|
3724
|
+
abstract getMethod(name: string): FunctionAbi | undefined;
|
|
3725
|
+
/**
|
|
3726
|
+
* Return Abi in legacy format
|
|
3727
|
+
* @return Abi
|
|
3728
|
+
*/
|
|
3729
|
+
abstract getLegacyFormat(): Abi;
|
|
3695
3730
|
}
|
|
3731
|
+
|
|
3696
3732
|
declare const isLen: (name: string) => boolean;
|
|
3697
3733
|
declare const isTypeFelt: (type: string) => boolean;
|
|
3698
3734
|
declare const isTypeArray: (type: string) => boolean;
|
|
@@ -3734,8 +3770,6 @@ declare const tuple: (...args: (BigNumberish | object | boolean)[]) => Record<nu
|
|
|
3734
3770
|
*/
|
|
3735
3771
|
declare function felt(it: BigNumberish): string;
|
|
3736
3772
|
|
|
3737
|
-
type cairo_Uint = Uint;
|
|
3738
|
-
declare const cairo_Uint: typeof Uint;
|
|
3739
3773
|
declare const cairo_felt: typeof felt;
|
|
3740
3774
|
declare const cairo_getArrayType: typeof getArrayType;
|
|
3741
3775
|
declare const cairo_isCairo1Abi: typeof isCairo1Abi;
|
|
@@ -3754,7 +3788,6 @@ declare const cairo_tuple: typeof tuple;
|
|
|
3754
3788
|
declare const cairo_uint256: typeof uint256;
|
|
3755
3789
|
declare namespace cairo {
|
|
3756
3790
|
export {
|
|
3757
|
-
cairo_Uint as Uint,
|
|
3758
3791
|
cairo_felt as felt,
|
|
3759
3792
|
cairo_getArrayType as getArrayType,
|
|
3760
3793
|
cairo_isCairo1Abi as isCairo1Abi,
|
|
@@ -3776,15 +3809,16 @@ declare namespace cairo {
|
|
|
3776
3809
|
|
|
3777
3810
|
declare class CallData {
|
|
3778
3811
|
abi: Abi;
|
|
3812
|
+
parser: AbiParserInterface;
|
|
3779
3813
|
protected readonly structs: AbiStructs;
|
|
3780
3814
|
constructor(abi: Abi);
|
|
3781
3815
|
/**
|
|
3782
3816
|
* Validate arguments passed to the method as corresponding to the ones in the abi
|
|
3783
|
-
* @param type
|
|
3817
|
+
* @param type ValidateType - type of the method
|
|
3784
3818
|
* @param method string - name of the method
|
|
3785
3819
|
* @param args ArgsOrCalldata - arguments that are passed to the method
|
|
3786
3820
|
*/
|
|
3787
|
-
validate(type:
|
|
3821
|
+
validate(type: ValidateType, method: string, args?: ArgsOrCalldata): void;
|
|
3788
3822
|
/**
|
|
3789
3823
|
* Compile contract callData with abi
|
|
3790
3824
|
* Parse the calldata by using input fields from the abi for that method
|
|
@@ -3821,12 +3855,6 @@ declare class CallData {
|
|
|
3821
3855
|
* @returns Result - parsed and formatted response object
|
|
3822
3856
|
*/
|
|
3823
3857
|
format(method: string, response: string[], format: object): Result;
|
|
3824
|
-
/**
|
|
3825
|
-
* Helper to calculate inputs from abi
|
|
3826
|
-
* @param inputs AbiEntry
|
|
3827
|
-
* @returns number
|
|
3828
|
-
*/
|
|
3829
|
-
static abiInputsLength(inputs: AbiEntry[]): number;
|
|
3830
3858
|
/**
|
|
3831
3859
|
* Helper to extract structs from abi
|
|
3832
3860
|
* @param abi Abi
|
|
@@ -3882,4 +3910,4 @@ declare function parseUDCEvent(txReceipt: InvokeTransactionReceiptResponse): {
|
|
|
3882
3910
|
/** @deprecated prefer the 'num' naming */
|
|
3883
3911
|
declare const number: typeof num;
|
|
3884
3912
|
|
|
3885
|
-
export { Abi, AbiEntry, AbiStructs, Account, AccountInterface, AccountInvocationItem, AccountInvocations, AccountInvocationsFactoryDetails, AllowArray, Args, ArgsOrCalldata, ArgsOrCalldataWithOptions, ArraySignatureType, AsyncContractFunction, BigNumberish, BlockIdentifier, BlockNumber, BlockStatus, BlockTag, Builtins, ByteCode, CairoAssembly, CairoContract, CairoVersion, Call, CallContractResponse, CallData, CallDetails, CallL1Handler, CallOptions, CallStruct, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompiledSierra, CompiledSierraCasm, CompleteDeclareContractPayload, CompressedProgram, Contract, ContractClass, ContractClassResponse, ContractEntryPoint, ContractEntryPointFields, ContractFactory, ContractFunction, ContractInterface, ContractOptions, CustomError, DeclareAndDeployContractPayload, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractResponse, DeployContractUDCResponse, DeployedContractItem, Details, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HexCalldata, HttpError, Invocation, Invocations, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeOptions, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, MultiType, Nonce, OptionalPayload, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, PythonicHints, RPC, RawArgs, RawArgsArray, RawArgsObject, RawCalldata, Result, RpcProvider, RpcProviderOptions, SIMULATION_FLAG, Sequencer, SequencerHttpMethod, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, SierraContractClass, SierraContractEntryPointFields, SierraEntryPointsByType, SierraProgramDebugInfo, Signature, Signer, SignerInterface, SimulateTransactionDetails, SimulateTransactionResponse, SimulatedTransaction, SimulationFlags, StarkNetDomain, StarkNetMerkleType, StarkNetType, StateUpdateResponse, Storage, StructAbi, TransactionStatus, TransactionType, Tupled, TypedData, Uint256, UniversalDeployerContractPayload, WeierstrassSignatureType, addAddressPadding, buildUrl, cairo, constants, contractClassResponseToLegacyCompiledContract, defaultProvider, ec, encode, extractContractHashes, fixProto, fixStack, getCalldata, getChecksumAddress, getEstimateFeeBulkOptions, getSimulateTransactionOptions, hash, isSierra, isUrl, json, merkle, num, number, parseUDCEvent, provider, selector, shortString, splitArgsAndOptions, stark, starknetId, transaction, typedData, index as types, uint256$1 as uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
|
|
3913
|
+
export { Abi, AbiEntry, AbiStructs, Account, AccountInterface, AccountInvocationItem, AccountInvocations, AccountInvocationsFactoryDetails, AllowArray, Args, ArgsOrCalldata, ArgsOrCalldataWithOptions, ArraySignatureType, AsyncContractFunction, BigNumberish, BlockIdentifier, BlockNumber, BlockStatus, BlockTag, Builtins, ByteCode, CairoAssembly, CairoContract, CairoVersion, Call, CallContractResponse, CallData, CallDetails, CallL1Handler, CallOptions, CallStruct, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompiledSierra, CompiledSierraCasm, CompleteDeclareContractPayload, CompressedProgram, Contract, ContractClass, ContractClassResponse, ContractEntryPoint, ContractEntryPointFields, ContractFactory, ContractFunction, ContractInterface, ContractOptions, CustomError, DeclareAndDeployContractPayload, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractResponse, DeployContractUDCResponse, DeployedContractItem, Details, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HexCalldata, HttpError, Invocation, Invocations, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeOptions, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, MultiType, Nonce, OptionalPayload, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, PythonicHints, RPC, RawArgs, RawArgsArray, RawArgsObject, RawCalldata, Result, RpcProvider, RpcProviderOptions, SIMULATION_FLAG, Sequencer, SequencerHttpMethod, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, SierraContractClass, SierraContractEntryPointFields, SierraEntryPointsByType, SierraProgramDebugInfo, Signature, Signer, SignerInterface, SimulateTransactionDetails, SimulateTransactionResponse, SimulatedTransaction, SimulationFlags, StarkNetDomain, StarkNetMerkleType, StarkNetType, StateUpdateResponse, Storage, StructAbi, TransactionStatus, TransactionType, Tupled, TypedData, Uint, Uint256, UniversalDeployerContractPayload, ValidateType, WeierstrassSignatureType, addAddressPadding, buildUrl, cairo, constants, contractClassResponseToLegacyCompiledContract, defaultProvider, ec, encode, extractContractHashes, fixProto, fixStack, getCalldata, getChecksumAddress, getEstimateFeeBulkOptions, getSimulateTransactionOptions, hash, isSierra, isUrl, json, merkle, num, number, parseUDCEvent, provider, selector, shortString, splitArgsAndOptions, stark, starknetId, transaction, typedData, index as types, uint256$1 as uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
|
package/dist/index.global.js
CHANGED
|
@@ -615,6 +615,7 @@ var starknet = (() => {
|
|
|
615
615
|
Account: () => Account,
|
|
616
616
|
AccountInterface: () => AccountInterface,
|
|
617
617
|
BlockStatus: () => BlockStatus,
|
|
618
|
+
BlockTag: () => BlockTag,
|
|
618
619
|
CallData: () => CallData,
|
|
619
620
|
Contract: () => Contract,
|
|
620
621
|
ContractFactory: () => ContractFactory,
|
|
@@ -634,6 +635,8 @@ var starknet = (() => {
|
|
|
634
635
|
SignerInterface: () => SignerInterface,
|
|
635
636
|
TransactionStatus: () => TransactionStatus,
|
|
636
637
|
TransactionType: () => TransactionType,
|
|
638
|
+
Uint: () => Uint,
|
|
639
|
+
ValidateType: () => ValidateType,
|
|
637
640
|
addAddressPadding: () => addAddressPadding,
|
|
638
641
|
buildUrl: () => buildUrl,
|
|
639
642
|
cairo: () => cairo_exports,
|
|
@@ -2836,11 +2839,14 @@ var starknet = (() => {
|
|
|
2836
2839
|
var types_exports = {};
|
|
2837
2840
|
__export(types_exports, {
|
|
2838
2841
|
BlockStatus: () => BlockStatus,
|
|
2842
|
+
BlockTag: () => BlockTag,
|
|
2839
2843
|
EntryPointType: () => EntryPointType,
|
|
2840
2844
|
RPC: () => RPC,
|
|
2841
2845
|
SIMULATION_FLAG: () => SIMULATION_FLAG,
|
|
2842
2846
|
TransactionStatus: () => TransactionStatus,
|
|
2843
|
-
TransactionType: () => TransactionType
|
|
2847
|
+
TransactionType: () => TransactionType,
|
|
2848
|
+
Uint: () => Uint,
|
|
2849
|
+
ValidateType: () => ValidateType
|
|
2844
2850
|
});
|
|
2845
2851
|
|
|
2846
2852
|
// src/types/account.ts
|
|
@@ -2881,6 +2887,11 @@ var starknet = (() => {
|
|
|
2881
2887
|
BlockStatus2["REJECTED"] = "REJECTED";
|
|
2882
2888
|
return BlockStatus2;
|
|
2883
2889
|
})(BlockStatus || {});
|
|
2890
|
+
var BlockTag = /* @__PURE__ */ ((BlockTag2) => {
|
|
2891
|
+
BlockTag2["pending"] = "pending";
|
|
2892
|
+
BlockTag2["latest"] = "latest";
|
|
2893
|
+
return BlockTag2;
|
|
2894
|
+
})(BlockTag || {});
|
|
2884
2895
|
|
|
2885
2896
|
// src/types/api/rpc.ts
|
|
2886
2897
|
var RPC;
|
|
@@ -2895,6 +2906,23 @@ var starknet = (() => {
|
|
|
2895
2906
|
})(TransactionType2 = RPC2.TransactionType || (RPC2.TransactionType = {}));
|
|
2896
2907
|
})(RPC || (RPC = {}));
|
|
2897
2908
|
|
|
2909
|
+
// src/types/calldata.ts
|
|
2910
|
+
var ValidateType = /* @__PURE__ */ ((ValidateType2) => {
|
|
2911
|
+
ValidateType2["DEPLOY"] = "DEPLOY";
|
|
2912
|
+
ValidateType2["CALL"] = "CALL";
|
|
2913
|
+
ValidateType2["INVOKE"] = "INVOKE";
|
|
2914
|
+
return ValidateType2;
|
|
2915
|
+
})(ValidateType || {});
|
|
2916
|
+
var Uint = /* @__PURE__ */ ((Uint2) => {
|
|
2917
|
+
Uint2["u8"] = "core::integer::u8";
|
|
2918
|
+
Uint2["u16"] = "core::integer::u16";
|
|
2919
|
+
Uint2["u32"] = "core::integer::u32";
|
|
2920
|
+
Uint2["u64"] = "core::integer::u64";
|
|
2921
|
+
Uint2["u128"] = "core::integer::u128";
|
|
2922
|
+
Uint2["u256"] = "core::integer::u256";
|
|
2923
|
+
return Uint2;
|
|
2924
|
+
})(Uint || {});
|
|
2925
|
+
|
|
2898
2926
|
// src/utils/assert.ts
|
|
2899
2927
|
function assert(condition, message) {
|
|
2900
2928
|
if (!condition) {
|
|
@@ -5633,7 +5661,6 @@ var starknet = (() => {
|
|
|
5633
5661
|
// src/utils/calldata/cairo.ts
|
|
5634
5662
|
var cairo_exports = {};
|
|
5635
5663
|
__export(cairo_exports, {
|
|
5636
|
-
Uint: () => Uint,
|
|
5637
5664
|
felt: () => felt,
|
|
5638
5665
|
getArrayType: () => getArrayType,
|
|
5639
5666
|
isCairo1Abi: () => isCairo1Abi,
|
|
@@ -5680,15 +5707,6 @@ var starknet = (() => {
|
|
|
5680
5707
|
}
|
|
5681
5708
|
|
|
5682
5709
|
// src/utils/calldata/cairo.ts
|
|
5683
|
-
var Uint = /* @__PURE__ */ ((Uint2) => {
|
|
5684
|
-
Uint2["u8"] = "core::integer::u8";
|
|
5685
|
-
Uint2["u16"] = "core::integer::u16";
|
|
5686
|
-
Uint2["u32"] = "core::integer::u32";
|
|
5687
|
-
Uint2["u64"] = "core::integer::u64";
|
|
5688
|
-
Uint2["u128"] = "core::integer::u128";
|
|
5689
|
-
Uint2["u256"] = "core::integer::u256";
|
|
5690
|
-
return Uint2;
|
|
5691
|
-
})(Uint || {});
|
|
5692
5710
|
var isLen = (name) => /_len$/.test(name);
|
|
5693
5711
|
var isTypeFelt = (type) => type === "felt" || type === "core::felt252";
|
|
5694
5712
|
var isTypeArray = (type) => /\*/.test(type) || type.startsWith("core::array::Array::");
|
|
@@ -5709,6 +5727,9 @@ var starknet = (() => {
|
|
|
5709
5727
|
function isCairo1Abi(abi) {
|
|
5710
5728
|
const firstFunction = abi.find((entry) => entry.type === "function");
|
|
5711
5729
|
if (!firstFunction) {
|
|
5730
|
+
if (abi.find((it) => it.type === "interface")) {
|
|
5731
|
+
return true;
|
|
5732
|
+
}
|
|
5712
5733
|
throw new Error(`Error in ABI. No function in ABI.`);
|
|
5713
5734
|
}
|
|
5714
5735
|
if (firstFunction.inputs.length) {
|
|
@@ -5810,6 +5831,92 @@ var starknet = (() => {
|
|
|
5810
5831
|
}, {});
|
|
5811
5832
|
}
|
|
5812
5833
|
|
|
5834
|
+
// src/utils/calldata/parser/parser-0-1.1.0.ts
|
|
5835
|
+
var AbiParser1 = class {
|
|
5836
|
+
constructor(abi) {
|
|
5837
|
+
this.abi = abi;
|
|
5838
|
+
}
|
|
5839
|
+
/**
|
|
5840
|
+
* abi method inputs length without '_len' inputs
|
|
5841
|
+
* cairo 0 reducer
|
|
5842
|
+
* @param abiMethod FunctionAbi
|
|
5843
|
+
* @returns number
|
|
5844
|
+
*/
|
|
5845
|
+
methodInputsLength(abiMethod) {
|
|
5846
|
+
return abiMethod.inputs.reduce((acc, input) => !isLen(input.name) ? acc + 1 : acc, 0);
|
|
5847
|
+
}
|
|
5848
|
+
/**
|
|
5849
|
+
* get method definition from abi
|
|
5850
|
+
* @param name string
|
|
5851
|
+
* @returns FunctionAbi | undefined
|
|
5852
|
+
*/
|
|
5853
|
+
getMethod(name) {
|
|
5854
|
+
return this.abi.find((it) => it.name === name);
|
|
5855
|
+
}
|
|
5856
|
+
/**
|
|
5857
|
+
* Get Abi in legacy format
|
|
5858
|
+
* @returns Abi
|
|
5859
|
+
*/
|
|
5860
|
+
getLegacyFormat() {
|
|
5861
|
+
return this.abi;
|
|
5862
|
+
}
|
|
5863
|
+
};
|
|
5864
|
+
|
|
5865
|
+
// src/utils/calldata/parser/parser-2.0.0.ts
|
|
5866
|
+
var AbiParser2 = class {
|
|
5867
|
+
constructor(abi) {
|
|
5868
|
+
this.abi = abi;
|
|
5869
|
+
}
|
|
5870
|
+
/**
|
|
5871
|
+
* abi method inputs length
|
|
5872
|
+
* @param abiMethod FunctionAbi
|
|
5873
|
+
* @returns number
|
|
5874
|
+
*/
|
|
5875
|
+
methodInputsLength(abiMethod) {
|
|
5876
|
+
return abiMethod.inputs.length;
|
|
5877
|
+
}
|
|
5878
|
+
/**
|
|
5879
|
+
* get method definition from abi
|
|
5880
|
+
* @param name string
|
|
5881
|
+
* @returns FunctionAbi | undefined
|
|
5882
|
+
*/
|
|
5883
|
+
getMethod(name) {
|
|
5884
|
+
const intf = this.abi.find((it) => it.type === "interface");
|
|
5885
|
+
return intf.items.find((it) => it.name === name);
|
|
5886
|
+
}
|
|
5887
|
+
/**
|
|
5888
|
+
* Get Abi in legacy format
|
|
5889
|
+
* @returns Abi
|
|
5890
|
+
*/
|
|
5891
|
+
getLegacyFormat() {
|
|
5892
|
+
return this.abi.flatMap((e) => {
|
|
5893
|
+
if (e.type === "interface") {
|
|
5894
|
+
return e.items;
|
|
5895
|
+
}
|
|
5896
|
+
return e;
|
|
5897
|
+
});
|
|
5898
|
+
}
|
|
5899
|
+
};
|
|
5900
|
+
|
|
5901
|
+
// src/utils/calldata/parser/index.ts
|
|
5902
|
+
function createAbiParser(abi) {
|
|
5903
|
+
const version = getAbiVersion(abi);
|
|
5904
|
+
if (version === 0 || version === 1) {
|
|
5905
|
+
return new AbiParser1(abi);
|
|
5906
|
+
}
|
|
5907
|
+
if (version === 2) {
|
|
5908
|
+
return new AbiParser2(abi);
|
|
5909
|
+
}
|
|
5910
|
+
throw Error(`Unsupported ABI version ${version}`);
|
|
5911
|
+
}
|
|
5912
|
+
function getAbiVersion(abi) {
|
|
5913
|
+
if (abi.find((it) => it.type === "interface"))
|
|
5914
|
+
return 2;
|
|
5915
|
+
if (isCairo1Abi(abi))
|
|
5916
|
+
return 1;
|
|
5917
|
+
return 0;
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5813
5920
|
// src/utils/calldata/tuple.ts
|
|
5814
5921
|
function parseNamedTuple(namedTuple) {
|
|
5815
5922
|
const name = namedTuple.substring(0, namedTuple.indexOf(":"));
|
|
@@ -5937,7 +6044,7 @@ var starknet = (() => {
|
|
|
5937
6044
|
switch (true) {
|
|
5938
6045
|
case typeInArray in structs:
|
|
5939
6046
|
return myArray.map((myObj) => orderStruct(myObj, structs[typeInArray].members));
|
|
5940
|
-
case typeInArray === "core::integer::u256"
|
|
6047
|
+
case typeInArray === "core::integer::u256" /* u256 */:
|
|
5941
6048
|
return myArray.map((u256) => {
|
|
5942
6049
|
if (typeof u256 !== "object") {
|
|
5943
6050
|
return u256;
|
|
@@ -6038,6 +6145,14 @@ var starknet = (() => {
|
|
|
6038
6145
|
};
|
|
6039
6146
|
});
|
|
6040
6147
|
}
|
|
6148
|
+
function parseUint256(element) {
|
|
6149
|
+
if (typeof element === "object") {
|
|
6150
|
+
const { low, high } = element;
|
|
6151
|
+
return [felt(low), felt(high)];
|
|
6152
|
+
}
|
|
6153
|
+
const el_uint256 = uint256(element);
|
|
6154
|
+
return [felt(el_uint256.low), felt(el_uint256.high)];
|
|
6155
|
+
}
|
|
6041
6156
|
function parseCalldataValue(element, type, structs) {
|
|
6042
6157
|
if (element === void 0) {
|
|
6043
6158
|
throw Error(`Missing parameter for type ${type}`);
|
|
@@ -6051,6 +6166,9 @@ var starknet = (() => {
|
|
|
6051
6166
|
}, result);
|
|
6052
6167
|
}
|
|
6053
6168
|
if (structs[type] && structs[type].members.length) {
|
|
6169
|
+
if (isTypeUint256(type)) {
|
|
6170
|
+
return parseUint256(element);
|
|
6171
|
+
}
|
|
6054
6172
|
const { members } = structs[type];
|
|
6055
6173
|
const subElement = element;
|
|
6056
6174
|
return members.reduce((acc, it) => {
|
|
@@ -6065,12 +6183,7 @@ var starknet = (() => {
|
|
|
6065
6183
|
}, []);
|
|
6066
6184
|
}
|
|
6067
6185
|
if (isTypeUint256(type)) {
|
|
6068
|
-
|
|
6069
|
-
const { low, high } = element;
|
|
6070
|
-
return [felt(low), felt(high)];
|
|
6071
|
-
}
|
|
6072
|
-
const el_uint256 = uint256(element);
|
|
6073
|
-
return [felt(el_uint256.low), felt(el_uint256.high)];
|
|
6186
|
+
return parseUint256(element);
|
|
6074
6187
|
}
|
|
6075
6188
|
if (typeof element === "object") {
|
|
6076
6189
|
throw Error(`Parameter ${element} do not align with abi parameter ${type}`);
|
|
@@ -6113,6 +6226,11 @@ var starknet = (() => {
|
|
|
6113
6226
|
}
|
|
6114
6227
|
}
|
|
6115
6228
|
function parseResponseValue(responseIterator, element, structs) {
|
|
6229
|
+
if (isTypeUint256(element.type)) {
|
|
6230
|
+
const low = responseIterator.next().value;
|
|
6231
|
+
const high = responseIterator.next().value;
|
|
6232
|
+
return uint256ToBN({ low, high });
|
|
6233
|
+
}
|
|
6116
6234
|
if (element.type in structs && structs[element.type]) {
|
|
6117
6235
|
return structs[element.type].members.reduce((acc, el) => {
|
|
6118
6236
|
acc[el.name] = parseResponseValue(responseIterator, el, structs);
|
|
@@ -6239,6 +6357,10 @@ var starknet = (() => {
|
|
|
6239
6357
|
);
|
|
6240
6358
|
};
|
|
6241
6359
|
var validateStruct = (parameter, input, structs) => {
|
|
6360
|
+
if (input.type === "core::integer::u256" /* u256 */) {
|
|
6361
|
+
validateUint(parameter, input);
|
|
6362
|
+
return;
|
|
6363
|
+
}
|
|
6242
6364
|
assert(
|
|
6243
6365
|
typeof parameter === "object" && !Array.isArray(parameter),
|
|
6244
6366
|
`Validate: arg ${input.name} is cairo type struct (${input.type}), and should be defined as js object (not array)`
|
|
@@ -6328,32 +6450,33 @@ var starknet = (() => {
|
|
|
6328
6450
|
// src/utils/calldata/index.ts
|
|
6329
6451
|
var CallData = class {
|
|
6330
6452
|
constructor(abi) {
|
|
6331
|
-
this.abi = abi;
|
|
6332
6453
|
this.structs = CallData.getAbiStruct(abi);
|
|
6454
|
+
this.parser = createAbiParser(abi);
|
|
6455
|
+
this.abi = this.parser.getLegacyFormat();
|
|
6333
6456
|
}
|
|
6334
6457
|
/**
|
|
6335
6458
|
* Validate arguments passed to the method as corresponding to the ones in the abi
|
|
6336
|
-
* @param type
|
|
6459
|
+
* @param type ValidateType - type of the method
|
|
6337
6460
|
* @param method string - name of the method
|
|
6338
6461
|
* @param args ArgsOrCalldata - arguments that are passed to the method
|
|
6339
6462
|
*/
|
|
6340
6463
|
validate(type, method, args = []) {
|
|
6341
|
-
if (type !== "DEPLOY") {
|
|
6464
|
+
if (type !== "DEPLOY" /* DEPLOY */) {
|
|
6342
6465
|
const invocableFunctionNames = this.abi.filter((abi) => {
|
|
6343
6466
|
if (abi.type !== "function")
|
|
6344
6467
|
return false;
|
|
6345
6468
|
const isView = abi.stateMutability === "view" || abi.state_mutability === "view";
|
|
6346
|
-
return type === "INVOKE" ? !isView : isView;
|
|
6469
|
+
return type === "INVOKE" /* INVOKE */ ? !isView : isView;
|
|
6347
6470
|
}).map((abi) => abi.name);
|
|
6348
6471
|
assert(
|
|
6349
6472
|
invocableFunctionNames.includes(method),
|
|
6350
|
-
`${type === "INVOKE" ? "invocable" : "viewable"} method not found in abi`
|
|
6473
|
+
`${type === "INVOKE" /* INVOKE */ ? "invocable" : "viewable"} method not found in abi`
|
|
6351
6474
|
);
|
|
6352
6475
|
}
|
|
6353
6476
|
const abiMethod = this.abi.find(
|
|
6354
|
-
(abi) => type === "DEPLOY" ? abi.name === method && abi.type ===
|
|
6477
|
+
(abi) => type === "DEPLOY" /* DEPLOY */ ? abi.name === method && abi.type === "constructor" : abi.name === method && abi.type === "function"
|
|
6355
6478
|
);
|
|
6356
|
-
const inputsLength =
|
|
6479
|
+
const inputsLength = this.parser.methodInputsLength(abiMethod);
|
|
6357
6480
|
if (args.length !== inputsLength) {
|
|
6358
6481
|
throw Error(
|
|
6359
6482
|
`Invalid number of arguments, expected ${inputsLength} arguments, but got ${args.length}`
|
|
@@ -6460,14 +6583,6 @@ var starknet = (() => {
|
|
|
6460
6583
|
const parsed = this.parse(method, response);
|
|
6461
6584
|
return formatter(parsed, format);
|
|
6462
6585
|
}
|
|
6463
|
-
/**
|
|
6464
|
-
* Helper to calculate inputs from abi
|
|
6465
|
-
* @param inputs AbiEntry
|
|
6466
|
-
* @returns number
|
|
6467
|
-
*/
|
|
6468
|
-
static abiInputsLength(inputs) {
|
|
6469
|
-
return inputs.reduce((acc, input) => !isLen(input.name) ? acc + 1 : acc, 0);
|
|
6470
|
-
}
|
|
6471
6586
|
/**
|
|
6472
6587
|
* Helper to extract structs from abi
|
|
6473
6588
|
* @param abi Abi
|
|
@@ -7240,12 +7355,12 @@ var starknet = (() => {
|
|
|
7240
7355
|
];
|
|
7241
7356
|
return computeHashOnElements2(dataToHash);
|
|
7242
7357
|
}
|
|
7243
|
-
function calculateDeployTransactionHash(contractAddress, constructorCalldata, version, chainId) {
|
|
7358
|
+
function calculateDeployTransactionHash(contractAddress, constructorCalldata, version, chainId, constructorName = "constructor") {
|
|
7244
7359
|
return calculateTransactionHashCommon(
|
|
7245
7360
|
"0x6465706c6f79" /* DEPLOY */,
|
|
7246
7361
|
version,
|
|
7247
7362
|
contractAddress,
|
|
7248
|
-
getSelectorFromName(
|
|
7363
|
+
getSelectorFromName(constructorName),
|
|
7249
7364
|
constructorCalldata,
|
|
7250
7365
|
0,
|
|
7251
7366
|
chainId
|
|
@@ -11953,7 +12068,7 @@ var starknet = (() => {
|
|
|
11953
12068
|
}
|
|
11954
12069
|
|
|
11955
12070
|
// src/provider/utils.ts
|
|
11956
|
-
var validBlockTags =
|
|
12071
|
+
var validBlockTags = Object.values(BlockTag);
|
|
11957
12072
|
var Block = class {
|
|
11958
12073
|
constructor(_identifier) {
|
|
11959
12074
|
this.hash = null;
|
|
@@ -11973,7 +12088,7 @@ var starknet = (() => {
|
|
|
11973
12088
|
} else if (typeof __identifier === "string" && validBlockTags.includes(__identifier)) {
|
|
11974
12089
|
this.tag = __identifier;
|
|
11975
12090
|
} else {
|
|
11976
|
-
this.tag = "pending"
|
|
12091
|
+
this.tag = "pending" /* pending */;
|
|
11977
12092
|
}
|
|
11978
12093
|
}
|
|
11979
12094
|
// TODO: fix any
|
|
@@ -12616,7 +12731,7 @@ var starknet = (() => {
|
|
|
12616
12731
|
}
|
|
12617
12732
|
var defaultOptions2 = {
|
|
12618
12733
|
network: "SN_GOERLI2" /* SN_GOERLI2 */,
|
|
12619
|
-
blockIdentifier: "pending"
|
|
12734
|
+
blockIdentifier: "pending" /* pending */
|
|
12620
12735
|
};
|
|
12621
12736
|
var SequencerProvider = class {
|
|
12622
12737
|
constructor(optionsOrProvider = defaultOptions2) {
|
|
@@ -14114,7 +14229,8 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14114
14229
|
this.providerOrAccount = providerOrAccount;
|
|
14115
14230
|
this.callData = new CallData(abi);
|
|
14116
14231
|
this.structs = CallData.getAbiStruct(abi);
|
|
14117
|
-
|
|
14232
|
+
const parser = createAbiParser(abi);
|
|
14233
|
+
this.abi = parser.getLegacyFormat();
|
|
14118
14234
|
const options = { enumerable: true, value: {}, writable: false };
|
|
14119
14235
|
Object.defineProperties(this, {
|
|
14120
14236
|
functions: { enumerable: true, value: {}, writable: false },
|
|
@@ -14180,7 +14296,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14180
14296
|
assert(this.address !== null, "contract is not connected to an address");
|
|
14181
14297
|
const calldata = getCalldata(args, () => {
|
|
14182
14298
|
if (parseRequest) {
|
|
14183
|
-
this.callData.validate("CALL"
|
|
14299
|
+
this.callData.validate("CALL" /* CALL */, method, args);
|
|
14184
14300
|
return this.callData.compile(method, args);
|
|
14185
14301
|
}
|
|
14186
14302
|
console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
|
|
@@ -14207,7 +14323,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14207
14323
|
assert(this.address !== null, "contract is not connected to an address");
|
|
14208
14324
|
const calldata = getCalldata(args, () => {
|
|
14209
14325
|
if (parseRequest) {
|
|
14210
|
-
this.callData.validate("INVOKE"
|
|
14326
|
+
this.callData.validate("INVOKE" /* INVOKE */, method, args);
|
|
14211
14327
|
return this.callData.compile(method, args);
|
|
14212
14328
|
}
|
|
14213
14329
|
console.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request");
|
|
@@ -14240,7 +14356,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14240
14356
|
async estimate(method, args = []) {
|
|
14241
14357
|
assert(this.address !== null, "contract is not connected to an address");
|
|
14242
14358
|
if (!getCalldata(args, () => false)) {
|
|
14243
|
-
this.callData.validate("INVOKE"
|
|
14359
|
+
this.callData.validate("INVOKE" /* INVOKE */, method, args);
|
|
14244
14360
|
}
|
|
14245
14361
|
const invocation = this.populate(method, args);
|
|
14246
14362
|
if ("estimateInvokeFee" in this.providerOrAccount) {
|
|
@@ -14285,7 +14401,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
|
|
|
14285
14401
|
const { args: param, options = { parseRequest: true } } = splitArgsAndOptions(args);
|
|
14286
14402
|
const constructorCalldata = getCalldata(param, () => {
|
|
14287
14403
|
if (options.parseRequest) {
|
|
14288
|
-
this.CallData.validate("DEPLOY"
|
|
14404
|
+
this.CallData.validate("DEPLOY" /* DEPLOY */, "constructor", param);
|
|
14289
14405
|
return this.CallData.compile("constructor", param);
|
|
14290
14406
|
}
|
|
14291
14407
|
console.warn("Call skipped parsing but provided rawArgs, possible malfunction request");
|