starknet 5.4.0 → 5.4.2

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,16 @@
1
+ ## [5.4.2](https://github.com/0xs34n/starknet.js/compare/v5.4.1...v5.4.2) (2023-04-04)
2
+
3
+ ### Bug Fixes
4
+
5
+ - implement custom ts error localy ([fa90a3e](https://github.com/0xs34n/starknet.js/commit/fa90a3e7dcbe8c0952b0681be903dffb4b4c74c6))
6
+
7
+ ## [5.4.1](https://github.com/0xs34n/starknet.js/compare/v5.4.0...v5.4.1) (2023-04-03)
8
+
9
+ ### Bug Fixes
10
+
11
+ - remove AnySignatureType and parseSignature method ([358bfad](https://github.com/0xs34n/starknet.js/commit/358bfad8e70ab3d4b2c784e0444780c4d7c5f71a))
12
+ - signature tight flexible resolution ([4990cd8](https://github.com/0xs34n/starknet.js/commit/4990cd8a4d6fd8b87c3016fd27c7eb1b2d5a4a8a))
13
+
1
14
  # [5.4.0](https://github.com/0xs34n/starknet.js/compare/v5.3.0...v5.4.0) (2023-04-03)
2
15
 
3
16
  ### Bug Fixes
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _noble_curves_abstract_weierstrass from '@noble/curves/abstract/weierstrass';
2
2
  import * as poseidon from '@noble/curves/abstract/poseidon';
3
3
  import * as microStarknet from 'micro-starknet';
4
- import { CustomError } from 'ts-custom-error/dist/custom-error';
5
4
 
6
5
  declare const IS_BROWSER: boolean;
7
6
  declare function arrayBufferToString(array: ArrayBuffer): string;
@@ -310,7 +309,9 @@ declare enum EntryPointType {
310
309
  CONSTRUCTOR = "CONSTRUCTOR"
311
310
  }
312
311
 
313
- declare type Signature = _noble_curves_abstract_weierstrass.SignatureType;
312
+ declare type WeierstrassSignatureType = _noble_curves_abstract_weierstrass.SignatureType;
313
+ declare type ArraySignatureType = string[];
314
+ declare type Signature = ArraySignatureType | WeierstrassSignatureType;
314
315
  declare type RawCalldata = BigNumberish[];
315
316
  declare type AllowArray<T> = T | T[];
316
317
  declare type RawArgs = {
@@ -482,6 +483,9 @@ declare type DeployAccountSignerDetails = Required<DeployAccountContractPayload>
482
483
 
483
484
  declare type AsyncContractFunction<T = any> = (...args: Array<any>) => Promise<T>;
484
485
  declare type ContractFunction = (...args: Array<any>) => any;
486
+ declare type Result = {
487
+ [key: string]: any;
488
+ };
485
489
 
486
490
  declare type BlockIdentifier = BlockNumber | BigNumberish;
487
491
 
@@ -2118,6 +2122,12 @@ declare class Provider implements ProviderInterface {
2118
2122
  getAddressFromStarkName(name: string, StarknetIdContract?: string): Promise<string>;
2119
2123
  }
2120
2124
 
2125
+ declare function fixStack(target: Error, fn?: Function): void;
2126
+ declare function fixProto(target: Error, prototype: {}): void;
2127
+ declare class CustomError extends Error {
2128
+ name: string;
2129
+ constructor(message?: string);
2130
+ }
2121
2131
  declare class LibraryError extends CustomError {
2122
2132
  }
2123
2133
  declare class GatewayError extends LibraryError {
@@ -2724,7 +2734,7 @@ declare class Contract implements ContractInterface {
2724
2734
  attach(address: string): void;
2725
2735
  connect(providerOrAccount: ProviderInterface | AccountInterface): void;
2726
2736
  deployed(): Promise<Contract>;
2727
- call(method: string, args?: Array<any>, options?: CallOptions): Promise<object>;
2737
+ call(method: string, args?: Array<any>, options?: CallOptions): Promise<Result>;
2728
2738
  invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
2729
2739
  estimate(method: string, args?: Array<any>): Promise<EstimateFeeResponse>;
2730
2740
  populate(method: string, args?: Array<any>): Call;
@@ -2938,10 +2948,9 @@ declare namespace transaction {
2938
2948
  declare function compressProgram(jsonProgram: Program | string): CompressedProgram;
2939
2949
  declare function randomAddress(): string;
2940
2950
  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;
2951
+ declare function formatSignature(sig?: Signature): ArraySignatureType;
2952
+ declare function signatureToDecimalArray(sig?: Signature): ArraySignatureType;
2953
+ declare function signatureToHexArray(sig?: Signature): ArraySignatureType;
2945
2954
  /**
2946
2955
  * @deprecated this function is deprecated use callData instead from calldata.ts
2947
2956
  */
@@ -2954,7 +2963,6 @@ declare const stark_makeAddress: typeof makeAddress;
2954
2963
  declare const stark_formatSignature: typeof formatSignature;
2955
2964
  declare const stark_signatureToDecimalArray: typeof signatureToDecimalArray;
2956
2965
  declare const stark_signatureToHexArray: typeof signatureToHexArray;
2957
- declare const stark_parseSignature: typeof parseSignature;
2958
2966
  declare const stark_compileCalldata: typeof compileCalldata;
2959
2967
  declare const stark_estimatedFeeToMaxFee: typeof estimatedFeeToMaxFee;
2960
2968
  declare namespace stark {
@@ -2965,7 +2973,6 @@ declare namespace stark {
2965
2973
  stark_formatSignature as formatSignature,
2966
2974
  stark_signatureToDecimalArray as signatureToDecimalArray,
2967
2975
  stark_signatureToHexArray as signatureToHexArray,
2968
- stark_parseSignature as parseSignature,
2969
2976
  stark_compileCalldata as compileCalldata,
2970
2977
  stark_estimatedFeeToMaxFee as estimatedFeeToMaxFee,
2971
2978
  };
@@ -3145,4 +3152,4 @@ declare class CallData {
3145
3152
  /** @deprecated prefer the 'num' naming */
3146
3153
  declare const number: typeof num;
3147
3154
 
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 };
3155
+ 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, 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, fixProto, fixStack, getChecksumAddress, hash, isUrl, json, merkle, num, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress, waitForTransactionOptions };
@@ -540,108 +540,6 @@ var starknet = (() => {
540
540
  }
541
541
  });
542
542
 
543
- // node_modules/ts-custom-error/dist/custom-error.js
544
- var require_custom_error = __commonJS({
545
- "node_modules/ts-custom-error/dist/custom-error.js"(exports) {
546
- function fixProto(target, prototype) {
547
- var setPrototypeOf = Object.setPrototypeOf;
548
- setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
549
- }
550
- function fixStack(target, fn) {
551
- if (fn === void 0) {
552
- fn = target.constructor;
553
- }
554
- var captureStackTrace = Error.captureStackTrace;
555
- captureStackTrace && captureStackTrace(target, fn);
556
- }
557
- var __extends = function() {
558
- var _extendStatics = function extendStatics(d, b) {
559
- _extendStatics = Object.setPrototypeOf || {
560
- __proto__: []
561
- } instanceof Array && function(d2, b2) {
562
- d2.__proto__ = b2;
563
- } || function(d2, b2) {
564
- for (var p in b2) {
565
- if (Object.prototype.hasOwnProperty.call(b2, p))
566
- d2[p] = b2[p];
567
- }
568
- };
569
- return _extendStatics(d, b);
570
- };
571
- return function(d, b) {
572
- if (typeof b !== "function" && b !== null)
573
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
574
- _extendStatics(d, b);
575
- function __() {
576
- this.constructor = d;
577
- }
578
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
579
- };
580
- }();
581
- var CustomError2 = function(_super) {
582
- __extends(CustomError3, _super);
583
- function CustomError3(message, options) {
584
- var _newTarget = this.constructor;
585
- var _this = _super.call(this, message, options) || this;
586
- Object.defineProperty(_this, "name", {
587
- value: _newTarget.name,
588
- enumerable: false,
589
- configurable: true
590
- });
591
- fixProto(_this, _newTarget.prototype);
592
- fixStack(_this);
593
- return _this;
594
- }
595
- return CustomError3;
596
- }(Error);
597
- var __spreadArray = function(to, from, pack) {
598
- if (pack || arguments.length === 2)
599
- for (var i = 0, l = from.length, ar; i < l; i++) {
600
- if (ar || !(i in from)) {
601
- if (!ar)
602
- ar = Array.prototype.slice.call(from, 0, i);
603
- ar[i] = from[i];
604
- }
605
- }
606
- return to.concat(ar || Array.prototype.slice.call(from));
607
- };
608
- function customErrorFactory(fn, parent) {
609
- if (parent === void 0) {
610
- parent = Error;
611
- }
612
- function CustomError3() {
613
- var args = [];
614
- for (var _i = 0; _i < arguments.length; _i++) {
615
- args[_i] = arguments[_i];
616
- }
617
- if (!(this instanceof CustomError3))
618
- return new (CustomError3.bind.apply(CustomError3, __spreadArray([void 0], args, false)))();
619
- parent.apply(this, args);
620
- Object.defineProperty(this, "name", {
621
- value: fn.name || parent.name,
622
- enumerable: false,
623
- configurable: true
624
- });
625
- fn.apply(this, args);
626
- fixStack(this, CustomError3);
627
- }
628
- return Object.defineProperties(CustomError3, {
629
- prototype: {
630
- value: Object.create(parent.prototype, {
631
- constructor: {
632
- value: CustomError3,
633
- writable: true,
634
- configurable: true
635
- }
636
- })
637
- }
638
- });
639
- }
640
- exports.CustomError = CustomError2;
641
- exports.customErrorFactory = customErrorFactory;
642
- }
643
- });
644
-
645
543
  // node_modules/url-join/lib/url-join.js
646
544
  var require_url_join = __commonJS({
647
545
  "node_modules/url-join/lib/url-join.js"(exports, module) {
@@ -716,6 +614,7 @@ var starknet = (() => {
716
614
  Contract: () => Contract,
717
615
  ContractFactory: () => ContractFactory,
718
616
  ContractInterface: () => ContractInterface,
617
+ CustomError: () => CustomError,
719
618
  EntryPointType: () => EntryPointType,
720
619
  GatewayError: () => GatewayError,
721
620
  HttpError: () => HttpError,
@@ -735,6 +634,8 @@ var starknet = (() => {
735
634
  defaultProvider: () => defaultProvider,
736
635
  ec: () => ec_exports,
737
636
  encode: () => encode_exports,
637
+ fixProto: () => fixProto,
638
+ fixStack: () => fixStack,
738
639
  getChecksumAddress: () => getChecksumAddress,
739
640
  hash: () => hash_exports,
740
641
  isUrl: () => isUrl,
@@ -6542,7 +6443,6 @@ var starknet = (() => {
6542
6443
  estimatedFeeToMaxFee: () => estimatedFeeToMaxFee,
6543
6444
  formatSignature: () => formatSignature,
6544
6445
  makeAddress: () => makeAddress,
6545
- parseSignature: () => parseSignature,
6546
6446
  randomAddress: () => randomAddress,
6547
6447
  signatureToDecimalArray: () => signatureToDecimalArray,
6548
6448
  signatureToHexArray: () => signatureToHexArray
@@ -10637,12 +10537,15 @@ var starknet = (() => {
10637
10537
  }
10638
10538
  function formatSignature(sig) {
10639
10539
  if (!sig)
10640
- return [];
10540
+ throw Error("formatSignature: provided signature is undefined");
10541
+ if (Array.isArray(sig)) {
10542
+ return sig.map((it) => toHex(it));
10543
+ }
10641
10544
  try {
10642
10545
  const { r, s } = sig;
10643
10546
  return [toHex(r), toHex(s)];
10644
10547
  } catch (e) {
10645
- return [];
10548
+ throw new Error("Signature need to be weierstrass.SignatureType or an array for custom");
10646
10549
  }
10647
10550
  }
10648
10551
  function signatureToDecimalArray(sig) {
@@ -10651,12 +10554,6 @@ var starknet = (() => {
10651
10554
  function signatureToHexArray(sig) {
10652
10555
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
10653
10556
  }
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
10557
  function compileCalldata(args) {
10661
10558
  const compiledData = Object.values(args).flatMap((value) => {
10662
10559
  if (Array.isArray(value))
@@ -10750,8 +10647,27 @@ var starknet = (() => {
10750
10647
  };
10751
10648
 
10752
10649
  // src/provider/errors.ts
10753
- var import_custom_error = __toESM(require_custom_error());
10754
- var LibraryError = class extends import_custom_error.CustomError {
10650
+ function fixStack(target, fn = target.constructor) {
10651
+ const { captureStackTrace } = Error;
10652
+ captureStackTrace && captureStackTrace(target, fn);
10653
+ }
10654
+ function fixProto(target, prototype) {
10655
+ const { setPrototypeOf } = Object;
10656
+ setPrototypeOf ? setPrototypeOf(target, prototype) : target.__proto__ = prototype;
10657
+ }
10658
+ var CustomError = class extends Error {
10659
+ constructor(message) {
10660
+ super(message);
10661
+ Object.defineProperty(this, "name", {
10662
+ value: new.target.name,
10663
+ enumerable: false,
10664
+ configurable: true
10665
+ });
10666
+ fixProto(this, new.target.prototype);
10667
+ fixStack(this);
10668
+ }
10669
+ };
10670
+ var LibraryError = class extends CustomError {
10755
10671
  };
10756
10672
  var GatewayError = class extends LibraryError {
10757
10673
  constructor(message, errorCode) {
@@ -11291,7 +11207,7 @@ var starknet = (() => {
11291
11207
  max_fee: "max_fee" in res.transaction ? res.transaction.max_fee : void 0,
11292
11208
  nonce: res.transaction.nonce,
11293
11209
  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,
11210
+ signature: "signature" in res.transaction ? res.transaction.signature : void 0,
11295
11211
  transaction_hash: "transaction_hash" in res.transaction ? res.transaction.transaction_hash : void 0,
11296
11212
  version: "version" in res.transaction ? res.transaction.version : void 0
11297
11213
  };
@@ -13338,7 +13254,7 @@ ${res.tx_failure_reason.error_message}` : res.tx_status;
13338
13254
  entrypoint: "isValidSignature",
13339
13255
  calldata: compileCalldata({
13340
13256
  hash: toBigInt(hash2).toString(),
13341
- signature: [toHex(signature.r), toHex(signature.s)]
13257
+ signature: formatSignature(signature)
13342
13258
  })
13343
13259
  });
13344
13260
  return true;