@stellar/stellar-sdk 14.1.1 → 14.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/CHANGELOG.md +23 -0
- package/README.md +14 -20
- package/dist/stellar-sdk-minimal.js +532 -375
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +532 -375
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +781 -551
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +781 -551
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/contract/client.js +2 -2
- package/lib/contract/spec.js +10 -2
- package/lib/contract/utils.js +7 -7
- package/lib/errors/account_requires_memo.d.ts +0 -1
- package/lib/errors/account_requires_memo.js +0 -4
- package/lib/errors/bad_request.d.ts +0 -1
- package/lib/errors/bad_request.js +2 -8
- package/lib/errors/bad_response.d.ts +0 -1
- package/lib/errors/bad_response.js +2 -8
- package/lib/errors/network.d.ts +0 -1
- package/lib/errors/network.js +0 -3
- package/lib/errors/not_found.d.ts +0 -1
- package/lib/errors/not_found.js +2 -8
- package/lib/federation/index.d.ts +2 -2
- package/lib/horizon/call_builder.js +1 -1
- package/lib/horizon/horizon_api.js +0 -1
- package/lib/horizon/horizon_axios_client.js +4 -4
- package/lib/horizon/index.d.ts +1 -1
- package/lib/horizon/types/effects.d.ts +41 -41
- package/lib/horizon/types/trade.d.ts +1 -1
- package/lib/http-client/fetch-client.d.ts +2 -2
- package/lib/http-client/fetch-client.js +16 -16
- package/lib/http-client/index.js +2 -2
- package/lib/http-client/types.d.ts +2 -2
- package/lib/index.d.ts +11 -11
- package/lib/index.js +2 -2
- package/lib/minimal/contract/client.js +2 -2
- package/lib/minimal/contract/spec.js +10 -2
- package/lib/minimal/contract/utils.js +7 -7
- package/lib/minimal/errors/account_requires_memo.d.ts +0 -1
- package/lib/minimal/errors/account_requires_memo.js +0 -4
- package/lib/minimal/errors/bad_request.d.ts +0 -1
- package/lib/minimal/errors/bad_request.js +2 -8
- package/lib/minimal/errors/bad_response.d.ts +0 -1
- package/lib/minimal/errors/bad_response.js +2 -8
- package/lib/minimal/errors/network.d.ts +0 -1
- package/lib/minimal/errors/network.js +0 -3
- package/lib/minimal/errors/not_found.d.ts +0 -1
- package/lib/minimal/errors/not_found.js +2 -8
- package/lib/minimal/federation/index.d.ts +2 -2
- package/lib/minimal/horizon/call_builder.js +1 -1
- package/lib/minimal/horizon/horizon_api.js +0 -1
- package/lib/minimal/horizon/horizon_axios_client.js +4 -4
- package/lib/minimal/horizon/index.d.ts +1 -1
- package/lib/minimal/horizon/types/effects.d.ts +41 -41
- package/lib/minimal/horizon/types/trade.d.ts +1 -1
- package/lib/minimal/http-client/fetch-client.d.ts +2 -2
- package/lib/minimal/http-client/fetch-client.js +16 -16
- package/lib/minimal/http-client/index.js +2 -2
- package/lib/minimal/http-client/types.d.ts +2 -2
- package/lib/minimal/index.d.ts +11 -11
- package/lib/minimal/index.js +2 -2
- package/lib/minimal/rpc/api.d.ts +148 -8
- package/lib/minimal/rpc/api.js +3 -3
- package/lib/minimal/rpc/axios.js +3 -3
- package/lib/minimal/rpc/browser.d.ts +2 -2
- package/lib/minimal/rpc/index.d.ts +1 -1
- package/lib/minimal/rpc/parsers.d.ts +3 -2
- package/lib/minimal/rpc/parsers.js +42 -19
- package/lib/minimal/rpc/server.d.ts +123 -31
- package/lib/minimal/rpc/server.js +425 -267
- package/lib/minimal/rpc/transaction.d.ts +2 -2
- package/lib/minimal/rpc/transaction.js +6 -6
- package/lib/minimal/webauth/errors.d.ts +0 -2
- package/lib/minimal/webauth/errors.js +2 -8
- package/lib/minimal/webauth/index.d.ts +2 -2
- package/lib/no-axios/contract/client.js +2 -2
- package/lib/no-axios/contract/spec.js +10 -2
- package/lib/no-axios/contract/utils.js +7 -7
- package/lib/no-axios/errors/account_requires_memo.d.ts +0 -1
- package/lib/no-axios/errors/account_requires_memo.js +0 -4
- package/lib/no-axios/errors/bad_request.d.ts +0 -1
- package/lib/no-axios/errors/bad_request.js +2 -8
- package/lib/no-axios/errors/bad_response.d.ts +0 -1
- package/lib/no-axios/errors/bad_response.js +2 -8
- package/lib/no-axios/errors/network.d.ts +0 -1
- package/lib/no-axios/errors/network.js +0 -3
- package/lib/no-axios/errors/not_found.d.ts +0 -1
- package/lib/no-axios/errors/not_found.js +2 -8
- package/lib/no-axios/federation/index.d.ts +2 -2
- package/lib/no-axios/horizon/call_builder.js +1 -1
- package/lib/no-axios/horizon/horizon_api.js +0 -1
- package/lib/no-axios/horizon/horizon_axios_client.js +4 -4
- package/lib/no-axios/horizon/index.d.ts +1 -1
- package/lib/no-axios/horizon/types/effects.d.ts +41 -41
- package/lib/no-axios/horizon/types/trade.d.ts +1 -1
- package/lib/no-axios/http-client/fetch-client.d.ts +2 -2
- package/lib/no-axios/http-client/fetch-client.js +16 -16
- package/lib/no-axios/http-client/index.js +2 -2
- package/lib/no-axios/http-client/types.d.ts +2 -2
- package/lib/no-axios/index.d.ts +11 -11
- package/lib/no-axios/index.js +2 -2
- package/lib/no-axios/rpc/api.d.ts +148 -8
- package/lib/no-axios/rpc/api.js +3 -3
- package/lib/no-axios/rpc/axios.js +3 -3
- package/lib/no-axios/rpc/browser.d.ts +2 -2
- package/lib/no-axios/rpc/index.d.ts +1 -1
- package/lib/no-axios/rpc/parsers.d.ts +3 -2
- package/lib/no-axios/rpc/parsers.js +42 -19
- package/lib/no-axios/rpc/server.d.ts +123 -31
- package/lib/no-axios/rpc/server.js +425 -267
- package/lib/no-axios/rpc/transaction.d.ts +2 -2
- package/lib/no-axios/rpc/transaction.js +6 -6
- package/lib/no-axios/webauth/errors.d.ts +0 -2
- package/lib/no-axios/webauth/errors.js +2 -8
- package/lib/no-axios/webauth/index.d.ts +2 -2
- package/lib/no-eventsource/contract/client.js +2 -2
- package/lib/no-eventsource/contract/spec.js +10 -2
- package/lib/no-eventsource/contract/utils.js +7 -7
- package/lib/no-eventsource/errors/account_requires_memo.d.ts +0 -1
- package/lib/no-eventsource/errors/account_requires_memo.js +0 -4
- package/lib/no-eventsource/errors/bad_request.d.ts +0 -1
- package/lib/no-eventsource/errors/bad_request.js +2 -8
- package/lib/no-eventsource/errors/bad_response.d.ts +0 -1
- package/lib/no-eventsource/errors/bad_response.js +2 -8
- package/lib/no-eventsource/errors/network.d.ts +0 -1
- package/lib/no-eventsource/errors/network.js +0 -3
- package/lib/no-eventsource/errors/not_found.d.ts +0 -1
- package/lib/no-eventsource/errors/not_found.js +2 -8
- package/lib/no-eventsource/federation/index.d.ts +2 -2
- package/lib/no-eventsource/horizon/call_builder.js +1 -1
- package/lib/no-eventsource/horizon/horizon_api.js +0 -1
- package/lib/no-eventsource/horizon/horizon_axios_client.js +4 -4
- package/lib/no-eventsource/horizon/index.d.ts +1 -1
- package/lib/no-eventsource/horizon/types/effects.d.ts +41 -41
- package/lib/no-eventsource/horizon/types/trade.d.ts +1 -1
- package/lib/no-eventsource/http-client/fetch-client.d.ts +2 -2
- package/lib/no-eventsource/http-client/fetch-client.js +16 -16
- package/lib/no-eventsource/http-client/index.js +2 -2
- package/lib/no-eventsource/http-client/types.d.ts +2 -2
- package/lib/no-eventsource/index.d.ts +11 -11
- package/lib/no-eventsource/index.js +2 -2
- package/lib/no-eventsource/rpc/api.d.ts +148 -8
- package/lib/no-eventsource/rpc/api.js +3 -3
- package/lib/no-eventsource/rpc/axios.js +3 -3
- package/lib/no-eventsource/rpc/browser.d.ts +2 -2
- package/lib/no-eventsource/rpc/index.d.ts +1 -1
- package/lib/no-eventsource/rpc/parsers.d.ts +3 -2
- package/lib/no-eventsource/rpc/parsers.js +42 -19
- package/lib/no-eventsource/rpc/server.d.ts +123 -31
- package/lib/no-eventsource/rpc/server.js +425 -267
- package/lib/no-eventsource/rpc/transaction.d.ts +2 -2
- package/lib/no-eventsource/rpc/transaction.js +6 -6
- package/lib/no-eventsource/webauth/errors.d.ts +0 -2
- package/lib/no-eventsource/webauth/errors.js +2 -8
- package/lib/no-eventsource/webauth/index.d.ts +2 -2
- package/lib/rpc/api.d.ts +148 -8
- package/lib/rpc/api.js +3 -3
- package/lib/rpc/axios.js +3 -3
- package/lib/rpc/browser.d.ts +2 -2
- package/lib/rpc/index.d.ts +1 -1
- package/lib/rpc/parsers.d.ts +3 -2
- package/lib/rpc/parsers.js +42 -19
- package/lib/rpc/server.d.ts +123 -31
- package/lib/rpc/server.js +425 -267
- package/lib/rpc/transaction.d.ts +2 -2
- package/lib/rpc/transaction.js +6 -6
- package/lib/webauth/errors.d.ts +0 -2
- package/lib/webauth/errors.js +2 -8
- package/lib/webauth/index.d.ts +2 -2
- package/package.json +17 -9
package/lib/minimal/rpc/api.js
CHANGED
|
@@ -14,15 +14,15 @@ var Api;
|
|
|
14
14
|
}({});
|
|
15
15
|
_Api.GetTransactionStatus = GetTransactionStatus;
|
|
16
16
|
function isSimulationError(sim) {
|
|
17
|
-
return
|
|
17
|
+
return "error" in sim;
|
|
18
18
|
}
|
|
19
19
|
_Api.isSimulationError = isSimulationError;
|
|
20
20
|
function isSimulationSuccess(sim) {
|
|
21
|
-
return
|
|
21
|
+
return "transactionData" in sim;
|
|
22
22
|
}
|
|
23
23
|
_Api.isSimulationSuccess = isSimulationSuccess;
|
|
24
24
|
function isSimulationRestore(sim) {
|
|
25
|
-
return isSimulationSuccess(sim) &&
|
|
25
|
+
return isSimulationSuccess(sim) && "restorePreamble" in sim && !!sim.restorePreamble.transactionData;
|
|
26
26
|
}
|
|
27
27
|
_Api.isSimulationRestore = isSimulationRestore;
|
|
28
28
|
function isSimulationRaw(sim) {
|
package/lib/minimal/rpc/axios.js
CHANGED
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.default = exports.AxiosClient = void 0;
|
|
7
7
|
var _httpClient = require("../http-client");
|
|
8
|
-
var version = exports.version = "14.
|
|
8
|
+
var version = exports.version = "14.3.0";
|
|
9
9
|
var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
|
|
10
10
|
headers: {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
"X-Client-Name": "js-soroban-client",
|
|
12
|
+
"X-Client-Version": version
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
var _default = exports.default = AxiosClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @module rpc */
|
|
2
2
|
export * from "./api";
|
|
3
|
-
export { RpcServer as Server, BasicSleepStrategy, LinearSleepStrategy, Durability } from "./server";
|
|
3
|
+
export { RpcServer as Server, BasicSleepStrategy, LinearSleepStrategy, Durability, } from "./server";
|
|
4
4
|
export { default as AxiosClient } from "./axios";
|
|
5
5
|
export { parseRawSimulation, parseRawEvents } from "./parsers";
|
|
6
6
|
export * from "./transaction";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Api } from
|
|
1
|
+
import { Api } from "./api";
|
|
2
2
|
/**
|
|
3
3
|
* Parse the response from invoking the `submitTransaction` method of a RPC server.
|
|
4
4
|
* @memberof module:rpc
|
|
@@ -8,7 +8,7 @@ import { Api } from './api';
|
|
|
8
8
|
* @returns {Api.SendTransactionResponse} transaction response parsed from the RPC server's response
|
|
9
9
|
*/
|
|
10
10
|
export declare function parseRawSendTransaction(raw: Api.RawSendTransactionResponse): Api.SendTransactionResponse;
|
|
11
|
-
export declare function parseTransactionInfo(raw: Api.RawTransactionInfo | Api.RawGetTransactionResponse): Omit<Api.TransactionInfo,
|
|
11
|
+
export declare function parseTransactionInfo(raw: Api.RawTransactionInfo | Api.RawGetTransactionResponse): Omit<Api.TransactionInfo, "status" | "txHash">;
|
|
12
12
|
export declare function parseRawTransactions(r: Api.RawTransactionInfo): Api.TransactionInfo;
|
|
13
13
|
/**
|
|
14
14
|
* Parse and return the retrieved events, if any, from a raw response from a
|
|
@@ -43,3 +43,4 @@ export declare function parseRawLedgerEntries(raw: Api.RawGetLedgerEntriesRespon
|
|
|
43
43
|
* @returns {Api.SimulateTransactionResponse} the original parameter (if already parsed), parsed otherwise
|
|
44
44
|
*/
|
|
45
45
|
export declare function parseRawSimulation(sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse): Api.SimulateTransactionResponse;
|
|
46
|
+
export declare function parseRawLedger(raw: Api.RawLedgerResponse): Api.LedgerResponse;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parseRawEvents = parseRawEvents;
|
|
7
|
+
exports.parseRawLedger = parseRawLedger;
|
|
7
8
|
exports.parseRawLedgerEntries = parseRawLedgerEntries;
|
|
8
9
|
exports.parseRawSendTransaction = parseRawSendTransaction;
|
|
9
10
|
exports.parseRawSimulation = parseRawSimulation;
|
|
@@ -25,24 +26,24 @@ function parseRawSendTransaction(raw) {
|
|
|
25
26
|
if (errorResultXdr) {
|
|
26
27
|
return _objectSpread(_objectSpread(_objectSpread({}, raw), diagnosticEventsXdr !== undefined && diagnosticEventsXdr.length > 0 && {
|
|
27
28
|
diagnosticEvents: diagnosticEventsXdr.map(function (evt) {
|
|
28
|
-
return _stellarBase.xdr.DiagnosticEvent.fromXDR(evt,
|
|
29
|
+
return _stellarBase.xdr.DiagnosticEvent.fromXDR(evt, "base64");
|
|
29
30
|
})
|
|
30
31
|
}), {}, {
|
|
31
|
-
errorResult: _stellarBase.xdr.TransactionResult.fromXDR(errorResultXdr,
|
|
32
|
+
errorResult: _stellarBase.xdr.TransactionResult.fromXDR(errorResultXdr, "base64")
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
return _objectSpread({}, raw);
|
|
35
36
|
}
|
|
36
37
|
function parseTransactionInfo(raw) {
|
|
37
38
|
var _raw$events$contractE, _raw$events, _raw$events$transacti, _raw$events2;
|
|
38
|
-
var meta = _stellarBase.xdr.TransactionMeta.fromXDR(raw.resultMetaXdr,
|
|
39
|
+
var meta = _stellarBase.xdr.TransactionMeta.fromXDR(raw.resultMetaXdr, "base64");
|
|
39
40
|
var info = {
|
|
40
41
|
ledger: raw.ledger,
|
|
41
42
|
createdAt: raw.createdAt,
|
|
42
43
|
applicationOrder: raw.applicationOrder,
|
|
43
44
|
feeBump: raw.feeBump,
|
|
44
|
-
envelopeXdr: _stellarBase.xdr.TransactionEnvelope.fromXDR(raw.envelopeXdr,
|
|
45
|
-
resultXdr: _stellarBase.xdr.TransactionResult.fromXDR(raw.resultXdr,
|
|
45
|
+
envelopeXdr: _stellarBase.xdr.TransactionEnvelope.fromXDR(raw.envelopeXdr, "base64"),
|
|
46
|
+
resultXdr: _stellarBase.xdr.TransactionResult.fromXDR(raw.resultXdr, "base64"),
|
|
46
47
|
resultMetaXdr: meta,
|
|
47
48
|
events: {
|
|
48
49
|
contractEventsXdr: ((_raw$events$contractE = (_raw$events = raw.events) === null || _raw$events === void 0 ? void 0 : _raw$events.contractEventsXdr) !== null && _raw$events$contractE !== void 0 ? _raw$events$contractE : []).map(function (lst) {
|
|
@@ -66,7 +67,7 @@ function parseTransactionInfo(raw) {
|
|
|
66
67
|
}
|
|
67
68
|
if (raw.diagnosticEventsXdr) {
|
|
68
69
|
info.diagnosticEventsXdr = raw.diagnosticEventsXdr.map(function (e) {
|
|
69
|
-
return _stellarBase.xdr.DiagnosticEvent.fromXDR(e,
|
|
70
|
+
return _stellarBase.xdr.DiagnosticEvent.fromXDR(e, "base64");
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
73
|
return info;
|
|
@@ -88,13 +89,13 @@ function parseRawEvents(raw) {
|
|
|
88
89
|
events: ((_raw$events3 = raw.events) !== null && _raw$events3 !== void 0 ? _raw$events3 : []).map(function (evt) {
|
|
89
90
|
var clone = _objectSpread({}, evt);
|
|
90
91
|
delete clone.contractId;
|
|
91
|
-
return _objectSpread(_objectSpread(_objectSpread({}, clone), evt.contractId !==
|
|
92
|
+
return _objectSpread(_objectSpread(_objectSpread({}, clone), evt.contractId !== "" && {
|
|
92
93
|
contractId: new _stellarBase.Contract(evt.contractId)
|
|
93
94
|
}), {}, {
|
|
94
95
|
topic: evt.topic.map(function (topic) {
|
|
95
|
-
return _stellarBase.xdr.ScVal.fromXDR(topic,
|
|
96
|
+
return _stellarBase.xdr.ScVal.fromXDR(topic, "base64");
|
|
96
97
|
}),
|
|
97
|
-
value: _stellarBase.xdr.ScVal.fromXDR(evt.value,
|
|
98
|
+
value: _stellarBase.xdr.ScVal.fromXDR(evt.value, "base64")
|
|
98
99
|
});
|
|
99
100
|
})
|
|
100
101
|
};
|
|
@@ -109,8 +110,8 @@ function parseRawLedgerEntries(raw) {
|
|
|
109
110
|
}
|
|
110
111
|
return _objectSpread({
|
|
111
112
|
lastModifiedLedgerSeq: rawEntry.lastModifiedLedgerSeq,
|
|
112
|
-
key: _stellarBase.xdr.LedgerKey.fromXDR(rawEntry.key,
|
|
113
|
-
val: _stellarBase.xdr.LedgerEntryData.fromXDR(rawEntry.xdr,
|
|
113
|
+
key: _stellarBase.xdr.LedgerKey.fromXDR(rawEntry.key, "base64"),
|
|
114
|
+
val: _stellarBase.xdr.LedgerEntryData.fromXDR(rawEntry.xdr, "base64")
|
|
114
115
|
}, rawEntry.liveUntilLedgerSeq !== undefined && {
|
|
115
116
|
liveUntilLedgerSeq: rawEntry.liveUntilLedgerSeq
|
|
116
117
|
});
|
|
@@ -127,22 +128,22 @@ function parseSuccessful(sim, partial) {
|
|
|
127
128
|
var _row$auth;
|
|
128
129
|
return {
|
|
129
130
|
auth: ((_row$auth = row.auth) !== null && _row$auth !== void 0 ? _row$auth : []).map(function (entry) {
|
|
130
|
-
return _stellarBase.xdr.SorobanAuthorizationEntry.fromXDR(entry,
|
|
131
|
+
return _stellarBase.xdr.SorobanAuthorizationEntry.fromXDR(entry, "base64");
|
|
131
132
|
}),
|
|
132
|
-
retval: row.xdr ? _stellarBase.xdr.ScVal.fromXDR(row.xdr,
|
|
133
|
+
retval: row.xdr ? _stellarBase.xdr.ScVal.fromXDR(row.xdr, "base64") : _stellarBase.xdr.ScVal.scvVoid()
|
|
133
134
|
};
|
|
134
135
|
})[0]
|
|
135
136
|
}), ((_sim$stateChanges$len = (_sim$stateChanges = sim.stateChanges) === null || _sim$stateChanges === void 0 ? void 0 : _sim$stateChanges.length) !== null && _sim$stateChanges$len !== void 0 ? _sim$stateChanges$len : 0 > 0) && {
|
|
136
137
|
stateChanges: (_sim$stateChanges2 = sim.stateChanges) === null || _sim$stateChanges2 === void 0 ? void 0 : _sim$stateChanges2.map(function (entryChange) {
|
|
137
138
|
return {
|
|
138
139
|
type: entryChange.type,
|
|
139
|
-
key: _stellarBase.xdr.LedgerKey.fromXDR(entryChange.key,
|
|
140
|
-
before: entryChange.before ? _stellarBase.xdr.LedgerEntry.fromXDR(entryChange.before,
|
|
141
|
-
after: entryChange.after ? _stellarBase.xdr.LedgerEntry.fromXDR(entryChange.after,
|
|
140
|
+
key: _stellarBase.xdr.LedgerKey.fromXDR(entryChange.key, "base64"),
|
|
141
|
+
before: entryChange.before ? _stellarBase.xdr.LedgerEntry.fromXDR(entryChange.before, "base64") : null,
|
|
142
|
+
after: entryChange.after ? _stellarBase.xdr.LedgerEntry.fromXDR(entryChange.after, "base64") : null
|
|
142
143
|
};
|
|
143
144
|
})
|
|
144
145
|
});
|
|
145
|
-
if (!sim.restorePreamble || sim.restorePreamble.transactionData ===
|
|
146
|
+
if (!sim.restorePreamble || sim.restorePreamble.transactionData === "") {
|
|
146
147
|
return success;
|
|
147
148
|
}
|
|
148
149
|
return _objectSpread(_objectSpread({}, success), {}, {
|
|
@@ -163,13 +164,35 @@ function parseRawSimulation(sim) {
|
|
|
163
164
|
id: sim.id,
|
|
164
165
|
latestLedger: sim.latestLedger,
|
|
165
166
|
events: (_sim$events$map = (_sim$events = sim.events) === null || _sim$events === void 0 ? void 0 : _sim$events.map(function (evt) {
|
|
166
|
-
return _stellarBase.xdr.DiagnosticEvent.fromXDR(evt,
|
|
167
|
+
return _stellarBase.xdr.DiagnosticEvent.fromXDR(evt, "base64");
|
|
167
168
|
})) !== null && _sim$events$map !== void 0 ? _sim$events$map : []
|
|
168
169
|
};
|
|
169
|
-
if (typeof sim.error ===
|
|
170
|
+
if (typeof sim.error === "string") {
|
|
170
171
|
return _objectSpread(_objectSpread({}, base), {}, {
|
|
171
172
|
error: sim.error
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
return parseSuccessful(sim, base);
|
|
176
|
+
}
|
|
177
|
+
function parseRawLedger(raw) {
|
|
178
|
+
if (!raw.metadataXdr || !raw.headerXdr) {
|
|
179
|
+
var missingFields;
|
|
180
|
+
if (!raw.metadataXdr && !raw.headerXdr) {
|
|
181
|
+
missingFields = "metadataXdr and headerXdr";
|
|
182
|
+
} else if (!raw.metadataXdr) {
|
|
183
|
+
missingFields = "metadataXdr";
|
|
184
|
+
} else {
|
|
185
|
+
missingFields = "headerXdr";
|
|
186
|
+
}
|
|
187
|
+
throw new TypeError("invalid ledger missing fields: ".concat(missingFields));
|
|
188
|
+
}
|
|
189
|
+
var metadataXdr = _stellarBase.xdr.LedgerCloseMeta.fromXDR(raw.metadataXdr, "base64");
|
|
190
|
+
var headerXdr = _stellarBase.xdr.LedgerHeaderHistoryEntry.fromXDR(raw.headerXdr, "base64");
|
|
191
|
+
return {
|
|
192
|
+
hash: raw.hash,
|
|
193
|
+
sequence: raw.sequence,
|
|
194
|
+
ledgerCloseTime: raw.ledgerCloseTime,
|
|
195
|
+
metadataXdr: metadataXdr,
|
|
196
|
+
headerXdr: headerXdr
|
|
197
|
+
};
|
|
175
198
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import URI from
|
|
2
|
-
import { Account, Address, Asset, Contract, FeeBumpTransaction, Transaction, xdr } from
|
|
3
|
-
import { Api } from
|
|
1
|
+
import URI from "urijs";
|
|
2
|
+
import { Account, Address, Asset, Contract, FeeBumpTransaction, Transaction, xdr } from "@stellar/stellar-base";
|
|
3
|
+
import { Api } from "./api";
|
|
4
4
|
/**
|
|
5
5
|
* Default transaction submission timeout for RPC requests, in milliseconds
|
|
6
6
|
* @constant {number}
|
|
@@ -20,14 +20,6 @@ export declare enum Durability {
|
|
|
20
20
|
Temporary = "temporary",
|
|
21
21
|
Persistent = "persistent"
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {object} GetEventsRequest Describes the complex filter combinations available for event queries.
|
|
25
|
-
* @property {Array.<module:rpc.Api.EventFilter>} filters Filters to use when querying events from the RPC server.
|
|
26
|
-
* @property {number} [startLedger] Ledger number (inclusive) to begin querying events.
|
|
27
|
-
* @property {string} [cursor] Page cursor (exclusive) to begin querying events.
|
|
28
|
-
* @property {number} [limit=100] The maximum number of events that should be returned in the RPC response.
|
|
29
|
-
* @memberof module:rpc.Server
|
|
30
|
-
*/
|
|
31
23
|
/**
|
|
32
24
|
* @typedef {object} ResourceLeeway Describes additional resource leeways for transaction simulation.
|
|
33
25
|
* @property {number} cpuInstructions Simulate the transaction with more CPU instructions available.
|
|
@@ -41,13 +33,11 @@ export declare enum Durability {
|
|
|
41
33
|
* @memberof module:rpc.Server
|
|
42
34
|
*/
|
|
43
35
|
export declare namespace RpcServer {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
limit?: number;
|
|
50
|
-
}
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Use `Api.GetEventsRequest` instead.
|
|
38
|
+
* @see {@link Api.GetEventsRequest}
|
|
39
|
+
*/
|
|
40
|
+
type GetEventsRequest = Api.GetEventsRequest;
|
|
51
41
|
interface PollingOptions {
|
|
52
42
|
attempts?: number;
|
|
53
43
|
sleepStrategy?: SleepStrategy;
|
|
@@ -106,6 +96,66 @@ export declare class RpcServer {
|
|
|
106
96
|
* });
|
|
107
97
|
*/
|
|
108
98
|
getAccount(address: string): Promise<Account>;
|
|
99
|
+
/**
|
|
100
|
+
* Fetch the full account entry for a Stellar account.
|
|
101
|
+
*
|
|
102
|
+
* @param {string} address The public address of the account to load.
|
|
103
|
+
* @returns {Promise<xdr.AccountEntry>} Resolves to the full on-chain account
|
|
104
|
+
* entry
|
|
105
|
+
*
|
|
106
|
+
* @see
|
|
107
|
+
* {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* const accountId = "GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4";
|
|
111
|
+
* server.getAccountEntry(accountId).then((account) => {
|
|
112
|
+
* console.log("sequence:", account.balance().toString());
|
|
113
|
+
* });
|
|
114
|
+
*/
|
|
115
|
+
getAccountEntry(address: string): Promise<xdr.AccountEntry>;
|
|
116
|
+
/**
|
|
117
|
+
* Fetch the full trustline entry for a Stellar account.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} account The public address of the account whose trustline it is
|
|
120
|
+
* @param {string} asset The trustline's asset
|
|
121
|
+
* @returns {Promise<xdr.TrustLineEntry>} Resolves to the full on-chain trustline
|
|
122
|
+
* entry
|
|
123
|
+
*
|
|
124
|
+
* @see
|
|
125
|
+
* {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* const accountId = "GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4";
|
|
129
|
+
* const asset = new Asset(
|
|
130
|
+
* "USDC",
|
|
131
|
+
* "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
|
|
132
|
+
* );
|
|
133
|
+
* server.getTrustline(accountId, asset).then((entry) => {
|
|
134
|
+
* console.log(`{asset.toString()} balance for ${accountId}:", entry.balance().toString());
|
|
135
|
+
* });
|
|
136
|
+
*/
|
|
137
|
+
getTrustline(account: string, asset: Asset): Promise<xdr.TrustLineEntry>;
|
|
138
|
+
/**
|
|
139
|
+
* Fetch the full claimable balance entry for a Stellar account.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} id The strkey (`B...`) or hex (`00000000abcde...`) (both
|
|
142
|
+
* IDs with and without the 000... version prefix are accepted) of the
|
|
143
|
+
* claimable balance to load
|
|
144
|
+
* @returns {Promise<xdr.ClaimableBalanceEntry>} Resolves to the full on-chain
|
|
145
|
+
* claimable balance entry
|
|
146
|
+
*
|
|
147
|
+
* @see
|
|
148
|
+
* {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* const id = "00000000178826fbfe339e1f5c53417c6fedfe2c05e8bec14303143ec46b38981b09c3f9";
|
|
152
|
+
* server.getClaimableBalance(id).then((entry) => {
|
|
153
|
+
* console.log(`Claimable balance {id.substr(0, 12)} has:`);
|
|
154
|
+
* console.log(` asset: ${Asset.fromXDRObject(entry.asset()).toString()}`;
|
|
155
|
+
* console.log(` amount: ${entry.amount().toString()}`;
|
|
156
|
+
* });
|
|
157
|
+
*/
|
|
158
|
+
getClaimableBalance(id: string): Promise<xdr.ClaimableBalanceEntry>;
|
|
109
159
|
/**
|
|
110
160
|
* General node health check.
|
|
111
161
|
*
|
|
@@ -231,6 +281,7 @@ export declare class RpcServer {
|
|
|
231
281
|
*/
|
|
232
282
|
getLedgerEntries(...keys: xdr.LedgerKey[]): Promise<Api.GetLedgerEntriesResponse>;
|
|
233
283
|
_getLedgerEntries(...keys: xdr.LedgerKey[]): Promise<Api.RawGetLedgerEntriesResponse>;
|
|
284
|
+
getLedgerEntry(key: xdr.LedgerKey): Promise<Api.LedgerEntryResult>;
|
|
234
285
|
/**
|
|
235
286
|
* Poll for a particular transaction with certain parameters.
|
|
236
287
|
*
|
|
@@ -304,20 +355,21 @@ export declare class RpcServer {
|
|
|
304
355
|
/**
|
|
305
356
|
* Fetch all events that match a given set of filters.
|
|
306
357
|
*
|
|
307
|
-
* The given filters (see {@link
|
|
358
|
+
* The given filters (see {@link Api.EventFilter}
|
|
308
359
|
* for detailed fields) are combined only in a logical OR fashion, and all of
|
|
309
360
|
* the fields in each filter are optional.
|
|
310
361
|
*
|
|
311
362
|
* To page through events, use the `pagingToken` field on the relevant
|
|
312
363
|
* {@link Api.EventResponse} object to set the `cursor` parameter.
|
|
313
364
|
*
|
|
314
|
-
* @param {
|
|
365
|
+
* @param {Api.GetEventsRequest} request Event filters {@link Api.GetEventsRequest},
|
|
315
366
|
* @returns {Promise<Api.GetEventsResponse>} A paginatable set of the events
|
|
316
367
|
* matching the given event filters
|
|
317
368
|
*
|
|
318
369
|
* @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents docs}
|
|
319
370
|
*
|
|
320
371
|
* @example
|
|
372
|
+
*
|
|
321
373
|
* server.getEvents({
|
|
322
374
|
* startLedger: 1000,
|
|
323
375
|
* endLedger: 2000,
|
|
@@ -341,8 +393,8 @@ export declare class RpcServer {
|
|
|
341
393
|
* limit: 10,
|
|
342
394
|
* });
|
|
343
395
|
*/
|
|
344
|
-
getEvents(request:
|
|
345
|
-
_getEvents(request:
|
|
396
|
+
getEvents(request: Api.GetEventsRequest): Promise<Api.GetEventsResponse>;
|
|
397
|
+
_getEvents(request: Api.GetEventsRequest): Promise<Api.RawGetEventsResponse>;
|
|
346
398
|
/**
|
|
347
399
|
* Fetch metadata about the network this Soroban RPC server is connected to.
|
|
348
400
|
*
|
|
@@ -563,7 +615,7 @@ export declare class RpcServer {
|
|
|
563
615
|
* off" if it already exists)
|
|
564
616
|
* @throws If Friendbot is not configured on this network or request failure
|
|
565
617
|
*
|
|
566
|
-
* @see {@link https://developers.stellar.org/docs/learn/networks#friendbot | Friendbot docs}
|
|
618
|
+
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}
|
|
567
619
|
* @see {@link module:Friendbot.Api.Response}
|
|
568
620
|
*
|
|
569
621
|
* @example
|
|
@@ -575,7 +627,7 @@ export declare class RpcServer {
|
|
|
575
627
|
* console.error("error:", error);
|
|
576
628
|
* });
|
|
577
629
|
*/
|
|
578
|
-
requestAirdrop(address: string | Pick<Account,
|
|
630
|
+
requestAirdrop(address: string | Pick<Account, "accountId">, friendbotUrl?: string): Promise<Account>;
|
|
579
631
|
/**
|
|
580
632
|
* Provides an analysis of the recent fee stats for regular and smart
|
|
581
633
|
* contract operations.
|
|
@@ -596,8 +648,8 @@ export declare class RpcServer {
|
|
|
596
648
|
*
|
|
597
649
|
* This is a convenience wrapper around {@link Server.getLedgerEntries}.
|
|
598
650
|
*
|
|
599
|
-
* @param {string}
|
|
600
|
-
* balance of `sac` you want to know
|
|
651
|
+
* @param {string} address the contract (string `C...`) or account ID
|
|
652
|
+
* (`G...`) whose balance of `sac` you want to know
|
|
601
653
|
* @param {Asset} sac the built-in SAC token (e.g. `USDC:GABC...`) that
|
|
602
654
|
* you are querying from the given `contract`.
|
|
603
655
|
* @param {string} [networkPassphrase] optionally, the network passphrase to
|
|
@@ -610,16 +662,16 @@ export declare class RpcServer {
|
|
|
610
662
|
* entry details if and only if the request returned a valid balance ledger
|
|
611
663
|
* entry. If it doesn't, the `balanceEntry` field will not exist.
|
|
612
664
|
*
|
|
613
|
-
* @throws {TypeError} If `
|
|
665
|
+
* @throws {TypeError} If `address` is not a valid contract ID (C...).
|
|
614
666
|
*
|
|
615
667
|
* @see getLedgerEntries
|
|
616
668
|
* @see https://developers.stellar.org/docs/tokens/stellar-asset-contract
|
|
617
669
|
*
|
|
618
670
|
* @example
|
|
619
|
-
* // assume `
|
|
671
|
+
* // assume `address` is some contract or account with an XLM balance
|
|
620
672
|
* // assume server is an instantiated `Server` instance.
|
|
621
673
|
* const entry = (await server.getSACBalance(
|
|
622
|
-
* new Address(
|
|
674
|
+
* new Address(address),
|
|
623
675
|
* Asset.native(),
|
|
624
676
|
* Networks.PUBLIC
|
|
625
677
|
* ));
|
|
@@ -628,7 +680,47 @@ export declare class RpcServer {
|
|
|
628
680
|
* console.log(
|
|
629
681
|
* entry.balanceEntry ?
|
|
630
682
|
* BigInt(entry.balanceEntry.amount) :
|
|
631
|
-
* "
|
|
683
|
+
* "Address has no XLM");
|
|
684
|
+
*/
|
|
685
|
+
getSACBalance(address: string | Address, sac: Asset, networkPassphrase?: string): Promise<Api.BalanceResponse>;
|
|
686
|
+
/**
|
|
687
|
+
* Fetch a detailed list of ledgers starting from a specified point.
|
|
688
|
+
*
|
|
689
|
+
* Returns ledger data with support for pagination as long as the requested
|
|
690
|
+
* pages fall within the history retention of the RPC provider.
|
|
691
|
+
*
|
|
692
|
+
* @param {Api.GetLedgersRequest} request - The request parameters for fetching ledgers. {@link Api.GetLedgersRequest}
|
|
693
|
+
* @returns {Promise<Api.GetLedgersResponse>} A promise that resolves to the
|
|
694
|
+
* ledgers response containing an array of ledger data and pagination info. {@link Api.GetLedgersResponse}
|
|
695
|
+
*
|
|
696
|
+
* @throws {Error} If startLedger is less than the oldest ledger stored in this
|
|
697
|
+
* node, or greater than the latest ledger seen by this node.
|
|
698
|
+
*
|
|
699
|
+
* @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers docs}
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* // Fetch ledgers starting from a specific sequence number
|
|
703
|
+
* server.getLedgers({
|
|
704
|
+
* startLedger: 36233,
|
|
705
|
+
* limit: 10
|
|
706
|
+
* }).then((response) => {
|
|
707
|
+
* console.log("Ledgers:", response.ledgers);
|
|
708
|
+
* console.log("Latest Ledger:", response.latestLedger);
|
|
709
|
+
* console.log("Cursor:", response.cursor);
|
|
710
|
+
* });
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* // Paginate through ledgers using cursor
|
|
714
|
+
* const firstPage = await server.getLedgers({
|
|
715
|
+
* startLedger: 36233,
|
|
716
|
+
* limit: 5
|
|
717
|
+
* });
|
|
718
|
+
*
|
|
719
|
+
* const nextPage = await server.getLedgers({
|
|
720
|
+
* cursor: firstPage.cursor,
|
|
721
|
+
* limit: 5
|
|
722
|
+
* });
|
|
632
723
|
*/
|
|
633
|
-
|
|
724
|
+
getLedgers(request: Api.GetLedgersRequest): Promise<Api.GetLedgersResponse>;
|
|
725
|
+
_getLedgers(request: Api.GetLedgersRequest): Promise<Api.RawGetLedgersResponse>;
|
|
634
726
|
}
|