@pafi-dev/core 0.5.0 → 0.5.2
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 +100 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +79 -1
- package/dist/index.d.ts +79 -1
- package/dist/index.js +102 -12
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.d.cts
CHANGED
|
@@ -718,6 +718,69 @@ interface PafiProxyTransportParams {
|
|
|
718
718
|
*/
|
|
719
719
|
declare function createPafiProxyTransport(params: PafiProxyTransportParams): HttpTransport;
|
|
720
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Minimal interface for any smart-account client capable of submitting
|
|
723
|
+
* transactions. Deliberately duck-typed so the SDK does not need a hard
|
|
724
|
+
* dependency on permissionless — any client with this shape works.
|
|
725
|
+
*/
|
|
726
|
+
interface SmartAccountSender {
|
|
727
|
+
sendTransaction(params: Record<string, unknown>): Promise<Hex>;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Returns true when `err` originates from the **paymaster layer** rather
|
|
731
|
+
* than the contract or bundler layer. Covers:
|
|
732
|
+
*
|
|
733
|
+
* - ERC-4337 AA3x validation errors (AA31–AA34)
|
|
734
|
+
* - Pimlico sponsorship rejections (`pm_*` methods, "sponsorship" messages)
|
|
735
|
+
* - PAFI proxy HTTP errors (401, 403, 429, 503)
|
|
736
|
+
* - Generic "rate limit" / "unauthorized" strings
|
|
737
|
+
*
|
|
738
|
+
* Use this to decide whether retrying without a paymaster makes sense.
|
|
739
|
+
* Contract reverts (AA23, AA24, AA25) and bundler errors are NOT matched.
|
|
740
|
+
*/
|
|
741
|
+
declare function isPaymasterError(err: unknown): boolean;
|
|
742
|
+
interface SendWithPaymasterFallbackParams {
|
|
743
|
+
/** Smart-account client with paymaster configured — tried first. */
|
|
744
|
+
primaryClient: SmartAccountSender;
|
|
745
|
+
/**
|
|
746
|
+
* Smart-account client without paymaster — used when `primaryClient`
|
|
747
|
+
* throws a paymaster error. User pays gas from their ETH balance.
|
|
748
|
+
* Pass `null` or `undefined` to disable fallback (error re-thrown as-is).
|
|
749
|
+
*/
|
|
750
|
+
fallbackClient: SmartAccountSender | null | undefined;
|
|
751
|
+
/** Transaction params forwarded verbatim to `sendTransaction`. */
|
|
752
|
+
txParams: Record<string, unknown>;
|
|
753
|
+
/**
|
|
754
|
+
* Called just before the fallback attempt so the caller can log or
|
|
755
|
+
* update UI. Receives the error message from the failed primary attempt.
|
|
756
|
+
*/
|
|
757
|
+
onFallback?: (errorMessage: string) => void;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Submit a UserOp with paymaster sponsorship, falling back to user-paid gas
|
|
761
|
+
* if the paymaster refuses.
|
|
762
|
+
*
|
|
763
|
+
* Flow:
|
|
764
|
+
* 1. Call `primaryClient.sendTransaction(txParams)`.
|
|
765
|
+
* 2. If it throws and `isPaymasterError` returns true, call `onFallback` then
|
|
766
|
+
* retry with `fallbackClient` (no paymaster — user pays gas).
|
|
767
|
+
* 3. All other errors (contract revert, bundler rejection, network) are
|
|
768
|
+
* re-thrown immediately without a retry.
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* import { sendWithPaymasterFallback } from '@pafi-dev/core';
|
|
773
|
+
*
|
|
774
|
+
* const txHash = await sendWithPaymasterFallback({
|
|
775
|
+
* primaryClient: smartClientWithPaymaster,
|
|
776
|
+
* fallbackClient: smartClientNoPaymaster,
|
|
777
|
+
* txParams: { calls, paymasterContext: { sponsorshipPolicyId } },
|
|
778
|
+
* onFallback: (msg) => addLog(`Paymaster refused (${msg}) — you will pay gas.`),
|
|
779
|
+
* });
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
declare function sendWithPaymasterFallback(params: SendWithPaymasterFallbackParams): Promise<Hex>;
|
|
783
|
+
|
|
721
784
|
/**
|
|
722
785
|
* Real `PointToken` ABI — matches the contract deployed on Base mainnet
|
|
723
786
|
* (POINT at `0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e`). Sourced from
|
|
@@ -1343,6 +1406,21 @@ declare function getPafiWebModalAdapter(): PafiWebModalAdapter | null;
|
|
|
1343
1406
|
*/
|
|
1344
1407
|
declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Promise<PafiWebModalHandle>;
|
|
1345
1408
|
|
|
1409
|
+
/** PAFI-hosted subgraph endpoint — single source of truth across all SDK packages. */
|
|
1410
|
+
declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
|
|
1411
|
+
/**
|
|
1412
|
+
* Fetch the Uniswap V4 pool(s) for a PAFI PointToken from the subgraph.
|
|
1413
|
+
*
|
|
1414
|
+
* Browser and Node compatible — uses globalThis.fetch. Returns an empty
|
|
1415
|
+
* array (never throws) when the token has no pool yet or the subgraph is
|
|
1416
|
+
* unreachable, so callers can show "quote unavailable" without crashing.
|
|
1417
|
+
*
|
|
1418
|
+
* @param chainId - Chain ID (reserved for multi-subgraph routing; currently unused)
|
|
1419
|
+
* @param pointTokenAddress - The PointToken contract address
|
|
1420
|
+
* @param subgraphUrl - Override the default PAFI subgraph URL
|
|
1421
|
+
*/
|
|
1422
|
+
declare function fetchPafiPools(_chainId: number, pointTokenAddress: Address, subgraphUrl?: string): Promise<PoolKey[]>;
|
|
1423
|
+
|
|
1346
1424
|
declare class PafiSDK {
|
|
1347
1425
|
private _pointTokenAddress?;
|
|
1348
1426
|
private _signer?;
|
|
@@ -1478,4 +1556,4 @@ declare class PafiSDK {
|
|
|
1478
1556
|
signLoginMessage(message: string): Promise<Hex>;
|
|
1479
1557
|
}
|
|
1480
1558
|
|
|
1481
|
-
export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
|
|
1559
|
+
export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
|
package/dist/index.d.ts
CHANGED
|
@@ -718,6 +718,69 @@ interface PafiProxyTransportParams {
|
|
|
718
718
|
*/
|
|
719
719
|
declare function createPafiProxyTransport(params: PafiProxyTransportParams): HttpTransport;
|
|
720
720
|
|
|
721
|
+
/**
|
|
722
|
+
* Minimal interface for any smart-account client capable of submitting
|
|
723
|
+
* transactions. Deliberately duck-typed so the SDK does not need a hard
|
|
724
|
+
* dependency on permissionless — any client with this shape works.
|
|
725
|
+
*/
|
|
726
|
+
interface SmartAccountSender {
|
|
727
|
+
sendTransaction(params: Record<string, unknown>): Promise<Hex>;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Returns true when `err` originates from the **paymaster layer** rather
|
|
731
|
+
* than the contract or bundler layer. Covers:
|
|
732
|
+
*
|
|
733
|
+
* - ERC-4337 AA3x validation errors (AA31–AA34)
|
|
734
|
+
* - Pimlico sponsorship rejections (`pm_*` methods, "sponsorship" messages)
|
|
735
|
+
* - PAFI proxy HTTP errors (401, 403, 429, 503)
|
|
736
|
+
* - Generic "rate limit" / "unauthorized" strings
|
|
737
|
+
*
|
|
738
|
+
* Use this to decide whether retrying without a paymaster makes sense.
|
|
739
|
+
* Contract reverts (AA23, AA24, AA25) and bundler errors are NOT matched.
|
|
740
|
+
*/
|
|
741
|
+
declare function isPaymasterError(err: unknown): boolean;
|
|
742
|
+
interface SendWithPaymasterFallbackParams {
|
|
743
|
+
/** Smart-account client with paymaster configured — tried first. */
|
|
744
|
+
primaryClient: SmartAccountSender;
|
|
745
|
+
/**
|
|
746
|
+
* Smart-account client without paymaster — used when `primaryClient`
|
|
747
|
+
* throws a paymaster error. User pays gas from their ETH balance.
|
|
748
|
+
* Pass `null` or `undefined` to disable fallback (error re-thrown as-is).
|
|
749
|
+
*/
|
|
750
|
+
fallbackClient: SmartAccountSender | null | undefined;
|
|
751
|
+
/** Transaction params forwarded verbatim to `sendTransaction`. */
|
|
752
|
+
txParams: Record<string, unknown>;
|
|
753
|
+
/**
|
|
754
|
+
* Called just before the fallback attempt so the caller can log or
|
|
755
|
+
* update UI. Receives the error message from the failed primary attempt.
|
|
756
|
+
*/
|
|
757
|
+
onFallback?: (errorMessage: string) => void;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Submit a UserOp with paymaster sponsorship, falling back to user-paid gas
|
|
761
|
+
* if the paymaster refuses.
|
|
762
|
+
*
|
|
763
|
+
* Flow:
|
|
764
|
+
* 1. Call `primaryClient.sendTransaction(txParams)`.
|
|
765
|
+
* 2. If it throws and `isPaymasterError` returns true, call `onFallback` then
|
|
766
|
+
* retry with `fallbackClient` (no paymaster — user pays gas).
|
|
767
|
+
* 3. All other errors (contract revert, bundler rejection, network) are
|
|
768
|
+
* re-thrown immediately without a retry.
|
|
769
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* import { sendWithPaymasterFallback } from '@pafi-dev/core';
|
|
773
|
+
*
|
|
774
|
+
* const txHash = await sendWithPaymasterFallback({
|
|
775
|
+
* primaryClient: smartClientWithPaymaster,
|
|
776
|
+
* fallbackClient: smartClientNoPaymaster,
|
|
777
|
+
* txParams: { calls, paymasterContext: { sponsorshipPolicyId } },
|
|
778
|
+
* onFallback: (msg) => addLog(`Paymaster refused (${msg}) — you will pay gas.`),
|
|
779
|
+
* });
|
|
780
|
+
* ```
|
|
781
|
+
*/
|
|
782
|
+
declare function sendWithPaymasterFallback(params: SendWithPaymasterFallbackParams): Promise<Hex>;
|
|
783
|
+
|
|
721
784
|
/**
|
|
722
785
|
* Real `PointToken` ABI — matches the contract deployed on Base mainnet
|
|
723
786
|
* (POINT at `0x7d25E7156E51F865D522fd3ef257a6B5DD41b97e`). Sourced from
|
|
@@ -1343,6 +1406,21 @@ declare function getPafiWebModalAdapter(): PafiWebModalAdapter | null;
|
|
|
1343
1406
|
*/
|
|
1344
1407
|
declare function openPafiWebModal(url: string, options?: ModalOpenOptions): Promise<PafiWebModalHandle>;
|
|
1345
1408
|
|
|
1409
|
+
/** PAFI-hosted subgraph endpoint — single source of truth across all SDK packages. */
|
|
1410
|
+
declare const PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
|
|
1411
|
+
/**
|
|
1412
|
+
* Fetch the Uniswap V4 pool(s) for a PAFI PointToken from the subgraph.
|
|
1413
|
+
*
|
|
1414
|
+
* Browser and Node compatible — uses globalThis.fetch. Returns an empty
|
|
1415
|
+
* array (never throws) when the token has no pool yet or the subgraph is
|
|
1416
|
+
* unreachable, so callers can show "quote unavailable" without crashing.
|
|
1417
|
+
*
|
|
1418
|
+
* @param chainId - Chain ID (reserved for multi-subgraph routing; currently unused)
|
|
1419
|
+
* @param pointTokenAddress - The PointToken contract address
|
|
1420
|
+
* @param subgraphUrl - Override the default PAFI subgraph URL
|
|
1421
|
+
*/
|
|
1422
|
+
declare function fetchPafiPools(_chainId: number, pointTokenAddress: Address, subgraphUrl?: string): Promise<PoolKey[]>;
|
|
1423
|
+
|
|
1346
1424
|
declare class PafiSDK {
|
|
1347
1425
|
private _pointTokenAddress?;
|
|
1348
1426
|
private _signer?;
|
|
@@ -1478,4 +1556,4 @@ declare class PafiSDK {
|
|
|
1478
1556
|
signLoginMessage(message: string): Promise<Hex>;
|
|
1479
1557
|
}
|
|
1480
1558
|
|
|
1481
|
-
export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
|
|
1559
|
+
export { ApiError, BATCH_EXECUTOR_ABI, BATCH_EXECUTOR_ADDRESS_BASE_MAINNET, BATCH_EXECUTOR_ADDRESS_BASE_SEPOLIA, BROKER_HASHES, BestQuote, type BuildDelegationUserOpParams, type BuildPartialUserOpParams, type BuildPerpDepositWithGasDeductionParams, COMMON_POOLS, COMMON_TOKENS, CONTRACT_ADDRESSES, ChainConfig, type CheckEthAndBranchParams, ConfigurationError, type ContractAddresses, EIP712Signature, ENTRY_POINT_V07, LoginMessageParams, MintRequest, type ModalOpenOptions, ORDERLY_VAULT_ABI, ORDERLY_VAULT_ADDRESSES, ORDERLY_VAULT_BASE_MAINNET, Operation, PAFI_SUBGRAPH_URL, PERMIT2_ADDRESS, POINT_TOKEN_FACTORY_ADDRESSES, POINT_TOKEN_IMPL_ADDRESSES, POINT_TOKEN_POOLS, POINT_TOKEN_ABI as POINT_TOKEN_V2_ABI, type PafiProxyTransportParams, PafiSDK, PafiSDKConfig, PafiSDKError, type PafiWebModalAdapter, type PafiWebModalHandle, PartialUserOperation, type PaymasterConfig, PointTokenDomainConfig, PoolKey, QuoteResult, ReceiverConsent, SUPPORTED_CHAINS, type SendWithPaymasterFallbackParams, type SignatureStruct, SignatureVerification, SigningError, SimulationError, type SmartAccountSender, type SponsorshipScenario, type SubmissionPath, SwapSimulationResult, TOKEN_HASHES, UNIVERSAL_ROUTER_ADDRESSES, UserOperation, V4_QUOTER_ADDRESSES, type VaultDepositFE, _resetPaymasterConfigForTests, assembleUserOperation, buildDelegationUserOp, buildPartialUserOperation, buildPerpDepositWithGasDeduction, burnRequestTypes, checkDelegation, checkEthAndBranch, computeAccountId, createPafiProxyTransport, encodeBatchExecute, erc20ApproveOp, erc20BurnOp, erc20TransferOp, fetchPafiPools, getAaNonce, getContractAddresses, getPafiWebModalAdapter, getPaymasterConfig, isDelegatedTo, isPaymasterConfigured, isPaymasterError, mintRequestTypes, openPafiWebModal, openWebPopup, parseEip7702DelegatedAddress, rawCallOp, receiverConsentTypes, sendWithPaymasterFallback, setPafiWebModalAdapter, setPaymasterConfig, webPopupAdapter };
|
package/dist/index.js
CHANGED
|
@@ -13,18 +13,6 @@ import {
|
|
|
13
13
|
verifyLoginMessage,
|
|
14
14
|
verifySponsorAuth
|
|
15
15
|
} from "./chunk-W6VULMCO.js";
|
|
16
|
-
import {
|
|
17
|
-
buildBurnRequestTypedData,
|
|
18
|
-
buildDomain,
|
|
19
|
-
buildMintRequestTypedData,
|
|
20
|
-
buildReceiverConsentTypedData,
|
|
21
|
-
signBurnRequest,
|
|
22
|
-
signMintRequest,
|
|
23
|
-
signReceiverConsent,
|
|
24
|
-
verifyBurnRequest,
|
|
25
|
-
verifyMintRequest,
|
|
26
|
-
verifyReceiverConsent
|
|
27
|
-
} from "./chunk-WTWG6QXP.js";
|
|
28
16
|
import {
|
|
29
17
|
getIssuer,
|
|
30
18
|
getIssuer2,
|
|
@@ -42,6 +30,18 @@ import {
|
|
|
42
30
|
mintingOracleAbi,
|
|
43
31
|
pointTokenAbi
|
|
44
32
|
} from "./chunk-FXNG4G22.js";
|
|
33
|
+
import {
|
|
34
|
+
buildBurnRequestTypedData,
|
|
35
|
+
buildDomain,
|
|
36
|
+
buildMintRequestTypedData,
|
|
37
|
+
buildReceiverConsentTypedData,
|
|
38
|
+
signBurnRequest,
|
|
39
|
+
signMintRequest,
|
|
40
|
+
signReceiverConsent,
|
|
41
|
+
verifyBurnRequest,
|
|
42
|
+
verifyMintRequest,
|
|
43
|
+
verifyReceiverConsent
|
|
44
|
+
} from "./chunk-WTWG6QXP.js";
|
|
45
45
|
import {
|
|
46
46
|
buildAllPaths,
|
|
47
47
|
combineRoutes,
|
|
@@ -374,6 +374,25 @@ function createPafiProxyTransport(params) {
|
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
+
// src/transport/paymasterFallback.ts
|
|
378
|
+
function isPaymasterError(err) {
|
|
379
|
+
const msg = (err?.message ?? String(err)).toLowerCase();
|
|
380
|
+
return msg.includes("paymaster") || msg.includes("sponsorship") || msg.includes("aa31") || msg.includes("aa32") || msg.includes("aa33") || msg.includes("aa34") || msg.includes("pm_") || msg.includes("rate limit") || msg.includes("unauthorized") || msg.includes("403") || msg.includes("429") || msg.includes("503");
|
|
381
|
+
}
|
|
382
|
+
async function sendWithPaymasterFallback(params) {
|
|
383
|
+
const { primaryClient, fallbackClient, txParams, onFallback } = params;
|
|
384
|
+
try {
|
|
385
|
+
return await primaryClient.sendTransaction(txParams);
|
|
386
|
+
} catch (err) {
|
|
387
|
+
if (isPaymasterError(err) && fallbackClient) {
|
|
388
|
+
const msg = err?.message ?? String(err);
|
|
389
|
+
onFallback?.(msg);
|
|
390
|
+
return await fallbackClient.sendTransaction(txParams);
|
|
391
|
+
}
|
|
392
|
+
throw err;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
377
396
|
// src/contracts/real/pointToken.ts
|
|
378
397
|
import { parseAbi } from "viem";
|
|
379
398
|
var POINT_TOKEN_ABI = parseAbi([
|
|
@@ -593,6 +612,73 @@ async function openPafiWebModal(url, options = {}) {
|
|
|
593
612
|
);
|
|
594
613
|
}
|
|
595
614
|
|
|
615
|
+
// src/subgraph/pools.ts
|
|
616
|
+
import { isAddress } from "viem";
|
|
617
|
+
var PAFI_SUBGRAPH_URL = "https://graph-base-mainnet.pacificfinance.org/subgraphs/name/pafi-subgraph-v2";
|
|
618
|
+
var POOL_QUERY = `
|
|
619
|
+
query GetPoolForPointToken($id: ID!) {
|
|
620
|
+
pafiToken(id: $id) {
|
|
621
|
+
id
|
|
622
|
+
pool {
|
|
623
|
+
id
|
|
624
|
+
feeTier
|
|
625
|
+
tickSpacing
|
|
626
|
+
hooks
|
|
627
|
+
token0 { id }
|
|
628
|
+
token1 { id }
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
`;
|
|
633
|
+
function sortCurrencies(a, b) {
|
|
634
|
+
return a.toLowerCase() < b.toLowerCase() ? [a, b] : [b, a];
|
|
635
|
+
}
|
|
636
|
+
async function fetchPafiPools(_chainId, pointTokenAddress, subgraphUrl = PAFI_SUBGRAPH_URL) {
|
|
637
|
+
let response;
|
|
638
|
+
try {
|
|
639
|
+
response = await fetch(subgraphUrl, {
|
|
640
|
+
method: "POST",
|
|
641
|
+
headers: { "Content-Type": "application/json" },
|
|
642
|
+
body: JSON.stringify({
|
|
643
|
+
query: POOL_QUERY,
|
|
644
|
+
variables: { id: pointTokenAddress.toLowerCase() }
|
|
645
|
+
})
|
|
646
|
+
});
|
|
647
|
+
} catch (err) {
|
|
648
|
+
console.warn("[fetchPafiPools] subgraph unreachable:", err.message);
|
|
649
|
+
return [];
|
|
650
|
+
}
|
|
651
|
+
if (!response.ok) {
|
|
652
|
+
console.warn(`[fetchPafiPools] subgraph returned ${response.status}`);
|
|
653
|
+
return [];
|
|
654
|
+
}
|
|
655
|
+
const json = await response.json();
|
|
656
|
+
if (json.errors && json.errors.length > 0) {
|
|
657
|
+
console.warn(
|
|
658
|
+
"[fetchPafiPools] subgraph errors:",
|
|
659
|
+
json.errors.map((e) => e.message).join("; ")
|
|
660
|
+
);
|
|
661
|
+
return [];
|
|
662
|
+
}
|
|
663
|
+
const pool = json.data?.pafiToken?.pool;
|
|
664
|
+
if (!pool) return [];
|
|
665
|
+
if (!isAddress(pool.hooks) || !isAddress(pool.token0.id) || !isAddress(pool.token1.id) || !Number.isFinite(Number(pool.feeTier)) || !Number.isFinite(Number(pool.tickSpacing))) {
|
|
666
|
+
console.error("[fetchPafiPools] invalid pool data in subgraph response \u2014 skipping");
|
|
667
|
+
return [];
|
|
668
|
+
}
|
|
669
|
+
const [currency0, currency1] = sortCurrencies(
|
|
670
|
+
pool.token0.id,
|
|
671
|
+
pool.token1.id
|
|
672
|
+
);
|
|
673
|
+
return [{
|
|
674
|
+
currency0,
|
|
675
|
+
currency1,
|
|
676
|
+
fee: Number(pool.feeTier),
|
|
677
|
+
tickSpacing: Number(pool.tickSpacing),
|
|
678
|
+
hooks: pool.hooks
|
|
679
|
+
}];
|
|
680
|
+
}
|
|
681
|
+
|
|
596
682
|
// src/index.ts
|
|
597
683
|
var PafiSDK = class {
|
|
598
684
|
_pointTokenAddress;
|
|
@@ -826,6 +912,7 @@ export {
|
|
|
826
912
|
ORDERLY_VAULT_ABI,
|
|
827
913
|
ORDERLY_VAULT_ADDRESSES,
|
|
828
914
|
ORDERLY_VAULT_BASE_MAINNET,
|
|
915
|
+
PAFI_SUBGRAPH_URL,
|
|
829
916
|
PERMIT2_ADDRESS,
|
|
830
917
|
POINT_TOKEN_FACTORY_ADDRESSES,
|
|
831
918
|
POINT_TOKEN_IMPL_ADDRESSES,
|
|
@@ -878,6 +965,7 @@ export {
|
|
|
878
965
|
erc20ApproveOp,
|
|
879
966
|
erc20BurnOp,
|
|
880
967
|
erc20TransferOp,
|
|
968
|
+
fetchPafiPools,
|
|
881
969
|
findBestQuote,
|
|
882
970
|
getAaNonce,
|
|
883
971
|
getContractAddresses,
|
|
@@ -894,6 +982,7 @@ export {
|
|
|
894
982
|
isDelegatedTo,
|
|
895
983
|
isMinter,
|
|
896
984
|
isPaymasterConfigured,
|
|
985
|
+
isPaymasterError,
|
|
897
986
|
issuerRegistryAbi,
|
|
898
987
|
mintRequestTypes,
|
|
899
988
|
mintingOracleAbi,
|
|
@@ -909,6 +998,7 @@ export {
|
|
|
909
998
|
quoteExactInputSingle,
|
|
910
999
|
rawCallOp,
|
|
911
1000
|
receiverConsentTypes,
|
|
1001
|
+
sendWithPaymasterFallback,
|
|
912
1002
|
setPafiWebModalAdapter,
|
|
913
1003
|
setPaymasterConfig,
|
|
914
1004
|
signBurnRequest,
|