@1llet.xyz/erc4337-gasless-sdk 0.4.33 → 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 +173 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Chain, Address, Hash, Hex } from 'viem';
|
|
2
|
+
import * as StellarSdk from 'stellar-sdk';
|
|
3
|
+
import { Address as Address$1 } from 'abitype';
|
|
2
4
|
import z from 'zod';
|
|
3
5
|
|
|
4
6
|
interface Token {
|
|
@@ -6,7 +8,7 @@ interface Token {
|
|
|
6
8
|
decimals: number;
|
|
7
9
|
address: Address;
|
|
8
10
|
}
|
|
9
|
-
interface ChainConfig {
|
|
11
|
+
interface ChainConfig$1 {
|
|
10
12
|
chain: Chain;
|
|
11
13
|
rpcUrl?: string;
|
|
12
14
|
bundlerUrl: string;
|
|
@@ -66,7 +68,7 @@ declare class AccountAbstraction {
|
|
|
66
68
|
private userOpBuilder;
|
|
67
69
|
private entryPointAddress;
|
|
68
70
|
private factoryAddress;
|
|
69
|
-
constructor(chainConfig: ChainConfig);
|
|
71
|
+
constructor(chainConfig: ChainConfig$1);
|
|
70
72
|
/**
|
|
71
73
|
* Connect to MetaMask OR use Private Key
|
|
72
74
|
* @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
|
|
@@ -149,7 +151,7 @@ declare global {
|
|
|
149
151
|
declare class BundlerClient {
|
|
150
152
|
private bundlerUrl;
|
|
151
153
|
private entryPointAddress;
|
|
152
|
-
constructor(config: ChainConfig, entryPointAddress: Address);
|
|
154
|
+
constructor(config: ChainConfig$1, entryPointAddress: Address);
|
|
153
155
|
private call;
|
|
154
156
|
estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate>;
|
|
155
157
|
sendUserOperation(userOp: UserOperation): Promise<Hash>;
|
|
@@ -157,11 +159,11 @@ declare class BundlerClient {
|
|
|
157
159
|
requestApprovalSupport(token: Address, owner: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult>;
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
declare const BASE_MAINNET: ChainConfig;
|
|
161
|
-
declare const OPTIMISM_MAINNET: ChainConfig;
|
|
162
|
-
declare const GNOSIS_MAINNET: ChainConfig;
|
|
163
|
-
declare const BASE_SEPOLIA: ChainConfig;
|
|
164
|
-
declare const CHAIN_CONFIGS: Record<number, ChainConfig>;
|
|
162
|
+
declare const BASE_MAINNET: ChainConfig$1;
|
|
163
|
+
declare const OPTIMISM_MAINNET: ChainConfig$1;
|
|
164
|
+
declare const GNOSIS_MAINNET: ChainConfig$1;
|
|
165
|
+
declare const BASE_SEPOLIA: ChainConfig$1;
|
|
166
|
+
declare const CHAIN_CONFIGS: Record<number, ChainConfig$1>;
|
|
165
167
|
|
|
166
168
|
declare const entryPointAbi: readonly [{
|
|
167
169
|
readonly inputs: readonly [{
|
|
@@ -298,6 +300,27 @@ declare const erc20Abi: readonly [{
|
|
|
298
300
|
|
|
299
301
|
declare const CHAIN_ID_TO_KEY: Record<string, string>;
|
|
300
302
|
|
|
303
|
+
declare class StellarService {
|
|
304
|
+
server: StellarSdk.Horizon.Server;
|
|
305
|
+
network: string;
|
|
306
|
+
constructor();
|
|
307
|
+
/**
|
|
308
|
+
* Get balance for a specific token (or all if not specified)
|
|
309
|
+
* Returns string representation
|
|
310
|
+
*/
|
|
311
|
+
getBalance(address: string, tokenName?: string): Promise<string>;
|
|
312
|
+
/**
|
|
313
|
+
* Build and Sign a Transfer Transaction
|
|
314
|
+
*/
|
|
315
|
+
buildTransferXdr(senderPk: string, recipient: string, amount: string, tokenName?: string, memo?: string): Promise<string>;
|
|
316
|
+
/**
|
|
317
|
+
* Submit Signed XDR
|
|
318
|
+
*/
|
|
319
|
+
submitXdr(xdr: string): Promise<StellarSdk.Horizon.HorizonApi.SubmitTransactionResponse>;
|
|
320
|
+
getAsset(tokenName: string): StellarSdk.Asset;
|
|
321
|
+
getKeypair(pk: string): StellarSdk.Keypair;
|
|
322
|
+
}
|
|
323
|
+
|
|
301
324
|
declare const ChainKeyEnum: z.ZodEnum<{
|
|
302
325
|
Optimism: "Optimism";
|
|
303
326
|
Arbitrum: "Arbitrum";
|
|
@@ -312,6 +335,57 @@ declare const ChainKeyEnum: z.ZodEnum<{
|
|
|
312
335
|
GNOSIS: "GNOSIS";
|
|
313
336
|
}>;
|
|
314
337
|
type ChainKey = z.infer<typeof ChainKeyEnum>;
|
|
338
|
+
interface NearIntentAsset {
|
|
339
|
+
assetId: string;
|
|
340
|
+
name: string;
|
|
341
|
+
decimals: number;
|
|
342
|
+
}
|
|
343
|
+
interface NearIntentInformation {
|
|
344
|
+
support: boolean;
|
|
345
|
+
assetsId: NearIntentAsset[];
|
|
346
|
+
needMemo: boolean;
|
|
347
|
+
}
|
|
348
|
+
interface CCTPInformation {
|
|
349
|
+
supportCCTP: boolean;
|
|
350
|
+
domain: number;
|
|
351
|
+
}
|
|
352
|
+
interface CircleInformation {
|
|
353
|
+
supportCirclePaymaster: boolean;
|
|
354
|
+
cCTPInformation?: CCTPInformation;
|
|
355
|
+
aproxFromFee: number;
|
|
356
|
+
}
|
|
357
|
+
interface CrossChainInformation {
|
|
358
|
+
circleInformation?: CircleInformation;
|
|
359
|
+
nearIntentInformation: NearIntentInformation | null;
|
|
360
|
+
}
|
|
361
|
+
interface EvmInformation {
|
|
362
|
+
chain: any;
|
|
363
|
+
rpcUrl: string | null;
|
|
364
|
+
supports7702: boolean;
|
|
365
|
+
erc4337: boolean;
|
|
366
|
+
bundlerUrl?: string;
|
|
367
|
+
entryPointAddress?: Address$1;
|
|
368
|
+
factoryAddress?: Address$1;
|
|
369
|
+
paymasterAddress?: Address$1;
|
|
370
|
+
}
|
|
371
|
+
interface NonEvmInformation {
|
|
372
|
+
networkPassphrase?: string;
|
|
373
|
+
serverURL?: string;
|
|
374
|
+
}
|
|
375
|
+
interface Asset {
|
|
376
|
+
name: string;
|
|
377
|
+
decimals: number;
|
|
378
|
+
address?: Address$1 | string;
|
|
379
|
+
coingeckoId?: string;
|
|
380
|
+
}
|
|
381
|
+
interface ChainConfig {
|
|
382
|
+
assets: Asset[];
|
|
383
|
+
evm?: EvmInformation;
|
|
384
|
+
nonEvm?: NonEvmInformation;
|
|
385
|
+
crossChainInformation: CrossChainInformation;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare const STELLAR: ChainConfig;
|
|
315
389
|
|
|
316
390
|
interface FacilitatorPaymentPayload {
|
|
317
391
|
authorization: {
|
|
@@ -377,4 +451,4 @@ declare class CCTPStrategy implements BridgeStrategy {
|
|
|
377
451
|
execute(context: BridgeContext): Promise<SettleResponse>;
|
|
378
452
|
}
|
|
379
453
|
|
|
380
|
-
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
454
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, StellarService, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Chain, Address, Hash, Hex } from 'viem';
|
|
2
|
+
import * as StellarSdk from 'stellar-sdk';
|
|
3
|
+
import { Address as Address$1 } from 'abitype';
|
|
2
4
|
import z from 'zod';
|
|
3
5
|
|
|
4
6
|
interface Token {
|
|
@@ -6,7 +8,7 @@ interface Token {
|
|
|
6
8
|
decimals: number;
|
|
7
9
|
address: Address;
|
|
8
10
|
}
|
|
9
|
-
interface ChainConfig {
|
|
11
|
+
interface ChainConfig$1 {
|
|
10
12
|
chain: Chain;
|
|
11
13
|
rpcUrl?: string;
|
|
12
14
|
bundlerUrl: string;
|
|
@@ -66,7 +68,7 @@ declare class AccountAbstraction {
|
|
|
66
68
|
private userOpBuilder;
|
|
67
69
|
private entryPointAddress;
|
|
68
70
|
private factoryAddress;
|
|
69
|
-
constructor(chainConfig: ChainConfig);
|
|
71
|
+
constructor(chainConfig: ChainConfig$1);
|
|
70
72
|
/**
|
|
71
73
|
* Connect to MetaMask OR use Private Key
|
|
72
74
|
* @param privateKey (Optional) Hex string of private key. If provided, uses local signing.
|
|
@@ -149,7 +151,7 @@ declare global {
|
|
|
149
151
|
declare class BundlerClient {
|
|
150
152
|
private bundlerUrl;
|
|
151
153
|
private entryPointAddress;
|
|
152
|
-
constructor(config: ChainConfig, entryPointAddress: Address);
|
|
154
|
+
constructor(config: ChainConfig$1, entryPointAddress: Address);
|
|
153
155
|
private call;
|
|
154
156
|
estimateGas(userOp: Partial<UserOperation>): Promise<GasEstimate>;
|
|
155
157
|
sendUserOperation(userOp: UserOperation): Promise<Hash>;
|
|
@@ -157,11 +159,11 @@ declare class BundlerClient {
|
|
|
157
159
|
requestApprovalSupport(token: Address, owner: Address, spender: Address, amount: bigint): Promise<ApprovalSupportResult>;
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
declare const BASE_MAINNET: ChainConfig;
|
|
161
|
-
declare const OPTIMISM_MAINNET: ChainConfig;
|
|
162
|
-
declare const GNOSIS_MAINNET: ChainConfig;
|
|
163
|
-
declare const BASE_SEPOLIA: ChainConfig;
|
|
164
|
-
declare const CHAIN_CONFIGS: Record<number, ChainConfig>;
|
|
162
|
+
declare const BASE_MAINNET: ChainConfig$1;
|
|
163
|
+
declare const OPTIMISM_MAINNET: ChainConfig$1;
|
|
164
|
+
declare const GNOSIS_MAINNET: ChainConfig$1;
|
|
165
|
+
declare const BASE_SEPOLIA: ChainConfig$1;
|
|
166
|
+
declare const CHAIN_CONFIGS: Record<number, ChainConfig$1>;
|
|
165
167
|
|
|
166
168
|
declare const entryPointAbi: readonly [{
|
|
167
169
|
readonly inputs: readonly [{
|
|
@@ -298,6 +300,27 @@ declare const erc20Abi: readonly [{
|
|
|
298
300
|
|
|
299
301
|
declare const CHAIN_ID_TO_KEY: Record<string, string>;
|
|
300
302
|
|
|
303
|
+
declare class StellarService {
|
|
304
|
+
server: StellarSdk.Horizon.Server;
|
|
305
|
+
network: string;
|
|
306
|
+
constructor();
|
|
307
|
+
/**
|
|
308
|
+
* Get balance for a specific token (or all if not specified)
|
|
309
|
+
* Returns string representation
|
|
310
|
+
*/
|
|
311
|
+
getBalance(address: string, tokenName?: string): Promise<string>;
|
|
312
|
+
/**
|
|
313
|
+
* Build and Sign a Transfer Transaction
|
|
314
|
+
*/
|
|
315
|
+
buildTransferXdr(senderPk: string, recipient: string, amount: string, tokenName?: string, memo?: string): Promise<string>;
|
|
316
|
+
/**
|
|
317
|
+
* Submit Signed XDR
|
|
318
|
+
*/
|
|
319
|
+
submitXdr(xdr: string): Promise<StellarSdk.Horizon.HorizonApi.SubmitTransactionResponse>;
|
|
320
|
+
getAsset(tokenName: string): StellarSdk.Asset;
|
|
321
|
+
getKeypair(pk: string): StellarSdk.Keypair;
|
|
322
|
+
}
|
|
323
|
+
|
|
301
324
|
declare const ChainKeyEnum: z.ZodEnum<{
|
|
302
325
|
Optimism: "Optimism";
|
|
303
326
|
Arbitrum: "Arbitrum";
|
|
@@ -312,6 +335,57 @@ declare const ChainKeyEnum: z.ZodEnum<{
|
|
|
312
335
|
GNOSIS: "GNOSIS";
|
|
313
336
|
}>;
|
|
314
337
|
type ChainKey = z.infer<typeof ChainKeyEnum>;
|
|
338
|
+
interface NearIntentAsset {
|
|
339
|
+
assetId: string;
|
|
340
|
+
name: string;
|
|
341
|
+
decimals: number;
|
|
342
|
+
}
|
|
343
|
+
interface NearIntentInformation {
|
|
344
|
+
support: boolean;
|
|
345
|
+
assetsId: NearIntentAsset[];
|
|
346
|
+
needMemo: boolean;
|
|
347
|
+
}
|
|
348
|
+
interface CCTPInformation {
|
|
349
|
+
supportCCTP: boolean;
|
|
350
|
+
domain: number;
|
|
351
|
+
}
|
|
352
|
+
interface CircleInformation {
|
|
353
|
+
supportCirclePaymaster: boolean;
|
|
354
|
+
cCTPInformation?: CCTPInformation;
|
|
355
|
+
aproxFromFee: number;
|
|
356
|
+
}
|
|
357
|
+
interface CrossChainInformation {
|
|
358
|
+
circleInformation?: CircleInformation;
|
|
359
|
+
nearIntentInformation: NearIntentInformation | null;
|
|
360
|
+
}
|
|
361
|
+
interface EvmInformation {
|
|
362
|
+
chain: any;
|
|
363
|
+
rpcUrl: string | null;
|
|
364
|
+
supports7702: boolean;
|
|
365
|
+
erc4337: boolean;
|
|
366
|
+
bundlerUrl?: string;
|
|
367
|
+
entryPointAddress?: Address$1;
|
|
368
|
+
factoryAddress?: Address$1;
|
|
369
|
+
paymasterAddress?: Address$1;
|
|
370
|
+
}
|
|
371
|
+
interface NonEvmInformation {
|
|
372
|
+
networkPassphrase?: string;
|
|
373
|
+
serverURL?: string;
|
|
374
|
+
}
|
|
375
|
+
interface Asset {
|
|
376
|
+
name: string;
|
|
377
|
+
decimals: number;
|
|
378
|
+
address?: Address$1 | string;
|
|
379
|
+
coingeckoId?: string;
|
|
380
|
+
}
|
|
381
|
+
interface ChainConfig {
|
|
382
|
+
assets: Asset[];
|
|
383
|
+
evm?: EvmInformation;
|
|
384
|
+
nonEvm?: NonEvmInformation;
|
|
385
|
+
crossChainInformation: CrossChainInformation;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare const STELLAR: ChainConfig;
|
|
315
389
|
|
|
316
390
|
interface FacilitatorPaymentPayload {
|
|
317
391
|
authorization: {
|
|
@@ -377,4 +451,4 @@ declare class CCTPStrategy implements BridgeStrategy {
|
|
|
377
451
|
execute(context: BridgeContext): Promise<SettleResponse>;
|
|
378
452
|
}
|
|
379
453
|
|
|
380
|
-
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
|
454
|
+
export { AccountAbstraction, type ApprovalSupportResult, BASE_MAINNET, BASE_SEPOLIA, BundlerClient, CCTPStrategy, CHAIN_CONFIGS, CHAIN_ID_TO_KEY, type ChainConfig$1 as ChainConfig, GNOSIS_MAINNET, type GasEstimate, NearStrategy, OPTIMISM_MAINNET, STELLAR, StellarService, type Token, TransferManager, type UserOpReceipt, type UserOperation, entryPointAbi, erc20Abi, smartAccountAbi };
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,31 @@
|
|
|
3
3
|
var chains = require('viem/chains');
|
|
4
4
|
var viem = require('viem');
|
|
5
5
|
var accounts = require('viem/accounts');
|
|
6
|
+
var StellarSdk = require('stellar-sdk');
|
|
6
7
|
var axios = require('axios');
|
|
7
|
-
var stellarSdk = require('stellar-sdk');
|
|
8
8
|
var oneClickSdkTypescript = require('@defuse-protocol/one-click-sdk-typescript');
|
|
9
9
|
|
|
10
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var StellarSdk__namespace = /*#__PURE__*/_interopNamespace(StellarSdk);
|
|
12
31
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
13
32
|
|
|
14
33
|
var __defProp = Object.defineProperty;
|
|
@@ -1149,6 +1168,134 @@ var CHAIN_ID_TO_KEY = {
|
|
|
1149
1168
|
"11155420": "Optimism",
|
|
1150
1169
|
"42161": "Arbitrum"
|
|
1151
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
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
|
|
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
|
+
};
|
|
1152
1299
|
|
|
1153
1300
|
// src/services/cctp.ts
|
|
1154
1301
|
init_facilitator();
|
|
@@ -1518,48 +1665,6 @@ var WORLD_CHAIN = {
|
|
|
1518
1665
|
nearIntentInformation: null
|
|
1519
1666
|
}
|
|
1520
1667
|
};
|
|
1521
|
-
var STELLAR = {
|
|
1522
|
-
assets: [
|
|
1523
|
-
{
|
|
1524
|
-
name: "USDC",
|
|
1525
|
-
decimals: 7,
|
|
1526
|
-
address: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
1527
|
-
coingeckoId: "usd-coin"
|
|
1528
|
-
},
|
|
1529
|
-
{
|
|
1530
|
-
name: "XLM",
|
|
1531
|
-
decimals: 7,
|
|
1532
|
-
address: "native",
|
|
1533
|
-
coingeckoId: "stellar"
|
|
1534
|
-
}
|
|
1535
|
-
],
|
|
1536
|
-
nonEvm: {
|
|
1537
|
-
networkPassphrase: stellarSdk.Networks.PUBLIC,
|
|
1538
|
-
serverURL: "https://horizon.stellar.org"
|
|
1539
|
-
},
|
|
1540
|
-
crossChainInformation: {
|
|
1541
|
-
circleInformation: {
|
|
1542
|
-
supportCirclePaymaster: false,
|
|
1543
|
-
aproxFromFee: 0
|
|
1544
|
-
},
|
|
1545
|
-
nearIntentInformation: {
|
|
1546
|
-
support: true,
|
|
1547
|
-
assetsId: [
|
|
1548
|
-
{
|
|
1549
|
-
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB65GxAPAVoxqmMcgYo5oS3txhqs1Uh1cgahKQUeTUq1TJu",
|
|
1550
|
-
name: "USDC",
|
|
1551
|
-
decimals: 7
|
|
1552
|
-
},
|
|
1553
|
-
{
|
|
1554
|
-
assetId: "nep245:v2_1.omni.hot.tg:1100_111bzQBB5v7AhLyPMDwS8uJgQV24KaAPXtwyVWu2KXbbfQU6NXRCz",
|
|
1555
|
-
name: "XLM",
|
|
1556
|
-
decimals: 6
|
|
1557
|
-
}
|
|
1558
|
-
],
|
|
1559
|
-
needMemo: true
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
1668
|
var Monad = {
|
|
1564
1669
|
assets: [
|
|
1565
1670
|
{
|
|
@@ -1694,7 +1799,7 @@ var NETWORKS = {
|
|
|
1694
1799
|
Stellar: STELLAR,
|
|
1695
1800
|
Monad,
|
|
1696
1801
|
BNB,
|
|
1697
|
-
GNOSIS
|
|
1802
|
+
Gnosis: GNOSIS
|
|
1698
1803
|
};
|
|
1699
1804
|
|
|
1700
1805
|
// src/services/cctp.ts
|
|
@@ -2007,7 +2112,28 @@ var NearStrategy = class {
|
|
|
2007
2112
|
return !!(sourceNear && destNear);
|
|
2008
2113
|
}
|
|
2009
2114
|
async execute(context) {
|
|
2010
|
-
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash } = context;
|
|
2115
|
+
const { sourceChain, destChain, amount, recipient, destToken, sourceToken, senderAddress, depositTxHash, paymentPayload } = context;
|
|
2116
|
+
if (sourceChain === "Stellar" && paymentPayload?.signedXDR) {
|
|
2117
|
+
const signedXDR = paymentPayload.signedXDR;
|
|
2118
|
+
console.log("[NearStrategy] Submitting Stellar User -> Facilitator TX...");
|
|
2119
|
+
try {
|
|
2120
|
+
const stellarService = new StellarService();
|
|
2121
|
+
const result = await stellarService.submitXdr(signedXDR);
|
|
2122
|
+
const pullHash = result.hash;
|
|
2123
|
+
console.log("[NearStrategy] Pull Success (Stellar):", pullHash);
|
|
2124
|
+
return {
|
|
2125
|
+
success: true,
|
|
2126
|
+
transactionHash: pullHash,
|
|
2127
|
+
data: {
|
|
2128
|
+
completed: true,
|
|
2129
|
+
message: "Stellar Transaction Submitted. Bridge in progress."
|
|
2130
|
+
}
|
|
2131
|
+
};
|
|
2132
|
+
} catch (e) {
|
|
2133
|
+
console.error("Stellar Submit Error", e);
|
|
2134
|
+
return { success: false, errorReason: "Stellar Submit Failed: " + (e.message || "Unknown") };
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2011
2137
|
if (depositTxHash) {
|
|
2012
2138
|
console.log(`[NearStrategy] Verifying deposit hash: ${depositTxHash}`);
|
|
2013
2139
|
const { createPublicClient: createPublicClient3, http: http3 } = await import('viem');
|
|
@@ -2181,6 +2307,8 @@ exports.CHAIN_ID_TO_KEY = CHAIN_ID_TO_KEY;
|
|
|
2181
2307
|
exports.GNOSIS_MAINNET = GNOSIS_MAINNET;
|
|
2182
2308
|
exports.NearStrategy = NearStrategy;
|
|
2183
2309
|
exports.OPTIMISM_MAINNET = OPTIMISM_MAINNET;
|
|
2310
|
+
exports.STELLAR = STELLAR;
|
|
2311
|
+
exports.StellarService = StellarService;
|
|
2184
2312
|
exports.TransferManager = TransferManager;
|
|
2185
2313
|
exports.entryPointAbi = entryPointAbi;
|
|
2186
2314
|
exports.erc20Abi = erc20Abi;
|