@galaxy-kj/core-stellar-sdk 2.0.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.
Files changed (179) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +576 -0
  3. package/dist/claimable-balances/claimable-balance-manager.d.ts +99 -0
  4. package/dist/claimable-balances/claimable-balance-manager.d.ts.map +1 -0
  5. package/dist/claimable-balances/claimable-balance-manager.js +352 -0
  6. package/dist/claimable-balances/claimable-balance-manager.js.map +1 -0
  7. package/dist/claimable-balances/helpers.d.ts +66 -0
  8. package/dist/claimable-balances/helpers.d.ts.map +1 -0
  9. package/dist/claimable-balances/helpers.js +179 -0
  10. package/dist/claimable-balances/helpers.js.map +1 -0
  11. package/dist/claimable-balances/index.d.ts +12 -0
  12. package/dist/claimable-balances/index.d.ts.map +1 -0
  13. package/dist/claimable-balances/index.js +14 -0
  14. package/dist/claimable-balances/index.js.map +1 -0
  15. package/dist/claimable-balances/predicate-builder.d.ts +66 -0
  16. package/dist/claimable-balances/predicate-builder.d.ts.map +1 -0
  17. package/dist/claimable-balances/predicate-builder.js +169 -0
  18. package/dist/claimable-balances/predicate-builder.js.map +1 -0
  19. package/dist/claimable-balances/types.d.ts +123 -0
  20. package/dist/claimable-balances/types.d.ts.map +1 -0
  21. package/dist/claimable-balances/types.js +9 -0
  22. package/dist/claimable-balances/types.js.map +1 -0
  23. package/dist/hooks/use-stellar.d.ts +48 -0
  24. package/dist/hooks/use-stellar.d.ts.map +1 -0
  25. package/dist/hooks/use-stellar.js +510 -0
  26. package/dist/hooks/use-stellar.js.map +1 -0
  27. package/dist/index.d.ts +19 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +28 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/liquidity-pools/calculations.d.ts +113 -0
  32. package/dist/liquidity-pools/calculations.d.ts.map +1 -0
  33. package/dist/liquidity-pools/calculations.js +291 -0
  34. package/dist/liquidity-pools/calculations.js.map +1 -0
  35. package/dist/liquidity-pools/helpers.d.ts +102 -0
  36. package/dist/liquidity-pools/helpers.d.ts.map +1 -0
  37. package/dist/liquidity-pools/helpers.js +219 -0
  38. package/dist/liquidity-pools/helpers.js.map +1 -0
  39. package/dist/liquidity-pools/index.d.ts +13 -0
  40. package/dist/liquidity-pools/index.d.ts.map +1 -0
  41. package/dist/liquidity-pools/index.js +18 -0
  42. package/dist/liquidity-pools/index.js.map +1 -0
  43. package/dist/liquidity-pools/liquidity-pool-manager.d.ts +106 -0
  44. package/dist/liquidity-pools/liquidity-pool-manager.d.ts.map +1 -0
  45. package/dist/liquidity-pools/liquidity-pool-manager.js +387 -0
  46. package/dist/liquidity-pools/liquidity-pool-manager.js.map +1 -0
  47. package/dist/liquidity-pools/types.d.ts +135 -0
  48. package/dist/liquidity-pools/types.d.ts.map +1 -0
  49. package/dist/liquidity-pools/types.js +6 -0
  50. package/dist/liquidity-pools/types.js.map +1 -0
  51. package/dist/liquidity-pools/validation.d.ts +75 -0
  52. package/dist/liquidity-pools/validation.d.ts.map +1 -0
  53. package/dist/liquidity-pools/validation.js +218 -0
  54. package/dist/liquidity-pools/validation.js.map +1 -0
  55. package/dist/services/stellar-service.d.ts +231 -0
  56. package/dist/services/stellar-service.d.ts.map +1 -0
  57. package/dist/services/stellar-service.js +674 -0
  58. package/dist/services/stellar-service.js.map +1 -0
  59. package/dist/soroban/helpers/contract-factory.d.ts +45 -0
  60. package/dist/soroban/helpers/contract-factory.d.ts.map +1 -0
  61. package/dist/soroban/helpers/contract-factory.js +84 -0
  62. package/dist/soroban/helpers/contract-factory.js.map +1 -0
  63. package/dist/soroban/helpers/token-contract-wrapper.d.ts +104 -0
  64. package/dist/soroban/helpers/token-contract-wrapper.d.ts.map +1 -0
  65. package/dist/soroban/helpers/token-contract-wrapper.js +286 -0
  66. package/dist/soroban/helpers/token-contract-wrapper.js.map +1 -0
  67. package/dist/soroban/index.d.ts +19 -0
  68. package/dist/soroban/index.d.ts.map +1 -0
  69. package/dist/soroban/index.js +19 -0
  70. package/dist/soroban/index.js.map +1 -0
  71. package/dist/soroban/soroban-contract-manager.d.ts +71 -0
  72. package/dist/soroban/soroban-contract-manager.d.ts.map +1 -0
  73. package/dist/soroban/soroban-contract-manager.js +376 -0
  74. package/dist/soroban/soroban-contract-manager.js.map +1 -0
  75. package/dist/soroban/types/contract-types.d.ts +156 -0
  76. package/dist/soroban/types/contract-types.d.ts.map +1 -0
  77. package/dist/soroban/types/contract-types.js +3 -0
  78. package/dist/soroban/types/contract-types.js.map +1 -0
  79. package/dist/soroban/utils/abi-parser.d.ts +90 -0
  80. package/dist/soroban/utils/abi-parser.d.ts.map +1 -0
  81. package/dist/soroban/utils/abi-parser.js +308 -0
  82. package/dist/soroban/utils/abi-parser.js.map +1 -0
  83. package/dist/soroban/utils/error-parser.d.ts +70 -0
  84. package/dist/soroban/utils/error-parser.d.ts.map +1 -0
  85. package/dist/soroban/utils/error-parser.js +302 -0
  86. package/dist/soroban/utils/error-parser.js.map +1 -0
  87. package/dist/soroban/utils/event-decoder.d.ts +91 -0
  88. package/dist/soroban/utils/event-decoder.d.ts.map +1 -0
  89. package/dist/soroban/utils/event-decoder.js +307 -0
  90. package/dist/soroban/utils/event-decoder.js.map +1 -0
  91. package/dist/soroban/utils/event-monitor.d.ts +93 -0
  92. package/dist/soroban/utils/event-monitor.d.ts.map +1 -0
  93. package/dist/soroban/utils/event-monitor.js +282 -0
  94. package/dist/soroban/utils/event-monitor.js.map +1 -0
  95. package/dist/soroban/utils/function-signature-builder.d.ts +98 -0
  96. package/dist/soroban/utils/function-signature-builder.d.ts.map +1 -0
  97. package/dist/soroban/utils/function-signature-builder.js +272 -0
  98. package/dist/soroban/utils/function-signature-builder.js.map +1 -0
  99. package/dist/soroban/utils/scval-converter.d.ts +48 -0
  100. package/dist/soroban/utils/scval-converter.d.ts.map +1 -0
  101. package/dist/soroban/utils/scval-converter.js +320 -0
  102. package/dist/soroban/utils/scval-converter.js.map +1 -0
  103. package/dist/sponsored-reserves/builders/sponsored-account-builder.d.ts +58 -0
  104. package/dist/sponsored-reserves/builders/sponsored-account-builder.d.ts.map +1 -0
  105. package/dist/sponsored-reserves/builders/sponsored-account-builder.js +159 -0
  106. package/dist/sponsored-reserves/builders/sponsored-account-builder.js.map +1 -0
  107. package/dist/sponsored-reserves/builders/sponsored-claimable-balance-builder.d.ts +104 -0
  108. package/dist/sponsored-reserves/builders/sponsored-claimable-balance-builder.d.ts.map +1 -0
  109. package/dist/sponsored-reserves/builders/sponsored-claimable-balance-builder.js +258 -0
  110. package/dist/sponsored-reserves/builders/sponsored-claimable-balance-builder.js.map +1 -0
  111. package/dist/sponsored-reserves/builders/sponsored-data-entry-builder.d.ts +96 -0
  112. package/dist/sponsored-reserves/builders/sponsored-data-entry-builder.d.ts.map +1 -0
  113. package/dist/sponsored-reserves/builders/sponsored-data-entry-builder.js +320 -0
  114. package/dist/sponsored-reserves/builders/sponsored-data-entry-builder.js.map +1 -0
  115. package/dist/sponsored-reserves/builders/sponsored-signer-builder.d.ts +100 -0
  116. package/dist/sponsored-reserves/builders/sponsored-signer-builder.d.ts.map +1 -0
  117. package/dist/sponsored-reserves/builders/sponsored-signer-builder.js +271 -0
  118. package/dist/sponsored-reserves/builders/sponsored-signer-builder.js.map +1 -0
  119. package/dist/sponsored-reserves/builders/sponsored-trustline-builder.d.ts +87 -0
  120. package/dist/sponsored-reserves/builders/sponsored-trustline-builder.d.ts.map +1 -0
  121. package/dist/sponsored-reserves/builders/sponsored-trustline-builder.js +281 -0
  122. package/dist/sponsored-reserves/builders/sponsored-trustline-builder.js.map +1 -0
  123. package/dist/sponsored-reserves/index.d.ts +20 -0
  124. package/dist/sponsored-reserves/index.d.ts.map +1 -0
  125. package/dist/sponsored-reserves/index.js +24 -0
  126. package/dist/sponsored-reserves/index.js.map +1 -0
  127. package/dist/sponsored-reserves/services/sponsored-reserves-manager.d.ts +144 -0
  128. package/dist/sponsored-reserves/services/sponsored-reserves-manager.d.ts.map +1 -0
  129. package/dist/sponsored-reserves/services/sponsored-reserves-manager.js +536 -0
  130. package/dist/sponsored-reserves/services/sponsored-reserves-manager.js.map +1 -0
  131. package/dist/sponsored-reserves/templates/claimable-balance-template.d.ts +96 -0
  132. package/dist/sponsored-reserves/templates/claimable-balance-template.d.ts.map +1 -0
  133. package/dist/sponsored-reserves/templates/claimable-balance-template.js +306 -0
  134. package/dist/sponsored-reserves/templates/claimable-balance-template.js.map +1 -0
  135. package/dist/sponsored-reserves/templates/multi-operation-template.d.ts +99 -0
  136. package/dist/sponsored-reserves/templates/multi-operation-template.d.ts.map +1 -0
  137. package/dist/sponsored-reserves/templates/multi-operation-template.js +313 -0
  138. package/dist/sponsored-reserves/templates/multi-operation-template.js.map +1 -0
  139. package/dist/sponsored-reserves/templates/user-onboarding-template.d.ts +79 -0
  140. package/dist/sponsored-reserves/templates/user-onboarding-template.d.ts.map +1 -0
  141. package/dist/sponsored-reserves/templates/user-onboarding-template.js +262 -0
  142. package/dist/sponsored-reserves/templates/user-onboarding-template.js.map +1 -0
  143. package/dist/sponsored-reserves/types/sponsored-reserves-types.d.ts +364 -0
  144. package/dist/sponsored-reserves/types/sponsored-reserves-types.d.ts.map +1 -0
  145. package/dist/sponsored-reserves/types/sponsored-reserves-types.js +9 -0
  146. package/dist/sponsored-reserves/types/sponsored-reserves-types.js.map +1 -0
  147. package/dist/sponsored-reserves/utils/cost-calculator.d.ts +98 -0
  148. package/dist/sponsored-reserves/utils/cost-calculator.d.ts.map +1 -0
  149. package/dist/sponsored-reserves/utils/cost-calculator.js +238 -0
  150. package/dist/sponsored-reserves/utils/cost-calculator.js.map +1 -0
  151. package/dist/sponsored-reserves/utils/sponsorship-validation.d.ts +112 -0
  152. package/dist/sponsored-reserves/utils/sponsorship-validation.d.ts.map +1 -0
  153. package/dist/sponsored-reserves/utils/sponsorship-validation.js +394 -0
  154. package/dist/sponsored-reserves/utils/sponsorship-validation.js.map +1 -0
  155. package/dist/types/stellar-sdk-compat.d.ts +25 -0
  156. package/dist/types/stellar-sdk-compat.d.ts.map +1 -0
  157. package/dist/types/stellar-sdk-compat.js +44 -0
  158. package/dist/types/stellar-sdk-compat.js.map +1 -0
  159. package/dist/types/stellar-types.d.ts +160 -0
  160. package/dist/types/stellar-types.d.ts.map +1 -0
  161. package/dist/types/stellar-types.js +9 -0
  162. package/dist/types/stellar-types.js.map +1 -0
  163. package/dist/utils/encryption.utils.d.ts +9 -0
  164. package/dist/utils/encryption.utils.d.ts.map +1 -0
  165. package/dist/utils/encryption.utils.js +44 -0
  166. package/dist/utils/encryption.utils.js.map +1 -0
  167. package/dist/utils/network-utils.d.ts +138 -0
  168. package/dist/utils/network-utils.d.ts.map +1 -0
  169. package/dist/utils/network-utils.js +240 -0
  170. package/dist/utils/network-utils.js.map +1 -0
  171. package/dist/utils/stellar-utils.d.ts +114 -0
  172. package/dist/utils/stellar-utils.d.ts.map +1 -0
  173. package/dist/utils/stellar-utils.js +186 -0
  174. package/dist/utils/stellar-utils.js.map +1 -0
  175. package/dist/utils/supabase-client.d.ts +2 -0
  176. package/dist/utils/supabase-client.d.ts.map +1 -0
  177. package/dist/utils/supabase-client.js +9 -0
  178. package/dist/utils/supabase-client.js.map +1 -0
  179. package/package.json +60 -0
