@flashbacktech/flashbackclient 0.1.36 → 0.1.38
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.
|
@@ -36,6 +36,7 @@ const getServer = (network) => {
|
|
|
36
36
|
serverUrl = 'https://rpc.stellar.org:443';
|
|
37
37
|
break;
|
|
38
38
|
}
|
|
39
|
+
console.log(`@@@Creating Stellar RPC server for network: ${network.network}, URL: ${serverUrl}`);
|
|
39
40
|
const server = new stellar_sdk_2.rpc.Server(serverUrl);
|
|
40
41
|
return server;
|
|
41
42
|
};
|
|
@@ -8,6 +8,12 @@ BigInt.prototype.toJSON = function () {
|
|
|
8
8
|
};
|
|
9
9
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
10
10
|
const stellar_sdk_2 = require("@stellar/stellar-sdk");
|
|
11
|
+
// Set global configuration for Stellar SDK to allow HTTP connections
|
|
12
|
+
// This is sometimes needed for newer versions of the SDK
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
// Browser environment
|
|
15
|
+
window.__STELLAR_SDK_ALLOW_HTTP__ = true;
|
|
16
|
+
}
|
|
11
17
|
const getNetwork = (network) => {
|
|
12
18
|
let networkPassphrase = "";
|
|
13
19
|
switch (network) {
|
|
@@ -36,12 +42,73 @@ const getServer = (network) => {
|
|
|
36
42
|
serverUrl = "https://rpc.stellar.org";
|
|
37
43
|
break;
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
console.log(`!!!Creating Soroban RPC server for network: ${network.network}, URL: ${serverUrl}`);
|
|
46
|
+
// For Stellar SDK v13+, we need to handle the allowHttp issue
|
|
47
|
+
// Try different approaches to create the server
|
|
48
|
+
let server;
|
|
49
|
+
// Approach 1: Try with allowHttp option
|
|
50
|
+
try {
|
|
51
|
+
console.log(`Attempting to create server with allowHttp: true`);
|
|
52
|
+
server = new stellar_sdk_2.rpc.Server(serverUrl, { allowHttp: true });
|
|
53
|
+
console.log(`Soroban RPC server created successfully with allowHttp: true`);
|
|
54
|
+
return server;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.log(`Failed with allowHttp: true:`, error instanceof Error ? error.message : String(error));
|
|
58
|
+
}
|
|
59
|
+
// Approach 1.5: Try with allowHttp as a boolean string
|
|
60
|
+
try {
|
|
61
|
+
console.log(`Attempting to create server with allowHttp: "true"`);
|
|
62
|
+
server = new stellar_sdk_2.rpc.Server(serverUrl, { allowHttp: "true" });
|
|
63
|
+
console.log(`Soroban RPC server created successfully with allowHttp: "true"`);
|
|
64
|
+
return server;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.log(`Failed with allowHttp: "true":`, error instanceof Error ? error.message : String(error));
|
|
68
|
+
}
|
|
69
|
+
// Approach 1.6: Try with allowHttp as a number
|
|
70
|
+
try {
|
|
71
|
+
console.log(`Attempting to create server with allowHttp: 1`);
|
|
72
|
+
server = new stellar_sdk_2.rpc.Server(serverUrl, { allowHttp: 1 });
|
|
73
|
+
console.log(`Soroban RPC server created successfully with allowHttp: 1`);
|
|
74
|
+
return server;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
console.log(`Failed with allowHttp: 1:`, error instanceof Error ? error.message : String(error));
|
|
78
|
+
}
|
|
79
|
+
// Approach 3: Try without any options
|
|
80
|
+
try {
|
|
81
|
+
console.log(`Attempting to create server without options`);
|
|
82
|
+
server = new stellar_sdk_2.rpc.Server(serverUrl);
|
|
83
|
+
console.log(`Soroban RPC server created successfully without options`);
|
|
84
|
+
return server;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.log(`Failed without options:`, error instanceof Error ? error.message : String(error));
|
|
88
|
+
}
|
|
89
|
+
// Approach 4: Try with empty options
|
|
90
|
+
try {
|
|
91
|
+
console.log(`Attempting to create server with empty options`);
|
|
92
|
+
server = new stellar_sdk_2.rpc.Server(serverUrl, {});
|
|
93
|
+
console.log(`Soroban RPC server created successfully with empty options`);
|
|
94
|
+
return server;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.log(`Failed with empty options:`, error instanceof Error ? error.message : String(error));
|
|
98
|
+
}
|
|
99
|
+
// Approach 5: Try with a different URL format (without protocol)
|
|
100
|
+
try {
|
|
101
|
+
console.log(`Attempting to create server with URL without protocol`);
|
|
102
|
+
const urlWithoutProtocol = serverUrl.replace('https://', '');
|
|
103
|
+
server = new stellar_sdk_2.rpc.Server(urlWithoutProtocol, { allowHttp: true });
|
|
104
|
+
console.log(`Soroban RPC server created successfully with URL without protocol`);
|
|
105
|
+
return server;
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.log(`Failed with URL without protocol:`, error instanceof Error ? error.message : String(error));
|
|
109
|
+
}
|
|
110
|
+
// If all approaches fail, throw a comprehensive error
|
|
111
|
+
throw new Error(`Failed to create Soroban RPC server for ${network.network} at ${serverUrl}. All configuration attempts failed.`);
|
|
45
112
|
};
|
|
46
113
|
exports.getServer = getServer;
|
|
47
114
|
const TIMEOUT_TRANSACTION = 60;
|
|
@@ -154,7 +221,17 @@ const prepareTransaction = async (context, address, contractCalls) => {
|
|
|
154
221
|
const builtTransaction = transactionBuilder
|
|
155
222
|
.setTimeout(TIMEOUT_TRANSACTION)
|
|
156
223
|
.build();
|
|
157
|
-
|
|
224
|
+
console.log(`About to simulate transaction for method: ${calls[0]?.method || 'unknown'}`);
|
|
225
|
+
console.log(`Network: ${context.network.network}, Passphrase: ${context.network.networkPassphrase}`);
|
|
226
|
+
let sim;
|
|
227
|
+
try {
|
|
228
|
+
sim = await server.simulateTransaction(builtTransaction);
|
|
229
|
+
console.log(`Transaction simulation successful`);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
console.error(`Transaction simulation failed:`, error);
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
158
235
|
if (stellar_sdk_2.rpc.Api.isSimulationSuccess(sim)) {
|
|
159
236
|
response.isSuccess = true;
|
|
160
237
|
const result = sim.result && sim.result.retval
|