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/dist/index.mjs CHANGED
@@ -2720,12 +2720,11 @@ __export(stark_exports, {
2720
2720
  estimatedFeeToMaxFee: () => estimatedFeeToMaxFee,
2721
2721
  formatSignature: () => formatSignature,
2722
2722
  makeAddress: () => makeAddress,
2723
- parseSignature: () => parseSignature,
2724
2723
  randomAddress: () => randomAddress,
2725
2724
  signatureToDecimalArray: () => signatureToDecimalArray,
2726
2725
  signatureToHexArray: () => signatureToHexArray
2727
2726
  });
2728
- import { Signature, getStarkKey, utils } from "micro-starknet";
2727
+ import { getStarkKey, utils } from "micro-starknet";
2729
2728
  import { gzip } from "pako";
2730
2729
  function compressProgram(jsonProgram) {
2731
2730
  const stringified = typeof jsonProgram === "string" ? jsonProgram : stringify2(jsonProgram);
@@ -2741,12 +2740,15 @@ function makeAddress(input) {
2741
2740
  }
2742
2741
  function formatSignature(sig) {
2743
2742
  if (!sig)
2744
- return [];
2743
+ throw Error("formatSignature: provided signature is undefined");
2744
+ if (Array.isArray(sig)) {
2745
+ return sig.map((it) => toHex(it));
2746
+ }
2745
2747
  try {
2746
2748
  const { r, s } = sig;
2747
2749
  return [toHex(r), toHex(s)];
2748
2750
  } catch (e) {
2749
- return [];
2751
+ throw new Error("Signature need to be weierstrass.SignatureType or an array for custom");
2750
2752
  }
2751
2753
  }
2752
2754
  function signatureToDecimalArray(sig) {
@@ -2755,12 +2757,6 @@ function signatureToDecimalArray(sig) {
2755
2757
  function signatureToHexArray(sig) {
2756
2758
  return bigNumberishArrayToHexadecimalStringArray(formatSignature(sig));
2757
2759
  }
2758
- function parseSignature(sig) {
2759
- if (!sig)
2760
- return void 0;
2761
- const [r, s] = sig;
2762
- return new Signature(toBigInt(r), toBigInt(s));
2763
- }
2764
2760
  function compileCalldata(args) {
2765
2761
  const compiledData = Object.values(args).flatMap((value) => {
2766
2762
  if (Array.isArray(value))
@@ -3395,7 +3391,7 @@ var SequencerAPIResponseParser = class extends ResponseParser {
3395
3391
  max_fee: "max_fee" in res.transaction ? res.transaction.max_fee : void 0,
3396
3392
  nonce: res.transaction.nonce,
3397
3393
  sender_address: "sender_address" in res.transaction ? res.transaction.sender_address : void 0,
3398
- signature: "signature" in res.transaction ? parseSignature(res.transaction.signature) : void 0,
3394
+ signature: "signature" in res.transaction ? res.transaction.signature : void 0,
3399
3395
  transaction_hash: "transaction_hash" in res.transaction ? res.transaction.transaction_hash : void 0,
3400
3396
  version: "version" in res.transaction ? res.transaction.version : void 0
3401
3397
  };
@@ -5442,7 +5438,7 @@ var Account = class extends Provider {
5442
5438
  entrypoint: "isValidSignature",
5443
5439
  calldata: compileCalldata({
5444
5440
  hash: toBigInt(hash).toString(),
5445
- signature: [toHex(signature.r), toHex(signature.s)]
5441
+ signature: formatSignature(signature)
5446
5442
  })
5447
5443
  });
5448
5444
  return true;