@pafi-dev/issuer 0.7.1 → 0.7.3

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.d.cts CHANGED
@@ -469,18 +469,6 @@ declare class AuthError extends PafiSdkError {
469
469
  constructor(code: AuthErrorCode, message: string);
470
470
  }
471
471
 
472
- /**
473
- * Errors raised by RelayService carry a `code` so callers (handlers /
474
- * gateway-less HTTP wrappers) can decide how to map them to HTTP status.
475
- *
476
- * v1.4 trimmed the error space to just encoding failures — the service
477
- * no longer broadcasts transactions, so `SUBMIT_FAILED`, `TX_REVERTED`,
478
- * `SIMULATION_FAILED`, and `TIMEOUT` all went away with the operator
479
- * wallet. Paymaster/Bundler errors surface out-of-band on the FE.
480
- *
481
- * v0.7.1 — extends `PafiSdkError` so `createSdkErrorMapper` routes it
482
- * to 422 instead of leaking as a 500. See SDK_ISSUER_AUDIT.md C2.
483
- */
484
472
  type RelayErrorCode = "ENCODE_FAILED";
485
473
  declare class RelayError extends PafiSdkError {
486
474
  readonly httpStatus: "unprocessable";
@@ -2002,14 +1990,19 @@ declare class PerpDepositHandler {
2002
1990
 
2003
1991
  /**
2004
1992
  * Pure mechanics for the EIP-7702 delegation submit flow. Builds the
2005
- * empty-batch UserOp, attaches paymaster sponsorship, splits the user's
2006
- * authorization signature into the JSON-RPC tuple, and relays via the
2007
- * PAFI sponsor-relayer.
1993
+ * delegation-anchor UserOp via `buildDelegationUserOp` (self-call EOA
1994
+ * with empty calldata), attaches paymaster sponsorship, splits the
1995
+ * user's authorization signature into the JSON-RPC tuple, and relays
1996
+ * via the PAFI sponsor-relayer.
1997
+ *
1998
+ * The UserOp itself is a no-op — a self-call to the user's EOA with
1999
+ * `data: "0x"`. The work is in the `eip7702Auth` object: the bundler
2000
+ * picks it up, runs the EIP-7702 path, and installs the delegation on
2001
+ * the user's EOA atomically with the (no-op) UserOp.
2008
2002
  *
2009
- * The UserOp itself is a no-op — `BatchExecutor.execute([])` does
2010
- * nothing. The work is in the `eip7702Auth` object: the bundler picks
2011
- * it up, runs the EIP-7702 path, and installs the delegation on the
2012
- * user's EOA atomically with the (empty) UserOp.
2003
+ * v0.7.1 switched from `encodeBatchExecute([])` (which throws
2004
+ * "operations array must not be empty") to `buildDelegationUserOp`
2005
+ * (self-call pattern). See SDK_CORE_TRADING_AUDIT.md C1.
2013
2006
  *
2014
2007
  * Throws the same `BundlerNotConfiguredError` / `BundlerRejectedError`
2015
2008
  * as other relay paths so issuer controllers can use one error mapper.
@@ -2343,14 +2336,6 @@ interface DelegatePrepareDto {
2343
2336
  batchExecutorAddress: Address;
2344
2337
  chainId: number;
2345
2338
  }
2346
- /**
2347
- * Thrown by `IssuerApiAdapter` constructor when the wired ledger does
2348
- * not implement the optional methods required by the configured
2349
- * handlers. Surfaces at boot, not at first request — issuer can't
2350
- * silently ship a partial ledger and discover the gap in production.
2351
- *
2352
- * v0.7.1 — added per SDK_ISSUER_AUDIT.md C4.
2353
- */
2354
2339
  declare class AdapterMisconfiguredError extends Error {
2355
2340
  readonly code: "ADAPTER_MISCONFIGURED";
2356
2341
  constructor(message: string);
@@ -2424,11 +2409,6 @@ declare class IssuerApiAdapter {
2424
2409
  /**
2425
2410
  * Build + sign a SponsorAuth payload. Returns `undefined` when no
2426
2411
  * issuer id is configured, so the controller can skip the field.
2427
- *
2428
- * v0.7.1 — `scenario` typed as `SponsorshipScenario` (was `string`).
2429
- * Previously a typo (`"perp_deposit"` vs `"perp-deposit"`) compiled
2430
- * fine but rejected at L1 by sponsor-relayer's IntentValidator. See
2431
- * SDK_ISSUER_AUDIT.md N5.
2432
2412
  */
2433
2413
  private buildSponsorAuth;
2434
2414
  private runMobilePrepare;
package/dist/index.d.ts CHANGED
@@ -469,18 +469,6 @@ declare class AuthError extends PafiSdkError {
469
469
  constructor(code: AuthErrorCode, message: string);
470
470
  }
471
471
 
472
- /**
473
- * Errors raised by RelayService carry a `code` so callers (handlers /
474
- * gateway-less HTTP wrappers) can decide how to map them to HTTP status.
475
- *
476
- * v1.4 trimmed the error space to just encoding failures — the service
477
- * no longer broadcasts transactions, so `SUBMIT_FAILED`, `TX_REVERTED`,
478
- * `SIMULATION_FAILED`, and `TIMEOUT` all went away with the operator
479
- * wallet. Paymaster/Bundler errors surface out-of-band on the FE.
480
- *
481
- * v0.7.1 — extends `PafiSdkError` so `createSdkErrorMapper` routes it
482
- * to 422 instead of leaking as a 500. See SDK_ISSUER_AUDIT.md C2.
483
- */
484
472
  type RelayErrorCode = "ENCODE_FAILED";
485
473
  declare class RelayError extends PafiSdkError {
486
474
  readonly httpStatus: "unprocessable";
@@ -2002,14 +1990,19 @@ declare class PerpDepositHandler {
2002
1990
 
2003
1991
  /**
2004
1992
  * Pure mechanics for the EIP-7702 delegation submit flow. Builds the
2005
- * empty-batch UserOp, attaches paymaster sponsorship, splits the user's
2006
- * authorization signature into the JSON-RPC tuple, and relays via the
2007
- * PAFI sponsor-relayer.
1993
+ * delegation-anchor UserOp via `buildDelegationUserOp` (self-call EOA
1994
+ * with empty calldata), attaches paymaster sponsorship, splits the
1995
+ * user's authorization signature into the JSON-RPC tuple, and relays
1996
+ * via the PAFI sponsor-relayer.
1997
+ *
1998
+ * The UserOp itself is a no-op — a self-call to the user's EOA with
1999
+ * `data: "0x"`. The work is in the `eip7702Auth` object: the bundler
2000
+ * picks it up, runs the EIP-7702 path, and installs the delegation on
2001
+ * the user's EOA atomically with the (no-op) UserOp.
2008
2002
  *
2009
- * The UserOp itself is a no-op — `BatchExecutor.execute([])` does
2010
- * nothing. The work is in the `eip7702Auth` object: the bundler picks
2011
- * it up, runs the EIP-7702 path, and installs the delegation on the
2012
- * user's EOA atomically with the (empty) UserOp.
2003
+ * v0.7.1 switched from `encodeBatchExecute([])` (which throws
2004
+ * "operations array must not be empty") to `buildDelegationUserOp`
2005
+ * (self-call pattern). See SDK_CORE_TRADING_AUDIT.md C1.
2013
2006
  *
2014
2007
  * Throws the same `BundlerNotConfiguredError` / `BundlerRejectedError`
2015
2008
  * as other relay paths so issuer controllers can use one error mapper.
@@ -2343,14 +2336,6 @@ interface DelegatePrepareDto {
2343
2336
  batchExecutorAddress: Address;
2344
2337
  chainId: number;
2345
2338
  }
2346
- /**
2347
- * Thrown by `IssuerApiAdapter` constructor when the wired ledger does
2348
- * not implement the optional methods required by the configured
2349
- * handlers. Surfaces at boot, not at first request — issuer can't
2350
- * silently ship a partial ledger and discover the gap in production.
2351
- *
2352
- * v0.7.1 — added per SDK_ISSUER_AUDIT.md C4.
2353
- */
2354
2339
  declare class AdapterMisconfiguredError extends Error {
2355
2340
  readonly code: "ADAPTER_MISCONFIGURED";
2356
2341
  constructor(message: string);
@@ -2424,11 +2409,6 @@ declare class IssuerApiAdapter {
2424
2409
  /**
2425
2410
  * Build + sign a SponsorAuth payload. Returns `undefined` when no
2426
2411
  * issuer id is configured, so the controller can skip the field.
2427
- *
2428
- * v0.7.1 — `scenario` typed as `SponsorshipScenario` (was `string`).
2429
- * Previously a typo (`"perp_deposit"` vs `"perp-deposit"`) compiled
2430
- * fine but rejected at L1 by sponsor-relayer's IntentValidator. See
2431
- * SDK_ISSUER_AUDIT.md N5.
2432
2412
  */
2433
2413
  private buildSponsorAuth;
2434
2414
  private runMobilePrepare;
package/dist/index.js CHANGED
@@ -2299,8 +2299,8 @@ var PerpDepositHandler = class {
2299
2299
  // src/api/delegateHandler.ts
2300
2300
  import {
2301
2301
  ENTRY_POINT_V08 as ENTRY_POINT_V082,
2302
+ buildDelegationUserOp,
2302
2303
  buildEip7702Authorization,
2303
- encodeBatchExecute,
2304
2304
  getContractAddresses as getContractAddresses5,
2305
2305
  serializeUserOpToJsonRpc as serializeUserOpToJsonRpc2
2306
2306
  } from "@pafi-dev/core";
@@ -2311,14 +2311,22 @@ var DEFAULT_DELEGATE_GAS = {
2311
2311
  };
2312
2312
  async function handleDelegateSubmit(params) {
2313
2313
  const { batchExecutor } = getContractAddresses5(params.chainId);
2314
- const callData = encodeBatchExecute([]);
2314
+ const partial = buildDelegationUserOp({
2315
+ userAddress: params.userAddress,
2316
+ aaNonce: params.aaNonce,
2317
+ gasLimits: {
2318
+ callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_DELEGATE_GAS.callGasLimit,
2319
+ verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_DELEGATE_GAS.verificationGasLimit,
2320
+ preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_DELEGATE_GAS.preVerificationGas
2321
+ }
2322
+ });
2315
2323
  const userOp = {
2316
- sender: params.userAddress,
2317
- nonce: params.aaNonce,
2318
- callData,
2319
- callGasLimit: params.gasLimits?.callGasLimit ?? DEFAULT_DELEGATE_GAS.callGasLimit,
2320
- verificationGasLimit: params.gasLimits?.verificationGasLimit ?? DEFAULT_DELEGATE_GAS.verificationGasLimit,
2321
- preVerificationGas: params.gasLimits?.preVerificationGas ?? DEFAULT_DELEGATE_GAS.preVerificationGas,
2324
+ sender: partial.sender,
2325
+ nonce: partial.nonce,
2326
+ callData: partial.callData,
2327
+ callGasLimit: partial.callGasLimit,
2328
+ verificationGasLimit: partial.verificationGasLimit,
2329
+ preVerificationGas: partial.preVerificationGas,
2322
2330
  maxFeePerGas: params.fees.maxFeePerGas ?? 0n,
2323
2331
  maxPriorityFeePerGas: params.fees.maxPriorityFeePerGas ?? 0n
2324
2332
  };
@@ -2403,7 +2411,7 @@ import {
2403
2411
  buildAndSignSponsorAuth,
2404
2412
  computeAuthorizationHash,
2405
2413
  decodeBatchExecuteCalls as decodeBatchExecuteCalls3,
2406
- encodeBatchExecute as encodeBatchExecute2,
2414
+ encodeBatchExecute,
2407
2415
  ENTRY_POINT_V08 as ENTRY_POINT_V083,
2408
2416
  getContractAddresses as getContractAddresses6,
2409
2417
  parseEip7702DelegatedAddress as parseEip7702DelegatedAddress2
@@ -2747,11 +2755,6 @@ var IssuerApiAdapter = class {
2747
2755
  /**
2748
2756
  * Build + sign a SponsorAuth payload. Returns `undefined` when no
2749
2757
  * issuer id is configured, so the controller can skip the field.
2750
- *
2751
- * v0.7.1 — `scenario` typed as `SponsorshipScenario` (was `string`).
2752
- * Previously a typo (`"perp_deposit"` vs `"perp-deposit"`) compiled
2753
- * fine but rejected at L1 by sponsor-relayer's IntentValidator. See
2754
- * SDK_ISSUER_AUDIT.md N5.
2755
2758
  */
2756
2759
  async buildSponsorAuth(authenticatedAddress, callData, chainId, scenario) {
2757
2760
  if (!this.cfg.pafiIssuerId) return void 0;
@@ -3656,7 +3659,7 @@ var IssuerStateValidator = class _IssuerStateValidator {
3656
3659
  };
3657
3660
 
3658
3661
  // src/index.ts
3659
- var PAFI_ISSUER_SDK_VERSION = true ? "0.7.1" : "dev";
3662
+ var PAFI_ISSUER_SDK_VERSION = true ? "0.7.3" : "dev";
3660
3663
  export {
3661
3664
  AdapterMisconfiguredError,
3662
3665
  AuthError,