@pafi-dev/core 0.20.1 → 0.22.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/README.md +54 -0
- package/dist/index.cjs +43 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -2
- package/dist/index.d.ts +97 -2
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.d.cts
CHANGED
|
@@ -1499,6 +1499,87 @@ interface DelegateDirectResult {
|
|
|
1499
1499
|
*/
|
|
1500
1500
|
declare function delegateDirect(params: DelegateDirectParams): Promise<DelegateDirectResult>;
|
|
1501
1501
|
|
|
1502
|
+
interface AttachDelegationIfNeededParams {
|
|
1503
|
+
/**
|
|
1504
|
+
* Public client connected to the chain on which the delegation lives.
|
|
1505
|
+
* The helper uses it to (1) read on-chain code via `eth_getCode` and
|
|
1506
|
+
* (2) read the EOA's tx nonce — both reads must hit the SAME chain
|
|
1507
|
+
* that `chainId` declares, otherwise Pimlico's bundler will reject the
|
|
1508
|
+
* authorization with a chain-mismatch error.
|
|
1509
|
+
*/
|
|
1510
|
+
rpc: PublicClient;
|
|
1511
|
+
/**
|
|
1512
|
+
* The user's EOA — the wallet that will become a temporary smart account
|
|
1513
|
+
* via EIP-7702 SetCode. MUST match the `sender` of the UserOp the caller
|
|
1514
|
+
* is about to submit; otherwise the bundler's recovered-signer check
|
|
1515
|
+
* fails ("recovered signer does not match userOperation sender").
|
|
1516
|
+
*/
|
|
1517
|
+
account: Address;
|
|
1518
|
+
/**
|
|
1519
|
+
* The implementation address the EOA should delegate to — typically the
|
|
1520
|
+
* Pimlico Simple7702Account / BatchExecutor on the target chain (Base
|
|
1521
|
+
* mainnet: `0xe6Cae83BdE06E4c305530e199D7217f42808555B`).
|
|
1522
|
+
*
|
|
1523
|
+
* The helper compares the on-chain code at `account` against this address.
|
|
1524
|
+
* Mismatch → sign a new authorization to switch the delegate. Match →
|
|
1525
|
+
* return `undefined` (caller passes nothing — extra auth would be wasted
|
|
1526
|
+
* gas + the bundler may reject redundant authorizations).
|
|
1527
|
+
*/
|
|
1528
|
+
expectedDelegate: Address;
|
|
1529
|
+
/**
|
|
1530
|
+
* Chain id baked into the EIP-7702 authorization tuple. Must equal the
|
|
1531
|
+
* chain `rpc` connects to.
|
|
1532
|
+
*/
|
|
1533
|
+
chainId: number;
|
|
1534
|
+
/**
|
|
1535
|
+
* Privy-shaped authorization signer. Pass `useSign7702Authorization().signAuthorization`
|
|
1536
|
+
* directly on web, or the Expo SDK's equivalent on mobile.
|
|
1537
|
+
*
|
|
1538
|
+
* The helper feeds it `(contractAddress, chainId, nonce)` — the signer
|
|
1539
|
+
* MUST sign with the same private key that controls `account`, otherwise
|
|
1540
|
+
* the recovered signer mismatch above triggers.
|
|
1541
|
+
*/
|
|
1542
|
+
signAuthorization: SignAuthorizationFn;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Sign an EIP-7702 authorization for `account` ONLY when the EOA does not
|
|
1546
|
+
* already delegate to `expectedDelegate`. Returns the authorization in the
|
|
1547
|
+
* shape that permissionless / viem expect on
|
|
1548
|
+
* `smartClient.sendTransaction({ authorization, ... })`. Pimlico bundles
|
|
1549
|
+
* the SetCode + UserOp execution into a SINGLE bundler tx — "atomic
|
|
1550
|
+
* activation" — so the user never sees a separate "delegate" step on their
|
|
1551
|
+
* first action.
|
|
1552
|
+
*
|
|
1553
|
+
* Returns `undefined` when the EOA already points at `expectedDelegate`.
|
|
1554
|
+
* Caller spreads the return value into the tx params:
|
|
1555
|
+
*
|
|
1556
|
+
* ```ts
|
|
1557
|
+
* const authPart = await attachDelegationIfNeeded({ ... });
|
|
1558
|
+
* await smartClient.sendTransaction({
|
|
1559
|
+
* to: pointToken,
|
|
1560
|
+
* data: encodeMintCalldata(amount),
|
|
1561
|
+
* ...(authPart ?? {}), // attaches { authorization: ... } only when needed
|
|
1562
|
+
* });
|
|
1563
|
+
* ```
|
|
1564
|
+
*
|
|
1565
|
+
* Cost: 1 `eth_getCode` read every time + 1 `eth_getTransactionCount` +
|
|
1566
|
+
* 1 signature (only the first time per EOA). Subsequent calls collapse to
|
|
1567
|
+
* a single RPC read and return `undefined` — cheap to call before every
|
|
1568
|
+
* UserOp.
|
|
1569
|
+
*
|
|
1570
|
+
* Implementation notes:
|
|
1571
|
+
* - Comparison is case-insensitive (`isDelegatedTo` lowercases both
|
|
1572
|
+
* sides) so passing checksum-cased addresses is safe.
|
|
1573
|
+
* - Nonce is fetched freshly per call to avoid replaying an old nonce
|
|
1574
|
+
* when the FE held the helper params across multiple actions.
|
|
1575
|
+
* - The signed tuple is passed through `buildEip7702Authorization` to
|
|
1576
|
+
* normalise `r` / `s` / `yParity` into the wire shape Pimlico accepts
|
|
1577
|
+
* (handles Privy's bigint `v` and string-hex `yParity` variants).
|
|
1578
|
+
*/
|
|
1579
|
+
declare function attachDelegationIfNeeded(params: AttachDelegationIfNeededParams): Promise<{
|
|
1580
|
+
authorization: Eip7702AuthorizationJsonRpc;
|
|
1581
|
+
} | undefined>;
|
|
1582
|
+
|
|
1502
1583
|
/**
|
|
1503
1584
|
* Parameters for `createPafiProxyTransport`.
|
|
1504
1585
|
*/
|
|
@@ -2650,7 +2731,21 @@ declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Prom
|
|
|
2650
2731
|
* MintFeeWrapper. Schema entities: `MintFeeWrapper`, `MintFeeConfig`,
|
|
2651
2732
|
* `FeeRecipient`, `MintWithFeeEvent`, `FeeDistribution`.
|
|
2652
2733
|
*/
|
|
2653
|
-
|
|
2734
|
+
/**
|
|
2735
|
+
* Default subgraph endpoint. Points at `pafi-subgraph-v1` — the deployment
|
|
2736
|
+
* that indexes the V2 contract bucket (IssuerRegistry 0x3e8264…,
|
|
2737
|
+
* PointTokenFactory 0x34f9F8…, TokenRegistry 0x7092b3…, MintingOracle
|
|
2738
|
+
* 0x19F5Ea…, MintFeeWrapper 0x72B8FB…). Despite the "v1" name in the URL
|
|
2739
|
+
* this is the freshest subgraph — naming is a deploy-order artifact, not
|
|
2740
|
+
* a contract-version indicator.
|
|
2741
|
+
*
|
|
2742
|
+
* Previous deployments (`pafi-subgraph-v4`, `v5`) tracked the v1.6
|
|
2743
|
+
* contract bucket and have been retired alongside the v2 cutover.
|
|
2744
|
+
*
|
|
2745
|
+
* Override per-call via `subgraphUrl` parameter when you need to point at
|
|
2746
|
+
* a fork or a private graph node for staging.
|
|
2747
|
+
*/
|
|
2748
|
+
declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
|
|
2654
2749
|
/**
|
|
2655
2750
|
* Fetch the Uniswap V3 pool(s) for a PAFI PointToken from the subgraph.
|
|
2656
2751
|
*
|
|
@@ -2731,4 +2826,4 @@ declare class PafiSDK {
|
|
|
2731
2826
|
signLoginMessage(message: string): Promise<Hex>;
|
|
2732
2827
|
}
|
|
2733
2828
|
|
|
2734
|
-
export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, 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, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
|
|
2829
|
+
export { ApiError, type AttachDelegationIfNeededParams, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, 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, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, attachDelegationIfNeeded, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1499,6 +1499,87 @@ interface DelegateDirectResult {
|
|
|
1499
1499
|
*/
|
|
1500
1500
|
declare function delegateDirect(params: DelegateDirectParams): Promise<DelegateDirectResult>;
|
|
1501
1501
|
|
|
1502
|
+
interface AttachDelegationIfNeededParams {
|
|
1503
|
+
/**
|
|
1504
|
+
* Public client connected to the chain on which the delegation lives.
|
|
1505
|
+
* The helper uses it to (1) read on-chain code via `eth_getCode` and
|
|
1506
|
+
* (2) read the EOA's tx nonce — both reads must hit the SAME chain
|
|
1507
|
+
* that `chainId` declares, otherwise Pimlico's bundler will reject the
|
|
1508
|
+
* authorization with a chain-mismatch error.
|
|
1509
|
+
*/
|
|
1510
|
+
rpc: PublicClient;
|
|
1511
|
+
/**
|
|
1512
|
+
* The user's EOA — the wallet that will become a temporary smart account
|
|
1513
|
+
* via EIP-7702 SetCode. MUST match the `sender` of the UserOp the caller
|
|
1514
|
+
* is about to submit; otherwise the bundler's recovered-signer check
|
|
1515
|
+
* fails ("recovered signer does not match userOperation sender").
|
|
1516
|
+
*/
|
|
1517
|
+
account: Address;
|
|
1518
|
+
/**
|
|
1519
|
+
* The implementation address the EOA should delegate to — typically the
|
|
1520
|
+
* Pimlico Simple7702Account / BatchExecutor on the target chain (Base
|
|
1521
|
+
* mainnet: `0xe6Cae83BdE06E4c305530e199D7217f42808555B`).
|
|
1522
|
+
*
|
|
1523
|
+
* The helper compares the on-chain code at `account` against this address.
|
|
1524
|
+
* Mismatch → sign a new authorization to switch the delegate. Match →
|
|
1525
|
+
* return `undefined` (caller passes nothing — extra auth would be wasted
|
|
1526
|
+
* gas + the bundler may reject redundant authorizations).
|
|
1527
|
+
*/
|
|
1528
|
+
expectedDelegate: Address;
|
|
1529
|
+
/**
|
|
1530
|
+
* Chain id baked into the EIP-7702 authorization tuple. Must equal the
|
|
1531
|
+
* chain `rpc` connects to.
|
|
1532
|
+
*/
|
|
1533
|
+
chainId: number;
|
|
1534
|
+
/**
|
|
1535
|
+
* Privy-shaped authorization signer. Pass `useSign7702Authorization().signAuthorization`
|
|
1536
|
+
* directly on web, or the Expo SDK's equivalent on mobile.
|
|
1537
|
+
*
|
|
1538
|
+
* The helper feeds it `(contractAddress, chainId, nonce)` — the signer
|
|
1539
|
+
* MUST sign with the same private key that controls `account`, otherwise
|
|
1540
|
+
* the recovered signer mismatch above triggers.
|
|
1541
|
+
*/
|
|
1542
|
+
signAuthorization: SignAuthorizationFn;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Sign an EIP-7702 authorization for `account` ONLY when the EOA does not
|
|
1546
|
+
* already delegate to `expectedDelegate`. Returns the authorization in the
|
|
1547
|
+
* shape that permissionless / viem expect on
|
|
1548
|
+
* `smartClient.sendTransaction({ authorization, ... })`. Pimlico bundles
|
|
1549
|
+
* the SetCode + UserOp execution into a SINGLE bundler tx — "atomic
|
|
1550
|
+
* activation" — so the user never sees a separate "delegate" step on their
|
|
1551
|
+
* first action.
|
|
1552
|
+
*
|
|
1553
|
+
* Returns `undefined` when the EOA already points at `expectedDelegate`.
|
|
1554
|
+
* Caller spreads the return value into the tx params:
|
|
1555
|
+
*
|
|
1556
|
+
* ```ts
|
|
1557
|
+
* const authPart = await attachDelegationIfNeeded({ ... });
|
|
1558
|
+
* await smartClient.sendTransaction({
|
|
1559
|
+
* to: pointToken,
|
|
1560
|
+
* data: encodeMintCalldata(amount),
|
|
1561
|
+
* ...(authPart ?? {}), // attaches { authorization: ... } only when needed
|
|
1562
|
+
* });
|
|
1563
|
+
* ```
|
|
1564
|
+
*
|
|
1565
|
+
* Cost: 1 `eth_getCode` read every time + 1 `eth_getTransactionCount` +
|
|
1566
|
+
* 1 signature (only the first time per EOA). Subsequent calls collapse to
|
|
1567
|
+
* a single RPC read and return `undefined` — cheap to call before every
|
|
1568
|
+
* UserOp.
|
|
1569
|
+
*
|
|
1570
|
+
* Implementation notes:
|
|
1571
|
+
* - Comparison is case-insensitive (`isDelegatedTo` lowercases both
|
|
1572
|
+
* sides) so passing checksum-cased addresses is safe.
|
|
1573
|
+
* - Nonce is fetched freshly per call to avoid replaying an old nonce
|
|
1574
|
+
* when the FE held the helper params across multiple actions.
|
|
1575
|
+
* - The signed tuple is passed through `buildEip7702Authorization` to
|
|
1576
|
+
* normalise `r` / `s` / `yParity` into the wire shape Pimlico accepts
|
|
1577
|
+
* (handles Privy's bigint `v` and string-hex `yParity` variants).
|
|
1578
|
+
*/
|
|
1579
|
+
declare function attachDelegationIfNeeded(params: AttachDelegationIfNeededParams): Promise<{
|
|
1580
|
+
authorization: Eip7702AuthorizationJsonRpc;
|
|
1581
|
+
} | undefined>;
|
|
1582
|
+
|
|
1502
1583
|
/**
|
|
1503
1584
|
* Parameters for `createPafiProxyTransport`.
|
|
1504
1585
|
*/
|
|
@@ -2650,7 +2731,21 @@ declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Prom
|
|
|
2650
2731
|
* MintFeeWrapper. Schema entities: `MintFeeWrapper`, `MintFeeConfig`,
|
|
2651
2732
|
* `FeeRecipient`, `MintWithFeeEvent`, `FeeDistribution`.
|
|
2652
2733
|
*/
|
|
2653
|
-
|
|
2734
|
+
/**
|
|
2735
|
+
* Default subgraph endpoint. Points at `pafi-subgraph-v1` — the deployment
|
|
2736
|
+
* that indexes the V2 contract bucket (IssuerRegistry 0x3e8264…,
|
|
2737
|
+
* PointTokenFactory 0x34f9F8…, TokenRegistry 0x7092b3…, MintingOracle
|
|
2738
|
+
* 0x19F5Ea…, MintFeeWrapper 0x72B8FB…). Despite the "v1" name in the URL
|
|
2739
|
+
* this is the freshest subgraph — naming is a deploy-order artifact, not
|
|
2740
|
+
* a contract-version indicator.
|
|
2741
|
+
*
|
|
2742
|
+
* Previous deployments (`pafi-subgraph-v4`, `v5`) tracked the v1.6
|
|
2743
|
+
* contract bucket and have been retired alongside the v2 cutover.
|
|
2744
|
+
*
|
|
2745
|
+
* Override per-call via `subgraphUrl` parameter when you need to point at
|
|
2746
|
+
* a fork or a private graph node for staging.
|
|
2747
|
+
*/
|
|
2748
|
+
declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
|
|
2654
2749
|
/**
|
|
2655
2750
|
* Fetch the Uniswap V3 pool(s) for a PAFI PointToken from the subgraph.
|
|
2656
2751
|
*
|
|
@@ -2731,4 +2826,4 @@ declare class PafiSDK {
|
|
|
2731
2826
|
signLoginMessage(message: string): Promise<Hex>;
|
|
2732
2827
|
}
|
|
2733
2828
|
|
|
2734
|
-
export { ApiError, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, 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, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
|
|
2829
|
+
export { ApiError, type AttachDelegationIfNeededParams, BATCH_EXECUTOR_7702_IMPL, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, type BuildDelegationUserOpParams, type BuildErc20TransferParams, 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, type FallbackInfo, type FeeScenario, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_RELAY_ABI, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, type Operation, OracleStaleError, type OrderlyRelayDepositRequest, PAFI_SERVICE_URLS, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_ABI, POINT_TOKEN_BEACON_ADDRESSES, POINT_TOKEN_BURN_SIG_ABI, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_MINT_SIG_ABI, POINT_TOKEN_POOLS, type PackedUserOperationMessage, type PafiErrorType, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSdkError, type PafiServiceUrls, type PafiWebModalAdapter, type PafiWebModalHandle, type PartialUserOperation, type PaymasterConfig, type PaymasterFields, PointTokenDomainConfig, PoolKey, QUOTER_V2_ADDRESSES, type QuoteOperatorFeeForTransferConfig, type QuoteOperatorFeePtConfig, type QuoteOperatorFeeUsdtConfig, SCENARIO_GAS_UNITS, SDK_ERROR_HTTP_STATUS_CODE, SIMPLE_7702_IMPL_BASE_MAINNET, SUPPORTED_CHAINS, type SdkErrorHttpStatus, type SendWithPaymasterFallbackParams, type SignAuthorizationFn, type SignatureStruct, SignatureVerification, SignatureVerifyOptions, type SignedAuthorization, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, type UserOpReceipt, type UserOpTypedData, type UserOperation, V3Path, V3_FACTORY_ADDRESSES, V3_POOL_INIT_CODE_HASH, V3_SWAP_ROUTER_ADDRESSES, VAULT_BEACON_ADDRESSES, ValidationError, type VaultDepositFE, ZERO_VALUE, assembleUserOperation, attachDelegationIfNeeded, buildDelegationUserOp, buildEip7702Authorization, buildErc20TransferUserOp, buildPartialUserOperation, buildPerpDepositViaRelay, buildPerpDepositWithGasDeduction, buildUserOpTypedData, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, computeAuthorizationHash, computeUserOpHash, computeV3PoolAddress, createPafiProxyTransport, decodeBatchExecuteCalls, defaultErrorTypeForStatus, delegateDirect, detectDelegateImpl, encodeBatchExecute, encodeV3Path, encodeV3PathReversed, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getDummySignatureFor7702, getPafiServiceUrls, getPafiWebModalAdapter, isDelegatedTo, isDelegatedToTarget, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, quoteOperatorFeeForTransfer, quoteOperatorFeePt, quoteOperatorFeeUsdt, rawCallOp, sendWithPaymasterFallback, serializeUserOpToJsonRpc, setPafiWebModalAdapter, splitAuthorizationSig, webPopupAdapter };
|
package/dist/index.js
CHANGED
|
@@ -1048,6 +1048,46 @@ function normalizeHex32(value) {
|
|
|
1048
1048
|
return "0x" + stripped.padStart(64, "0");
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
+
// src/delegation/attachDelegationIfNeeded.ts
|
|
1052
|
+
var inFlight = /* @__PURE__ */ new Map();
|
|
1053
|
+
function cacheKey(chainId, account) {
|
|
1054
|
+
return `${chainId}:${account.toLowerCase()}`;
|
|
1055
|
+
}
|
|
1056
|
+
async function attachDelegationIfNeeded(params) {
|
|
1057
|
+
const key = cacheKey(params.chainId, params.account);
|
|
1058
|
+
const existing = inFlight.get(key);
|
|
1059
|
+
if (existing) return existing;
|
|
1060
|
+
const promise = doAttach(params).finally(() => {
|
|
1061
|
+
inFlight.delete(key);
|
|
1062
|
+
});
|
|
1063
|
+
inFlight.set(key, promise);
|
|
1064
|
+
return promise;
|
|
1065
|
+
}
|
|
1066
|
+
async function doAttach(params) {
|
|
1067
|
+
const { rpc, account, expectedDelegate, chainId, signAuthorization } = params;
|
|
1068
|
+
if (await isDelegatedTo(rpc, account, expectedDelegate)) {
|
|
1069
|
+
return void 0;
|
|
1070
|
+
}
|
|
1071
|
+
const nonce = await rpc.getTransactionCount({ address: account });
|
|
1072
|
+
const rawAuth = await signAuthorization({
|
|
1073
|
+
contractAddress: expectedDelegate,
|
|
1074
|
+
chainId,
|
|
1075
|
+
nonce
|
|
1076
|
+
});
|
|
1077
|
+
const authorization = {
|
|
1078
|
+
chainId: toHexQuantity(rawAuth.chainId),
|
|
1079
|
+
address: rawAuth.contractAddress ?? rawAuth.address ?? expectedDelegate,
|
|
1080
|
+
nonce: toHexQuantity(BigInt(rawAuth.nonce)),
|
|
1081
|
+
r: rawAuth.r,
|
|
1082
|
+
s: rawAuth.s,
|
|
1083
|
+
yParity: typeof rawAuth.yParity === "string" ? rawAuth.yParity.startsWith("0x") ? rawAuth.yParity : `0x${rawAuth.yParity}` : `0x${rawAuth.yParity}`
|
|
1084
|
+
};
|
|
1085
|
+
return { authorization };
|
|
1086
|
+
}
|
|
1087
|
+
function toHexQuantity(n) {
|
|
1088
|
+
return `0x${BigInt(n).toString(16)}`;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1051
1091
|
// src/transport/proxyTransport.ts
|
|
1052
1092
|
import { http } from "viem";
|
|
1053
1093
|
function createPafiProxyTransport(params) {
|
|
@@ -1107,7 +1147,7 @@ import { parseAbi as parseAbi3 } from "viem";
|
|
|
1107
1147
|
|
|
1108
1148
|
// src/subgraph/pools.ts
|
|
1109
1149
|
import { isAddress } from "viem";
|
|
1110
|
-
var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-
|
|
1150
|
+
var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v1";
|
|
1111
1151
|
var POOL_QUERY = `
|
|
1112
1152
|
query GetPoolForPointToken($id: ID!) {
|
|
1113
1153
|
pafiToken(id: $id) {
|
|
@@ -1796,6 +1836,7 @@ export {
|
|
|
1796
1836
|
ZERO_VALUE,
|
|
1797
1837
|
assembleUserOperation,
|
|
1798
1838
|
assertDomainMatchesContract,
|
|
1839
|
+
attachDelegationIfNeeded,
|
|
1799
1840
|
buildAndSignSponsorAuth,
|
|
1800
1841
|
buildBurnRequestTypedData,
|
|
1801
1842
|
buildDelegationUserOp,
|