@pafi-dev/issuer 0.5.33 → 0.5.34
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 +78 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -2
- package/dist/index.d.ts +94 -2
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,8 @@ __export(index_exports, {
|
|
|
23
23
|
AuthError: () => AuthError,
|
|
24
24
|
AuthService: () => AuthService,
|
|
25
25
|
BalanceAggregator: () => BalanceAggregator,
|
|
26
|
+
BundlerNotConfiguredError: () => BundlerNotConfiguredError,
|
|
27
|
+
BundlerRejectedError: () => BundlerRejectedError,
|
|
26
28
|
BurnIndexer: () => BurnIndexer,
|
|
27
29
|
DefaultPolicyEngine: () => DefaultPolicyEngine,
|
|
28
30
|
FeeManager: () => FeeManager,
|
|
@@ -53,6 +55,8 @@ __export(index_exports, {
|
|
|
53
55
|
handleRedeemStatus: () => handleRedeemStatus,
|
|
54
56
|
mergePaymasterFields: () => mergePaymasterFields,
|
|
55
57
|
prepareMobileUserOp: () => prepareMobileUserOp,
|
|
58
|
+
relayUserOp: () => relayUserOp,
|
|
59
|
+
requestPaymaster: () => requestPaymaster,
|
|
56
60
|
serializeEntryToJsonRpc: () => serializeEntryToJsonRpc,
|
|
57
61
|
serializeUserOpTypedData: () => serializeUserOpTypedData
|
|
58
62
|
});
|
|
@@ -2360,6 +2364,76 @@ var PafiBackendClient = class {
|
|
|
2360
2364
|
}
|
|
2361
2365
|
};
|
|
2362
2366
|
|
|
2367
|
+
// src/pafi-backend/helpers.ts
|
|
2368
|
+
var BundlerNotConfiguredError = class extends Error {
|
|
2369
|
+
code = "BUNDLER_NOT_CONFIGURED";
|
|
2370
|
+
constructor() {
|
|
2371
|
+
super(
|
|
2372
|
+
"PAFI backend client not configured \u2014 set PAFI_BACKEND_URL, PAFI_ISSUER_ID, PAFI_API_KEY to enable mobile submit."
|
|
2373
|
+
);
|
|
2374
|
+
this.name = "BundlerNotConfiguredError";
|
|
2375
|
+
}
|
|
2376
|
+
};
|
|
2377
|
+
var BundlerRejectedError = class extends Error {
|
|
2378
|
+
code = "BUNDLER_REJECTED";
|
|
2379
|
+
cause;
|
|
2380
|
+
constructor(message, cause) {
|
|
2381
|
+
super(message);
|
|
2382
|
+
this.name = "BundlerRejectedError";
|
|
2383
|
+
this.cause = cause;
|
|
2384
|
+
}
|
|
2385
|
+
};
|
|
2386
|
+
async function requestPaymaster(params) {
|
|
2387
|
+
if (!params.client) return void 0;
|
|
2388
|
+
const fn = params.functionName ?? defaultFunctionForScenario(params.scenario);
|
|
2389
|
+
try {
|
|
2390
|
+
return await params.client.requestSponsorship({
|
|
2391
|
+
chainId: params.chainId,
|
|
2392
|
+
scenario: params.scenario,
|
|
2393
|
+
userOp: params.userOp,
|
|
2394
|
+
target: {
|
|
2395
|
+
contract: params.pointTokenAddress,
|
|
2396
|
+
function: fn,
|
|
2397
|
+
pointToken: params.pointTokenAddress
|
|
2398
|
+
}
|
|
2399
|
+
});
|
|
2400
|
+
} catch (err) {
|
|
2401
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2402
|
+
params.onWarning?.(`Paymaster sponsorship declined: ${msg}`);
|
|
2403
|
+
return void 0;
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
function defaultFunctionForScenario(scenario) {
|
|
2407
|
+
switch (scenario) {
|
|
2408
|
+
case "mint":
|
|
2409
|
+
return "mint";
|
|
2410
|
+
case "burn":
|
|
2411
|
+
return "burn";
|
|
2412
|
+
case "swap":
|
|
2413
|
+
return "swap";
|
|
2414
|
+
case "perp-deposit":
|
|
2415
|
+
return "deposit";
|
|
2416
|
+
default:
|
|
2417
|
+
return scenario;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
async function relayUserOp(params) {
|
|
2421
|
+
if (!params.client) {
|
|
2422
|
+
throw new BundlerNotConfiguredError();
|
|
2423
|
+
}
|
|
2424
|
+
try {
|
|
2425
|
+
const result = await params.client.relayUserOperation({
|
|
2426
|
+
userOp: params.userOp,
|
|
2427
|
+
entryPoint: params.entryPoint,
|
|
2428
|
+
eip7702Auth: params.eip7702Auth
|
|
2429
|
+
});
|
|
2430
|
+
return { userOpHash: result.userOpHash };
|
|
2431
|
+
} catch (err) {
|
|
2432
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2433
|
+
throw new BundlerRejectedError(msg, err);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2363
2437
|
// src/config.ts
|
|
2364
2438
|
var import_viem11 = require("viem");
|
|
2365
2439
|
var import_core8 = require("@pafi-dev/core");
|
|
@@ -2789,6 +2863,8 @@ var PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
|
2789
2863
|
AuthError,
|
|
2790
2864
|
AuthService,
|
|
2791
2865
|
BalanceAggregator,
|
|
2866
|
+
BundlerNotConfiguredError,
|
|
2867
|
+
BundlerRejectedError,
|
|
2792
2868
|
BurnIndexer,
|
|
2793
2869
|
DefaultPolicyEngine,
|
|
2794
2870
|
FeeManager,
|
|
@@ -2819,6 +2895,8 @@ var PAFI_ISSUER_SDK_VERSION = "0.4.0";
|
|
|
2819
2895
|
handleRedeemStatus,
|
|
2820
2896
|
mergePaymasterFields,
|
|
2821
2897
|
prepareMobileUserOp,
|
|
2898
|
+
relayUserOp,
|
|
2899
|
+
requestPaymaster,
|
|
2822
2900
|
serializeEntryToJsonRpc,
|
|
2823
2901
|
serializeUserOpTypedData
|
|
2824
2902
|
});
|