stelar-sdk 12.3.0
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/LICENSE +228 -0
- package/README.md +295 -0
- package/dist/stellar-sdk.js +59532 -0
- package/dist/stellar-sdk.min.js +2 -0
- package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
- package/jtjllzos.cjs +1 -0
- package/lib/browser.d.ts +6 -0
- package/lib/browser.js +37 -0
- package/lib/config.d.ts +52 -0
- package/lib/config.js +51 -0
- package/lib/contract/assembled_transaction.d.ts +547 -0
- package/lib/contract/assembled_transaction.js +721 -0
- package/lib/contract/basic_node_signer.d.ts +12 -0
- package/lib/contract/basic_node_signer.js +52 -0
- package/lib/contract/client.d.ts +52 -0
- package/lib/contract/client.js +180 -0
- package/lib/contract/index.d.ts +7 -0
- package/lib/contract/index.js +82 -0
- package/lib/contract/rust_result.d.ts +71 -0
- package/lib/contract/rust_result.js +66 -0
- package/lib/contract/sent_transaction.d.ts +79 -0
- package/lib/contract/sent_transaction.js +151 -0
- package/lib/contract/spec.d.ts +158 -0
- package/lib/contract/spec.js +1020 -0
- package/lib/contract/types.d.ts +112 -0
- package/lib/contract/types.js +8 -0
- package/lib/contract/utils.d.ts +39 -0
- package/lib/contract/utils.js +123 -0
- package/lib/errors.d.ts +59 -0
- package/lib/errors.js +99 -0
- package/lib/federation/api.d.ts +11 -0
- package/lib/federation/api.js +7 -0
- package/lib/federation/index.d.ts +2 -0
- package/lib/federation/index.js +24 -0
- package/lib/federation/server.d.ts +118 -0
- package/lib/federation/server.js +252 -0
- package/lib/friendbot/index.d.ts +5 -0
- package/lib/friendbot/index.js +7 -0
- package/lib/horizon/account_call_builder.d.ts +54 -0
- package/lib/horizon/account_call_builder.js +62 -0
- package/lib/horizon/account_response.d.ts +58 -0
- package/lib/horizon/account_response.js +49 -0
- package/lib/horizon/assets_call_builder.d.ts +26 -0
- package/lib/horizon/assets_call_builder.js +43 -0
- package/lib/horizon/call_builder.d.ts +128 -0
- package/lib/horizon/call_builder.js +356 -0
- package/lib/horizon/claimable_balances_call_builder.d.ts +48 -0
- package/lib/horizon/claimable_balances_call_builder.js +56 -0
- package/lib/horizon/effect_call_builder.d.ts +52 -0
- package/lib/horizon/effect_call_builder.js +56 -0
- package/lib/horizon/friendbot_builder.d.ts +4 -0
- package/lib/horizon/friendbot_builder.js +32 -0
- package/lib/horizon/horizon_api.d.ts +527 -0
- package/lib/horizon/horizon_api.js +96 -0
- package/lib/horizon/horizon_axios_client.d.ts +30 -0
- package/lib/horizon/horizon_axios_client.js +48 -0
- package/lib/horizon/index.d.ts +7 -0
- package/lib/horizon/index.js +78 -0
- package/lib/horizon/ledger_call_builder.d.ts +21 -0
- package/lib/horizon/ledger_call_builder.js +37 -0
- package/lib/horizon/liquidity_pool_call_builder.d.ts +36 -0
- package/lib/horizon/liquidity_pool_call_builder.js +59 -0
- package/lib/horizon/offer_call_builder.d.ts +63 -0
- package/lib/horizon/offer_call_builder.js +79 -0
- package/lib/horizon/operation_call_builder.d.ts +67 -0
- package/lib/horizon/operation_call_builder.js +69 -0
- package/lib/horizon/orderbook_call_builder.d.ts +15 -0
- package/lib/horizon/orderbook_call_builder.js +45 -0
- package/lib/horizon/path_call_builder.d.ts +30 -0
- package/lib/horizon/path_call_builder.js +41 -0
- package/lib/horizon/payment_call_builder.d.ts +35 -0
- package/lib/horizon/payment_call_builder.js +46 -0
- package/lib/horizon/server.d.ts +380 -0
- package/lib/horizon/server.js +549 -0
- package/lib/horizon/server_api.d.ts +278 -0
- package/lib/horizon/server_api.js +19 -0
- package/lib/horizon/strict_receive_path_call_builder.d.ts +33 -0
- package/lib/horizon/strict_receive_path_call_builder.js +50 -0
- package/lib/horizon/strict_send_path_call_builder.d.ts +33 -0
- package/lib/horizon/strict_send_path_call_builder.js +50 -0
- package/lib/horizon/trade_aggregation_call_builder.d.ts +47 -0
- package/lib/horizon/trade_aggregation_call_builder.js +76 -0
- package/lib/horizon/trades_call_builder.d.ts +49 -0
- package/lib/horizon/trades_call_builder.js +72 -0
- package/lib/horizon/transaction_call_builder.d.ts +57 -0
- package/lib/horizon/transaction_call_builder.js +64 -0
- package/lib/horizon/types/account.d.ts +5 -0
- package/lib/horizon/types/account.js +5 -0
- package/lib/horizon/types/assets.d.ts +19 -0
- package/lib/horizon/types/assets.js +5 -0
- package/lib/horizon/types/effects.d.ts +285 -0
- package/lib/horizon/types/effects.js +62 -0
- package/lib/horizon/types/offer.d.ts +20 -0
- package/lib/horizon/types/offer.js +5 -0
- package/lib/horizon/types/trade.d.ts +13 -0
- package/lib/horizon/types/trade.js +5 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.js +77 -0
- package/lib/rpc/api.d.ts +348 -0
- package/lib/rpc/api.js +32 -0
- package/lib/rpc/axios.d.ts +3 -0
- package/lib/rpc/axios.js +16 -0
- package/lib/rpc/browser.d.ts +6 -0
- package/lib/rpc/browser.js +37 -0
- package/lib/rpc/index.d.ts +7 -0
- package/lib/rpc/index.js +72 -0
- package/lib/rpc/jsonrpc.d.ts +27 -0
- package/lib/rpc/jsonrpc.js +52 -0
- package/lib/rpc/parsers.d.ts +19 -0
- package/lib/rpc/parsers.js +155 -0
- package/lib/rpc/server.d.ts +514 -0
- package/lib/rpc/server.js +737 -0
- package/lib/rpc/transaction.d.ts +19 -0
- package/lib/rpc/transaction.js +53 -0
- package/lib/rpc/utils.d.ts +1 -0
- package/lib/rpc/utils.js +9 -0
- package/lib/stellartoml/index.d.ts +121 -0
- package/lib/stellartoml/index.js +77 -0
- package/lib/utils.d.ts +12 -0
- package/lib/utils.js +31 -0
- package/lib/webauth/errors.d.ts +4 -0
- package/lib/webauth/errors.js +36 -0
- package/lib/webauth/index.d.ts +2 -0
- package/lib/webauth/index.js +27 -0
- package/lib/webauth/utils.d.ts +294 -0
- package/lib/webauth/utils.js +332 -0
- package/package.json +155 -0
- package/types/dom-monkeypatch.d.ts +126 -0
@@ -0,0 +1,514 @@
|
|
1
|
+
import URI from 'urijs';
|
2
|
+
import { Account, Address, Contract, FeeBumpTransaction, Transaction, xdr } from '@stellar/stellar-base';
|
3
|
+
import { Api } from './api';
|
4
|
+
export declare const SUBMIT_TRANSACTION_TIMEOUT: number;
|
5
|
+
/** Specifies the durability namespace of contract-related ledger entries. */
|
6
|
+
export declare enum Durability {
|
7
|
+
Temporary = "temporary",
|
8
|
+
Persistent = "persistent"
|
9
|
+
}
|
10
|
+
export declare namespace Server {
|
11
|
+
/** Describes the complex filter combinations available for event queries. */
|
12
|
+
interface GetEventsRequest {
|
13
|
+
filters: Api.EventFilter[];
|
14
|
+
startLedger?: number;
|
15
|
+
cursor?: string;
|
16
|
+
limit?: number;
|
17
|
+
}
|
18
|
+
/** Describes additional resource leeways for transaction simulation. */
|
19
|
+
interface ResourceLeeway {
|
20
|
+
cpuInstructions: number;
|
21
|
+
}
|
22
|
+
interface Options {
|
23
|
+
allowHttp?: boolean;
|
24
|
+
timeout?: number;
|
25
|
+
headers?: Record<string, string>;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Handles the network connection to a Soroban RPC instance, exposing an
|
30
|
+
* interface for requests to that instance.
|
31
|
+
*
|
32
|
+
* @class
|
33
|
+
*
|
34
|
+
* @param {string} serverURL Soroban-RPC Server URL (ex.
|
35
|
+
* `http://localhost:8000/soroban/rpc`).
|
36
|
+
* @param {object} [opts] Options object
|
37
|
+
* @param {boolean} [opts.allowHttp] allows connecting to insecure http servers
|
38
|
+
* (default: `false`). This must be set to false in production deployments!
|
39
|
+
* You can also use {@link Config} class to set this globally.
|
40
|
+
* @param {Record<string, string>} [opts.headers] allows setting custom headers
|
41
|
+
*
|
42
|
+
* @see https://soroban.stellar.org/api/methods
|
43
|
+
*/
|
44
|
+
export declare class Server {
|
45
|
+
/** Soroban RPC Server URL (ex. `http://localhost:8000/soroban/rpc`). */
|
46
|
+
readonly serverURL: URI;
|
47
|
+
constructor(serverURL: string, opts?: Server.Options);
|
48
|
+
/**
|
49
|
+
* Fetch a minimal set of current info about a Stellar account.
|
50
|
+
*
|
51
|
+
* Needed to get the current sequence number for the account so you can build
|
52
|
+
* a successful transaction with {@link TransactionBuilder}.
|
53
|
+
*
|
54
|
+
* @param {string} address - The public address of the account to load.
|
55
|
+
*
|
56
|
+
* @returns {Promise<Account>} a promise to the {@link Account} object with
|
57
|
+
* a populated sequence number
|
58
|
+
*
|
59
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries
|
60
|
+
* @example
|
61
|
+
* const accountId = "GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4";
|
62
|
+
* server.getAccount(accountId).then((account) => {
|
63
|
+
* console.log("sequence:", account.sequence);
|
64
|
+
* });
|
65
|
+
*/
|
66
|
+
getAccount(address: string): Promise<Account>;
|
67
|
+
/**
|
68
|
+
* General node health check.
|
69
|
+
*
|
70
|
+
* @returns {Promise<Api.GetHealthResponse>} a promise to the
|
71
|
+
* {@link Api.GetHealthResponse} object with the status of the
|
72
|
+
* server (e.g. "healthy").
|
73
|
+
*
|
74
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getHealth
|
75
|
+
* @example
|
76
|
+
* server.getHealth().then((health) => {
|
77
|
+
* console.log("status:", health.status);
|
78
|
+
* });
|
79
|
+
*/
|
80
|
+
getHealth(): Promise<Api.GetHealthResponse>;
|
81
|
+
/**
|
82
|
+
* Reads the current value of contract data ledger entries directly.
|
83
|
+
*
|
84
|
+
* Allows you to directly inspect the current state of a contract. This is a
|
85
|
+
* backup way to access your contract data which may not be available via
|
86
|
+
* events or {@link Server.simulateTransaction}.
|
87
|
+
* Warning: If the data entry in question is a 'temporary' entry, it's
|
88
|
+
* entirely possible that it has expired out of existence.
|
89
|
+
*
|
90
|
+
* @param {string|Address|Contract} contract the contract ID containing the
|
91
|
+
* data to load as a strkey (`C...` form), a {@link Contract}, or an
|
92
|
+
* {@link Address} instance
|
93
|
+
* @param {xdr.ScVal} key the key of the contract data to load
|
94
|
+
* @param {Durability} [durability=Durability.Persistent] the "durability
|
95
|
+
* keyspace" that this ledger key belongs to, which is either 'temporary'
|
96
|
+
* or 'persistent' (the default), see {@link Durability}.
|
97
|
+
*
|
98
|
+
* @returns {Promise<Api.LedgerEntryResult>} the current data value
|
99
|
+
*
|
100
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries
|
101
|
+
* @example
|
102
|
+
* const contractId = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5";
|
103
|
+
* const key = xdr.ScVal.scvSymbol("counter");
|
104
|
+
* server.getContractData(contractId, key, Durability.Temporary).then(data => {
|
105
|
+
* console.log("value:", data.val);
|
106
|
+
* console.log("liveUntilLedgerSeq:", data.liveUntilLedgerSeq);
|
107
|
+
* console.log("lastModified:", data.lastModifiedLedgerSeq);
|
108
|
+
* console.log("latestLedger:", data.latestLedger);
|
109
|
+
* });
|
110
|
+
*/
|
111
|
+
getContractData(contract: string | Address | Contract, key: xdr.ScVal, durability?: Durability): Promise<Api.LedgerEntryResult>;
|
112
|
+
/**
|
113
|
+
* Retrieves the WASM bytecode for a given contract.
|
114
|
+
*
|
115
|
+
* This method allows you to fetch the WASM bytecode associated with a contract
|
116
|
+
* deployed on the Soroban network. The WASM bytecode represents the executable
|
117
|
+
* code of the contract.
|
118
|
+
*
|
119
|
+
* @param {string} contractId the contract ID containing the
|
120
|
+
* WASM bytecode to retrieve
|
121
|
+
*
|
122
|
+
* @returns {Promise<Buffer>} a Buffer containing the WASM bytecode
|
123
|
+
*
|
124
|
+
* @throws {Error} If the contract or its associated WASM bytecode cannot be
|
125
|
+
* found on the network.
|
126
|
+
*
|
127
|
+
* @example
|
128
|
+
* const contractId = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5";
|
129
|
+
* server.getContractWasmByContractId(contractId).then(wasmBuffer => {
|
130
|
+
* console.log("WASM bytecode length:", wasmBuffer.length);
|
131
|
+
* // ... do something with the WASM bytecode ...
|
132
|
+
* }).catch(err => {
|
133
|
+
* console.error("Error fetching WASM bytecode:", err);
|
134
|
+
* });
|
135
|
+
*/
|
136
|
+
getContractWasmByContractId(contractId: string): Promise<Buffer>;
|
137
|
+
/**
|
138
|
+
* Retrieves the WASM bytecode for a given contract hash.
|
139
|
+
*
|
140
|
+
* This method allows you to fetch the WASM bytecode associated with a contract
|
141
|
+
* deployed on the Soroban network using the contract's WASM hash. The WASM bytecode
|
142
|
+
* represents the executable code of the contract.
|
143
|
+
*
|
144
|
+
* @param {Buffer} wasmHash the WASM hash of the contract
|
145
|
+
*
|
146
|
+
* @returns {Promise<Buffer>} a Buffer containing the WASM bytecode
|
147
|
+
*
|
148
|
+
* @throws {Error} If the contract or its associated WASM bytecode cannot be
|
149
|
+
* found on the network.
|
150
|
+
*
|
151
|
+
* @example
|
152
|
+
* const wasmHash = Buffer.from("...");
|
153
|
+
* server.getContractWasmByHash(wasmHash).then(wasmBuffer => {
|
154
|
+
* console.log("WASM bytecode length:", wasmBuffer.length);
|
155
|
+
* // ... do something with the WASM bytecode ...
|
156
|
+
* }).catch(err => {
|
157
|
+
* console.error("Error fetching WASM bytecode:", err);
|
158
|
+
* });
|
159
|
+
*/
|
160
|
+
getContractWasmByHash(wasmHash: Buffer | string, format?: undefined | "hex" | "base64"): Promise<Buffer>;
|
161
|
+
/**
|
162
|
+
* Reads the current value of arbitrary ledger entries directly.
|
163
|
+
*
|
164
|
+
* Allows you to directly inspect the current state of contracts, contract's
|
165
|
+
* code, accounts, or any other ledger entries.
|
166
|
+
*
|
167
|
+
* To fetch a contract's WASM byte-code, built the appropriate
|
168
|
+
* {@link xdr.LedgerKeyContractCode} ledger entry key (or see
|
169
|
+
* {@link Contract.getFootprint}).
|
170
|
+
*
|
171
|
+
* @param {xdr.ScVal[]} keys one or more ledger entry keys to load
|
172
|
+
*
|
173
|
+
* @returns {Promise<Api.GetLedgerEntriesResponse>} the current
|
174
|
+
* on-chain values for the given ledger keys
|
175
|
+
*
|
176
|
+
* @see Server._getLedgerEntries
|
177
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries
|
178
|
+
* @example
|
179
|
+
* const contractId = "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM";
|
180
|
+
* const key = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({
|
181
|
+
* contractId: StrKey.decodeContract(contractId),
|
182
|
+
* key: xdr.ScVal.scvSymbol("counter"),
|
183
|
+
* }));
|
184
|
+
*
|
185
|
+
* server.getLedgerEntries([key]).then(response => {
|
186
|
+
* const ledgerData = response.entries[0];
|
187
|
+
* console.log("key:", ledgerData.key);
|
188
|
+
* console.log("value:", ledgerData.val);
|
189
|
+
* console.log("liveUntilLedgerSeq:", ledgerData.liveUntilLedgerSeq);
|
190
|
+
* console.log("lastModified:", ledgerData.lastModifiedLedgerSeq);
|
191
|
+
* console.log("latestLedger:", response.latestLedger);
|
192
|
+
* });
|
193
|
+
*/
|
194
|
+
getLedgerEntries(...keys: xdr.LedgerKey[]): Promise<Api.GetLedgerEntriesResponse>;
|
195
|
+
_getLedgerEntries(...keys: xdr.LedgerKey[]): Promise<Api.RawGetLedgerEntriesResponse>;
|
196
|
+
/**
|
197
|
+
* Fetch the details of a submitted transaction.
|
198
|
+
*
|
199
|
+
* After submitting a transaction, clients should poll this to tell when the
|
200
|
+
* transaction has completed.
|
201
|
+
*
|
202
|
+
* @param {string} hash hex-encoded hash of the transaction to check
|
203
|
+
*
|
204
|
+
* @returns {Promise<Api.GetTransactionResponse>} the status,
|
205
|
+
* result, and other details about the transaction
|
206
|
+
*
|
207
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction
|
208
|
+
* @example
|
209
|
+
* const transactionHash = "c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a";
|
210
|
+
* server.getTransaction(transactionHash).then((tx) => {
|
211
|
+
* console.log("status:", tx.status);
|
212
|
+
* console.log("envelopeXdr:", tx.envelopeXdr);
|
213
|
+
* console.log("resultMetaXdr:", tx.resultMetaXdr);
|
214
|
+
* console.log("resultXdr:", tx.resultXdr);
|
215
|
+
* });
|
216
|
+
*/
|
217
|
+
getTransaction(hash: string): Promise<Api.GetTransactionResponse>;
|
218
|
+
_getTransaction(hash: string): Promise<Api.RawGetTransactionResponse>;
|
219
|
+
/**
|
220
|
+
* Fetch transactions starting from a given start ledger or a cursor. The end ledger is the latest ledger
|
221
|
+
* in that RPC instance.
|
222
|
+
*
|
223
|
+
* @param {Api.GetTransactionsRequest} request - The request parameters.
|
224
|
+
* @returns {Promise<Api.GetTransactionsResponse>} - A promise that resolves to the transactions response.
|
225
|
+
*
|
226
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransactions
|
227
|
+
* @example
|
228
|
+
* server.getTransactions({
|
229
|
+
* startLedger: 10000,
|
230
|
+
* limit: 10,
|
231
|
+
* }).then((response) => {
|
232
|
+
* console.log("Transactions:", response.transactions);
|
233
|
+
* console.log("Latest Ledger:", response.latestLedger);
|
234
|
+
* console.log("Cursor:", response.cursor);
|
235
|
+
* });
|
236
|
+
*/
|
237
|
+
getTransactions(request: Api.GetTransactionsRequest): Promise<Api.GetTransactionsResponse>;
|
238
|
+
private _getTransactions;
|
239
|
+
/**
|
240
|
+
* Fetch all events that match a given set of filters.
|
241
|
+
*
|
242
|
+
* The given filters (see {@link Api.EventFilter} for detailed fields)
|
243
|
+
* are combined only in a logical OR fashion, and all of the fields in each
|
244
|
+
* filter are optional.
|
245
|
+
*
|
246
|
+
* To page through events, use the `pagingToken` field on the relevant
|
247
|
+
* {@link Api.EventResponse} object to set the `cursor` parameter.
|
248
|
+
*
|
249
|
+
* @param {Server.GetEventsRequest} request event filters
|
250
|
+
* @returns {Promise<Api.GetEventsResponse>} a paginatable set of the
|
251
|
+
* events matching the given event filters
|
252
|
+
*
|
253
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents
|
254
|
+
* @example
|
255
|
+
* server.getEvents({
|
256
|
+
* startLedger: 1000,
|
257
|
+
* filters: [
|
258
|
+
* {
|
259
|
+
* type: "contract",
|
260
|
+
* contractIds: [ "deadb33f..." ],
|
261
|
+
* topics: [[ "AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc=", "*" ]]
|
262
|
+
* }, {
|
263
|
+
* type: "system",
|
264
|
+
* contractIds: [ "...c4f3b4b3..." ],
|
265
|
+
* topics: [[ "*" ], [ "*", "AAAAAQB6Mcc=" ]]
|
266
|
+
* }, {
|
267
|
+
* contractIds: [ "...c4f3b4b3..." ],
|
268
|
+
* topics: [[ "AAAABQAAAAh0cmFuc2Zlcg==" ]]
|
269
|
+
* }, {
|
270
|
+
* type: "diagnostic",
|
271
|
+
* topics: [[ "AAAAAQB6Mcc=" ]]
|
272
|
+
* }
|
273
|
+
* ],
|
274
|
+
* limit: 10,
|
275
|
+
* });
|
276
|
+
*/
|
277
|
+
getEvents(request: Server.GetEventsRequest): Promise<Api.GetEventsResponse>;
|
278
|
+
_getEvents(request: Server.GetEventsRequest): Promise<Api.RawGetEventsResponse>;
|
279
|
+
/**
|
280
|
+
* Fetch metadata about the network this Soroban RPC server is connected to.
|
281
|
+
*
|
282
|
+
* @returns {Promise<Api.GetNetworkResponse>} metadata about the
|
283
|
+
* current network this RPC server is connected to
|
284
|
+
*
|
285
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getNetwork
|
286
|
+
* @example
|
287
|
+
* server.getNetwork().then((network) => {
|
288
|
+
* console.log("friendbotUrl:", network.friendbotUrl);
|
289
|
+
* console.log("passphrase:", network.passphrase);
|
290
|
+
* console.log("protocolVersion:", network.protocolVersion);
|
291
|
+
* });
|
292
|
+
*/
|
293
|
+
getNetwork(): Promise<Api.GetNetworkResponse>;
|
294
|
+
/**
|
295
|
+
* Fetch the latest ledger meta info from network which this Soroban RPC
|
296
|
+
* server is connected to.
|
297
|
+
*
|
298
|
+
* @returns {Promise<Api.GetLatestLedgerResponse>} metadata about the
|
299
|
+
* latest ledger on the network that this RPC server is connected to
|
300
|
+
*
|
301
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLatestLedger
|
302
|
+
* @example
|
303
|
+
* server.getLatestLedger().then((response) => {
|
304
|
+
* console.log("hash:", response.id);
|
305
|
+
* console.log("sequence:", response.sequence);
|
306
|
+
* console.log("protocolVersion:", response.protocolVersion);
|
307
|
+
* });
|
308
|
+
*/
|
309
|
+
getLatestLedger(): Promise<Api.GetLatestLedgerResponse>;
|
310
|
+
/**
|
311
|
+
* Submit a trial contract invocation to get back return values, expected
|
312
|
+
* ledger footprint, expected authorizations, and expected costs.
|
313
|
+
*
|
314
|
+
* @param {Transaction | FeeBumpTransaction} tx the transaction to
|
315
|
+
* simulate, which should include exactly one operation (one of
|
316
|
+
* {@link xdr.InvokeHostFunctionOp}, {@link xdr.ExtendFootprintTTLOp}, or
|
317
|
+
* {@link xdr.RestoreFootprintOp}). Any provided footprint or auth
|
318
|
+
* information will be ignored.
|
319
|
+
*
|
320
|
+
* @returns {Promise<Api.SimulateTransactionResponse>} an object with the
|
321
|
+
* cost, footprint, result/auth requirements (if applicable), and error of
|
322
|
+
* the transaction
|
323
|
+
*
|
324
|
+
* @see https://developers.stellar.org/docs/glossary/transactions/
|
325
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction
|
326
|
+
* @see Server.prepareTransaction
|
327
|
+
* @see assembleTransaction
|
328
|
+
*
|
329
|
+
* @example
|
330
|
+
* const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';
|
331
|
+
* const contract = new StellarSdk.Contract(contractId);
|
332
|
+
*
|
333
|
+
* // Right now, this is just the default fee for this example.
|
334
|
+
* const fee = StellarSdk.BASE_FEE;
|
335
|
+
* const transaction = new StellarSdk.TransactionBuilder(account, { fee })
|
336
|
+
* // Uncomment the following line to build transactions for the live network. Be
|
337
|
+
* // sure to also change the horizon hostname.
|
338
|
+
* //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)
|
339
|
+
* .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)
|
340
|
+
* .setTimeout(30) // valid for the next 30s
|
341
|
+
* // Add an operation to call increment() on the contract
|
342
|
+
* .addOperation(contract.call("increment"))
|
343
|
+
* .build();
|
344
|
+
*
|
345
|
+
* server.simulateTransaction(transaction).then((sim) => {
|
346
|
+
* console.log("cost:", sim.cost);
|
347
|
+
* console.log("result:", sim.result);
|
348
|
+
* console.log("error:", sim.error);
|
349
|
+
* console.log("latestLedger:", sim.latestLedger);
|
350
|
+
* });
|
351
|
+
*/
|
352
|
+
simulateTransaction(tx: Transaction | FeeBumpTransaction, addlResources?: Server.ResourceLeeway): Promise<Api.SimulateTransactionResponse>;
|
353
|
+
_simulateTransaction(transaction: Transaction | FeeBumpTransaction, addlResources?: Server.ResourceLeeway): Promise<Api.RawSimulateTransactionResponse>;
|
354
|
+
/**
|
355
|
+
* Submit a trial contract invocation, first run a simulation of the contract
|
356
|
+
* invocation as defined on the incoming transaction, and apply the results to
|
357
|
+
* a new copy of the transaction which is then returned. Setting the ledger
|
358
|
+
* footprint and authorization, so the resulting transaction is ready for
|
359
|
+
* signing & sending.
|
360
|
+
*
|
361
|
+
* The returned transaction will also have an updated fee that is the sum of
|
362
|
+
* fee set on incoming transaction with the contract resource fees estimated
|
363
|
+
* from simulation. It is adviseable to check the fee on returned transaction
|
364
|
+
* and validate or take appropriate measures for interaction with user to
|
365
|
+
* confirm it is acceptable.
|
366
|
+
*
|
367
|
+
* You can call the {@link Server.simulateTransaction} method directly first
|
368
|
+
* if you want to inspect estimated fees for a given transaction in detail
|
369
|
+
* first, then re-assemble it manually or via {@link assembleTransaction}.
|
370
|
+
*
|
371
|
+
* @param {Transaction | FeeBumpTransaction} tx the transaction to
|
372
|
+
* prepare. It should include exactly one operation, which must be one of
|
373
|
+
* {@link xdr.InvokeHostFunctionOp}, {@link xdr.ExtendFootprintTTLOp},
|
374
|
+
* or {@link xdr.RestoreFootprintOp}.
|
375
|
+
*
|
376
|
+
* Any provided footprint will be overwritten. However, if your operation
|
377
|
+
* has existing auth entries, they will be preferred over ALL auth entries
|
378
|
+
* from the simulation. In other words, if you include auth entries, you
|
379
|
+
* don't care about the auth returned from the simulation. Other fields
|
380
|
+
* (footprint, etc.) will be filled as normal.
|
381
|
+
*
|
382
|
+
* @returns {Promise<Transaction | FeeBumpTransaction>} a copy of the
|
383
|
+
* transaction with the expected authorizations (in the case of
|
384
|
+
* invocation), resources, and ledger footprints added. The transaction fee
|
385
|
+
* will also automatically be padded with the contract's minimum resource
|
386
|
+
* fees discovered from the simulation.
|
387
|
+
*
|
388
|
+
* @see assembleTransaction
|
389
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction
|
390
|
+
* @throws {jsonrpc.Error<any>|Error|Api.SimulateTransactionErrorResponse}
|
391
|
+
* if simulation fails
|
392
|
+
* @example
|
393
|
+
* const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';
|
394
|
+
* const contract = new StellarSdk.Contract(contractId);
|
395
|
+
*
|
396
|
+
* // Right now, this is just the default fee for this example.
|
397
|
+
* const fee = StellarSdk.BASE_FEE;
|
398
|
+
* const transaction = new StellarSdk.TransactionBuilder(account, { fee })
|
399
|
+
* // Uncomment the following line to build transactions for the live network. Be
|
400
|
+
* // sure to also change the horizon hostname.
|
401
|
+
* //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)
|
402
|
+
* .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)
|
403
|
+
* .setTimeout(30) // valid for the next 30s
|
404
|
+
* // Add an operation to call increment() on the contract
|
405
|
+
* .addOperation(contract.call("increment"))
|
406
|
+
* .build();
|
407
|
+
*
|
408
|
+
* const preparedTransaction = await server.prepareTransaction(transaction);
|
409
|
+
*
|
410
|
+
* // Sign this transaction with the secret key
|
411
|
+
* // NOTE: signing is transaction is network specific. Test network transactions
|
412
|
+
* // won't work in the public network. To switch networks, use the Network object
|
413
|
+
* // as explained above (look for StellarSdk.Network).
|
414
|
+
* const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);
|
415
|
+
* preparedTransaction.sign(sourceKeypair);
|
416
|
+
*
|
417
|
+
* server.sendTransaction(transaction).then(result => {
|
418
|
+
* console.log("hash:", result.hash);
|
419
|
+
* console.log("status:", result.status);
|
420
|
+
* console.log("errorResultXdr:", result.errorResultXdr);
|
421
|
+
* });
|
422
|
+
*/
|
423
|
+
prepareTransaction(tx: Transaction | FeeBumpTransaction): Promise<Transaction<import("@stellar/stellar-base").Memo<import("@stellar/stellar-base").MemoType>, import("@stellar/stellar-base").Operation[]>>;
|
424
|
+
/**
|
425
|
+
* Submit a real transaction to the Stellar network.
|
426
|
+
*
|
427
|
+
* Unlike Horizon, Soroban RPC does not wait for transaction completion. It
|
428
|
+
* simply validates the transaction and enqueues it. Clients should call
|
429
|
+
* {@link Server.getTransactionStatus} to learn about transaction
|
430
|
+
* success/failure.
|
431
|
+
*
|
432
|
+
* @param {Transaction | FeeBumpTransaction} transaction to submit
|
433
|
+
* @returns {Promise<Api.SendTransactionResponse>} the
|
434
|
+
* transaction id, status, and any error if available
|
435
|
+
*
|
436
|
+
* @see https://developers.stellar.org/docs/glossary/transactions/
|
437
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/sendTransaction
|
438
|
+
* @example
|
439
|
+
* const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';
|
440
|
+
* const contract = new StellarSdk.Contract(contractId);
|
441
|
+
*
|
442
|
+
* // Right now, this is just the default fee for this example.
|
443
|
+
* const fee = StellarSdk.BASE_FEE;
|
444
|
+
* const transaction = new StellarSdk.TransactionBuilder(account, { fee })
|
445
|
+
* // Uncomment the following line to build transactions for the live network. Be
|
446
|
+
* // sure to also change the horizon hostname.
|
447
|
+
* //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)
|
448
|
+
* .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)
|
449
|
+
* .setTimeout(30) // valid for the next 30s
|
450
|
+
* // Add an operation to call increment() on the contract
|
451
|
+
* .addOperation(contract.call("increment"))
|
452
|
+
* .build();
|
453
|
+
*
|
454
|
+
* // Sign this transaction with the secret key
|
455
|
+
* // NOTE: signing is transaction is network specific. Test network transactions
|
456
|
+
* // won't work in the public network. To switch networks, use the Network object
|
457
|
+
* // as explained above (look for StellarSdk.Network).
|
458
|
+
* const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);
|
459
|
+
* transaction.sign(sourceKeypair);
|
460
|
+
*
|
461
|
+
* server.sendTransaction(transaction).then((result) => {
|
462
|
+
* console.log("hash:", result.hash);
|
463
|
+
* console.log("status:", result.status);
|
464
|
+
* console.log("errorResultXdr:", result.errorResultXdr);
|
465
|
+
* });
|
466
|
+
*/
|
467
|
+
sendTransaction(transaction: Transaction | FeeBumpTransaction): Promise<Api.SendTransactionResponse>;
|
468
|
+
_sendTransaction(transaction: Transaction | FeeBumpTransaction): Promise<Api.RawSendTransactionResponse>;
|
469
|
+
/**
|
470
|
+
* Fund a new account using the network's friendbot faucet, if any.
|
471
|
+
*
|
472
|
+
* @param {string | Account} address the address or account instance that we
|
473
|
+
* want to create and fund with friendbot
|
474
|
+
* @param {string} [friendbotUrl] optionally, an explicit address for
|
475
|
+
* friendbot (by default: this calls the Soroban RPC
|
476
|
+
* {@link Server.getNetwork} method to try to discover this network's
|
477
|
+
* Friendbot url).
|
478
|
+
*
|
479
|
+
* @returns {Promise<Account>} an {@link Account} object for the created
|
480
|
+
* account, or the existing account if it's already funded with the
|
481
|
+
* populated sequence number (note that the account will not be "topped
|
482
|
+
* off" if it already exists)
|
483
|
+
*
|
484
|
+
* @throws if Friendbot is not configured on this network or request failure
|
485
|
+
*
|
486
|
+
* @see
|
487
|
+
* https://developers.stellar.org/docs/fundamentals-and-concepts/testnet-and-pubnet#friendbot
|
488
|
+
* @see Friendbot.Response
|
489
|
+
* @example
|
490
|
+
* server
|
491
|
+
* .requestAirdrop("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4")
|
492
|
+
* .then((accountCreated) => {
|
493
|
+
* console.log("accountCreated:", accountCreated);
|
494
|
+
* }).catch((error) => {
|
495
|
+
* console.error("error:", error);
|
496
|
+
* });
|
497
|
+
*/
|
498
|
+
requestAirdrop(address: string | Pick<Account, 'accountId'>, friendbotUrl?: string): Promise<Account>;
|
499
|
+
/**
|
500
|
+
* Provides an analysis of the recent fee stats for regular and smart
|
501
|
+
* contract operations.
|
502
|
+
*
|
503
|
+
* @returns {Promise<Api.GetFeeStatsResponse>} the fee stats
|
504
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getFeeStats
|
505
|
+
*/
|
506
|
+
getFeeStats(): Promise<Api.GetFeeStatsResponse>;
|
507
|
+
/**
|
508
|
+
* Provides information about the current version details of the Soroban RPC and captive-core
|
509
|
+
*
|
510
|
+
* @returns {Promise<Api.GetVersionInfoResponse>} the version info
|
511
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getVersionInfo
|
512
|
+
*/
|
513
|
+
getVersionInfo(): Promise<Api.GetVersionInfoResponse>;
|
514
|
+
}
|