@flashbacktech/flashbackclient 0.1.39 → 0.1.40

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 (50) hide show
  1. package/dist/stellarv2/wallet/transaction.js +0 -1
  2. package/package.json +1 -1
  3. package/dist/api/types.d.ts +0 -89
  4. package/dist/api/types.js +0 -20
  5. package/dist/consumer/file/delete.d.ts +0 -3
  6. package/dist/consumer/file/delete.js +0 -23
  7. package/dist/consumer/file/getUrl.d.ts +0 -3
  8. package/dist/consumer/file/getUrl.js +0 -20
  9. package/dist/consumer/file/index.d.ts +0 -30
  10. package/dist/consumer/file/index.js +0 -52
  11. package/dist/consumer/file/types.d.ts +0 -25
  12. package/dist/consumer/file/types.js +0 -2
  13. package/dist/consumer/file/upload.d.ts +0 -3
  14. package/dist/consumer/file/upload.js +0 -75
  15. package/dist/consumer/index.d.ts +0 -1
  16. package/dist/consumer/index.js +0 -17
  17. package/dist/stellar/client.d.ts +0 -282
  18. package/dist/stellar/client.js +0 -453
  19. package/dist/stellar/consumer.d.ts +0 -10
  20. package/dist/stellar/consumer.js +0 -86
  21. package/dist/stellar/decorator.d.ts +0 -1
  22. package/dist/stellar/decorator.js +0 -33
  23. package/dist/stellar/index.d.ts +0 -4
  24. package/dist/stellar/index.js +0 -5
  25. package/dist/stellar/models.d.ts +0 -55
  26. package/dist/stellar/models.js +0 -2
  27. package/dist/stellar/provider.d.ts +0 -10
  28. package/dist/stellar/provider.js +0 -86
  29. package/dist/stellar/reservation.d.ts +0 -8
  30. package/dist/stellar/reservation.js +0 -61
  31. package/dist/stellar/stats.d.ts +0 -4
  32. package/dist/stellar/stats.js +0 -12
  33. package/dist/stellar/transaction.d.ts +0 -24
  34. package/dist/stellar/transaction.js +0 -138
  35. package/dist/stellar/unit.d.ts +0 -12
  36. package/dist/stellar/unit.js +0 -100
  37. package/dist/stellarv2/bucket.d.ts +0 -111
  38. package/dist/stellarv2/bucket.js +0 -262
  39. package/dist/stellarv2/client.d.ts +0 -134
  40. package/dist/stellarv2/client.js +0 -240
  41. package/dist/stellarv2/consumer.d.ts +0 -60
  42. package/dist/stellarv2/consumer.js +0 -145
  43. package/dist/stellarv2/deal.d.ts +0 -160
  44. package/dist/stellarv2/deal.js +0 -357
  45. package/dist/stellarv2/funding.d.ts +0 -46
  46. package/dist/stellarv2/funding.js +0 -86
  47. package/dist/stellarv2/provider.d.ts +0 -72
  48. package/dist/stellarv2/provider.js +0 -174
  49. package/dist/stellarv2/transaction.d.ts +0 -36
  50. package/dist/stellarv2/transaction.js +0 -168
