@flashbacktech/flashbackclient 0.2.70 → 0.2.71
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.
|
@@ -7,6 +7,12 @@ export interface StellarNetwork {
|
|
|
7
7
|
}
|
|
8
8
|
declare const getNetwork: (network: string) => StellarNetwork;
|
|
9
9
|
declare const getPublicKeyFromPrivateKey: (privateKey: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Set a custom Soroban RPC server URL for a network.
|
|
12
|
+
* Use this to point the client at a different RPC endpoint (e.g. your own node).
|
|
13
|
+
* Pass `undefined` as url to clear the override and revert to the default for that network.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setServer: (network: string, url: string | undefined) => void;
|
|
10
16
|
declare const getServer: (network: StellarNetwork) => rpc.Server;
|
|
11
17
|
interface ContractMethodCall {
|
|
12
18
|
method: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getServer = exports.getPublicKeyFromPrivateKey = exports.getNetwork = exports.signTransaction = exports.sendTransaction = exports.prepareTransaction = exports.createPrivateKeySigner = exports.executeMultiWalletTransactions = exports.executeWalletTransaction = exports.executeServerTransaction = exports.getHorizonServer = void 0;
|
|
3
|
+
exports.getServer = exports.getPublicKeyFromPrivateKey = exports.getNetwork = exports.signTransaction = exports.sendTransaction = exports.prepareTransaction = exports.createPrivateKeySigner = exports.executeMultiWalletTransactions = exports.executeWalletTransaction = exports.executeServerTransaction = exports.getHorizonServer = exports.setServer = void 0;
|
|
4
4
|
const timing_1 = require("../utils/timing");
|
|
5
5
|
// Polyfill for BigInt JSON serialization
|
|
6
6
|
BigInt.prototype.toJSON = function () {
|
|
@@ -32,30 +32,37 @@ const getPublicKeyFromPrivateKey = (privateKey) => {
|
|
|
32
32
|
return keypair.publicKey();
|
|
33
33
|
};
|
|
34
34
|
exports.getPublicKeyFromPrivateKey = getPublicKeyFromPrivateKey;
|
|
35
|
+
const DEFAULT_RPC_URLS = {
|
|
36
|
+
TESTNET: "https://soroban-testnet.stellar.org",
|
|
37
|
+
PUBLIC: "https://soroban-rpc.creit.tech",
|
|
38
|
+
};
|
|
39
|
+
const customRpcUrls = {};
|
|
40
|
+
/**
|
|
41
|
+
* Set a custom Soroban RPC server URL for a network.
|
|
42
|
+
* Use this to point the client at a different RPC endpoint (e.g. your own node).
|
|
43
|
+
* Pass `undefined` as url to clear the override and revert to the default for that network.
|
|
44
|
+
*/
|
|
45
|
+
const setServer = (network, url) => {
|
|
46
|
+
if (url === undefined) {
|
|
47
|
+
delete customRpcUrls[network];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
customRpcUrls[network] = url;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.setServer = setServer;
|
|
35
54
|
const getServer = (network) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
serverUrl = "https://soroban-testnet.stellar.org";
|
|
40
|
-
break;
|
|
41
|
-
case "PUBLIC":
|
|
42
|
-
//serverUrl = "https://rpc.stellar.org";
|
|
43
|
-
//serverUrl = "https://stellar-soroban-public.nodies.app";
|
|
44
|
-
serverUrl = "https://soroban-rpc.mainnet.stellar.gateway.fm";
|
|
45
|
-
break;
|
|
55
|
+
const serverUrl = customRpcUrls[network.network] ?? DEFAULT_RPC_URLS[network.network] ?? "";
|
|
56
|
+
if (!serverUrl) {
|
|
57
|
+
throw new Error(`No RPC URL configured for network "${network.network}". Use setServer(network, url) or ensure the network is one of: TESTNET, PUBLIC.`);
|
|
46
58
|
}
|
|
47
|
-
// For Stellar SDK v13+, we need to handle the allowHttp issue
|
|
48
|
-
let server;
|
|
49
|
-
// Approach 1: Try with allowHttp option
|
|
50
59
|
try {
|
|
51
|
-
|
|
52
|
-
return server;
|
|
60
|
+
return new stellar_sdk_2.rpc.Server(serverUrl, { allowHttp: true });
|
|
53
61
|
}
|
|
54
62
|
catch (error) {
|
|
55
63
|
console.log(`Failed with allowHttp: true:`, error instanceof Error ? error.message : String(error));
|
|
64
|
+
throw new Error(`Failed to create Soroban RPC server for ${network.network} at ${serverUrl}. All configuration attempts failed.`);
|
|
56
65
|
}
|
|
57
|
-
// If all approaches fail, throw a comprehensive error
|
|
58
|
-
throw new Error(`Failed to create Soroban RPC server for ${network.network} at ${serverUrl}. All configuration attempts failed.`);
|
|
59
66
|
};
|
|
60
67
|
exports.getServer = getServer;
|
|
61
68
|
const TIMEOUT_TRANSACTION = 60;
|