@1llet.xyz/erc4337-gasless-sdk 0.4.35 → 0.4.37

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 CHANGED
@@ -8,7 +8,7 @@ interface Token {
8
8
  decimals: number;
9
9
  address: Address;
10
10
  }
11
- interface ChainConfig$1 {
11
+ interface EvmChainConfig {
12
12
  chain: Chain;
13
13
  rpcUrl?: string;
14
14
  bundlerUrl: string;
@@ -17,6 +17,17 @@ interface ChainConfig$1 {
17
17
  paymasterAddress?: Address;
18
18
  tokens: Token[];
19
19
  }
20
+ interface NonEvmChainConfig {
21
+ chain: {
22
+ id: number;
23
+ name: string;
24
+ [key: string]: any;
25
+ };
26
+ rpcUrl?: string;
27
+ bundlerUrl?: string;
28
+ tokens: Token[];
29
+ }
30
+ type ChainConfig$1 = EvmChainConfig | NonEvmChainConfig;
20
31
  interface UserOperation {
21
32
  sender: Address;
22
33
  nonce: bigint;
@@ -68,7 +79,7 @@ declare class AccountAbstraction {
68
79
  private userOpBuilder;
69
80
  private entryPointAddress;
70
81
  private factoryAddress;
71
- constructor(chainConfig: ChainConfig$1);
82
+ constructor(chainConfig: EvmChainConfig);
72
83
  /**
73
84
  * Connect to MetaMask OR use Private Key
74
85
  * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
@@ -151,7 +162,7 @@ declare global {
151
162
  declare class BundlerClient {
152
163
  private bundlerUrl;
153
164
  private entryPointAddress;
154
- constructor(config: ChainConfig$1, entryPointAddress: Address);
165
+ constructor(config: EvmChainConfig, entryPointAddress: Address);
155
166
  private call;
156
167
  estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate>;
157
168
  sendUserOperation(userOp: UserOperation): Promise<Hash>;
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ interface Token {
8
8
  decimals: number;
9
9
  address: Address;
10
10
  }
11
- interface ChainConfig$1 {
11
+ interface EvmChainConfig {
12
12
  chain: Chain;
13
13
  rpcUrl?: string;
14
14
  bundlerUrl: string;
@@ -17,6 +17,17 @@ interface ChainConfig$1 {
17
17
  paymasterAddress?: Address;
18
18
  tokens: Token[];
19
19
  }
20
+ interface NonEvmChainConfig {
21
+ chain: {
22
+ id: number;
23
+ name: string;
24
+ [key: string]: any;
25
+ };
26
+ rpcUrl?: string;
27
+ bundlerUrl?: string;
28
+ tokens: Token[];
29
+ }
30
+ type ChainConfig$1 = EvmChainConfig | NonEvmChainConfig;
20
31
  interface UserOperation {
21
32
  sender: Address;
22
33
  nonce: bigint;
@@ -68,7 +79,7 @@ declare class AccountAbstraction {
68
79
  private userOpBuilder;
69
80
  private entryPointAddress;
70
81
  private factoryAddress;
71
- constructor(chainConfig: ChainConfig$1);
82
+ constructor(chainConfig: EvmChainConfig);
72
83
  /**
73
84
  * Connect to MetaMask OR use Private Key
74
85
  * @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
@@ -151,7 +162,7 @@ declare global {
151
162
  declare class BundlerClient {
152
163
  private bundlerUrl;
153
164
  private entryPointAddress;
154
- constructor(config: ChainConfig$1, entryPointAddress: Address);
165
+ constructor(config: EvmChainConfig, entryPointAddress: Address);
155
166
  private call;
156
167
  estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate>;
157
168
  sendUserOperation(userOp: UserOperation): Promise<Hash>;
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 = {};
@@ -1132,7 +1275,22 @@ var BASE_SEPOLIA = {
1132
1275
  factoryAddress: "0x9406Cc6185a346906296840746125a0E44976454"
1133
1276
  // Paymaster optional
1134
1277
  }};
1278
+
1279
+ // src/chains.ts
1280
+ init_Stellar();
1135
1281
  function mapToSDKConfig(data) {
1282
+ if (data.nonEvm) {
1283
+ return {
1284
+ chain: { id: 9e3, name: "Stellar" },
1285
+ // Custom ID for Stellar
1286
+ tokens: data.assets.map((a) => ({
1287
+ symbol: a.name,
1288
+ decimals: a.decimals,
1289
+ address: a.address
1290
+ // Valid address string
1291
+ }))
1292
+ };
1293
+ }
1136
1294
  if (!data.evm) throw new Error("Non-EVM config used in EVM SDK");
1137
1295
  return {
1138
1296
  chain: data.evm.chain,
@@ -1152,11 +1310,13 @@ var BASE_MAINNET = mapToSDKConfig(BASE);
1152
1310
  var OPTIMISM_MAINNET = mapToSDKConfig(OPTIMISM);
1153
1311
  var GNOSIS_MAINNET = mapToSDKConfig(GNOSIS);
1154
1312
  var BASE_SEPOLIA2 = mapToSDKConfig(BASE_SEPOLIA);
1313
+ var STELLAR_TESTNET = mapToSDKConfig(exports.STELLAR);
1155
1314
  var CHAIN_CONFIGS = {
1156
1315
  [chains.base.id]: BASE_MAINNET,
1157
1316
  [chains.baseSepolia.id]: BASE_SEPOLIA2,
1158
1317
  [chains.gnosis.id]: GNOSIS_MAINNET,
1159
- [chains.optimism.id]: OPTIMISM_MAINNET
1318
+ [chains.optimism.id]: OPTIMISM_MAINNET,
1319
+ 9e3: STELLAR_TESTNET
1160
1320
  };
1161
1321
 
1162
1322
  // src/constants/chains.ts
@@ -1166,136 +1326,13 @@ var CHAIN_ID_TO_KEY = {
1166
1326
  "100": "Gnosis",
1167
1327
  "10": "Optimism",
1168
1328
  "11155420": "Optimism",
1169
- "42161": "Arbitrum"
1170
- };
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
- }
1329
+ "42161": "Arbitrum",
1330
+ "9000": "Stellar"
1212
1331
  };
1213
1332
 
1214
- // src/services/StellarService.ts
1215
- var StellarService = class {
1216
- constructor() {
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
- };
1333
+ // src/index.ts
1334
+ init_StellarService();
1335
+ init_Stellar();
1299
1336
 
1300
1337
  // src/services/cctp.ts
1301
1338
  init_facilitator();
@@ -1665,6 +1702,9 @@ var WORLD_CHAIN = {
1665
1702
  nearIntentInformation: null
1666
1703
  }
1667
1704
  };
1705
+
1706
+ // src/chains/index.ts
1707
+ init_Stellar();
1668
1708
  var Monad = {
1669
1709
  assets: [
1670
1710
  {
@@ -1796,7 +1836,7 @@ var NETWORKS = {
1796
1836
  Polygon: POLYGON,
1797
1837
  Avalanche: AVALANCHE,
1798
1838
  WorldChain: WORLD_CHAIN,
1799
- Stellar: STELLAR,
1839
+ Stellar: exports.STELLAR,
1800
1840
  Monad,
1801
1841
  BNB,
1802
1842
  Gnosis: GNOSIS
@@ -2097,6 +2137,7 @@ async function executeCCTPBridge(sourceChain, amount, crossChainConfig, facilita
2097
2137
  }
2098
2138
  };
2099
2139
  }
2140
+ init_StellarService();
2100
2141
  oneClickSdkTypescript.OpenAPI.BASE = "https://1click.chaindefuser.com";
2101
2142
  var NearStrategy = class {
2102
2143
  constructor() {
@@ -2117,7 +2158,7 @@ var NearStrategy = class {
2117
2158
  const signedXDR = paymentPayload.signedXDR;
2118
2159
  console.log("[NearStrategy] Submitting Stellar User -> Facilitator TX...");
2119
2160
  try {
2120
- const stellarService = new StellarService();
2161
+ const stellarService = new exports.StellarService();
2121
2162
  const result = await stellarService.submitXdr(signedXDR);
2122
2163
  const pullHash = result.hash;
2123
2164
  console.log("[NearStrategy] Pull Success (Stellar):", pullHash);
@@ -2136,6 +2177,26 @@ var NearStrategy = class {
2136
2177
  }
2137
2178
  if (depositTxHash) {
2138
2179
  console.log(`[NearStrategy] Verifying deposit hash: ${depositTxHash}`);
2180
+ if (sourceChain === "Stellar") {
2181
+ try {
2182
+ const { StellarService: StellarService2 } = await Promise.resolve().then(() => (init_StellarService(), StellarService_exports));
2183
+ const stellarService = new StellarService2();
2184
+ const tx = await stellarService.server.transactions().transaction(depositTxHash).call();
2185
+ if (tx.successful) {
2186
+ return {
2187
+ success: true,
2188
+ transactionHash: depositTxHash,
2189
+ netAmount: amount,
2190
+ data: { completed: true }
2191
+ };
2192
+ } else {
2193
+ return { success: false, errorReason: "Stellar Transaction Failed" };
2194
+ }
2195
+ } catch (e) {
2196
+ console.error("Stellar Verification Error", e);
2197
+ return { success: false, errorReason: `Stellar Verification Failed: ${e.message}` };
2198
+ }
2199
+ }
2139
2200
  const { createPublicClient: createPublicClient3, http: http3 } = await import('viem');
2140
2201
  const { FACILITATOR_NETWORKS: FACILITATOR_NETWORKS2 } = await Promise.resolve().then(() => (init_facilitator(), facilitator_exports));
2141
2202
  const networkConfig = FACILITATOR_NETWORKS2[sourceChain];
@@ -2307,8 +2368,6 @@ exports.CHAIN_ID_TO_KEY = CHAIN_ID_TO_KEY;
2307
2368
  exports.GNOSIS_MAINNET = GNOSIS_MAINNET;
2308
2369
  exports.NearStrategy = NearStrategy;
2309
2370
  exports.OPTIMISM_MAINNET = OPTIMISM_MAINNET;
2310
- exports.STELLAR = STELLAR;
2311
- exports.StellarService = StellarService;
2312
2371
  exports.TransferManager = TransferManager;
2313
2372
  exports.entryPointAbi = entryPointAbi;
2314
2373
  exports.erc20Abi = erc20Abi;