@1llet.xyz/erc4337-gasless-sdk 0.4.48 → 0.4.50

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");
@@ -1995,7 +1995,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
1995
1995
  const amountBigInt = BigInt(Math.floor(parseFloat(amount) * 1e6));
1996
1996
  const feeRaw = calculateFee();
1997
1997
  const fee = BigInt(Math.floor(feeRaw * 1e6));
1998
- const minRequired = fee * BigInt(2);
1998
+ const minRequired = fee;
1999
1999
  if (amountBigInt <= minRequired) {
2000
2000
  return {
2001
2001
  success: false,
@@ -2051,8 +2051,8 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
2051
2051
  abi: tokenMessengerAbi,
2052
2052
  functionName: "depositForBurn",
2053
2053
  args: [
2054
- amountBigInt - fee * BigInt(2),
2055
- // Deduct 0.02 USDC Fee (2x Base Fee)
2054
+ amountBigInt - fee,
2055
+ // Deduct 0.02 USDC Fee
2056
2056
  crossChainConfig.destinationDomain,
2057
2057
  mintRecipient,
2058
2058
  networkConfig.usdc,