@cosmosapp/pay_sdk 2.2.0 → 2.3.0
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-AQEHMCJZ.js → chunk-FTHQKUE5.js} +3 -3
- package/dist/{chunk-AQEHMCJZ.js.map → chunk-FTHQKUE5.js.map} +1 -1
- package/dist/index.cjs +408 -10
- 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 +404 -12
- package/dist/index.js.map +1 -1
- package/dist/{intent-input-GiCgpAWR.d.cts → intent-input-B16Lt69q.d.cts} +650 -5
- package/dist/{intent-input-GiCgpAWR.d.ts → intent-input-B16Lt69q.d.ts} +650 -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/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 +258 -10
- package/llms/llms.txt +4 -2
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -95,6 +95,17 @@ var AnalyticsManager = class {
|
|
|
95
95
|
summary() {
|
|
96
96
|
return this.rest.get("/summary");
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Activity per day, week, month or year, with the window before for growth:
|
|
100
|
+
* payments (with their settled volume in USD), swaps of every kind, liquidity
|
|
101
|
+
* operations, webhook deliveries and private payments, each in the UTC
|
|
102
|
+
* buckets of `period` (`day` when omitted).
|
|
103
|
+
*/
|
|
104
|
+
series(options = {}) {
|
|
105
|
+
return this.rest.get("/summary/series", {
|
|
106
|
+
query: { period: options.period }
|
|
107
|
+
});
|
|
108
|
+
}
|
|
98
109
|
/** Settled (and pending) amount per asset. */
|
|
99
110
|
balances() {
|
|
100
111
|
return this.rest.get("/balances");
|
|
@@ -126,6 +137,17 @@ var AssetManager = class {
|
|
|
126
137
|
}
|
|
127
138
|
};
|
|
128
139
|
|
|
140
|
+
// src/util/path.ts
|
|
141
|
+
function pathSegment(value) {
|
|
142
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
143
|
+
throw new TypeError("A path segment must be a non-empty string.");
|
|
144
|
+
}
|
|
145
|
+
if (value === "." || value === "..") {
|
|
146
|
+
throw new TypeError(`"${value}" is not a valid id.`);
|
|
147
|
+
}
|
|
148
|
+
return encodeURIComponent(value);
|
|
149
|
+
}
|
|
150
|
+
|
|
129
151
|
// src/structures/Base.ts
|
|
130
152
|
var Base = class {
|
|
131
153
|
constructor(client, data) {
|
|
@@ -147,12 +169,6 @@ var Base = class {
|
|
|
147
169
|
var Customer = class extends Base {
|
|
148
170
|
constructor(client, data) {
|
|
149
171
|
super(client, data);
|
|
150
|
-
/** Number of payment intents from this customer's account (list view only). */
|
|
151
|
-
this.payments = null;
|
|
152
|
-
/** Number of succeeded payments (list view only). */
|
|
153
|
-
this.succeeded = null;
|
|
154
|
-
/** Total settled amount as a decimal string (list view only). */
|
|
155
|
-
this.total = null;
|
|
156
172
|
}
|
|
157
173
|
_patch(data) {
|
|
158
174
|
super._patch(data);
|
|
@@ -160,13 +176,14 @@ var Customer = class extends Base {
|
|
|
160
176
|
this.alias = data.alias;
|
|
161
177
|
this.note = data.note;
|
|
162
178
|
this.email = data.email;
|
|
179
|
+
this.wallets = data.wallets ?? [];
|
|
163
180
|
this.account = data.account;
|
|
164
181
|
this.reference = data.reference;
|
|
165
182
|
this.createdAt = new Date(data.createdAt);
|
|
166
183
|
this.updatedAt = new Date(data.updatedAt);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
this.payments = data.payments ?? this.payments ?? null;
|
|
185
|
+
this.succeeded = data.succeeded ?? this.succeeded ?? null;
|
|
186
|
+
this.total = data.total ?? this.total ?? null;
|
|
170
187
|
return this;
|
|
171
188
|
}
|
|
172
189
|
/** Re-fetch this customer. */
|
|
@@ -182,6 +199,29 @@ var Customer = class extends Base {
|
|
|
182
199
|
delete() {
|
|
183
200
|
return this.client.customers.delete(this.id);
|
|
184
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Add a wallet to this customer and to {@link Customer.wallets}. A wallet the
|
|
204
|
+
* customer already holds answers as it is.
|
|
205
|
+
*/
|
|
206
|
+
async addWallet(options) {
|
|
207
|
+
const wallet = await this.client.customers.addWallet(this.id, options);
|
|
208
|
+
const at = this.wallets.findIndex((w) => w.id === wallet.id);
|
|
209
|
+
this.wallets = at === -1 ? [...this.wallets, wallet] : this.wallets.map((w, i) => i === at ? wallet : w);
|
|
210
|
+
this.syncAccount();
|
|
211
|
+
return wallet;
|
|
212
|
+
}
|
|
213
|
+
/** Remove one of this customer's wallets, by id or as read from {@link Customer.wallets}. */
|
|
214
|
+
async removeWallet(wallet) {
|
|
215
|
+
const walletId = typeof wallet === "string" ? wallet : wallet.id;
|
|
216
|
+
const result = await this.client.customers.removeWallet(this.id, walletId);
|
|
217
|
+
this.wallets = this.wallets.filter((w) => w.id !== walletId);
|
|
218
|
+
this.syncAccount();
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
/** `account` is the first wallet's address, as the API derives it. */
|
|
222
|
+
syncAccount() {
|
|
223
|
+
this.account = this.wallets[0]?.address ?? null;
|
|
224
|
+
}
|
|
185
225
|
toJSON() {
|
|
186
226
|
return {
|
|
187
227
|
id: this.id,
|
|
@@ -189,6 +229,7 @@ var Customer = class extends Base {
|
|
|
189
229
|
alias: this.alias,
|
|
190
230
|
note: this.note,
|
|
191
231
|
email: this.email,
|
|
232
|
+
wallets: this.wallets,
|
|
192
233
|
account: this.account,
|
|
193
234
|
reference: this.reference,
|
|
194
235
|
createdAt: this.createdAt.toISOString(),
|
|
@@ -257,6 +298,27 @@ var CustomerManager = class extends BaseManager {
|
|
|
257
298
|
this.cache.delete(id);
|
|
258
299
|
return result;
|
|
259
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Add a wallet to a customer, on Stellar, Solana or Monad (up to 20 per
|
|
303
|
+
* customer); payments paid from it count toward the customer. A wallet the
|
|
304
|
+
* customer already holds answers as it is; one another of your customers holds
|
|
305
|
+
* is `409 customer_wallet_taken`.
|
|
306
|
+
*/
|
|
307
|
+
async addWallet(customerId, options) {
|
|
308
|
+
return this.rest.post(`${this.route}/${pathSegment(customerId)}/wallets`, {
|
|
309
|
+
body: options
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Remove a wallet from a customer. Payments from that address stop counting
|
|
314
|
+
* toward it, and a later settled payment from it adds it as a new automatic
|
|
315
|
+
* customer. A `walletId` that is not one of this customer's wallets is 404.
|
|
316
|
+
*/
|
|
317
|
+
async removeWallet(customerId, walletId) {
|
|
318
|
+
return this.rest.delete(
|
|
319
|
+
`${this.route}/${pathSegment(customerId)}/wallets/${pathSegment(walletId)}`
|
|
320
|
+
);
|
|
321
|
+
}
|
|
260
322
|
};
|
|
261
323
|
|
|
262
324
|
// src/managers/HealthManager.ts
|
|
@@ -358,6 +420,23 @@ var CrossChainSwapStatus = {
|
|
|
358
420
|
Failed: "FAILED",
|
|
359
421
|
Expired: "EXPIRED"
|
|
360
422
|
};
|
|
423
|
+
var PrivatePaymentStatus = {
|
|
424
|
+
Pending: "PENDING",
|
|
425
|
+
Succeeded: "SUCCEEDED",
|
|
426
|
+
Expired: "EXPIRED"
|
|
427
|
+
};
|
|
428
|
+
var Usdt0TransferStatus = {
|
|
429
|
+
/** Built, waiting for the signature. */
|
|
430
|
+
Pending: "PENDING",
|
|
431
|
+
/** On the Stellar ledger; LayerZero is delivering it. */
|
|
432
|
+
Submitted: "SUBMITTED",
|
|
433
|
+
/** Credited on the destination network. */
|
|
434
|
+
Delivered: "DELIVERED",
|
|
435
|
+
/** The Stellar transaction failed, or LayerZero gave up on the message. */
|
|
436
|
+
Failed: "FAILED",
|
|
437
|
+
/** Never reached the ledger before `expiresAt`. */
|
|
438
|
+
Expired: "EXPIRED"
|
|
439
|
+
};
|
|
361
440
|
|
|
362
441
|
// src/structures/LiquidityOperation.ts
|
|
363
442
|
var LiquidityOperation = class extends Base {
|
|
@@ -1570,6 +1649,125 @@ var PaymentIntentManager = class extends BaseManager {
|
|
|
1570
1649
|
}
|
|
1571
1650
|
};
|
|
1572
1651
|
|
|
1652
|
+
// src/structures/PrivatePayment.ts
|
|
1653
|
+
var PrivatePayment = class extends Base {
|
|
1654
|
+
constructor(client, data) {
|
|
1655
|
+
super(client, data);
|
|
1656
|
+
}
|
|
1657
|
+
_patch(data) {
|
|
1658
|
+
super._patch(data);
|
|
1659
|
+
this.status = data.status;
|
|
1660
|
+
this.network = data.network;
|
|
1661
|
+
this.tokenContract = data.tokenContract;
|
|
1662
|
+
this.amount = data.amount;
|
|
1663
|
+
this.netAmount = data.netAmount;
|
|
1664
|
+
this.feeAmount = data.feeAmount;
|
|
1665
|
+
this.feeBps = data.feeBps;
|
|
1666
|
+
this.recipient = data.recipient;
|
|
1667
|
+
this.feeAccount = data.feeAccount;
|
|
1668
|
+
this.payer = data.payer;
|
|
1669
|
+
this.paymentTxHash = data.paymentTxHash;
|
|
1670
|
+
this.feeTxHash = data.feeTxHash;
|
|
1671
|
+
this.merchantFee = data.merchantFee;
|
|
1672
|
+
this.merchantFeeTxHash = data.merchantFeeTxHash;
|
|
1673
|
+
this.description = data.description;
|
|
1674
|
+
this.idempotencyKey = data.idempotencyKey;
|
|
1675
|
+
this.expiresAt = new Date(data.expiresAt);
|
|
1676
|
+
this.settledAt = data.settledAt ? new Date(data.settledAt) : null;
|
|
1677
|
+
this.createdAt = new Date(data.createdAt);
|
|
1678
|
+
this.updatedAt = new Date(data.updatedAt);
|
|
1679
|
+
return this;
|
|
1680
|
+
}
|
|
1681
|
+
/** Whether the payment is still waiting for its transfers. */
|
|
1682
|
+
get isPending() {
|
|
1683
|
+
return this.status === PrivatePaymentStatus.Pending;
|
|
1684
|
+
}
|
|
1685
|
+
/** Whether every transfer has been confirmed. */
|
|
1686
|
+
get isSucceeded() {
|
|
1687
|
+
return this.status === PrivatePaymentStatus.Succeeded;
|
|
1688
|
+
}
|
|
1689
|
+
/** Whether it passed {@link expiresAt} without settling (it can still settle with transfers that closed in time). */
|
|
1690
|
+
get isExpired() {
|
|
1691
|
+
return this.status === PrivatePaymentStatus.Expired;
|
|
1692
|
+
}
|
|
1693
|
+
/** Re-fetch from the API, updating this instance in place. */
|
|
1694
|
+
async fetch() {
|
|
1695
|
+
const fresh = await this.client.privatePayments.fetch(this.id);
|
|
1696
|
+
return this._patch(fresh.toJSON());
|
|
1697
|
+
}
|
|
1698
|
+
toJSON() {
|
|
1699
|
+
return {
|
|
1700
|
+
id: this.id,
|
|
1701
|
+
status: this.status,
|
|
1702
|
+
network: this.network,
|
|
1703
|
+
tokenContract: this.tokenContract,
|
|
1704
|
+
amount: this.amount,
|
|
1705
|
+
netAmount: this.netAmount,
|
|
1706
|
+
feeAmount: this.feeAmount,
|
|
1707
|
+
feeBps: this.feeBps,
|
|
1708
|
+
recipient: this.recipient,
|
|
1709
|
+
feeAccount: this.feeAccount,
|
|
1710
|
+
payer: this.payer,
|
|
1711
|
+
paymentTxHash: this.paymentTxHash,
|
|
1712
|
+
feeTxHash: this.feeTxHash,
|
|
1713
|
+
merchantFee: this.merchantFee,
|
|
1714
|
+
merchantFeeTxHash: this.merchantFeeTxHash,
|
|
1715
|
+
description: this.description,
|
|
1716
|
+
idempotencyKey: this.idempotencyKey,
|
|
1717
|
+
expiresAt: this.expiresAt.toISOString(),
|
|
1718
|
+
settledAt: this.settledAt ? this.settledAt.toISOString() : null,
|
|
1719
|
+
createdAt: this.createdAt.toISOString(),
|
|
1720
|
+
updatedAt: this.updatedAt.toISOString()
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
};
|
|
1724
|
+
|
|
1725
|
+
// src/managers/PrivatePaymentManager.ts
|
|
1726
|
+
var PrivatePaymentManager = class extends BaseManager {
|
|
1727
|
+
constructor() {
|
|
1728
|
+
super(...arguments);
|
|
1729
|
+
this.route = "/zk-payments";
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Create a private payment. The server prices it (`amount` = `netAmount` +
|
|
1733
|
+
* `feeAmount`) and checks on-chain that the recipient holds a confidential
|
|
1734
|
+
* account on the token, refusing it with `recipient_not_registered` otherwise.
|
|
1735
|
+
*/
|
|
1736
|
+
async create(options) {
|
|
1737
|
+
const { idempotencyKey, ...body } = options;
|
|
1738
|
+
const data = await this.rest.post(this.route, {
|
|
1739
|
+
body: { ...body, ...idempotencyKey ? { idempotencyKey } : {} },
|
|
1740
|
+
...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
|
|
1741
|
+
});
|
|
1742
|
+
return this._add(new PrivatePayment(this.client, data));
|
|
1743
|
+
}
|
|
1744
|
+
/** List the private payments on the key's network, newest first. */
|
|
1745
|
+
async list(options = {}) {
|
|
1746
|
+
const data = await this.rest.get(this.route, {
|
|
1747
|
+
query: { status: options.status, take: options.take, skip: options.skip }
|
|
1748
|
+
});
|
|
1749
|
+
return {
|
|
1750
|
+
items: data.data.map((d) => this._add(new PrivatePayment(this.client, d))),
|
|
1751
|
+
total: data.total,
|
|
1752
|
+
take: data.take,
|
|
1753
|
+
skip: data.skip
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
/** Get one of your private payments, with the transfers that settled it. */
|
|
1757
|
+
async fetch(id) {
|
|
1758
|
+
const data = await this.rest.get(`${this.route}/${pathSegment(id)}`);
|
|
1759
|
+
return this._add(new PrivatePayment(this.client, data));
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* The private payments setup of the key's network: the token, registries,
|
|
1763
|
+
* auditor id, commission and fee account a wallet registers and pays against.
|
|
1764
|
+
* `enabled` is false where private payments do not run yet.
|
|
1765
|
+
*/
|
|
1766
|
+
config() {
|
|
1767
|
+
return this.rest.get(`${this.route}/config`);
|
|
1768
|
+
}
|
|
1769
|
+
};
|
|
1770
|
+
|
|
1573
1771
|
// src/structures/Product.ts
|
|
1574
1772
|
var Product = class extends Base {
|
|
1575
1773
|
constructor(client, data) {
|
|
@@ -1925,6 +2123,198 @@ var SwapManager = class extends BaseManager {
|
|
|
1925
2123
|
}
|
|
1926
2124
|
};
|
|
1927
2125
|
|
|
2126
|
+
// src/structures/Usdt0Transfer.ts
|
|
2127
|
+
var FINAL2 = [
|
|
2128
|
+
Usdt0TransferStatus.Delivered,
|
|
2129
|
+
Usdt0TransferStatus.Failed,
|
|
2130
|
+
Usdt0TransferStatus.Expired
|
|
2131
|
+
];
|
|
2132
|
+
var Usdt0Transfer = class extends Base {
|
|
2133
|
+
constructor(client, data) {
|
|
2134
|
+
super(client, data);
|
|
2135
|
+
}
|
|
2136
|
+
_patch(data) {
|
|
2137
|
+
super._patch(data);
|
|
2138
|
+
this.status = data.status;
|
|
2139
|
+
this.network = data.network;
|
|
2140
|
+
this.source = data.source;
|
|
2141
|
+
this.to = data.to;
|
|
2142
|
+
this.eid = data.eid;
|
|
2143
|
+
this.receives = data.receives;
|
|
2144
|
+
this.recipient = data.recipient;
|
|
2145
|
+
this.amount = data.amount;
|
|
2146
|
+
this.amountSent = data.amountSent;
|
|
2147
|
+
this.amountReceived = data.amountReceived;
|
|
2148
|
+
this.dust = data.dust;
|
|
2149
|
+
this.nativeFee = data.nativeFee;
|
|
2150
|
+
this.nativeFeeLimit = data.nativeFeeLimit;
|
|
2151
|
+
this.networkFee = data.networkFee;
|
|
2152
|
+
this.feeBps = data.feeBps;
|
|
2153
|
+
this.feeAmount = data.feeAmount;
|
|
2154
|
+
this.feeWallet = data.feeWallet;
|
|
2155
|
+
this.xdr = data.xdr;
|
|
2156
|
+
this.uri = data.uri;
|
|
2157
|
+
this.qr = data.qr ?? null;
|
|
2158
|
+
this.txHash = data.txHash;
|
|
2159
|
+
this.guid = data.guid;
|
|
2160
|
+
this.destinationTxHash = data.destinationTxHash;
|
|
2161
|
+
this.scanStatus = data.scanStatus;
|
|
2162
|
+
this.scanUrl = data.scanUrl;
|
|
2163
|
+
this.failureReason = data.failureReason;
|
|
2164
|
+
this.merchantFee = data.merchantFee;
|
|
2165
|
+
this.idempotencyKey = data.idempotencyKey;
|
|
2166
|
+
this.expiresAt = new Date(data.expiresAt);
|
|
2167
|
+
this.submittedAt = data.submittedAt ? new Date(data.submittedAt) : null;
|
|
2168
|
+
this.createdAt = new Date(data.createdAt);
|
|
2169
|
+
this.updatedAt = new Date(data.updatedAt);
|
|
2170
|
+
this.publicToken = data.publicToken ?? this.publicToken ?? null;
|
|
2171
|
+
return this;
|
|
2172
|
+
}
|
|
2173
|
+
/** Whether the transfer is still waiting for its signature. */
|
|
2174
|
+
get isPending() {
|
|
2175
|
+
return this.status === Usdt0TransferStatus.Pending;
|
|
2176
|
+
}
|
|
2177
|
+
/** Whether it was credited on the destination network. */
|
|
2178
|
+
get isDelivered() {
|
|
2179
|
+
return this.status === Usdt0TransferStatus.Delivered;
|
|
2180
|
+
}
|
|
2181
|
+
/** Whether it reached an outcome that will not change (DELIVERED, FAILED or EXPIRED). */
|
|
2182
|
+
get isFinal() {
|
|
2183
|
+
return FINAL2.includes(this.status);
|
|
2184
|
+
}
|
|
2185
|
+
/** Re-read it (the API refreshes it from the ledger and LayerZero Scan), updating this instance in place. */
|
|
2186
|
+
async fetch() {
|
|
2187
|
+
const fresh = await this.client.usdt0.fetch(this.id, this.recordToken());
|
|
2188
|
+
return this._patch(fresh.toJSON());
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Relay the signed transaction. Mutates this instance from the transfer in the
|
|
2192
|
+
* outcome and returns the outcome.
|
|
2193
|
+
*/
|
|
2194
|
+
async submit(options) {
|
|
2195
|
+
const outcome = await this.client.usdt0.submit(this.id, {
|
|
2196
|
+
signedXdr: options.signedXdr,
|
|
2197
|
+
...this.recordToken()
|
|
2198
|
+
});
|
|
2199
|
+
this._patch(outcome.transfer.toJSON());
|
|
2200
|
+
return outcome;
|
|
2201
|
+
}
|
|
2202
|
+
recordToken() {
|
|
2203
|
+
return this.publicToken ? { recordToken: this.publicToken } : {};
|
|
2204
|
+
}
|
|
2205
|
+
toJSON() {
|
|
2206
|
+
return {
|
|
2207
|
+
id: this.id,
|
|
2208
|
+
status: this.status,
|
|
2209
|
+
network: this.network,
|
|
2210
|
+
source: this.source,
|
|
2211
|
+
to: this.to,
|
|
2212
|
+
eid: this.eid,
|
|
2213
|
+
receives: this.receives,
|
|
2214
|
+
recipient: this.recipient,
|
|
2215
|
+
amount: this.amount,
|
|
2216
|
+
amountSent: this.amountSent,
|
|
2217
|
+
amountReceived: this.amountReceived,
|
|
2218
|
+
dust: this.dust,
|
|
2219
|
+
nativeFee: this.nativeFee,
|
|
2220
|
+
nativeFeeLimit: this.nativeFeeLimit,
|
|
2221
|
+
networkFee: this.networkFee,
|
|
2222
|
+
feeBps: this.feeBps,
|
|
2223
|
+
feeAmount: this.feeAmount,
|
|
2224
|
+
feeWallet: this.feeWallet,
|
|
2225
|
+
xdr: this.xdr,
|
|
2226
|
+
uri: this.uri,
|
|
2227
|
+
qr: this.qr,
|
|
2228
|
+
txHash: this.txHash,
|
|
2229
|
+
guid: this.guid,
|
|
2230
|
+
destinationTxHash: this.destinationTxHash,
|
|
2231
|
+
scanStatus: this.scanStatus,
|
|
2232
|
+
scanUrl: this.scanUrl,
|
|
2233
|
+
failureReason: this.failureReason,
|
|
2234
|
+
merchantFee: this.merchantFee,
|
|
2235
|
+
idempotencyKey: this.idempotencyKey,
|
|
2236
|
+
expiresAt: this.expiresAt.toISOString(),
|
|
2237
|
+
submittedAt: this.submittedAt ? this.submittedAt.toISOString() : null,
|
|
2238
|
+
createdAt: this.createdAt.toISOString(),
|
|
2239
|
+
updatedAt: this.updatedAt.toISOString(),
|
|
2240
|
+
...this.publicToken ? { publicToken: this.publicToken } : {}
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
// src/managers/Usdt0Manager.ts
|
|
2246
|
+
function recordTokenHeader(recordToken) {
|
|
2247
|
+
return recordToken ? { headers: { "X-Record-Token": recordToken } } : {};
|
|
2248
|
+
}
|
|
2249
|
+
var Usdt0Manager = class extends BaseManager {
|
|
2250
|
+
constructor() {
|
|
2251
|
+
super(...arguments);
|
|
2252
|
+
this.route = "/usdt0";
|
|
2253
|
+
}
|
|
2254
|
+
/** The networks USDT0 can be sent to from Stellar, with the token and OFT a transfer uses. */
|
|
2255
|
+
routes() {
|
|
2256
|
+
return this.rest.get(`${this.route}/routes`);
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Price a transfer: what is sent and arrives, the dust, LayerZero's fee and the
|
|
2260
|
+
* OFT's limits. Persists nothing.
|
|
2261
|
+
*/
|
|
2262
|
+
quote(options) {
|
|
2263
|
+
return this.rest.post(`${this.route}/quote`, { body: options });
|
|
2264
|
+
}
|
|
2265
|
+
/** Build a transfer: the one unsigned Soroban transaction the holder signs (XDR and SEP-7 link). */
|
|
2266
|
+
async create(options) {
|
|
2267
|
+
const { idempotencyKey, ...body } = options;
|
|
2268
|
+
const data = await this.rest.post(`${this.route}/transfers`, {
|
|
2269
|
+
body: { ...body, ...idempotencyKey ? { idempotencyKey } : {} },
|
|
2270
|
+
...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
|
|
2271
|
+
});
|
|
2272
|
+
return this._add(new Usdt0Transfer(this.client, data));
|
|
2273
|
+
}
|
|
2274
|
+
/** List your transfers, newest first, as last refreshed (fetch one to refresh it). */
|
|
2275
|
+
async list(options = {}) {
|
|
2276
|
+
const data = await this.rest.get(`${this.route}/transfers`, {
|
|
2277
|
+
query: { status: options.status, take: options.take, skip: options.skip }
|
|
2278
|
+
});
|
|
2279
|
+
return {
|
|
2280
|
+
items: data.data.map((d) => this._add(new Usdt0Transfer(this.client, d))),
|
|
2281
|
+
total: data.total,
|
|
2282
|
+
take: data.take,
|
|
2283
|
+
skip: data.skip
|
|
2284
|
+
};
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Get one transfer. While PENDING or SUBMITTED the API refreshes it from the
|
|
2288
|
+
* Stellar ledger and LayerZero Scan (at most every 15 seconds).
|
|
2289
|
+
*/
|
|
2290
|
+
async fetch(id, options = {}) {
|
|
2291
|
+
const data = await this.rest.get(
|
|
2292
|
+
`${this.route}/transfers/${pathSegment(id)}`,
|
|
2293
|
+
recordTokenHeader(options.recordToken)
|
|
2294
|
+
);
|
|
2295
|
+
return this._add(new Usdt0Transfer(this.client, data));
|
|
2296
|
+
}
|
|
2297
|
+
/**
|
|
2298
|
+
* Relay the signed transaction to Stellar mainnet. It must be the transaction
|
|
2299
|
+
* the API built for this transfer, signed. A refusal by the network leaves it
|
|
2300
|
+
* PENDING (`submitted: false`, `reason`) to submit again until it expires.
|
|
2301
|
+
*/
|
|
2302
|
+
async submit(id, options) {
|
|
2303
|
+
const { recordToken, ...body } = options;
|
|
2304
|
+
const data = await this.rest.post(
|
|
2305
|
+
`${this.route}/transfers/${pathSegment(id)}/submit`,
|
|
2306
|
+
{ body, ...recordTokenHeader(recordToken) }
|
|
2307
|
+
);
|
|
2308
|
+
return {
|
|
2309
|
+
submitted: data.submitted,
|
|
2310
|
+
status: data.status,
|
|
2311
|
+
txHash: data.txHash ?? null,
|
|
2312
|
+
reason: data.reason ?? null,
|
|
2313
|
+
transfer: this._add(new Usdt0Transfer(this.client, data.transfer))
|
|
2314
|
+
};
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
|
|
1928
2318
|
// src/structures/WebhookDelivery.ts
|
|
1929
2319
|
var WebhookDelivery = class extends Base {
|
|
1930
2320
|
constructor(client, data) {
|
|
@@ -2037,7 +2427,7 @@ var WebhookEndpoint = class extends Base {
|
|
|
2037
2427
|
};
|
|
2038
2428
|
|
|
2039
2429
|
// src/util/Constants.ts
|
|
2040
|
-
var version = "2.
|
|
2430
|
+
var version = "2.3.0";
|
|
2041
2431
|
var DEFAULT_BASE_URL = "https://api.cosmospay.lat/cosmos-api";
|
|
2042
2432
|
var DEFAULT_VERSION = "v1";
|
|
2043
2433
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -2589,6 +2979,8 @@ var Client = class extends events.EventEmitter {
|
|
|
2589
2979
|
this.products = new ProductManager(this);
|
|
2590
2980
|
this.swaps = new SwapManager(this);
|
|
2591
2981
|
this.crossChainSwaps = new CrossChainSwapManager(this);
|
|
2982
|
+
this.usdt0 = new Usdt0Manager(this);
|
|
2983
|
+
this.privatePayments = new PrivatePaymentManager(this);
|
|
2592
2984
|
this.liquidity = new LiquidityManager(this);
|
|
2593
2985
|
this.onramp = new OnrampManager(this);
|
|
2594
2986
|
this.offramp = new OfframpManager(this);
|
|
@@ -2665,6 +3057,9 @@ exports.PaymentIntentKind = PaymentIntentKind;
|
|
|
2665
3057
|
exports.PaymentIntentManager = PaymentIntentManager;
|
|
2666
3058
|
exports.PaymentIntentStatus = PaymentIntentStatus;
|
|
2667
3059
|
exports.PluginManager = PluginManager;
|
|
3060
|
+
exports.PrivatePayment = PrivatePayment;
|
|
3061
|
+
exports.PrivatePaymentManager = PrivatePaymentManager;
|
|
3062
|
+
exports.PrivatePaymentStatus = PrivatePaymentStatus;
|
|
2668
3063
|
exports.Product = Product;
|
|
2669
3064
|
exports.ProductKind = ProductKind;
|
|
2670
3065
|
exports.ProductManager = ProductManager;
|
|
@@ -2676,6 +3071,9 @@ exports.Swap = Swap;
|
|
|
2676
3071
|
exports.SwapManager = SwapManager;
|
|
2677
3072
|
exports.SwapStatus = SwapStatus;
|
|
2678
3073
|
exports.TestnetAssets = TestnetAssets;
|
|
3074
|
+
exports.Usdt0Manager = Usdt0Manager;
|
|
3075
|
+
exports.Usdt0Transfer = Usdt0Transfer;
|
|
3076
|
+
exports.Usdt0TransferStatus = Usdt0TransferStatus;
|
|
2679
3077
|
exports.Wallets = Wallets;
|
|
2680
3078
|
exports.WebhookDelivery = WebhookDelivery;
|
|
2681
3079
|
exports.WebhookDeliveryStatus = WebhookDeliveryStatus;
|