@cosmosapp/pay_sdk 2.0.0 → 2.2.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/dist/index.js CHANGED
@@ -1,8 +1,86 @@
1
- import { version, DEFAULT_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_RETRIES, Events, CosmosPayAPIError, CosmosPayRequestError, resolveIntentBody, SIGNATURE_HEADER } from './chunk-TM4HAKWE.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-TM4HAKWE.js';
1
+ import { version, DEFAULT_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_RETRIES, Events, CosmosPayAPIError, CosmosPayRequestError, resolveIntentBody, SIGNATURE_HEADER } from './chunk-AQEHMCJZ.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-AQEHMCJZ.js';
3
3
  import { EventEmitter } from 'events';
4
4
  import { createHmac, timingSafeEqual } from 'crypto';
5
5
 
6
+ // src/managers/AliasManager.ts
7
+ var AliasManager = class {
8
+ constructor(client) {
9
+ this.route = "/aliases";
10
+ this.client = client;
11
+ }
12
+ get rest() {
13
+ return this.client.rest;
14
+ }
15
+ /** Where to pay a handle: its verified addresses on a network, primary first. */
16
+ resolve(name, options = {}) {
17
+ return this.rest.get(`${this.route}/resolve/${encodeURIComponent(name)}`, {
18
+ query: { network: options.network }
19
+ });
20
+ }
21
+ /** Whether a handle can be claimed, and if not, why not. */
22
+ availability(name) {
23
+ return this.rest.get(`${this.route}/availability/${encodeURIComponent(name)}`);
24
+ }
25
+ /** Which handles point at an address — the reverse lookup. */
26
+ byAddress(address, options = {}) {
27
+ return this.rest.get(`${this.route}/by-address/${encodeURIComponent(address)}`, {
28
+ query: { network: options.network }
29
+ });
30
+ }
31
+ /** A nonce and the exact message to sign, for a claim, a new address or a recovery. */
32
+ createChallenge(options) {
33
+ return this.rest.post(`${this.route}/challenges`, { body: options });
34
+ }
35
+ /** Claim a handle with a signature over a CLAIM challenge. */
36
+ claim(options) {
37
+ return this.rest.post(this.route, { body: options });
38
+ }
39
+ /** The handles this consumer owns (paginated). */
40
+ list(options = {}) {
41
+ return this.rest.get(this.route, {
42
+ query: { take: options.take, skip: options.skip }
43
+ });
44
+ }
45
+ /** Point a handle at another address, signed by that address (ADD_ADDRESS challenge). */
46
+ addAddress(name, options) {
47
+ return this.rest.post(`${this.route}/${encodeURIComponent(name)}/addresses`, {
48
+ body: options
49
+ });
50
+ }
51
+ /** Remove one address from a handle. */
52
+ removeAddress(name, addressId) {
53
+ return this.rest.delete(
54
+ `${this.route}/${encodeURIComponent(name)}/addresses/${encodeURIComponent(addressId)}`
55
+ );
56
+ }
57
+ /** Release a handle back to the namespace. */
58
+ release(name) {
59
+ return this.rest.delete(`${this.route}/${encodeURIComponent(name)}`);
60
+ }
61
+ /**
62
+ * Start a recovery: the service emails a one-time token to the mailbox the
63
+ * handle was claimed with, if `email` is that mailbox. The answer is the same
64
+ * either way, so it says nothing about who owns the handle; the token only
65
+ * ever reaches the mailbox, never this response.
66
+ */
67
+ startRecovery(name, email) {
68
+ return this.rest.post(`${this.route}/${encodeURIComponent(name)}/recovery`, {
69
+ body: { email }
70
+ });
71
+ }
72
+ /**
73
+ * Take a handle over with a new address after losing the old one: the token
74
+ * the owner received by email, plus a signature by the new address over a
75
+ * RECOVER challenge.
76
+ */
77
+ completeRecovery(name, options) {
78
+ return this.rest.post(`${this.route}/${encodeURIComponent(name)}/recovery/complete`, {
79
+ body: options
80
+ });
81
+ }
82
+ };
83
+
6
84
  // src/managers/AnalyticsManager.ts
