@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.mjs CHANGED
@@ -1,8 +1,8 @@
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
- import * as StellarSdk from 'stellar-sdk';
5
- import { Networks } from 'stellar-sdk';
6
6
  import axios from 'axios';
7
7
  import { OpenAPI, QuoteRequest, OneClickService } from '@defuse-protocol/one-click-sdk-typescript';
8
8
 
@@ -15,6 +15,149 @@ var __export = (target, all) => {
15
15
  for (var name in all)
16
16
  __defProp(target, name, { get: all[name], enumerable: true });
17
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
+ });
18
161
 
19
162
  // src/constants/facilitator.ts
20
163
  var facilitator_exports = {};
@@ -1144,134 +1287,10 @@ var CHAIN_ID_TO_KEY = {
1144
1287
  "11155420": "Optimism",
1145
1288
  "42161": "Arbitrum"
1146
1289
  };
1147
- var STELLAR = {
1148
- assets: [
1149
- {
1150
- name: "USDC",
1151
- decimals: 7,
1152
- address: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
1153
- coingeckoId: "usd-coin"
1154
- },
1155
- {
1156
- name: "XLM",
1157
- decimals: 7,
1158
- address: "native",
1159
- coingeckoId: "stellar"
1160
- }
1161
- ],
1162
- nonEvm: {
1163
- networkPassphrase: Networks.PUBLIC,
1164
- serverURL: "https://horizon.stellar.org"
1165
- },
1166
- crossChainInformation: {
1167
- circleInformation: {
1168
- supportCirclePaymaster: false,
1169
- aproxFromFee: 0
1170
- },
1171
- nearIntentInformation: {
1172
- support: true,
1173
- assetsId: [
1174
- {
1175
- assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu",
1176
- name: "USDC",
1177
- decimals: 7
1178
- },
1179
- {
1180
- assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz",
1181
- name: "XLM",
1182
- decimals: 6
1183
- }
1184
- ],
1185
- needMemo: true
1186
- }
1187
- }
1188
- };
1189
1290
 
1190
- // src/services/StellarService.ts
1191
- var StellarService = class {
1192
- constructor() {
1193
- if (!STELLAR.nonEvm?.serverURL || !STELLAR.nonEvm?.networkPassphrase) {
1194
- throw new Error("Stellar Non-EVM config missing or incomplete");
1195
- }
1196
- this.server = new StellarSdk.Horizon.Server(STELLAR.nonEvm.serverURL);
1197
- this.network = STELLAR.nonEvm.networkPassphrase;
1198
- }
1199
- /**
1200
- * Get balance for a specific token (or all if not specified)
1201
- * Returns string representation
1202
- */
1203
- async getBalance(address, tokenName = "XLM") {
1204
- try {
1205
- const account = await this.server.loadAccount(address);
1206
- const assetDef = STELLAR.assets.find((a) => a.name === tokenName);
1207
- if (!assetDef) throw new Error(`Asset ${tokenName} not configured`);
1208
- const isNative = assetDef.address === "native";
1209
- const balanceLine = account.balances.find((b) => {
1210
- if (isNative) {
1211
- return b.asset_type === "native";
1212
- }
1213
- return b.asset_code === tokenName && b.asset_issuer === assetDef.address;
1214
- });
1215
- return balanceLine ? balanceLine.balance : "0";
1216
- } catch (e) {
1217
- if (e.response && e.response.status === 404) {
1218
- return "0";
1219
- }
1220
- throw e;
1221
- }
1222
- }
1223
- /**
1224
- * Build and Sign a Transfer Transaction
1225
- */
1226
- async buildTransferXdr(senderPk, recipient, amount, tokenName = "XLM", memo) {
1227
- const keypair = StellarSdk.Keypair.fromSecret(senderPk);
1228
- const sourceAddress = keypair.publicKey();
1229
- let account;
1230
- try {
1231
- account = await this.server.loadAccount(sourceAddress);
1232
- } catch (e) {
1233
- throw new Error(`Stellar Account ${sourceAddress} not valid or not active.`);
1234
- }
1235
- const asset = this.getAsset(tokenName);
1236
- const txBuilder = new StellarSdk.TransactionBuilder(account, {
1237
- fee: StellarSdk.BASE_FEE,
1238
- networkPassphrase: this.network
1239
- });
1240
- txBuilder.addOperation(StellarSdk.Operation.payment({
1241
- destination: recipient,
1242
- asset,
1243
- amount
1244
- }));
1245
- if (memo) {
1246
- txBuilder.addMemo(StellarSdk.Memo.text(memo));
1247
- }
1248
- txBuilder.setTimeout(30);
1249
- const builtTx = txBuilder.build();
1250
- builtTx.sign(keypair);
1251
- return builtTx.toXDR();
1252
- }
1253
- /**
1254
- * Submit Signed XDR
1255
- */
1256
- async submitXdr(xdr) {
1257
- const tx = StellarSdk.TransactionBuilder.fromXDR(xdr, this.network);
1258
- return this.server.submitTransaction(tx);
1259
- }
1260
- getAsset(tokenName) {
1261
- const assetDef = STELLAR.assets.find((a) => a.name === tokenName);
1262
- if (!assetDef) {
1263
- if (tokenName === "XLM") return StellarSdk.Asset.native();
1264
- throw new Error(`Asset ${tokenName} not found in configuration`);
1265
- }
1266
- if (assetDef.address === "native") {
1267
- return StellarSdk.Asset.native();
1268
- }
1269
- return new StellarSdk.Asset(assetDef.name, assetDef.address);
1270
- }
1271
- getKeypair(pk) {
1272
- return StellarSdk.Keypair.fromSecret(pk);
1273
- }
1274
- };
1291
+ // src/index.ts
1292
+ init_StellarService();
1293
+ init_Stellar();
1275
1294
 
1276
1295
  // src/services/cctp.ts
1277
1296
  init_facilitator();
@@ -1641,6 +1660,9 @@ var WORLD_CHAIN = {
1641
1660
  nearIntentInformation: null
1642
1661
  }
1643
1662
  };
1663
+
1664
+ // src/chains/index.ts
1665
+ init_Stellar();
1644
1666
  var Monad = {
1645
1667
  assets: [
1646
1668
  {
@@ -2073,6 +2095,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
2073
2095
  }
2074
2096
  };
2075
2097
  }
2098
+ init_StellarService();
2076
2099
  OpenAPI.BASE = "https://1click.chaindefuser.com";
2077
2100
  var NearStrategy = class {
2078
2101
  constructor() {
@@ -2112,6 +2135,26 @@ var NearStrategy = class {
2112
2135
  }
2113
2136
  if (depositTxHash) {
2114
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
+ }
2115
2158
  const { createPublicClient: createPublicClient3, http: http3 } = await import('viem');
2116
2159
  const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
2117
2160
  const networkConfig = FACILITATOR_NETWORKS2[sourceChain];