@pafi-dev/core 0.7.4 → 0.7.6

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
@@ -1,4 +1,4 @@
1
- import { Address, Hex, TypedDataDomain, PublicClient, HttpTransport, WalletClient } from 'viem';
1
+ import { Address, Hex, TypedDataDomain, PublicClient, WalletClient, TransactionReceipt, HttpTransport } from 'viem';
2
2
  import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-BAkmxgVo.cjs';
3
3
  export { B as BestQuote, c as BurnRequest, I as Issuer, d as PathKey, Q as QuoteResult } from './types-BAkmxgVo.cjs';
4
4
  export { pointTokenAbi as POINT_TOKEN_V2_ABI, erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.cjs';
@@ -1152,6 +1152,157 @@ declare function buildEip7702Authorization(params: {
1152
1152
  authSig: Hex | string;
1153
1153
  }): Eip7702AuthorizationJsonRpc;
1154
1154
 
1155
+ /**
1156
+ * Privy-style EIP-7702 authorization signer. Matches the shape returned
1157
+ * by `useSign7702Authorization()` from `@privy-io/react-auth` /
1158
+ * `@privy-io/expo`. Pass it via `params.signAuthorization` and the
1159
+ * helper takes care of the rest.
1160
+ *
1161
+ * The signer MUST be the user's Privy embedded wallet — external
1162
+ * wallets (MetaMask, WalletConnect, …) cannot produce raw secp256k1
1163
+ * EIP-7702 authorizations.
1164
+ */
1165
+ type SignAuthorizationFn = (args: {
1166
+ contractAddress: Address;
1167
+ chainId: number;
1168
+ nonce: number;
1169
+ }) => Promise<{
1170
+ contractAddress?: Address;
1171
+ address?: Address;
1172
+ chainId: number;
1173
+ nonce: number;
1174
+ r: Hex | string;
1175
+ s: Hex | string;
1176
+ v?: string | number;
1177
+ yParity: 0 | 1 | string;
1178
+ }>;
1179
+ /**
1180
+ * Authorization tuple in the shape `walletClient.sendTransaction`
1181
+ * expects on its `authorizationList` field. Mirrors viem's
1182
+ * `SignedAuthorization` so callers can also build it manually.
1183
+ */
1184
+ interface SignedAuthorization {
1185
+ contractAddress: Address;
1186
+ chainId: number;
1187
+ nonce: number;
1188
+ r: Hex;
1189
+ s: Hex;
1190
+ yParity: 0 | 1;
1191
+ }
1192
+ interface DelegateDirectParams {
1193
+ /** User EOA — must equal `walletClient.account.address`. */
1194
+ userAddress: Address;
1195
+ chainId: number;
1196
+ /** viem PublicClient — used for `getCode` + `getTransactionCount`. */
1197
+ publicClient: PublicClient;
1198
+ /** viem WalletClient (or any sender that exposes `sendTransaction`). */
1199
+ walletClient: WalletClient;
1200
+ /**
1201
+ * Privy hook that produces the EIP-7702 authorization signature.
1202
+ * Pass `useSign7702Authorization().signAuthorization` directly.
1203
+ */
1204
+ signAuthorization: SignAuthorizationFn;
1205
+ /**
1206
+ * Override the impl the EOA delegates to. Defaults to
1207
+ * `getContractAddresses(chainId).batchExecutor` (Pimlico
1208
+ * Simple7702Account on Base mainnet — the canonical PAFI delegate
1209
+ * target).
1210
+ */
1211
+ contractAddress?: Address;
1212
+ /**
1213
+ * When the user already has a 7702 delegation pointing at the
1214
+ * expected impl, skip the tx and return early. Default `true`.
1215
+ * Set `false` to force re-delegate even if status check passes.
1216
+ */
1217
+ skipIfAlreadyDelegated?: boolean;
1218
+ /**
1219
+ * Wait for the transaction receipt before returning. Default
1220
+ * `true` — caller usually wants to know "delegation completed"
1221
+ * before proceeding to claim/redeem flows.
1222
+ */
1223
+ waitForReceipt?: boolean;
1224
+ /** Optional onWarning hook for non-fatal warnings (logger surface). */
1225
+ onWarning?: (msg: string) => void;
1226
+ }
1227
+ interface DelegateDirectResult {
1228
+ /** `'sent'` when a tx was broadcast; `'already-delegated'` when skipped. */
1229
+ status: "sent" | "already-delegated";
1230
+ /** Transaction hash. `undefined` on `already-delegated`. */
1231
+ txHash?: Hex;
1232
+ /** Receipt — present when `waitForReceipt` AND status is `'sent'`. */
1233
+ receipt?: TransactionReceipt;
1234
+ /** EIP-7702 authorization tuple actually sent. */
1235
+ authorization: SignedAuthorization;
1236
+ /** Impl address user delegated to. */
1237
+ delegatedTo: Address;
1238
+ }
1239
+ /**
1240
+ * One-shot helper for the FE-direct EIP-7702 delegation path —
1241
+ * **no AA, no paymaster, no PAFI sponsor-relayer**. The user EOA
1242
+ * pays gas in ETH and broadcasts a single type-4 transaction with the
1243
+ * authorization attached.
1244
+ *
1245
+ * Use this when:
1246
+ * - The FE already has a Privy embedded wallet ready and the user
1247
+ * has a small ETH balance for gas (~$0.01–0.10 on Base).
1248
+ * - You don't want to depend on `permissionless` / Pimlico bundlers
1249
+ * / sponsor-relayer for the one-time delegation step.
1250
+ * - You're testing or running a self-hosted dev environment without
1251
+ * the full PAFI infra.
1252
+ *
1253
+ * Flow:
1254
+ * 1. Read on-chain code; short-circuit if already delegated to the
1255
+ * expected impl (`skipIfAlreadyDelegated`).
1256
+ * 2. Read EOA tx nonce (pending).
1257
+ * 3. Call `signAuthorization` (Privy hook) → r/s/yParity.
1258
+ * 4. Send EIP-7702 type-4 tx with `authorizationList: [auth]` and
1259
+ * `to: userAddress, data: '0x'` (no-op self-call; the work is
1260
+ * bundling the authorization).
1261
+ * 5. Wait for receipt (optional).
1262
+ *
1263
+ * Caller's `signAuthorization` MUST be wired to the user's Privy
1264
+ * embedded wallet — external wallets (MetaMask, …) do NOT support
1265
+ * raw secp256k1 EIP-7702 sign.
1266
+ *
1267
+ * @example
1268
+ * ```ts
1269
+ * import { useSign7702Authorization, useWallets } from "@privy-io/react-auth";
1270
+ * import { delegateDirect } from "@pafi-dev/core";
1271
+ * import { createWalletClient, custom } from "viem";
1272
+ * import { base } from "viem/chains";
1273
+ *
1274
+ * function DelegateButton() {
1275
+ * const { wallets } = useWallets();
1276
+ * const { signAuthorization } = useSign7702Authorization();
1277
+ * const wallet = wallets.find(w => w.walletClientType === "privy"); // embedded
1278
+ *
1279
+ * async function handleClick() {
1280
+ * const provider = await wallet.getEthereumProvider();
1281
+ * const walletClient = createWalletClient({
1282
+ * account: wallet.address,
1283
+ * chain: base,
1284
+ * transport: custom(provider),
1285
+ * });
1286
+ *
1287
+ * const result = await delegateDirect({
1288
+ * userAddress: wallet.address as `0x${string}`,
1289
+ * chainId: 8453,
1290
+ * publicClient,
1291
+ * walletClient,
1292
+ * signAuthorization,
1293
+ * });
1294
+ *
1295
+ * if (result.status === "already-delegated") {
1296
+ * console.log("Already delegated to", result.delegatedTo);
1297
+ * } else {
1298
+ * console.log("Delegated! tx:", result.txHash);
1299
+ * }
1300
+ * }
1301
+ * }
1302
+ * ```
1303
+ */
1304
+ declare function delegateDirect(params: DelegateDirectParams): Promise<DelegateDirectResult>;
1305
+
1155
1306
  /**
1156
1307
  * Parameters for `createPafiProxyTransport`.
1157
1308
  */
@@ -1820,4 +1971,4 @@ declare class PafiSDK {
1820
1971
  signLoginMessage(message: string): Promise<Hex>;
1821
1972
  }
1822
1973
 
1823
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
1974
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Address, Hex, TypedDataDomain, PublicClient, HttpTransport, WalletClient } from 'viem';
1
+ import { Address, Hex, TypedDataDomain, PublicClient, WalletClient, TransactionReceipt, HttpTransport } from 'viem';
2
2
  import { P as PoolKey, C as ChainConfig, a as PafiSDKConfig, b as PointTokenDomainConfig, M as MintRequest, R as ReceiverConsent, E as EIP712Signature, S as SignatureVerification } from './types-BAkmxgVo.js';
