@embarkai/ui-kit 0.4.18 → 0.4.20

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 CHANGED
@@ -471,6 +471,42 @@ function DirectTransactionExample() {
471
471
  - ✅ Use `useSendTransaction()` hook for React components (automatic session management)
472
472
  - ✅ Use `sendUserOperation()` function for custom logic, utility functions, or non-React code
473
473
 
474
+ ### sendBatchUserOperation - Atomic Multi-Call Submission
475
+
476
+ Use `sendBatchUserOperation()` when you need multiple smart-account calls to execute atomically in a single UserOperation.
477
+
478
+ ```tsx
479
+ import { sendBatchUserOperation, useAccountSession } from '@embarkai/ui-kit'
480
+
481
+ function BatchTransactionExample() {
482
+ const session = useAccountSession()
483
+
484
+ const handleSend = async () => {
485
+ if (!session) return
486
+
487
+ const userOpHash = await sendBatchUserOperation(session, {
488
+ operations: [
489
+ {
490
+ to: '0xTokenAddress',
491
+ value: '0',
492
+ data: '0xa9059cbb...' // ERC20 transfer calldata
493
+ },
494
+ {
495
+ to: '0xTargetContract',
496
+ value: '0',
497
+ data: '0xabcdef12...' // Contract call calldata
498
+ }
499
+ ],
500
+ feeType: 'standard'
501
+ })
502
+
503
+ console.log('Batch transaction submitted:', userOpHash)
504
+ }
505
+
506
+ return <button onClick={handleSend}>Send Batch Transaction</button>
507
+ }
508
+ ```
509
+
474
510
  ### deployAccount - Deploy Smart Account (Optional)
475
511
 
476
512
  Deploy the smart account contract immediately after registration. This is **optional** - accounts are automatically deployed on first transaction.
@@ -723,6 +759,36 @@ return {
723
759
  }
724
760
  ```
725
761
 
762
+ ### prepareBatchUserOperation - Prepare Atomic Multi-Call for Backend Submission
763
+
764
+ ```tsx
765
+ import { prepareBatchUserOperation, useAccountSession } from '@embarkai/ui-kit'
766
+
767
+ function PrepareBatchExample() {
768
+ const session = useAccountSession()
769
+
770
+ const handlePrepare = async () => {
771
+ if (!session) return
772
+
773
+ const { userOp, userOpHash } = await prepareBatchUserOperation(session, {
774
+ operations: [
775
+ { to: '0xTokenAddress', value: '0', data: '0xa9059cbb...' },
776
+ { to: '0xAnotherContract', value: '0', data: '0x12345678...' }
777
+ ],
778
+ feeType: 'standard'
779
+ })
780
+
781
+ await fetch('/api/submit-batch', {
782
+ method: 'POST',
783
+ headers: { 'Content-Type': 'application/json' },
784
+ body: JSON.stringify({ userOp, userOpHash, ownerAddress: session.ownerAddress })
785
+ })
786
+ }
787
+
788
+ return <button onClick={handlePrepare}>Prepare Batch</button>
789
+ }
790
+ ```
791
+
726
792
  ### useOpenPage - Programmatic EmbarkAI Dialog Control
727
793
 
728
794
  Control the EmbarkAI dialog programmatically.
@@ -15,7 +15,7 @@
15
15
  <meta http-equiv="X-Content-Type-Options" content="nosniff" />
16
16
  <meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
17
17
 
18
- <title>EmbarkAI Secure Wallet - iframe version 0.4.18</title>
18
+ <title>EmbarkAI Secure Wallet - iframe version 0.4.20</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -1516,8 +1516,10 @@ function buildConfirmTxTemplateData(project, origin, transaction, risk, metadata
1516
1516
  const userName = userProfile?.displayName || "EmbarkAI Wallet";
1517
1517
  const domainStatusClass = isVerifiedOrigin ? "verified" : "unverified";
1518
1518
  const domainStatusText = isVerifiedOrigin ? "\u2705" : "\u26A0\uFE0F";
1519
+ const batchOperations = transaction.userOpDetails?.operations || [];
1520
+ const isBatchUserOp = isUserOp && batchOperations.length > 0;
1519
1521
  const fromAddressFull = transaction.userOpDetails?.sender || "";
1520
- const toAddressFull = transaction.userOpDetails?.callTarget || transaction.to || "";
1522
+ const toAddressFull = transaction.userOpDetails?.callTarget || batchOperations[0]?.to || transaction.to || "";
1521
1523
  const fromAddress = formatAddress(fromAddressFull);
1522
1524
  const toAddress = formatAddress(toAddressFull);
1523
1525
  const baseExplorerUrl = explorerUrl || DEFAULT_EXPLORER_URL;
@@ -1537,16 +1539,18 @@ function buildConfirmTxTemplateData(project, origin, transaction, risk, metadata
1537
1539
  return "0";
1538
1540
  }
1539
1541
  };
1540
- const transactionValue = transaction.value || "0";
1542
+ const transactionValue = isBatchUserOp ? batchOperations.reduce((total, operation) => total + BigInt(operation.value || "0"), 0n).toString() : transaction.value || "0";
1541
1543
  const formattedValue = formatValue(transactionValue);
1542
1544
  const hasValue = BigInt(transactionValue) > 0n;
1543
1545
  const callData = transaction.userOpDetails?.callData || transaction.data || "";
1544
1546
  const innerCallData = extractInnerCallData(callData);
1545
1547
  const effectiveCallData = innerCallData || callData;
1546
1548
  const hasContractCall = !!effectiveCallData && effectiveCallData !== "0x" && effectiveCallData.length > 2;
1547
- const showContractInteraction = isUserOp ? hasContractCall : !!callData && callData !== "0x";
1549
+ const showContractInteraction = isBatchUserOp || (isUserOp ? hasContractCall : !!callData && callData !== "0x");
1548
1550
  let actionDescription = "Contract Interaction";
1549
- if (showContractInteraction) {
1551
+ if (isBatchUserOp) {
1552
+ actionDescription = `Batch transaction (${batchOperations.length} operations)`;
1553
+ } else if (showContractInteraction) {
1550
1554
  const approveData = parseERC20Approve(callData);
1551
1555
  if (approveData) {
1552
1556
  if (approveData.amount === 0n) {
@@ -6262,7 +6266,7 @@ var SigningManager = class extends TokenRefreshApiClient {
6262
6266
  };
6263
6267
 
6264
6268
  // src/iframe/main.ts
6265
- var IFRAME_VERSION = "0.4.18";
6269
+ var IFRAME_VERSION = "0.4.20";
6266
6270
  var IframeWallet = class {
6267
6271
  constructor() {
6268
6272
  console.log("=".repeat(60));