@lumiapassport/ui-kit 1.0.2 → 1.2.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 +434 -0
- package/dist/iframe/main.js +18 -18
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +245 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +244 -40
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
+
import { UserOperationV07, UserOperationV06 } from '@lumiapassport/core/bundler';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
import * as viem from 'viem';
|
|
5
6
|
import { Chain, Hash as Hash$1, TransactionReceipt } from 'viem';
|
|
@@ -173,6 +174,22 @@ interface AccountSession$1 {
|
|
|
173
174
|
address: `0x${string}`;
|
|
174
175
|
}
|
|
175
176
|
declare function sendUserOperation(session: AccountSession$1, callTarget: `0x${string}`, amountWei: string, innerData?: `0x${string}`, feeType?: 'economy' | 'standard' | 'fast', entryPointVersion?: 'v0.6' | 'v0.7'): Promise<`0x${string}`>;
|
|
177
|
+
/**
|
|
178
|
+
* Prepare and sign a UserOperation without sending it to the bundler.
|
|
179
|
+
* Returns the signed UserOp and its hash for backend verification and submission.
|
|
180
|
+
*
|
|
181
|
+
* @param session - Account session with signing credentials
|
|
182
|
+
* @param callTarget - Target address for the transaction
|
|
183
|
+
* @param amountWei - Amount in wei to send
|
|
184
|
+
* @param innerData - Call data for the transaction
|
|
185
|
+
* @param feeType - Fee tier: 'economy', 'standard', or 'fast'
|
|
186
|
+
* @param entryPointVersion - EntryPoint version: 'v0.6' or 'v0.7'
|
|
187
|
+
* @returns Object with signed UserOperation and its hash
|
|
188
|
+
*/
|
|
189
|
+
declare function prepareUserOperation(session: AccountSession$1, callTarget: `0x${string}`, amountWei: string, innerData?: `0x${string}`, feeType?: 'economy' | 'standard' | 'fast', entryPointVersion?: 'v0.6' | 'v0.7'): Promise<{
|
|
190
|
+
userOp: UserOperationV07 | UserOperationV06;
|
|
191
|
+
userOpHash: `0x${string}`;
|
|
192
|
+
}>;
|
|
176
193
|
|
|
177
194
|
type AccountSession = AccountSession$1;
|
|
178
195
|
interface SessionState {
|
|
@@ -795,4 +812,4 @@ declare function useLumiaPassportLinkedProfiles(): {
|
|
|
795
812
|
readonly refresh: () => Promise<void>;
|
|
796
813
|
};
|
|
797
814
|
|
|
798
|
-
export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type SendTransactionParams, type SendTransactionResult, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, getUserProfile, lumiaBeam, queryClient, sendUserOperation, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
|
|
815
|
+
export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type SendTransactionParams, type SendTransactionResult, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, getUserProfile, lumiaBeam, prepareUserOperation, queryClient, sendUserOperation, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
+
import { UserOperationV07, UserOperationV06 } from '@lumiapassport/core/bundler';
|
|
3
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
5
|
import * as viem from 'viem';
|
|
5
6
|
import { Chain, Hash as Hash$1, TransactionReceipt } from 'viem';
|
|
@@ -173,6 +174,22 @@ interface AccountSession$1 {
|
|
|
173
174
|
address: `0x${string}`;
|
|
174
175
|
}
|
|
175
176
|
declare function sendUserOperation(session: AccountSession$1, callTarget: `0x${string}`, amountWei: string, innerData?: `0x${string}`, feeType?: 'economy' | 'standard' | 'fast', entryPointVersion?: 'v0.6' | 'v0.7'): Promise<`0x${string}`>;
|
|
177
|
+
/**
|
|
178
|
+
* Prepare and sign a UserOperation without sending it to the bundler.
|
|
179
|
+
* Returns the signed UserOp and its hash for backend verification and submission.
|
|
180
|
+
*
|
|
181
|
+
* @param session - Account session with signing credentials
|
|
182
|
+
* @param callTarget - Target address for the transaction
|
|
183
|
+
* @param amountWei - Amount in wei to send
|
|
184
|
+
* @param innerData - Call data for the transaction
|
|
185
|
+
* @param feeType - Fee tier: 'economy', 'standard', or 'fast'
|
|
186
|
+
* @param entryPointVersion - EntryPoint version: 'v0.6' or 'v0.7'
|
|
187
|
+
* @returns Object with signed UserOperation and its hash
|
|
188
|
+
*/
|
|
189
|
+
declare function prepareUserOperation(session: AccountSession$1, callTarget: `0x${string}`, amountWei: string, innerData?: `0x${string}`, feeType?: 'economy' | 'standard' | 'fast', entryPointVersion?: 'v0.6' | 'v0.7'): Promise<{
|
|
190
|
+
userOp: UserOperationV07 | UserOperationV06;
|
|
191
|
+
userOpHash: `0x${string}`;
|
|
192
|
+
}>;
|
|
176
193
|
|
|
177
194
|
type AccountSession = AccountSession$1;
|
|
178
195
|
interface SessionState {
|
|
@@ -795,4 +812,4 @@ declare function useLumiaPassportLinkedProfiles(): {
|
|
|
795
812
|
readonly refresh: () => Promise<void>;
|
|
796
813
|
};
|
|
797
814
|
|
|
798
|
-
export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type SendTransactionParams, type SendTransactionResult, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, getUserProfile, lumiaBeam, queryClient, sendUserOperation, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
|
|
815
|
+
export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type SendTransactionParams, type SendTransactionResult, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, getUserProfile, lumiaBeam, prepareUserOperation, queryClient, sendUserOperation, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
|
package/dist/index.js
CHANGED
|
@@ -1403,7 +1403,7 @@ async function deriveBackupPasswordFromPasskey(userId, credentialId) {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
function getBackupStatus(userId) {
|
|
1405
1405
|
const storage = typeof window !== "undefined" ? window.localStorage : void 0;
|
|
1406
|
-
const statusData = storage?.getItem(`lumia.backup.status.${userId}`);
|
|
1406
|
+
const statusData = storage?.getItem(`lumia-passport.backup.status.${userId}`);
|
|
1407
1407
|
if (statusData) {
|
|
1408
1408
|
try {
|
|
1409
1409
|
return JSON.parse(statusData);
|
|
@@ -1417,14 +1417,14 @@ function updateBackupStatus(userId, method, status) {
|
|
|
1417
1417
|
if (!storage) return;
|
|
1418
1418
|
const current = getBackupStatus(userId);
|
|
1419
1419
|
current[method] = { ...current[method], ...status };
|
|
1420
|
-
storage.setItem(`lumia.backup.status.${userId}`, JSON.stringify(current));
|
|
1420
|
+
storage.setItem(`lumia-passport.backup.status.${userId}`, JSON.stringify(current));
|
|
1421
1421
|
if (typeof window !== "undefined") {
|
|
1422
|
-
window.dispatchEvent(new CustomEvent("lumia-backup-status-changed", { detail: { method, status, currentStatus: current } }));
|
|
1422
|
+
window.dispatchEvent(new CustomEvent("lumia-passport-backup-status-changed", { detail: { method, status, currentStatus: current } }));
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
1425
|
function clearBackupStatus(userId) {
|
|
1426
1426
|
const storage = typeof window !== "undefined" ? window.localStorage : void 0;
|
|
1427
|
-
storage?.removeItem(`lumia.backup.status.${userId}`);
|
|
1427
|
+
storage?.removeItem(`lumia-passport.backup.status.${userId}`);
|
|
1428
1428
|
}
|
|
1429
1429
|
async function checkServerBackupAvailability() {
|
|
1430
1430
|
try {
|
|
@@ -2411,7 +2411,7 @@ var init_iframe_manager = __esm({
|
|
|
2411
2411
|
const response = await this.sendMessage("SDK_AUTH", {
|
|
2412
2412
|
projectId: this.projectId
|
|
2413
2413
|
});
|
|
2414
|
-
if (response.type === "
|
|
2414
|
+
if (response.type === "LUMIA_PASSPORT_SDK_AUTH_SUCCESS") {
|
|
2415
2415
|
this.sessionToken = response.sessionToken;
|
|
2416
2416
|
this.log("[IframeManager] \u2705 SDK authenticated, session token received");
|
|
2417
2417
|
} else {
|
|
@@ -2427,20 +2427,21 @@ var init_iframe_manager = __esm({
|
|
|
2427
2427
|
return;
|
|
2428
2428
|
}
|
|
2429
2429
|
const validIframeTypes = [
|
|
2430
|
-
"
|
|
2431
|
-
"
|
|
2432
|
-
"
|
|
2433
|
-
"
|
|
2434
|
-
"
|
|
2435
|
-
"
|
|
2436
|
-
"
|
|
2437
|
-
"
|
|
2438
|
-
"
|
|
2439
|
-
"
|
|
2440
|
-
"
|
|
2441
|
-
"
|
|
2442
|
-
"
|
|
2443
|
-
"
|
|
2430
|
+
"LUMIA_PASSPORT_IFRAME_READY",
|
|
2431
|
+
"LUMIA_PASSPORT_SHOW_IFRAME",
|
|
2432
|
+
"LUMIA_PASSPORT_HIDE_IFRAME",
|
|
2433
|
+
"LUMIA_PASSPORT_SDK_AUTH_SUCCESS",
|
|
2434
|
+
"LUMIA_PASSPORT_AUTH_SUCCESS",
|
|
2435
|
+
"LUMIA_PASSPORT_DKG_SUCCESS",
|
|
2436
|
+
"LUMIA_PASSPORT_SIGNATURE",
|
|
2437
|
+
"LUMIA_PASSPORT_ADDRESS",
|
|
2438
|
+
"LUMIA_PASSPORT_KEYSHARE_STATUS",
|
|
2439
|
+
"LUMIA_PASSPORT_TRUSTED_APPS_LIST",
|
|
2440
|
+
"LUMIA_PASSPORT_TRUSTED_APP_REMOVED",
|
|
2441
|
+
"LUMIA_PASSPORT_REQUEST_NEW_TOKEN",
|
|
2442
|
+
"LUMIA_PASSPORT_TOKEN_REFRESHED",
|
|
2443
|
+
"LUMIA_PASSPORT_RESPONSE",
|
|
2444
|
+
"LUMIA_PASSPORT_ERROR"
|
|
2444
2445
|
];
|
|
2445
2446
|
if (!validIframeTypes.includes(message.type) && !message.messageId) {
|
|
2446
2447
|
return;
|
|
@@ -2450,24 +2451,24 @@ var init_iframe_manager = __esm({
|
|
|
2450
2451
|
this.log("[IframeManager] \u26A0\uFE0F Ignored message from invalid origin:", event.origin, "expected:", iframeOrigin);
|
|
2451
2452
|
return;
|
|
2452
2453
|
}
|
|
2453
|
-
if (message.type === "
|
|
2454
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
2454
|
+
if (message.type === "LUMIA_PASSPORT_IFRAME_READY") {
|
|
2455
|
+
this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_IFRAME_READY");
|
|
2455
2456
|
this.isReady = true;
|
|
2456
2457
|
this.readyResolve();
|
|
2457
2458
|
return;
|
|
2458
2459
|
}
|
|
2459
|
-
if (message.type === "
|
|
2460
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
2460
|
+
if (message.type === "LUMIA_PASSPORT_SHOW_IFRAME") {
|
|
2461
|
+
this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_SHOW_IFRAME");
|
|
2461
2462
|
this.showIframe();
|
|
2462
2463
|
return;
|
|
2463
2464
|
}
|
|
2464
|
-
if (message.type === "
|
|
2465
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
2465
|
+
if (message.type === "LUMIA_PASSPORT_HIDE_IFRAME") {
|
|
2466
|
+
this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_HIDE_IFRAME");
|
|
2466
2467
|
this.hideIframe();
|
|
2467
2468
|
return;
|
|
2468
2469
|
}
|
|
2469
|
-
if (message.type === "
|
|
2470
|
-
this.log("[IframeManager] \u{1F4E8} Received
|
|
2470
|
+
if (message.type === "LUMIA_PASSPORT_REQUEST_NEW_TOKEN") {
|
|
2471
|
+
this.log("[IframeManager] \u{1F4E8} Received LUMIA_PASSPORT_REQUEST_NEW_TOKEN");
|
|
2471
2472
|
this.handleTokenRefreshRequest(message).catch((error) => {
|
|
2472
2473
|
this.log("[IframeManager] \u274C Token refresh error:", error);
|
|
2473
2474
|
});
|
|
@@ -2477,7 +2478,7 @@ var init_iframe_manager = __esm({
|
|
|
2477
2478
|
const pending = this.pendingRequests.get(message.messageId);
|
|
2478
2479
|
if (pending) {
|
|
2479
2480
|
this.pendingRequests.delete(message.messageId);
|
|
2480
|
-
if (message.type === "
|
|
2481
|
+
if (message.type === "LUMIA_PASSPORT_ERROR") {
|
|
2481
2482
|
pending.reject(new Error(message.error || "Unknown error"));
|
|
2482
2483
|
} else {
|
|
2483
2484
|
pending.resolve(message.data || message);
|
|
@@ -2500,7 +2501,7 @@ var init_iframe_manager = __esm({
|
|
|
2500
2501
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
2501
2502
|
this.iframe.contentWindow.postMessage(
|
|
2502
2503
|
{
|
|
2503
|
-
type: "
|
|
2504
|
+
type: "LUMIA_PASSPORT_TOKEN_REFRESHED",
|
|
2504
2505
|
messageId: message.messageId,
|
|
2505
2506
|
accessToken: newAccessToken,
|
|
2506
2507
|
timestamp: Date.now()
|
|
@@ -2515,7 +2516,7 @@ var init_iframe_manager = __esm({
|
|
|
2515
2516
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
2516
2517
|
this.iframe.contentWindow.postMessage(
|
|
2517
2518
|
{
|
|
2518
|
-
type: "
|
|
2519
|
+
type: "LUMIA_PASSPORT_TOKEN_REFRESHED",
|
|
2519
2520
|
messageId: message.messageId,
|
|
2520
2521
|
error: "Token refresh failed",
|
|
2521
2522
|
timestamp: Date.now()
|
|
@@ -2530,7 +2531,7 @@ var init_iframe_manager = __esm({
|
|
|
2530
2531
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
2531
2532
|
this.iframe.contentWindow.postMessage(
|
|
2532
2533
|
{
|
|
2533
|
-
type: "
|
|
2534
|
+
type: "LUMIA_PASSPORT_TOKEN_REFRESHED",
|
|
2534
2535
|
messageId: message.messageId,
|
|
2535
2536
|
error: error instanceof Error ? error.message : "Unknown error",
|
|
2536
2537
|
timestamp: Date.now()
|
|
@@ -2653,7 +2654,7 @@ var init_iframe_manager = __esm({
|
|
|
2653
2654
|
userId,
|
|
2654
2655
|
projectId: this.projectId
|
|
2655
2656
|
});
|
|
2656
|
-
if (response.type === "
|
|
2657
|
+
if (response.type === "LUMIA_PASSPORT_AUTH_SUCCESS") {
|
|
2657
2658
|
return {
|
|
2658
2659
|
userId: response.userId,
|
|
2659
2660
|
address: response.address
|
|
@@ -2672,7 +2673,7 @@ var init_iframe_manager = __esm({
|
|
|
2672
2673
|
accessToken
|
|
2673
2674
|
// Pass access token for TSS API authentication
|
|
2674
2675
|
});
|
|
2675
|
-
if (response.type === "
|
|
2676
|
+
if (response.type === "LUMIA_PASSPORT_DKG_SUCCESS") {
|
|
2676
2677
|
return response.ownerAddress;
|
|
2677
2678
|
}
|
|
2678
2679
|
throw new Error("DKG failed");
|
|
@@ -2689,7 +2690,7 @@ var init_iframe_manager = __esm({
|
|
|
2689
2690
|
accessToken
|
|
2690
2691
|
// Pass access token for TSS API authentication
|
|
2691
2692
|
});
|
|
2692
|
-
if (response.type === "
|
|
2693
|
+
if (response.type === "LUMIA_PASSPORT_SIGNATURE") {
|
|
2693
2694
|
return response.signature;
|
|
2694
2695
|
}
|
|
2695
2696
|
throw new Error("Transaction signing failed");
|
|
@@ -2702,7 +2703,7 @@ var init_iframe_manager = __esm({
|
|
|
2702
2703
|
const response = await this.sendMessage("GET_ADDRESS", {
|
|
2703
2704
|
userId
|
|
2704
2705
|
});
|
|
2705
|
-
if (response.type === "
|
|
2706
|
+
if (response.type === "LUMIA_PASSPORT_ADDRESS") {
|
|
2706
2707
|
return response.address;
|
|
2707
2708
|
}
|
|
2708
2709
|
return void 0;
|
|
@@ -2715,7 +2716,7 @@ var init_iframe_manager = __esm({
|
|
|
2715
2716
|
const response = await this.sendMessage("CHECK_KEYSHARE", {
|
|
2716
2717
|
userId
|
|
2717
2718
|
});
|
|
2718
|
-
if (response.type === "
|
|
2719
|
+
if (response.type === "LUMIA_PASSPORT_KEYSHARE_STATUS") {
|
|
2719
2720
|
return {
|
|
2720
2721
|
hasKeyshare: response.hasKeyshare,
|
|
2721
2722
|
address: response.address
|
|
@@ -2731,7 +2732,7 @@ var init_iframe_manager = __esm({
|
|
|
2731
2732
|
const response = await this.sendMessage("GET_TRUSTED_APPS", {
|
|
2732
2733
|
userId
|
|
2733
2734
|
});
|
|
2734
|
-
if (response.type === "
|
|
2735
|
+
if (response.type === "LUMIA_PASSPORT_TRUSTED_APPS_LIST") {
|
|
2735
2736
|
return response.apps || [];
|
|
2736
2737
|
}
|
|
2737
2738
|
return [];
|
|
@@ -2746,7 +2747,7 @@ var init_iframe_manager = __esm({
|
|
|
2746
2747
|
projectId,
|
|
2747
2748
|
appOrigin: origin
|
|
2748
2749
|
});
|
|
2749
|
-
if (response.type === "
|
|
2750
|
+
if (response.type === "LUMIA_PASSPORT_TRUSTED_APP_REMOVED") {
|
|
2750
2751
|
return response.success;
|
|
2751
2752
|
}
|
|
2752
2753
|
return false;
|
|
@@ -5271,6 +5272,208 @@ async function sendUserOperation(session, callTarget, amountWei, innerData = "0x
|
|
|
5271
5272
|
}
|
|
5272
5273
|
return hash;
|
|
5273
5274
|
}
|
|
5275
|
+
async function prepareUserOperation(session, callTarget, amountWei, innerData = "0x", feeType = "standard", entryPointVersion = "v0.7") {
|
|
5276
|
+
const entryPointAddress = entryPointVersion === "v0.6" ? ENTRYPOINT_V06 : ENTRYPOINT_V07;
|
|
5277
|
+
const amountWeiBigInt = BigInt(amountWei);
|
|
5278
|
+
const isMinimalTest = callTarget === "0x0000000000000000000000000000000000000000" && amountWei === "0" && innerData === "0x";
|
|
5279
|
+
let callData;
|
|
5280
|
+
if (isMinimalTest) {
|
|
5281
|
+
callData = "0x";
|
|
5282
|
+
} else {
|
|
5283
|
+
callData = encodeFunctionData({ abi: executeAbi, functionName: "execute", args: [callTarget, amountWeiBigInt, innerData] });
|
|
5284
|
+
}
|
|
5285
|
+
let isDeployed = false;
|
|
5286
|
+
let deploymentMethod = "unknown";
|
|
5287
|
+
try {
|
|
5288
|
+
const code = await publicClient.getCode({ address: session.smartAccountAddress });
|
|
5289
|
+
if (code && code !== "0x" && code.length > 2) {
|
|
5290
|
+
isDeployed = true;
|
|
5291
|
+
deploymentMethod = "getCode";
|
|
5292
|
+
}
|
|
5293
|
+
} catch {
|
|
5294
|
+
}
|
|
5295
|
+
const nonce = await fetchEntryPointNonce(session.smartAccountAddress, entryPointAddress);
|
|
5296
|
+
const nonceValue = BigInt(nonce);
|
|
5297
|
+
if (!isDeployed && nonceValue !== 0n) throw new Error(`Undeployed account has non-zero nonce: ${nonce}. This will cause CodeHashChanged error.`);
|
|
5298
|
+
const shouldIncludeFactory = !isDeployed;
|
|
5299
|
+
let userOp;
|
|
5300
|
+
if (shouldIncludeFactory) {
|
|
5301
|
+
const compatCreateAbi = [{ type: "function", name: "createAccount", stateMutability: "payable", inputs: [{ name: "owner", type: "address" }, { name: "salt", type: "bytes32" }], outputs: [{ name: "", type: "address" }] }];
|
|
5302
|
+
const saltZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
5303
|
+
const factoryData = encodeFunctionData({ abi: compatCreateAbi, functionName: "createAccount", args: [session.ownerAddress, saltZero] });
|
|
5304
|
+
userOp = await createUserOperationWithDynamicFees(
|
|
5305
|
+
session.smartAccountAddress,
|
|
5306
|
+
nonce,
|
|
5307
|
+
callData,
|
|
5308
|
+
true,
|
|
5309
|
+
session.factoryAddress,
|
|
5310
|
+
factoryData,
|
|
5311
|
+
feeType
|
|
5312
|
+
);
|
|
5313
|
+
} else {
|
|
5314
|
+
userOp = await createUserOperationWithDynamicFees(
|
|
5315
|
+
session.smartAccountAddress,
|
|
5316
|
+
nonce,
|
|
5317
|
+
callData,
|
|
5318
|
+
false,
|
|
5319
|
+
void 0,
|
|
5320
|
+
void 0,
|
|
5321
|
+
feeType
|
|
5322
|
+
);
|
|
5323
|
+
}
|
|
5324
|
+
const ensureGenerousDefaults = () => {
|
|
5325
|
+
const toHex2 = (v) => `0x${v.toString(16)}`;
|
|
5326
|
+
const minCallGas = 0x493e0n;
|
|
5327
|
+
const minVerificationGas = 0x989680n;
|
|
5328
|
+
const minPreVerificationGas = 0x30d40n;
|
|
5329
|
+
if (BigInt(userOp.callGasLimit || "0x0") < minCallGas) userOp.callGasLimit = toHex2(minCallGas);
|
|
5330
|
+
if (BigInt(userOp.verificationGasLimit || "0x0") < minVerificationGas) userOp.verificationGasLimit = toHex2(minVerificationGas);
|
|
5331
|
+
if (BigInt(userOp.preVerificationGas || "0x0") < minPreVerificationGas) userOp.preVerificationGas = toHex2(minPreVerificationGas);
|
|
5332
|
+
};
|
|
5333
|
+
const enforceCaps = (usePaymaster) => {
|
|
5334
|
+
try {
|
|
5335
|
+
const envCaps = typeof import.meta !== "undefined" && import.meta.env || {};
|
|
5336
|
+
const maxBundlerVerifGas = envCaps.VITE_MAX_VERIFICATION_GAS ? BigInt(envCaps.VITE_MAX_VERIFICATION_GAS) : MAX_BUNDLER_VERIFICATION_GAS;
|
|
5337
|
+
const maxCallGas = envCaps.VITE_MAX_CALL_GAS_LIMIT ? BigInt(envCaps.VITE_MAX_CALL_GAS_LIMIT) : 0x7a120n;
|
|
5338
|
+
const toHex2 = (v) => `0x${v.toString(16)}`;
|
|
5339
|
+
const maxAccountVerifGas = usePaymaster ? maxBundlerVerifGas - PAYMASTER_VERIFICATION_GAS : maxBundlerVerifGas;
|
|
5340
|
+
const verGas = BigInt(userOp.verificationGasLimit || "0x0");
|
|
5341
|
+
if (verGas > maxAccountVerifGas) userOp.verificationGasLimit = toHex2(maxAccountVerifGas);
|
|
5342
|
+
const callGas = BigInt(userOp.callGasLimit || "0x0");
|
|
5343
|
+
if (callGas > maxCallGas) userOp.callGasLimit = toHex2(maxCallGas);
|
|
5344
|
+
} catch {
|
|
5345
|
+
}
|
|
5346
|
+
};
|
|
5347
|
+
let estimated = false;
|
|
5348
|
+
try {
|
|
5349
|
+
const gasEst = await estimateUserOperationGas({ ...userOp, signature: `0x${"00".repeat(65)}` });
|
|
5350
|
+
userOp.callGasLimit = gasEst.callGasLimit;
|
|
5351
|
+
userOp.verificationGasLimit = gasEst.verificationGasLimit;
|
|
5352
|
+
userOp.preVerificationGas = gasEst.preVerificationGas;
|
|
5353
|
+
ensureGenerousDefaults();
|
|
5354
|
+
enforceCaps(session.usePaymaster);
|
|
5355
|
+
estimated = true;
|
|
5356
|
+
} catch {
|
|
5357
|
+
ensureGenerousDefaults();
|
|
5358
|
+
enforceCaps(session.usePaymaster);
|
|
5359
|
+
}
|
|
5360
|
+
try {
|
|
5361
|
+
const toHex2 = (v) => `0x${v.toString(16)}`;
|
|
5362
|
+
const isContractCall = !!userOp.callData && userOp.callData !== "0x";
|
|
5363
|
+
if (isContractCall) {
|
|
5364
|
+
const currentVer = BigInt(userOp.verificationGasLimit || "0x0");
|
|
5365
|
+
const call = BigInt(userOp.callGasLimit || "0x0");
|
|
5366
|
+
const postOp = 150000n;
|
|
5367
|
+
const safety10k = 10000n;
|
|
5368
|
+
let buffer = call + postOp + safety10k;
|
|
5369
|
+
buffer += buffer / 63n;
|
|
5370
|
+
const newVer = currentVer + buffer;
|
|
5371
|
+
userOp.verificationGasLimit = toHex2(newVer);
|
|
5372
|
+
enforceCaps(session.usePaymaster);
|
|
5373
|
+
}
|
|
5374
|
+
} catch {
|
|
5375
|
+
}
|
|
5376
|
+
if (session.usePaymaster && LUMIA_PAYMASTER_ADDRESS) {
|
|
5377
|
+
userOp.paymaster = LUMIA_PAYMASTER_ADDRESS;
|
|
5378
|
+
userOp.paymasterData = "0x";
|
|
5379
|
+
userOp.paymasterVerificationGasLimit = PAYMASTER_VERIFICATION_GAS_LIMIT;
|
|
5380
|
+
userOp.paymasterPostOpGasLimit = PAYMASTER_POSTOP_GAS_LIMIT;
|
|
5381
|
+
}
|
|
5382
|
+
userOp.nonce = nonce;
|
|
5383
|
+
let opHash;
|
|
5384
|
+
if (entryPointVersion === "v0.6") {
|
|
5385
|
+
const userOpV06 = convertUserOpV07ToV06(userOp);
|
|
5386
|
+
opHash = await publicClient.readContract({
|
|
5387
|
+
address: entryPointAddress,
|
|
5388
|
+
abi: [{ type: "function", name: "getUserOpHash", inputs: [{ name: "userOp", type: "tuple", components: [{ name: "sender", type: "address" }, { name: "nonce", type: "uint256" }, { name: "initCode", type: "bytes" }, { name: "callData", type: "bytes" }, { name: "callGasLimit", type: "uint256" }, { name: "verificationGasLimit", type: "uint256" }, { name: "preVerificationGas", type: "uint256" }, { name: "maxFeePerGas", type: "uint256" }, { name: "maxPriorityFeePerGas", type: "uint256" }, { name: "paymasterAndData", type: "bytes" }, { name: "signature", type: "bytes" }] }], outputs: [{ name: "", type: "bytes32" }] }],
|
|
5389
|
+
functionName: "getUserOpHash",
|
|
5390
|
+
args: [{
|
|
5391
|
+
sender: userOpV06.sender,
|
|
5392
|
+
nonce: BigInt(userOpV06.nonce),
|
|
5393
|
+
initCode: userOpV06.initCode,
|
|
5394
|
+
callData: userOpV06.callData,
|
|
5395
|
+
callGasLimit: BigInt(userOpV06.callGasLimit),
|
|
5396
|
+
verificationGasLimit: BigInt(userOpV06.verificationGasLimit),
|
|
5397
|
+
preVerificationGas: BigInt(userOpV06.preVerificationGas),
|
|
5398
|
+
maxFeePerGas: BigInt(userOpV06.maxFeePerGas),
|
|
5399
|
+
maxPriorityFeePerGas: BigInt(userOpV06.maxPriorityFeePerGas),
|
|
5400
|
+
paymasterAndData: userOpV06.paymasterAndData,
|
|
5401
|
+
signature: "0x"
|
|
5402
|
+
}]
|
|
5403
|
+
});
|
|
5404
|
+
} else {
|
|
5405
|
+
const hasFactoryData = !!(userOp.factory && userOp.factoryData);
|
|
5406
|
+
const initCode = hasFactoryData ? (() => {
|
|
5407
|
+
const factoryAddr = userOp.factory.startsWith("0x") ? userOp.factory.slice(2) : userOp.factory;
|
|
5408
|
+
const factoryDataClean = userOp.factoryData.startsWith("0x") ? userOp.factoryData.slice(2) : userOp.factoryData;
|
|
5409
|
+
return `0x${factoryAddr}${factoryDataClean}`;
|
|
5410
|
+
})() : "0x";
|
|
5411
|
+
const accountGasLimits = pack2x128(BigInt(userOp.verificationGasLimit), BigInt(userOp.callGasLimit));
|
|
5412
|
+
const gasFees = pack2x128(BigInt(userOp.maxPriorityFeePerGas), BigInt(userOp.maxFeePerGas));
|
|
5413
|
+
let paymasterAndData = "0x";
|
|
5414
|
+
if (userOp.paymaster && userOp.paymaster !== "0x0000000000000000000000000000000000000000") {
|
|
5415
|
+
const verificationGasLimit = userOp.paymasterVerificationGasLimit || "0x186a0";
|
|
5416
|
+
const postOpGasLimit = userOp.paymasterPostOpGasLimit || "0x186a0";
|
|
5417
|
+
const paymasterDataField = userOp.paymasterData || "0x";
|
|
5418
|
+
const packedPaymasterGasLimits = pack2x128(BigInt(verificationGasLimit), BigInt(postOpGasLimit));
|
|
5419
|
+
const paymasterAddr = userOp.paymaster.startsWith("0x") ? userOp.paymaster.slice(2) : userOp.paymaster;
|
|
5420
|
+
const paymasterDataClean = paymasterDataField === "0x" ? "" : paymasterDataField.startsWith("0x") ? paymasterDataField.slice(2) : paymasterDataField;
|
|
5421
|
+
paymasterAndData = `0x${paymasterAddr}${packedPaymasterGasLimits.slice(2)}${paymasterDataClean}`;
|
|
5422
|
+
}
|
|
5423
|
+
const packedForHash = {
|
|
5424
|
+
sender: session.smartAccountAddress,
|
|
5425
|
+
nonce: BigInt(nonce),
|
|
5426
|
+
initCode,
|
|
5427
|
+
callData,
|
|
5428
|
+
accountGasLimits,
|
|
5429
|
+
preVerificationGas: BigInt(userOp.preVerificationGas),
|
|
5430
|
+
gasFees,
|
|
5431
|
+
paymasterAndData,
|
|
5432
|
+
signature: "0x"
|
|
5433
|
+
};
|
|
5434
|
+
opHash = await publicClient.readContract({
|
|
5435
|
+
address: entryPointAddress,
|
|
5436
|
+
abi: entryPoint07Abi,
|
|
5437
|
+
functionName: "getUserOpHash",
|
|
5438
|
+
args: [packedForHash]
|
|
5439
|
+
});
|
|
5440
|
+
}
|
|
5441
|
+
let signature;
|
|
5442
|
+
if (session.mpcUserId) {
|
|
5443
|
+
const mpcSig = await signDigestWithMpc(session.mpcUserId, opHash, {
|
|
5444
|
+
sender: userOp.sender,
|
|
5445
|
+
nonce: userOp.nonce,
|
|
5446
|
+
callData: userOp.callData,
|
|
5447
|
+
callGasLimit: userOp.callGasLimit,
|
|
5448
|
+
verificationGasLimit: userOp.verificationGasLimit,
|
|
5449
|
+
preVerificationGas: userOp.preVerificationGas,
|
|
5450
|
+
maxFeePerGas: userOp.maxFeePerGas,
|
|
5451
|
+
maxPriorityFeePerGas: userOp.maxPriorityFeePerGas,
|
|
5452
|
+
paymaster: userOp.paymaster,
|
|
5453
|
+
factory: userOp.factory,
|
|
5454
|
+
factoryData: userOp.factoryData
|
|
5455
|
+
});
|
|
5456
|
+
if (!mpcSig) throw new Error("MPC signing failed");
|
|
5457
|
+
signature = mpcSig;
|
|
5458
|
+
} else if (session.ownerPrivateKey) {
|
|
5459
|
+
const account = privateKeyToAccount(session.ownerPrivateKey);
|
|
5460
|
+
const rawSig = await account.sign({ hash: opHash });
|
|
5461
|
+
signature = normalizeSignature(rawSig);
|
|
5462
|
+
} else {
|
|
5463
|
+
throw new Error("No signing method available");
|
|
5464
|
+
}
|
|
5465
|
+
userOp.signature = signature;
|
|
5466
|
+
if (typeof userOp.sender !== "string") {
|
|
5467
|
+
userOp.sender = session.smartAccountAddress;
|
|
5468
|
+
}
|
|
5469
|
+
console.log("[Account] \u2705 Prepared signed UserOp (not sent):", JSON.stringify(userOp, (key, value) => typeof value === "bigint" ? `0x${value.toString(16)}` : value, 2));
|
|
5470
|
+
console.log("[Account] \u{1F511} UserOp Hash:", opHash);
|
|
5471
|
+
if (entryPointVersion === "v0.6") {
|
|
5472
|
+
const userOpV06 = convertUserOpV07ToV06(userOp);
|
|
5473
|
+
return { userOp: userOpV06, userOpHash: opHash };
|
|
5474
|
+
}
|
|
5475
|
+
return { userOp, userOpHash: opHash };
|
|
5476
|
+
}
|
|
5274
5477
|
async function getEntryPointDeposit(address, entryPointVersion = "v0.7") {
|
|
5275
5478
|
const entryPointAddress = entryPointVersion === "v0.6" ? ENTRYPOINT_V06 : ENTRYPOINT_V07;
|
|
5276
5479
|
const depositAbi = [{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }] }];
|
|
@@ -5967,7 +6170,7 @@ function BackupForm({ userId, onBackupSuccess }) {
|
|
|
5967
6170
|
setTimeout(() => {
|
|
5968
6171
|
if (typeof window !== "undefined") {
|
|
5969
6172
|
window.dispatchEvent(
|
|
5970
|
-
new CustomEvent("lumia-backup-status-changed", {
|
|
6173
|
+
new CustomEvent("lumia-passport-backup-status-changed", {
|
|
5971
6174
|
detail: { method, success: true }
|
|
5972
6175
|
})
|
|
5973
6176
|
);
|
|
@@ -8996,7 +9199,7 @@ function KeyshareBackup({ userId, onClose, onBackupSuccess }) {
|
|
|
8996
9199
|
setTimeout(() => {
|
|
8997
9200
|
if (typeof window !== "undefined") {
|
|
8998
9201
|
window.dispatchEvent(
|
|
8999
|
-
new CustomEvent("lumia-backup-status-changed", {
|
|
9202
|
+
new CustomEvent("lumia-passport-backup-status-changed", {
|
|
9000
9203
|
detail: { method, success: true }
|
|
9001
9204
|
})
|
|
9002
9205
|
);
|
|
@@ -9500,6 +9703,7 @@ export {
|
|
|
9500
9703
|
UserOpStatus,
|
|
9501
9704
|
getUserProfile,
|
|
9502
9705
|
lumiaBeam,
|
|
9706
|
+
prepareUserOperation,
|
|
9503
9707
|
queryClient,
|
|
9504
9708
|
sendUserOperation,
|
|
9505
9709
|
updateUserProfile,
|