@chipi-stack/backend 14.15.1 → 14.17.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/dist/wallets.mjs CHANGED
@@ -346,6 +346,7 @@ var init_stark = __esm({
346
346
  var execute_paymaster_raw_exports = {};
347
347
  __export(execute_paymaster_raw_exports, {
348
348
  executeShhhSponsoredRaw: () => executeShhhSponsoredRaw,
349
+ newOeNonce: () => newOeNonce,
349
350
  resolveShhhChainId: () => resolveShhhChainId,
350
351
  serializeExecuteFromOutsideV2Calldata: () => serializeExecuteFromOutsideV2Calldata
351
352
  });
@@ -472,13 +473,26 @@ init_encryption2();
472
473
 
473
474
  // src/execute-paymaster-transaction.ts
474
475
  init_encryption2();
476
+ function feltEquals(value, expected) {
477
+ try {
478
+ return BigInt(value) === expected;
479
+ } catch {
480
+ return false;
481
+ }
482
+ }
475
483
  function normalizeSignature(signature) {
476
484
  if (Array.isArray(signature)) {
477
485
  if (signature.length < 2) {
478
486
  throw new Error(`Array signature must have at least 2 elements, got ${signature.length}`);
479
487
  }
480
- const r = signature[0];
481
- const s = signature[1];
488
+ const isArgentSingle = signature.length === 5 && feltEquals(signature[0], 1n) && feltEquals(signature[1], 0n);
489
+ if (signature.length !== 2 && !isArgentSingle) {
490
+ throw new Error(
491
+ `Unsupported ${signature.length}-felt signature: expected [r, s] or Argent [1, 0, pubkey, r, s].`
492
+ );
493
+ }
494
+ const r = isArgentSingle ? signature[3] : signature[0];
495
+ const s = isArgentSingle ? signature[4] : signature[1];
482
496
  if (r == null || s == null) {
483
497
  throw new Error(`Signature elements must not be null/undefined. Got r=${r}, s=${s}`);
484
498
  }
@@ -917,7 +931,10 @@ var ChipiWallets = class {
917
931
  publicKey,
918
932
  walletType,
919
933
  starkKeyPubAX,
920
- ...customClassHash && { classHash: customClassHash },
934
+ // The class the address above was computed with. SHHH always
935
+ // names it: chipi-back's default for clients that name none is
936
+ // the class SDKs up to 14.16 used (V8.4), not ours.
937
+ ...(customClassHash || isShhh) && { classHash: accountClassHash },
921
938
  // SHHH: tell chipi-back which signer kind + pubkey felts
922
939
  // produced this deployment so it can validate against the
923
940
  // expected SHHH constructor shape and populate the new
@@ -929,6 +946,11 @@ var ChipiWallets = class {
929
946
  }
930
947
  });
931
948
  const { typedData: typedData2, accountClassHash: accountClassHashResponse } = typedDataResponse;
949
+ if (isShhh && (!accountClassHashResponse || BigInt(accountClassHashResponse) !== BigInt(accountClassHash))) {
950
+ throw new Error(
951
+ `prepare-creation returned class ${accountClassHashResponse ?? "(none)"}, but the wallet address was computed with ${accountClassHash}. Not deploying.`
952
+ );
953
+ }
932
954
  let userSignaturePayload;
933
955
  if (isShhh) {
934
956
  userSignaturePayload = {