@1llet.xyz/erc4337-gasless-sdk 0.4.35 → 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.js +173 -132
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +172 -129
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var StellarSdk = require('stellar-sdk');
|
|
3
4
|
var chains = require('viem/chains');
|
|
4
5
|
var viem = require('viem');
|
|
5
6
|
var accounts = require('viem/accounts');
|
|
6
|
-
var StellarSdk = require('stellar-sdk');
|
|
7
7
|
var axios = require('axios');
|
|
8
8
|
var oneClickSdkTypescript = require('@defuse-protocol/one-click-sdk-typescript');
|
|
9
9
|
|
|
@@ -39,6 +39,149 @@ var __export = (target, all) => {
|
|
|
39
39
|
for (var name in all)
|
|
40
40
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
41
41
|
};
|
|
42
|
+
exports.STELLAR = void 0;
|
|
43
|
+
var init_Stellar = __esm({
|
|
44
|
+
"src/chains/NoEvm/Stellar.ts"() {
|
|
45
|
+
exports.STELLAR = {
|
|
46
|
+
assets: [
|
|
47
|
+
{
|
|
48
|
+
name: "USDC",
|
|
49
|
+
decimals: 7,
|
|
50
|
+
address: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
51
|
+
coingeckoId: "usd-coin"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "XLM",
|
|
55
|
+
decimals: 7,
|
|
56
|
+
address: "native",
|
|
57
|
+
coingeckoId: "stellar"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
nonEvm: {
|
|
61
|
+
networkPassphrase: StellarSdk.Networks.PUBLIC,
|
|
62
|
+
serverURL: "https://horizon.stellar.org"
|
|
63
|
+
},
|
|
64
|
+
crossChainInformation: {
|
|
65
|
+
circleInformation: {
|
|
66
|
+
supportCirclePaymaster: false,
|
|
67
|
+
aproxFromFee: 0
|
|
68
|
+
},
|
|
69
|
+
nearIntentInformation: {
|
|
70
|
+
support: true,
|
|
71
|
+
assetsId: [
|
|
72
|
+
{
|
|
73
|
+
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu",
|
|
74
|
+
name: "USDC",
|
|
75
|
+
decimals: 7
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz",
|
|
79
|
+
name: "XLM",
|
|
80
|
+
decimals: 6
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
needMemo: true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// src/services/StellarService.ts
|
|
91
|
+
var StellarService_exports = {};
|
|
92
|
+
__export(StellarService_exports, {
|
|
93
|
+
StellarService: () => exports.StellarService
|
|
94
|
+
});
|
|
95
|
+
exports.StellarService = void 0;
|
|
96
|
+
var init_StellarService = __esm({
|
|
97
|
+
"src/services/StellarService.ts"() {
|
|
98
|
+
init_Stellar();
|
|
99
|
+
exports.StellarService = class {
|
|
100
|
+
constructor() {
|
|
101
|
+
if (!exports.STELLAR.nonEvm?.serverURL || !exports.STELLAR.nonEvm?.networkPassphrase) {
|
|
102
|
+
throw new Error("Stellar Non-EVM config missing or incomplete");
|
|
103
|
+
}
|
|
104
|
+
this.server = new StellarSdk__namespace.Horizon.Server(exports.STELLAR.nonEvm.serverURL);
|
|
105
|
+
this.network = exports.STELLAR.nonEvm.networkPassphrase;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get balance for a specific token (or all if not specified)
|
|
109
|
+
* Returns string representation
|
|
110
|
+
*/
|
|
111
|
+
async getBalance(address, tokenName = "XLM") {
|
|
112
|
+
try {
|
|
113
|
+
const account = await this.server.loadAccount(address);
|
|
114
|
+
const assetDef = exports.STELLAR.assets.find((a) => a.name === tokenName);
|
|
115
|
+
if (!assetDef) throw new Error(`Asset ${tokenName} not configured`);
|
|
116
|
+
const isNative = assetDef.address === "native";
|
|
117
|
+
const balanceLine = account.balances.find((b) => {
|
|
118
|
+
if (isNative) {
|
|
119
|
+
return b.asset_type === "native";
|
|
120
|
+
}
|
|
121
|
+
return b.asset_code === tokenName && b.asset_issuer === assetDef.address;
|
|
122
|
+
});
|
|
123
|
+
return balanceLine ? balanceLine.balance : "0";
|
|
124
|
+
} catch (e) {
|
|
125
|
+
if (e.response && e.response.status === 404) {
|
|
126
|
+
return "0";
|
|
127
|
+
}
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Build and Sign a Transfer Transaction
|
|
133
|
+
*/
|
|
134
|
+
async buildTransferXdr(senderPk, recipient, amount, tokenName = "XLM", memo) {
|
|
135
|
+
const keypair = StellarSdk__namespace.Keypair.fromSecret(senderPk);
|
|
136
|
+
const sourceAddress = keypair.publicKey();
|
|
137
|
+
let account;
|
|
138
|
+
try {
|
|
139
|
+
account = await this.server.loadAccount(sourceAddress);
|
|
140
|
+
} catch (e) {
|
|
141
|
+
throw new Error(`Stellar Account ${sourceAddress} not valid or not active.`);
|
|
142
|
+
}
|
|
143
|
+
const asset = this.getAsset(tokenName);
|
|
144
|
+
const txBuilder = new StellarSdk__namespace.TransactionBuilder(account, {
|
|
145
|
+
fee: StellarSdk__namespace.BASE_FEE,
|
|
146
|
+
networkPassphrase: this.network
|
|
147
|
+
});
|
|
148
|
+
txBuilder.addOperation(StellarSdk__namespace.Operation.payment({
|
|
149
|
+
destination: recipient,
|
|
150
|
+
asset,
|
|
151
|
+
amount
|
|
152
|
+
}));
|
|
153
|
+
if (memo) {
|
|
154
|
+
txBuilder.addMemo(StellarSdk__namespace.Memo.text(memo));
|
|
155
|
+
}
|
|
156
|
+
txBuilder.setTimeout(30);
|
|
157
|
+
const builtTx = txBuilder.build();
|
|
158
|
+
builtTx.sign(keypair);
|
|
159
|
+
return builtTx.toXDR();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Submit Signed XDR
|
|
163
|
+
*/
|
|
164
|
+
async submitXdr(xdr) {
|
|
165
|
+
const tx = StellarSdk__namespace.TransactionBuilder.fromXDR(xdr, this.network);
|
|
166
|
+
return this.server.submitTransaction(tx);
|
|
167
|
+
}
|
|
168
|
+
getAsset(tokenName) {
|
|
169
|
+
const assetDef = exports.STELLAR.assets.find((a) => a.name === tokenName);
|
|
170
|
+
if (!assetDef) {
|
|
171
|
+
if (tokenName === "XLM") return StellarSdk__namespace.Asset.native();
|
|
172
|
+
throw new Error(`Asset ${tokenName} not found in configuration`);
|
|
173
|
+
}
|
|
174
|
+
if (assetDef.address === "native") {
|
|
175
|
+
return StellarSdk__namespace.Asset.native();
|
|
176
|
+
}
|
|
177
|
+
return new StellarSdk__namespace.Asset(assetDef.name, assetDef.address);
|
|
178
|
+
}
|
|
179
|
+
getKeypair(pk) {
|
|
180
|
+
return StellarSdk__namespace.Keypair.fromSecret(pk);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
});
|
|
42
185
|
|
|
43
186
|
// src/constants/facilitator.ts
|
|
44
187
|
var facilitator_exports = {};
|
|
@@ -1168,134 +1311,10 @@ var CHAIN_ID_TO_KEY = {
|
|
|
1168
1311
|
"11155420": "Optimism",
|
|
1169
1312
|
"42161": "Arbitrum"
|
|
1170
1313
|
};
|
|
1171
|
-
var STELLAR = {
|
|
1172
|
-
assets: [
|
|
1173
|
-
{
|
|
1174
|
-
name: "USDC",
|
|
1175
|
-
decimals: 7,
|
|
1176
|
-
address: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
1177
|
-
coingeckoId: "usd-coin"
|
|
1178
|
-
},
|
|
1179
|
-
{
|
|
1180
|
-
name: "XLM",
|
|
1181
|
-
decimals: 7,
|
|
1182
|
-
address: "native",
|
|
1183
|
-
coingeckoId: "stellar"
|
|
1184
|
-
}
|
|
1185
|
-
],
|
|
1186
|
-
nonEvm: {
|
|
1187
|
-
networkPassphrase: StellarSdk.Networks.PUBLIC,
|
|
1188
|
-
serverURL: "https://horizon.stellar.org"
|
|
1189
|
-
},
|
|
1190
|
-
crossChainInformation: {
|
|
1191
|
-
circleInformation: {
|
|
1192
|
-
supportCirclePaymaster: false,
|
|
1193
|
-
aproxFromFee: 0
|
|
1194
|
-
},
|
|
1195
|
-
nearIntentInformation: {
|
|
1196
|
-
support: true,
|
|
1197
|
-
assetsId: [
|
|
1198
|
-
{
|
|
1199
|
-
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu",
|
|
1200
|
-
name: "USDC",
|
|
1201
|
-
decimals: 7
|
|
1202
|
-
},
|
|
1203
|
-
{
|
|
1204
|
-
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz",
|
|
1205
|
-
name: "XLM",
|
|
1206
|
-
decimals: 6
|
|
1207
|
-
}
|
|
1208
|
-
],
|
|
1209
|
-
needMemo: true
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
};
|
|
1213
1314
|
|
|
1214
|
-
// src/
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
if (!STELLAR.nonEvm?.serverURL || !STELLAR.nonEvm?.networkPassphrase) {
|
|
1218
|
-
throw new Error("Stellar Non-EVM config missing or incomplete");
|
|
1219
|
-
}
|
|
1220
|
-
this.server = new StellarSdk__namespace.Horizon.Server(STELLAR.nonEvm.serverURL);
|
|
1221
|
-
this.network = STELLAR.nonEvm.networkPassphrase;
|
|
1222
|
-
}
|
|
1223
|
-
/**
|
|
1224
|
-
* Get balance for a specific token (or all if not specified)
|
|
1225
|
-
* Returns string representation
|
|
1226
|
-
*/
|
|
1227
|
-
async getBalance(address, tokenName = "XLM") {
|
|
1228
|
-
try {
|
|
1229
|
-
const account = await this.server.loadAccount(address);
|
|
1230
|
-
const assetDef = STELLAR.assets.find((a) => a.name === tokenName);
|
|
1231
|
-
if (!assetDef) throw new Error(`Asset ${tokenName} not configured`);
|
|
1232
|
-
const isNative = assetDef.address === "native";
|
|
1233
|
-
const balanceLine = account.balances.find((b) => {
|
|
1234
|
-
if (isNative) {
|
|
1235
|
-
return b.asset_type === "native";
|
|
1236
|
-
}
|
|
1237
|
-
return b.asset_code === tokenName && b.asset_issuer === assetDef.address;
|
|
1238
|
-
});
|
|
1239
|
-
return balanceLine ? balanceLine.balance : "0";
|
|
1240
|
-
} catch (e) {
|
|
1241
|
-
if (e.response && e.response.status === 404) {
|
|
1242
|
-
return "0";
|
|
1243
|
-
}
|
|
1244
|
-
throw e;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
/**
|
|
1248
|
-
* Build and Sign a Transfer Transaction
|
|
1249
|
-
*/
|
|
1250
|
-
async buildTransferXdr(senderPk, recipient, amount, tokenName = "XLM", memo) {
|
|
1251
|
-
const keypair = StellarSdk__namespace.Keypair.fromSecret(senderPk);
|
|
1252
|
-
const sourceAddress = keypair.publicKey();
|
|
1253
|
-
let account;
|
|
1254
|
-
try {
|
|
1255
|
-
account = await this.server.loadAccount(sourceAddress);
|
|
1256
|
-
} catch (e) {
|
|
1257
|
-
throw new Error(`Stellar Account ${sourceAddress} not valid or not active.`);
|
|
1258
|
-
}
|
|
1259
|
-
const asset = this.getAsset(tokenName);
|
|
1260
|
-
const txBuilder = new StellarSdk__namespace.TransactionBuilder(account, {
|
|
1261
|
-
fee: StellarSdk__namespace.BASE_FEE,
|
|
1262
|
-
networkPassphrase: this.network
|
|
1263
|
-
});
|
|
1264
|
-
txBuilder.addOperation(StellarSdk__namespace.Operation.payment({
|
|
1265
|
-
destination: recipient,
|
|
1266
|
-
asset,
|
|
1267
|
-
amount
|
|
1268
|
-
}));
|
|
1269
|
-
if (memo) {
|
|
1270
|
-
txBuilder.addMemo(StellarSdk__namespace.Memo.text(memo));
|
|
1271
|
-
}
|
|
1272
|
-
txBuilder.setTimeout(30);
|
|
1273
|
-
const builtTx = txBuilder.build();
|
|
1274
|
-
builtTx.sign(keypair);
|
|
1275
|
-
return builtTx.toXDR();
|
|
1276
|
-
}
|
|
1277
|
-
/**
|
|
1278
|
-
* Submit Signed XDR
|
|
1279
|
-
*/
|
|
1280
|
-
async submitXdr(xdr) {
|
|
1281
|
-
const tx = StellarSdk__namespace.TransactionBuilder.fromXDR(xdr, this.network);
|
|
1282
|
-
return this.server.submitTransaction(tx);
|
|
1283
|
-
}
|
|
1284
|
-
getAsset(tokenName) {
|
|
1285
|
-
const assetDef = STELLAR.assets.find((a) => a.name === tokenName);
|
|
1286
|
-
if (!assetDef) {
|
|
1287
|
-
if (tokenName === "XLM") return StellarSdk__namespace.Asset.native();
|
|
1288
|
-
throw new Error(`Asset ${tokenName} not found in configuration`);
|
|
1289
|
-
}
|
|
1290
|
-
if (assetDef.address === "native") {
|
|
1291
|
-
return StellarSdk__namespace.Asset.native();
|
|
1292
|
-
}
|
|
1293
|
-
return new StellarSdk__namespace.Asset(assetDef.name, assetDef.address);
|
|
1294
|
-
}
|
|
1295
|
-
getKeypair(pk) {
|
|
1296
|
-
return StellarSdk__namespace.Keypair.fromSecret(pk);
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1315
|
+
// src/index.ts
|
|
1316
|
+
init_StellarService();
|
|
1317
|
+
init_Stellar();
|
|
1299
1318
|
|
|
1300
1319
|
// src/services/cctp.ts
|
|
1301
1320
|
init_facilitator();
|
|
@@ -1665,6 +1684,9 @@ var WORLD_CHAIN = {
|
|
|
1665
1684
|
nearIntentInformation: null
|
|
1666
1685
|
}
|
|
1667
1686
|
};
|
|
1687
|
+
|
|
1688
|
+
// src/chains/index.ts
|
|
1689
|
+
init_Stellar();
|
|
1668
1690
|
var Monad = {
|
|
1669
1691
|
assets: [
|
|
1670
1692
|
{
|
|
@@ -1796,7 +1818,7 @@ var NETWORKS = {
|
|
|
1796
1818
|
Polygon: POLYGON,
|
|
1797
1819
|
Avalanche: AVALANCHE,
|
|
1798
1820
|
WorldChain: WORLD_CHAIN,
|
|
1799
|
-
Stellar: STELLAR,
|
|
1821
|
+
Stellar: exports.STELLAR,
|
|
1800
1822
|
Monad,
|
|
1801
1823
|
BNB,
|
|
1802
1824
|
Gnosis: GNOSIS
|
|
@@ -2097,6 +2119,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
|
|
|
2097
2119
|
}
|
|
2098
2120
|
};
|
|
2099
2121
|
}
|
|
2122
|
+
init_StellarService();
|
|
2100
2123
|
oneClickSdkTypescript.OpenAPI.BASE = "https://1click.chaindefuser.com";
|
|
2101
2124
|
var NearStrategy = class {
|
|
2102
2125
|
constructor() {
|
|
@@ -2117,7 +2140,7 @@ var NearStrategy = class {
|
|
|
2117
2140
|
const signedXDR = paymentPayload.signedXDR;
|
|
2118
2141
|
console.log("[NearStrategy] Submitting Stellar User -> Facilitator TX...");
|
|
2119
2142
|
try {
|
|
2120
|
-
const stellarService = new StellarService();
|
|
2143
|
+
const stellarService = new exports.StellarService();
|
|
2121
2144
|
const result = await stellarService.submitXdr(signedXDR);
|
|
2122
2145
|
const pullHash = result.hash;
|
|
2123
2146
|
console.log("[NearStrategy] Pull Success (Stellar):", pullHash);
|
|
@@ -2136,6 +2159,26 @@ var NearStrategy = class {
|
|
|
2136
2159
|
}
|
|
2137
2160
|
if (depositTxHash) {
|
|
2138
2161
|
console.log(`[NearStrategy] Verifying deposit hash: ${depositTxHash}`);
|
|
2162
|
+
if (sourceChain === "Stellar") {
|
|
2163
|
+
try {
|
|
2164
|
+
const { StellarService: StellarService2 } = await Promise.resolve().then(() => (init_StellarService(), StellarService_exports));
|
|
2165
|
+
const stellarService = new StellarService2();
|
|
2166
|
+
const tx = await stellarService.server.transactions().transaction(depositTxHash).call();
|
|
2167
|
+
if (tx.successful) {
|
|
2168
|
+
return {
|
|
2169
|
+
success: true,
|
|
2170
|
+
transactionHash: depositTxHash,
|
|
2171
|
+
netAmount: amount,
|
|
2172
|
+
data: { completed: true }
|
|
2173
|
+
};
|
|
2174
|
+
} else {
|
|
2175
|
+
return { success: false, errorReason: "Stellar Transaction Failed" };
|
|
2176
|
+
}
|
|
2177
|
+
} catch (e) {
|
|
2178
|
+
console.error("Stellar Verification Error", e);
|
|
2179
|
+
return { success: false, errorReason: `Stellar Verification Failed: ${e.message}` };
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2139
2182
|
const { createPublicClient: createPublicClient3, http: http3 } = await import('viem');
|
|
2140
2183
|
const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
|
|
2141
2184
|
const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
|
|
@@ -2307,8 +2350,6 @@ exports.CHAIN_ID_TO_KEY = CHAIN_ID_TO_KEY;
|
|
|
2307
2350
|
exports.GNOSIS_MAINNET = GNOSIS_MAINNET;
|
|
2308
2351
|
exports.NearStrategy = NearStrategy;
|
|
2309
2352
|
exports.OPTIMISM_MAINNET = OPTIMISM_MAINNET;
|
|
2310
|
-
exports.STELLAR = STELLAR;
|
|
2311
|
-
exports.StellarService = StellarService;
|
|
2312
2353
|
exports.TransferManager = TransferManager;
|
|
2313
2354
|
exports.entryPointAbi = entryPointAbi;
|
|
2314
2355
|
exports.erc20Abi = erc20Abi;
|