@asgcard/pay 0.1.1
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/CHANGELOG.md +90 -0
- package/LICENSE +21 -0
- package/README.md +393 -0
- package/dist/cjs/adapters/base.js +174 -0
- package/dist/cjs/adapters/base.js.map +1 -0
- package/dist/cjs/adapters/evm.js +263 -0
- package/dist/cjs/adapters/evm.js.map +1 -0
- package/dist/cjs/adapters/index.js +13 -0
- package/dist/cjs/adapters/index.js.map +1 -0
- package/dist/cjs/adapters/stellar.js +173 -0
- package/dist/cjs/adapters/stellar.js.map +1 -0
- package/dist/cjs/adapters/stripe.js +338 -0
- package/dist/cjs/adapters/stripe.js.map +1 -0
- package/dist/cjs/adapters/types.js +3 -0
- package/dist/cjs/adapters/types.js.map +1 -0
- package/dist/cjs/client.js +309 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/logger.js +7 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/cjs/mpp.js +187 -0
- package/dist/cjs/mpp.js.map +1 -0
- package/dist/cjs/policy.js +71 -0
- package/dist/cjs/policy.js.map +1 -0
- package/dist/cjs/stellar.js +87 -0
- package/dist/cjs/stellar.js.map +1 -0
- package/dist/esm/adapters/base.js +170 -0
- package/dist/esm/adapters/base.js.map +1 -0
- package/dist/esm/adapters/evm.js +258 -0
- package/dist/esm/adapters/evm.js.map +1 -0
- package/dist/esm/adapters/index.js +5 -0
- package/dist/esm/adapters/index.js.map +1 -0
- package/dist/esm/adapters/stellar.js +136 -0
- package/dist/esm/adapters/stellar.js.map +1 -0
- package/dist/esm/adapters/stripe.js +334 -0
- package/dist/esm/adapters/stripe.js.map +1 -0
- package/dist/esm/adapters/types.js +2 -0
- package/dist/esm/adapters/types.js.map +1 -0
- package/dist/esm/client.js +302 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.js +3 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/mpp.js +175 -0
- package/dist/esm/mpp.js.map +1 -0
- package/dist/esm/policy.js +67 -0
- package/dist/esm/policy.js.map +1 -0
- package/dist/esm/stellar.js +50 -0
- package/dist/esm/stellar.js.map +1 -0
- package/dist/types/adapters/base.d.ts +53 -0
- package/dist/types/adapters/base.d.ts.map +1 -0
- package/dist/types/adapters/evm.d.ts +81 -0
- package/dist/types/adapters/evm.d.ts.map +1 -0
- package/dist/types/adapters/index.d.ts +6 -0
- package/dist/types/adapters/index.d.ts.map +1 -0
- package/dist/types/adapters/stellar.d.ts +67 -0
- package/dist/types/adapters/stellar.d.ts.map +1 -0
- package/dist/types/adapters/stripe.d.ts +206 -0
- package/dist/types/adapters/stripe.d.ts.map +1 -0
- package/dist/types/adapters/types.d.ts +35 -0
- package/dist/types/adapters/types.d.ts.map +1 -0
- package/dist/types/client.d.ts +89 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/logger.d.ts +10 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/mpp.d.ts +153 -0
- package/dist/types/mpp.d.ts.map +1 -0
- package/dist/types/policy.d.ts +40 -0
- package/dist/types/policy.d.ts.map +1 -0
- package/dist/types/stellar.d.ts +27 -0
- package/dist/types/stellar.d.ts.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { createWalletClient, createPublicClient, http, formatEther, formatUnits, } from 'viem';
|
|
2
|
+
import { privateKeyToAccount, generatePrivateKey } from 'viem/accounts';
|
|
3
|
+
import { base, baseSepolia, arbitrum, arbitrumSepolia, optimism, optimismSepolia, mainnet as ethereum, sepolia as ethereumSepolia, polygon, polygonAmoy, } from 'viem/chains';
|
|
4
|
+
import { noopLogger } from '../logger';
|
|
5
|
+
/**
|
|
6
|
+
* Chain registry — maps chain names to viem chain objects + USDC contracts.
|
|
7
|
+
* All USDC addresses are Circle's official native USDC deployments.
|
|
8
|
+
*/
|
|
9
|
+
const CHAIN_REGISTRY = {
|
|
10
|
+
// ── Base (Coinbase L2) ──────────────────────────────────────────
|
|
11
|
+
'base': {
|
|
12
|
+
chain: base,
|
|
13
|
+
displayName: 'Base',
|
|
14
|
+
usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
15
|
+
},
|
|
16
|
+
'base-sepolia': {
|
|
17
|
+
chain: baseSepolia,
|
|
18
|
+
displayName: 'Base Sepolia',
|
|
19
|
+
usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
|
|
20
|
+
},
|
|
21
|
+
// ── Arbitrum ────────────────────────────────────────────────────
|
|
22
|
+
'arbitrum': {
|
|
23
|
+
chain: arbitrum,
|
|
24
|
+
displayName: 'Arbitrum One',
|
|
25
|
+
usdc: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
26
|
+
},
|
|
27
|
+
'arbitrum-sepolia': {
|
|
28
|
+
chain: arbitrumSepolia,
|
|
29
|
+
displayName: 'Arbitrum Sepolia',
|
|
30
|
+
usdc: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
|
|
31
|
+
},
|
|
32
|
+
// ── Optimism ────────────────────────────────────────────────────
|
|
33
|
+
'optimism': {
|
|
34
|
+
chain: optimism,
|
|
35
|
+
displayName: 'Optimism',
|
|
36
|
+
usdc: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
37
|
+
},
|
|
38
|
+
'optimism-sepolia': {
|
|
39
|
+
chain: optimismSepolia,
|
|
40
|
+
displayName: 'Optimism Sepolia',
|
|
41
|
+
usdc: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7',
|
|
42
|
+
},
|
|
43
|
+
// ── Ethereum ────────────────────────────────────────────────────
|
|
44
|
+
'ethereum': {
|
|
45
|
+
chain: ethereum,
|
|
46
|
+
displayName: 'Ethereum',
|
|
47
|
+
usdc: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
48
|
+
},
|
|
49
|
+
'ethereum-sepolia': {
|
|
50
|
+
chain: ethereumSepolia,
|
|
51
|
+
displayName: 'Ethereum Sepolia',
|
|
52
|
+
usdc: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
|
|
53
|
+
},
|
|
54
|
+
// ── Polygon ─────────────────────────────────────────────────────
|
|
55
|
+
'polygon': {
|
|
56
|
+
chain: polygon,
|
|
57
|
+
displayName: 'Polygon',
|
|
58
|
+
usdc: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',
|
|
59
|
+
},
|
|
60
|
+
'polygon-amoy': {
|
|
61
|
+
chain: polygonAmoy,
|
|
62
|
+
displayName: 'Polygon Amoy',
|
|
63
|
+
usdc: null, // No official Circle testnet USDC on Amoy yet
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
// ─── ERC-20 ABI (minimal) ───────────────────────────────────────────
|
|
67
|
+
const ERC20_ABI = [
|
|
68
|
+
{
|
|
69
|
+
name: 'transfer',
|
|
70
|
+
type: 'function',
|
|
71
|
+
stateMutability: 'nonpayable',
|
|
72
|
+
inputs: [
|
|
73
|
+
{ name: 'to', type: 'address' },
|
|
74
|
+
{ name: 'amount', type: 'uint256' },
|
|
75
|
+
],
|
|
76
|
+
outputs: [{ name: '', type: 'bool' }],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'balanceOf',
|
|
80
|
+
type: 'function',
|
|
81
|
+
stateMutability: 'view',
|
|
82
|
+
inputs: [{ name: 'account', type: 'address' }],
|
|
83
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
// ─── Universal EVM Adapter ──────────────────────────────────────────
|
|
87
|
+
/**
|
|
88
|
+
* EvmPaymentAdapter — Universal EVM on-chain settlement.
|
|
89
|
+
*
|
|
90
|
+
* One adapter for ALL EVM chains supported by x402:
|
|
91
|
+
* Base, Arbitrum, Optimism, Ethereum, Polygon — mainnet & testnet.
|
|
92
|
+
*
|
|
93
|
+
* Supports native token (ETH/MATIC) and USDC (Circle ERC-20) transfers.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* // Arbitrum USDC settlement
|
|
98
|
+
* const adapter = new EvmPaymentAdapter({
|
|
99
|
+
* chain: 'arbitrum',
|
|
100
|
+
* asset: 'USDC',
|
|
101
|
+
* privateKey: '0x...',
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* // Base ETH settlement (testnet)
|
|
105
|
+
* const adapter = new EvmPaymentAdapter({
|
|
106
|
+
* chain: 'base-sepolia',
|
|
107
|
+
* asset: 'native',
|
|
108
|
+
* });
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @see https://x402.org — x402 payment protocol
|
|
112
|
+
* @see https://pay.asgcard.dev — ASG Pay production infrastructure
|
|
113
|
+
*/
|
|
114
|
+
export class EvmPaymentAdapter {
|
|
115
|
+
chainName;
|
|
116
|
+
caip2Id;
|
|
117
|
+
wallet;
|
|
118
|
+
publicClient;
|
|
119
|
+
account;
|
|
120
|
+
chainConfig;
|
|
121
|
+
asset;
|
|
122
|
+
log;
|
|
123
|
+
constructor(options) {
|
|
124
|
+
const config = CHAIN_REGISTRY[options.chain];
|
|
125
|
+
if (!config) {
|
|
126
|
+
throw new Error(`Unsupported chain: "${options.chain}". ` +
|
|
127
|
+
`Supported: ${Object.keys(CHAIN_REGISTRY).join(', ')}`);
|
|
128
|
+
}
|
|
129
|
+
this.chainConfig = config;
|
|
130
|
+
this.chainName = config.displayName;
|
|
131
|
+
this.caip2Id = `eip155:${config.chain.id}`;
|
|
132
|
+
this.asset = options.asset ?? 'native';
|
|
133
|
+
this.log = options.logger ?? noopLogger;
|
|
134
|
+
if (this.asset === 'USDC' && !config.usdc) {
|
|
135
|
+
throw new Error(`No USDC contract available for ${config.displayName}. ` +
|
|
136
|
+
`Use asset: 'native' or choose a chain with USDC support.`);
|
|
137
|
+
}
|
|
138
|
+
const key = options.privateKey ?? generatePrivateKey();
|
|
139
|
+
this.account = privateKeyToAccount(key);
|
|
140
|
+
const transport = options.rpcUrl ? http(options.rpcUrl) : http();
|
|
141
|
+
this.wallet = createWalletClient({
|
|
142
|
+
account: this.account,
|
|
143
|
+
chain: config.chain,
|
|
144
|
+
transport,
|
|
145
|
+
});
|
|
146
|
+
this.publicClient = createPublicClient({
|
|
147
|
+
chain: config.chain,
|
|
148
|
+
transport,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
getAddress() {
|
|
152
|
+
return this.account.address;
|
|
153
|
+
}
|
|
154
|
+
/** Get native token balance (ETH, MATIC, etc.). */
|
|
155
|
+
async getNativeBalance() {
|
|
156
|
+
const balance = await this.publicClient.getBalance({
|
|
157
|
+
address: this.account.address,
|
|
158
|
+
});
|
|
159
|
+
return formatEther(balance);
|
|
160
|
+
}
|
|
161
|
+
/** Get USDC balance (6 decimals). Returns '0.00' if USDC not supported. */
|
|
162
|
+
async getUsdcBalance() {
|
|
163
|
+
const usdcAddress = this.chainConfig.usdc;
|
|
164
|
+
if (!usdcAddress)
|
|
165
|
+
return '0.00';
|
|
166
|
+
const balance = await this.publicClient.readContract({
|
|
167
|
+
address: usdcAddress,
|
|
168
|
+
abi: ERC20_ABI,
|
|
169
|
+
functionName: 'balanceOf',
|
|
170
|
+
args: [this.account.address],
|
|
171
|
+
});
|
|
172
|
+
return formatUnits(balance, 6);
|
|
173
|
+
}
|
|
174
|
+
async pay(destination, amount, network) {
|
|
175
|
+
if (this.asset === 'USDC') {
|
|
176
|
+
return this.payUsdc(destination, amount);
|
|
177
|
+
}
|
|
178
|
+
return this.payNative(destination, amount);
|
|
179
|
+
}
|
|
180
|
+
// ── Native token transfer ───────────────────────────────────────
|
|
181
|
+
async payNative(destination, amount) {
|
|
182
|
+
const tag = `[${this.chainName}/native]`;
|
|
183
|
+
try {
|
|
184
|
+
const amountWei = BigInt(amount);
|
|
185
|
+
const formatted = formatEther(amountWei);
|
|
186
|
+
this.log(`${tag} 🚀 ${formatted} → ${this.shortAddr(destination)}`);
|
|
187
|
+
const balance = await this.publicClient.getBalance({
|
|
188
|
+
address: this.account.address,
|
|
189
|
+
});
|
|
190
|
+
if (balance < amountWei) {
|
|
191
|
+
this.log(`${tag} ❌ Insufficient: ${formatEther(balance)} < ${formatted}`);
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const hash = await this.wallet.sendTransaction({
|
|
195
|
+
account: this.account,
|
|
196
|
+
to: destination,
|
|
197
|
+
value: amountWei,
|
|
198
|
+
chain: this.chainConfig.chain,
|
|
199
|
+
});
|
|
200
|
+
this.log(`${tag} ✅ ${hash}`);
|
|
201
|
+
return hash;
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
this.log(`${tag} ❌ ${error.message}`);
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// ── USDC ERC-20 transfer ────────────────────────────────────────
|
|
209
|
+
async payUsdc(destination, amount) {
|
|
210
|
+
const tag = `[${this.chainName}/USDC]`;
|
|
211
|
+
const usdcAddress = this.chainConfig.usdc;
|
|
212
|
+
try {
|
|
213
|
+
const amountAtomic = BigInt(amount);
|
|
214
|
+
const formatted = formatUnits(amountAtomic, 6);
|
|
215
|
+
this.log(`${tag} 🚀 ${formatted} USDC → ${this.shortAddr(destination)}`);
|
|
216
|
+
// Balance check
|
|
217
|
+
const balance = await this.publicClient.readContract({
|
|
218
|
+
address: usdcAddress,
|
|
219
|
+
abi: ERC20_ABI,
|
|
220
|
+
functionName: 'balanceOf',
|
|
221
|
+
args: [this.account.address],
|
|
222
|
+
});
|
|
223
|
+
if (balance < amountAtomic) {
|
|
224
|
+
this.log(`${tag} ❌ Insufficient: ${formatUnits(balance, 6)} < ${formatted} USDC`);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
const hash = await this.wallet.writeContract({
|
|
228
|
+
address: usdcAddress,
|
|
229
|
+
abi: ERC20_ABI,
|
|
230
|
+
functionName: 'transfer',
|
|
231
|
+
args: [destination, amountAtomic],
|
|
232
|
+
chain: this.chainConfig.chain,
|
|
233
|
+
account: this.account,
|
|
234
|
+
});
|
|
235
|
+
this.log(`${tag} ✅ ${hash}`);
|
|
236
|
+
return hash;
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
this.log(`${tag} ❌ ${error.message}`);
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
shortAddr(addr) {
|
|
244
|
+
return `${addr.slice(0, 8)}…${addr.slice(-6)}`;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// ─── Helper: list all supported chains ──────────────────────────────
|
|
248
|
+
/** Returns metadata for all supported EVM chains. */
|
|
249
|
+
export function listEvmChains() {
|
|
250
|
+
return Object.entries(CHAIN_REGISTRY).map(([name, config]) => ({
|
|
251
|
+
name: name,
|
|
252
|
+
displayName: config.displayName,
|
|
253
|
+
chainId: config.chain.id,
|
|
254
|
+
caip2Id: `eip155:${config.chain.id}`,
|
|
255
|
+
hasUsdc: config.usdc !== null,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=evm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../../src/adapters/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,IAAI,EACJ,WAAW,EACX,WAAW,GAIZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,eAAe,EACf,OAAO,IAAI,QAAQ,EACnB,OAAO,IAAI,eAAe,EAC1B,OAAO,EAC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AAE,MAAM,CAAC,WAAW;QAC/B,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,EAAE,UAAU,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;QACpC,OAAO,EAAE,MAAM,CAAC,IAAI,KAAK,IAAI;KAC9B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAmC,aAAa,EAAE,MAAM,OAAO,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAwB,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAsB,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAgC,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as StellarSdk from '@stellar/stellar-sdk';
|
|
2
|
+
import { noopLogger } from '../logger';
|
|
3
|
+
/** Circle's official USDC issuer on Stellar mainnet. */
|
|
4
|
+
const USDC_ISSUER = 'GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN';
|
|
5
|
+
/**
|
|
6
|
+
* StellarPaymentAdapter — On-chain settlement on the Stellar network.
|
|
7
|
+
*
|
|
8
|
+
* Supports:
|
|
9
|
+
* - Native XLM payments (testnet default)
|
|
10
|
+
* - Circle USDC payments (production recommended)
|
|
11
|
+
*
|
|
12
|
+
* The production ASG Pay stack settles USDC on Stellar mainnet.
|
|
13
|
+
* @see https://pay.asgcard.dev
|
|
14
|
+
* @see https://stellar.org/usdc
|
|
15
|
+
*/
|
|
16
|
+
export class StellarPaymentAdapter {
|
|
17
|
+
chainName = 'Stellar';
|
|
18
|
+
caip2Id;
|
|
19
|
+
keypair;
|
|
20
|
+
server;
|
|
21
|
+
networkPassphrase;
|
|
22
|
+
assetType;
|
|
23
|
+
log;
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.keypair = StellarSdk.Keypair.fromSecret(options.secretKey);
|
|
26
|
+
this.log = options.logger ?? noopLogger;
|
|
27
|
+
this.assetType = options.asset ?? 'XLM';
|
|
28
|
+
const isMainnet = options.network === 'mainnet';
|
|
29
|
+
this.networkPassphrase = isMainnet
|
|
30
|
+
? StellarSdk.Networks.PUBLIC
|
|
31
|
+
: StellarSdk.Networks.TESTNET;
|
|
32
|
+
this.caip2Id = isMainnet ? 'stellar:pubnet' : 'stellar:testnet';
|
|
33
|
+
this.server = new StellarSdk.Horizon.Server(options.horizonUrl ??
|
|
34
|
+
(isMainnet
|
|
35
|
+
? 'https://horizon.stellar.org'
|
|
36
|
+
: 'https://horizon-testnet.stellar.org'));
|
|
37
|
+
}
|
|
38
|
+
getAddress() {
|
|
39
|
+
return this.keypair.publicKey();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get the Stellar asset object based on configuration.
|
|
43
|
+
* - XLM: native asset (no trustline needed)
|
|
44
|
+
* - USDC: Circle's issued USDC (trustline required)
|
|
45
|
+
*/
|
|
46
|
+
getAsset() {
|
|
47
|
+
if (this.assetType === 'USDC') {
|
|
48
|
+
return new StellarSdk.Asset('USDC', USDC_ISSUER);
|
|
49
|
+
}
|
|
50
|
+
return StellarSdk.Asset.native();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Convert atomic units to human-readable amount.
|
|
54
|
+
* Stellar uses 7 decimal places (stroops) for all assets.
|
|
55
|
+
*/
|
|
56
|
+
formatAmount(stroops) {
|
|
57
|
+
return (parseInt(stroops, 10) / 1e7).toFixed(7);
|
|
58
|
+
}
|
|
59
|
+
async pay(destination, amount, network) {
|
|
60
|
+
try {
|
|
61
|
+
const asset = this.getAsset();
|
|
62
|
+
const humanAmount = this.formatAmount(amount);
|
|
63
|
+
const assetLabel = this.assetType === 'USDC' ? 'USDC' : 'XLM';
|
|
64
|
+
this.log(`[Stellar/${assetLabel}] 🚀 ${humanAmount} → ${destination.slice(0, 10)}…`);
|
|
65
|
+
const sourceAccount = await this.server.loadAccount(this.keypair.publicKey());
|
|
66
|
+
const tx = new StellarSdk.TransactionBuilder(sourceAccount, {
|
|
67
|
+
fee: StellarSdk.BASE_FEE,
|
|
68
|
+
networkPassphrase: this.networkPassphrase,
|
|
69
|
+
})
|
|
70
|
+
.addOperation(StellarSdk.Operation.payment({
|
|
71
|
+
destination,
|
|
72
|
+
asset,
|
|
73
|
+
amount: humanAmount,
|
|
74
|
+
}))
|
|
75
|
+
.setTimeout(30)
|
|
76
|
+
.build();
|
|
77
|
+
tx.sign(this.keypair);
|
|
78
|
+
this.log(`[Stellar/${assetLabel}] 📡 Submitting…`);
|
|
79
|
+
const response = await this.server.submitTransaction(tx);
|
|
80
|
+
this.log(`[Stellar/${assetLabel}] ✅ ${response.hash}`);
|
|
81
|
+
return response.hash;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const detail = error?.response?.data?.extras?.result_codes || error.message;
|
|
85
|
+
this.log(`[Stellar] ❌ ${JSON.stringify(detail)}`);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if the account has a USDC trustline.
|
|
91
|
+
* Returns false if using XLM or if the trustline exists.
|
|
92
|
+
* Returns true if USDC is selected but trustline is missing.
|
|
93
|
+
*/
|
|
94
|
+
async needsTrustline() {
|
|
95
|
+
if (this.assetType !== 'USDC')
|
|
96
|
+
return false;
|
|
97
|
+
try {
|
|
98
|
+
const account = await this.server.loadAccount(this.keypair.publicKey());
|
|
99
|
+
const hasTrustline = account.balances.some((b) => b.asset_type !== 'native' &&
|
|
100
|
+
b.asset_code === 'USDC' &&
|
|
101
|
+
b.asset_issuer === USDC_ISSUER);
|
|
102
|
+
return !hasTrustline;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Establish a USDC trustline (required before receiving USDC).
|
|
110
|
+
* Only needed once per account.
|
|
111
|
+
*/
|
|
112
|
+
async createUsdcTrustline() {
|
|
113
|
+
try {
|
|
114
|
+
this.log('[Stellar/USDC] 🔗 Creating USDC trustline…');
|
|
115
|
+
const sourceAccount = await this.server.loadAccount(this.keypair.publicKey());
|
|
116
|
+
const tx = new StellarSdk.TransactionBuilder(sourceAccount, {
|
|
117
|
+
fee: StellarSdk.BASE_FEE,
|
|
118
|
+
networkPassphrase: this.networkPassphrase,
|
|
119
|
+
})
|
|
120
|
+
.addOperation(StellarSdk.Operation.changeTrust({
|
|
121
|
+
asset: new StellarSdk.Asset('USDC', USDC_ISSUER),
|
|
122
|
+
}))
|
|
123
|
+
.setTimeout(30)
|
|
124
|
+
.build();
|
|
125
|
+
tx.sign(this.keypair);
|
|
126
|
+
const response = await this.server.submitTransaction(tx);
|
|
127
|
+
this.log(`[Stellar/USDC] ✅ Trustline created: ${response.hash}`);
|
|
128
|
+
return response.hash;
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
this.log(`[Stellar/USDC] ❌ Trustline failed: ${error.message}`);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=stellar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stellar.js","sourceRoot":"","sources":["../../../src/adapters/stellar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAE/C,wDAAwD;AACxD,MAAM,WAAW,GAAG,0DAA0D,CAAC;AAsB/E;;;;;;;;;;GAUG;AACH,MAAM,OAAO,qBAAqB;IAChB,SAAS,GAAG,SAAS,CAAC;IACtB,OAAO,CAAS;IAExB,OAAO,CAAqB;IAC5B,MAAM,CAA4B;IAClC,iBAAi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