@1llet.xyz/erc4337-gasless-sdk 0.4.40 → 0.4.41

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.mjs CHANGED
@@ -162,14 +162,24 @@ var init_StellarService = __esm({
162
162
  // src/constants/facilitator.ts
163
163
  var facilitator_exports = {};
164
164
  __export(facilitator_exports, {
165
+ DUMMY_EVM_ADDRESS: () => DUMMY_EVM_ADDRESS,
166
+ DUMMY_STELLAR_ADDRESS: () => DUMMY_STELLAR_ADDRESS,
165
167
  FACILITATOR_NETWORKS: () => FACILITATOR_NETWORKS,
168
+ PlatformFees: () => PlatformFees,
166
169
  calculateFee: () => calculateFee
167
170
  });
168
- var calculateFee, FACILITATOR_NETWORKS;
171
+ var PlatformFees, DUMMY_EVM_ADDRESS, DUMMY_STELLAR_ADDRESS, calculateFee, FACILITATOR_NETWORKS;
169
172
  var init_facilitator = __esm({
170
173
  "src/constants/facilitator.ts"() {
171
- calculateFee = () => {
172
- return BigInt(1e4);
174
+ PlatformFees = {
175
+ DEV: 0,
176
+ EVM_TO_OTHER: 0.02,
177
+ DEFAULT: 0.02
178
+ };
179
+ DUMMY_EVM_ADDRESS = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
180
+ DUMMY_STELLAR_ADDRESS = "GB7BDSZU2Y27LYNLJLVEGW5TIVYQ6362DS5QZ5F6S27S227227227AAA";
181
+ calculateFee = (isDev = false) => {
182
+ return isDev ? PlatformFees.DEV : PlatformFees.DEFAULT;
173
183
  };
174
184
  FACILITATOR_NETWORKS = {
175
185
  Base: {
@@ -1959,7 +1969,8 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
1959
1969
  transport: http(networkConfig.rpcUrl)
1960
1970
  });
1961
1971
  const amountBigInt = BigInt(Math.floor(parseFloat(amount) * 1e6));
1962
- const fee = calculateFee();
1972
+ const feeRaw = calculateFee();
1973
+ const fee = BigInt(Math.floor(feeRaw * 1e6));
1963
1974
  const minRequired = fee * BigInt(2);
1964
1975
  if (amountBigInt <= minRequired) {
1965
1976
  return {
@@ -2113,6 +2124,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
2113
2124
  };
2114
2125
  }
2115
2126
  init_StellarService();
2127
+ init_facilitator();
2116
2128
  OpenAPI.BASE = "https://1click.chaindefuser.com";
2117
2129
  var NearStrategy = class {
2118
2130
  constructor() {
@@ -2272,7 +2284,7 @@ var NearStrategy = class {
2272
2284
  }
2273
2285
  }
2274
2286
  };
2275
- async function getNearQuote(sourceChain, destChain, amount, destToken, sourceToken, recipient, senderAddress) {
2287
+ async function getNearQuote(sourceChain, destChain, amount, destToken, sourceToken, recipient, senderAddress, options) {
2276
2288
  const sourceConfig = NETWORKS[sourceChain];
2277
2289
  const destConfig = NETWORKS[destChain];
2278
2290
  if (!sourceConfig || !destConfig) {
@@ -2302,9 +2314,9 @@ async function getNearQuote(sourceChain, destChain, amount, destToken, sourceTok
2302
2314
  throw new Error("Recipient address is required for NEAR Quote");
2303
2315
  }
2304
2316
  const refundAddress = senderAddress || recipient;
2305
- console.log(`[NearService] Requesting Quote: ${sourceChain} -> ${destChain}`, { amount, sourceAsset, destAsset });
2317
+ console.log(`[NearService] Requesting Quote: ${sourceChain} -> ${destChain}`, { amount, sourceAsset, destAsset, options });
2306
2318
  const quoteRequest = {
2307
- dry: false,
2319
+ dry: options?.dry || false,
2308
2320
  swapType: QuoteRequest.swapType.EXACT_INPUT,
2309
2321
  slippageTolerance: 100,
2310
2322
  originAsset: sourceAsset,
@@ -2331,6 +2343,54 @@ async function getNearQuote(sourceChain, destChain, amount, destToken, sourceTok
2331
2343
  amountAtomicNet
2332
2344
  };
2333
2345
  }
2346
+ async function getNearSimulation(sourceChain, destChain, amount, destToken, sourceToken) {
2347
+ console.log(">>> [Bridge Quote] Simulation Request:", { sourceChain, destChain, amount, destToken, sourceToken });
2348
+ if (!amount || isNaN(parseFloat(amount))) {
2349
+ throw new Error("Invalid amount");
2350
+ }
2351
+ const amountNum = parseFloat(amount);
2352
+ const isDev = process.env.NEXT_PUBLIC_ENVIROMENT === "development" || process.env.NODE_ENV === "development";
2353
+ const usedFee = isDev ? PlatformFees.DEV : PlatformFees.EVM_TO_OTHER;
2354
+ const MIN_AMOUNT = usedFee;
2355
+ const netAmountBridged = (amountNum - usedFee).toFixed(6);
2356
+ if (parseFloat(netAmountBridged) <= 0) {
2357
+ return {
2358
+ success: false,
2359
+ error: `Insufficient amount (${amountNum}) to cover fee (${usedFee})`,
2360
+ minAmount: MIN_AMOUNT
2361
+ };
2362
+ }
2363
+ const sender = sourceChain === "Stellar" ? DUMMY_STELLAR_ADDRESS : DUMMY_EVM_ADDRESS;
2364
+ const recipient = destChain === "Stellar" ? DUMMY_STELLAR_ADDRESS : DUMMY_EVM_ADDRESS;
2365
+ try {
2366
+ const quoteResult = await getNearQuote(
2367
+ sourceChain,
2368
+ destChain,
2369
+ netAmountBridged.toString(),
2370
+ destToken,
2371
+ sourceToken,
2372
+ recipient,
2373
+ sender,
2374
+ { dry: true }
2375
+ );
2376
+ return {
2377
+ success: true,
2378
+ amountSent: amountNum,
2379
+ protocolFee: usedFee,
2380
+ netAmountBridged: parseFloat(netAmountBridged),
2381
+ // @ts-ignore - access safe property
2382
+ estimatedReceived: quoteResult.quote?.quote?.estimatedOutput || "0",
2383
+ minAmount: MIN_AMOUNT
2384
+ };
2385
+ } catch (error) {
2386
+ console.error(">>> [Bridge Quote] Error:", error);
2387
+ return {
2388
+ success: false,
2389
+ error: error.message || "Unknown quote error",
2390
+ minAmount: MIN_AMOUNT
2391
+ };
2392
+ }
2393
+ }
2334
2394
 
2335
2395
  // src/services/TransferManager.ts
2336
2396
  var TransferManager = class {
@@ -2372,6 +2432,6 @@ var TransferManager = class {
2372
2432
  }
2373
2433
  };
2374
2434
 
2375
- export { AccountAbstraction, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StellarService, TransferManager, entryPointAbi, erc20Abi, smartAccountAbi };
2435
+ export { AccountAbstraction, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StellarService, TransferManager, entryPointAbi, erc20Abi, getNearSimulation, smartAccountAbi };
2376
2436
  //# sourceMappingURL=index.mjs.map
2377
2437
  //# sourceMappingURL=index.mjs.map