starknet 5.24.5 → 5.26.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 +12 -0
- package/dist/index.d.ts +47 -14
- package/dist/index.global.js +117 -64
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +33 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [5.26.0](https://github.com/starknet-io/starknet.js/compare/v5.25.0...v5.26.0) (2024-01-15)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- abi-wan trigger ([c10150a](https://github.com/starknet-io/starknet.js/commit/c10150a328051054a7bba1260296c0c92fdd2051))
|
|
6
|
+
|
|
7
|
+
# [5.25.0](https://github.com/starknet-io/starknet.js/compare/v5.24.5...v5.25.0) (2023-12-18)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- sepolia ([26d7044](https://github.com/starknet-io/starknet.js/commit/26d70446edd7c098b7f257d9242cc9d9d220b11e))
|
|
12
|
+
|
|
1
13
|
## [5.24.5](https://github.com/starknet-io/starknet.js/compare/v5.24.4...v5.24.5) (2023-12-10)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as weierstrass from '@noble/curves/abstract/weierstrass';
|
|
2
2
|
import { Abi as Abi$1, TypedContract as TypedContract$1 } from 'abi-wan-kanabi';
|
|
3
|
+
import { Abi as Abi$2, TypedContract as TypedContract$2 } from 'abi-wan-kanabi-v2';
|
|
3
4
|
import * as poseidon from '@noble/curves/abstract/poseidon';
|
|
4
5
|
import * as json$1 from 'lossless-json';
|
|
5
6
|
import * as starknet from '@scure/starknet';
|
|
@@ -133,15 +134,18 @@ declare const MAX_STORAGE_ITEM_SIZE = 256n;
|
|
|
133
134
|
declare const ADDR_BOUND: bigint;
|
|
134
135
|
declare enum BaseUrl {
|
|
135
136
|
SN_MAIN = "https://alpha-mainnet.starknet.io",
|
|
136
|
-
SN_GOERLI = "https://alpha4.starknet.io"
|
|
137
|
+
SN_GOERLI = "https://alpha4.starknet.io",
|
|
138
|
+
SN_SEPOLIA = "https://alpha-sepolia.starknet.io"
|
|
137
139
|
}
|
|
138
140
|
declare enum NetworkName {
|
|
139
141
|
SN_MAIN = "SN_MAIN",
|
|
140
|
-
SN_GOERLI = "SN_GOERLI"
|
|
142
|
+
SN_GOERLI = "SN_GOERLI",
|
|
143
|
+
SN_SEPOLIA = "SN_SEPOLIA"
|
|
141
144
|
}
|
|
142
145
|
declare enum StarknetChainId {
|
|
143
146
|
SN_MAIN = "0x534e5f4d41494e",
|
|
144
|
-
SN_GOERLI = "0x534e5f474f45524c49"
|
|
147
|
+
SN_GOERLI = "0x534e5f474f45524c49",
|
|
148
|
+
SN_SEPOLIA = "0x534e5f5345504f4c4941"
|
|
145
149
|
}
|
|
146
150
|
declare enum TransactionHashPrefix {
|
|
147
151
|
DECLARE = "0x6465636c617265",
|
|
@@ -154,8 +158,12 @@ declare const UDC: {
|
|
|
154
158
|
ADDRESS: string;
|
|
155
159
|
ENTRYPOINT: string;
|
|
156
160
|
};
|
|
157
|
-
declare const
|
|
158
|
-
declare const
|
|
161
|
+
declare const RPC_DEFAULT_VERSION = "v0_5";
|
|
162
|
+
declare const RPC_NODES: {
|
|
163
|
+
SN_GOERLI: string[];
|
|
164
|
+
SN_MAIN: string[];
|
|
165
|
+
SN_SEPOLIA: string[];
|
|
166
|
+
};
|
|
159
167
|
|
|
160
168
|
declare const constants_ADDR_BOUND: typeof ADDR_BOUND;
|
|
161
169
|
declare const constants_API_VERSION: typeof API_VERSION;
|
|
@@ -172,8 +180,8 @@ declare const constants_MASK_250: typeof MASK_250;
|
|
|
172
180
|
declare const constants_MAX_STORAGE_ITEM_SIZE: typeof MAX_STORAGE_ITEM_SIZE;
|
|
173
181
|
type constants_NetworkName = NetworkName;
|
|
174
182
|
declare const constants_NetworkName: typeof NetworkName;
|
|
175
|
-
declare const
|
|
176
|
-
declare const
|
|
183
|
+
declare const constants_RPC_DEFAULT_VERSION: typeof RPC_DEFAULT_VERSION;
|
|
184
|
+
declare const constants_RPC_NODES: typeof RPC_NODES;
|
|
177
185
|
type constants_StarknetChainId = StarknetChainId;
|
|
178
186
|
declare const constants_StarknetChainId: typeof StarknetChainId;
|
|
179
187
|
declare const constants_TEXT_TO_FELT_MAX_LEN: typeof TEXT_TO_FELT_MAX_LEN;
|
|
@@ -196,8 +204,8 @@ declare namespace constants {
|
|
|
196
204
|
constants_MASK_250 as MASK_250,
|
|
197
205
|
constants_MAX_STORAGE_ITEM_SIZE as MAX_STORAGE_ITEM_SIZE,
|
|
198
206
|
constants_NetworkName as NetworkName,
|
|
199
|
-
|
|
200
|
-
|
|
207
|
+
constants_RPC_DEFAULT_VERSION as RPC_DEFAULT_VERSION,
|
|
208
|
+
constants_RPC_NODES as RPC_NODES,
|
|
201
209
|
constants_StarknetChainId as StarknetChainId,
|
|
202
210
|
constants_TEXT_TO_FELT_MAX_LEN as TEXT_TO_FELT_MAX_LEN,
|
|
203
211
|
constants_TransactionHashPrefix as TransactionHashPrefix,
|
|
@@ -323,7 +331,7 @@ declare class CairoResult<T, U> {
|
|
|
323
331
|
type CairoEnum = CairoCustomEnum | CairoOption<any> | CairoResult<any, any>;
|
|
324
332
|
|
|
325
333
|
/** ABI */
|
|
326
|
-
type Abi =
|
|
334
|
+
type Abi = ReadonlyArray<FunctionAbi | EventAbi | StructAbi | any>;
|
|
327
335
|
type AbiEntry = {
|
|
328
336
|
name: string;
|
|
329
337
|
type: 'felt' | 'felt*' | string;
|
|
@@ -713,6 +721,7 @@ type RpcProviderOptions = {
|
|
|
713
721
|
blockIdentifier?: BlockIdentifier;
|
|
714
722
|
chainId?: StarknetChainId;
|
|
715
723
|
default?: boolean;
|
|
724
|
+
rpcVersion?: 'v0_5' | 'v0_6';
|
|
716
725
|
};
|
|
717
726
|
type SequencerHttpMethod = 'POST' | 'GET';
|
|
718
727
|
type SequencerProviderOptions = {
|
|
@@ -1112,7 +1121,7 @@ type SIERRA_ENTRY_POINT = {
|
|
|
1112
1121
|
selector: FELT;
|
|
1113
1122
|
function_idx: number;
|
|
1114
1123
|
};
|
|
1115
|
-
type CONTRACT_ABI = CONTRACT_ABI_ENTRY[];
|
|
1124
|
+
type CONTRACT_ABI = readonly CONTRACT_ABI_ENTRY[];
|
|
1116
1125
|
type CONTRACT_ABI_ENTRY = {
|
|
1117
1126
|
selector: FELT;
|
|
1118
1127
|
input: string;
|
|
@@ -3586,7 +3595,7 @@ declare class SequencerProvider implements ProviderInterface {
|
|
|
3586
3595
|
private chainId;
|
|
3587
3596
|
private responseParser;
|
|
3588
3597
|
constructor(optionsOrProvider?: SequencerProviderOptions);
|
|
3589
|
-
protected static getNetworkFromName(name: NetworkName | StarknetChainId): BaseUrl;
|
|
3598
|
+
protected static getNetworkFromName(name: NetworkName | StarknetChainId): BaseUrl.SN_MAIN | BaseUrl.SN_GOERLI;
|
|
3590
3599
|
protected static getChainIdFromBaseUrl(baseUrl: string): StarknetChainId;
|
|
3591
3600
|
private getFetchUrl;
|
|
3592
3601
|
private getFetchMethod;
|
|
@@ -3662,7 +3671,13 @@ declare class SequencerProvider implements ProviderInterface {
|
|
|
3662
3671
|
buildTransaction(invocation: AccountInvocationItem, versionType?: 'fee' | 'transaction'): AccountTransactionItem;
|
|
3663
3672
|
}
|
|
3664
3673
|
|
|
3665
|
-
|
|
3674
|
+
/**
|
|
3675
|
+
* Return randomly select available public node
|
|
3676
|
+
* @param networkName NetworkName
|
|
3677
|
+
* @param mute mute public node warning
|
|
3678
|
+
* @returns default node url
|
|
3679
|
+
*/
|
|
3680
|
+
declare const getDefaultNodeUrl: (networkName?: NetworkName, mute?: boolean, version?: 'v0_5' | 'v0_6') => string;
|
|
3666
3681
|
declare class RpcProvider implements ProviderInterface {
|
|
3667
3682
|
nodeUrl: string;
|
|
3668
3683
|
headers: object;
|
|
@@ -4168,7 +4183,22 @@ declare class Account extends Provider implements AccountInterface {
|
|
|
4168
4183
|
StarknetIdContract?: string): Promise<string>;
|
|
4169
4184
|
}
|
|
4170
4185
|
|
|
4186
|
+
declare module 'abi-wan-kanabi-v2' {
|
|
4187
|
+
interface Config<OptionT = any, ResultT = any, ErrorT = any> {
|
|
4188
|
+
FeltType: BigNumberish;
|
|
4189
|
+
U256Type: number | bigint | Uint256;
|
|
4190
|
+
Option: CairoOption<OptionT>;
|
|
4191
|
+
Tuple: Record<number, BigNumberish | object | boolean>;
|
|
4192
|
+
Result: CairoResult<ResultT, ErrorT>;
|
|
4193
|
+
Enum: CairoCustomEnum;
|
|
4194
|
+
Calldata: RawArgs | Calldata;
|
|
4195
|
+
CallOptions: CallOptions;
|
|
4196
|
+
InvokeOptions: InvokeOptions;
|
|
4197
|
+
InvokeFunctionResponse: InvokeFunctionResponse;
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4171
4200
|
type TypedContract<TAbi extends Abi$1> = TypedContract$1<TAbi> & ContractInterface;
|
|
4201
|
+
type TypedContractV2$1<TAbi extends Abi$2> = TypedContract$2<TAbi> & ContractInterface;
|
|
4172
4202
|
declare abstract class ContractInterface {
|
|
4173
4203
|
abstract abi: Abi;
|
|
4174
4204
|
abstract address: string;
|
|
@@ -4264,8 +4294,10 @@ declare abstract class ContractInterface {
|
|
|
4264
4294
|
*/
|
|
4265
4295
|
abstract getVersion(): Promise<ContractVersion>;
|
|
4266
4296
|
abstract typed<TAbi extends Abi$1>(tAbi: TAbi): TypedContract<TAbi>;
|
|
4297
|
+
abstract typedv2<TAbi extends Abi$2>(tAbi: TAbi): TypedContractV2$1<TAbi>;
|
|
4267
4298
|
}
|
|
4268
4299
|
|
|
4300
|
+
type TypedContractV2<TAbi extends Abi$2> = TypedContract$2<TAbi> & Contract;
|
|
4269
4301
|
declare const splitArgsAndOptions: (args: ArgsOrCalldataWithOptions) => {
|
|
4270
4302
|
args: ArgsOrCalldata;
|
|
4271
4303
|
options: ContractOptions;
|
|
@@ -4316,6 +4348,7 @@ declare class Contract implements ContractInterface {
|
|
|
4316
4348
|
isCairo1(): boolean;
|
|
4317
4349
|
getVersion(): Promise<ContractVersion>;
|
|
4318
4350
|
typed<TAbi extends Abi$1>(tAbi: TAbi): TypedContract<TAbi>;
|
|
4351
|
+
typedv2<TAbi extends Abi$2>(tAbi: TAbi): TypedContractV2<TAbi>;
|
|
4319
4352
|
}
|
|
4320
4353
|
|
|
4321
4354
|
type ContractFactoryParams = {
|
|
@@ -5365,4 +5398,4 @@ declare function parseUDCEvent(txReceipt: InvokeTransactionReceiptResponse): {
|
|
|
5365
5398
|
/** @deprecated prefer the 'num' naming */
|
|
5366
5399
|
declare const number: typeof num;
|
|
5367
5400
|
|
|
5368
|
-
export { Abi, AbiEntry, AbiEnums, AbiEvents, AbiStructs, Account, AccountInterface, AccountInvocationItem, AccountInvocations, AccountInvocationsFactoryDetails, AllowArray, Args, ArgsOrCalldata, ArgsOrCalldataWithOptions, ArraySignatureType, AsyncContractFunction, BigNumberish, BlockIdentifier, BlockNumber, BlockStatus, BlockTag, Builtins, ByteCode, Cairo1Event, CairoAssembly, CairoContract, CairoCustomEnum, CairoEnum, CairoEnumRaw, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoVersion, Call, CallContractResponse, CallData, CallDetails, CallL1Handler, CallOptions, CallStruct, Calldata, CommonTransactionResponse, CompiledContract, CompiledSierra, CompiledSierraCasm, CompilerVersion, CompleteDeclareContractPayload, CompressedProgram, Contract, ContractClass$1 as ContractClass, ContractClassResponse, ContractEntryPoint, ContractEntryPointFields, ContractFactory, ContractFactoryParams, ContractFunction, ContractInterface, ContractOptions, ContractVersion, CustomError, DeclareAndDeployContractPayload, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractResponse, DeployContractUDCResponse, DeployTransactionReceiptResponse, DeployedContractItem, Details, EntryPointType, EntryPointsByType, EnumAbi, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, EventAbi, EventEntry, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HexCalldata, HttpError, Invocation, Invocations, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeOptions, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LegacyEvent, LibraryError, Litteral, MessageToL1, MessageToL2, MultiDeployContractResponse, MultiType, Nonce, OptionalPayload, ParsedEvent, ParsedEvents, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, PythonicHints, rpc as RPC, RawArgs, RawArgsArray, RawArgsObject, RawCalldata, RejectedTransactionReceiptResponse, RejectedTransactionResponse, Result, RevertedTransactionReceiptResponse, RpcProvider, RpcProviderOptions, SIMULATION_FLAG, sequencer as Sequencer, SequencerHttpMethod, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, SierraContractClass, SierraContractEntryPointFields, SierraEntryPointsByType, SierraProgramDebugInfo, Signature, Signer, SignerInterface, SimulateTransactionDetails, SimulateTransactionResponse, SimulatedTransaction, SimulationFlags, StarkNetDomain, StarkNetMerkleType, StarkNetType, StateUpdateResponse, Storage, StructAbi, SuccessfulTransactionReceiptResponse, TransactionExecutionStatus, TransactionFinalityStatus, TransactionStatus$1 as TransactionStatus, TransactionType, Tupled, TypedContract, TypedData, Uint, Uint256, UniversalDeployerContractPayload, ValidateType, WeierstrassSignatureType, addAddressPadding, buildUrl, cairo, constants, contractClassResponseToLegacyCompiledContract, defaultProvider, ec, encode, index as events, extractContractHashes, fixProto, fixStack, getCalldata, getChecksumAddress, getContractVersionOptions, getDefaultNodeUrl, getEstimateFeeBulkOptions, getSimulateTransactionOptions, hash, isSierra, isUrl, json, merkle, num, number, parseUDCEvent, provider, selector, shortString, splitArgsAndOptions, stark, starknetId, transaction, typedData, index$1 as types, uint256$1 as uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
|
|
5401
|
+
export { Abi, AbiEntry, AbiEnums, AbiEvents, AbiStructs, Account, AccountInterface, AccountInvocationItem, AccountInvocations, AccountInvocationsFactoryDetails, AllowArray, Args, ArgsOrCalldata, ArgsOrCalldataWithOptions, ArraySignatureType, AsyncContractFunction, BigNumberish, BlockIdentifier, BlockNumber, BlockStatus, BlockTag, Builtins, ByteCode, Cairo1Event, CairoAssembly, CairoContract, CairoCustomEnum, CairoEnum, CairoEnumRaw, CairoOption, CairoOptionVariant, CairoResult, CairoResultVariant, CairoVersion, Call, CallContractResponse, CallData, CallDetails, CallL1Handler, CallOptions, CallStruct, Calldata, CommonTransactionResponse, CompiledContract, CompiledSierra, CompiledSierraCasm, CompilerVersion, CompleteDeclareContractPayload, CompressedProgram, Contract, ContractClass$1 as ContractClass, ContractClassResponse, ContractEntryPoint, ContractEntryPointFields, ContractFactory, ContractFactoryParams, ContractFunction, ContractInterface, ContractOptions, ContractVersion, CustomError, DeclareAndDeployContractPayload, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployUDCResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractResponse, DeployContractUDCResponse, DeployTransactionReceiptResponse, DeployedContractItem, Details, EntryPointType, EntryPointsByType, EnumAbi, EstimateFee, EstimateFeeAction, EstimateFeeBulk, EstimateFeeDetails, EstimateFeeResponse, EstimateFeeResponseBulk, Event, EventAbi, EventEntry, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, HexCalldata, HttpError, Invocation, Invocations, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeOptions, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LegacyEvent, LibraryError, Litteral, MessageToL1, MessageToL2, MultiDeployContractResponse, MultiType, Nonce, OptionalPayload, ParsedEvent, ParsedEvents, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, PythonicHints, rpc as RPC, RawArgs, RawArgsArray, RawArgsObject, RawCalldata, RejectedTransactionReceiptResponse, RejectedTransactionResponse, Result, RevertedTransactionReceiptResponse, RpcProvider, RpcProviderOptions, SIMULATION_FLAG, sequencer as Sequencer, SequencerHttpMethod, SequencerIdentifier, SequencerProvider, SequencerProviderOptions, SierraContractClass, SierraContractEntryPointFields, SierraEntryPointsByType, SierraProgramDebugInfo, Signature, Signer, SignerInterface, SimulateTransactionDetails, SimulateTransactionResponse, SimulatedTransaction, SimulationFlags, StarkNetDomain, StarkNetMerkleType, StarkNetType, StateUpdateResponse, Storage, StructAbi, SuccessfulTransactionReceiptResponse, TransactionExecutionStatus, TransactionFinalityStatus, TransactionStatus$1 as TransactionStatus, TransactionType, Tupled, TypedContract, TypedContractV2, TypedData, Uint, Uint256, UniversalDeployerContractPayload, ValidateType, WeierstrassSignatureType, addAddressPadding, buildUrl, cairo, constants, contractClassResponseToLegacyCompiledContract, defaultProvider, ec, encode, index as events, extractContractHashes, fixProto, fixStack, getCalldata, getChecksumAddress, getContractVersionOptions, getDefaultNodeUrl, getEstimateFeeBulkOptions, getSimulateTransactionOptions, hash, isSierra, isUrl, json, merkle, num, number, parseUDCEvent, provider, selector, shortString, splitArgsAndOptions, stark, starknetId, transaction, typedData, index$1 as types, uint256$1 as uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
|
package/dist/index.global.js
CHANGED
|
@@ -362,7 +362,7 @@ var starknet = (() => {
|
|
|
362
362
|
statusText: xhr.statusText,
|
|
363
363
|
headers: parseHeaders(xhr.getAllResponseHeaders() || "")
|
|
364
364
|
};
|
|
365
|
-
if (request.url.
|
|
365
|
+
if (request.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
|
|
366
366
|
options.status = 200;
|
|
367
367
|
} else {
|
|
368
368
|
options.status = xhr.status;
|
|
@@ -536,6 +536,7 @@ var starknet = (() => {
|
|
|
536
536
|
};
|
|
537
537
|
Response.error = function() {
|
|
538
538
|
var response = new Response(null, { status: 200, statusText: "" });
|
|
539
|
+
response.ok = false;
|
|
539
540
|
response.status = 0;
|
|
540
541
|
response.type = "error";
|
|
541
542
|
return response;
|
|
@@ -733,8 +734,8 @@ var starknet = (() => {
|
|
|
733
734
|
MASK_250: () => MASK_250,
|
|
734
735
|
MAX_STORAGE_ITEM_SIZE: () => MAX_STORAGE_ITEM_SIZE,
|
|
735
736
|
NetworkName: () => NetworkName,
|
|
736
|
-
|
|
737
|
-
|
|
737
|
+
RPC_DEFAULT_VERSION: () => RPC_DEFAULT_VERSION,
|
|
738
|
+
RPC_NODES: () => RPC_NODES,
|
|
738
739
|
StarknetChainId: () => StarknetChainId,
|
|
739
740
|
TEXT_TO_FELT_MAX_LEN: () => TEXT_TO_FELT_MAX_LEN,
|
|
740
741
|
TransactionHashPrefix: () => TransactionHashPrefix,
|
|
@@ -766,10 +767,14 @@ var starknet = (() => {
|
|
|
766
767
|
if (!Number.isSafeInteger(n))
|
|
767
768
|
throw new Error(`Wrong integer: ${n}`);
|
|
768
769
|
}
|
|
770
|
+
function isBytes(a) {
|
|
771
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
772
|
+
}
|
|
769
773
|
function chain(...args) {
|
|
774
|
+
const id = (a) => a;
|
|
770
775
|
const wrap = (a, b) => (c) => a(b(c));
|
|
771
|
-
const encode =
|
|
772
|
-
const decode2 = args.
|
|
776
|
+
const encode = args.map((x) => x.encode).reduceRight(wrap, id);
|
|
777
|
+
const decode2 = args.map((x) => x.decode).reduce(wrap, id);
|
|
773
778
|
return { encode, decode: decode2 };
|
|
774
779
|
}
|
|
775
780
|
function alphabet(alphabet2) {
|
|
@@ -905,13 +910,13 @@ var starknet = (() => {
|
|
|
905
910
|
throw new Error("radix2: carry overflow");
|
|
906
911
|
return {
|
|
907
912
|
encode: (bytes2) => {
|
|
908
|
-
if (!(bytes2
|
|
913
|
+
if (!isBytes(bytes2))
|
|
909
914
|
throw new Error("radix2.encode input should be Uint8Array");
|
|
910
915
|
return convertRadix2(Array.from(bytes2), 8, bits, !revPadding);
|
|
911
916
|
},
|
|
912
917
|
decode: (digits) => {
|
|
913
918
|
if (!Array.isArray(digits) || digits.length && typeof digits[0] !== "number")
|
|
914
|
-
throw new Error("radix2.decode input should be array of
|
|
919
|
+
throw new Error("radix2.decode input should be array of numbers");
|
|
915
920
|
return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
|
|
916
921
|
}
|
|
917
922
|
};
|
|
@@ -1003,16 +1008,19 @@ var starknet = (() => {
|
|
|
1003
1008
|
var BaseUrl = /* @__PURE__ */ ((BaseUrl2) => {
|
|
1004
1009
|
BaseUrl2["SN_MAIN"] = "https://alpha-mainnet.starknet.io";
|
|
1005
1010
|
BaseUrl2["SN_GOERLI"] = "https://alpha4.starknet.io";
|
|
1011
|
+
BaseUrl2["SN_SEPOLIA"] = "https://alpha-sepolia.starknet.io";
|
|
1006
1012
|
return BaseUrl2;
|
|
1007
1013
|
})(BaseUrl || {});
|
|
1008
1014
|
var NetworkName = /* @__PURE__ */ ((NetworkName2) => {
|
|
1009
1015
|
NetworkName2["SN_MAIN"] = "SN_MAIN";
|
|
1010
1016
|
NetworkName2["SN_GOERLI"] = "SN_GOERLI";
|
|
1017
|
+
NetworkName2["SN_SEPOLIA"] = "SN_SEPOLIA";
|
|
1011
1018
|
return NetworkName2;
|
|
1012
1019
|
})(NetworkName || {});
|
|
1013
1020
|
var StarknetChainId = /* @__PURE__ */ ((StarknetChainId4) => {
|
|
1014
1021
|
StarknetChainId4["SN_MAIN"] = "0x534e5f4d41494e";
|
|
1015
1022
|
StarknetChainId4["SN_GOERLI"] = "0x534e5f474f45524c49";
|
|
1023
|
+
StarknetChainId4["SN_SEPOLIA"] = "0x534e5f5345504f4c4941";
|
|
1016
1024
|
return StarknetChainId4;
|
|
1017
1025
|
})(StarknetChainId || {});
|
|
1018
1026
|
var TransactionHashPrefix = /* @__PURE__ */ ((TransactionHashPrefix2) => {
|
|
@@ -1027,14 +1035,21 @@ var starknet = (() => {
|
|
|
1027
1035
|
ADDRESS: "0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",
|
|
1028
1036
|
ENTRYPOINT: "deployContract"
|
|
1029
1037
|
};
|
|
1030
|
-
var
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
+
var RPC_DEFAULT_VERSION = "v0_5";
|
|
1039
|
+
var RPC_NODES = {
|
|
1040
|
+
SN_GOERLI: [
|
|
1041
|
+
`https://starknet-testnet.public.blastapi.io/rpc/`,
|
|
1042
|
+
`https://free-rpc.nethermind.io/goerli-juno/`
|
|
1043
|
+
],
|
|
1044
|
+
SN_MAIN: [
|
|
1045
|
+
`https://starknet-mainnet.public.blastapi.io/rpc/`,
|
|
1046
|
+
`https://free-rpc.nethermind.io/mainnet-juno/`
|
|
1047
|
+
],
|
|
1048
|
+
SN_SEPOLIA: [
|
|
1049
|
+
`https://starknet-sepolia.public.blastapi.io/rpc/`,
|
|
1050
|
+
`https://free-rpc.nethermind.io/sepolia-juno/`
|
|
1051
|
+
]
|
|
1052
|
+
};
|
|
1038
1053
|
|
|
1039
1054
|
// src/types/index.ts
|
|
1040
1055
|
var types_exports = {};
|
|
@@ -1248,6 +1263,7 @@ var starknet = (() => {
|
|
|
1248
1263
|
equalBytes: () => equalBytes,
|
|
1249
1264
|
hexToBytes: () => hexToBytes,
|
|
1250
1265
|
hexToNumber: () => hexToNumber,
|
|
1266
|
+
isBytes: () => isBytes2,
|
|
1251
1267
|
numberToBytesBE: () => numberToBytesBE,
|
|
1252
1268
|
numberToBytesLE: () => numberToBytesLE,
|
|
1253
1269
|
numberToHexUnpadded: () => numberToHexUnpadded,
|
|
@@ -1258,10 +1274,12 @@ var starknet = (() => {
|
|
|
1258
1274
|
var _0n = BigInt(0);
|
|
1259
1275
|
var _1n = BigInt(1);
|
|
1260
1276
|
var _2n = BigInt(2);
|
|
1261
|
-
|
|
1277
|
+
function isBytes2(a) {
|
|
1278
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
1279
|
+
}
|
|
1262
1280
|
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
1263
1281
|
function bytesToHex(bytes2) {
|
|
1264
|
-
if (!
|
|
1282
|
+
if (!isBytes2(bytes2))
|
|
1265
1283
|
throw new Error("Uint8Array expected");
|
|
1266
1284
|
let hex2 = "";
|
|
1267
1285
|
for (let i = 0; i < bytes2.length; i++) {
|
|
@@ -1278,20 +1296,32 @@ var starknet = (() => {
|
|
|
1278
1296
|
throw new Error("hex string expected, got " + typeof hex2);
|
|
1279
1297
|
return BigInt(hex2 === "" ? "0" : `0x${hex2}`);
|
|
1280
1298
|
}
|
|
1299
|
+
var asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
|
|
1300
|
+
function asciiToBase16(char) {
|
|
1301
|
+
if (char >= asciis._0 && char <= asciis._9)
|
|
1302
|
+
return char - asciis._0;
|
|
1303
|
+
if (char >= asciis._A && char <= asciis._F)
|
|
1304
|
+
return char - (asciis._A - 10);
|
|
1305
|
+
if (char >= asciis._a && char <= asciis._f)
|
|
1306
|
+
return char - (asciis._a - 10);
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1281
1309
|
function hexToBytes(hex2) {
|
|
1282
1310
|
if (typeof hex2 !== "string")
|
|
1283
1311
|
throw new Error("hex string expected, got " + typeof hex2);
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
const
|
|
1291
|
-
const
|
|
1292
|
-
if (
|
|
1293
|
-
|
|
1294
|
-
|
|
1312
|
+
const hl = hex2.length;
|
|
1313
|
+
const al = hl / 2;
|
|
1314
|
+
if (hl % 2)
|
|
1315
|
+
throw new Error("padded hex string expected, got unpadded hex of length " + hl);
|
|
1316
|
+
const array = new Uint8Array(al);
|
|
1317
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
1318
|
+
const n1 = asciiToBase16(hex2.charCodeAt(hi));
|
|
1319
|
+
const n2 = asciiToBase16(hex2.charCodeAt(hi + 1));
|
|
1320
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
1321
|
+
const char = hex2[hi] + hex2[hi + 1];
|
|
1322
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
1323
|
+
}
|
|
1324
|
+
array[ai] = n1 * 16 + n2;
|
|
1295
1325
|
}
|
|
1296
1326
|
return array;
|
|
1297
1327
|
}
|
|
@@ -1299,7 +1329,7 @@ var starknet = (() => {
|
|
|
1299
1329
|
return hexToNumber(bytesToHex(bytes2));
|
|
1300
1330
|
}
|
|
1301
1331
|
function bytesToNumberLE(bytes2) {
|
|
1302
|
-
if (!
|
|
1332
|
+
if (!isBytes2(bytes2))
|
|
1303
1333
|
throw new Error("Uint8Array expected");
|
|
1304
1334
|
return hexToNumber(bytesToHex(Uint8Array.from(bytes2).reverse()));
|
|
1305
1335
|
}
|
|
@@ -1320,7 +1350,7 @@ var starknet = (() => {
|
|
|
1320
1350
|
} catch (e) {
|
|
1321
1351
|
throw new Error(`${title} must be valid hex string, got "${hex2}". Cause: ${e}`);
|
|
1322
1352
|
}
|
|
1323
|
-
} else if (
|
|
1353
|
+
} else if (isBytes2(hex2)) {
|
|
1324
1354
|
res = Uint8Array.from(hex2);
|
|
1325
1355
|
} else {
|
|
1326
1356
|
throw new Error(`${title} must be hex string or Uint8Array`);
|
|
@@ -1331,23 +1361,29 @@ var starknet = (() => {
|
|
|
1331
1361
|
return res;
|
|
1332
1362
|
}
|
|
1333
1363
|
function concatBytes(...arrays) {
|
|
1334
|
-
|
|
1335
|
-
let
|
|
1336
|
-
|
|
1337
|
-
if (!
|
|
1364
|
+
let sum = 0;
|
|
1365
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
1366
|
+
const a = arrays[i];
|
|
1367
|
+
if (!isBytes2(a))
|
|
1338
1368
|
throw new Error("Uint8Array expected");
|
|
1339
|
-
|
|
1369
|
+
sum += a.length;
|
|
1370
|
+
}
|
|
1371
|
+
let res = new Uint8Array(sum);
|
|
1372
|
+
let pad = 0;
|
|
1373
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
1374
|
+
const a = arrays[i];
|
|
1375
|
+
res.set(a, pad);
|
|
1340
1376
|
pad += a.length;
|
|
1341
|
-
}
|
|
1342
|
-
return
|
|
1377
|
+
}
|
|
1378
|
+
return res;
|
|
1343
1379
|
}
|
|
1344
|
-
function equalBytes(
|
|
1345
|
-
if (
|
|
1380
|
+
function equalBytes(a, b) {
|
|
1381
|
+
if (a.length !== b.length)
|
|
1346
1382
|
return false;
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
return
|
|
1383
|
+
let diff = 0;
|
|
1384
|
+
for (let i = 0; i < a.length; i++)
|
|
1385
|
+
diff |= a[i] ^ b[i];
|
|
1386
|
+
return diff === 0;
|
|
1351
1387
|
}
|
|
1352
1388
|
function utf8ToBytes(str) {
|
|
1353
1389
|
if (typeof str !== "string")
|
|
@@ -1422,7 +1458,7 @@ var starknet = (() => {
|
|
|
1422
1458
|
function: (val) => typeof val === "function",
|
|
1423
1459
|
boolean: (val) => typeof val === "boolean",
|
|
1424
1460
|
string: (val) => typeof val === "string",
|
|
1425
|
-
stringOrUint8Array: (val) => typeof val === "string" || val
|
|
1461
|
+
stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
|
|
1426
1462
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
1427
1463
|
array: (val) => Array.isArray(val),
|
|
1428
1464
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -1563,8 +1599,11 @@ var starknet = (() => {
|
|
|
1563
1599
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
1564
1600
|
throw new Error(`Wrong positive integer: ${n}`);
|
|
1565
1601
|
}
|
|
1602
|
+
function isBytes3(a) {
|
|
1603
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
1604
|
+
}
|
|
1566
1605
|
function bytes(b, ...lengths) {
|
|
1567
|
-
if (!(b
|
|
1606
|
+
if (!isBytes3(b))
|
|
1568
1607
|
throw new Error("Expected Uint8Array");
|
|
1569
1608
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
1570
1609
|
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
@@ -1615,8 +1654,10 @@ var starknet = (() => {
|
|
|
1615
1654
|
var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
1616
1655
|
|
|
1617
1656
|
// node_modules/@noble/hashes/esm/utils.js
|
|
1618
|
-
var u8a2 = (a) => a instanceof Uint8Array;
|
|
1619
1657
|
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
1658
|
+
function isBytes4(a) {
|
|
1659
|
+
return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
|
|
1660
|
+
}
|
|
1620
1661
|
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
1621
1662
|
var rotr = (word, shift) => word << 32 - shift | word >>> shift;
|
|
1622
1663
|
var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
@@ -1630,20 +1671,25 @@ var starknet = (() => {
|
|
|
1630
1671
|
function toBytes(data) {
|
|
1631
1672
|
if (typeof data === "string")
|
|
1632
1673
|
data = utf8ToBytes2(data);
|
|
1633
|
-
if (!
|
|
1674
|
+
if (!isBytes4(data))
|
|
1634
1675
|
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
1635
1676
|
return data;
|
|
1636
1677
|
}
|
|
1637
1678
|
function concatBytes2(...arrays) {
|
|
1638
|
-
|
|
1639
|
-
let
|
|
1640
|
-
|
|
1641
|
-
if (!
|
|
1679
|
+
let sum = 0;
|
|
1680
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
1681
|
+
const a = arrays[i];
|
|
1682
|
+
if (!isBytes4(a))
|
|
1642
1683
|
throw new Error("Uint8Array expected");
|
|
1643
|
-
|
|
1684
|
+
sum += a.length;
|
|
1685
|
+
}
|
|
1686
|
+
const res = new Uint8Array(sum);
|
|
1687
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
1688
|
+
const a = arrays[i];
|
|
1689
|
+
res.set(a, pad);
|
|
1644
1690
|
pad += a.length;
|
|
1645
|
-
}
|
|
1646
|
-
return
|
|
1691
|
+
}
|
|
1692
|
+
return res;
|
|
1647
1693
|
}
|
|
1648
1694
|
var Hash = class {
|
|
1649
1695
|
// Safe version that clones internal state
|
|
@@ -2649,7 +2695,7 @@ var starknet = (() => {
|
|
|
2649
2695
|
toSig(hex2) {
|
|
2650
2696
|
const { Err: E } = DER;
|
|
2651
2697
|
const data = typeof hex2 === "string" ? h2b(hex2) : hex2;
|
|
2652
|
-
if (!(data
|
|
2698
|
+
if (!isBytes2(data))
|
|
2653
2699
|
throw new Error("ui8a expected");
|
|
2654
2700
|
let l = data.length;
|
|
2655
2701
|
if (l < 2 || data[0] != 48)
|
|
@@ -2713,7 +2759,7 @@ var starknet = (() => {
|
|
|
2713
2759
|
function normPrivateKeyToScalar(key) {
|
|
2714
2760
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE2;
|
|
2715
2761
|
if (lengths && typeof key !== "bigint") {
|
|
2716
|
-
if (key
|
|
2762
|
+
if (isBytes2(key))
|
|
2717
2763
|
key = bytesToHex(key);
|
|
2718
2764
|
if (typeof key !== "string" || !lengths.includes(key.length))
|
|
2719
2765
|
throw new Error("Invalid key");
|
|
@@ -3248,7 +3294,7 @@ var starknet = (() => {
|
|
|
3248
3294
|
return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
|
3249
3295
|
}
|
|
3250
3296
|
function isProbPub(item) {
|
|
3251
|
-
const arr = item
|
|
3297
|
+
const arr = isBytes2(item);
|
|
3252
3298
|
const str = typeof item === "string";
|
|
3253
3299
|
const len = (arr || str) && item.length;
|
|
3254
3300
|
if (arr)
|
|
@@ -3343,7 +3389,7 @@ var starknet = (() => {
|
|
|
3343
3389
|
let _sig = void 0;
|
|
3344
3390
|
let P;
|
|
3345
3391
|
try {
|
|
3346
|
-
if (typeof sg === "string" || sg
|
|
3392
|
+
if (typeof sg === "string" || isBytes2(sg)) {
|
|
3347
3393
|
try {
|
|
3348
3394
|
_sig = Signature3.fromDER(sg);
|
|
3349
3395
|
} catch (derError) {
|
|
@@ -10800,12 +10846,12 @@ var starknet = (() => {
|
|
|
10800
10846
|
};
|
|
10801
10847
|
|
|
10802
10848
|
// src/provider/rpc.ts
|
|
10803
|
-
var getDefaultNodeUrl = (networkName, mute = false) => {
|
|
10849
|
+
var getDefaultNodeUrl = (networkName, mute = false, version = RPC_DEFAULT_VERSION) => {
|
|
10804
10850
|
if (!mute)
|
|
10805
10851
|
console.warn("Using default public node url, please provide nodeUrl in provider options!");
|
|
10806
|
-
const nodes = networkName
|
|
10852
|
+
const nodes = RPC_NODES[networkName ?? "SN_GOERLI" /* SN_GOERLI */];
|
|
10807
10853
|
const randIdx = Math.floor(Math.random() * nodes.length);
|
|
10808
|
-
return nodes[randIdx]
|
|
10854
|
+
return `${nodes[randIdx]}${version}`;
|
|
10809
10855
|
};
|
|
10810
10856
|
var defaultOptions = {
|
|
10811
10857
|
headers: { "Content-Type": "application/json" },
|
|
@@ -10843,13 +10889,17 @@ var starknet = (() => {
|
|
|
10843
10889
|
* @deprecated renamed to simulateTransaction();
|
|
10844
10890
|
*/
|
|
10845
10891
|
this.getSimulateTransaction = this.simulateTransaction;
|
|
10846
|
-
const { nodeUrl, retries, headers, blockIdentifier, chainId } = optionsOrProvider || {};
|
|
10892
|
+
const { nodeUrl, retries, headers, blockIdentifier, chainId, rpcVersion } = optionsOrProvider || {};
|
|
10847
10893
|
if (Object.values(NetworkName).includes(nodeUrl)) {
|
|
10848
|
-
this.nodeUrl = getDefaultNodeUrl(
|
|
10894
|
+
this.nodeUrl = getDefaultNodeUrl(
|
|
10895
|
+
nodeUrl,
|
|
10896
|
+
optionsOrProvider?.default,
|
|
10897
|
+
rpcVersion
|
|
10898
|
+
);
|
|
10849
10899
|
} else if (nodeUrl) {
|
|
10850
10900
|
this.nodeUrl = nodeUrl;
|
|
10851
10901
|
} else {
|
|
10852
|
-
this.nodeUrl = getDefaultNodeUrl(void 0, optionsOrProvider?.default);
|
|
10902
|
+
this.nodeUrl = getDefaultNodeUrl(void 0, optionsOrProvider?.default, rpcVersion);
|
|
10853
10903
|
}
|
|
10854
10904
|
this.retries = retries || defaultOptions.retries;
|
|
10855
10905
|
this.headers = { ...defaultOptions.headers, ...headers };
|
|
@@ -13324,6 +13374,9 @@ ${res.tx_failure_reason.error_message}`;
|
|
|
13324
13374
|
typed(tAbi) {
|
|
13325
13375
|
return this;
|
|
13326
13376
|
}
|
|
13377
|
+
typedv2(tAbi) {
|
|
13378
|
+
return this;
|
|
13379
|
+
}
|
|
13327
13380
|
};
|
|
13328
13381
|
|
|
13329
13382
|
// src/contract/interface.ts
|