@lumiapassport/core 1.2.0 → 1.3.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.
Files changed (2) hide show
  1. package/README.md +25 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -70,7 +70,7 @@ console.log('Transaction hash:', userOpHash);
70
70
  ### Backend: Verify and Submit UserOperation
71
71
 
72
72
  ```typescript
73
- import { sendUserOperationRaw } from '@lumiapassport/core';
73
+ import { sendUserOperationRaw, getUserOperationReceipt } from '@lumiapassport/core';
74
74
  import { recoverAddress } from 'viem';
75
75
 
76
76
  // Receive from frontend (prepared with prepareUserOperation)
@@ -86,9 +86,30 @@ if (recoveredAddress.toLowerCase() !== ownerAddress.toLowerCase()) {
86
86
  throw new Error('Invalid signature');
87
87
  }
88
88
 
89
- // Submit to bundler
90
- const txHash = await sendUserOperationRaw(userOp);
91
- console.log('Transaction submitted:', txHash);
89
+ // Submit to bundler - returns userOpHash
90
+ const submittedUserOpHash = await sendUserOperationRaw(userOp);
91
+ console.log('UserOperation submitted:', submittedUserOpHash);
92
+
93
+ // Poll for receipt to get transaction hash and status
94
+ const waitForReceipt = async (userOpHash: string, maxAttempts = 60, delayMs = 1000) => {
95
+ for (let i = 0; i < maxAttempts; i++) {
96
+ const receipt = await getUserOperationReceipt(userOpHash as `0x${string}`);
97
+ if (receipt) {
98
+ return {
99
+ success: receipt.success,
100
+ transactionHash: receipt.receipt?.transactionHash,
101
+ blockNumber: receipt.receipt?.blockNumber,
102
+ gasUsed: receipt.actualGasUsed,
103
+ };
104
+ }
105
+ await new Promise(resolve => setTimeout(resolve, delayMs));
106
+ }
107
+ throw new Error('Transaction timeout');
108
+ };
109
+
110
+ const result = await waitForReceipt(submittedUserOpHash);
111
+ console.log('Transaction confirmed:', result.transactionHash);
112
+ console.log('Status:', result.success ? 'Success' : 'Failed');
92
113
  ```
93
114
 
94
115
  ### JWT Verification
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumiapassport/core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Framework-agnostic core SDK for Lumia Passport smart accounts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",