@1llet.xyz/erc4337-gasless-sdk 0.4.34 → 0.4.36
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 +83 -9
- package/dist/index.d.ts +83 -9
- package/dist/index.js +214 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +196 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import * as StellarSdk from 'stellar-sdk';
|
|
2
|
+
import { Networks } from 'stellar-sdk';
|
|
1
3
|
import { gnosis, optimism, baseSepolia, base, avalanche, worldchain, monad, polygon, arbitrum, bsc, unichain } from 'viem/chains';
|
|
2
4
|
import { createPublicClient, http, createWalletClient, decodeErrorResult, maxUint256, encodeFunctionData, encodeAbiParameters, keccak256, padHex } from 'viem';
|
|
3
5
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
6
|
import axios from 'axios';
|
|
5
|
-
import { Networks } from 'stellar-sdk';
|
|
6
7
|
import { OpenAPI, QuoteRequest, OneClickService } from '@defuse-protocol/one-click-sdk-typescript';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
@@ -14,6 +15,149 @@ var __export = (target, all) => {
|
|
|
14
15
|
for (var name in all)
|
|
15
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
17
|
};
|
|
18
|
+
var STELLAR;
|
|
19
|
+
var init_Stellar = __esm({
|
|
20
|
+
"src/chains/NoEvm/Stellar.ts"() {
|
|
21
|
+
STELLAR = {
|
|
22
|
+
assets: [
|
|
23
|
+
{
|
|
24
|
+
name: "USDC",
|
|
25
|
+
decimals: 7,
|
|
26
|
+
address: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
27
|
+
coingeckoId: "usd-coin"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "XLM",
|
|
31
|
+
decimals: 7,
|
|
32
|
+
address: "native",
|
|
33
|
+
coingeckoId: "stellar"
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
nonEvm: {
|
|
37
|
+
networkPassphrase: Networks.PUBLIC,
|
|
38
|
+
serverURL: "https://horizon.stellar.org"
|
|
39
|
+
},
|
|
40
|
+
crossChainInformation: {
|
|
41
|
+
circleInformation: {
|
|
42
|
+
supportCirclePaymaster: false,
|
|
43
|
+
aproxFromFee: 0
|
|
44
|
+
},
|
|
45
|
+
nearIntentInformation: {
|
|
46
|
+
support: true,
|
|
47
|
+
assetsId: [
|
|
48
|
+
{
|
|
49
|
+
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu",
|
|
50
|
+
name: "USDC",
|
|
51
|
+
decimals: 7
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz",
|
|
55
|
+
name: "XLM",
|
|
56
|
+
decimals: 6
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
needMemo: true
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// src/services/StellarService.ts
|
|
67
|
+
var StellarService_exports = {};
|
|
68
|
+
__export(StellarService_exports, {
|
|
69
|
+
StellarService: () => StellarService
|
|
70
|
+
});
|
|
71
|
+
var StellarService;
|
|
72
|
+
var init_StellarService = __esm({
|
|
73
|
+
"src/services/StellarService.ts"() {
|
|
74
|
+
init_Stellar();
|
|
75
|
+
StellarService = class {
|
|
76
|
+
constructor() {
|
|
77
|
+
if (!STELLAR.nonEvm?.serverURL || !STELLAR.nonEvm?.networkPassphrase) {
|
|
78
|
+
throw new Error("Stellar Non-EVM config missing or incomplete");
|
|
79
|
+
}
|
|
80
|
+
this.server = new StellarSdk.Horizon.Server(STELLAR.nonEvm.serverURL);
|
|
81
|
+
this.network = STELLAR.nonEvm.networkPassphrase;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get balance for a specific token (or all if not specified)
|
|
85
|
+
* Returns string representation
|
|
86
|
+
*/
|
|
87
|
+
async getBalance(address, tokenName = "XLM") {
|
|
88
|
+
try {
|
|
89
|
+
const account = await this.server.loadAccount(address);
|
|
90
|
+
const assetDef = STELLAR.assets.find((a) => a.name === tokenName);
|
|
91
|
+
if (!assetDef) throw new Error(`Asset ${tokenName} not configured`);
|
|
92
|
+
const isNative = assetDef.address === "native";
|
|
93
|
+
const balanceLine = account.balances.find((b) => {
|
|
94
|
+
if (isNative) {
|
|
95
|
+
return b.asset_type === "native";
|
|
96
|
+
}
|
|
97
|
+
return b.asset_code === tokenName && b.asset_issuer === assetDef.address;
|
|
98
|
+
});
|
|
99
|
+
return balanceLine ? balanceLine.balance : "0";
|
|
100
|
+
} catch (e) {
|
|
101
|
+
if (e.response && e.response.status === 404) {
|
|
102
|
+
return "0";
|
|
103
|
+
}
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Build and Sign a Transfer Transaction
|
|
109
|
+
*/
|
|
110
|
+
async buildTransferXdr(senderPk, recipient, amount, tokenName = "XLM", memo) {
|
|
111
|
+
const keypair = StellarSdk.Keypair.fromSecret(senderPk);
|
|
112
|
+
const sourceAddress = keypair.publicKey();
|
|
113
|
+
let account;
|
|
114
|
+
try {
|
|
115
|
+
account = await this.server.loadAccount(sourceAddress);
|
|
116
|
+
} catch (e) {
|
|
117
|
+
throw new Error(`Stellar Account ${sourceAddress} not valid or not active.`);
|
|
118
|
+
}
|
|
119
|
+
const asset = this.getAsset(tokenName);
|
|
120
|
+
const txBuilder = new StellarSdk.TransactionBuilder(account, {
|
|
121
|
+
fee: StellarSdk.BASE_FEE,
|
|
122
|
+
networkPassphrase: this.network
|
|
123
|
+
});
|
|
124
|
+
txBuilder.addOperation(StellarSdk.Operation.payment({
|
|
125
|
+
destination: recipient,
|
|
126
|
+
asset,
|
|
127
|
+
amount
|
|
128
|
+
}));
|
|
129
|
+
if (memo) {
|
|
130
|
+
txBuilder.addMemo(StellarSdk.Memo.text(memo));
|
|
131
|
+
}
|
|
132
|
+
txBuilder.setTimeout(30);
|
|
133
|
+
const builtTx = txBuilder.build();
|
|
134
|
+
builtTx.sign(keypair);
|
|
135
|
+
return builtTx.toXDR();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Submit Signed XDR
|
|
139
|
+
*/
|
|
140
|
+
async submitXdr(xdr) {
|
|
141
|
+
const tx = StellarSdk.TransactionBuilder.fromXDR(xdr, this.network);
|
|
142
|
+
return this.server.submitTransaction(tx);
|
|
143
|
+
}
|
|
144
|
+
getAsset(tokenName) {
|
|
145
|
+
const assetDef = STELLAR.assets.find((a) => a.name === tokenName);
|
|
146
|
+
if (!assetDef) {
|
|
147
|
+
if (tokenName === "XLM") return StellarSdk.Asset.native();
|
|
148
|
+
throw new Error(`Asset ${tokenName} not found in configuration`);
|
|
149
|
+
}
|
|
150
|
+
if (assetDef.address === "native") {
|
|
151
|
+
return StellarSdk.Asset.native();
|
|
152
|
+
}
|
|
153
|
+
return new StellarSdk.Asset(assetDef.name, assetDef.address);
|
|
154
|
+
}
|
|
155
|
+
getKeypair(pk) {
|
|
156
|
+
return StellarSdk.Keypair.fromSecret(pk);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
});
|
|
17
161
|
|
|
18
162
|
// src/constants/facilitator.ts
|
|
19
163
|
var facilitator_exports = {};
|
|
@@ -1144,6 +1288,10 @@ var CHAIN_ID_TO_KEY = {
|
|
|
1144
1288
|
"42161": "Arbitrum"
|
|
1145
1289
|
};
|
|
1146
1290
|
|
|
1291
|
+
// src/index.ts
|
|
1292
|
+
init_StellarService();
|
|
1293
|
+
init_Stellar();
|
|
1294
|
+
|
|
1147
1295
|
// src/services/cctp.ts
|
|
1148
1296
|
init_facilitator();
|
|
1149
1297
|
init_facilitator();
|
|
@@ -1512,48 +1660,9 @@ var WORLD_CHAIN = {
|
|
|
1512
1660
|
nearIntentInformation: null
|
|
1513
1661
|
}
|
|
1514
1662
|
};
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
name: "USDC",
|
|
1519
|
-
decimals: 7,
|
|
1520
|
-
address: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
1521
|
-
coingeckoId: "usd-coin"
|
|
1522
|
-
},
|
|
1523
|
-
{
|
|
1524
|
-
name: "XLM",
|
|
1525
|
-
decimals: 7,
|
|
1526
|
-
address: "native",
|
|
1527
|
-
coingeckoId: "stellar"
|
|
1528
|
-
}
|
|
1529
|
-
],
|
|
1530
|
-
nonEvm: {
|
|
1531
|
-
networkPassphrase: Networks.PUBLIC,
|
|
1532
|
-
serverURL: "https://horizon.stellar.org"
|
|
1533
|
-
},
|
|
1534
|
-
crossChainInformation: {
|
|
1535
|
-
circleInformation: {
|
|
1536
|
-
supportCirclePaymaster: false,
|
|
1537
|
-
aproxFromFee: 0
|
|
1538
|
-
},
|
|
1539
|
-
nearIntentInformation: {
|
|
1540
|
-
support: true,
|
|
1541
|
-
assetsId: [
|
|
1542
|
-
{
|
|
1543
|
-
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu",
|
|
1544
|
-
name: "USDC",
|
|
1545
|
-
decimals: 7
|
|
1546
|
-
},
|
|
1547
|
-
{
|
|
1548
|
-
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz",
|
|
1549
|
-
name: "XLM",
|
|
1550
|
-
decimals: 6
|
|
1551
|
-
}
|
|
1552
|
-
],
|
|
1553
|
-
needMemo: true
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
};
|
|
1663
|
+
|
|
1664
|
+
// src/chains/index.ts
|
|
1665
|
+
init_Stellar();
|
|
1557
1666
|
var Monad = {
|
|
1558
1667
|
assets: [
|
|
1559
1668
|
{
|
|
@@ -1986,6 +2095,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
|
|
|
1986
2095
|
}
|
|
1987
2096
|
};
|
|
1988
2097
|
}
|
|
2098
|
+
init_StellarService();
|
|
1989
2099
|
OpenAPI.BASE = "https://1click.chaindefuser.com";
|
|
1990
2100
|
var NearStrategy = class {
|
|
1991
2101
|
constructor() {
|
|
@@ -2001,9 +2111,50 @@ var NearStrategy = class {
|
|
|
2001
2111
|
return !!(sourceNear && destNear);
|
|
2002
2112
|
}
|
|
2003
2113
|
async execute(context) {
|
|
2004
|
-
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash } = context;
|
|
2114
|
+
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash, paymentPayload } = context;
|
|
2115
|
+
if (sourceChain === "Stellar" && paymentPayload?.signedXDR) {
|
|
2116
|
+
const signedXDR = paymentPayload.signedXDR;
|
|
2117
|
+
console.log("[NearStrategy] Submitting Stellar User -> Facilitator TX...");
|
|
2118
|
+
try {
|
|
2119
|
+
const stellarService = new StellarService();
|
|
2120
|
+
const result = await stellarService.submitXdr(signedXDR);
|
|
2121
|
+
const pullHash = result.hash;
|
|
2122
|
+
console.log("[NearStrategy] Pull Success (Stellar):", pullHash);
|
|
2123
|
+
return {
|
|
2124
|
+
success: true,
|
|
2125
|
+
transactionHash: pullHash,
|
|
2126
|
+
data: {
|
|
2127
|
+
completed: true,
|
|
2128
|
+
message: "Stellar Transaction Submitted. Bridge in progress."
|
|
2129
|
+
}
|
|
2130
|
+
};
|
|
2131
|
+
} catch (e) {
|
|
2132
|
+
console.error("Stellar Submit Error", e);
|
|
2133
|
+
return { success: false, errorReason: "Stellar Submit Failed: " + (e.message || "Unknown") };
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2005
2136
|
if (depositTxHash) {
|
|
2006
2137
|
console.log(`[NearStrategy] Verifying deposit hash: ${depositTxHash}`);
|
|
2138
|
+
if (sourceChain === "Stellar") {
|
|
2139
|
+
try {
|
|
2140
|
+
const { StellarService: StellarService2 } = await Promise.resolve().then(() => (init_StellarService(), StellarService_exports));
|
|
2141
|
+
const stellarService = new StellarService2();
|
|
2142
|
+
const tx = await stellarService.server.transactions().transaction(depositTxHash).call();
|
|
2143
|
+
if (tx.successful) {
|
|
2144
|
+
return {
|
|
2145
|
+
success: true,
|
|
2146
|
+
transactionHash: depositTxHash,
|
|
2147
|
+
netAmount: amount,
|
|
2148
|
+
data: { completed: true }
|
|
2149
|
+
};
|
|
2150
|
+
} else {
|
|
2151
|
+
return { success: false, errorReason: "Stellar Transaction Failed" };
|
|
2152
|
+
}
|
|
2153
|
+
} catch (e) {
|
|
2154
|
+
console.error("Stellar Verification Error", e);
|
|
2155
|
+
return { success: false, errorReason: `Stellar Verification Failed: ${e.message}` };
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2007
2158
|
const { createPublicClient: createPublicClient3, http: http3 } = await import('viem');
|
|
2008
2159
|
const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
|
|
2009
2160
|
const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
|
|
@@ -2165,6 +2316,6 @@ var TransferManager = class {
|
|
|
2165
2316
|
}
|
|
2166
2317
|
};
|
|
2167
2318
|
|
|
2168
|
-
export { AccountAbstraction, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, NearStrategy, OPTIMISM_MAINNET, TransferManager, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
2319
|
+
export { AccountAbstraction, BASE_MAINNET, BASE_SEPOLIA2 as BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, GNOSIS_MAINNET, NearStrategy, OPTIMISM_MAINNET, STELLAR, StellarService, TransferManager, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
2169
2320
|
//# sourceMappingURL=index.mjs.map
|
|
2170
2321
|
//# sourceMappingURL=index.mjs.map
|