@1llet.xyz/erc4337-gasless-sdk 0.4.39 → 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.d.mts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +108 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -459,6 +459,23 @@ declare class NearStrategy implements BridgeStrategy {
|
|
|
459
459
|
canHandle(context: BridgeContext): boolean;
|
|
460
460
|
execute(context: BridgeContext): Promise<SettleResponse>;
|
|
461
461
|
}
|
|
462
|
+
declare function getNearSimulation(sourceChain: ChainKey, destChain: ChainKey, amount: string, destToken?: string, sourceToken?: string): Promise<{
|
|
463
|
+
success: boolean;
|
|
464
|
+
amountSent: number;
|
|
465
|
+
protocolFee: number;
|
|
466
|
+
netAmountBridged: number;
|
|
467
|
+
estimatedReceived: any;
|
|
468
|
+
minAmount: number;
|
|
469
|
+
error?: undefined;
|
|
470
|
+
} | {
|
|
471
|
+
success: boolean;
|
|
472
|
+
error: any;
|
|
473
|
+
minAmount: number;
|
|
474
|
+
amountSent?: undefined;
|
|
475
|
+
protocolFee?: undefined;
|
|
476
|
+
netAmountBridged?: undefined;
|
|
477
|
+
estimatedReceived?: undefined;
|
|
478
|
+
}>;
|
|
462
479
|
|
|
463
480
|
declare class CCTPStrategy implements BridgeStrategy {
|
|
464
481
|
name: string;
|
|
@@ -466,4 +483,4 @@ declare class CCTPStrategy implements BridgeStrategy {
|
|
|
466
483
|
execute(context: BridgeContext): Promise<SettleResponse>;
|
|
467
484
|
}
|
|
468
485
|
|
|
469
|
-
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StellarService, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
486
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StellarService, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, getNearSimulation, smartAccountAbi };
|
package/dist/index.d.ts
CHANGED
|
@@ -459,6 +459,23 @@ declare class NearStrategy implements BridgeStrategy {
|
|
|
459
459
|
canHandle(context: BridgeContext): boolean;
|
|
460
460
|
execute(context: BridgeContext): Promise<SettleResponse>;
|
|
461
461
|
}
|
|
462
|
+
declare function getNearSimulation(sourceChain: ChainKey, destChain: ChainKey, amount: string, destToken?: string, sourceToken?: string): Promise<{
|
|
463
|
+
success: boolean;
|
|
464
|
+
amountSent: number;
|
|
465
|
+
protocolFee: number;
|
|
466
|
+
netAmountBridged: number;
|
|
467
|
+
estimatedReceived: any;
|
|
468
|
+
minAmount: number;
|
|
469
|
+
error?: undefined;
|
|
470
|
+
} | {
|
|
471
|
+
success: boolean;
|
|
472
|
+
error: any;
|
|
473
|
+
minAmount: number;
|
|
474
|
+
amountSent?: undefined;
|
|
475
|
+
protocolFee?: undefined;
|
|
476
|
+
netAmountBridged?: undefined;
|
|
477
|
+
estimatedReceived?: undefined;
|
|
478
|
+
}>;
|
|
462
479
|
|
|
463
480
|
declare class CCTPStrategy implements BridgeStrategy {
|
|
464
481
|
name: string;
|
|
@@ -466,4 +483,4 @@ declare class CCTPStrategy implements BridgeStrategy {
|
|
|
466
483
|
execute(context: BridgeContext): Promise<SettleResponse>;
|
|
467
484
|
}
|
|
468
485
|
|
|
469
|
-
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StellarService, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
486
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, STELLAR_MAINNET, StellarService, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, getNearSimulation, smartAccountAbi };
|
package/dist/index.js
CHANGED
|
@@ -186,14 +186,24 @@ var init_StellarService = __esm({
|
|
|
186
186
|
// src/constants/facilitator.ts
|
|
187
187
|
var facilitator_exports = {};
|
|
188
188
|
__export(facilitator_exports, {
|
|
189
|
+
DUMMY_EVM_ADDRESS: () => DUMMY_EVM_ADDRESS,
|
|
190
|
+
DUMMY_STELLAR_ADDRESS: () => DUMMY_STELLAR_ADDRESS,
|
|
189
191
|
FACILITATOR_NETWORKS: () => FACILITATOR_NETWORKS,
|
|
192
|
+
PlatformFees: () => PlatformFees,
|
|
190
193
|
calculateFee: () => calculateFee
|
|
191
194
|
});
|
|
192
|
-
var calculateFee, FACILITATOR_NETWORKS;
|
|
195
|
+
var PlatformFees, DUMMY_EVM_ADDRESS, DUMMY_STELLAR_ADDRESS, calculateFee, FACILITATOR_NETWORKS;
|
|
193
196
|
var init_facilitator = __esm({
|
|
194
197
|
"src/constants/facilitator.ts"() {
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
PlatformFees = {
|
|
199
|
+
DEV: 0,
|
|
200
|
+
EVM_TO_OTHER: 0.02,
|
|
201
|
+
DEFAULT: 0.02
|
|
202
|
+
};
|
|
203
|
+
DUMMY_EVM_ADDRESS = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
|
|
204
|
+
DUMMY_STELLAR_ADDRESS = "GB7BDSZU2Y27LYNLJLVEGW5TIVYQ6362DS5QZ5F6S27S227227227AAA";
|
|
205
|
+
calculateFee = (isDev = false) => {
|
|
206
|
+
return isDev ? PlatformFees.DEV : PlatformFees.DEFAULT;
|
|
197
207
|
};
|
|
198
208
|
FACILITATOR_NETWORKS = {
|
|
199
209
|
Base: {
|
|
@@ -1983,7 +1993,8 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
|
|
|
1983
1993
|
transport: viem.http(networkConfig.rpcUrl)
|
|
1984
1994
|
});
|
|
1985
1995
|
const amountBigInt = BigInt(Math.floor(parseFloat(amount) * 1e6));
|
|
1986
|
-
const
|
|
1996
|
+
const feeRaw = calculateFee();
|
|
1997
|
+
const fee = BigInt(Math.floor(feeRaw * 1e6));
|
|
1987
1998
|
const minRequired = fee * BigInt(2);
|
|
1988
1999
|
if (amountBigInt <= minRequired) {
|
|
1989
2000
|
return {
|
|
@@ -2137,6 +2148,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
|
|
|
2137
2148
|
};
|
|
2138
2149
|
}
|
|
2139
2150
|
init_StellarService();
|
|
2151
|
+
init_facilitator();
|
|
2140
2152
|
oneClickSdkTypescript.OpenAPI.BASE = "https://1click.chaindefuser.com";
|
|
2141
2153
|
var NearStrategy = class {
|
|
2142
2154
|
constructor() {
|
|
@@ -2182,6 +2194,31 @@ var NearStrategy = class {
|
|
|
2182
2194
|
const stellarService = new StellarService2();
|
|
2183
2195
|
const tx = await stellarService.server.transactions().transaction(depositTxHash).call();
|
|
2184
2196
|
if (tx.successful) {
|
|
2197
|
+
const operations = await stellarService.server.operations().forTransaction(depositTxHash).call();
|
|
2198
|
+
const paymentOp = operations.records.find((op) => op.type === "payment" || op.type === "path_payment_strict_send" || op.type === "path_payment_strict_receive");
|
|
2199
|
+
let depositAddress = "";
|
|
2200
|
+
let memo = "";
|
|
2201
|
+
if (paymentOp) {
|
|
2202
|
+
depositAddress = paymentOp.to || paymentOp.funder || "";
|
|
2203
|
+
}
|
|
2204
|
+
if (tx.memo_type === "text" || tx.memo_type === "id") {
|
|
2205
|
+
memo = tx.memo || "";
|
|
2206
|
+
}
|
|
2207
|
+
if (depositAddress) {
|
|
2208
|
+
console.log(`[NearStrategy] Submitting deposit to 1-Click: ${depositTxHash} -> ${depositAddress} (Memo: ${memo})`);
|
|
2209
|
+
try {
|
|
2210
|
+
await oneClickSdkTypescript.OneClickService.submitDepositTx({
|
|
2211
|
+
txHash: depositTxHash,
|
|
2212
|
+
depositAddress,
|
|
2213
|
+
memo: memo || void 0
|
|
2214
|
+
});
|
|
2215
|
+
console.log("[NearStrategy] Deposit submitted successfully.");
|
|
2216
|
+
} catch (e) {
|
|
2217
|
+
console.error("[NearStrategy] Failed to submit deposit to 1-Click:", e.message);
|
|
2218
|
+
}
|
|
2219
|
+
} else {
|
|
2220
|
+
console.error("[NearStrategy] Could not determine deposit address from Stellar operations.");
|
|
2221
|
+
}
|
|
2185
2222
|
return {
|
|
2186
2223
|
success: true,
|
|
2187
2224
|
transactionHash: depositTxHash,
|
|
@@ -2211,6 +2248,20 @@ var NearStrategy = class {
|
|
|
2211
2248
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: depositTxHash });
|
|
2212
2249
|
console.log(`[NearStrategy] Receipt found. Status: ${receipt.status}`);
|
|
2213
2250
|
if (receipt.status === "success") {
|
|
2251
|
+
const tx = await publicClient.getTransaction({ hash: depositTxHash });
|
|
2252
|
+
const depositAddress = tx.to;
|
|
2253
|
+
if (depositAddress) {
|
|
2254
|
+
console.log(`[NearStrategy] Submitting deposit to 1-Click: ${depositTxHash} -> ${depositAddress}`);
|
|
2255
|
+
try {
|
|
2256
|
+
await oneClickSdkTypescript.OneClickService.submitDepositTx({
|
|
2257
|
+
txHash: depositTxHash,
|
|
2258
|
+
depositAddress
|
|
2259
|
+
});
|
|
2260
|
+
console.log("[NearStrategy] Deposit submitted successfully.");
|
|
2261
|
+
} catch (e) {
|
|
2262
|
+
console.error("[NearStrategy] Failed to submit deposit to 1-Click:", e.message);
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2214
2265
|
return {
|
|
2215
2266
|
success: true,
|
|
2216
2267
|
transactionHash: depositTxHash,
|
|
@@ -2257,7 +2308,7 @@ var NearStrategy = class {
|
|
|
2257
2308
|
}
|
|
2258
2309
|
}
|
|
2259
2310
|
};
|
|
2260
|
-
async function getNearQuote(sourceChain, destChain, amount, destToken, sourceToken, recipient, senderAddress) {
|
|
2311
|
+
async function getNearQuote(sourceChain, destChain, amount, destToken, sourceToken, recipient, senderAddress, options) {
|
|
2261
2312
|
const sourceConfig = NETWORKS[sourceChain];
|
|
2262
2313
|
const destConfig = NETWORKS[destChain];
|
|
2263
2314
|
if (!sourceConfig || !destConfig) {
|
|
@@ -2287,9 +2338,9 @@ async function getNearQuote(sourceChain, destChain, amount, destToken, sourceTok
|
|
|
2287
2338
|
throw new Error("Recipient address is required for NEAR Quote");
|
|
2288
2339
|
}
|
|
2289
2340
|
const refundAddress = senderAddress || recipient;
|
|
2290
|
-
console.log(`[NearService] Requesting Quote: ${sourceChain} -> ${destChain}`, { amount, sourceAsset, destAsset });
|
|
2341
|
+
console.log(`[NearService] Requesting Quote: ${sourceChain} -> ${destChain}`, { amount, sourceAsset, destAsset, options });
|
|
2291
2342
|
const quoteRequest = {
|
|
2292
|
-
dry: false,
|
|
2343
|
+
dry: options?.dry || false,
|
|
2293
2344
|
swapType: oneClickSdkTypescript.QuoteRequest.swapType.EXACT_INPUT,
|
|
2294
2345
|
slippageTolerance: 100,
|
|
2295
2346
|
originAsset: sourceAsset,
|
|
@@ -2301,7 +2352,7 @@ async function getNearQuote(sourceChain, destChain, amount, destToken, sourceTok
|
|
|
2301
2352
|
refundType: oneClickSdkTypescript.QuoteRequest.refundType.ORIGIN_CHAIN,
|
|
2302
2353
|
recipient,
|
|
2303
2354
|
recipientType: oneClickSdkTypescript.QuoteRequest.recipientType.DESTINATION_CHAIN,
|
|
2304
|
-
deadline: new Date(Date.now() +
|
|
2355
|
+
deadline: new Date(Date.now() + 3 * 60 * 1e3).toISOString(),
|
|
2305
2356
|
referral: "1llet",
|
|
2306
2357
|
quoteWaitingTimeMs: 1e4
|
|
2307
2358
|
};
|
|
@@ -2316,6 +2367,54 @@ async function getNearQuote(sourceChain, destChain, amount, destToken, sourceTok
|
|
|
2316
2367
|
amountAtomicNet
|
|
2317
2368
|
};
|
|
2318
2369
|
}
|
|
2370
|
+
async function getNearSimulation(sourceChain, destChain, amount, destToken, sourceToken) {
|
|
2371
|
+
console.log(">>> [Bridge Quote] Simulation Request:", { sourceChain, destChain, amount, destToken, sourceToken });
|
|
2372
|
+
if (!amount || isNaN(parseFloat(amount))) {
|
|
2373
|
+
throw new Error("Invalid amount");
|
|
2374
|
+
}
|
|
2375
|
+
const amountNum = parseFloat(amount);
|
|
2376
|
+
const isDev = process.env.NEXT_PUBLIC_ENVIROMENT === "development" || process.env.NODE_ENV === "development";
|
|
2377
|
+
const usedFee = isDev ? PlatformFees.DEV : PlatformFees.EVM_TO_OTHER;
|
|
2378
|
+
const MIN_AMOUNT = usedFee;
|
|
2379
|
+
const netAmountBridged = (amountNum - usedFee).toFixed(6);
|
|
2380
|
+
if (parseFloat(netAmountBridged) <= 0) {
|
|
2381
|
+
return {
|
|
2382
|
+
success: false,
|
|
2383
|
+
error: `Insufficient amount (${amountNum}) to cover fee (${usedFee})`,
|
|
2384
|
+
minAmount: MIN_AMOUNT
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
const sender = sourceChain === "Stellar" ? DUMMY_STELLAR_ADDRESS : DUMMY_EVM_ADDRESS;
|
|
2388
|
+
const recipient = destChain === "Stellar" ? DUMMY_STELLAR_ADDRESS : DUMMY_EVM_ADDRESS;
|
|
2389
|
+
try {
|
|
2390
|
+
const quoteResult = await getNearQuote(
|
|
2391
|
+
sourceChain,
|
|
2392
|
+
destChain,
|
|
2393
|
+
netAmountBridged.toString(),
|
|
2394
|
+
destToken,
|
|
2395
|
+
sourceToken,
|
|
2396
|
+
recipient,
|
|
2397
|
+
sender,
|
|
2398
|
+
{ dry: true }
|
|
2399
|
+
);
|
|
2400
|
+
return {
|
|
2401
|
+
success: true,
|
|
2402
|
+
amountSent: amountNum,
|
|
2403
|
+
protocolFee: usedFee,
|
|
2404
|
+
netAmountBridged: parseFloat(netAmountBridged),
|
|
2405
|
+
// @ts-ignore - access safe property
|
|
2406
|
+
estimatedReceived: quoteResult.quote?.quote?.estimatedOutput || "0",
|
|
2407
|
+
minAmount: MIN_AMOUNT
|
|
2408
|
+
};
|
|
2409
|
+
} catch (error) {
|
|
2410
|
+
console.error(">>> [Bridge Quote] Error:", error);
|
|
2411
|
+
return {
|
|
2412
|
+
success: false,
|
|
2413
|
+
error: error.message || "Unknown quote error",
|
|
2414
|
+
minAmount: MIN_AMOUNT
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2319
2418
|
|
|
2320
2419
|
// src/services/TransferManager.ts
|
|
2321
2420
|
var TransferManager = class {
|
|
@@ -2371,6 +2470,7 @@ exports.STELLAR_MAINNET = STELLAR_MAINNET;
|
|
|
2371
2470
|
exports.TransferManager = TransferManager;
|
|
2372
2471
|
exports.entryPointAbi = entryPointAbi;
|
|
2373
2472
|
exports.erc20Abi = erc20Abi;
|
|
2473
|
+
exports.getNearSimulation = getNearSimulation;
|
|
2374
2474
|
exports.smartAccountAbi = smartAccountAbi;
|
|
2375
2475
|
//# sourceMappingURL=index.js.map
|
|
2376
2476
|
//# sourceMappingURL=index.js.map
|