@1llet.xyz/erc4337-gasless-sdk 0.4.47 → 0.4.49

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
@@ -1,6 +1,6 @@
1
1
  # ERC-4337 Gasless SDK ⛽️
2
2
 
3
- A lightweight, typed SDK to integrate Account Abstraction (ERC-4337) and Cross-Chain transfers into your dApp. It handles Smart Account creation, gasless transactions, and orchestrates cross-chain bridges.
3
+ A lightweight, typed SDK to integrate Account Abstraction (ERC-4337) and Cross-Chain transfers into your dApp. It handles Smart Account creation, gasless transactions, and orchestrates cross-chain bridges strategies including CCTP and Near Intents.
4
4
 
5
5
  ## 📦 Installation
6
6
 
@@ -61,7 +61,7 @@ await aa.sendTransaction({
61
61
 
62
62
  ## 🌉 Cross-Chain Transfer Manager
63
63
 
64
- The `TransferManager` orchestrates transfers between chains, choosing the best strategy (CCTP, Near Intents) or signaling a direct transfer if on the same chain.
64
+ The `TransferManager` orchestrates transfers between chains, choosing the best strategy (**CCTP**, **Near Intents**) or signaling a **Direct Transfer** if on the same chain.
65
65
 
66
66
  ```typescript
67
67
  import { TransferManager, BridgeContext } from "@1llet.xyz/erc4337-gasless-sdk";
@@ -76,7 +76,14 @@ const context: BridgeContext = {
76
76
  amount: "10.5", // Human readable string
77
77
  recipient: "0xRecipient...",
78
78
  senderAddress: "0xSender...",
79
- facilitatorPrivateKey: "0x..." // For CCTP/Near verification usage (Backend)
79
+
80
+ // Optional: Provide depositTxHash if you already made the deposit
81
+ depositTxHash: "0x...",
82
+
83
+ // Optional: For Stellar source
84
+ paymentPayload: {
85
+ signedXDR: "AAAA..."
86
+ }
80
87
  };
81
88
 
82
89
  const result = await transferManager.execute(context);
@@ -86,22 +93,79 @@ if (result.success) {
86
93
  // Signal to Client: Execute direct transfer on same chain!
87
94
  console.log("Execute local transfer:", result.data);
88
95
  } else {
89
- // Cross-chain initiated
90
- console.log("Bridge Tx:", result.transactionHash);
96
+ // Cross-chain initiated (or Deposit Address returned for Near)
97
+ console.log("Bridge Tx / Deposit Address:", result.data);
91
98
  }
92
99
  } else {
93
100
  console.error("Error:", result.errorReason);
94
101
  }
95
102
  ```
96
103
 
104
+ ### Simulation (Quote)
105
+
106
+ You can simulate a simulation to estimate fees and received amount before executing.
107
+
108
+ ```typescript
109
+ import { getNearSimulation } from "@1llet.xyz/erc4337-gasless-sdk";
110
+
111
+ const simulation = await getNearSimulation(
112
+ "Base",
113
+ "Gnosis",
114
+ "10",
115
+ "USDC", // Source
116
+ "EURe" // Destination
117
+ );
118
+
119
+ if (simulation.success) {
120
+ console.log(`Fee: ${simulation.protocolFee}`);
121
+ console.log(`Est. Received: ${simulation.estimatedReceived}`);
122
+ } else {
123
+ console.error(simulation.error);
124
+ }
125
+ ```
126
+
127
+ ---
128
+
129
+ ## 🌟 Stellar Service
130
+
131
+ The SDK includes a dedicated `StellarService` to handle non-EVM interactions, useful for bridging from Stellar to EVM.
132
+
133
+ ```typescript
134
+ import { StellarService } from "@1llet.xyz/erc4337-gasless-sdk";
135
+
136
+ const stellar = new StellarService();
137
+
138
+ // 1. Get Balance
139
+ const balance = await stellar.getBalance("G...", "USDC");
140
+
141
+ // 2. Build Transfer XDR (for bridging)
142
+ const xdr = await stellar.buildTransferXdr(
143
+ "S_SENDER_PRIVATE_KEY",
144
+ "G_RECIPIENT_ADDRESS",
145
+ "10", // Amount
146
+ "USDC",
147
+ "MEMO_IF_NEEDED"
148
+ );
149
+
150
+ // 3. Submit Transaction
151
+ const hash = await stellar.submitXdr(xdr);
152
+ ```
153
+
154
+ ---
155
+
97
156
  ## 🛠️ Supported Chains
98
157
 
99
158
  The SDK exports pre-configured objects:
100
159
 
101
- - `BASE_MAINNET`
102
- - `BASE_SEPOLIA`
160
+ - `BASE_MAINNET`, `BASE_SEPOLIA`
103
161
  - `OPTIMISM_MAINNET`
162
+ - `ARBITRUM_MAINNET`
104
163
  - `GNOSIS_MAINNET`
164
+ - `POLYGON_MAINNET`
165
+ - `AVALANCHE_MAINNET`
166
+ - `STELLAR_MAINNET`
167
+ - `UNICHAIN_SEPOLIA`
168
+ - `WORLD_CHAIN_MAINNET`
105
169
 
106
170
  ```typescript
107
171
  import { GNOSIS_MAINNET } from "@1llet.xyz/erc4337-gasless-sdk";
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Chain, Address, Hash, Hex } from 'viem';
1
+ import { Chain, Address, Hash, Hex, WalletClient } from 'viem';
2
2
  import * as StellarSdk from 'stellar-sdk';
3
3
  import { Address as Address$1 } from 'abitype';
4
4
  import z from 'zod';
@@ -83,11 +83,7 @@ declare class AccountAbstraction {
83
83
  private entryPointAddress;
84
84
  private factoryAddress;
85
85
  constructor(chainConfig: EvmChainConfig);
86
- /**
87
- * Connect to MetaMask OR use Private Key
88
- * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
89
- */
90
- connect(privateKey?: Hex): Promise<{
86
+ connect(signer?: Hex | WalletClient): Promise<{
91
87
  owner: Address;
92
88
  smartAccount: Address;
93
89
  }>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Chain, Address, Hash, Hex } from 'viem';
1
+ import { Chain, Address, Hash, Hex, WalletClient } from 'viem';
2
2
  import * as StellarSdk from 'stellar-sdk';
3
3
  import { Address as Address$1 } from 'abitype';
4
4
  import z from 'zod';
@@ -83,11 +83,7 @@ declare class AccountAbstraction {
83
83
  private entryPointAddress;
84
84
  private factoryAddress;
85
85
  constructor(chainConfig: EvmChainConfig);
86
- /**
87
- * Connect to MetaMask OR use Private Key
88
- * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
89
- */
90
- connect(privateKey?: Hex): Promise<{
86
+ connect(signer?: Hex | WalletClient): Promise<{
91
87
  owner: Address;
92
88
  smartAccount: Address;
93
89
  }>;
package/dist/index.js CHANGED
@@ -692,13 +692,9 @@ var AccountAbstraction = class {
692
692
  this.tokenService = new TokenService(chainConfig, this.publicClient);
693
693
  this.userOpBuilder = new UserOpBuilder(chainConfig, this.bundlerClient, this.publicClient);
694
694
  }
695
- /**
696
- * Connect to MetaMask OR use Private Key
697
- * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
698
- */
699
- async connect(privateKey) {
700
- if (privateKey) {
701
- const account = accounts.privateKeyToAccount(privateKey);
695
+ async connect(signer) {
696
+ if (typeof signer === "string") {
697
+ const account = accounts.privateKeyToAccount(signer);
702
698
  this.owner = account.address;
703
699
  const rpcUrl = this.chainConfig.rpcUrl || this.chainConfig.chain.rpcUrls.default.http[0];
704
700
  this.walletClient = viem.createWalletClient({
@@ -706,6 +702,10 @@ var AccountAbstraction = class {
706
702
  chain: this.chainConfig.chain,
707
703
  transport: viem.http(rpcUrl)
708
704
  });
705
+ } else if (signer && typeof signer === "object") {
706
+ this.walletClient = signer;
707
+ if (!this.walletClient.account) throw new Error("WalletClient must have an account");
708
+ this.owner = this.walletClient.account.address;
709
709
  } else {
710
710
  if (typeof window === "undefined" || !window.ethereum) {
711
711
  throw new Error("MetaMask is not installed and no private key provided");