3
3
  export { B as BestQuote, c as BurnRequest, I as Issuer, d as PathKey, Q as QuoteResult } from './types-BAkmxgVo.js';
4
4
  export { pointTokenAbi as POINT_TOKEN_V2_ABI, erc20Abi, issuerRegistryAbi, mintingOracleAbi, permit2Abi, pointTokenAbi, pointTokenFactoryAbi, universalRouterAbi, v4QuoterAbi } from './abi/index.js';
@@ -1152,6 +1152,157 @@ declare function buildEip7702Authorization(params: {
1152
1152
  authSig: Hex | string;
1153
1153
  }): Eip7702AuthorizationJsonRpc;
1154
1154
 
1155
+ /**
1156
+ * Privy-style EIP-7702 authorization signer. Matches the shape returned
1157
+ * by `useSign7702Authorization()` from `@privy-io/react-auth` /
1158
+ * `@privy-io/expo`. Pass it via `params.signAuthorization` and the
1159
+ * helper takes care of the rest.
1160
+ *
1161
+ * The signer MUST be the user's Privy embedded wallet — external
1162
+ * wallets (MetaMask, WalletConnect, …) cannot produce raw secp256k1
1163
+ * EIP-7702 authorizations.
1164
+ */
1165
+ type SignAuthorizationFn = (args: {
1166
+ contractAddress: Address;
1167
+ chainId: number;
1168
+ nonce: number;
1169
+ }) => Promise<{
1170
+ contractAddress?: Address;
1171
+ address?: Address;
1172
+ chainId: number;
1173
+ nonce: number;
1174
+ r: Hex | string;
1175
+ s: Hex | string;
1176
+ v?: string | number;
1177
+ yParity: 0 | 1 | string;
1178
+ }>;
1179
+ /**
1180
+ * Authorization tuple in the shape `walletClient.sendTransaction`
1181
+ * expects on its `authorizationList` field. Mirrors viem's
1182
+ * `SignedAuthorization` so callers can also build it manually.
1183
+ */
1184
+ interface SignedAuthorization {
1185
+ contractAddress: Address;
1186
+ chainId: number;
1187
+ nonce: number;
1188
+ r: Hex;
1189
+ s: Hex;
1190
+ yParity: 0 | 1;
1191
+ }
1192
+ interface DelegateDirectParams {
1193
+ /** User EOA — must equal `walletClient.account.address`. */
1194
+ userAddress: Address;
1195
+ chainId: number;
1196
+ /** viem PublicClient — used for `getCode` + `getTransactionCount`. */
1197
+ publicClient: PublicClient;
1198
+ /** viem WalletClient (or any sender that exposes `sendTransaction`). */
1199
+ walletClient: WalletClient;
1200
+ /**
1201
+ * Privy hook that produces the EIP-7702 authorization signature.
1202
+ * Pass `useSign7702Authorization().signAuthorization` directly.
1203
+ */
1204
+ signAuthorization: SignAuthorizationFn;
1205
+ /**
1206
+ * Override the impl the EOA delegates to. Defaults to
1207
+ * `getContractAddresses(chainId).batchExecutor` (Pimlico
1208
+ * Simple7702Account on Base mainnet — the canonical PAFI delegate
1209
+ * target).
1210
+ */
1211
+ contractAddress?: Address;
1212
+ /**
1213
+ * When the user already has a 7702 delegation pointing at the
1214
+ * expected impl, skip the tx and return early. Default `true`.
1215
+ * Set `false` to force re-delegate even if status check passes.
1216
+ */
1217
+ skipIfAlreadyDelegated?: boolean;
1218
+ /**
1219
+ * Wait for the transaction receipt before returning. Default
1220
+ * `true` — caller usually wants to know "delegation completed"
1221
+ * before proceeding to claim/redeem flows.
1222
+ */
1223
+ waitForReceipt?: boolean;
1224
+ /** Optional onWarning hook for non-fatal warnings (logger surface). */
1225
+ onWarning?: (msg: string) => void;
1226
+ }
1227
+ interface DelegateDirectResult {
1228
+ /** `'sent'` when a tx was broadcast; `'already-delegated'` when skipped. */
1229
+ status: "sent" | "already-delegated";
1230
+ /** Transaction hash. `undefined` on `already-delegated`. */
1231
+ txHash?: Hex;
1232
+ /** Receipt — present when `waitForReceipt` AND status is `'sent'`. */
1233
+ receipt?: TransactionReceipt;
1234
+ /** EIP-7702 authorization tuple actually sent. */
1235
+ authorization: SignedAuthorization;
1236
+ /** Impl address user delegated to. */
1237
+ delegatedTo: Address;
1238
+ }
1239
+ /**
1240
+ * One-shot helper for the FE-direct EIP-7702 delegation path —
1241
+ * **no AA, no paymaster, no PAFI sponsor-relayer**. The user EOA
1242
+ * pays gas in ETH and broadcasts a single type-4 transaction with the
1243
+ * authorization attached.
1244
+ *
1245
+ * Use this when:
1246
+ * - The FE already has a Privy embedded wallet ready and the user
1247
+ * has a small ETH balance for gas (~$0.01–0.10 on Base).
1248
+ * - You don't want to depend on `permissionless` / Pimlico bundlers
1249
+ * / sponsor-relayer for the one-time delegation step.
1250
+ * - You're testing or running a self-hosted dev environment without
1251
+ * the full PAFI infra.
1252
+ *
1253
+ * Flow:
1254
+ * 1. Read on-chain code; short-circuit if already delegated to the
1255
+ * expected impl (`skipIfAlreadyDelegated`).
1256
+ * 2. Read EOA tx nonce (pending).
1257
+ * 3. Call `signAuthorization` (Privy hook) → r/s/yParity.
1258
+ * 4. Send EIP-7702 type-4 tx with `authorizationList: [auth]` and
1259
+ * `to: userAddress, data: '0x'` (no-op self-call; the work is
1260
+ * bundling the authorization).
1261
+ * 5. Wait for receipt (optional).
1262
+ *
1263
+ * Caller's `signAuthorization` MUST be wired to the user's Privy
1264
+ * embedded wallet — external wallets (MetaMask, …) do NOT support
1265
+ * raw secp256k1 EIP-7702 sign.
1266
+ *
1267
+ * @example
1268
+ * ```ts
1269
+ * import { useSign7702Authorization, useWallets } from "@privy-io/react-auth";
1270
+ * import { delegateDirect } from "@pafi-dev/core";
1271
+ * import { createWalletClient, custom } from "viem";
1272
+ * import { base } from "viem/chains";
1273
+ *
1274
+ * function DelegateButton() {
1275
+ * const { wallets } = useWallets();
1276
+ * const { signAuthorization } = useSign7702Authorization();
1277
+ * const wallet = wallets.find(w => w.walletClientType === "privy"); // embedded
1278
+ *
1279
+ * async function handleClick() {
1280
+ * const provider = await wallet.getEthereumProvider();
1281
+ * const walletClient = createWalletClient({
1282
+ * account: wallet.address,
1283
+ * chain: base,
1284
+ * transport: custom(provider),
1285
+ * });
1286
+ *
1287
+ * const result = await delegateDirect({
1288
+ * userAddress: wallet.address as `0x${string}`,
1289
+ * chainId: 8453,
1290
+ * publicClient,
1291
+ * walletClient,
1292
+ * signAuthorization,
1293
+ * });
1294
+ *
1295
+ * if (result.status === "already-delegated") {
1296
+ * console.log("Already delegated to", result.delegatedTo);
1297
+ * } else {
1298
+ * console.log("Delegated! tx:", result.txHash);
1299
+ * }
1300
+ * }
1301
+ * }
1302
+ * ```
1303
+ */
1304
+ declare function delegateDirect(params: DelegateDirectParams): Promise<DelegateDirectResult>;
1305
+
1155
1306
  /**
1156
1307
  * Parameters for `createPafiProxyTransport`.
1157
1308
  */
