@1llet.xyz/erc4337-gasless-sdk 0.4.48 → 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/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");