@flashbacktech/flashbackclient 0.1.30 → 0.1.32
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/api/client.js +7 -0
- package/dist/api/types/stats.d.ts +4 -0
- package/dist/stellarv2/bucket.d.ts +111 -0
- package/dist/stellarv2/bucket.js +262 -0
- package/dist/stellarv2/client.d.ts +134 -0
- package/dist/stellarv2/client.js +240 -0
- package/dist/stellarv2/consumer.d.ts +60 -0
- package/dist/stellarv2/consumer.js +145 -0
- package/dist/stellarv2/deal.d.ts +160 -0
- package/dist/stellarv2/deal.js +357 -0
- package/dist/stellarv2/funding.d.ts +46 -0
- package/dist/stellarv2/funding.js +86 -0
- package/dist/stellarv2/index.d.ts +9 -0
- package/dist/stellarv2/index.js +32 -0
- package/dist/stellarv2/models.d.ts +149 -0
- package/dist/stellarv2/models.js +49 -0
- package/dist/stellarv2/provider.d.ts +72 -0
- package/dist/stellarv2/provider.js +174 -0
- package/dist/stellarv2/transaction.d.ts +36 -0
- package/dist/stellarv2/transaction.js +168 -0
- package/package.json +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlashOnStellarClientV2 = void 0;
|
|
4
|
+
const consumer_1 = require("./consumer");
|
|
5
|
+
const provider_1 = require("./provider");
|
|
6
|
+
const bucket_1 = require("./bucket");
|
|
7
|
+
const deal_1 = require("./deal");
|
|
8
|
+
const funding_1 = require("./funding");
|
|
9
|
+
/**
|
|
10
|
+
* Main client class for interacting with the FlashOnStellar V2 system
|
|
11
|
+
* This client provides methods for managing providers, consumers, buckets, and deals
|
|
12
|
+
* on the Stellar blockchain through organized operation classes.
|
|
13
|
+
*/
|
|
14
|
+
class FlashOnStellarClientV2 {
|
|
15
|
+
getContext() {
|
|
16
|
+
return {
|
|
17
|
+
network: this.network,
|
|
18
|
+
signTransaction: this.signTransaction,
|
|
19
|
+
contractAddress: this.contractAddress,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new instance of the FlashOnStellarClient
|
|
24
|
+
* @param config - Configuration options for the client
|
|
25
|
+
*/
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.signTransaction = config.signTransaction;
|
|
28
|
+
this.contractAddress = config.contractAddress;
|
|
29
|
+
this.network = config.network;
|
|
30
|
+
// Initialize operation classes
|
|
31
|
+
const context = this.getContext();
|
|
32
|
+
this.consumers = new consumer_1.ConsumerOps(context);
|
|
33
|
+
this.providers = new provider_1.ProviderOps(context);
|
|
34
|
+
this.buckets = new bucket_1.BucketOps(context);
|
|
35
|
+
this.deals = new deal_1.DealOps(context);
|
|
36
|
+
this.funding = new funding_1.FundingOps(context);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the contract address
|
|
40
|
+
* @returns The contract address
|
|
41
|
+
*/
|
|
42
|
+
getContractAddress() {
|
|
43
|
+
return this.contractAddress;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the network configuration
|
|
47
|
+
* @returns The network configuration
|
|
48
|
+
*/
|
|
49
|
+
getNetwork() {
|
|
50
|
+
return this.network;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the version of the contract
|
|
54
|
+
* @returns Promise resolving to the contract version
|
|
55
|
+
*/
|
|
56
|
+
async getVersion() {
|
|
57
|
+
// This would call the version() method on the contract
|
|
58
|
+
// Implementation depends on the transaction layer
|
|
59
|
+
throw new Error('getVersion not implemented - requires transaction layer implementation');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets the owner address of the contract
|
|
63
|
+
* @returns Promise resolving to the owner address
|
|
64
|
+
*/
|
|
65
|
+
async getOwnerAddress() {
|
|
66
|
+
// This would call the get_owner_address() method on the contract
|
|
67
|
+
// Implementation depends on the transaction layer
|
|
68
|
+
throw new Error('getOwnerAddress not implemented - requires transaction layer implementation');
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Gets the stable asset address from the contract
|
|
72
|
+
* @returns Promise resolving to the stable asset address
|
|
73
|
+
*/
|
|
74
|
+
async getStableAssetAddress() {
|
|
75
|
+
// This would call the get_stable_asset_address() method on the contract
|
|
76
|
+
// Implementation depends on the transaction layer
|
|
77
|
+
throw new Error('getStableAssetAddress not implemented - requires transaction layer implementation');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the current ledger sequence
|
|
81
|
+
* @returns Promise resolving to the ledger sequence number
|
|
82
|
+
*/
|
|
83
|
+
async getLedgerSequence() {
|
|
84
|
+
// This would call the get_ledger_sequence() method on the contract
|
|
85
|
+
// Implementation depends on the transaction layer
|
|
86
|
+
throw new Error('getLedgerSequence not implemented - requires transaction layer implementation');
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Updates the owner address (owner only)
|
|
90
|
+
* @param new_owner - New owner address
|
|
91
|
+
* @returns Promise resolving to the update result
|
|
92
|
+
*/
|
|
93
|
+
async updateOwner(new_owner) {
|
|
94
|
+
// This would call the update_owner() method on the contract
|
|
95
|
+
// Implementation depends on the transaction layer
|
|
96
|
+
throw new Error('updateOwner not implemented - requires transaction layer implementation');
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Sets the stable asset address (owner only)
|
|
100
|
+
* @param stable_asset_address - New stable asset address
|
|
101
|
+
* @returns Promise resolving to the update result
|
|
102
|
+
*/
|
|
103
|
+
async setStableAssetAddress(stable_asset_address) {
|
|
104
|
+
// This would call the set_stable_asset_address() method on the contract
|
|
105
|
+
// Implementation depends on the transaction layer
|
|
106
|
+
throw new Error('setStableAssetAddress not implemented - requires transaction layer implementation');
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Upgrades the contract (owner only)
|
|
110
|
+
* @param new_wasm_hash - Hash of the new WASM bytecode
|
|
111
|
+
* @returns Promise resolving to the upgrade result
|
|
112
|
+
*/
|
|
113
|
+
async upgrade(new_wasm_hash) {
|
|
114
|
+
// This would call the upgrade() method on the contract
|
|
115
|
+
// Implementation depends on the transaction layer
|
|
116
|
+
throw new Error('upgrade not implemented - requires transaction layer implementation');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Gets system statistics
|
|
120
|
+
* @returns Promise resolving to system statistics
|
|
121
|
+
*/
|
|
122
|
+
async getSystemStats() {
|
|
123
|
+
try {
|
|
124
|
+
const [consumerCount, providerCount, bucketCount, dealCount] = await Promise.all([
|
|
125
|
+
this.consumers.getConsumerCount(),
|
|
126
|
+
this.providers.getProviderCount(),
|
|
127
|
+
this.buckets.getBucketCount(),
|
|
128
|
+
this.deals.getDealCount()
|
|
129
|
+
]);
|
|
130
|
+
// Get active deals count
|
|
131
|
+
const activeDeals = await this.deals.getActiveDeals(0, 1000); // Get all active deals
|
|
132
|
+
const activeDealCount = activeDeals.length;
|
|
133
|
+
return {
|
|
134
|
+
consumerCount,
|
|
135
|
+
providerCount,
|
|
136
|
+
bucketCount,
|
|
137
|
+
dealCount,
|
|
138
|
+
activeDealCount
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.error('Error getting system stats:', error);
|
|
143
|
+
return {
|
|
144
|
+
consumerCount: 0,
|
|
145
|
+
providerCount: 0,
|
|
146
|
+
bucketCount: 0,
|
|
147
|
+
dealCount: 0,
|
|
148
|
+
activeDealCount: 0
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Gets comprehensive information about a provider including their buckets and deals
|
|
154
|
+
* @param provider_id - Address of the provider
|
|
155
|
+
* @returns Promise resolving to comprehensive provider information
|
|
156
|
+
*/
|
|
157
|
+
async getProviderInfo(provider_id) {
|
|
158
|
+
try {
|
|
159
|
+
const [provider, buckets, deals, activeDeals] = await Promise.all([
|
|
160
|
+
this.providers.getProvider(provider_id),
|
|
161
|
+
this.buckets.getBucketsByProvider(provider_id),
|
|
162
|
+
this.deals.getDealsByProvider(provider_id),
|
|
163
|
+
this.deals.getActiveDeals(0, 1000) // Get all active deals and filter by provider
|
|
164
|
+
]);
|
|
165
|
+
if (!provider) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
// Filter active deals for this provider
|
|
169
|
+
const providerActiveDeals = activeDeals.filter(deal => deal.provider_id === provider_id);
|
|
170
|
+
return {
|
|
171
|
+
provider,
|
|
172
|
+
buckets,
|
|
173
|
+
deals,
|
|
174
|
+
activeDeals: providerActiveDeals
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
console.error('Error getting provider info:', error);
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Gets comprehensive information about a consumer including their deals
|
|
184
|
+
* @param consumer_id - Address of the consumer
|
|
185
|
+
* @returns Promise resolving to comprehensive consumer information
|
|
186
|
+
*/
|
|
187
|
+
async getConsumerInfo(consumer_id) {
|
|
188
|
+
try {
|
|
189
|
+
const [consumer, deals, activeDeals] = await Promise.all([
|
|
190
|
+
this.consumers.getConsumer(consumer_id),
|
|
191
|
+
this.deals.getDealsByConsumer(consumer_id),
|
|
192
|
+
this.deals.getActiveDeals(0, 1000) // Get all active deals and filter by consumer
|
|
193
|
+
]);
|
|
194
|
+
if (!consumer) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
// Filter active deals for this consumer
|
|
198
|
+
const consumerActiveDeals = activeDeals.filter(deal => deal.consumer_id === consumer_id);
|
|
199
|
+
return {
|
|
200
|
+
consumer,
|
|
201
|
+
deals,
|
|
202
|
+
activeDeals: consumerActiveDeals
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
console.error('Error getting consumer info:', error);
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Gets comprehensive information about a bucket including its provider and any active deals
|
|
212
|
+
* @param provider_id - Address of the provider
|
|
213
|
+
* @param bucket_id - ID of the bucket
|
|
214
|
+
* @returns Promise resolving to comprehensive bucket information
|
|
215
|
+
*/
|
|
216
|
+
async getBucketInfo(provider_id, bucket_id) {
|
|
217
|
+
try {
|
|
218
|
+
const [bucket, provider, activeDeals] = await Promise.all([
|
|
219
|
+
this.buckets.getBucket(provider_id, bucket_id),
|
|
220
|
+
this.providers.getProvider(provider_id),
|
|
221
|
+
this.deals.getActiveDeals(0, 1000) // Get all active deals and filter by bucket
|
|
222
|
+
]);
|
|
223
|
+
if (!bucket) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
// Filter active deals for this bucket
|
|
227
|
+
const bucketActiveDeals = activeDeals.filter(deal => deal.bucket_id === bucket_id);
|
|
228
|
+
return {
|
|
229
|
+
bucket,
|
|
230
|
+
provider,
|
|
231
|
+
activeDeals: bucketActiveDeals
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
console.error('Error getting bucket info:', error);
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
exports.FlashOnStellarClientV2 = FlashOnStellarClientV2;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ClientContext } from './client';
|
|
2
|
+
import { Consumer } from './models';
|
|
3
|
+
/**
|
|
4
|
+
* Consumer operations client for FlashOnStellar V2
|
|
5
|
+
* Implements all consumer-related contract methods
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConsumerOps {
|
|
8
|
+
private context;
|
|
9
|
+
constructor(context: ClientContext);
|
|
10
|
+
/**
|
|
11
|
+
* Registers a new consumer in the system
|
|
12
|
+
* @param consumer_id - Address of the consumer to register
|
|
13
|
+
* @param description - Description of the consumer
|
|
14
|
+
* @returns Promise resolving to the registration result
|
|
15
|
+
*/
|
|
16
|
+
registerConsumer(consumer_id: string, description: string): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Updates an existing consumer's information
|
|
19
|
+
* @param consumer_id - Address of the consumer to update
|
|
20
|
+
* @param description - New description for the consumer
|
|
21
|
+
* @returns Promise resolving to the update result
|
|
22
|
+
*/
|
|
23
|
+
updateConsumer(consumer_id: string, description: string): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Deletes a consumer from the system
|
|
26
|
+
* @param consumer_id - Address of the consumer to delete
|
|
27
|
+
* @returns Promise resolving to the deletion result
|
|
28
|
+
*/
|
|
29
|
+
deleteConsumer(consumer_id: string): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves consumer information
|
|
32
|
+
* @param consumer_id - Address of the consumer to retrieve
|
|
33
|
+
* @returns Promise resolving to Consumer object or null if not found
|
|
34
|
+
*/
|
|
35
|
+
getConsumer(consumer_id: string): Promise<Consumer | null>;
|
|
36
|
+
/**
|
|
37
|
+
* Gets the total count of consumers in the system
|
|
38
|
+
* @returns Promise resolving to the total number of consumers
|
|
39
|
+
*/
|
|
40
|
+
getConsumerCount(): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves a paginated list of consumers
|
|
43
|
+
* @param skip - Number of items to skip for pagination
|
|
44
|
+
* @param take - Number of items to take per page
|
|
45
|
+
* @returns Promise resolving to a map of consumer addresses to Consumer objects
|
|
46
|
+
*/
|
|
47
|
+
getConsumers(skip?: number, take?: number): Promise<Map<string, Consumer>>;
|
|
48
|
+
/**
|
|
49
|
+
* Gets all deals associated with a consumer
|
|
50
|
+
* @param consumer_id - Address of the consumer
|
|
51
|
+
* @returns Promise resolving to an array of deal IDs
|
|
52
|
+
*/
|
|
53
|
+
getConsumerDeals(consumer_id: string): Promise<string[]>;
|
|
54
|
+
/**
|
|
55
|
+
* Gets all active deals associated with a consumer
|
|
56
|
+
* @param consumer_id - Address of the consumer
|
|
57
|
+
* @returns Promise resolving to an array of active deal IDs
|
|
58
|
+
*/
|
|
59
|
+
getConsumerActiveDeals(consumer_id: string): Promise<string[]>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsumerOps = void 0;
|
|
4
|
+
const transaction_1 = require("./transaction");
|
|
5
|
+
/**
|
|
6
|
+
* Consumer operations client for FlashOnStellar V2
|
|
7
|
+
* Implements all consumer-related contract methods
|
|
8
|
+
*/
|
|
9
|
+
class ConsumerOps {
|
|
10
|
+
constructor(context) {
|
|
11
|
+
this.context = context;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Registers a new consumer in the system
|
|
15
|
+
* @param consumer_id - Address of the consumer to register
|
|
16
|
+
* @param description - Description of the consumer
|
|
17
|
+
* @returns Promise resolving to the registration result
|
|
18
|
+
*/
|
|
19
|
+
async registerConsumer(consumer_id, description) {
|
|
20
|
+
return (0, transaction_1.callContractMethod)(this.context, consumer_id, {
|
|
21
|
+
method: 'register_consumer',
|
|
22
|
+
args: [
|
|
23
|
+
{ value: consumer_id, type: 'address' },
|
|
24
|
+
{ value: description, type: 'string' }
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Updates an existing consumer's information
|
|
30
|
+
* @param consumer_id - Address of the consumer to update
|
|
31
|
+
* @param description - New description for the consumer
|
|
32
|
+
* @returns Promise resolving to the update result
|
|
33
|
+
*/
|
|
34
|
+
async updateConsumer(consumer_id, description) {
|
|
35
|
+
return (0, transaction_1.callContractMethod)(this.context, consumer_id, {
|
|
36
|
+
method: 'update_consumer',
|
|
37
|
+
args: [
|
|
38
|
+
{ value: consumer_id, type: 'address' },
|
|
39
|
+
{ value: description, type: 'string' }
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Deletes a consumer from the system
|
|
45
|
+
* @param consumer_id - Address of the consumer to delete
|
|
46
|
+
* @returns Promise resolving to the deletion result
|
|
47
|
+
*/
|
|
48
|
+
async deleteConsumer(consumer_id) {
|
|
49
|
+
return (0, transaction_1.callContractMethod)(this.context, consumer_id, {
|
|
50
|
+
method: 'delete_consumer',
|
|
51
|
+
args: [
|
|
52
|
+
{ value: consumer_id, type: 'address' }
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves consumer information
|
|
58
|
+
* @param consumer_id - Address of the consumer to retrieve
|
|
59
|
+
* @returns Promise resolving to Consumer object or null if not found
|
|
60
|
+
*/
|
|
61
|
+
async getConsumer(consumer_id) {
|
|
62
|
+
const result = await (0, transaction_1.callContractMethod)(this.context, consumer_id, {
|
|
63
|
+
method: 'get_consumer',
|
|
64
|
+
args: [
|
|
65
|
+
{ value: consumer_id, type: 'address' }
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
if (result && typeof result === 'object') {
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Gets the total count of consumers in the system
|
|
75
|
+
* @returns Promise resolving to the total number of consumers
|
|
76
|
+
*/
|
|
77
|
+
async getConsumerCount() {
|
|
78
|
+
const result = await (0, transaction_1.callContractMethod)(this.context, '', {
|
|
79
|
+
method: 'get_consumer_count',
|
|
80
|
+
args: []
|
|
81
|
+
});
|
|
82
|
+
if (typeof result === 'number') {
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a paginated list of consumers
|
|
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 a map of consumer addresses to Consumer objects
|
|
92
|
+
*/
|
|
93
|
+
async getConsumers(skip = 0, take = 10) {
|
|
94
|
+
const result = await (0, transaction_1.callContractMethod)(this.context, '', {
|
|
95
|
+
method: 'get_consumers',
|
|
96
|
+
args: [
|
|
97
|
+
{ value: skip, type: 'u32' },
|
|
98
|
+
{ value: take, type: 'u32' }
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
if (result && typeof result === 'object') {
|
|
102
|
+
// Convert the result to a Map<string, Consumer>
|
|
103
|
+
const consumerMap = new Map();
|
|
104
|
+
// Note: The actual conversion depends on how the contract returns the data
|
|
105
|
+
// This is a placeholder implementation
|
|
106
|
+
return consumerMap;
|
|
107
|
+
}
|
|
108
|
+
return new Map();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Gets all deals associated with a consumer
|
|
112
|
+
* @param consumer_id - Address of the consumer
|
|
113
|
+
* @returns Promise resolving to an array of deal IDs
|
|
114
|
+
*/
|
|
115
|
+
async getConsumerDeals(consumer_id) {
|
|
116
|
+
const consumer = await this.getConsumer(consumer_id);
|
|
117
|
+
if (!consumer) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
// Extract deal IDs from the consumer's deals map
|
|
121
|
+
const dealIds = [];
|
|
122
|
+
consumer.deals.forEach((_, dealId) => {
|
|
123
|
+
dealIds.push(dealId);
|
|
124
|
+
});
|
|
125
|
+
return dealIds;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Gets all active deals associated with a consumer
|
|
129
|
+
* @param consumer_id - Address of the consumer
|
|
130
|
+
* @returns Promise resolving to an array of active deal IDs
|
|
131
|
+
*/
|
|
132
|
+
async getConsumerActiveDeals(consumer_id) {
|
|
133
|
+
const consumer = await this.getConsumer(consumer_id);
|
|
134
|
+
if (!consumer) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
// Extract active deal IDs from the consumer's active_deals map
|
|
138
|
+
const activeDealIds = [];
|
|
139
|
+
consumer.active_deals.forEach((_, dealId) => {
|
|
140
|
+
activeDealIds.push(dealId);
|
|
141
|
+
});
|
|
142
|
+
return activeDealIds;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.ConsumerOps = ConsumerOps;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { ClientContext } from './client';
|
|
2
|
+
import { Deal, DealCreateParams, DealConsumptionUpdateParams, DealSLAUpdateParams } from './models';
|
|
3
|
+
/**
|
|
4
|
+
* Deal operations client for FlashOnStellar V2
|
|
5
|
+
* Implements all deal-related contract methods
|
|
6
|
+
*/
|
|
7
|
+
export declare class DealOps {
|
|
8
|
+
private context;
|
|
9
|
+
constructor(context: ClientContext);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new deal between a consumer and provider
|
|
12
|
+
* @param consumer_id - Address of the consumer creating the deal
|
|
13
|
+
* @param provider_id - Address of the provider
|
|
14
|
+
* @param bucket_id - ID of the bucket for the deal
|
|
15
|
+
* @param params - Deal creation parameters
|
|
16
|
+
* @returns Promise resolving to the created deal ID
|
|
17
|
+
*/
|
|
18
|
+
createDeal(consumer_id: string, provider_id: string, bucket_id: number, params: DealCreateParams): Promise<number>;
|
|
19
|
+
/**
|
|
20
|
+
* Sets a deal as accepted by the provider
|
|
21
|
+
* @param consumer_id - Address of the consumer
|
|
22
|
+
* @param provider_id - Address of the provider accepting the deal
|
|
23
|
+
* @param deal_id - ID of the deal to accept
|
|
24
|
+
* @returns Promise resolving to the acceptance result
|
|
25
|
+
*/
|
|
26
|
+
setDealAccepted(consumer_id: string, provider_id: string, deal_id: number): Promise<boolean>;
|
|
27
|
+
/**
|
|
28
|
+
* Sets a deal as funded by the consumer
|
|
29
|
+
* @param consumer_id - Address of the consumer funding the deal
|
|
30
|
+
* @param provider_id - Address of the provider
|
|
31
|
+
* @param deal_id - ID of the deal to fund
|
|
32
|
+
* @param amount_usd - Amount to fund in USD (scaled by 10^7)
|
|
33
|
+
* @returns Promise resolving to the funding result
|
|
34
|
+
*/
|
|
35
|
+
setDealFunded(consumer_id: string, provider_id: string, deal_id: number, amount_usd: bigint): Promise<boolean>;
|
|
36
|
+
/**
|
|
37
|
+
* Sets a deal as completed
|
|
38
|
+
* @param consumer_id - Address of the consumer
|
|
39
|
+
* @param provider_id - Address of the provider
|
|
40
|
+
* @param deal_id - ID of the deal to complete
|
|
41
|
+
* @returns Promise resolving to the completion result
|
|
42
|
+
*/
|
|
43
|
+
setDealCompleted(consumer_id: string, provider_id: string, deal_id: number): Promise<boolean>;
|
|
44
|
+
/**
|
|
45
|
+
* Sets a deal as cancelled
|
|
46
|
+
* @param consumer_id - Address of the consumer
|
|
47
|
+
* @param provider_id - Address of the provider
|
|
48
|
+
* @param deal_id - ID of the deal to cancel
|
|
49
|
+
* @returns Promise resolving to the cancellation result
|
|
50
|
+
*/
|
|
51
|
+
setDealCancelled(consumer_id: string, provider_id: string, deal_id: number): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Marks a deal as breached by the consumer
|
|
54
|
+
* @param consumer_id - Address of the consumer
|
|
55
|
+
* @param provider_id - Address of the provider
|
|
56
|
+
* @param deal_id - ID of the deal
|
|
57
|
+
* @returns Promise resolving to the breach marking result
|
|
58
|
+
*/
|
|
59
|
+
setDealBreachedConsumer(consumer_id: string, provider_id: string, deal_id: number): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Marks a deal as breached by the provider
|
|
62
|
+
* @param consumer_id - Address of the consumer
|
|
63
|
+
* @param provider_id - Address of the provider
|
|
64
|
+
* @param deal_id - ID of the deal
|
|
65
|
+
* @returns Promise resolving to the breach marking result
|
|
66
|
+
*/
|
|
67
|
+
setDealBreachedProvider(consumer_id: string, provider_id: string, deal_id: number): Promise<boolean>;
|
|
68
|
+
/**
|
|
69
|
+
* Deletes a deal from the system (owner only)
|
|
70
|
+
* @param consumer_id - Address of the consumer
|
|
71
|
+
* @param provider_id - Address of the provider
|
|
72
|
+
* @param deal_id - ID of the deal to delete
|
|
73
|
+
* @returns Promise resolving to the deletion result
|
|
74
|
+
*/
|
|
75
|
+
deleteDeal(consumer_id: string, provider_id: string, deal_id: number): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves deal information
|
|
78
|
+
* @param consumer_id - Address of the consumer
|
|
79
|
+
* @param provider_id - Address of the provider
|
|
80
|
+
* @param deal_id - ID of the deal to retrieve
|
|
81
|
+
* @returns Promise resolving to Deal object or null if not found
|
|
82
|
+
*/
|
|
83
|
+
getDeal(consumer_id: string, provider_id: string, deal_id: number): Promise<Deal | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Gets the total count of deals in the system
|
|
86
|
+
* @returns Promise resolving to the total number of deals
|
|
87
|
+
*/
|
|
88
|
+
getDealCount(): Promise<number>;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves a paginated list of all deals
|
|
91
|
+
* @param skip - Number of items to skip for pagination
|
|
92
|
+
* @param take - Number of items to take per page
|
|
93
|
+
* @returns Promise resolving to an array of Deal objects
|
|
94
|
+
*/
|
|
95
|
+
getDeals(skip?: number, take?: number): Promise<Deal[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Retrieves all deals for a specific consumer
|
|
98
|
+
* @param consumer_id - Address of the consumer
|
|
99
|
+
* @returns Promise resolving to an array of Deal objects
|
|
100
|
+
*/
|
|
101
|
+
getDealsByConsumer(consumer_id: string): Promise<Deal[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves all deals for a specific provider
|
|
104
|
+
* @param provider_id - Address of the provider
|
|
105
|
+
* @returns Promise resolving to an array of Deal objects
|
|
106
|
+
*/
|
|
107
|
+
getDealsByProvider(provider_id: string): Promise<Deal[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Retrieves all active deals
|
|
110
|
+
* @param skip - Number of items to skip for pagination
|
|
111
|
+
* @param take - Number of items to take per page
|
|
112
|
+
* @returns Promise resolving to an array of active Deal objects
|
|
113
|
+
*/
|
|
114
|
+
getActiveDeals(skip?: number, take?: number): Promise<Deal[]>;
|
|
115
|
+
/**
|
|
116
|
+
* Pays for pending consumption in a deal (owner only)
|
|
117
|
+
* @param provider_id - Address of the provider
|
|
118
|
+
* @param consumer_id - Address of the consumer
|
|
119
|
+
* @param deal_id - ID of the deal
|
|
120
|
+
* @returns Promise resolving to the payment result
|
|
121
|
+
*/
|
|
122
|
+
payPendingConsumption(provider_id: string, consumer_id: string, deal_id: number): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Updates deal consumption metrics (owner only)
|
|
125
|
+
* @param provider_id - Address of the provider
|
|
126
|
+
* @param consumer_id - Address of the consumer
|
|
127
|
+
* @param deal_id - ID of the deal
|
|
128
|
+
* @param params - Consumption update parameters
|
|
129
|
+
* @returns Promise resolving to the update result
|
|
130
|
+
*/
|
|
131
|
+
updateDealConsumption(provider_id: string, consumer_id: string, deal_id: number, params: DealConsumptionUpdateParams): Promise<boolean>;
|
|
132
|
+
/**
|
|
133
|
+
* Updates deal SLA metrics (owner only)
|
|
134
|
+
* @param provider_id - Address of the provider
|
|
135
|
+
* @param consumer_id - Address of the consumer
|
|
136
|
+
* @param deal_id - ID of the deal
|
|
137
|
+
* @param params - SLA update parameters
|
|
138
|
+
* @returns Promise resolving to the update result
|
|
139
|
+
*/
|
|
140
|
+
updateDealSLA(provider_id: string, consumer_id: string, deal_id: number, params: DealSLAUpdateParams): Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* Gets deal status information
|
|
143
|
+
* @param consumer_id - Address of the consumer
|
|
144
|
+
* @param provider_id - Address of the provider
|
|
145
|
+
* @param deal_id - ID of the deal
|
|
146
|
+
* @returns Promise resolving to deal status or null if deal not found
|
|
147
|
+
*/
|
|
148
|
+
getDealStatus(consumer_id: string, provider_id: string, deal_id: number): Promise<string | null>;
|
|
149
|
+
/**
|
|
150
|
+
* Gets deal balance information
|
|
151
|
+
* @param consumer_id - Address of the consumer
|
|
152
|
+
* @param provider_id - Address of the provider
|
|
153
|
+
* @param deal_id - ID of the deal
|
|
154
|
+
* @returns Promise resolving to deal balances or null if deal not found
|
|
155
|
+
*/
|
|
156
|
+
getDealBalances(consumer_id: string, provider_id: string, deal_id: number): Promise<{
|
|
157
|
+
balance_consumer: bigint;
|
|
158
|
+
balance_provider: bigint;
|
|
159
|
+
} | null>;
|
|
160
|
+
}
|