@@ -1820,4 +1971,4 @@ declare class PafiSDK {
1820
1971
  signLoginMessage(message: string): Promise<Hex>;
1821
1972
  }
1822
1973
 
1823
- export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
1974
+ export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositViaRelayParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, DUMMY_SIGNATURE_V07, type DelegateDirectParams, type DelegateDirectResult, type DelegateImpl, EIP712Signature, ENTRY_POINT_V07, ENTRY_POINT_V08, type Eip7702AuthorizationJsonRpc, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, PafiSdkError, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V4_QUOTER_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, createPafiProxyTransport, decodeBatchExecuteCalls, delegateDirect, detectDelegateImpl, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isDelegatedToTarget, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
package/dist/index.js CHANGED
@@ -739,6 +739,155 @@ function buildEip7702Authorization(params) {
739
739
  };
740
740
  }
741
741
 
742
+ // src/contracts/real/addresses.ts
743
+ var PLACEHOLDER_DEAD = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
744
+ var CONTRACT_ADDRESSES = {
745
+ // Base mainnet — SC-delivered (2026-04-21, 2026-04-22)
746
+ // registry: IssuerRegistry 0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31
747
+ // factory: PointTokenFactory 0x36c0BAb2faBE45EfA6d13001143e43A266Af673B
748
+ // oracle: MintingOracle 0xD85165939C700E51c8a45099316C6482634C2Ab9
749
+ // tokenImpl: PointToken (impl) 0x2e6FB1B0C1A51abb83eC974890126a64eC02E995
750
+ // mockUsdt: MockERC20 0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd
751
+ // POINT: PointToken instance 0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e
752
+ // batchExecutor: Pimlico Simple7702 0xe6Cae83BdE06E4c305530e199D7217f42808555B
753
+ // (v0.7.6 — switched from Coinbase SW v2
754
+ // `0x7702cb...7176C`; CSW v2 uses SignatureWrapper
755
+ // format that Pimlico's `pm_sponsorUserOperation`
756
+ // cannot produce a working dummy sig for, leading
757
+ // to AA23 `0x3c10b94e` reverts on the simulator.
758
+ // Pimlico's `Simple7702Account` accepts standard
759
+ // v0.7 ECDSA dummy and matches what the web FE +
760
+ // permissionless `to7702SimpleSmartAccount` already
761
+ // used in production.)
762
+ // pafiHook: PAFIHook (V4, 10%) 0x870cAF9882d3160602AaC1769C2B264A2d8EC044
763
+ 8453: {
764
+ pointToken: "0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e",
765
+ batchExecutor: "0xe6Cae83BdE06E4c305530e199D7217f42808555B",
766
+ usdt: "0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd",
767
+ issuerRegistry: "0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31",
768
+ mintingOracle: "0xD85165939C700E51c8a45099316C6482634C2Ab9",
769
+ pafiHook: "0x870cAF9882d3160602AaC1769C2B264A2d8EC044",
770
+ chainlinkEthUsd: "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
771
+ orderlyRelay: "0xDA082DAce1522c185aeB5A713FcA6fa6B6E99e7f",
772
+ pafiFeeRecipient: "0xa3F71eadEd101513a0151007590020dCFD7C495e",
773
+ universalRouter: "0x6fF5693b99212Da76ad316178A184AB56D299b43"
774
+ },
775
+ // Base Sepolia — not in active use; placeholders kept so the map
776
+ // compiles for tooling that enumerates chains.
777
+ 84532: {
778
+ pointToken: PLACEHOLDER_DEAD("dead"),
779
+ batchExecutor: PLACEHOLDER_DEAD("de01"),
780
+ usdt: PLACEHOLDER_DEAD("dead"),
781
+ issuerRegistry: PLACEHOLDER_DEAD("dead"),
782
+ mintingOracle: PLACEHOLDER_DEAD("dead"),
783
+ pafiHook: PLACEHOLDER_DEAD("dead"),
784
+ chainlinkEthUsd: PLACEHOLDER_DEAD("de02"),
785
+ orderlyRelay: PLACEHOLDER_DEAD("de03"),
786
+ pafiFeeRecipient: PLACEHOLDER_DEAD("de04"),
787
+ universalRouter: PLACEHOLDER_DEAD("de05")
788
+ }
789
+ };
790
+ var POINT_TOKEN_FACTORY_ADDRESSES = {
791
+ 8453: "0x36c0BAb2faBE45EfA6d13001143e43A266Af673B",
792
+ 84532: PLACEHOLDER_DEAD("dead")
793
+ };
794
+ var POINT_TOKEN_IMPL_ADDRESSES = {
795
+ 8453: "0x2e6FB1B0C1A51abb83eC974890126a64eC02E995",
796
+ 84532: PLACEHOLDER_DEAD("dead")
797
+ };
798
+ function getContractAddresses(chainId) {
799
+ const addrs = CONTRACT_ADDRESSES[chainId];
800
+ if (!addrs) {
801
+ throw new Error(
802
+ `getContractAddresses: no addresses for chainId ${chainId}. Supported: ${Object.keys(CONTRACT_ADDRESSES).join(", ")}`
803
+ );
804
+ }
805
+ return addrs;
806
+ }
807
+
808
+ // src/delegation/delegateDirect.ts
809
+ async function delegateDirect(params) {
810
+ const target = params.contractAddress ?? getContractAddresses(params.chainId).batchExecutor;
811
+ if (params.skipIfAlreadyDelegated !== false) {
812
+ const code = await params.publicClient.getCode({
813
+ address: params.userAddress
814
+ });
815
+ const current = parseEip7702DelegatedAddress(code);
816
+ if (current && current.toLowerCase() === target.toLowerCase()) {
817
+ return {
818
+ status: "already-delegated",
819
+ delegatedTo: current,
820
+ authorization: {
821
+ contractAddress: target,
822
+ chainId: params.chainId,
823
+ nonce: 0,
824
+ r: "0x",
825
+ s: "0x",
826
+ yParity: 0
827
+ }
828
+ };
829
+ }
830
+ }
831
+ const nonce = await params.publicClient.getTransactionCount({
832
+ address: params.userAddress,
833
+ blockTag: "pending"
834
+ });
835
+ const raw = await params.signAuthorization({
836
+ contractAddress: target,
837
+ chainId: params.chainId,
838
+ nonce
839
+ });
840
+ const yParityRaw = raw.yParity;
841
+ const yParity = typeof yParityRaw === "number" ? yParityRaw : String(yParityRaw) === "1" || String(yParityRaw) === "0x1" ? 1 : 0;
842
+ const authorization = {
843
+ contractAddress: target,
844
+ chainId: params.chainId,
845
+ nonce,
846
+ r: normalizeHex32(raw.r),
847
+ s: normalizeHex32(raw.s),
848
+ yParity
849
+ };
850
+ const account = params.walletClient.account;
851
+ if (!account) {
852
+ throw new Error(
853
+ "delegateDirect: walletClient has no account attached \u2014 cannot send tx"
854
+ );
855
+ }
856
+ const txHash = await params.walletClient.sendTransaction({
857
+ account,
858
+ chain: params.walletClient.chain,
859
+ to: params.userAddress,
860
+ value: 0n,
861
+ data: "0x",
862
+ authorizationList: [authorization]
863
+ });
864
+ const waitForReceipt = params.waitForReceipt !== false;
865
+ let receipt;
866
+ if (waitForReceipt) {
867
+ try {
868
+ receipt = await params.publicClient.waitForTransactionReceipt({
869
+ hash: txHash
870
+ });
871
+ } catch (err) {
872
+ params.onWarning?.(
873
+ `delegateDirect: tx ${txHash} sent but receipt fetch failed: ${err instanceof Error ? err.message : String(err)}`
874
+ );
875
+ }
876
+ }
877
+ return {
878
+ status: "sent",
879
+ txHash,
880
+ receipt,
881
+ authorization,
882
+ delegatedTo: target
883
+ };
884
+ }
885
+ function normalizeHex32(value) {
886
+ if (!value) return "0x";
887
+ const stripped = value.replace(/^0x/i, "");
888
+ return "0x" + stripped.padStart(64, "0");
889
+ }
890
+
742
891
  // src/transport/proxyTransport.ts
