@flashbacktech/flashbackclient 0.1.40 → 0.1.41
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.
|
@@ -82,12 +82,6 @@ export declare class FlashOnStellarClientV2 {
|
|
|
82
82
|
* @returns Promise resolving to the update result
|
|
83
83
|
*/
|
|
84
84
|
setStableAssetAddress(stable_asset_address: string): Promise<boolean>;
|
|
85
|
-
/**
|
|
86
|
-
* Upgrades the contract (owner only)
|
|
87
|
-
* @param new_wasm_hash - Hash of the new WASM bytecode
|
|
88
|
-
* @returns Promise resolving to the upgrade result
|
|
89
|
-
*/
|
|
90
|
-
upgrade(new_wasm_hash: string): Promise<boolean>;
|
|
91
85
|
/**
|
|
92
86
|
* Gets system statistics
|
|
93
87
|
* @returns Promise resolving to system statistics
|
|
@@ -110,6 +104,7 @@ export declare class FlashOnStellarClientV2 {
|
|
|
110
104
|
deals: any[];
|
|
111
105
|
activeDeals: any[];
|
|
112
106
|
} | null>;
|
|
107
|
+
registerAsConsumerProvider(address: string, description: string): Promise<void>;
|
|
113
108
|
/**
|
|
114
109
|
* Gets comprehensive information about a consumer including their deals
|
|
115
110
|
* @param consumer_id - Address of the consumer
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FlashOnStellarClientV2 = void 0;
|
|
4
|
+
const transaction_1 = require("../wallet/transaction");
|
|
4
5
|
const consumer_1 = require("./consumer");
|
|
5
6
|
const provider_1 = require("./provider");
|
|
6
7
|
const bucket_1 = require("./bucket");
|
|
7
8
|
const deal_1 = require("./deal");
|
|
8
9
|
const funding_1 = require("./funding");
|
|
10
|
+
const decorator_1 = require("../utils/decorator");
|
|
9
11
|
/**
|
|
10
12
|
* Main client class for interacting with the FlashOnStellar V2 system
|
|
11
13
|
* This client provides methods for managing providers, consumers, buckets, and deals
|
|
@@ -105,16 +107,6 @@ class FlashOnStellarClientV2 {
|
|
|
105
107
|
// Implementation depends on the transaction layer
|
|
106
108
|
throw new Error('setStableAssetAddress not implemented - requires transaction layer implementation');
|
|
107
109
|
}
|
|
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
110
|
/**
|
|
119
111
|
* Gets system statistics
|
|
120
112
|
* @returns Promise resolving to system statistics
|
|
@@ -179,6 +171,28 @@ class FlashOnStellarClientV2 {
|
|
|
179
171
|
return null;
|
|
180
172
|
}
|
|
181
173
|
}
|
|
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
|
+
}
|
|
182
196
|
/**
|
|
183
197
|
* Gets comprehensive information about a consumer including their deals
|
|
184
198
|
* @param consumer_id - Address of the consumer
|
|
@@ -42,7 +42,6 @@ const getServer = (network) => {
|
|
|
42
42
|
serverUrl = "https://rpc.stellar.org";
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
|
-
console.log(`!!!Creating Soroban RPC server for network: ${network.network}, URL: ${serverUrl}`);
|
|
46
45
|
// For Stellar SDK v13+, we need to handle the allowHttp issue
|
|
47
46
|
let server;
|
|
48
47
|
// Approach 1: Try with allowHttp option
|
|
@@ -55,57 +54,6 @@ const getServer = (network) => {
|
|
|
55
54
|
catch (error) {
|
|
56
55
|
console.log(`Failed with allowHttp: true:`, error instanceof Error ? error.message : String(error));
|
|
57
56
|
}
|
|
58
|
-
// Approach 1.5: Try with allowHttp as a boolean string
|
|
59
|
-
try {
|
|
60
|
-
console.log(`Attempting to create server with allowHttp: "true"`);
|
|
61
|
-
server = new stellar_sdk_2.rpc.Server(serverUrl, { allowHttp: "true" });
|
|
62
|
-
console.log(`Soroban RPC server created successfully with allowHttp: "true"`);
|
|
63
|
-
return server;
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.log(`Failed with allowHttp: "true":`, error instanceof Error ? error.message : String(error));
|
|
67
|
-
}
|
|
68
|
-
// Approach 1.6: Try with allowHttp as a number
|
|
69
|
-
try {
|
|
70
|
-
console.log(`Attempting to create server with allowHttp: 1`);
|
|
71
|
-
server = new stellar_sdk_2.rpc.Server(serverUrl, { allowHttp: 1 });
|
|
72
|
-
console.log(`Soroban RPC server created successfully with allowHttp: 1`);
|
|
73
|
-
return server;
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.log(`Failed with allowHttp: 1:`, error instanceof Error ? error.message : String(error));
|
|
77
|
-
}
|
|
78
|
-
// Approach 3: Try without any options
|
|
79
|
-
try {
|
|
80
|
-
console.log(`Attempting to create server without options`);
|
|
81
|
-
server = new stellar_sdk_2.rpc.Server(serverUrl);
|
|
82
|
-
console.log(`Soroban RPC server created successfully without options`);
|
|
83
|
-
return server;
|
|
84
|
-
}
|
|
85
|
-
catch (error) {
|
|
86
|
-
console.log(`Failed without options:`, error instanceof Error ? error.message : String(error));
|
|
87
|
-
}
|
|
88
|
-
// Approach 4: Try with empty options
|
|
89
|
-
try {
|
|
90
|
-
console.log(`Attempting to create server with empty options`);
|
|
91
|
-
server = new stellar_sdk_2.rpc.Server(serverUrl, {});
|
|
92
|
-
console.log(`Soroban RPC server created successfully with empty options`);
|
|
93
|
-
return server;
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
console.log(`Failed with empty options:`, error instanceof Error ? error.message : String(error));
|
|
97
|
-
}
|
|
98
|
-
// Approach 5: Try with a different URL format (without protocol)
|
|
99
|
-
try {
|
|
100
|
-
console.log(`Attempting to create server with URL without protocol`);
|
|
101
|
-
const urlWithoutProtocol = serverUrl.replace('https://', '');
|
|
102
|
-
server = new stellar_sdk_2.rpc.Server(urlWithoutProtocol, { allowHttp: true });
|
|
103
|
-
console.log(`Soroban RPC server created successfully with URL without protocol`);
|
|
104
|
-
return server;
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
console.log(`Failed with URL without protocol:`, error instanceof Error ? error.message : String(error));
|
|
108
|
-
}
|
|
109
57
|
// If all approaches fail, throw a comprehensive error
|
|
110
58
|
throw new Error(`Failed to create Soroban RPC server for ${network.network} at ${serverUrl}. All configuration attempts failed.`);
|
|
111
59
|
};
|