@@ -0,0 +1,536 @@
1
+ /**
2
+ * @fileoverview Main manager class for sponsored reserves operations
3
+ * @description Handles all Stellar sponsored reserves functionality
4
+ * @author Galaxy DevKit Team
5
+ * @version 1.0.0
6
+ * @since 2024-12-01
7
+ */
8
+ import { Keypair, Asset, Operation, BASE_FEE, TransactionBuilder, Memo, Horizon, Claimant as StellarClaimant, } from '@stellar/stellar-sdk';
9
+ import { validatePublicKey, validateSecretKey, validateSponsorBalance, } from '../utils/sponsorship-validation';
10
+ import { calculateEntryReserve, getDetailedBreakdown, } from '../utils/cost-calculator';
11
+ /**
12
+ * Manager class for Stellar sponsored reserves operations
13
+ * @class SponsoredReservesManager
14
+ * @description Provides methods for sponsoring reserves, building transactions, and querying sponsored entries
15
+ */
16
+ export class SponsoredReservesManager {
17
+ /**
18
+ * Creates a new SponsoredReservesManager instance
19
+ * @param networkConfig - Network configuration
20
+ */
21
+ constructor(networkConfig) {
22
+ this.networkConfig = networkConfig;
23
+ this.server = new Horizon.Server(networkConfig.horizonUrl);
24
+ }
25
+ /**
26
+ * Creates a beginSponsoringFutureReserves operation
27
+ * @param sponsoredPublicKey - Public key of the account to sponsor
28
+ * @returns The Stellar operation
29
+ */
30
+ beginSponsoringFutureReserves(sponsoredPublicKey) {
31
+ if (!validatePublicKey(sponsoredPublicKey)) {
32
+ throw new Error('Invalid sponsored public key');
33
+ }
34
+ return Operation.beginSponsoringFutureReserves({
35
+ sponsoredId: sponsoredPublicKey,
36
+ });
37
+ }
38
+ /**
39
+ * Creates an endSponsoringFutureReserves operation
40
+ * @param sponsoredPublicKey - Public key of the sponsored account (used as source)
41
+ * @returns The Stellar operation
42
+ */
43
+ endSponsoringFutureReserves(sponsoredPublicKey) {
44
+ if (!validatePublicKey(sponsoredPublicKey)) {
45
+ throw new Error('Invalid sponsored public key');
46
+ }
47
+ return Operation.endSponsoringFutureReserves({
48
+ source: sponsoredPublicKey,
49
+ });
50
+ }
51
+ /**
52
+ * Creates a revoke sponsorship operation
53
+ * @param target - Target specification for revocation
54
+ * @returns The Stellar operation
55
+ */
56
+ revokeSponsorship(target) {
57
+ switch (target.entryType) {
58
+ case 'account':
59
+ if (!target.accountPublicKey) {
60
+ throw new Error('Account public key required for account revocation');
61
+ }
62
+ if (!validatePublicKey(target.accountPublicKey)) {
63
+ throw new Error('Invalid account public key');
64
+ }
65
+ return Operation.revokeAccountSponsorship({
66
+ account: target.accountPublicKey,
67
+ });
68
+ case 'trustline':
69
+ if (!target.accountPublicKey || !target.asset) {
70
+ throw new Error('Account and asset required for trustline revocation');
71
+ }
72
+ if (!validatePublicKey(target.accountPublicKey)) {
73
+ throw new Error('Invalid account public key');
74
+ }
75
+ const trustlineAsset = target.asset.issuer
76
+ ? new Asset(target.asset.code, target.asset.issuer)
77
+ : Asset.native();
78
+ return Operation.revokeTrustlineSponsorship({
79
+ account: target.accountPublicKey,
80
+ asset: trustlineAsset,
81
+ });
82
+ case 'offer':
83
+ if (!target.accountPublicKey || !target.offerId) {
84
+ throw new Error('Account and offer ID required for offer revocation');
85
+ }
86
+ if (!validatePublicKey(target.accountPublicKey)) {
87
+ throw new Error('Invalid account public key');
88
+ }
89
+ return Operation.revokeOfferSponsorship({
90
+ seller: target.accountPublicKey,
91
+ offerId: target.offerId,
92
+ });
93
+ case 'data':
94
+ if (!target.accountPublicKey || !target.dataName) {
95
+ throw new Error('Account and data name required for data revocation');
96
+ }
97
+ if (!validatePublicKey(target.accountPublicKey)) {
98
+ throw new Error('Invalid account public key');
99
+ }
100
+ return Operation.revokeDataSponsorship({
101
+ account: target.accountPublicKey,
102
+ name: target.dataName,
103
+ });
104
+ case 'claimable_balance':
105
+ if (!target.balanceId) {
106
+ throw new Error('Balance ID required for claimable balance revocation');
107
+ }
108
+ return Operation.revokeClaimableBalanceSponsorship({
109
+ balanceId: target.balanceId,
110
+ });
111
+ case 'signer':
112
+ if (!target.accountPublicKey || !target.signerKey) {
113
+ throw new Error('Account and signer key required for signer revocation');
114
+ }
115
+ if (!validatePublicKey(target.accountPublicKey)) {
116
+ throw new Error('Invalid account public key');
117
+ }
118
+ return Operation.revokeSignerSponsorship({
119
+ account: target.accountPublicKey,
120
+ signer: {
121
+ ed25519PublicKey: target.signerKey,
122
+ },
123
+ });
124
+ default:
125
+ throw new Error(`Unknown entry type: ${target.entryType}`);
126
+ }
127
+ }
128
+ /**
129
+ * Executes a complete sponsorship transaction
130
+ * @param config - Sponsorship configuration
131
+ * @param sponsorSecret - Sponsor's secret key
132
+ * @param sponsoredSecret - Sponsored account's secret key
133
+ * @param operations - Additional operations to include between begin and end
134
+ * @returns Promise<SponsorshipResult>
135
+ */
136
+ async executeSponsorshipTransaction(config, sponsorSecret, sponsoredSecret, operations) {
137
+ if (!validateSecretKey(sponsorSecret)) {
138
+ throw new Error('Invalid sponsor secret key');
139
+ }
140
+ if (!validateSecretKey(sponsoredSecret)) {
141
+ throw new Error('Invalid sponsored secret key');
142
+ }
143
+ const sponsorKeypair = Keypair.fromSecret(sponsorSecret);
144
+ const sponsoredKeypair = Keypair.fromSecret(sponsoredSecret);
145
+ // Load sponsor account
146
+ const sponsorAccount = await this.server.loadAccount(sponsorKeypair.publicKey());
147
+ // Calculate fee
148
+ const totalOperations = operations.length + 2; // +2 for begin and end
149
+ const fee = await this.estimateFee(totalOperations);
150
+ // Build transaction
151
+ const transactionBuilder = new TransactionBuilder(sponsorAccount, {
152
+ fee,
153
+ networkPassphrase: this.networkConfig.passphrase,
154
+ });
155
+ // Add begin sponsoring operation
156
+ transactionBuilder.addOperation(this.beginSponsoringFutureReserves(config.sponsoredPublicKey));
157
+ // Add sponsored operations
158
+ for (const op of operations) {
159
+ transactionBuilder.addOperation(op);
160
+ }
161
+ // Add end sponsoring operation
162
+ transactionBuilder.addOperation(this.endSponsoringFutureReserves(config.sponsoredPublicKey));
163
+ transactionBuilder.setTimeout(180);
164
+ const transaction = transactionBuilder.build();
165
+ // Sign with both keypairs
166
+ transaction.sign(sponsorKeypair);
167
+ transaction.sign(sponsoredKeypair);
168
+ // Submit transaction
169
+ const result = await this.submitWithRetry(transaction);
170
+ return {
171
+ hash: result.hash,
172
+ status: result.successful ? 'success' : 'failed',
173
+ ledger: result.ledger.toString(),
174
+ createdAt: new Date(),
175
+ sponsoredEntries: [{ type: config.entryType }],
176
+ feePaid: fee,
177
+ };
178
+ }
179
+ /**
180
+ * Builds an unsigned sponsorship transaction
181
+ * @param config - Sponsorship configuration
182
+ * @param operations - Operations to include
183
+ * @param options - Transaction options
184
+ * @returns Promise<UnsignedTransactionResult>
185
+ */
186
+ async buildUnsignedSponsorshipTransaction(config, operations, options = {}) {
187
+ if (!validatePublicKey(config.sponsorPublicKey)) {
188
+ throw new Error('Invalid sponsor public key');
189
+ }
190
+ // Load sponsor account
191
+ const sponsorAccount = await this.server.loadAccount(config.sponsorPublicKey);
192
+ // Calculate fee
193
+ const totalOperations = operations.length + 2;
194
+ const fee = options.fee || (await this.estimateFee(totalOperations));
195
+ // Build transaction
196
+ const transactionBuilder = new TransactionBuilder(sponsorAccount, {
197
+ fee,
198
+ networkPassphrase: this.networkConfig.passphrase,
199
+ });
200
+ // Add begin sponsoring operation
201
+ transactionBuilder.addOperation(this.beginSponsoringFutureReserves(config.sponsoredPublicKey));
202
+ // Add sponsored operations
203
+ for (const op of operations) {
204
+ transactionBuilder.addOperation(op);
205
+ }
206
+ // Add end sponsoring operation
207
+ transactionBuilder.addOperation(this.endSponsoringFutureReserves(config.sponsoredPublicKey));
208
+ // Add memo if provided
209
+ if (options.memo) {
210
+ transactionBuilder.addMemo(Memo.text(options.memo));
211
+ }
212
+ transactionBuilder.setTimeout(options.timeout || 180);
213
+ const transaction = transactionBuilder.build();
214
+ return {
215
+ xdr: transaction.toXDR(),
216
+ networkPassphrase: this.networkConfig.passphrase,
217
+ requiredSigners: [config.sponsorPublicKey, config.sponsoredPublicKey],
218
+ estimatedFee: fee,
219
+ };
220
+ }
221
+ /**
222
+ * Signs and submits a sponsorship transaction from XDR
223
+ * @param transactionXdr - Transaction XDR
224
+ * @param signerSecrets - Array of secret keys for signing
225
+ * @returns Promise<SponsorshipResult>
226
+ */
227
+ async signAndSubmitSponsorshipTransaction(transactionXdr, signerSecrets) {
228
+ const transaction = TransactionBuilder.fromXDR(transactionXdr, this.networkConfig.passphrase);
229
+ // Sign with all provided keys
230
+ for (const secret of signerSecrets) {
231
+ if (!validateSecretKey(secret)) {
232
+ throw new Error('Invalid secret key provided');
233
+ }
234
+ const keypair = Keypair.fromSecret(secret);
235
+ transaction.sign(keypair);
236
+ }
237
+ // Submit transaction
238
+ const result = await this.submitWithRetry(transaction);
239
+ return {
240
+ hash: result.hash,
241
+ status: result.successful ? 'success' : 'failed',
242
+ ledger: result.ledger.toString(),
243
+ createdAt: new Date(),
244
+ sponsoredEntries: [],
245
+ feePaid: transaction.fee.toString(),
246
+ };
247
+ }
248
+ /**
249
+ * Gets entries sponsored FOR an account (entries where this account has sponsored reserves)
250
+ * @param accountPublicKey - Account public key
251
+ * @param options - Query options
252
+ * @returns Promise<SponsoredEntry[]>
253
+ */
254
+ async getSponsoredEntries(accountPublicKey, options = {}) {
255
+ if (!validatePublicKey(accountPublicKey)) {
256
+ throw new Error('Invalid account public key');
257
+ }
258
+ const entries = [];
259
+ try {
260
+ const account = await this.server.loadAccount(accountPublicKey);
261
+ // Check for sponsored account
262
+ if (account.sponsor) {
263
+ if (!options.entryType || options.entryType === 'account') {
264
+ entries.push({
265
+ entryType: 'account',
266
+ sponsor: account.sponsor,
267
+ sponsoredAccount: accountPublicKey,
268
+ entryId: accountPublicKey,
269
+ details: { type: 'account' },
270
+ });
271
+ }
272
+ }
273
+ // Check trustlines for sponsorship
274
+ if (!options.entryType || options.entryType === 'trustline') {
275
+ for (const balance of account.balances) {
276
+ if ('sponsor' in balance && balance.sponsor) {
277
+ const balanceAny = balance;
278
+ const isNative = balanceAny.asset_type === 'native';
279
+ const assetInfo = isNative
280
+ ? { code: 'XLM' }
281
+ : { code: balanceAny.asset_code, issuer: balanceAny.asset_issuer };
282
+ entries.push({
283
+ entryType: 'trustline',
284
+ sponsor: balanceAny.sponsor,
285
+ sponsoredAccount: accountPublicKey,
286
+ entryId: `${accountPublicKey}:${assetInfo.code}:${assetInfo.issuer || 'native'}`,
287
+ details: { asset: assetInfo },
288
+ });
289
+ }
290
+ }
291
+ }
292
+ // Check data entries for sponsorship
293
+ // Note: Data entry sponsorship info requires querying effects/operations
294
+ // This is a placeholder for future implementation
295
+ if (!options.entryType || options.entryType === 'data') {
296
+ // Data entries with sponsors would need to be checked via effects/operations
297
+ // Full implementation would iterate through account data and check sponsorship
298
+ }
299
+ // Check signers for sponsorship
300
+ if (!options.entryType || options.entryType === 'signer') {
301
+ for (const signer of account.signers) {
302
+ const signerAny = signer;
303
+ if ('sponsor' in signer && signerAny.sponsor) {
304
+ entries.push({
305
+ entryType: 'signer',
306
+ sponsor: signerAny.sponsor,
307
+ sponsoredAccount: accountPublicKey,
308
+ entryId: `${accountPublicKey}:${signer.key}`,
309
+ details: { signerKey: signer.key, weight: signer.weight },
310
+ });
311
+ }
312
+ }
313
+ }
314
+ // Apply limit
315
+ if (options.limit && entries.length > options.limit) {
316
+ return entries.slice(0, options.limit);
317
+ }
318
+ return entries;
319
+ }
320
+ catch (error) {
321
+ if (error instanceof Error && error.message.includes('404')) {
322
+ return [];
323
+ }
324
+ throw new Error(`Failed to get sponsored entries: ${error instanceof Error ? error.message : 'Unknown error'}`);
325
+ }
326
+ }
327
+ /**
328
+ * Gets entries sponsored BY an account (entries this account is sponsoring)
329
+ * @param sponsorPublicKey - Sponsor's public key
330
+ * @param options - Query options
331
+ * @returns Promise<SponsoredEntry[]>
332
+ */
333
+ async getEntriesSponsoredBy(sponsorPublicKey, _options = {}) {
334
+ if (!validatePublicKey(sponsorPublicKey)) {
335
+ throw new Error('Invalid sponsor public key');
336
+ }
337
+ // This requires querying accounts and checking their sponsors
338
+ // A full implementation would use Horizon's effects or a dedicated API
339
+ // For now, return empty array - would need indexer support for full implementation
340
+ const entries = [];
341
+ // Note: Stellar Horizon doesn't provide a direct API to query entries sponsored BY an account
342
+ // This would require either:
343
+ // 1. An indexer that tracks sponsorship relationships
344
+ // 2. Querying all accounts and filtering (not practical)
345
+ // 3. Tracking sponsorship events from the transaction history
346
+ // The _options parameter is reserved for future use with an indexer
347
+ return entries;
348
+ }
349
+ /**
350
+ * Checks if a sponsor is eligible for a sponsorship operation
351
+ * @param sponsorPublicKey - Sponsor's public key
352
+ * @param config - Sponsorship configuration or cost breakdown
353
+ * @returns Promise<SponsorshipEligibility>
354
+ */
355
+ async checkSponsorshipEligibility(sponsorPublicKey, config) {
356
+ if (!validatePublicKey(sponsorPublicKey)) {
357
+ throw new Error('Invalid sponsor public key');
358
+ }
359
+ try {
360
+ const account = await this.server.loadAccount(sponsorPublicKey);
361
+ // Find XLM balance
362
+ const xlmBalance = account.balances.find((b) => b.asset_type === 'native');
363
+ if (!xlmBalance) {
364
+ return {
365
+ eligible: false,
366
+ currentBalance: '0',
367
+ requiredBalance: '0',
368
+ reason: 'Account has no XLM balance',
369
+ };
370
+ }
371
+ const currentBalance = xlmBalance.balance;
372
+ // Calculate required balance
373
+ let requiredBalance;
374
+ if ('totalCost' in config) {
375
+ // SponsorshipCost
376
+ requiredBalance = (parseFloat(config.totalCost) +
377
+ parseFloat(config.transactionFee) +
378
+ 1 // Buffer
379
+ ).toFixed(7);
380
+ }
381
+ else {
382
+ // SponsorshipConfig
383
+ requiredBalance = (parseFloat(calculateEntryReserve(config.entryType, 1)) +
384
+ 0.001 + // Estimated fee
385
+ 1 // Buffer
386
+ ).toFixed(7);
387
+ }
388
+ const validation = validateSponsorBalance(currentBalance, requiredBalance, '0');
389
+ if (validation.valid) {
390
+ return {
391
+ eligible: true,
392
+ currentBalance,
393
+ requiredBalance,
394
+ };
395
+ }
396
+ else {
397
+ return {
398
+ eligible: false,
399
+ currentBalance,
400
+ requiredBalance,
401
+ shortfall: validation.shortfall,
402
+ reason: validation.message,
403
+ };
404
+ }
405
+ }
406
+ catch (error) {
407
+ if (error instanceof Error && error.message.includes('404')) {
408
+ return {
409
+ eligible: false,
410
+ currentBalance: '0',
411
+ requiredBalance: '0',
412
+ reason: 'Sponsor account not found or not funded',
413
+ };
414
+ }
415
+ throw new Error(`Failed to check eligibility: ${error instanceof Error ? error.message : 'Unknown error'}`);
416
+ }
417
+ }
418
+ /**
419
+ * Calculates the cost of a sponsorship configuration
420
+ * @param config - Sponsorship configuration
421
+ * @returns SponsorshipCost
422
+ */
423
+ calculateSponsorshipCost(config) {
424
+ return getDetailedBreakdown([{ type: config.entryType, count: 1 }]);
425
+ }
426
+ /**
427
+ * Calculates the cost for multiple entries
428
+ * @param entryTypes - Array of entry types with counts
429
+ * @returns SponsorshipCost
430
+ */
431
+ calculateMultipleSponsorshipCost(entryTypes) {
432
+ return getDetailedBreakdown(entryTypes.map(e => ({
433
+ type: e.type,
434
+ count: e.count,
435
+ })));
436
+ }
437
+ /**
438
+ * Converts a ClaimPredicate to Stellar SDK format
439
+ * @param predicate - Claim predicate
440
+ * @returns Stellar SDK claimant predicate
441
+ */
442
+ buildClaimPredicate(predicate) {
443
+ if ('unconditional' in predicate) {
444
+ return StellarClaimant.predicateUnconditional();
445
+ }
446
+ if ('and' in predicate) {
447
+ return StellarClaimant.predicateAnd(this.buildClaimPredicate(predicate.and[0]), this.buildClaimPredicate(predicate.and[1]));
448
+ }
449
+ if ('or' in predicate) {
450
+ return StellarClaimant.predicateOr(this.buildClaimPredicate(predicate.or[0]), this.buildClaimPredicate(predicate.or[1]));
451
+ }
452
+ if ('not' in predicate) {
453
+ return StellarClaimant.predicateNot(this.buildClaimPredicate(predicate.not));
454
+ }
455
+ if ('beforeAbsoluteTime' in predicate) {
456
+ return StellarClaimant.predicateBeforeAbsoluteTime(predicate.beforeAbsoluteTime);
457
+ }
458
+ if ('beforeRelativeTime' in predicate) {
459
+ return StellarClaimant.predicateBeforeRelativeTime(predicate.beforeRelativeTime);
460
+ }
461
+ throw new Error('Invalid predicate format');
462
+ }
463
+ /**
464
+ * Builds a Stellar Claimant from our Claimant interface
465
+ * @param claimant - Claimant configuration
466
+ * @returns Stellar SDK Claimant
467
+ */
468
+ buildStellarClaimant(claimant) {
469
+ return new StellarClaimant(claimant.destination, this.buildClaimPredicate(claimant.predicate));
470
+ }
471
+ /**
472
+ * Gets the current network configuration
473
+ * @returns NetworkConfig
474
+ */
475
+ getNetworkConfig() {
476
+ return this.networkConfig;
477
+ }
478
+ /**
479
+ * Switches to a different network
480
+ * @param networkConfig - New network configuration
481
+ */
482
+ switchNetwork(networkConfig) {
483
+ this.networkConfig = networkConfig;
484
+ this.server = new Horizon.Server(networkConfig.horizonUrl);
485
+ }
486
+ /**
487
+ * Estimates transaction fee
488
+ * @param operationCount - Number of operations
489
+ * @returns Fee in stroops as string
490
+ */
491
+ async estimateFee(operationCount = 1) {
492
+ try {
493
+ const feeStats = await this.server.feeStats();
494
+ const baseFee = parseInt(feeStats.max_fee.mode, 10);
495
+ return (baseFee * operationCount).toString();
496
+ }
497
+ catch {
498
+ return (parseInt(BASE_FEE, 10) * operationCount).toString();
499
+ }
500
+ }
501
+ /**
502
+ * Submits transaction with retry logic
503
+ * @param transaction - Transaction to submit
504
+ * @param maxRetries - Maximum retry attempts
505
+ * @returns Transaction result
506
+ */
507
+ async submitWithRetry(transaction, maxRetries = 3) {
508
+ for (let i = 0; i < maxRetries; i++) {
509
+ try {
510
+ return await this.server.submitTransaction(transaction);
511
+ }
512
+ catch (error) {
513
+ const isRetryable = this.isRetryableError(error);
514
+ if (i === maxRetries - 1 || !isRetryable) {
515
+ throw error;
516
+ }
517
+ await new Promise(resolve => setTimeout(resolve, 1000 * (i + 1)));
518
+ }
519
+ }
520
+ }
521
+ /**
522
+ * Checks if an error is retryable
523
+ * @param error - Error to check
524
+ * @returns true if retryable
525
+ */
526
+ isRetryableError(error) {
527
+ if (!error)
528
+ return false;
529
+ const message = error.message || '';
530
+ return (message.includes('timeout') ||
531
+ message.includes('ECONNRESET') ||
532
+ message.includes('ETIMEDOUT') ||
533
+ error.response?.status >= 500);
534
+ }
535
+ }
536
+ //# sourceMappingURL=sponsored-reserves-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sponsored-reserves-manager.js","sourceRoot":"","sources":["../../../src/sponsored-reserves/services/sponsored-reserves-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,KAAK,EACL,SAAS,EACT,QAAQ,EACR,kBAAkB,EAClB,IAAI,EACJ,OAAO,EAEP,QAAQ,IAAI,eAAe,GAC5B,MAAM,sBAAsB,CAAC;AAe9B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qBAAqB,EAC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K,UAAU,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;oBACzC,MAAM,KAAK,CAAC;gBACd,CAAC;gBACD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACpE,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,gBAAgB,CAAC,KAAU;QACjC,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QACpC,OAAO,CACL,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;YAC7B,KAAK,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,CAC9B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @fileoverview Template for sponsored claimable balance operations
3
+ * @description Provides templates for common claimable balance patterns like airdrops and vesting
4
+ * @author Galaxy DevKit Team
5
+ * @version 1.0.0
6
+ * @since 2024-12-01
7
+ */
8
+ import { NetworkConfig } from '../../types/stellar-types';
9
+ import { SponsorshipResult } from '../types/sponsored-reserves-types';
10
+ /**
11
+ * Template class for sponsored claimable balance operations
12
+ * @class ClaimableBalanceTemplate
13
+ */
14
+ export declare class ClaimableBalanceTemplate {
15
+ private server;
16
+ private networkConfig;
17
+ /**
18
+ * Creates a new ClaimableBalanceTemplate instance
19
+ * @param networkConfig - Network configuration
20
+ */
21
+ constructor(networkConfig: NetworkConfig);
22
+ /**
23
+ * Converts a ClaimPredicate to Stellar SDK format
24
+ */
25
+ private buildClaimPredicate;
26
+ /**
27
+ * Builds a Stellar Claimant from our Claimant interface
28
+ */
29
+ private buildStellarClaimant;
30
+ /**
31
+ * Creates a sponsored airdrop using claimable balances
32
+ * Recipients can claim their airdrop without needing any XLM
33
+ * @param sponsorSecret - Sponsor's secret key
34
+ * @param sourceSecret - Source account's secret key (holds the tokens)
35
+ * @param asset - Asset to airdrop
36
+ * @param recipients - Array of recipient addresses with amounts
37
+ * @param expirationTime - Optional expiration timestamp
38
+ * @returns Promise<SponsorshipResult[]>
39
+ */
40
+ createSponsoredAirdrop(sponsorSecret: string, sourceSecret: string, asset: {
41
+ code: string;
42
+ issuer?: string;
43
+ }, recipients: Array<{
44
+ destination: string;
45
+ amount: string;
46
+ }>, expirationTime?: number): Promise<SponsorshipResult[]>;
47
+ /**
48
+ * Creates a sponsored vesting schedule using claimable balances
49
+ * @param sponsorSecret - Sponsor's secret key
50
+ * @param sourceSecret - Source account's secret key
51
+ * @param asset - Asset to vest
52
+ * @param recipient - Recipient address
53
+ * @param vestingSchedule - Array of vesting tranches
54
+ * @returns Promise<SponsorshipResult>
55
+ */
56
+ createSponsoredVesting(sponsorSecret: string, sourceSecret: string, asset: {
57
+ code: string;
58
+ issuer?: string;
59
+ }, recipient: string, vestingSchedule: Array<{
60
+ amount: string;
61
+ unlockTime: number;
62
+ }>): Promise<SponsorshipResult>;
63
+ /**
64
+ * Creates a sponsored escrow-style claimable balance
65
+ * Can be claimed by either party under different conditions
66
+ * @param sponsorSecret - Sponsor's secret key
67
+ * @param sourceSecret - Source account's secret key
68
+ * @param asset - Asset to escrow
69
+ * @param amount - Amount to escrow
70
+ * @param partyA - First party's public key
71
+ * @param partyB - Second party's public key
72
+ * @param releaseTime - Time when partyA can claim (partyB can claim anytime)
73
+ * @returns Promise<SponsorshipResult>
74
+ */
75
+ createSponsoredEscrow(sponsorSecret: string, sourceSecret: string, asset: {
76
+ code: string;
77
+ issuer?: string;
78
+ }, amount: string, partyA: string, partyB: string, releaseTime: number): Promise<SponsorshipResult>;
79
+ /**
80
+ * Helper to create a linear vesting schedule
81
+ * @param totalAmount - Total amount to vest
82
+ * @param tranches - Number of vesting tranches
83
+ * @param startTime - Unix timestamp of first unlock
84
+ * @param intervalSeconds - Seconds between each tranche
85
+ * @returns Array of vesting tranches
86
+ */
87
+ static createLinearVestingSchedule(totalAmount: string, tranches: number, startTime: number, intervalSeconds: number): Array<{
88
+ amount: string;
89
+ unlockTime: number;
90
+ }>;
91
+ /**
92
+ * Estimates transaction fee
93
+ */
94
+ private estimateFee;
95
+ }
96
+ //# sourceMappingURL=claimable-balance-template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claimable-balance-template.d.ts","sourceRoot":"","sources":["../../../src/sponsored-reserves/templates/claimable-balance-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAEL,iBAAiB,EAGlB,MAAM,mCAAmC,CAAC;AAQ3C;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,aAAa,CAAgB;IAErC;;;OAGG;gBACS,aAAa,EAAE,aAAa;IAKxC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,EACxC,UAAU,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,EAC1D,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAoG/B;;;;;;;;OAQG;IACG,sBAAsB,CAC1B,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MA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