@1llet.xyz/erc4337-gasless-sdk 0.4.34 → 0.4.35
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 +172 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { gnosis, optimism, baseSepolia, base, avalanche, worldchain, monad, polygon, arbitrum, bsc, unichain } from 'viem/chains';
|
|
2
2
|
import { createPublicClient, http, createWalletClient, decodeErrorResult, maxUint256, encodeFunctionData, encodeAbiParameters, keccak256, padHex } from 'viem';
|
|
3
3
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
-
import
|
|
4
|
+
import * as StellarSdk from 'stellar-sdk';
|
|
5
5
|
import { Networks } from 'stellar-sdk';
|
|
6
|
+
import axios from 'axios';
|
|
6
7
|
import { OpenAPI, QuoteRequest, OneClickService } from '@defuse-protocol/one-click-sdk-typescript';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
@@ -1143,6 +1144,134 @@ var CHAIN_ID_TO_KEY = {
|
|
|
1143
1144
|
"11155420": "Optimism",
|
|
1144
1145
|
"42161": "Arbitrum"
|
|
1145
1146
|
};
|
|
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
|
+
|
|
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
|
+
};
|
|
1146
1275
|
|
|
1147
1276
|
// src/services/cctp.ts
|
|
1148
1277
|
init_facilitator();
|
|
@@ -1512,48 +1641,6 @@ var WORLD_CHAIN = {
|
|
|
1512
1641
|
nearIntentInformation: null
|
|
1513
1642
|
}
|
|
1514
1643
|
};
|
|
1515
|
-
var STELLAR = {
|
|
1516
|
-
assets: [
|
|
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
|
-
};
|
|
1557
1644
|
var Monad = {
|
|
1558
1645
|
assets: [
|
|
1559
1646
|
{
|
|
@@ -2001,7 +2088,28 @@ var NearStrategy = class {
|
|
|
2001
2088
|
return !!(sourceNear && destNear);
|
|
2002
2089
|
}
|
|
2003
2090
|
async execute(context) {
|
|
2004
|
-
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash } = context;
|
|
2091
|
+
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash, paymentPayload } = context;
|
|
2092
|
+
if (sourceChain === "Stellar" && paymentPayload?.signedXDR) {
|
|
2093
|
+
const signedXDR = paymentPayload.signedXDR;
|
|
2094
|
+
console.log("[NearStrategy] Submitting Stellar User -> Facilitator TX...");
|
|
2095
|
+
try {
|
|
2096
|
+
const stellarService = new StellarService();
|
|
2097
|
+
const result = await stellarService.submitXdr(signedXDR);
|
|
2098
|
+
const pullHash = result.hash;
|
|
2099
|
+
console.log("[NearStrategy] Pull Success (Stellar):", pullHash);
|
|
2100
|
+
return {
|
|
2101
|
+
success: true,
|
|
2102
|
+
transactionHash: pullHash,
|
|
2103
|
+
data: {
|
|
2104
|
+
completed: true,
|
|
2105
|
+
message: "Stellar Transaction Submitted. Bridge in progress."
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
} catch (e) {
|
|
2109
|
+
console.error("Stellar Submit Error", e);
|
|
2110
|
+
return { success: false, errorReason: "Stellar Submit Failed: " + (e.message || "Unknown") };
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2005
2113
|
if (depositTxHash) {
|
|
2006
2114
|
console.log(`[NearStrategy] Verifying deposit hash: ${depositTxHash}`);
|
|
2007
2115
|
const { createPublicClient: createPublicClient3, http: http3 } = await import('viem');
|
|
@@ -2165,6 +2273,6 @@ var TransferManager = class {
|
|
|
2165
2273
|
}
|
|
2166
2274
|
};
|
|
2167
2275
|
|
|
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 };
|
|
2276
|
+
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
2277
|
//# sourceMappingURL=index.mjs.map
|
|
2170
2278
|
//# sourceMappingURL=index.mjs.map
|