@pafi-dev/core 0.5.21 → 0.5.22
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.cjs +34 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -1
- package/dist/index.d.ts +48 -1
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -972,6 +972,53 @@ declare function computeAuthorizationHash(chainId: number, address: Address, non
|
|
|
972
972
|
*/
|
|
973
973
|
declare function isDelegatedToTarget(code: string | null | undefined, target: Address): boolean;
|
|
974
974
|
|
|
975
|
+
/**
|
|
976
|
+
* EIP-7702 authorization tuple in the JSON-RPC wire format that bundlers
|
|
977
|
+
* (Pimlico, Stackup, etc.) accept on `eth_sendUserOperation`. All
|
|
978
|
+
* numeric fields are 0x-prefixed hex strings.
|
|
979
|
+
*
|
|
980
|
+
* Constructed from the user's secp256k1 signature over
|
|
981
|
+
* `keccak256(0x05 || rlp([chainId, address, nonce]))` — see
|
|
982
|
+
* `computeAuthorizationHash`.
|
|
983
|
+
*/
|
|
984
|
+
interface Eip7702AuthorizationJsonRpc {
|
|
985
|
+
chainId: Hex;
|
|
986
|
+
address: Address;
|
|
987
|
+
nonce: Hex;
|
|
988
|
+
r: Hex;
|
|
989
|
+
s: Hex;
|
|
990
|
+
yParity: Hex;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Split a serialized 65-byte ECDSA signature (`r || s || v`) into the
|
|
994
|
+
* `{ r, s, yParity }` triple required by EIP-7702 authorization tuples
|
|
995
|
+
* and EIP-1559+ transactions.
|
|
996
|
+
*
|
|
997
|
+
* Accepts the legacy `v ∈ {27, 28}` form and converts to `yParity ∈ {0, 1}`
|
|
998
|
+
* automatically. Already-normalized `v ∈ {0, 1}` passes through unchanged.
|
|
999
|
+
*
|
|
1000
|
+
* @throws when the signature is not 65 bytes (130 hex chars).
|
|
1001
|
+
*/
|
|
1002
|
+
declare function splitAuthorizationSig(authSig: Hex | string): {
|
|
1003
|
+
r: Hex;
|
|
1004
|
+
s: Hex;
|
|
1005
|
+
yParity: 0 | 1;
|
|
1006
|
+
};
|
|
1007
|
+
/**
|
|
1008
|
+
* Build the JSON-RPC EIP-7702 authorization tuple from raw fields and a
|
|
1009
|
+
* 65-byte secp256k1 signature.
|
|
1010
|
+
*
|
|
1011
|
+
* The `authSig` is the user's signature over `computeAuthorizationHash(
|
|
1012
|
+
* chainId, address, nonce )` — typically obtained via
|
|
1013
|
+
* `wallet.signAuthorization(...)` on the client.
|
|
1014
|
+
*/
|
|
1015
|
+
declare function buildEip7702Authorization(params: {
|
|
1016
|
+
chainId: number;
|
|
1017
|
+
address: Address;
|
|
1018
|
+
nonce: bigint;
|
|
1019
|
+
authSig: Hex | string;
|
|
1020
|
+
}): Eip7702AuthorizationJsonRpc;
|
|
1021
|
+
|
|
975
1022
|
/**
|
|
976
1023
|
* Parameters for `createPafiProxyTransport`.
|
|
977
1024
|
*/
|
|
@@ -1599,4 +1646,4 @@ declare class PafiSDK {
|
|
|
1599
1646
|
signLoginMessage(message: string): Promise<Hex>;
|
|
1600
1647
|
}
|
|
1601
1648
|
|
|
1602
|
-
export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, 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, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, 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, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, QuoteResult, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpTypedData, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, 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, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
|
|
1649
|
+
export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, 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, Operation, 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, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, type QuoteOperatorFeePtConfig, QuoteResult, ReceiverConsent, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpTypedData, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _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, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, setPaymasterConfig, splitAuthorizationSig, webPopupAdapter };
|
package/dist/index.js
CHANGED
|
@@ -586,6 +586,37 @@ function toMinimalHex(n) {
|
|
|
586
586
|
return `0x${hex.length % 2 === 0 ? hex : "0" + hex}`;
|
|
587
587
|
}
|
|
588
588
|
|
|
589
|
+
// src/delegation/eip7702Authorization.ts
|
|
590
|
+
function splitAuthorizationSig(authSig) {
|
|
591
|
+
const raw = authSig.startsWith("0x") ? authSig.slice(2) : authSig;
|
|
592
|
+
if (raw.length !== 130) {
|
|
593
|
+
throw new Error(
|
|
594
|
+
`splitAuthorizationSig: expected 65-byte signature (130 hex chars), got ${raw.length}`
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
const r = `0x${raw.slice(0, 64)}`;
|
|
598
|
+
const s = `0x${raw.slice(64, 128)}`;
|
|
599
|
+
const v = parseInt(raw.slice(128, 130), 16);
|
|
600
|
+
const yParity = v === 27 ? 0 : v === 28 ? 1 : v;
|
|
601
|
+
if (yParity !== 0 && yParity !== 1) {
|
|
602
|
+
throw new Error(
|
|
603
|
+
`splitAuthorizationSig: invalid recovery byte ${v} (expected 0/1/27/28)`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
return { r, s, yParity };
|
|
607
|
+
}
|
|
608
|
+
function buildEip7702Authorization(params) {
|
|
609
|
+
const { r, s, yParity } = splitAuthorizationSig(params.authSig);
|
|
610
|
+
return {
|
|
611
|
+
chainId: `0x${params.chainId.toString(16)}`,
|
|
612
|
+
address: params.address,
|
|
613
|
+
nonce: `0x${params.nonce.toString(16)}`,
|
|
614
|
+
r,
|
|
615
|
+
s,
|
|
616
|
+
yParity: `0x${yParity}`
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
|
|
589
620
|
// src/transport/proxyTransport.ts
|
|
590
621
|
import { http } from "viem";
|
|
591
622
|
function createPafiProxyTransport(params) {
|
|
@@ -1257,6 +1288,7 @@ export {
|
|
|
1257
1288
|
buildBurnRequestTypedData,
|
|
1258
1289
|
buildDelegationUserOp,
|
|
1259
1290
|
buildDomain,
|
|
1291
|
+
buildEip7702Authorization,
|
|
1260
1292
|
buildErc20ApprovalCalldata,
|
|
1261
1293
|
buildMintRequestTypedData,
|
|
1262
1294
|
buildPartialUserOperation,
|
|
@@ -1336,6 +1368,7 @@ export {
|
|
|
1336
1368
|
signReceiverConsent,
|
|
1337
1369
|
signSponsorAuth,
|
|
1338
1370
|
simulateSwap,
|
|
1371
|
+
splitAuthorizationSig,
|
|
1339
1372
|
universalRouterAbi,
|
|
1340
1373
|
v4QuoterAbi,
|
|
1341
1374
|
verifyBurnRequest,
|