@flashbacktech/flashbackclient 0.1.42 → 0.1.44
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/stellarv2/client/bucket.js +0 -8
- package/dist/stellarv2/client/consumer.js +1 -5
- package/dist/stellarv2/client/deal.d.ts +1 -1
- package/dist/stellarv2/client/deal.js +1 -4
- package/dist/stellarv2/client/funding.d.ts +2 -5
- package/dist/stellarv2/client/funding.js +18 -7
- package/dist/stellarv2/client/index.d.ts +1 -1
- package/dist/stellarv2/client/index.js +16 -22
- package/dist/stellarv2/client/provider.js +1 -5
- package/dist/stellarv2/wallet/transaction.d.ts +3 -3
- package/dist/stellarv2/wallet/transaction.js +6 -3
- package/package.json +1 -1
|
@@ -19,7 +19,6 @@ class BucketOps {
|
|
|
19
19
|
const response = await (0, transaction_1.prepareTransaction)(this.context, provider_id, {
|
|
20
20
|
method: 'create_bucket',
|
|
21
21
|
args: [
|
|
22
|
-
{ value: provider_id, type: 'address' },
|
|
23
22
|
{ value: params.name, type: 'string' },
|
|
24
23
|
{ value: params.region, type: 'string' },
|
|
25
24
|
{ value: params.country, type: 'string' },
|
|
@@ -75,7 +74,6 @@ class BucketOps {
|
|
|
75
74
|
*/
|
|
76
75
|
this.updateBucketBasic = (0, decorator_1.withSignature)(async (provider_id, bucket_id, params) => {
|
|
77
76
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "update_bucket_basic", [
|
|
78
|
-
{ value: provider_id, type: 'address' },
|
|
79
77
|
{ value: bucket_id, type: 'u32' },
|
|
80
78
|
{ value: params.name || null, type: 'string' },
|
|
81
79
|
{ value: params.region || null, type: 'string' },
|
|
@@ -91,7 +89,6 @@ class BucketOps {
|
|
|
91
89
|
*/
|
|
92
90
|
this.updateBucketPricing = (0, decorator_1.withSignature)(async (provider_id, bucket_id, params) => {
|
|
93
91
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "update_bucket_pricing", [
|
|
94
|
-
{ value: provider_id, type: 'address' },
|
|
95
92
|
{ value: bucket_id, type: 'u32' },
|
|
96
93
|
{ value: params.price_per_gb_storage || null, type: 'u128' },
|
|
97
94
|
{ value: params.price_per_gb_egress || null, type: 'u128' },
|
|
@@ -108,7 +105,6 @@ class BucketOps {
|
|
|
108
105
|
*/
|
|
109
106
|
this.updateBucketSLA = (0, decorator_1.withSignature)(async (provider_id, bucket_id, params) => {
|
|
110
107
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "update_bucket_sla", [
|
|
111
|
-
{ value: provider_id, type: 'address' },
|
|
112
108
|
{ value: bucket_id, type: 'u32' },
|
|
113
109
|
{ value: params.sla_avg_latency_ms || null, type: 'u32' },
|
|
114
110
|
{ value: params.sla_avg_uptime_pct || null, type: 'u32' }
|
|
@@ -122,7 +118,6 @@ class BucketOps {
|
|
|
122
118
|
*/
|
|
123
119
|
this.lockBucket = (0, decorator_1.withSignature)(async (provider_id, bucket_id) => {
|
|
124
120
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "lock_bucket", [
|
|
125
|
-
{ value: provider_id, type: 'address' },
|
|
126
121
|
{ value: bucket_id, type: 'u32' }
|
|
127
122
|
]);
|
|
128
123
|
});
|
|
@@ -134,7 +129,6 @@ class BucketOps {
|
|
|
134
129
|
*/
|
|
135
130
|
this.unlockBucket = (0, decorator_1.withSignature)(async (provider_id, bucket_id) => {
|
|
136
131
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "unlock_bucket", [
|
|
137
|
-
{ value: provider_id, type: 'address' },
|
|
138
132
|
{ value: bucket_id, type: 'u32' }
|
|
139
133
|
]);
|
|
140
134
|
});
|
|
@@ -146,7 +140,6 @@ class BucketOps {
|
|
|
146
140
|
*/
|
|
147
141
|
this.deleteBucket = (0, decorator_1.withSignature)(async (provider_id, bucket_id) => {
|
|
148
142
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "delete_bucket", [
|
|
149
|
-
{ value: provider_id, type: 'address' },
|
|
150
143
|
{ value: bucket_id, type: 'u32' }
|
|
151
144
|
]);
|
|
152
145
|
});
|
|
@@ -162,7 +155,6 @@ class BucketOps {
|
|
|
162
155
|
const response = await (0, transaction_1.prepareTransaction)(this.context, provider_id, {
|
|
163
156
|
method: 'get_bucket',
|
|
164
157
|
args: [
|
|
165
|
-
{ value: provider_id, type: 'address' },
|
|
166
158
|
{ value: bucket_id, type: 'u32' }
|
|
167
159
|
]
|
|
168
160
|
});
|
|
@@ -17,7 +17,6 @@ class ConsumerOps {
|
|
|
17
17
|
*/
|
|
18
18
|
this.registerConsumer = (0, decorator_1.withSignature)(async (consumer_id, description) => {
|
|
19
19
|
await (0, transaction_1.executeWalletTransaction)(this.context, consumer_id, "register_consumer", [
|
|
20
|
-
{ value: consumer_id, type: 'address' },
|
|
21
20
|
{ value: description, type: 'string' }
|
|
22
21
|
]);
|
|
23
22
|
});
|
|
@@ -29,7 +28,6 @@ class ConsumerOps {
|
|
|
29
28
|
*/
|
|
30
29
|
this.updateConsumer = (0, decorator_1.withSignature)(async (consumer_id, description) => {
|
|
31
30
|
await (0, transaction_1.executeWalletTransaction)(this.context, consumer_id, "update_consumer", [
|
|
32
|
-
{ value: consumer_id, type: 'address' },
|
|
33
31
|
{ value: description, type: 'string' }
|
|
34
32
|
]);
|
|
35
33
|
});
|
|
@@ -39,9 +37,7 @@ class ConsumerOps {
|
|
|
39
37
|
* @returns Promise resolving to the deletion result
|
|
40
38
|
*/
|
|
41
39
|
this.deleteConsumer = (0, decorator_1.withSignature)(async (consumer_id) => {
|
|
42
|
-
await (0, transaction_1.executeWalletTransaction)(this.context, consumer_id, "delete_consumer", [
|
|
43
|
-
{ value: consumer_id, type: 'address' }
|
|
44
|
-
]);
|
|
40
|
+
await (0, transaction_1.executeWalletTransaction)(this.context, consumer_id, "delete_consumer", []);
|
|
45
41
|
});
|
|
46
42
|
this.context = context;
|
|
47
43
|
}
|
|
@@ -23,7 +23,7 @@ export declare class DealOps {
|
|
|
23
23
|
* @param deal_id - ID of the deal to accept
|
|
24
24
|
* @returns Promise resolving to the acceptance result
|
|
25
25
|
*/
|
|
26
|
-
setDealAccepted: (
|
|
26
|
+
setDealAccepted: (provider_id: string, consumer_id: string, deal_id: number) => Promise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Sets a deal as funded by the consumer
|
|
29
29
|
* @param consumer_id - Address of the consumer funding the deal
|
|
@@ -21,7 +21,6 @@ class DealOps {
|
|
|
21
21
|
const response = await (0, transaction_1.prepareTransaction)(this.context, consumer_id, {
|
|
22
22
|
method: 'create_deal',
|
|
23
23
|
args: [
|
|
24
|
-
{ value: consumer_id, type: 'address' },
|
|
25
24
|
{ value: provider_id, type: 'address' },
|
|
26
25
|
{ value: bucket_id, type: 'u32' },
|
|
27
26
|
{ value: params.duration_secs, type: 'u64' },
|
|
@@ -47,10 +46,9 @@ class DealOps {
|
|
|
47
46
|
* @param deal_id - ID of the deal to accept
|
|
48
47
|
* @returns Promise resolving to the acceptance result
|
|
49
48
|
*/
|
|
50
|
-
this.setDealAccepted = (0, decorator_1.withSignature)(async (
|
|
49
|
+
this.setDealAccepted = (0, decorator_1.withSignature)(async (provider_id, consumer_id, deal_id) => {
|
|
51
50
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "set_deal_accepted", [
|
|
52
51
|
{ value: consumer_id, type: 'address' },
|
|
53
|
-
{ value: provider_id, type: 'address' },
|
|
54
52
|
{ value: deal_id, type: 'u32' }
|
|
55
53
|
]);
|
|
56
54
|
});
|
|
@@ -65,7 +63,6 @@ class DealOps {
|
|
|
65
63
|
this.setDealFunded = (0, decorator_1.withSignature)(async (consumer_id, provider_id, deal_id, amount_usd) => {
|
|
66
64
|
await (0, transaction_1.executeWalletTransaction)(this.context, consumer_id, "set_deal_funded", [
|
|
67
65
|
{ value: provider_id, type: 'address' },
|
|
68
|
-
{ value: consumer_id, type: 'address' },
|
|
69
66
|
{ value: deal_id, type: 'u32' },
|
|
70
67
|
{ value: amount_usd, type: 'u128' }
|
|
71
68
|
]);
|
|
@@ -6,6 +6,8 @@ import { ClientContext } from '.';
|
|
|
6
6
|
export declare class FundingOps {
|
|
7
7
|
private context;
|
|
8
8
|
constructor(context: ClientContext);
|
|
9
|
+
getStableAssetName(): Promise<string>;
|
|
10
|
+
getStableAssetAddress(): Promise<string>;
|
|
9
11
|
/**
|
|
10
12
|
* Sends funds from the contract to a receiver (owner only)
|
|
11
13
|
* @param receiver - Address of the receiver
|
|
@@ -26,11 +28,6 @@ export declare class FundingOps {
|
|
|
26
28
|
* @returns Promise resolving to the admin change result
|
|
27
29
|
*/
|
|
28
30
|
changeAssetAdmin: (new_admin: string) => Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Gets the stable asset address from the contract
|
|
31
|
-
* @returns Promise resolving to the stable asset contract address
|
|
32
|
-
*/
|
|
33
|
-
getStableAssetAddress(): Promise<string>;
|
|
34
31
|
/**
|
|
35
32
|
* Checks if an address is authorized for the stable asset
|
|
36
33
|
* @param address - Address to check
|
|
@@ -45,14 +45,25 @@ class FundingOps {
|
|
|
45
45
|
});
|
|
46
46
|
this.context = context;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
async getStableAssetName() {
|
|
49
|
+
const response = await (0, transaction_1.prepareTransaction)(this.context, '', {
|
|
50
|
+
method: 'get_stable_asset_name',
|
|
51
|
+
args: []
|
|
52
|
+
});
|
|
53
|
+
if (response.isSuccess) {
|
|
54
|
+
return response.result;
|
|
55
|
+
}
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
52
58
|
async getStableAssetAddress() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
const response = await (0, transaction_1.prepareTransaction)(this.context, '', {
|
|
60
|
+
method: 'get_stable_asset_address',
|
|
61
|
+
args: []
|
|
62
|
+
});
|
|
63
|
+
if (response.isSuccess) {
|
|
64
|
+
return response.result;
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
56
67
|
}
|
|
57
68
|
/**
|
|
58
69
|
* Checks if an address is authorized for the stable asset
|
|
@@ -104,7 +104,7 @@ export declare class FlashOnStellarClientV2 {
|
|
|
104
104
|
deals: any[];
|
|
105
105
|
activeDeals: any[];
|
|
106
106
|
} | null>;
|
|
107
|
-
registerAsConsumerProvider(address: string, description: string)
|
|
107
|
+
registerAsConsumerProvider: (address: string, description: string) => Promise<void>;
|
|
108
108
|
/**
|
|
109
109
|
* Gets comprehensive information about a consumer including their deals
|
|
110
110
|
* @param consumer_id - Address of the consumer
|
|
@@ -26,6 +26,22 @@ class FlashOnStellarClientV2 {
|
|
|
26
26
|
* @param config - Configuration options for the client
|
|
27
27
|
*/
|
|
28
28
|
constructor(config) {
|
|
29
|
+
this.registerAsConsumerProvider = (0, decorator_1.withSignature)(async (address, description) => {
|
|
30
|
+
await (0, transaction_1.executeMultiWalletTransactions)(this.getContext(), address, [
|
|
31
|
+
{
|
|
32
|
+
method: "register_consumer",
|
|
33
|
+
additionalArgs: [
|
|
34
|
+
{ value: description, type: 'string' }
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
method: "register_provider",
|
|
39
|
+
additionalArgs: [
|
|
40
|
+
{ value: description, type: 'string' }
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
29
45
|
this.signTransaction = config.signTransaction;
|
|
30
46
|
this.contractAddress = config.contractAddress;
|
|
31
47
|
this.network = config.network;
|
|
@@ -171,28 +187,6 @@ class FlashOnStellarClientV2 {
|
|
|
171
187
|
return null;
|
|
172
188
|
}
|
|
173
189
|
}
|
|
174
|
-
async registerAsConsumerProvider(address, description) {
|
|
175
|
-
const provider_id = address;
|
|
176
|
-
const consumer_id = address;
|
|
177
|
-
(0, decorator_1.withSignature)(async (address, description) => {
|
|
178
|
-
await (0, transaction_1.executeMultiWalletTransactions)(this.getContext(), address, [
|
|
179
|
-
{
|
|
180
|
-
method: "register_consumer",
|
|
181
|
-
additionalArgs: [
|
|
182
|
-
{ value: consumer_id, type: 'address' },
|
|
183
|
-
{ value: description, type: 'string' }
|
|
184
|
-
]
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
method: "register_provider",
|
|
188
|
-
additionalArgs: [
|
|
189
|
-
{ value: provider_id, type: 'address' },
|
|
190
|
-
{ value: description, type: 'string' }
|
|
191
|
-
]
|
|
192
|
-
}
|
|
193
|
-
]);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
190
|
/**
|
|
197
191
|
* Gets comprehensive information about a consumer including their deals
|
|
198
192
|
* @param consumer_id - Address of the consumer
|
|
@@ -17,7 +17,6 @@ class ProviderOps {
|
|
|
17
17
|
*/
|
|
18
18
|
this.registerProvider = (0, decorator_1.withSignature)(async (provider_id, description) => {
|
|
19
19
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "register_provider", [
|
|
20
|
-
{ value: provider_id, type: 'address' },
|
|
21
20
|
{ value: description, type: 'string' }
|
|
22
21
|
]);
|
|
23
22
|
});
|
|
@@ -29,7 +28,6 @@ class ProviderOps {
|
|
|
29
28
|
*/
|
|
30
29
|
this.updateProvider = (0, decorator_1.withSignature)(async (provider_id, description) => {
|
|
31
30
|
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "update_provider", [
|
|
32
|
-
{ value: provider_id, type: 'address' },
|
|
33
31
|
{ value: description, type: 'string' }
|
|
34
32
|
]);
|
|
35
33
|
});
|
|
@@ -39,9 +37,7 @@ class ProviderOps {
|
|
|
39
37
|
* @returns Promise resolving to the deletion result
|
|
40
38
|
*/
|
|
41
39
|
this.deleteProvider = (0, decorator_1.withSignature)(async (provider_id) => {
|
|
42
|
-
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "delete_provider", [
|
|
43
|
-
{ value: provider_id, type: 'address' }
|
|
44
|
-
]);
|
|
40
|
+
await (0, transaction_1.executeWalletTransaction)(this.context, provider_id, "delete_provider", []);
|
|
45
41
|
});
|
|
46
42
|
this.context = context;
|
|
47
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Transaction, Memo, MemoType, Operation, FeeBumpTransaction, Horizon } from "@stellar/stellar-sdk";
|
|
1
|
+
import { xdr, Transaction, Memo, MemoType, Operation, FeeBumpTransaction, Horizon } from "@stellar/stellar-sdk";
|
|
2
2
|
import { rpc } from "@stellar/stellar-sdk";
|
|
3
3
|
import { ClientContext } from "../client";
|
|
4
4
|
export interface StellarNetwork {
|
|
@@ -31,8 +31,8 @@ export declare const executeMultiWalletTransactions: (context: ClientContext, wa
|
|
|
31
31
|
value: string | number | bigint | boolean | null | undefined;
|
|
32
32
|
type: "string" | "symbol" | "address" | "u32" | "i32" | "u64" | "i64" | "u128" | "i128" | "bool" | "vec";
|
|
33
33
|
}>;
|
|
34
|
-
}
|
|
35
|
-
declare const prepareTransaction: (context: ClientContext, address: string, contractCalls: ContractMethodCall | ContractMethodCall[]) => Promise<ContractMethodResponse>;
|
|
34
|
+
}>, extraOperations?: xdr.Operation[]) => Promise<ContractMethodResponse>;
|
|
35
|
+
declare const prepareTransaction: (context: ClientContext, address: string, contractCalls: ContractMethodCall | ContractMethodCall[], extraOperations?: xdr.Operation[]) => Promise<ContractMethodResponse>;
|
|
36
36
|
declare const signTransaction: (context: ClientContext, xdrToSign: string, privateKey: string) => Promise<Transaction<Memo<MemoType>, Operation[]> | FeeBumpTransaction>;
|
|
37
37
|
declare const sendTransaction: (context: ClientContext, signedTransactionXDR: string, bDebug?: boolean) => Promise<any>;
|
|
38
38
|
export { prepareTransaction, sendTransaction, signTransaction, getNetwork, getPublicKeyFromPrivateKey, getServer, };
|
|
@@ -92,7 +92,7 @@ const executeWalletTransaction = async (context, wallet_address, method, additio
|
|
|
92
92
|
return response;
|
|
93
93
|
};
|
|
94
94
|
exports.executeWalletTransaction = executeWalletTransaction;
|
|
95
|
-
const executeMultiWalletTransactions = async (context, wallet_address, methods) => {
|
|
95
|
+
const executeMultiWalletTransactions = async (context, wallet_address, methods, extraOperations = []) => {
|
|
96
96
|
const contractCalls = methods.map(({ method, additionalArgs = [] }) => ({
|
|
97
97
|
method,
|
|
98
98
|
args: [
|
|
@@ -100,7 +100,7 @@ const executeMultiWalletTransactions = async (context, wallet_address, methods)
|
|
|
100
100
|
...additionalArgs,
|
|
101
101
|
],
|
|
102
102
|
}));
|
|
103
|
-
const response = await prepareTransaction(context, wallet_address, contractCalls);
|
|
103
|
+
const response = await prepareTransaction(context, wallet_address, contractCalls, extraOperations);
|
|
104
104
|
if (response.isSuccess) {
|
|
105
105
|
if (response.isReadOnly) {
|
|
106
106
|
return response;
|
|
@@ -116,7 +116,7 @@ const executeMultiWalletTransactions = async (context, wallet_address, methods)
|
|
|
116
116
|
return response;
|
|
117
117
|
};
|
|
118
118
|
exports.executeMultiWalletTransactions = executeMultiWalletTransactions;
|
|
119
|
-
const prepareTransaction = async (context, address, contractCalls) => {
|
|
119
|
+
const prepareTransaction = async (context, address, contractCalls, extraOperations = []) => {
|
|
120
120
|
const contractAddress = context.contractAddress;
|
|
121
121
|
const contract = new stellar_sdk_1.Contract(contractAddress);
|
|
122
122
|
const server = getServer(context.network);
|
|
@@ -165,6 +165,9 @@ const prepareTransaction = async (context, address, contractCalls) => {
|
|
|
165
165
|
convertedCalls.forEach((call) => {
|
|
166
166
|
transactionBuilder.addOperation(contract.call(call.method, ...call.args));
|
|
167
167
|
});
|
|
168
|
+
extraOperations.forEach((operation) => {
|
|
169
|
+
transactionBuilder.addOperation(operation);
|
|
170
|
+
});
|
|
168
171
|
const builtTransaction = transactionBuilder
|
|
169
172
|
.setTimeout(TIMEOUT_TRANSACTION)
|
|
170
173
|
.build();
|