@@ -1,453 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.FlashOnStellarClient = void 0;
13
- const provider_js_1 = require("./provider.js");
14
- const consumer_js_1 = require("./consumer.js");
15
- const unit_js_1 = require("./unit.js");
16
- const reservation_js_1 = require("./reservation.js");
17
- const transaction_js_1 = require("./transaction.js");
18
- const decorator_js_1 = require("./decorator.js");
19
- const stats_js_1 = require("./stats.js");
20
- /**
21
- * Main client class for interacting with the FlashOnStellar system
22
- * This client provides methods for managing providers, consumers, units, and reservations
23
- * on the Stellar blockchain.
24
- */
25
- class FlashOnStellarClient {
26
- getContext() {
27
- return {
28
- network: this.network,
29
- signTransaction: this.signTransaction,
30
- contractAddress: this.contractAddress,
31
- };
32
- }
33
- /**
34
- * Creates a new instance of the FlashOnStellarClient
35
- * @param config - Configuration options for the client
36
- */
37
- constructor(config) {
38
- /**
39
- * Derives a public key from a private key
40
- * @param privateKey - Stellar private key
41
- * @returns The corresponding public key
42
- */
43
- this.getPublicKey = (privateKey) => {
44
- return (0, transaction_js_1.getPublicKeyFromPrivateKey)(privateKey);
45
- };
46
- /**
47
- * Signs a transaction using the provided private key using Stellar SDK
48
- * The alternative is providing your own signing function (for example, using Wallet Kit).
49
- * @param xdrToSign - XDR-encoded transaction to sign
50
- * @param privateKey - Stellar private key to sign with
51
- * @returns Promise resolving to the signed XDR string
52
- */
53
- this.signTransactionWithKey = async (xdrToSign, privateKey) => {
54
- const signedTx = await (0, transaction_js_1.signTransaction)(this.getContext(), xdrToSign, privateKey);
55
- return signedTx.toXDR();
56
- };
57
- // Stats methods
58
- /**
59
- * Retrieves stats for the current user
60
- * @param wallet_address - Address of the wallet requesting the information
61
- * @returns Promise resolving to DashboardStats object
62
- */
63
- this.get_stats = (wallet_address) => {
64
- return (0, stats_js_1.get_stats)(this.getContext(), wallet_address);
65
- };
66
- // Provider methods
67
- /**
68
- * Retrieves provider information
69
- * @param wallet_address - Address of the wallet requesting the information
70
- * @param provider_address - Address of the provider to retrieve
71
- * @param load_units - Optional flag to include provider's units in the response
72
- * @returns Promise resolving to StorageProvider object
73
- */
74
- this.get_provider = (wallet_address, provider_address, load_units) => {
75
- return (0, provider_js_1.get_provider)(this.getContext(), wallet_address, provider_address, load_units);
76
- };
77
- /**
78
- * Retrieves all units associated with a provider
79
- * @param wallet_address - Address of the wallet requesting the information
80
- * @param provider_address - Address of the provider
81
- * @returns Promise resolving to an array of StorageUnit objects
82
- */
83
- this.get_provider_units = (wallet_address, provider_address) => {
84
- return (0, provider_js_1.get_provider_units)(this.getContext(), wallet_address, provider_address);
85
- };
86
- /**
87
- * Retrieves a paginated list of providers
88
- * @param wallet_address - Address of the wallet requesting the information
89
- * @param skip - Number of items to skip for pagination
90
- * @param take - Number of items to take per page
91
- * @returns Promise resolving to an array of StorageProvider objects
92
- */
93
- this.get_providers = (wallet_address, skip = 0, take = 10) => {
94
- return (0, provider_js_1.get_providers)(this.getContext(), wallet_address, skip, take);
95
- };
96
- /**
97
- * Gets the total count of providers in the system
98
- * @param wallet_address - Address of the wallet requesting the information
99
- * @returns Promise resolving to the total number of providers
100
- */
101
- this.get_provider_count = (wallet_address) => {
102
- return (0, provider_js_1.get_provider_count)(this.getContext(), wallet_address);
103
- };
104
- // Consumer methods
105
- /**
106
- * Retrieves consumer information
107
- * @param wallet_address - Address of the wallet requesting the information
108
- * @param consumer_address - Address of the consumer to retrieve
109
- * @param load_reservations - Optional flag to include consumer's reservations
110
- * @returns Promise resolving to StorageConsumer object
111
- */
112
- this.get_consumer = (wallet_address, consumer_address, load_reservations) => {
113
- return (0, consumer_js_1.get_consumer)(this.getContext(), wallet_address, consumer_address, load_reservations);
114
- };
115
- /**
116
- * Retrieves a paginated list of consumers
117
- * @param wallet_address - Address of the wallet requesting the information
118
- * @param skip - Number of items to skip for pagination
119
- * @param take - Number of items to take per page
120
- * @returns Promise resolving to an array of StorageConsumer objects
121
- */
122
- this.get_consumers = (wallet_address, skip = 0, take = 10) => {
123
- return (0, consumer_js_1.get_consumers)(this.getContext(), wallet_address, skip, take);
124
- };
125
- /**
126
- * Gets the total count of consumers in the system
127
- * @param wallet_address - Address of the wallet requesting the information
128
- * @returns Promise resolving to the total number of consumers
129
- */
130
- this.get_consumer_count = (wallet_address) => {
131
- return (0, consumer_js_1.get_consumer_count)(this.getContext(), wallet_address);
132
- };
133
- /**
134
- * Retrieves all reservations associated with a consumer
135
- * @param wallet_address - Address of the wallet requesting the information
136
- * @param consumer_address - Address of the consumer
137
- * @returns Promise resolving to an array of StorageReservation objects
138
- */
139
- this.get_consumer_reservations = (wallet_address, consumer_address) => {
140
- return (0, consumer_js_1.get_consumer_reservations)(this.getContext(), wallet_address, consumer_address);
141
- };
142
- /**
143
- * Retrieves storage unit information
144
- * @param wallet_address - Address of the wallet requesting the information
145
- * @param unit_id - Identifier of the storage unit
146
- * @param load_reservations - Optional flag to include unit's reservations
147
- * @returns Promise resolving to StorageUnit object
148
- */
149
- this.get_unit = (wallet_address, unit_id, load_reservations) => {
150
- return (0, unit_js_1.get_unit)(this.getContext(), wallet_address, unit_id, load_reservations);
151
- };
152
- /**
153
- * Retrieves all reservations for a specific storage unit
154
- * @param wallet_address - Address of the wallet requesting the information
155
- * @param unit_id - Identifier of the storage unit
156
- * @returns Promise resolving to an array of StorageReservation objects
157
- */
158
- this.get_unit_reservations = (wallet_address, unit_id) => {
159
- return (0, unit_js_1.get_unit_reservations)(this.getContext(), wallet_address, unit_id);
160
- };
161
- // Reservation methods
162
- /**
163
- * Retrieves information about a specific reservation
164
- * @param wallet_address - Address of the wallet requesting the information
165
- * @param reservation_id - Identifier of the reservation
166
- * @returns Promise resolving to StorageReservation object
167
- */
168
- this.get_reservation = (wallet_address, reservation_id) => {
169
- return (0, reservation_js_1.get_reservation)(this.getContext(), wallet_address, reservation_id);
170
- };
171
- this.signTransaction = config.signTransaction;
172
- this.contractAddress = config.contractAddress;
173
- this.network = config.network;
174
- }
175
- /**
176
- * Registers a new provider in the system
177
- * @param wallet_address - Address of the wallet registering the provider
178
- * @param provider_address - Address for the new provider
179
- * @param provider_description - Description of the provider
180
- * @returns Promise resolving to the registration transaction result
181
- * @requires Signature - This method requires a transaction signature
182
- * @throws Will throw if provider address is already registered
183
- */
184
- register_provider(wallet_address, provider_address, provider_description) {
185
- return (0, provider_js_1.register_provider)(this.getContext(), wallet_address, provider_address, provider_description);
186
- }
187
- /**
188
- * Deletes a provider from the system
189
- * @param wallet_address - Address of the wallet making the request
190
- * @param provider_address - Address of the provider to delete
191
- * @returns Promise resolving to the deletion transaction result
192
- * @requires Signature - This method requires a transaction signature
193
- */
194
- delete_provider(wallet_address, provider_address) {
195
- return (0, provider_js_1.delete_provider)(this.getContext(), wallet_address, provider_address);
196
- }
197
- /**
198
- * Updates provider information
199
- * @param wallet_address - Address of the wallet making the request
200
- * @param provider_address - Address of the provider to update
201
- * @param provider_description - New description for the provider
202
- * @returns Promise resolving to the update transaction result
203
- * @requires Signature - This method requires a transaction signature
204
- */
205
- update_provider(wallet_address, provider_address, provider_description) {
206
- return (0, provider_js_1.update_provider)(this.getContext(), wallet_address, provider_address, provider_description);
207
- }
208
- /**
209
- * Registers a new consumer in the system
210
- * @param wallet_address - Address of the wallet registering the consumer
211
- * @param consumer_address - Address for the new consumer
212
- * @param consumer_description - Description of the consumer
213
- * @returns Promise resolving to the registration transaction result
214
- * @requires Signature - This method requires a transaction signature
215
- */
216
- register_consumer(wallet_address, consumer_address, consumer_description) {
217
- return (0, consumer_js_1.register_consumer)(this.getContext(), wallet_address, consumer_address, consumer_description);
218
- }
219
- delete_consumer(wallet_address, consumer_address) {
220
- return (0, consumer_js_1.delete_consumer)(this.getContext(), wallet_address, consumer_address);
221
- }
222
- update_consumer(wallet_address, consumer_address, consumer_description) {
223
- return (0, consumer_js_1.update_consumer)(this.getContext(), wallet_address, consumer_address, consumer_description);
224
- }
225
- // Unit methods
226
- /**
227
- * Registers a new storage unit in the system
228
- * @param wallet_address - Address of the wallet registering the unit
229
- * @param provider_address - Address of the provider owning the unit
230
- * @param capacity - Capacity of the storage unit in gigabytes
231
- * @param endpoint - Endpoint for the storage unit
232
- * @returns Promise resolving to the registration transaction result
233
- * @requires Signature - This method requires a transaction signature
234
- */
235
- register_unit(wallet_address, provider_address, capacity, endpoint) {
236
- return (0, unit_js_1.register_unit)(this.getContext(), wallet_address, provider_address, capacity, endpoint);
237
- }
238
- /**
239
- * Deletes a storage unit from the system
240
- * @param wallet_address - Address of the wallet making the request
241
- * @param provider_address - Address of the provider owning the unit
242
- * @param unit_id - Identifier of the storage unit
243
- * @returns Promise resolving to the deletion transaction result
244
- * @requires Signature - This method requires a transaction signature
245
- * @throws Will throw if unit has active reservations
246
- */
247
- delete_unit(wallet_address, provider_address, unit_id) {
248
- return (0, unit_js_1.delete_unit)(this.getContext(), wallet_address, provider_address, unit_id);
249
- }
250
- /**
251
- * Places a storage unit into maintenance mode
252
- * @param wallet_address - Address of the wallet making the request
253
- * @param provider_address - Address of the provider owning the unit
254
- * @param unit_id - Identifier of the storage unit
255
- * @param maintenance_start - Start date of maintenance period
256
- * @param maintenance_end - End date of maintenance period
257
- * @returns Promise resolving to the maintenance transaction result
258
- * @requires Signature - This method requires a transaction signature
259
- * @throws Will throw if unit has active reservations that conflict with the maintenance window
260
- */
261
- enter_maintenance(wallet_address, provider_address, unit_id, maintenance_start, maintenance_end) {
262
- return (0, unit_js_1.enter_maintenance)(this.getContext(), wallet_address, provider_address, unit_id, maintenance_start, maintenance_end);
263
- }
264
- /**
265
- * Exits maintenance mode for a storage unit
266
- * @param wallet_address - Address of the wallet making the request
267
- * @param provider_address - Address of the provider owning the unit
268
- * @param unit_id - Identifier of the storage unit
269
- * @returns Promise resolving to the maintenance exit transaction result
270
- * @requires Signature - This method requires a transaction signature
271
- * @throws Will throw if unit is not in maintenance mode
272
- */
273
- exit_maintenance(wallet_address, provider_address, unit_id) {
274
- return (0, unit_js_1.exit_maintenance)(this.getContext(), wallet_address, provider_address, unit_id);
275
- }
276
- /**
277
- * Places a storage unit into decommissioning mode
278
- * This starts the process of removing the unit from service.
279
- * @param wallet_address - Address of the wallet making the request
280
- * @param provider_address - Address of the provider owning the unit
281
- * @param unit_id - Identifier of the storage unit
282
- * @returns Promise resolving to the decommissioning transaction result
283
- * @requires Signature - This method requires a transaction signature
284
- * @throws Will throw if unit has active reservations
285
- */
286
- enter_decommissioning(wallet_address, provider_address, unit_id) {
287
- return (0, unit_js_1.enter_decommissioning)(this.getContext(), wallet_address, provider_address, unit_id);
288
- }
289
- /**
290
- * Exits decommissioning mode for a storage unit
291
- * This cancels the decommissioning process and returns the unit to service.
292
- * @param wallet_address - Address of the wallet making the request
293
- * @param provider_address - Address of the provider owning the unit
294
- * @param unit_id - Identifier of the storage unit
295
- * @returns Promise resolving to the decommissioning exit transaction result
296
- * @requires Signature - This method requires a transaction signature
297
- * @throws Will throw if unit is not in decommissioning mode
298
- */
299
- exit_decommissioning(wallet_address, provider_address, unit_id) {
300
- return (0, unit_js_1.exit_decommissioning)(this.getContext(), wallet_address, provider_address, unit_id);
301
- }
302
- /**
303
- * Creates a new storage reservation
304
- * @param wallet_address - Address of the wallet making the request
305
- * @param consumer_address - Address of the consumer requesting storage
306
- * @param unit_id - Identifier of the storage unit to reserve
307
- * @param reserved_gb - Amount of storage to reserve in gigabytes
308
- * @returns Promise resolving to the reservation creation transaction result
309
- * @requires Signature - This method requires a transaction signature
310
- * @throws Will throw if unit doesn't have enough available capacity
311
- * @throws Will throw if unit is in maintenance or decommissioning mode
312
- */
313
- reserve_unit(wallet_address, consumer_address, unit_id, reserved_gb) {
314
- return (0, reservation_js_1.create_reservation)(this.getContext(), wallet_address, consumer_address, unit_id, reserved_gb);
315
- }
316
- /**
317
- * Deletes an existing reservation
318
- * @param wallet_address - Address of the wallet making the request
319
- * @param consumer_address - Address of the consumer who owns the reservation
320
- * @param reservation_id - Identifier of the reservation to delete
321
- * @returns Promise resolving to the reservation deletion transaction result
322
- * @requires Signature - This method requires a transaction signature
323
- * @throws Will throw if reservation has non-zero inuse_bytes
324
- */
325
- delete_reservation(wallet_address, consumer_address, reservation_id) {
326
- return (0, reservation_js_1.delete_reservation)(this.getContext(), wallet_address, consumer_address, reservation_id);
327
- }
328
- /**
329
- * Updates the amount of storage currently in use by a consumer
330
- * @param wallet_address - Address of the wallet making the request
331
- * @param consumer_address - Address of the consumer
332
- * @param reservation_id - Identifier of the reservation
333
- * @param inuse_bytes - Current number of bytes in use
334
- * @returns Promise resolving to the update transaction result
335
- * @requires Signature - This method requires a transaction signature
336
- * @throws Will throw if inuse_bytes exceeds reserved amount
337
- */
338
- update_inuse_bytes_consumer(wallet_address, consumer_address, reservation_id, inuse_bytes) {
339
- return (0, reservation_js_1.update_inuse_bytes_consumer)(this.getContext(), wallet_address, consumer_address, reservation_id, inuse_bytes);
340
- }
341
- /**
342
- * Updates the amount of storage currently in use, reported by provider
343
- * @param wallet_address - Address of the wallet making the request
344
- * @param provider_address - Address of the provider
345
- * @param reservation_id - Identifier of the reservation
346
- * @param inuse_bytes - Current number of bytes in use
347
- * @returns Promise resolving to the update transaction result
348
- * @requires Signature - This method requires a transaction signature
349
- * @throws Will throw if inuse_bytes exceeds reserved amount
350
- * @throws Will throw if provider's report differs significantly from consumer's report
351
- */
352
- update_inuse_bytes_provider(wallet_address, provider_address, reservation_id, inuse_bytes) {
353
- return (0, reservation_js_1.update_inuse_bytes_provider)(this.getContext(), wallet_address, provider_address, reservation_id, inuse_bytes);
354
- }
355
- }
356
- exports.FlashOnStellarClient = FlashOnStellarClient;
357
- __decorate([
358
- decorator_js_1.requiresSignature,
359
- __metadata("design:type", Function),
360
- __metadata("design:paramtypes", [String, String, String]),
361
- __metadata("design:returntype", void 0)
362
- ], FlashOnStellarClient.prototype, "register_provider", null);
363
- __decorate([
364
- decorator_js_1.requiresSignature,
365
- __metadata("design:type", Function),
366
- __metadata("design:paramtypes", [String, String]),
367
- __metadata("design:returntype", void 0)
368
- ], FlashOnStellarClient.prototype, "delete_provider", null);
369
- __decorate([
370
- decorator_js_1.requiresSignature,
371
- __metadata("design:type", Function),
372
- __metadata("design:paramtypes", [String, String, String]),
373
- __metadata("design:returntype", void 0)
374
- ], FlashOnStellarClient.prototype, "update_provider", null);
375
- __decorate([
376
- decorator_js_1.requiresSignature,
377
- __metadata("design:type", Function),
378
- __metadata("design:paramtypes", [String, String, String]),
379
- __metadata("design:returntype", void 0)
380
- ], FlashOnStellarClient.prototype, "register_consumer", null);
381
- __decorate([
382
- decorator_js_1.requiresSignature,
383
- __metadata("design:type", Function),
384
- __metadata("design:paramtypes", [String, String]),
385
- __metadata("design:returntype", void 0)
386
- ], FlashOnStellarClient.prototype, "delete_consumer", null);
387
- __decorate([
388
- decorator_js_1.requiresSignature,
389
- __metadata("design:type", Function),
390
- __metadata("design:paramtypes", [String, String, String]),
391
- __metadata("design:returntype", void 0)
392
- ], FlashOnStellarClient.prototype, "update_consumer", null);
393
- __decorate([
394
- decorator_js_1.requiresSignature,
395
- __metadata("design:type", Function),
396
- __metadata("design:paramtypes", [String, String, Number, String]),
397
- __metadata("design:returntype", void 0)
398
- ], FlashOnStellarClient.prototype, "register_unit", null);
399
- __decorate([
400
- decorator_js_1.requiresSignature,
401
- __metadata("design:type", Function),
402
- __metadata("design:paramtypes", [String, String, Number]),
403
- __metadata("design:returntype", void 0)
404
- ], FlashOnStellarClient.prototype, "delete_unit", null);
405
- __decorate([
406
- decorator_js_1.requiresSignature,
407
- __metadata("design:type", Function),
408
- __metadata("design:paramtypes", [String, String, Number, Date,
409
- Date]),
410
- __metadata("design:returntype", void 0)
411
- ], FlashOnStellarClient.prototype, "enter_maintenance", null);
412
- __decorate([
413
- decorator_js_1.requiresSignature,
414
- __metadata("design:type", Function),
415
- __metadata("design:paramtypes", [String, String, Number]),
416
- __metadata("design:returntype", void 0)
417
- ], FlashOnStellarClient.prototype, "exit_maintenance", null);
418
- __decorate([
419
- decorator_js_1.requiresSignature,
420
- __metadata("design:type", Function),
421
- __metadata("design:paramtypes", [String, String, Number]),
422
- __metadata("design:returntype", void 0)
423
- ], FlashOnStellarClient.prototype, "enter_decommissioning", null);
424
- __decorate([
425
- decorator_js_1.requiresSignature,
426
- __metadata("design:type", Function),
427
- __metadata("design:paramtypes", [String, String, Number]),
428
- __metadata("design:returntype", void 0)
429
- ], FlashOnStellarClient.prototype, "exit_decommissioning", null);
430
- __decorate([
431
- decorator_js_1.requiresSignature,
432
- __metadata("design:type", Function),
433
- __metadata("design:paramtypes", [String, String, Number, Number]),
434
- __metadata("design:returntype", void 0)
435
- ], FlashOnStellarClient.prototype, "reserve_unit", null);
436
- __decorate([
437
- decorator_js_1.requiresSignature,
438
- __metadata("design:type", Function),
439
- __metadata("design:paramtypes", [String, String, Number]),
440
- __metadata("design:returntype", void 0)
441
- ], FlashOnStellarClient.prototype, "delete_reservation", null);
442
- __decorate([
443
- decorator_js_1.requiresSignature,
444
- __metadata("design:type", Function),
445
- __metadata("design:paramtypes", [String, String, Number, Number]),
446
- __metadata("design:returntype", void 0)
447
- ], FlashOnStellarClient.prototype, "update_inuse_bytes_consumer", null);
448
- __decorate([
449
- decorator_js_1.requiresSignature,
450
- __metadata("design:type", Function),
451
- __metadata("design:paramtypes", [String, String, Number, Number]),
452
- __metadata("design:returntype", void 0)
453
- ], FlashOnStellarClient.prototype, "update_inuse_bytes_provider", null);
@@ -1,10 +0,0 @@
1
- import { ClientContext } from './client.js';
2
- import { StorageConsumer, StorageReservation } from './models.js';
3
- declare const get_consumer: (context: ClientContext, wallet_address: string, consumer_address: string, load_reservations?: boolean) => Promise<StorageConsumer | null>;
4
- declare const get_consumers: (context: ClientContext, wallet_address: string, skip?: number, take?: number) => Promise<Map<string, StorageConsumer>>;
5
- declare const get_consumer_count: (context: ClientContext, wallet_address: string) => Promise<number>;
6
- declare const get_consumer_reservations: (context: ClientContext, wallet_address: string, consumer_address: string) => Promise<Map<number, StorageReservation>>;
7
- declare const register_consumer: (context: ClientContext, wallet_address: string, consumer_address: string, consumer_description: string) => Promise<void>;
8
- declare const delete_consumer: (context: ClientContext, wallet_address: string, consumer_address: string) => Promise<void>;
9
- declare const update_consumer: (context: ClientContext, wallet_address: string, consumer_address: string, consumer_description: string) => Promise<void>;
10
- export { get_consumer, get_consumers, get_consumer_count, get_consumer_reservations, register_consumer, delete_consumer, update_consumer, };
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.update_consumer = exports.delete_consumer = exports.register_consumer = exports.get_consumer_reservations = exports.get_consumer_count = exports.get_consumers = exports.get_consumer = void 0;
4
- const transaction_js_1 = require("./transaction.js");
5
- const get_consumer = async (context, wallet_address, consumer_address, load_reservations = false) => {
6
- const [consumer, reservations] = await Promise.all([
7
- (0, transaction_js_1.prepareTransaction)(context, wallet_address, {
8
- method: 'get_consumer',
9
- args: [{ value: consumer_address, type: 'address' }],
10
- }),
11
- load_reservations
12
- ? get_consumer_reservations(context, wallet_address, consumer_address)
13
- : new Map(),
14
- ]);
15
- const typedConsumerData = consumer.isSuccess ? consumer.result : null;
16
- if (typedConsumerData) {
17
- typedConsumerData.reservations = reservations;
18
- }
19
- return typedConsumerData;
20
- };
21
- exports.get_consumer = get_consumer;
22
- const get_consumers = async (context, wallet_address, skip = 0, take = 10) => {
23
- const response = await (0, transaction_js_1.prepareTransaction)(context, wallet_address, {
24
- method: 'get_consumers',
25
- args: [
26
- { value: skip, type: 'u32' },
27
- { value: take, type: 'u32' },
28
- ],
29
- });
30
- if (!response.isSuccess) {
31
- return new Map();
32
- }
33
- // Convert the plain object to a Map
34
- const consumersObj = response.result;
35
- return new Map(Object.entries(consumersObj));
36
- };
37
- exports.get_consumers = get_consumers;
38
- const get_consumer_count = async (context, wallet_address) => {
39
- const response = await (0, transaction_js_1.prepareTransaction)(context, wallet_address, {
40
- method: 'get_consumer_count',
41
- });
42
- return response.isSuccess ? response.result : 0;
43
- };
44
- exports.get_consumer_count = get_consumer_count;
45
- const get_consumer_reservations = async (context, wallet_address, consumer_address) => {
46
- const response = await (0, transaction_js_1.prepareTransaction)(context, wallet_address, {
47
- method: 'get_consumer_reservations',
48
- args: [{ value: consumer_address, type: 'address' }],
49
- });
50
- const typedConsumerReservations = response.isSuccess
51
- ? response.result
52
- : new Map();
53
- return typedConsumerReservations;
54
- };
55
- exports.get_consumer_reservations = get_consumer_reservations;
56
- const executeConsumerTransaction = async (context, wallet_address, consumer_address, method, additionalArgs = []) => {
57
- const is_owner = wallet_address !== consumer_address;
58
- const response = await (0, transaction_js_1.prepareTransaction)(context, wallet_address, {
59
- method,
60
- args: [
61
- { value: consumer_address, type: 'address' },
62
- ...additionalArgs,
63
- { value: is_owner, type: 'bool' },
64
- ],
65
- });
66
- if (response.isSuccess && !response.isReadOnly) {
67
- const signedTxXDR = await context.signTransaction(response.result);
68
- await (0, transaction_js_1.sendTransaction)(context, signedTxXDR);
69
- }
70
- };
71
- const register_consumer = async (context, wallet_address, consumer_address, consumer_description) => {
72
- await executeConsumerTransaction(context, wallet_address, consumer_address, 'register_consumer', [
73
- { value: consumer_description, type: 'string' },
74
- ]);
75
- };
76
- exports.register_consumer = register_consumer;
77
- const delete_consumer = async (context, wallet_address, consumer_address) => {
78
- await executeConsumerTransaction(context, wallet_address, consumer_address, 'delete_consumer');
79
- };
80
- exports.delete_consumer = delete_consumer;
81
- const update_consumer = async (context, wallet_address, consumer_address, consumer_description) => {
82
- await executeConsumerTransaction(context, wallet_address, consumer_address, 'update_consumer', [
83
- { value: consumer_description, type: 'string' },
84
- ]);
85
- };
86
- exports.update_consumer = update_consumer;
@@ -1 +0,0 @@
1
- export declare function requiresSignature(target: any, propertyKey: string | symbol, descriptor?: PropertyDescriptor): any;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requiresSignature = requiresSignature;
4
- function requiresSignature(target, propertyKey, descriptor) {
5
- if (descriptor) {
6
- // Method decorator
7
- const originalMethod = descriptor.value;
8
- descriptor.value = function (...args) {
9
- const context = this.getContext();
10
- if (!context.signTransaction) {
11
- throw new Error('FlashOnStellarClient: signTransaction method is required for write operations');
12
- }
13
- return originalMethod.apply(this, args);
14
- };
15
- return descriptor;
16
- }
17
- // Property decorator (for arrow functions)
18
- const propertyDescriptor = {
19
- configurable: true,
20
- enumerable: true,
21
- get() {
22
- const value = target[propertyKey];
23
- return (...args) => {
24
- const context = this.getContext();
25
- if (!context.signTransaction) {
26
- throw new Error('FlashOnStellarClient: signTransaction method is required for write operations');
27
- }
28
- return value.apply(this, args);
29
- };
30
- },
31
- };
32
- Object.defineProperty(target, propertyKey, propertyDescriptor);
33
- }
@@ -1,4 +0,0 @@
1
- import { StellarNetwork } from './transaction.js';
2
- import { FlashOnStellarClient, FlashOnStellarClientConfig } from './client.js';
3
- export type * from './models.js';
4
- export { StellarNetwork, FlashOnStellarClient, FlashOnStellarClientConfig };
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlashOnStellarClient = void 0;
4
- const client_js_1 = require("./client.js");
5
- Object.defineProperty(exports, "FlashOnStellarClient", { enumerable: true, get: function () { return client_js_1.FlashOnStellarClient; } });
@@ -1,55 +0,0 @@
1
- interface StorageConsumer {
2
- description: string;
3
- reputation: number;
4
- registered_ts: number;
5
- last_update_ts: number;
6
- reservations: Map<number, StorageReservation>;
7
- reservations_count: number;
8
- }
9
- type StorageReservationStatus = 'Reserved' | 'In Use' | 'Maintenance' | 'Decommissioning';
10
- interface StorageReservation {
11
- unit_id: number;
12
- consumer_id: string;
13
- status: StorageReservationStatus | StorageReservationStatus[];
14
- reserved_gb: number;
15
- inuse_bytes_consumer: bigint;
16
- inuse_bytes_consumer_ts: bigint;
17
- inuse_bytes_provider: bigint;
18
- inuse_bytes_provider_ts: bigint;
19
- creation_ts: number;
20
- }
21
- type StorageUnitStatus = 'Available' | 'Reserved' | 'In Use' | 'Maintenance' | 'Decommissioning';
22
- type DeletionStatus = 'ReservationInUse' | 'UnitInUse' | 'UnitNotDecommissioned' | 'Unauthorized' | 'NotFound' | 'Success';
23
- interface StorageUnit {
24
- provider_id: string;
25
- address: string;
26
- status: StorageUnitStatus | StorageUnitStatus[];
27
- last_update_ts: number;
28
- maintenance_start_ts: number;
29
- maintenance_end_ts: number;
30
- previous_status: StorageUnitStatus | StorageUnitStatus[];
31
- capacity_gb: number;
32
- reserved_gb: number;
33
- inuse_bytes_provider: number;
34
- inuse_bytes_provider_ts: number;
35
- reservations_count: number;
36
- reservations: Map<number, StorageReservation>;
37
- }
38
- interface StorageProvider {
39
- units: Map<number, StorageUnit>;
40
- description: string;
41
- reputation: number;
42
- registered_ts: number;
43
- last_update_ts: number;
44
- units_count: number;
45
- }
46
- interface ContractStats {
47
- unit_count: number;
48
- total_capacity_gb: number;
49
- total_reserved_gb: number;
50
- total_inuse_bytes_consumer: number;
51
- total_inuse_bytes_provider: number;
52
- total_maintenance_gb: number;
53
- total_decommissioning_gb: number;
54
- }
55
- export type { StorageConsumer, StorageReservation, StorageUnit, StorageProvider, ContractStats, StorageUnitStatus, StorageReservationStatus, DeletionStatus, };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });