@1llet.xyz/erc4337-gasless-sdk 0.4.40 → 0.4.43
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 +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +73 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
172
|
-
|
|
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
|
|
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}`, JSON.stringify({ amount, sourceAsset, destAsset, options }, null, 2));
|
|
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,59 @@ 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 sourceConfig = NETWORKS[sourceChain];
|
|
2356
|
+
const sourceAssetInfo = sourceConfig?.crossChainInformation?.nearIntentInformation?.assetsId.find(
|
|
2357
|
+
(a) => a.name === (sourceToken || "USDC")
|
|
2358
|
+
) || sourceConfig?.crossChainInformation?.nearIntentInformation?.assetsId[0];
|
|
2359
|
+
const decimals = sourceAssetInfo?.decimals || (sourceChain === "Stellar" ? 7 : 6);
|
|
2360
|
+
const netAmountBridged = (amountNum - usedFee).toFixed(decimals);
|
|
2361
|
+
if (parseFloat(netAmountBridged) <= 0) {
|
|
2362
|
+
return {
|
|
2363
|
+
success: false,
|
|
2364
|
+
error: `Insufficient amount (${amountNum}) to cover fee (${usedFee})`,
|
|
2365
|
+
minAmount: MIN_AMOUNT
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2368
|
+
const sender = sourceChain === "Stellar" ? DUMMY_STELLAR_ADDRESS : DUMMY_EVM_ADDRESS;
|
|
2369
|
+
const recipient = destChain === "Stellar" ? DUMMY_STELLAR_ADDRESS : DUMMY_EVM_ADDRESS;
|
|
2370
|
+
try {
|
|
2371
|
+
const quoteResult = await getNearQuote(
|
|
2372
|
+
sourceChain,
|
|
2373
|
+
destChain,
|
|
2374
|
+
netAmountBridged.toString(),
|
|
2375
|
+
destToken,
|
|
2376
|
+
sourceToken,
|
|
2377
|
+
recipient,
|
|
2378
|
+
sender,
|
|
2379
|
+
{ dry: true }
|
|
2380
|
+
);
|
|
2381
|
+
return {
|
|
2382
|
+
success: true,
|
|
2383
|
+
amountSent: amountNum,
|
|
2384
|
+
protocolFee: usedFee,
|
|
2385
|
+
netAmountBridged: parseFloat(netAmountBridged),
|
|
2386
|
+
// @ts-ignore - access safe property
|
|
2387
|
+
estimatedReceived: quoteResult.quote?.quote?.estimatedOutput || "0",
|
|
2388
|
+
minAmount: MIN_AMOUNT
|
|
2389
|
+
};
|
|
2390
|
+
} catch (error) {
|
|
2391
|
+
console.error(">>> [Bridge Quote] Error:", error);
|
|
2392
|
+
return {
|
|
2393
|
+
success: false,
|
|
2394
|
+
error: error.message || "Unknown quote error",
|
|
2395
|
+
minAmount: MIN_AMOUNT
|
|
2396
|
+
};
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2334
2399
|
|
|
2335
2400
|
// src/services/TransferManager.ts
|
|
2336
2401
|
var TransferManager = class {
|
|
@@ -2372,6 +2437,6 @@ var TransferManager = class {
|
|
|
2372
2437
|
}
|
|
2373
2438
|
};
|
|
2374
2439
|
|
|
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 };
|
|
2440
|
+
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
2441
|
//# sourceMappingURL=index.mjs.map
|
|
2377
2442
|
//# sourceMappingURL=index.mjs.map
|