@cosmosapp/pay_sdk 2.2.1 → 2.3.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 +17 -0
- package/README.md +61 -3
- package/dist/{chunk-OVFDKC5Z.js → chunk-B3HT6MCO.js} +3 -3
- package/dist/{chunk-OVFDKC5Z.js.map → chunk-B3HT6MCO.js.map} +1 -1
- package/dist/index.cjs +413 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +292 -10
- package/dist/index.d.ts +292 -10
- package/dist/index.js +409 -13
- package/dist/index.js.map +1 -1
- package/dist/{intent-input-GiCgpAWR.d.cts → intent-input-CP5bkBYI.d.cts} +659 -5
- package/dist/{intent-input-GiCgpAWR.d.ts → intent-input-CP5bkBYI.d.ts} +659 -5
- package/dist/web/index.cjs +1 -1
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.d.cts +2 -2
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +2 -2
- package/llms/04-client.md +5 -3
- package/llms/07-webhooks.md +19 -3
- package/llms/08-products-customers.md +31 -4
- package/llms/09-analytics-health.md +31 -0
- package/llms/13-types-reference.md +26 -3
- package/llms/16-private-payments.md +77 -0
- package/llms/17-usdt0.md +82 -0
- package/llms/README.md +3 -2
- package/llms/llms-full.txt +277 -13
- package/llms/llms.txt +4 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { version, DEFAULT_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_RETRIES, Events, CosmosPayAPIError, CosmosPayRequestError, resolveIntentBody, SIGNATURE_HEADER } from './chunk-
|
|
2
|
-
export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, DEFAULT_BASE_URL, DEFAULT_RETRIES, DEFAULT_TIMEOUT, DEFAULT_VERSION, Events, SIGNATURE_HEADER, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody, version } from './chunk-
|
|
1
|
+
import { version, DEFAULT_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_RETRIES, Events, CosmosPayAPIError, CosmosPayRequestError, resolveIntentBody, SIGNATURE_HEADER } from './chunk-B3HT6MCO.js';
|
|
2
|
+
export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, DEFAULT_BASE_URL, DEFAULT_RETRIES, DEFAULT_TIMEOUT, DEFAULT_VERSION, Events, SIGNATURE_HEADER, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody, version } from './chunk-B3HT6MCO.js';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
5
5
|
|
|
@@ -93,6 +93,17 @@ var AnalyticsManager = class {
|
|
|
93
93
|
summary() {
|
|
94
94
|
return this.rest.get("/summary");
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Activity per day, week, month or year, with the window before for growth:
|
|
98
|
+
* payments (with their settled volume in USD), swaps of every kind, liquidity
|
|
99
|
+
* operations, webhook deliveries and private payments, each in the UTC
|
|
100
|
+
* buckets of `period` (`day` when omitted).
|
|
101
|
+
*/
|
|
102
|
+
series(options = {}) {
|
|
103
|
+
return this.rest.get("/summary/series", {
|
|
104
|
+
query: { period: options.period }
|
|
105
|
+
});
|
|
106
|
+
}
|
|
96
107
|
/** Settled (and pending) amount per asset. */
|
|
97
108
|
balances() {
|
|
98
109
|
return this.rest.get("/balances");
|
|
@@ -124,6 +135,17 @@ var AssetManager = class {
|
|
|
124
135
|
}
|
|
125
136
|
};
|
|
126
137
|
|
|
138
|
+
// src/util/path.ts
|
|
139
|
+
function pathSegment(value) {
|
|
140
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
141
|
+
throw new TypeError("A path segment must be a non-empty string.");
|
|
142
|
+
}
|
|
143
|
+
if (value === "." || value === "..") {
|
|
144
|
+
throw new TypeError(`"${value}" is not a valid id.`);
|
|
145
|
+
}
|
|
146
|
+
return encodeURIComponent(value);
|
|
147
|
+
}
|
|
148
|
+
|
|
127
149
|
// src/structures/Base.ts
|
|
128
150
|
var Base = class {
|
|
129
151
|
constructor(client, data) {
|
|
@@ -145,12 +167,6 @@ var Base = class {
|
|
|
145
167
|
var Customer = class extends Base {
|
|
146
168
|
constructor(client, data) {
|
|
147
169
|
super(client, data);
|
|
148
|
-
/** Number of payment intents from this customer's account (list view only). */
|
|
149
|
-
this.payments = null;
|
|
150
|
-
/** Number of succeeded payments (list view only). */
|
|
151
|
-
this.succeeded = null;
|
|
152
|
-
/** Total settled amount as a decimal string (list view only). */
|
|
153
|
-
this.total = null;
|
|
154
170
|
}
|
|
155
171
|
_patch(data) {
|
|
156
172
|
super._patch(data);
|
|
@@ -158,13 +174,14 @@ var Customer = class extends Base {
|
|
|
158
174
|
this.alias = data.alias;
|
|
159
175
|
this.note = data.note;
|
|
160
176
|
this.email = data.email;
|
|
177
|
+
this.wallets = data.wallets ?? [];
|
|
161
178
|
this.account = data.account;
|
|
162
179
|
this.reference = data.reference;
|
|
163
180
|
this.createdAt = new Date(data.createdAt);
|
|
164
181
|
this.updatedAt = new Date(data.updatedAt);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
182
|
+
this.payments = data.payments ?? this.payments ?? null;
|
|
183
|
+
this.succeeded = data.succeeded ?? this.succeeded ?? null;
|
|
184
|
+
this.total = data.total ?? this.total ?? null;
|
|
168
185
|
return this;
|
|
169
186
|
}
|
|
170
187
|
/** Re-fetch this customer. */
|
|
@@ -180,6 +197,29 @@ var Customer = class extends Base {
|
|
|
180
197
|
delete() {
|
|
181
198
|
return this.client.customers.delete(this.id);
|
|
182
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Add a wallet to this customer and to {@link Customer.wallets}. A wallet the
|
|
202
|
+
* customer already holds answers as it is.
|
|
203
|
+
*/
|
|
204
|
+
async addWallet(options) {
|
|
205
|
+
const wallet = await this.client.customers.addWallet(this.id, options);
|
|
206
|
+
const at = this.wallets.findIndex((w) => w.id === wallet.id);
|
|
207
|
+
this.wallets = at === -1 ? [...this.wallets, wallet] : this.wallets.map((w, i) => i === at ? wallet : w);
|
|
208
|
+
this.syncAccount();
|
|
209
|
+
return wallet;
|
|
210
|
+
}
|
|
211
|
+
/** Remove one of this customer's wallets, by id or as read from {@link Customer.wallets}. */
|
|
212
|
+
async removeWallet(wallet) {
|
|
213
|
+
const walletId = typeof wallet === "string" ? wallet : wallet.id;
|
|
214
|
+
const result = await this.client.customers.removeWallet(this.id, walletId);
|
|
215
|
+
this.wallets = this.wallets.filter((w) => w.id !== walletId);
|
|
216
|
+
this.syncAccount();
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
/** `account` is the first wallet's address, as the API derives it. */
|
|
220
|
+
syncAccount() {
|
|
221
|
+
this.account = this.wallets[0]?.address ?? null;
|
|
222
|
+
}
|
|
183
223
|
toJSON() {
|
|
184
224
|
return {
|
|
185
225
|
id: this.id,
|
|
@@ -187,6 +227,7 @@ var Customer = class extends Base {
|
|
|
187
227
|
alias: this.alias,
|
|
188
228
|
note: this.note,
|
|
189
229
|
email: this.email,
|
|
230
|
+
wallets: this.wallets,
|
|
190
231
|
account: this.account,
|
|
191
232
|
reference: this.reference,
|
|
192
233
|
createdAt: this.createdAt.toISOString(),
|
|
@@ -255,6 +296,27 @@ var CustomerManager = class extends BaseManager {
|
|
|
255
296
|
this.cache.delete(id);
|
|
256
297
|
return result;
|
|
257
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Add a wallet to a customer, on Stellar, Solana or Monad (up to 20 per
|
|
301
|
+
* customer); payments paid from it count toward the customer. A wallet the
|
|
302
|
+
* customer already holds answers as it is; one another of your customers holds
|
|
303
|
+
* is `409 customer_wallet_taken`.
|
|
304
|
+
*/
|
|
305
|
+
async addWallet(customerId, options) {
|
|
306
|
+
return this.rest.post(`${this.route}/${pathSegment(customerId)}/wallets`, {
|
|
307
|
+
body: options
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Remove a wallet from a customer. Payments from that address stop counting
|
|
312
|
+
* toward it, and a later settled payment from it adds it as a new automatic
|
|
313
|
+
* customer. A `walletId` that is not one of this customer's wallets is 404.
|
|
314
|
+
*/
|
|
315
|
+
async removeWallet(customerId, walletId) {
|
|
316
|
+
return this.rest.delete(
|
|
317
|
+
`${this.route}/${pathSegment(customerId)}/wallets/${pathSegment(walletId)}`
|
|
318
|
+
);
|
|
319
|
+
}
|
|
258
320
|
};
|
|
259
321
|
|
|
260
322
|
// src/managers/HealthManager.ts
|
|
@@ -311,18 +373,22 @@ var WebhookEventType = {
|
|
|
311
373
|
SwapSubmitted: "SWAP_SUBMITTED",
|
|
312
374
|
SwapSucceeded: "SWAP_SUCCEEDED",
|
|
313
375
|
SwapFailed: "SWAP_FAILED",
|
|
376
|
+
SwapExpired: "SWAP_EXPIRED",
|
|
314
377
|
// Liquidity pool operations.
|
|
315
378
|
LiquidityCreated: "LIQUIDITY_CREATED",
|
|
316
379
|
LiquiditySubmitted: "LIQUIDITY_SUBMITTED",
|
|
317
380
|
LiquiditySucceeded: "LIQUIDITY_SUCCEEDED",
|
|
318
381
|
LiquidityFailed: "LIQUIDITY_FAILED",
|
|
382
|
+
LiquidityExpired: "LIQUIDITY_EXPIRED",
|
|
319
383
|
// Cross-chain swaps (NEAR Intents).
|
|
320
384
|
CrossChainSwapCreated: "CROSS_CHAIN_SWAP_CREATED",
|
|
321
385
|
CrossChainSwapUpdated: "CROSS_CHAIN_SWAP_UPDATED",
|
|
322
386
|
CrossChainSwapSucceeded: "CROSS_CHAIN_SWAP_SUCCEEDED",
|
|
323
387
|
CrossChainSwapRefunded: "CROSS_CHAIN_SWAP_REFUNDED",
|
|
324
388
|
CrossChainSwapFailed: "CROSS_CHAIN_SWAP_FAILED",
|
|
325
|
-
CrossChainSwapExpired: "CROSS_CHAIN_SWAP_EXPIRED"
|
|
389
|
+
CrossChainSwapExpired: "CROSS_CHAIN_SWAP_EXPIRED",
|
|
390
|
+
// Private payments (client.privatePayments).
|
|
391
|
+
PrivatePaymentSucceeded: "ZK_PAYMENT_SUCCEEDED"
|
|
326
392
|
};
|
|
327
393
|
var WebhookDeliveryStatus = {
|
|
328
394
|
Pending: "PENDING",
|
|
@@ -356,6 +422,23 @@ var CrossChainSwapStatus = {
|
|
|
356
422
|
Failed: "FAILED",
|
|
357
423
|
Expired: "EXPIRED"
|
|
358
424
|
};
|
|
425
|
+
var PrivatePaymentStatus = {
|
|
426
|
+
Pending: "PENDING",
|
|
427
|
+
Succeeded: "SUCCEEDED",
|
|
428
|
+
Expired: "EXPIRED"
|
|
429
|
+
};
|
|
430
|
+
var Usdt0TransferStatus = {
|
|
431
|
+
/** Built, waiting for the signature. */
|
|
432
|
+
Pending: "PENDING",
|
|
433
|
+
/** On the Stellar ledger; LayerZero is delivering it. */
|
|
434
|
+
Submitted: "SUBMITTED",
|
|
435
|
+
/** Credited on the destination network. */
|
|
436
|
+
Delivered: "DELIVERED",
|
|
437
|
+
/** The Stellar transaction failed, or LayerZero gave up on the message. */
|
|
438
|
+
Failed: "FAILED",
|
|
439
|
+
/** Never reached the ledger before `expiresAt`. */
|
|
440
|
+
Expired: "EXPIRED"
|
|
441
|
+
};
|
|
359
442
|
|
|
360
443
|
// src/structures/LiquidityOperation.ts
|
|
361
444
|
var LiquidityOperation = class extends Base {
|
|
@@ -1422,6 +1505,125 @@ var PaymentIntentManager = class extends BaseManager {
|
|
|
1422
1505
|
}
|
|
1423
1506
|
};
|
|
1424
1507
|
|
|
1508
|
+
// src/structures/PrivatePayment.ts
|
|
1509
|
+
var PrivatePayment = class extends Base {
|
|
1510
|
+
constructor(client, data) {
|
|
1511
|
+
super(client, data);
|
|
1512
|
+
}
|
|
1513
|
+
_patch(data) {
|
|
1514
|
+
super._patch(data);
|
|
1515
|
+
this.status = data.status;
|
|
1516
|
+
this.network = data.network;
|
|
1517
|
+
this.tokenContract = data.tokenContract;
|
|
1518
|
+
this.amount = data.amount;
|
|
1519
|
+
this.netAmount = data.netAmount;
|
|
1520
|
+
this.feeAmount = data.feeAmount;
|
|
1521
|
+
this.feeBps = data.feeBps;
|
|
1522
|
+
this.recipient = data.recipient;
|
|
1523
|
+
this.feeAccount = data.feeAccount;
|
|
1524
|
+
this.payer = data.payer;
|
|
1525
|
+
this.paymentTxHash = data.paymentTxHash;
|
|
1526
|
+
this.feeTxHash = data.feeTxHash;
|
|
1527
|
+
this.merchantFee = data.merchantFee;
|
|
1528
|
+
this.merchantFeeTxHash = data.merchantFeeTxHash;
|
|
1529
|
+
this.description = data.description;
|
|
1530
|
+
this.idempotencyKey = data.idempotencyKey;
|
|
1531
|
+
this.expiresAt = new Date(data.expiresAt);
|
|
1532
|
+
this.settledAt = data.settledAt ? new Date(data.settledAt) : null;
|
|
1533
|
+
this.createdAt = new Date(data.createdAt);
|
|
1534
|
+
this.updatedAt = new Date(data.updatedAt);
|
|
1535
|
+
return this;
|
|
1536
|
+
}
|
|
1537
|
+
/** Whether the payment is still waiting for its transfers. */
|
|
1538
|
+
get isPending() {
|
|
1539
|
+
return this.status === PrivatePaymentStatus.Pending;
|
|
1540
|
+
}
|
|
1541
|
+
/** Whether every transfer has been confirmed. */
|
|
1542
|
+
get isSucceeded() {
|
|
1543
|
+
return this.status === PrivatePaymentStatus.Succeeded;
|
|
1544
|
+
}
|
|
1545
|
+
/** Whether it passed {@link expiresAt} without settling (it can still settle with transfers that closed in time). */
|
|
1546
|
+
get isExpired() {
|
|
1547
|
+
return this.status === PrivatePaymentStatus.Expired;
|
|
1548
|
+
}
|
|
1549
|
+
/** Re-fetch from the API, updating this instance in place. */
|
|
1550
|
+
async fetch() {
|
|
1551
|
+
const fresh = await this.client.privatePayments.fetch(this.id);
|
|
1552
|
+
return this._patch(fresh.toJSON());
|
|
1553
|
+
}
|
|
1554
|
+
toJSON() {
|
|
1555
|
+
return {
|
|
1556
|
+
id: this.id,
|
|
1557
|
+
status: this.status,
|
|
1558
|
+
network: this.network,
|
|
1559
|
+
tokenContract: this.tokenContract,
|
|
1560
|
+
amount: this.amount,
|
|
1561
|
+
netAmount: this.netAmount,
|
|
1562
|
+
feeAmount: this.feeAmount,
|
|
1563
|
+
feeBps: this.feeBps,
|
|
1564
|
+
recipient: this.recipient,
|
|
1565
|
+
feeAccount: this.feeAccount,
|
|
1566
|
+
payer: this.payer,
|
|
1567
|
+
paymentTxHash: this.paymentTxHash,
|
|
1568
|
+
feeTxHash: this.feeTxHash,
|
|
1569
|
+
merchantFee: this.merchantFee,
|
|
1570
|
+
merchantFeeTxHash: this.merchantFeeTxHash,
|
|
1571
|
+
description: this.description,
|
|
1572
|
+
idempotencyKey: this.idempotencyKey,
|
|
1573
|
+
expiresAt: this.expiresAt.toISOString(),
|
|
1574
|
+
settledAt: this.settledAt ? this.settledAt.toISOString() : null,
|
|
1575
|
+
createdAt: this.createdAt.toISOString(),
|
|
1576
|
+
updatedAt: this.updatedAt.toISOString()
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1581
|
+
// src/managers/PrivatePaymentManager.ts
|
|
1582
|
+
var PrivatePaymentManager = class extends BaseManager {
|
|
1583
|
+
constructor() {
|
|
1584
|
+
super(...arguments);
|
|
1585
|
+
this.route = "/zk-payments";
|
|
1586
|
+
}
|
|
1587
|
+
/**
|
|
1588
|
+
* Create a private payment. The server prices it (`amount` = `netAmount` +
|
|
1589
|
+
* `feeAmount`) and checks on-chain that the recipient holds a confidential
|
|
1590
|
+
* account on the token, refusing it with `recipient_not_registered` otherwise.
|
|
1591
|
+
*/
|
|
1592
|
+
async create(options) {
|
|
1593
|
+
const { idempotencyKey, ...body } = options;
|
|
1594
|
+
const data = await this.rest.post(this.route, {
|
|
1595
|
+
body: { ...body, ...idempotencyKey ? { idempotencyKey } : {} },
|
|
1596
|
+
...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
|
|
1597
|
+
});
|
|
1598
|
+
return this._add(new PrivatePayment(this.client, data));
|
|
1599
|
+
}
|
|
1600
|
+
/** List the private payments on the key's network, newest first. */
|
|
1601
|
+
async list(options = {}) {
|
|
1602
|
+
const data = await this.rest.get(this.route, {
|
|
1603
|
+
query: { status: options.status, take: options.take, skip: options.skip }
|
|
1604
|
+
});
|
|
1605
|
+
return {
|
|
1606
|
+
items: data.data.map((d) => this._add(new PrivatePayment(this.client, d))),
|
|
1607
|
+
total: data.total,
|
|
1608
|
+
take: data.take,
|
|
1609
|
+
skip: data.skip
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
/** Get one of your private payments, with the transfers that settled it. */
|
|
1613
|
+
async fetch(id) {
|
|
1614
|
+
const data = await this.rest.get(`${this.route}/${pathSegment(id)}`);
|
|
1615
|
+
return this._add(new PrivatePayment(this.client, data));
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* The private payments setup of the key's network: the token, registries,
|
|
1619
|
+
* auditor id, commission and fee account a wallet registers and pays against.
|
|
1620
|
+
* `enabled` is false where private payments do not run yet.
|
|
1621
|
+
*/
|
|
1622
|
+
config() {
|
|
1623
|
+
return this.rest.get(`${this.route}/config`);
|
|
1624
|
+
}
|
|
1625
|
+
};
|
|
1626
|
+
|
|
1425
1627
|
// src/structures/Product.ts
|
|
1426
1628
|
var Product = class extends Base {
|
|
1427
1629
|
constructor(client, data) {
|
|
@@ -1777,6 +1979,198 @@ var SwapManager = class extends BaseManager {
|
|
|
1777
1979
|
}
|
|
1778
1980
|
};
|
|
1779
1981
|
|
|
1982
|
+
// src/structures/Usdt0Transfer.ts
|
|
1983
|
+
var FINAL2 = [
|
|
1984
|
+
Usdt0TransferStatus.Delivered,
|
|
1985
|
+
Usdt0TransferStatus.Failed,
|
|
1986
|
+
Usdt0TransferStatus.Expired
|
|
1987
|
+
];
|
|
1988
|
+
var Usdt0Transfer = class extends Base {
|
|
1989
|
+
constructor(client, data) {
|
|
1990
|
+
super(client, data);
|
|
1991
|
+
}
|
|
1992
|
+
_patch(data) {
|
|
1993
|
+
super._patch(data);
|
|
1994
|
+
this.status = data.status;
|
|
1995
|
+
this.network = data.network;
|
|
1996
|
+
this.source = data.source;
|
|
1997
|
+
this.to = data.to;
|
|
1998
|
+
this.eid = data.eid;
|
|
1999
|
+
this.receives = data.receives;
|
|
2000
|
+
this.recipient = data.recipient;
|
|
2001
|
+
this.amount = data.amount;
|
|
2002
|
+
this.amountSent = data.amountSent;
|
|
2003
|
+
this.amountReceived = data.amountReceived;
|
|
2004
|
+
this.dust = data.dust;
|
|
2005
|
+
this.nativeFee = data.nativeFee;
|
|
2006
|
+
this.nativeFeeLimit = data.nativeFeeLimit;
|
|
2007
|
+
this.networkFee = data.networkFee;
|
|
2008
|
+
this.feeBps = data.feeBps;
|
|
2009
|
+
this.feeAmount = data.feeAmount;
|
|
2010
|
+
this.feeWallet = data.feeWallet;
|
|
2011
|
+
this.xdr = data.xdr;
|
|
2012
|
+
this.uri = data.uri;
|
|
2013
|
+
this.qr = data.qr ?? null;
|
|
2014
|
+
this.txHash = data.txHash;
|
|
2015
|
+
this.guid = data.guid;
|
|
2016
|
+
this.destinationTxHash = data.destinationTxHash;
|
|
2017
|
+
this.scanStatus = data.scanStatus;
|
|
2018
|
+
this.scanUrl = data.scanUrl;
|
|
2019
|
+
this.failureReason = data.failureReason;
|
|
2020
|
+
this.merchantFee = data.merchantFee;
|
|
2021
|
+
this.idempotencyKey = data.idempotencyKey;
|
|
2022
|
+
this.expiresAt = new Date(data.expiresAt);
|
|
2023
|
+
this.submittedAt = data.submittedAt ? new Date(data.submittedAt) : null;
|
|
2024
|
+
this.createdAt = new Date(data.createdAt);
|
|
2025
|
+
this.updatedAt = new Date(data.updatedAt);
|
|
2026
|
+
this.publicToken = data.publicToken ?? this.publicToken ?? null;
|
|
2027
|
+
return this;
|
|
2028
|
+
}
|
|
2029
|
+
/** Whether the transfer is still waiting for its signature. */
|
|
2030
|
+
get isPending() {
|
|
2031
|
+
return this.status === Usdt0TransferStatus.Pending;
|
|
2032
|
+
}
|
|
2033
|
+
/** Whether it was credited on the destination network. */
|
|
2034
|
+
get isDelivered() {
|
|
2035
|
+
return this.status === Usdt0TransferStatus.Delivered;
|
|
2036
|
+
}
|
|
2037
|
+
/** Whether it reached an outcome that will not change (DELIVERED, FAILED or EXPIRED). */
|
|
2038
|
+
get isFinal() {
|
|
2039
|
+
return FINAL2.includes(this.status);
|
|
2040
|
+
}
|
|
2041
|
+
/** Re-read it (the API refreshes it from the ledger and LayerZero Scan), updating this instance in place. */
|
|
2042
|
+
async fetch() {
|
|
2043
|
+
const fresh = await this.client.usdt0.fetch(this.id, this.recordToken());
|
|
2044
|
+
return this._patch(fresh.toJSON());
|
|
2045
|
+
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Relay the signed transaction. Mutates this instance from the transfer in the
|
|
2048
|
+
* outcome and returns the outcome.
|
|
2049
|
+
*/
|
|
2050
|
+
async submit(options) {
|
|
2051
|
+
const outcome = await this.client.usdt0.submit(this.id, {
|
|
2052
|
+
signedXdr: options.signedXdr,
|
|
2053
|
+
...this.recordToken()
|
|
2054
|
+
});
|
|
2055
|
+
this._patch(outcome.transfer.toJSON());
|
|
2056
|
+
return outcome;
|
|
2057
|
+
}
|
|
2058
|
+
recordToken() {
|
|
2059
|
+
return this.publicToken ? { recordToken: this.publicToken } : {};
|
|
2060
|
+
}
|
|
2061
|
+
toJSON() {
|
|
2062
|
+
return {
|
|
2063
|
+
id: this.id,
|
|
2064
|
+
status: this.status,
|
|
2065
|
+
network: this.network,
|
|
2066
|
+
source: this.source,
|
|
2067
|
+
to: this.to,
|
|
2068
|
+
eid: this.eid,
|
|
2069
|
+
receives: this.receives,
|
|
2070
|
+
recipient: this.recipient,
|
|
2071
|
+
amount: this.amount,
|
|
2072
|
+
amountSent: this.amountSent,
|
|
2073
|
+
amountReceived: this.amountReceived,
|
|
2074
|
+
dust: this.dust,
|
|
2075
|
+
nativeFee: this.nativeFee,
|
|
2076
|
+
nativeFeeLimit: this.nativeFeeLimit,
|
|
2077
|
+
networkFee: this.networkFee,
|
|
2078
|
+
feeBps: this.feeBps,
|
|
2079
|
+
feeAmount: this.feeAmount,
|
|
2080
|
+
feeWallet: this.feeWallet,
|
|
2081
|
+
xdr: this.xdr,
|
|
2082
|
+
uri: this.uri,
|
|
2083
|
+
qr: this.qr,
|
|
2084
|
+
txHash: this.txHash,
|
|
2085
|
+
guid: this.guid,
|
|
2086
|
+
destinationTxHash: this.destinationTxHash,
|
|
2087
|
+
scanStatus: this.scanStatus,
|
|
2088
|
+
scanUrl: this.scanUrl,
|
|
2089
|
+
failureReason: this.failureReason,
|
|
2090
|
+
merchantFee: this.merchantFee,
|
|
2091
|
+
idempotencyKey: this.idempotencyKey,
|
|
2092
|
+
expiresAt: this.expiresAt.toISOString(),
|
|
2093
|
+
submittedAt: this.submittedAt ? this.submittedAt.toISOString() : null,
|
|
2094
|
+
createdAt: this.createdAt.toISOString(),
|
|
2095
|
+
updatedAt: this.updatedAt.toISOString(),
|
|
2096
|
+
...this.publicToken ? { publicToken: this.publicToken } : {}
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
2099
|
+
};
|
|
2100
|
+
|
|
2101
|
+
// src/managers/Usdt0Manager.ts
|
|
2102
|
+
function recordTokenHeader(recordToken) {
|
|
2103
|
+
return recordToken ? { headers: { "X-Record-Token": recordToken } } : {};
|
|
2104
|
+
}
|
|
2105
|
+
var Usdt0Manager = class extends BaseManager {
|
|
2106
|
+
constructor() {
|
|
2107
|
+
super(...arguments);
|
|
2108
|
+
this.route = "/usdt0";
|
|
2109
|
+
}
|
|
2110
|
+
/** The networks USDT0 can be sent to from Stellar, with the token and OFT a transfer uses. */
|
|
2111
|
+
routes() {
|
|
2112
|
+
return this.rest.get(`${this.route}/routes`);
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Price a transfer: what is sent and arrives, the dust, LayerZero's fee and the
|
|
2116
|
+
* OFT's limits. Persists nothing.
|
|
2117
|
+
*/
|
|
2118
|
+
quote(options) {
|
|
2119
|
+
return this.rest.post(`${this.route}/quote`, { body: options });
|
|
2120
|
+
}
|
|
2121
|
+
/** Build a transfer: the one unsigned Soroban transaction the holder signs (XDR and SEP-7 link). */
|
|
2122
|
+
async create(options) {
|
|
2123
|
+
const { idempotencyKey, ...body } = options;
|
|
2124
|
+
const data = await this.rest.post(`${this.route}/transfers`, {
|
|
2125
|
+
body: { ...body, ...idempotencyKey ? { idempotencyKey } : {} },
|
|
2126
|
+
...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
|
|
2127
|
+
});
|
|
2128
|
+
return this._add(new Usdt0Transfer(this.client, data));
|
|
2129
|
+
}
|
|
2130
|
+
/** List your transfers, newest first, as last refreshed (fetch one to refresh it). */
|
|
2131
|
+
async list(options = {}) {
|
|
2132
|
+
const data = await this.rest.get(`${this.route}/transfers`, {
|
|
2133
|
+
query: { status: options.status, take: options.take, skip: options.skip }
|
|
2134
|
+
});
|
|
2135
|
+
return {
|
|
2136
|
+
items: data.data.map((d) => this._add(new Usdt0Transfer(this.client, d))),
|
|
2137
|
+
total: data.total,
|
|
2138
|
+
take: data.take,
|
|
2139
|
+
skip: data.skip
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
/**
|
|
2143
|
+
* Get one transfer. While PENDING or SUBMITTED the API refreshes it from the
|
|
2144
|
+
* Stellar ledger and LayerZero Scan (at most every 15 seconds).
|
|
2145
|
+
*/
|
|
2146
|
+
async fetch(id, options = {}) {
|
|
2147
|
+
const data = await this.rest.get(
|
|
2148
|
+
`${this.route}/transfers/${pathSegment(id)}`,
|
|
2149
|
+
recordTokenHeader(options.recordToken)
|
|
2150
|
+
);
|
|
2151
|
+
return this._add(new Usdt0Transfer(this.client, data));
|
|
2152
|
+
}
|
|
2153
|
+
/**
|
|
2154
|
+
* Relay the signed transaction to Stellar mainnet. It must be the transaction
|
|
2155
|
+
* the API built for this transfer, signed. A refusal by the network leaves it
|
|
2156
|
+
* PENDING (`submitted: false`, `reason`) to submit again until it expires.
|
|
2157
|
+
*/
|
|
2158
|
+
async submit(id, options) {
|
|
2159
|
+
const { recordToken, ...body } = options;
|
|
2160
|
+
const data = await this.rest.post(
|
|
2161
|
+
`${this.route}/transfers/${pathSegment(id)}/submit`,
|
|
2162
|
+
{ body, ...recordTokenHeader(recordToken) }
|
|
2163
|
+
);
|
|
2164
|
+
return {
|
|
2165
|
+
submitted: data.submitted,
|
|
2166
|
+
status: data.status,
|
|
2167
|
+
txHash: data.txHash ?? null,
|
|
2168
|
+
reason: data.reason ?? null,
|
|
2169
|
+
transfer: this._add(new Usdt0Transfer(this.client, data.transfer))
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
};
|
|
2173
|
+
|
|
1780
2174
|
// src/structures/WebhookDelivery.ts
|
|
1781
2175
|
var WebhookDelivery = class extends Base {
|
|
1782
2176
|
constructor(client, data) {
|
|
@@ -2379,6 +2773,8 @@ var Client = class extends EventEmitter {
|
|
|
2379
2773
|
this.products = new ProductManager(this);
|
|
2380
2774
|
this.swaps = new SwapManager(this);
|
|
2381
2775
|
this.crossChainSwaps = new CrossChainSwapManager(this);
|
|
2776
|
+
this.usdt0 = new Usdt0Manager(this);
|
|
2777
|
+
this.privatePayments = new PrivatePaymentManager(this);
|
|
2382
2778
|
this.liquidity = new LiquidityManager(this);
|
|
2383
2779
|
this.onramp = new OnrampManager(this);
|
|
2384
2780
|
this.offramp = new OfframpManager(this);
|
|
@@ -2410,6 +2806,6 @@ var Client = class extends EventEmitter {
|
|
|
2410
2806
|
}
|
|
2411
2807
|
};
|
|
2412
2808
|
|
|
2413
|
-
export { ActivityManager, AliasManager, AnalyticsManager, AssetManager, Base, BaseManager, ChainSwap, Client, CrossChainSwap, CrossChainSwapManager, CrossChainSwapStatus, Customer, CustomerManager, DefindexManager, HealthManager, KycManager, LiquidityManager, LiquidityOperation, OfframpManager, OnrampManager, PaymentIntent, PaymentIntentKind, PaymentIntentManager, PaymentIntentStatus, PluginManager, Product, ProductKind, ProductManager, PublicKeyManager, REST, Receiver, Swap, SwapManager, SwapStatus, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEventType, WebhookManager, WebhookSignatureError, Webhooks, resolveShared, shared };
|
|
2809
|
+
export { ActivityManager, AliasManager, AnalyticsManager, AssetManager, Base, BaseManager, ChainSwap, Client, CrossChainSwap, CrossChainSwapManager, CrossChainSwapStatus, Customer, CustomerManager, DefindexManager, HealthManager, KycManager, LiquidityManager, LiquidityOperation, OfframpManager, OnrampManager, PaymentIntent, PaymentIntentKind, PaymentIntentManager, PaymentIntentStatus, PluginManager, PrivatePayment, PrivatePaymentManager, PrivatePaymentStatus, Product, ProductKind, ProductManager, PublicKeyManager, REST, Receiver, Swap, SwapManager, SwapStatus, Usdt0Manager, Usdt0Transfer, Usdt0TransferStatus, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEventType, WebhookManager, WebhookSignatureError, Webhooks, resolveShared, shared };
|
|
2414
2810
|
//# sourceMappingURL=index.js.map
|
|
2415
2811
|
//# sourceMappingURL=index.js.map
|