starknet 5.4.0 → 5.4.1

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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [5.4.1](https://github.com/0xs34n/starknet.js/compare/v5.4.0...v5.4.1) (2023-04-03)
2
+
3
+ ### Bug Fixes
4
+
5
+ - remove AnySignatureType and parseSignature method ([358bfad](https://github.com/0xs34n/starknet.js/commit/358bfad8e70ab3d4b2c784e0444780c4d7c5f71a))
6
+ - signature tight flexible resolution ([4990cd8](https://github.com/0xs34n/starknet.js/commit/4990cd8a4d6fd8b87c3016fd27c7eb1b2d5a4a8a))
7
+
1
8
  # [5.4.0](https://github.com/0xs34n/starknet.js/compare/v5.3.0...v5.4.0) (2023-04-03)
2
9
 
3
10
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -310,7 +310,9 @@ declare enum EntryPointType {
310
310
  CONSTRUCTOR = "CONSTRUCTOR"
311
311
  }
312
312
 
313
- declare type Signature = _noble_curves_abstract_weierstrass.SignatureType;
313
+ declare type WeierstrassSignatureType = _noble_curves_abstract_weierstrass.SignatureType;
314
+ declare type ArraySignatureType = string[];
315
+ declare type Signature = ArraySignatureType | WeierstrassSignatureType;
314
316
  declare type RawCalldata = BigNumberish[];
315
317
  declare type AllowArray<T> = T | T[];
316
318
  declare type RawArgs = {
@@ -482,6 +484,9 @@ declare type DeployAccountSignerDetails = Required<DeployAccountContractPayload>
482
484
 
483
485
  declare type AsyncContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
484
486
  declare type ContractFunction = (...args: Array<any>) => any;
487
+ declare type Result = {
488
+ [key: string]: any;
489
+ };
485
490
 
486
491
  declare type BlockIdentifier = BlockNumber | BigNumberish;
487
492
 
@@ -2724,7 +2729,7 @@ declare class Contract implements ContractInterface {
2724
2729
  attach(address: string): void;
2725
2730
  connect(providerOrAccount: ProviderInterface | AccountInterface): void;
2726
2731
  deployed(): Promise<Contract>;
2727
- call(method: string, args?: Array<any>, options?: CallOptions): Promise<object>;
2732
+ call(method: string, args?: Array<any>, options?: CallOptions): Promise<Result>;
2728
2733
  invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
2729
2734
  estimate(method: string, args?: Array<any>): Promise<EstimateFeeResponse>;
2730
2735
  populate(method: string, args?: Array<any>): Call;
@@ -2938,10 +2943,9 @@ declare namespace transaction {
2938
2943
  declare function compressProgram(jsonProgram: Program | string): CompressedProgram;
2939
2944
  declare function randomAddress(): string;
2940
2945
  declare function makeAddress(input: string): string;
2941
- declare function formatSignature(sig?: Signature): string[];
2942
- declare function signatureToDecimalArray(sig?: Signature): string[];
2943
- declare function signatureToHexArray(sig?: Signature): string[];
2944
- declare function parseSignature(sig?: string[]): _noble_curves_abstract_weierstrass.SignatureType | undefined;
2946
+ declare function formatSignature(sig?: Signature): ArraySignatureType;
2947
+ declare function signatureToDecimalArray(sig?: Signature): ArraySignatureType;
2948
+ declare function signatureToHexArray(sig?: Signature): ArraySignatureType;
2945
2949
  /**
2946
2950
  * @deprecated this function is deprecated use callData instead from calldata.ts
2947
2951
  */
@@ -2954,7 +2958,6 @@ declare const stark_makeAddress: typeof makeAddress;
2954
2958
  declare const stark_formatSignature: typeof formatSignature;
2955
2959
  declare const stark_signatureToDecimalArray: typeof signatureToDecimalArray;
2956
2960
  declare const stark_signatureToHexArray: typeof signatureToHexArray;
2957
- declare const stark_parseSignature: typeof parseSignature;
2958
2961
  declare const stark_compileCalldata: typeof compileCalldata;
2959
2962
  declare const stark_estimatedFeeToMaxFee: typeof estimatedFeeToMaxFee;
2960
2963
  declare namespace stark {
@@ -2965,7 +2968,6 @@ declare namespace stark {
2965
2968
  stark_formatSignature as formatSignature,
2966
2969
  stark_signatureToDecimalArray as signatureToDecimalArray,
2967
2970
  stark_signatureToHexArray as signatureToHexArray,
2968
- stark_parseSignature as parseSignature,
2969
2971
  stark_compileCalldata as compileCalldata,
2970
2972
  stark_estimatedFeeToMaxFee as estimatedFeeToMaxFee,
2971
2973
  };
@@ -3145,4 +3147,4 @@ declare class CallData {
3145
3147
  /** @deprecated prefer the 'num' naming */
3146
3148
  declare const number: typeof num;
3147
3149
 
3148
- export { Abi, AbiEntry, AbiStructs, Account, AccountInterface, AllowArray, Args, 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, 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, Hints, HttpError, Invocation, InvocationBulk, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, Nonce, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, RPC, RawArgs, RawCalldata, 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, addAddressPadding, buildUrl, constants, defaultProvider, ec, encode, getChecksumAddress, hash, isUrl, json, merkle, num, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
3150
+ 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, 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, Hints, HttpError, Invocation, InvocationBulk, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, LegacyCompiledContract, LegacyContractClass, LibraryError, MessageToL1, MessageToL2, MultiDeployContractResponse, Nonce, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, 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, getChecksumAddress, hash, isUrl, json, merkle, num, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
@@ -6542,7 +6542,6 @@ var starknet = (() => {
6542
6542
  estimatedFeeToMaxFee: () => estimatedFeeToMaxFee,
6543
6543
  formatSignature: () => formatSignature,
6544
6544
  makeAddress: () => makeAddress,
6545
- parseSignature: () => parseSignature,
6546
6545
  randomAddress: () => randomAddress,
6547
6546
  signatureToDecimalArray: () => signatureToDecimalArray,
6548
6547
  signatureToHexArray: () => signatureToHexArray
@@ -10637,12 +10636,15 @@ var starknet = (() => {
10637
10636
  }
10638
10637
  function formatSignature(sig) {
10639
10638
  if (!sig)
10640
- return [];
10639
+ throw Error("formatSignature: provided signature is undefined");
10640
+ if (Array.isArray(sig)) {
10641
+ return sig.map((it) => toHex(it));
10642
+ }
10641
10643
  try {
10642
10644
  const { r, s } = sig;
10643
10645
  return [toHex(r), toHex(s)];
10644
10646
  } catch (e) {
10645
- return [];
10647
+ throw new Error("Signature need to be weierstrass.SignatureType or an array for custom");
10646
10648
  }
10647
10649
  }
10648
10650
  function signatureToDecimalArray(sig) {
@@ -10651,12 +10653,6 @@ var starknet = (() => {
10651
10653
  function signatureToHexArray(sig) {
10652
10654
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
10653
10655
  }
10654
- function parseSignature(sig) {
10655
- if (!sig)
10656
- return void 0;
10657
- const [r, s] = sig;
10658
- return new Signature(toBigInt(r), toBigInt(s));
10659
- }
10660
10656
  function compileCalldata(args) {
10661
10657
  const compiledData = Object.values(args).flatMap((value) => {
10662
10658
  if (Array.isArray(value))
@@ -11291,7 +11287,7 @@ var starknet = (() => {
11291
11287
  max_fee: "max_fee" in res.transaction ? res.transaction.max_fee : void 0,
11292
11288
  nonce: res.transaction.nonce,
11293
11289
  sender_address: "sender_address" in res.transaction ? res.transaction.sender_address : void 0,
11294
- signature: "signature" in res.transaction ? parseSignature(res.transaction.signature) : void 0,
11290
+ signature: "signature" in res.transaction ? res.transaction.signature : void 0,
11295
11291
  transaction_hash: "transaction_hash" in res.transaction ? res.transaction.transaction_hash : void 0,
11296
11292
  version: "version" in res.transaction ? res.transaction.version : void 0
11297
11293
  };
@@ -13338,7 +13334,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
13338
13334
  entrypoint: "isValidSignature",
13339
13335
  calldata: compileCalldata({
13340
13336
  hash: toBigInt(hash2).toString(),
13341
- signature: [toHex(signature.r), toHex(signature.s)]
13337
+ signature: formatSignature(signature)
13342
13338
  })
13343
13339
  });
13344
13340
  return true;