7
85
  var AnalyticsManager = class {
8
86
  constructor(client) {
@@ -29,6 +107,23 @@ var AnalyticsManager = class {
29
107
  }
30
108
  };
31
109
 
110
+ // src/managers/AssetManager.ts
111
+ var AssetManager = class {
112
+ constructor(client) {
113
+ this.route = "/assets";
114
+ this.client = client;
115
+ }
116
+ get rest() {
117
+ return this.client.rest;
118
+ }
119
+ /** The registry for a network. */
120
+ list(options = {}) {
121
+ return this.rest.get(this.route, {
122
+ query: { network: options.network, verified: options.verified }
123
+ });
124
+ }
125
+ };
126
+
32
127
  // src/structures/Base.ts
33
128
  var Base = class {
34
129
  constructor(client, data) {
@@ -202,7 +297,32 @@ var WebhookEventType = {
202
297
  PaymentIntentSucceeded: "PAYMENT_INTENT_SUCCEEDED",
203
298
  PaymentIntentFailed: "PAYMENT_INTENT_FAILED",
204
299
  PaymentIntentCancelled: "PAYMENT_INTENT_CANCELLED",
205
- PaymentIntentDeleted: "PAYMENT_INTENT_DELETED"
300
+ PaymentIntentDeleted: "PAYMENT_INTENT_DELETED",
301
+ // Fiat (BlindPay), re-emitted once the server syncs them.
302
+ ReceiverUpdated: "RECEIVER_UPDATED",
303
+ PayinCreated: "PAYIN_CREATED",
304
+ PayinUpdated: "PAYIN_UPDATED",
305
+ PayinCompleted: "PAYIN_COMPLETED",
306
+ PayoutCreated: "PAYOUT_CREATED",
307
+ PayoutUpdated: "PAYOUT_UPDATED",
308
+ PayoutCompleted: "PAYOUT_COMPLETED",
309
+ // Same-chain swaps on every chain (Stellar, Solana, Monad).
310
+ SwapCreated: "SWAP_CREATED",
311
+ SwapSubmitted: "SWAP_SUBMITTED",
312
+ SwapSucceeded: "SWAP_SUCCEEDED",
313
+ SwapFailed: "SWAP_FAILED",
314
+ // Liquidity pool operations.
315
+ LiquidityCreated: "LIQUIDITY_CREATED",
316
+ LiquiditySubmitted: "LIQUIDITY_SUBMITTED",
317
+ LiquiditySucceeded: "LIQUIDITY_SUCCEEDED",
318
+ LiquidityFailed: "LIQUIDITY_FAILED",
319
+ // Cross-chain swaps (NEAR Intents).
320
+ CrossChainSwapCreated: "CROSS_CHAIN_SWAP_CREATED",
321
+ CrossChainSwapUpdated: "CROSS_CHAIN_SWAP_UPDATED",
322
+ CrossChainSwapSucceeded: "CROSS_CHAIN_SWAP_SUCCEEDED",
323
+ CrossChainSwapRefunded: "CROSS_CHAIN_SWAP_REFUNDED",
324
+ CrossChainSwapFailed: "CROSS_CHAIN_SWAP_FAILED",
325
+ CrossChainSwapExpired: "CROSS_CHAIN_SWAP_EXPIRED"
206
326
  };
207
327
  var WebhookDeliveryStatus = {
208
328
  Pending: "PENDING",
@@ -226,6 +346,16 @@ var LiquidityOperationKind = {
226
346
  var LiquidityOperationStatus = {
227
347
  Pending: "PENDING",
228
348
  Succeeded: "SUCCEEDED"};
349
+ var CrossChainSwapStatus = {
350
+ AwaitingDeposit: "AWAITING_DEPOSIT",
351
+ DepositDetected: "DEPOSIT_DETECTED",
352
+ IncompleteDeposit: "INCOMPLETE_DEPOSIT",
353
+ Processing: "PROCESSING",
354
+ Succeeded: "SUCCEEDED",
355
+ Refunded: "REFUNDED",
356
+ Failed: "FAILED",
357
+ Expired: "EXPIRED"
358
+ };
229
359
 
230
360
  // src/structures/LiquidityOperation.ts
231
361
  var LiquidityOperation = class extends Base {
@@ -851,96 +981,260 @@ var KycManager = class extends BaseManager {
851
981
  }
852
982
  };
853
983
 
854
- // src/managers/PollarManager.ts
855
- var PollarManager = class {
856
- constructor(client) {
857
- this.route = "/pollar";
858
- this.client = client;
984
+ // src/structures/CrossChainSwap.ts
985
+ var FINAL = [
986
+ CrossChainSwapStatus.Succeeded,
987
+ CrossChainSwapStatus.Refunded,
988
+ CrossChainSwapStatus.Failed
989
+ ];
990
+ var CrossChainSwap = class extends Base {
991
+ constructor(client, data) {
992
+ super(client, data);
859
993
  }
860
- get rest() {
861
- return this.client.rest;
994
+ _patch(data) {
995
+ super._patch(data);
996
+ this.status = data.status;
997
+ this.providerStatus = data.providerStatus;
998
+ this.network = data.network;
999
+ this.originChain = data.originChain;
1000
+ this.originAsset = data.originAsset;
1001
+ this.originContract = data.originContract;
1002
+ this.destinationChain = data.destinationChain;
1003
+ this.destinationAsset = data.destinationAsset;
1004
+ this.destinationContract = data.destinationContract;
1005
+ this.amountIn = data.amountIn;
1006
+ this.feeBps = data.feeBps;
1007
+ this.feeAmount = data.feeAmount;
1008
+ this.amountOutEstimated = data.amountOutEstimated;
1009
+ this.amountOutMin = data.amountOutMin;
1010
+ this.slippageBps = data.slippageBps;
1011
+ this.recipient = data.recipient;
1012
+ this.refundTo = data.refundTo;
1013
+ this.depositAddress = data.depositAddress;
1014
+ this.depositMemo = data.depositMemo;
1015
+ this.depositUri = data.depositUri;
1016
+ this.qr = data.qr ?? null;
1017
+ this.depositTxHash = data.depositTxHash;
1018
+ this.amountOut = data.amountOut;
1019
+ this.refundedAmount = data.refundedAmount;
1020
+ this.originTxHashes = data.originTxHashes;
1021
+ this.destinationTxHashes = data.destinationTxHashes;
1022
+ this.timeEstimateSeconds = data.timeEstimateSeconds;
1023
+ this.correlationId = data.correlationId;
1024
+ this.quoteSignature = data.quoteSignature;
1025
+ this.idempotencyKey = data.idempotencyKey;
1026
+ this.expiresAt = new Date(data.expiresAt);
1027
+ this.createdAt = new Date(data.createdAt);
1028
+ this.updatedAt = new Date(data.updatedAt);
1029
+ return this;
862
1030
  }
863
- /* -------------------------------- login -------------------------------- */
864
- /** Start a login and get the URL to send the user to. */
865
- authorize(options) {
866
- return this.rest.post(`${this.route}/oauth/authorize`, { body: options });
1031
+ /** Whether the swap has reached an outcome that will not change. */
1032
+ get isFinal() {
1033
+ return FINAL.includes(this.status);
867
1034
  }
868
- /**
869
- * Poll a login. `status: 'authorized'` carries the bridge `code` to redeem;
870
- * `pending` means keep waiting; anything else is over.
871
- */
872
- session(state) {
873
- return this.rest.get(`${this.route}/oauth/sessions/${state}`);
1035
+ get isSucceeded() {
1036
+ return this.status === CrossChainSwapStatus.Succeeded;
874
1037
  }
875
- /** Redeem the bridge code for a session. Single use — a consumed code is dead. */
876
- token(options) {
877
- return this.rest.post(`${this.route}/oauth/token`, { body: options });
1038
+ /** Re-fetch from the API, updating this instance in place. */
1039
+ async fetch() {
1040
+ const fresh = await this.client.crossChainSwaps.fetch(this.id);
1041
+ return this._patch(fresh.toJSON());
878
1042
  }
879
1043
  /**
880
- * Rotate the token pair. The old refresh token stops working, so store what
881
- * comes back before using it — a rotation you lose is a session you lose.
1044
+ * Report the transaction that paid the deposit address so NEAR Intents starts
1045
+ * without waiting for its indexer. Updates this instance in place.
882
1046
  */
883
- refresh(options) {
884
- return this.rest.post(`${this.route}/oauth/refresh`, { body: options });
1047
+ async reportDeposit(txHash) {
1048
+ const fresh = await this.client.crossChainSwaps.reportDeposit(this.id, txHash);
1049
+ return this._patch(fresh.toJSON());
1050
+ }
1051
+ toJSON() {
1052
+ return {
1053
+ id: this.id,
1054
+ status: this.status,
1055
+ providerStatus: this.providerStatus,
1056
+ network: this.network,
1057
+ originChain: this.originChain,
1058
+ originAsset: this.originAsset,
1059
+ originContract: this.originContract,
1060
+ destinationChain: this.destinationChain,
1061
+ destinationAsset: this.destinationAsset,
1062
+ destinationContract: this.destinationContract,
1063
+ amountIn: this.amountIn,
1064
+ feeBps: this.feeBps,
1065
+ feeAmount: this.feeAmount,
1066
+ amountOutEstimated: this.amountOutEstimated,
1067
+ amountOutMin: this.amountOutMin,
1068
+ slippageBps: this.slippageBps,
1069
+ recipient: this.recipient,
1070
+ refundTo: this.refundTo,
1071
+ depositAddress: this.depositAddress,
1072
+ depositMemo: this.depositMemo,
1073
+ depositUri: this.depositUri,
1074
+ ...this.qr ? { qr: this.qr } : {},
1075
+ depositTxHash: this.depositTxHash,
1076
+ amountOut: this.amountOut,
1077
+ refundedAmount: this.refundedAmount,
1078
+ originTxHashes: this.originTxHashes,
1079
+ destinationTxHashes: this.destinationTxHashes,
1080
+ timeEstimateSeconds: this.timeEstimateSeconds,
1081
+ correlationId: this.correlationId,
1082
+ quoteSignature: this.quoteSignature,
1083
+ idempotencyKey: this.idempotencyKey,
1084
+ expiresAt: this.expiresAt.toISOString(),
1085
+ createdAt: this.createdAt.toISOString(),
1086
+ updatedAt: this.updatedAt.toISOString()
1087
+ };
1088
+ }
1089
+ };
1090
+
1091
+ // src/managers/CrossChainSwapManager.ts
1092
+ var CrossChainSwapManager = class extends BaseManager {
1093
+ constructor() {
1094
+ super(...arguments);
1095
+ this.route = "/cross-chain-swaps";
885
1096
  }
886
- /** Revoke a session — this device, or every one of them. */
887
- logout(options) {
888
- return this.rest.post(`${this.route}/oauth/logout`, { body: options });
1097
+ /** The tokens NEAR Intents can swap on Stellar, Solana and Monad. */
1098
+ async assets() {
1099
+ const { data } = await this.rest.get(
1100
+ `${this.route}/assets`
1101
+ );
1102
+ return data;
889
1103
  }
890
- /** Validate an end-user access token and learn whose it is. */
891
- verifyToken(options) {
892
- return this.rest.post(`${this.route}/tokens/verify`, {
1104
+ /** A dry quote: output, minimum and commission. Persists nothing. */
1105
+ quote(options) {
1106
+ return this.rest.post(`${this.route}/quote`, {
893
1107
  body: options
894
1108
  });
895
1109
  }
896
- /* ------------------------------- wallets ------------------------------- */
897
- /**
898
- * Fund a wallet's XLM base reserve. A Stellar account does not exist until
899
- * something pays for it, which is why a fresh Pollar wallet can have an address
900
- * and still not be on the network.
901
- */
902
- activateWallet(options) {
903
- return this.rest.post(`${this.route}/wallets/activate`, {
1110
+ /** A live quote: the deposit address, memo and wallet link that fund the swap. */
1111
+ async create(options) {
1112
+ const data = await this.rest.post(this.route, {
904
1113
  body: options
905
1114
  });
1115
+ return this._add(new CrossChainSwap(this.client, data));
1116
+ }
1117
+ async fetch(id) {
1118
+ const data = await this.rest.get(`${this.route}/${id}`);
1119
+ return this._add(new CrossChainSwap(this.client, data));
1120
+ }
1121
+ async list(options = {}) {
1122
+ const data = await this.rest.get(this.route, {
1123
+ query: { status: options.status, take: options.take, skip: options.skip }
1124
+ });
1125
+ return {
1126
+ items: data.data.map((d) => this._add(new CrossChainSwap(this.client, d))),
1127
+ total: data.total,
1128
+ take: data.take,
1129
+ skip: data.skip
1130
+ };
1131
+ }
1132
+ /** Report the transaction that paid the deposit address. */
1133
+ async reportDeposit(id, txHash) {
1134
+ const data = await this.rest.post(
1135
+ `${this.route}/${id}/deposit`,
1136
+ { body: { txHash } }
1137
+ );
1138
+ return this._add(new CrossChainSwap(this.client, data));
1139
+ }
1140
+ };
1141
+
1142
+ // src/managers/DefindexManager.ts
1143
+ var DefindexManager = class {
1144
+ constructor(client) {
1145
+ this.route = "/defindex";
1146
+ this.client = client;
1147
+ }
1148
+ get rest() {
1149
+ return this.client.rest;
1150
+ }
1151
+ vaults() {
1152
+ return this.rest.get(`${this.route}/vaults`);
1153
+ }
1154
+ vault(vault) {
1155
+ return this.rest.get(`${this.route}/vaults/${encodeURIComponent(vault)}`);
906
1156
  }
907
- /** Enable the application's configured assets on a wallet. */
908
- addDefaultTrustlines(address) {
1157
+ /** An account's position in a vault. */
1158
+ balance(vault, account) {
1159
+ return this.rest.get(
1160
+ `${this.route}/vaults/${encodeURIComponent(vault)}/balance`,
1161
+ { query: { account } }
1162
+ );
1163
+ }
1164
+ deposit(vault, options) {
909
1165
  return this.rest.post(
910
- `${this.route}/wallets/${address}/trustlines/default`
1166
+ `${this.route}/vaults/${encodeURIComponent(vault)}/deposit`,
1167
+ { body: options }
911
1168
  );
912
1169
  }
913
- /** Enable specific assets on a wallet. */
914
- addTrustlines(address, options) {
915
- return this.rest.post(`${this.route}/wallets/${address}/trustlines`, {
916
- body: options
917
- });
1170
+ withdraw(vault, options) {
1171
+ return this.rest.post(
1172
+ `${this.route}/vaults/${encodeURIComponent(vault)}/withdraw`,
1173
+ { body: options }
1174
+ );
918
1175
  }
919
- /**
920
- * Remove a trustline. An asset is `(code, issuer)`, and both are in the path for
921
- * that reason: a bare code names no asset.
922
- */
923
- removeTrustline(address, code, issuer) {
1176
+ /** Submit a signed DeFindex transaction (base64 XDR). */
1177
+ submit(xdr) {
1178
+ return this.rest.post(`${this.route}/submit`, { body: { xdr } });
1179
+ }
1180
+ };
1181
+
1182
+ // src/managers/PluginManager.ts
1183
+ var PluginManager = class {
1184
+ constructor(client) {
1185
+ this.route = "/plugins";
1186
+ this.client = client;
1187
+ }
1188
+ get rest() {
1189
+ return this.client.rest;
1190
+ }
1191
+ async list() {
1192
+ const { data } = await this.rest.get(this.route);
1193
+ return data;
1194
+ }
1195
+ fetch(slug) {
1196
+ return this.rest.get(`${this.route}/${encodeURIComponent(slug)}`);
1197
+ }
1198
+ /** Install (or re-consent to) a plugin. */
1199
+ install(slug, options) {
1200
+ return this.rest.put(
1201
+ `${this.route}/${encodeURIComponent(slug)}/installation`,
1202
+ { body: options }
1203
+ );
1204
+ }
1205
+ uninstall(slug) {
924
1206
  return this.rest.delete(
925
- `${this.route}/wallets/${address}/trustlines/${code}/${issuer}`
1207
+ `${this.route}/${encodeURIComponent(slug)}/installation`
926
1208
  );
927
1209
  }
928
- /* -------------------------------- users -------------------------------- */
929
- /**
930
- * Register a user with Pollar ahead of their first login. Needs an elevated
931
- * (admin) key: the Pollar user directory is shared by every tenant, so a tenant
932
- * key gets `403 elevated_key_required`.
933
- */
934
- registerUser(options) {
935
- return this.rest.post(`${this.route}/users`, { body: options });
1210
+ /** Run a read-only action the plugin declares. */
1211
+ query(slug, action, input) {
1212
+ return this.rest.post(
1213
+ `${this.route}/${encodeURIComponent(slug)}/queries/${encodeURIComponent(action)}`,
1214
+ { body: { input } }
1215
+ );
936
1216
  }
937
- /**
938
- * Register a user AND provision their Stellar wallet in one call — the variant
939
- * to use when the user should be able to receive before they ever log in. Needs
940
- * an elevated (admin) key, like {@link registerUser}.
941
- */
942
- registerUserWithWallet(options) {
943
- return this.rest.post(`${this.route}/users/with-wallet`, { body: options });
1217
+ /** Run an action that may change the plugin's state. */
1218
+ command(slug, action, input) {
1219
+ return this.rest.post(
1220
+ `${this.route}/${encodeURIComponent(slug)}/commands/${encodeURIComponent(action)}`,
1221
+ { body: { input } }
1222
+ );
1223
+ }
1224
+ };
1225
+
1226
+ // src/managers/PublicKeyManager.ts
1227
+ var PublicKeyManager = class {
1228
+ constructor(client) {
1229
+ this.route = "/public-key";
1230
+ this.client = client;
1231
+ }
1232
+ get rest() {
1233
+ return this.client.rest;
1234
+ }
1235
+ /** The public key for an environment (`dev` → testnet, `prod` → mainnet). */
1236
+ fetch(env = "dev") {
1237
+ return this.rest.get(this.route, { query: { env } });
944
1238
  }
945
1239
  };
946
1240
 
@@ -953,6 +1247,7 @@ var PaymentIntent = class extends Base {
953
1247
  super._patch(data);
954
1248
  this.kind = data.kind;
955
1249
  this.status = data.status;
1250
+ this.chain = data.chain ?? "stellar";
956
1251
  this.network = data.network;
957
1252
  this.source = data.source;
958
1253
  this.destination = data.destination;
@@ -987,9 +1282,10 @@ var PaymentIntent = class extends Base {
987
1282
  get isPending() {
988
1283
  return this.status === PaymentIntentStatus.Pending;
989
1284
  }
990
- /** Human-readable asset label (`XLM` for native). */
1285
+ /** Human-readable asset label (the chain's coin for native: `XLM`, `SOL` or `MON`). */
991
1286
  get assetLabel() {
992
- return !this.asset || this.asset === "native" ? "XLM" : this.asset;
1287
+ if (this.asset && this.asset !== "native") return this.asset;
1288
+ return this.chain === "solana" ? "SOL" : this.chain === "monad" ? "MON" : "XLM";
993
1289
  }
994
1290
  /** Re-fetch this intent from the API, returning a fresh instance. */
995
1291
  fetch() {
@@ -1020,6 +1316,7 @@ var PaymentIntent = class extends Base {
1020
1316
  id: this.id,
1021
1317
  kind: this.kind,
1022
1318
  status: this.status,
1319
+ chain: this.chain,
1023
1320
  network: this.network,
1024
1321
  source: this.source,
1025
1322
  destination: this.destination,
@@ -1053,7 +1350,10 @@ var PaymentIntentManager = class extends BaseManager {
1053
1350
  });
1054
1351
  return this._add(new PaymentIntent(this.client, data));
1055
1352
  }
1056
- /** Create a SEP-7 `pay` intent (no source → pay URI + QR, no XDR). */
1353
+ /**
1354
+ * Create a `pay` intent (no source → a payment link + QR, no XDR): SEP-7 on Stellar (the
1355
+ * default), Solana Pay with `chain: 'solana'`, EIP-681 with `chain: 'monad'`.
1356
+ */
1057
1357
  async createPay(options) {
1058
1358
  const data = await this.rest.post(`${this.route}/pay`, {
1059
1359
  body: resolveIntentBody(options)
@@ -1065,11 +1365,20 @@ var PaymentIntentManager = class extends BaseManager {
1065
1365
  const data = await this.rest.get(`${this.route}/${id}`);
1066
1366
  return this._add(new PaymentIntent(this.client, data));
1067
1367
  }
1368
+ /**
1369
+ * Every status change an intent went through, oldest first — who moved it
1370
+ * (`api`, `validate`, `observer`, `system`), when, and with which transaction.
1371
+ */
1372
+ transitions(id) {
1373
+ return this.rest.get(`${this.route}/${id}/transitions`);
1374
+ }
1068
1375
  /** List the consumer's payment intents (paginated). */
1069
1376
  async list(options = {}) {
1070
1377
  const data = await this.rest.get(this.route, {
1071
1378
  query: {
1072
1379
  status: options.status,
1380
+ chain: options.chain,
1381
+ createdFrom: options.createdFrom instanceof Date ? options.createdFrom.toISOString() : options.createdFrom,
1073
1382
  take: options.take,
1074
1383
  skip: options.skip
1075
1384
  }
@@ -1210,6 +1519,92 @@ var ProductManager = class extends BaseManager {
1210
1519
  }
1211
1520
  };
1212
1521
 
1522
+ // src/structures/ChainSwap.ts
1523
+ var ChainSwap = class extends Base {
1524
+ constructor(client, data) {
1525
+ super(client, data);
1526
+ }
1527
+ _patch(data) {
1528
+ super._patch(data);
1529
+ this.chain = data.chain;
1530
+ this.network = data.network;
1531
+ this.provider = data.provider;
1532
+ this.status = data.status;
1533
+ this.source = data.source;
1534
+ this.sendAsset = data.sendAsset;
1535
+ this.sendAmount = data.sendAmount;
1536
+ this.destAsset = data.destAsset;
1537
+ this.destEstimated = data.destEstimated;
1538
+ this.destMin = data.destMin;
1539
+ this.feeBps = data.feeBps;
1540
+ this.feeAmount = data.feeAmount;
1541
+ this.slippageBps = data.slippageBps;
1542
+ this.path = data.path;
1543
+ this.transaction = data.transaction;
1544
+ this.approval = data.approval;
1545
+ this.txHash = data.txHash;
1546
+ this.idempotencyKey = data.idempotencyKey;
1547
+ this.expiresAt = new Date(data.expiresAt);
1548
+ this.createdAt = new Date(data.createdAt);
1549
+ this.updatedAt = new Date(data.updatedAt);
1550
+ return this;
1551
+ }
1552
+ /** Whether the swap has settled on-chain. */
1553
+ get isSucceeded() {
1554
+ return this.status === SwapStatus.Succeeded;
1555
+ }
1556
+ /** Whether the swap is still awaiting submission. */
1557
+ get isPending() {
1558
+ return this.status === SwapStatus.Pending;
1559
+ }
1560
+ /** Whether the built transaction can no longer be submitted. */
1561
+ get isStale() {
1562
+ return this.isPending && this.expiresAt.getTime() <= Date.now();
1563
+ }
1564
+ /** Re-fetch this swap from the API. */
1565
+ async fetch() {
1566
+ return await this.client.swaps.fetch(this.id);
1567
+ }
1568
+ /**
1569
+ * Relay the signed transaction. Mutates this instance from the refreshed
1570
+ * swap in the outcome and returns the outcome.
1571
+ */
1572
+ async submit(options) {
1573
+ const outcome = await this.client.swaps.submit(
1574
+ this.id,
1575
+ options
1576
+ );
1577
+ this._patch(outcome.swap.toJSON());
1578
+ return outcome;
1579
+ }
1580
+ toJSON() {
1581
+ return {
1582
+ id: this.id,
1583
+ chain: this.chain,
1584
+ network: this.network,
1585
+ provider: this.provider,
1586
+ status: this.status,
1587
+ source: this.source,
1588
+ sendAsset: this.sendAsset,
1589
+ sendAmount: this.sendAmount,
1590
+ destAsset: this.destAsset,
1591
+ destEstimated: this.destEstimated,
1592
+ destMin: this.destMin,
1593
+ feeBps: this.feeBps,
1594
+ feeAmount: this.feeAmount,
1595
+ slippageBps: this.slippageBps,
1596
+ path: this.path,
1597
+ transaction: this.transaction,
1598
+ approval: this.approval,
1599
+ txHash: this.txHash,
1600
+ idempotencyKey: this.idempotencyKey,
1601
+ expiresAt: this.expiresAt.toISOString(),
1602
+ createdAt: this.createdAt.toISOString(),
1603
+ updatedAt: this.updatedAt.toISOString()
1604
+ };
1605
+ }
1606
+ };
1607
+
1213
1608
  // src/structures/Swap.ts
1214
1609
  var Swap = class extends Base {
1215
1610
  constructor(client, data) {
@@ -1259,15 +1654,18 @@ var Swap = class extends Base {
1259
1654
  return !this.destAsset || this.destAsset === "native" ? "XLM" : this.destAsset;
1260
1655
  }
1261
1656
  /** Re-fetch this swap from the API, returning a fresh instance. */
1262
- fetch() {
1263
- return this.client.swaps.fetch(this.id);
1657
+ async fetch() {
1658
+ return await this.client.swaps.fetch(this.id);
1264
1659
  }
1265
1660
  /**
1266
1661
  * Relay the signed transaction for this swap. Mutates this instance from the
1267
1662
  * refreshed swap in the outcome and returns the outcome.
1268
1663
  */
1269
1664
  async submit(options) {
1270
- const outcome = await this.client.swaps.submit(this.id, options);
1665
+ const outcome = await this.client.swaps.submit(
1666
+ this.id,
1667
+ options
1668
+ );
1271
1669
  this._patch(outcome.swap.toJSON());
1272
1670
  return outcome;
1273
1671
  }
@@ -1302,6 +1700,9 @@ var Swap = class extends Base {
1302
1700
  };
1303
1701
 
1304
1702
  // src/managers/SwapManager.ts
1703
+ function isChainSwapData(data) {
1704
+ return "chain" in data && typeof data.chain === "string";
1705
+ }
1305
1706
  var SwapManager = class extends BaseManager {
1306
1707
  constructor() {
1307
1708
  super(...arguments);
@@ -1313,50 +1714,67 @@ var SwapManager = class extends BaseManager {
1313
1714
  body: options
1314
1715
  });
1315
1716
  }
1316
- /** Create a swap (unsigned XDR + SEP-7 URI + QR). */
1317
1717
  async create(options) {
1318
- const data = await this.rest.post(this.route, { body: options });
1319
- return this._add(new Swap(this.client, data));
1718
+ const data = await this.rest.post(this.route, {
1719
+ body: options
1720
+ });
1721
+ return this.materialize(data);
1320
1722
  }
1321
- /** Get a single swap by id. */
1723
+ /** Get a single swap by id, on any chain. */
1322
1724
  async fetch(id) {
1323
- const data = await this.rest.get(`${this.route}/${id}`);
1324
- return this._add(new Swap(this.client, data));
1725
+ const data = await this.rest.get(
1726
+ `${this.route}/${id}`
1727
+ );
1728
+ return this.materialize(data);
1325
1729
  }
1326
- /** List the consumer's swaps (paginated). */
1327
1730
  async list(options = {}) {
1328
- const data = await this.rest.get(this.route, {
1329
- query: {
1330
- status: options.status,
1331
- take: options.take,
1332
- skip: options.skip
1731
+ const data = await this.rest.get(
1732
+ this.route,
1733
+ {
1734
+ query: {
1735
+ chain: options.chain,
1736
+ status: options.status,
1737
+ take: options.take,
1738
+ skip: options.skip
1739
+ }
1333
1740
  }
1334
- });
1741
+ );
1335
1742
  return {
1336
- items: data.data.map((d) => this._add(new Swap(this.client, d))),
1743
+ items: data.data.map((d) => this.materialize(d)),
1337
1744
  total: data.total,
1338
1745
  take: data.take,
1339
1746
  skip: data.skip
1340
1747
  };
1341
1748
  }
1342
1749
  /**
1343
- * Relay a signed swap transaction to the network. Finalizes status
1344
- * server-side and returns the outcome with the refreshed swap materialized.
1750
+ * Relay a signed swap transaction to its network: `{ signedXdr }` for a
1751
+ * Stellar swap, `{ signedTransaction }` for a Solana or Monad one.
1345
1752
  */
1346
1753
  async submit(id, options) {
1347
- const data = await this.rest.post(
1348
- `${this.route}/${id}/submit`,
1349
- { body: options }
1350
- );
1754
+ const data = await this.rest.post(`${this.route}/${id}/submit`, { body: options });
1755
+ if (isChainSwapData(data.swap)) {
1756
+ return {
1757
+ submitted: data.submitted,
1758
+ status: data.status,
1759
+ txHash: data.txHash,
1760
+ swap: this._add(new ChainSwap(this.client, data.swap))
1761
+ };
1762
+ }
1763
+ const stellar = data;
1351
1764
  return {
1352
- submitted: data.submitted,
1353
- status: data.status,
1354
- txHash: data.txHash ?? null,
1355
- reason: data.reason ?? null,
1356
- resultCodes: data.resultCodes ?? null,
1357
- swap: this._add(new Swap(this.client, data.swap))
1765
+ submitted: stellar.submitted,
1766
+ status: stellar.status,
1767
+ txHash: stellar.txHash ?? null,
1768
+ reason: stellar.reason ?? null,
1769
+ resultCodes: stellar.resultCodes ?? null,
1770
+ swap: this._add(new Swap(this.client, stellar.swap))
1358
1771
  };
1359
1772
  }
1773
+ materialize(data) {
1774
+ return this._add(
1775
+ isChainSwapData(data) ? new ChainSwap(this.client, data) : new Swap(this.client, data)
1776
+ );
1777
+ }
1360
1778
  };
1361
1779
 
1362
1780
  // src/structures/WebhookDelivery.ts
@@ -1641,12 +2059,9 @@ var WebhookManager = class extends BaseManager {
1641
2059
  "No webhook secret configured. Pass `{ secret }` or set `webhookSecret` on the client."
1642
2060
  );
1643
2061
  }
1644
- const event = Webhooks.constructEvent(
1645
- rawBody,
1646
- signatureHeader,
1647
- secret,
1648
- { toleranceSeconds: options.toleranceSeconds }
1649
- );
2062
+ const event = Webhooks.constructEvent(rawBody, signatureHeader, secret, {
2063
+ toleranceSeconds: options.toleranceSeconds
2064
+ });
1650
2065
  this.emit(event.type, event);
1651
2066
  this.emit(toCamelEvent(event.type), event);
1652
2067
  this.emit("event", event);
@@ -1769,6 +2184,9 @@ var REST = class extends EventEmitter {
1769
2184
  post(path, options = {}) {
1770
2185
  return this.request("POST", path, options);
1771
2186
  }
2187
+ put(path, options = {}) {
2188
+ return this.request("PUT", path, options);
2189
+ }
1772
2190
  patch(path, options = {}) {
1773
2191
  return this.request("PATCH", path, options);
1774
2192
  }
@@ -1960,15 +2378,20 @@ var Client = class extends EventEmitter {
1960
2378
  this.webhooks = new WebhookManager(this);
1961
2379
  this.products = new ProductManager(this);
1962
2380
  this.swaps = new SwapManager(this);
2381
+ this.crossChainSwaps = new CrossChainSwapManager(this);
1963
2382
  this.liquidity = new LiquidityManager(this);
1964
2383
  this.onramp = new OnrampManager(this);
1965
2384
  this.offramp = new OfframpManager(this);
1966
2385
  this.activity = new ActivityManager(this);
1967
2386
  this.kyc = new KycManager(this);
1968
- this.pollar = new PollarManager(this);
1969
2387
  this.customers = new CustomerManager(this);
1970
2388
  this.analytics = new AnalyticsManager(this);
1971
2389
  this.health = new HealthManager(this);
2390
+ this.aliases = new AliasManager(this);
2391
+ this.assets = new AssetManager(this);
2392
+ this.plugins = new PluginManager(this);
2393
+ this.defindex = new DefindexManager(this);
2394
+ this.publicKey = new PublicKeyManager(this);
1972
2395
  }
1973
2396
  /** Update the API key used for subsequent requests. */
1974
2397
  setApiKey(apiKey) {
@@ -1987,6 +2410,6 @@ var Client = class extends EventEmitter {
1987
2410
  }
1988
2411
  };
1989
2412
 
1990
- export { ActivityManager, AnalyticsManager, Base, BaseManager, Client, Customer, CustomerManager, HealthManager, KycManager, LiquidityManager, LiquidityOperation, OfframpManager, OnrampManager, PaymentIntent, PaymentIntentKind, PaymentIntentManager, PaymentIntentStatus, PollarManager, Product, ProductKind, ProductManager, REST, Receiver, Swap, SwapManager, SwapStatus, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEventType, WebhookManager, WebhookSignatureError, Webhooks, resolveShared, shared };
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 };
1991
2414
  //# sourceMappingURL=index.js.map
1992
2415
  //# sourceMappingURL=index.js.map