743
892
  import { http } from "viem";
744
893
  function createPafiProxyTransport(params) {
@@ -863,72 +1012,6 @@ async function fetchPafiPools(_chainId, pointTokenAddress, subgraphUrl = PAFI_SU
863
1012
  }];
864
1013
  }
865
1014
 
866
- // src/contracts/real/addresses.ts
867
- var PLACEHOLDER_DEAD = (suffix) => `0x000000000000000000000000000000000000${suffix.toLowerCase().padStart(4, "0")}`;
868
- var CONTRACT_ADDRESSES = {
869
- // Base mainnet — SC-delivered (2026-04-21, 2026-04-22)
870
- // registry: IssuerRegistry 0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31
871
- // factory: PointTokenFactory 0x36c0BAb2faBE45EfA6d13001143e43A266Af673B
872
- // oracle: MintingOracle 0xD85165939C700E51c8a45099316C6482634C2Ab9
873
- // tokenImpl: PointToken (impl) 0x2e6FB1B0C1A51abb83eC974890126a64eC02E995
874
- // mockUsdt: MockERC20 0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd
875
- // POINT: PointToken instance 0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e
876
- // batchExecutor: Pimlico Simple7702 0xe6Cae83BdE06E4c305530e199D7217f42808555B
877
- // (v0.7.6 — switched from Coinbase SW v2
878
- // `0x7702cb...7176C`; CSW v2 uses SignatureWrapper
879
- // format that Pimlico's `pm_sponsorUserOperation`
880
- // cannot produce a working dummy sig for, leading
881
- // to AA23 `0x3c10b94e` reverts on the simulator.
882
- // Pimlico's `Simple7702Account` accepts standard
883
- // v0.7 ECDSA dummy and matches what the web FE +
884
- // permissionless `to7702SimpleSmartAccount` already
885
- // used in production.)
886
- // pafiHook: PAFIHook (V4, 10%) 0x870cAF9882d3160602AaC1769C2B264A2d8EC044
887
- 8453: {
888
- pointToken: "0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e",
889
- batchExecutor: "0xe6Cae83BdE06E4c305530e199D7217f42808555B",
890
- usdt: "0x5d313485Ba59C3bb91e1A9C0C11782F0b83d5dcd",
891
- issuerRegistry: "0xda2D3338CF70F462Ac175F5f2edfa45660CA4f31",
892
- mintingOracle: "0xD85165939C700E51c8a45099316C6482634C2Ab9",
893
- pafiHook: "0x870cAF9882d3160602AaC1769C2B264A2d8EC044",
894
- chainlinkEthUsd: "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70",
895
- orderlyRelay: "0xDA082DAce1522c185aeB5A713FcA6fa6B6E99e7f",
896
- pafiFeeRecipient: "0xa3F71eadEd101513a0151007590020dCFD7C495e",
897
- universalRouter: "0x6fF5693b99212Da76ad316178A184AB56D299b43"
898
- },
899
- // Base Sepolia — not in active use; placeholders kept so the map
900
- // compiles for tooling that enumerates chains.
901
- 84532: {
902
- pointToken: PLACEHOLDER_DEAD("dead"),
903
- batchExecutor: PLACEHOLDER_DEAD("de01"),
904
- usdt: PLACEHOLDER_DEAD("dead"),
905
- issuerRegistry: PLACEHOLDER_DEAD("dead"),
906
- mintingOracle: PLACEHOLDER_DEAD("dead"),
907
- pafiHook: PLACEHOLDER_DEAD("dead"),
908
- chainlinkEthUsd: PLACEHOLDER_DEAD("de02"),
909
- orderlyRelay: PLACEHOLDER_DEAD("de03"),
910
- pafiFeeRecipient: PLACEHOLDER_DEAD("de04"),
911
- universalRouter: PLACEHOLDER_DEAD("de05")
912
- }
913
- };
914
- var POINT_TOKEN_FACTORY_ADDRESSES = {
915
- 8453: "0x36c0BAb2faBE45EfA6d13001143e43A266Af673B",
916
- 84532: PLACEHOLDER_DEAD("dead")
917
- };
918
- var POINT_TOKEN_IMPL_ADDRESSES = {
919
- 8453: "0x2e6FB1B0C1A51abb83eC974890126a64eC02E995",
920
- 84532: PLACEHOLDER_DEAD("dead")
921
- };
922
- function getContractAddresses(chainId) {
923
- const addrs = CONTRACT_ADDRESSES[chainId];
924
- if (!addrs) {
925
- throw new Error(
926
- `getContractAddresses: no addresses for chainId ${chainId}. Supported: ${Object.keys(CONTRACT_ADDRESSES).join(", ")}`
927
- );
928
- }
929
- return addrs;
930
- }
931
-
932
1015
  // src/fee/operatorFeeQuoter.ts
933
1016
  var CHAINLINK_ABI = parseAbi3([
934
1017
  "function latestRoundData() external view returns (uint80, int256, uint256, uint256, uint80)"
@@ -1433,6 +1516,7 @@ export {
1433
1516
  createLoginMessage,
1434
1517
  createPafiProxyTransport,
1435
1518
  decodeBatchExecuteCalls,
1519
+ delegateDirect,
1436
1520
  detectDelegateImpl,
1437
1521
  encodeBatchExecute,
1438
1522
  erc20Abi,