@stellar/stellar-sdk 14.3.2 → 14.4.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/stellar-sdk-minimal.js +7222 -7108
  3. package/dist/stellar-sdk-minimal.min.js +1 -1
  4. package/dist/stellar-sdk-no-axios.js +3460 -3346
  5. package/dist/stellar-sdk-no-axios.min.js +1 -1
  6. package/dist/stellar-sdk-no-eventsource.js +7213 -7099
  7. package/dist/stellar-sdk-no-eventsource.min.js +1 -1
  8. package/dist/stellar-sdk.js +8051 -7937
  9. package/dist/stellar-sdk.min.js +1 -1
  10. package/lib/config.d.ts +2 -6
  11. package/lib/contract/assembled_transaction.d.ts +16 -132
  12. package/lib/contract/assembled_transaction.js +14 -114
  13. package/lib/contract/errors.d.ts +26 -0
  14. package/lib/contract/errors.js +126 -0
  15. package/lib/contract/sent_transaction.d.ts +1 -1
  16. package/lib/contract/spec.d.ts +2 -2
  17. package/lib/contract/spec.js +40 -28
  18. package/lib/contract/types.d.ts +35 -9
  19. package/lib/contract/utils.d.ts +1 -1
  20. package/lib/contract/utils.js +18 -53
  21. package/lib/contract/wasm_spec_parser.d.ts +7 -0
  22. package/lib/contract/wasm_spec_parser.js +15 -0
  23. package/lib/errors/network.d.ts +1 -1
  24. package/lib/federation/server.d.ts +7 -7
  25. package/lib/horizon/horizon_axios_client.js +1 -1
  26. package/lib/horizon/server.d.ts +1 -1
  27. package/lib/horizon/server.js +2 -2
  28. package/lib/index.d.ts +0 -3
  29. package/lib/minimal/config.d.ts +2 -6
  30. package/lib/minimal/contract/assembled_transaction.d.ts +16 -132
  31. package/lib/minimal/contract/assembled_transaction.js +14 -114
  32. package/lib/minimal/contract/errors.d.ts +26 -0
  33. package/lib/minimal/contract/errors.js +126 -0
  34. package/lib/minimal/contract/sent_transaction.d.ts +1 -1
  35. package/lib/minimal/contract/spec.d.ts +2 -2
  36. package/lib/minimal/contract/spec.js +40 -28
  37. package/lib/minimal/contract/types.d.ts +35 -9
  38. package/lib/minimal/contract/utils.d.ts +1 -1
  39. package/lib/minimal/contract/utils.js +18 -53
  40. package/lib/minimal/contract/wasm_spec_parser.d.ts +7 -0
  41. package/lib/minimal/contract/wasm_spec_parser.js +15 -0
  42. package/lib/minimal/errors/network.d.ts +1 -1
  43. package/lib/minimal/federation/server.d.ts +7 -7
  44. package/lib/minimal/horizon/horizon_axios_client.js +1 -1
  45. package/lib/minimal/horizon/server.d.ts +1 -1
  46. package/lib/minimal/horizon/server.js +2 -2
  47. package/lib/minimal/index.d.ts +0 -3
  48. package/lib/minimal/rpc/api.d.ts +27 -3
  49. package/lib/minimal/rpc/axios.js +1 -1
  50. package/lib/minimal/rpc/jsonrpc.d.ts +2 -1
  51. package/lib/minimal/rpc/jsonrpc.js +1 -1
  52. package/lib/minimal/rpc/parsers.js +8 -5
  53. package/lib/minimal/rpc/server.d.ts +46 -7
  54. package/lib/minimal/rpc/server.js +290 -211
  55. package/lib/minimal/rpc/utils.js +1 -1
  56. package/lib/minimal/webauth/challenge_transaction.d.ts +235 -0
  57. package/lib/minimal/webauth/challenge_transaction.js +307 -0
  58. package/lib/minimal/webauth/index.d.ts +1 -0
  59. package/lib/minimal/webauth/index.js +13 -1
  60. package/lib/minimal/webauth/utils.d.ts +28 -273
  61. package/lib/minimal/webauth/utils.js +12 -288
  62. package/lib/no-axios/config.d.ts +2 -6
  63. package/lib/no-axios/contract/assembled_transaction.d.ts +16 -132
  64. package/lib/no-axios/contract/assembled_transaction.js +14 -114
  65. package/lib/no-axios/contract/errors.d.ts +26 -0
  66. package/lib/no-axios/contract/errors.js +126 -0
  67. package/lib/no-axios/contract/sent_transaction.d.ts +1 -1
  68. package/lib/no-axios/contract/spec.d.ts +2 -2
  69. package/lib/no-axios/contract/spec.js +40 -28
  70. package/lib/no-axios/contract/types.d.ts +35 -9
  71. package/lib/no-axios/contract/utils.d.ts +1 -1
  72. package/lib/no-axios/contract/utils.js +18 -53
  73. package/lib/no-axios/contract/wasm_spec_parser.d.ts +7 -0
  74. package/lib/no-axios/contract/wasm_spec_parser.js +15 -0
  75. package/lib/no-axios/errors/network.d.ts +1 -1
  76. package/lib/no-axios/federation/server.d.ts +7 -7
  77. package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
  78. package/lib/no-axios/horizon/server.d.ts +1 -1
  79. package/lib/no-axios/horizon/server.js +2 -2
  80. package/lib/no-axios/index.d.ts +0 -3
  81. package/lib/no-axios/rpc/api.d.ts +27 -3
  82. package/lib/no-axios/rpc/axios.js +1 -1
  83. package/lib/no-axios/rpc/jsonrpc.d.ts +2 -1
  84. package/lib/no-axios/rpc/jsonrpc.js +1 -1
  85. package/lib/no-axios/rpc/parsers.js +8 -5
  86. package/lib/no-axios/rpc/server.d.ts +46 -7
  87. package/lib/no-axios/rpc/server.js +290 -211
  88. package/lib/no-axios/rpc/utils.js +1 -1
  89. package/lib/no-axios/webauth/challenge_transaction.d.ts +235 -0
  90. package/lib/no-axios/webauth/challenge_transaction.js +307 -0
  91. package/lib/no-axios/webauth/index.d.ts +1 -0
  92. package/lib/no-axios/webauth/index.js +13 -1
  93. package/lib/no-axios/webauth/utils.d.ts +28 -273
  94. package/lib/no-axios/webauth/utils.js +12 -288
  95. package/lib/no-eventsource/config.d.ts +2 -6
  96. package/lib/no-eventsource/contract/assembled_transaction.d.ts +16 -132
  97. package/lib/no-eventsource/contract/assembled_transaction.js +14 -114
  98. package/lib/no-eventsource/contract/errors.d.ts +26 -0
  99. package/lib/no-eventsource/contract/errors.js +126 -0
  100. package/lib/no-eventsource/contract/sent_transaction.d.ts +1 -1
  101. package/lib/no-eventsource/contract/spec.d.ts +2 -2
  102. package/lib/no-eventsource/contract/spec.js +40 -28
  103. package/lib/no-eventsource/contract/types.d.ts +35 -9
  104. package/lib/no-eventsource/contract/utils.d.ts +1 -1
  105. package/lib/no-eventsource/contract/utils.js +18 -53
  106. package/lib/no-eventsource/contract/wasm_spec_parser.d.ts +7 -0
  107. package/lib/no-eventsource/contract/wasm_spec_parser.js +15 -0
  108. package/lib/no-eventsource/errors/network.d.ts +1 -1
  109. package/lib/no-eventsource/federation/server.d.ts +7 -7
  110. package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
  111. package/lib/no-eventsource/horizon/server.d.ts +1 -1
  112. package/lib/no-eventsource/horizon/server.js +2 -2
  113. package/lib/no-eventsource/index.d.ts +0 -3
  114. package/lib/no-eventsource/rpc/api.d.ts +27 -3
  115. package/lib/no-eventsource/rpc/axios.js +1 -1
  116. package/lib/no-eventsource/rpc/jsonrpc.d.ts +2 -1
  117. package/lib/no-eventsource/rpc/jsonrpc.js +1 -1
  118. package/lib/no-eventsource/rpc/parsers.js +8 -5
  119. package/lib/no-eventsource/rpc/server.d.ts +46 -7
  120. package/lib/no-eventsource/rpc/server.js +290 -211
  121. package/lib/no-eventsource/rpc/utils.js +1 -1
  122. package/lib/no-eventsource/webauth/challenge_transaction.d.ts +235 -0
  123. package/lib/no-eventsource/webauth/challenge_transaction.js +307 -0
  124. package/lib/no-eventsource/webauth/index.d.ts +1 -0
  125. package/lib/no-eventsource/webauth/index.js +13 -1
  126. package/lib/no-eventsource/webauth/utils.d.ts +28 -273
  127. package/lib/no-eventsource/webauth/utils.js +12 -288
  128. package/lib/rpc/api.d.ts +27 -3
  129. package/lib/rpc/axios.js +1 -1
  130. package/lib/rpc/jsonrpc.d.ts +2 -1
  131. package/lib/rpc/jsonrpc.js +1 -1
  132. package/lib/rpc/parsers.js +8 -5
  133. package/lib/rpc/server.d.ts +46 -7
  134. package/lib/rpc/server.js +290 -211
  135. package/lib/rpc/utils.js +1 -1
  136. package/lib/webauth/challenge_transaction.d.ts +235 -0
  137. package/lib/webauth/challenge_transaction.js +307 -0
  138. package/lib/webauth/index.d.ts +1 -0
  139. package/lib/webauth/index.js +13 -1
  140. package/lib/webauth/utils.d.ts +28 -273
  141. package/lib/webauth/utils.js +12 -288
  142. package/package.json +14 -14
  143. package/types/dom-monkeypatch.d.ts +1 -1
@@ -42,7 +42,7 @@ export type u256 = bigint;
42
42
  */
43
43
  export type i256 = bigint;
44
44
  export type Option<T> = T | undefined;
45
- export type Typepoint = bigint;
45
+ export type Timepoint = bigint;
46
46
  export type Duration = bigint;
47
47
  /**
48
48
  * A "regular" transaction, as opposed to a FeeBumpTransaction.
@@ -111,18 +111,16 @@ export type SignAuthEntry = (authEntry: string, opts?: {
111
111
  */
112
112
  export type ClientOptions = {
113
113
  /**
114
- * The public key of the account that will send this transaction. You can
115
- * override this for specific methods later, like
116
- * [signAndSend]{@link module:contract.AssembledTransaction#signAndSend} and
117
- * [signAuthEntries]{@link module:contract.AssembledTransaction#signAuthEntries}.
114
+ * The public key of the source account for this transaction. You can
115
+ * override this for specific methods later; see {@link MethodOptions}.
118
116
  */
119
117
  publicKey?: string;
120
118
  /**
121
119
  * A function to sign the transaction using the private key corresponding to
122
120
  * the given `publicKey`. You do not need to provide this, for read-only
123
- * calls, which only need to be simulated. If you do not need to sign and
124
- * send, there is no need to provide this. If you do not provide it during
125
- * initialization, you can provide it later when you call
121
+ * calls, which only need to be simulated. If you do not provide it during
122
+ * initialization, you can provide it later, either when you initialize a
123
+ * method (see {@link MethodOptions}) or when you call
126
124
  * {@link module:contract.AssembledTransaction#signAndSend signAndSend}.
127
125
  *
128
126
  * Matches signature of `signTransaction` from Freighter.
@@ -133,7 +131,8 @@ export type ClientOptions = {
133
131
  * private key corresponding to the provided `publicKey`. This is only needed
134
132
  * for multi-auth transactions, in which one transaction is signed by
135
133
  * multiple parties. If you do not provide it during initialization, you can
136
- * provide it later when you call {@link module:contract.AssembledTransaction#signAuthEntries signAuthEntries}.
134
+ * provide it later either when you initialize a method (see {@link MethodOptions})
135
+ * or when you call {@link module:contract.AssembledTransaction#signAuthEntries signAuthEntries}.
137
136
  *
138
137
  * Matches signature of `signAuthEntry` from Freighter.
139
138
  */
@@ -212,6 +211,33 @@ export type MethodOptions = {
212
211
  * @default false
213
212
  */
214
213
  restore?: boolean;
214
+ /**
215
+ * The public key of the source account for this transaction.
216
+ *
217
+ * Default: the one provided to the {@link Client} in {@link ClientOptions}
218
+ */
219
+ publicKey?: string;
220
+ /**
221
+ * A function to sign the transaction using the private key corresponding to
222
+ * the given `publicKey`. You do not need to provide this, for read-only
223
+ * calls, which only need to be simulated.
224
+ *
225
+ * Matches signature of `signTransaction` from Freighter.
226
+ *
227
+ * Default: the one provided to the {@link Client} in {@link ClientOptions}
228
+ */
229
+ signTransaction?: SignTransaction;
230
+ /**
231
+ * A function to sign a specific auth entry for a transaction, using the
232
+ * private key corresponding to the provided `publicKey`. This is only needed
233
+ * for multi-auth transactions, in which one transaction is signed by
234
+ * multiple parties.
235
+ *
236
+ * Matches signature of `signAuthEntry` from Freighter.
237
+ *
238
+ * Default: the one provided to the {@link Client} in {@link ClientOptions}
239
+ */
240
+ signAuthEntry?: SignAuthEntry;
215
241
  };
216
242
  export type AssembledTransactionOptions<T = string> = MethodOptions & ClientOptions & {
217
243
  method: string;
@@ -38,7 +38,7 @@ export declare function implementsToString(
38
38
  obj: unknown): obj is {
39
39
  toString(): string;
40
40
  };
41
- export declare function specFromWasm(wasm: Buffer): Promise<Buffer>;
41
+ export declare function parseWasmCustomSections(buffer: Buffer): Map<string, Uint8Array[]>;
42
42
  /**
43
43
  * Reads a binary stream of ScSpecEntries into an array for processing by ContractSpec
44
44
  * @private
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.contractErrorPattern = void 0;
7
7
  exports.getAccount = getAccount;
8
8
  exports.implementsToString = implementsToString;
9
+ exports.parseWasmCustomSections = parseWasmCustomSections;
9
10
  exports.processSpecEntryStream = processSpecEntryStream;
10
- exports.specFromWasm = specFromWasm;
11
11
  exports.withExponentialBackoff = withExponentialBackoff;
12
12
  var _stellarBase = require("@stellar/stellar-base");
13
13
  var _types = require("./types");
@@ -101,41 +101,6 @@ var contractErrorPattern = exports.contractErrorPattern = /Error\(Contract, #(\d
101
101
  function implementsToString(obj) {
102
102
  return _typeof(obj) === "object" && obj !== null && "toString" in obj;
103
103
  }
104
- function specFromWasm(_x4) {
105
- return _specFromWasm.apply(this, arguments);
106
- }
107
- function _specFromWasm() {
108
- _specFromWasm = _asyncToGenerator(_regenerator().m(function _callee2(wasm) {
109
- var xdrSections, wasmModule, customData, _t3;
110
- return _regenerator().w(function (_context2) {
111
- while (1) switch (_context2.p = _context2.n) {
112
- case 0:
113
- _context2.p = 0;
114
- _context2.n = 1;
115
- return WebAssembly.compile(wasm);
116
- case 1:
117
- wasmModule = _context2.v;
118
- xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
119
- _context2.n = 3;
120
- break;
121
- case 2:
122
- _context2.p = 2;
123
- _t3 = _context2.v;
124
- customData = parseWasmCustomSections(wasm);
125
- xdrSections = customData.get("contractspecv0");
126
- case 3:
127
- if (!(!xdrSections || xdrSections.length === 0)) {
128
- _context2.n = 4;
129
- break;
130
- }
131
- throw new Error("Could not obtain contract spec from wasm");
132
- case 4:
133
- return _context2.a(2, Buffer.from(xdrSections[0]));
134
- }
135
- }, _callee2, null, [[0, 2]]);
136
- }));
137
- return _specFromWasm.apply(this, arguments);
138
- }
139
104
  function parseWasmCustomSections(buffer) {
140
105
  var sections = new Map();
141
106
  var arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
@@ -146,6 +111,17 @@ function parseWasmCustomSections(buffer) {
146
111
  offset += length;
147
112
  return bytes;
148
113
  };
114
+ function readVarUint32() {
115
+ var value = 0;
116
+ var shift = 0;
117
+ while (true) {
118
+ var byte = read(1)[0];
119
+ value |= (byte & 0x7f) << shift;
120
+ if ((byte & 0x80) === 0) break;
121
+ if ((shift += 7) >= 32) throw new Error("Invalid WASM value");
122
+ }
123
+ return value >>> 0;
124
+ }
149
125
  if (_toConsumableArray(read(4)).join() !== "0,97,115,109") throw new Error("Invalid WASM magic");
150
126
  if (_toConsumableArray(read(4)).join() !== "1,0,0,0") throw new Error("Invalid WASM version");
151
127
  while (offset < buffer.byteLength) {
@@ -169,17 +145,6 @@ function parseWasmCustomSections(buffer) {
169
145
  offset += sectionLength;
170
146
  }
171
147
  }
172
- function readVarUint32() {
173
- var value = 0,
174
- shift = 0;
175
- while (true) {
176
- var byte = read(1)[0];
177
- value |= (byte & 0x7f) << shift;
178
- if ((byte & 0x80) === 0) break;
179
- if ((shift += 7) >= 32) throw new Error("Invalid WASM value");
180
- }
181
- return value >>> 0;
182
- }
183
148
  return sections;
184
149
  }
185
150
  function processSpecEntryStream(buffer) {
@@ -190,17 +155,17 @@ function processSpecEntryStream(buffer) {
190
155
  }
191
156
  return res;
192
157
  }
193
- function getAccount(_x5, _x6) {
158
+ function getAccount(_x4, _x5) {
194
159
  return _getAccount.apply(this, arguments);
195
160
  }
196
161
  function _getAccount() {
197
- _getAccount = _asyncToGenerator(_regenerator().m(function _callee3(options, server) {
198
- return _regenerator().w(function (_context3) {
199
- while (1) switch (_context3.n) {
162
+ _getAccount = _asyncToGenerator(_regenerator().m(function _callee2(options, server) {
163
+ return _regenerator().w(function (_context2) {
164
+ while (1) switch (_context2.n) {
200
165
  case 0:
201
- return _context3.a(2, options.publicKey ? server.getAccount(options.publicKey) : new _stellarBase.Account(_types.NULL_ACCOUNT, "0"));
166
+ return _context2.a(2, options.publicKey ? server.getAccount(options.publicKey) : new _stellarBase.Account(_types.NULL_ACCOUNT, "0"));
202
167
  }
203
- }, _callee3);
168
+ }, _callee2);
204
169
  }));
205
170
  return _getAccount.apply(this, arguments);
206
171
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Obtains the contract spec XDR from a contract's wasm binary.
3
+ * @param wasm The contract's wasm binary as a Buffer.
4
+ * @returns The XDR buffer representing the contract spec.
5
+ * @throws {Error} If the contract spec cannot be obtained from the provided wasm binary.
6
+ */
7
+ export declare function specFromWasm(wasm: Buffer): Buffer;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.specFromWasm = specFromWasm;
7
+ var _utils = require("./utils");
8
+ function specFromWasm(wasm) {
9
+ var customData = (0, _utils.parseWasmCustomSections)(wasm);
10
+ var xdrSections = customData.get("contractspecv0");
11
+ if (!xdrSections || xdrSections.length === 0) {
12
+ throw new Error("Could not obtain contract spec from wasm");
13
+ }
14
+ return Buffer.from(xdrSections[0]);
15
+ }
@@ -21,7 +21,7 @@ export declare class NetworkError extends Error {
21
21
  constructor(message: string, response: any);
22
22
  /**
23
23
  * Returns the error response sent by the Horizon server.
24
- * @returns {any}
24
+ * @returns {any} Response details, received from the Horizon server.
25
25
  */
26
26
  getResponse(): {
27
27
  data?: HorizonApi.ErrorResponseData;
@@ -56,7 +56,7 @@ export declare class FederationServer {
56
56
  * @param {string} value Stellar Address (ex. `bob*stellar.org`)
57
57
  * @param {object} [opts] Options object
58
58
  * @returns {Promise<module:Federation.Api.Record>} A promise that resolves to the federation record
59
- * @throws Will throw an error if the provided account ID is not a valid Ed25519 public key.
59
+ * @throws {Error} Will throw an error if the provided account ID is not a valid Ed25519 public key.
60
60
  */
61
61
  static resolve(value: string, opts?: Api.Options): Promise<Api.Record>;
62
62
  /**
@@ -80,7 +80,7 @@ export declare class FederationServer {
80
80
  * @param {string} domain Domain to get federation server for
81
81
  * @param {module:Federation.Api.Options} [opts] Options object
82
82
  * @returns {Promise<module:Federation.Api.Record>} A promise that resolves to the federation record
83
- * @throws Will throw an error if the domain's stellar.toml file does not contain a federation server field.
83
+ * @throws {Error} Will throw an error if the domain's stellar.toml file does not contain a federation server field.
84
84
  */
85
85
  static createForDomain(domain: string, opts?: Api.Options): Promise<FederationServer>;
86
86
  constructor(serverURL: string, domain: string, opts?: Api.Options);
@@ -89,7 +89,7 @@ export declare class FederationServer {
89
89
  * @see <a href="https://developers.stellar.org/docs/encyclopedia/federation" target="_blank">Federation doc</a>
90
90
  * @param {string} address Stellar address (ex. `bob*stellar.org`). If `FederationServer` was instantiated with `domain` param only username (ex. `bob`) can be passed.
91
91
  * @returns {Promise<module:Federation.Api.Record>} A promise that resolves to the federation record
92
- * @throws Will throw an error if the federated address does not contain a domain, or if the server object was not instantiated with a `domain` parameter
92
+ * @throws {Error} Will throw an error if the federated address does not contain a domain, or if the server object was not instantiated with a `domain` parameter
93
93
  */
94
94
  resolveAddress(address: string): Promise<Api.Record>;
95
95
  /**
@@ -97,8 +97,8 @@ export declare class FederationServer {
97
97
  * @see <a href="https://developers.stellar.org/docs/encyclopedia/federation" target="_blank">Federation doc</a>
98
98
  * @param {string} accountId Account ID (ex. `GBYNR2QJXLBCBTRN44MRORCMI4YO7FZPFBCNOKTOBCAAFC7KC3LNPRYS`)
99
99
  * @returns {Promise<module:Federation.Api.Record>} A promise that resolves to the federation record
100
- * @throws Will throw an error if the federation server returns an invalid memo value.
101
- * @throws Will throw an error if the federation server's response exceeds the allowed maximum size.
100
+ * @throws {Error} Will throw an error if the federation server returns an invalid memo value.
101
+ * @throws {Error} Will throw an error if the federation server's response exceeds the allowed maximum size.
102
102
  * @throws {BadResponseError} Will throw an error if the server query fails with an improper response.
103
103
  */
104
104
  resolveAccountId(accountId: string): Promise<Api.Record>;
@@ -107,8 +107,8 @@ export declare class FederationServer {
107
107
  * @see <a href="https://developers.stellar.org/docs/glossary/federation/" target="_blank">Federation doc</a>
108
108
  * @param {string} transactionId Transaction ID (ex. `3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889`)
109
109
  * @returns {Promise<module:Federation.Api.Record>} A promise that resolves to the federation record
110
- * @throws Will throw an error if the federation server returns an invalid memo value.
111
- * @throws Will throw an error if the federation server's response exceeds the allowed maximum size.
110
+ * @throws {Error} Will throw an error if the federation server returns an invalid memo value.
111
+ * @throws {Error} Will throw an error if the federation server's response exceeds the allowed maximum size.
112
112
  * @throws {BadResponseError} Will throw an error if the server query fails with an improper response.
113
113
  */
114
114
  resolveTransactionId(transactionId: string): Promise<Api.Record>;
@@ -16,7 +16,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
16
16
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
18
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
- var version = exports.version = "14.3.2";
19
+ var version = exports.version = "14.4.0";
20
20
  var SERVER_TIME_MAP = exports.SERVER_TIME_MAP = {};
21
21
  function toSeconds(ms) {
22
22
  return Math.floor(ms / 1000);
@@ -83,7 +83,7 @@ export declare class HorizonServer {
83
83
  * @param {number} seconds Number of seconds past the current time to wait.
84
84
  * @param {boolean} [_isRetry] True if this is a retry. Only set this internally!
85
85
  * This is to avoid a scenario where Horizon is horking up the wrong date.
86
- * @returns {Promise<Timebounds>} Promise that resolves a `timebounds` object
86
+ * @returns {Promise<module:HorizonServer.Timebounds>} Promise that resolves a `Timebounds` object
87
87
  * (with the shape `{ minTime: 0, maxTime: N }`) that you can set the `timebounds` option to.
88
88
  */
89
89
  fetchTimebounds(seconds: number, _isRetry?: boolean): Promise<HorizonServer.Timebounds>;
@@ -193,7 +193,7 @@ var HorizonServer = exports.HorizonServer = function () {
193
193
  return this.checkMemoRequired(transaction);
194
194
  case 1:
195
195
  tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
196
- return _context5.a(2, this.httpClient.post(this.serverURL.segment("transactions").toString(), "tx=".concat(tx), {
196
+ return _context5.a(2, this.httpClient.post(this.serverURL.clone().segment("transactions").toString(), "tx=".concat(tx), {
197
197
  timeout: SUBMIT_TRANSACTION_TIMEOUT,
198
198
  headers: {
199
199
  "Content-Type": "application/x-www-form-urlencoded"
@@ -334,7 +334,7 @@ var HorizonServer = exports.HorizonServer = function () {
334
334
  return this.checkMemoRequired(transaction);
335
335
  case 1:
336
336
  tx = encodeURIComponent(transaction.toEnvelope().toXDR().toString("base64"));
337
- return _context6.a(2, this.httpClient.post(this.serverURL.segment("transactions_async").toString(), "tx=".concat(tx), {
337
+ return _context6.a(2, this.httpClient.post(this.serverURL.clone().segment("transactions_async").toString(), "tx=".concat(tx), {
338
338
  headers: {
339
339
  "Content-Type": "application/x-www-form-urlencoded"
340
340
  }
@@ -11,7 +11,6 @@ export * as Horizon from "./horizon";
11
11
  * `assembleTransaction`, and the `Api` types. You can import these from the
12
12
  * `/rpc` entrypoint, if your version of Node and your TypeScript configuration
13
13
  * allow it:
14
- *
15
14
  * @example
16
15
  * import { Server } from '@stellar/stellar-sdk/rpc';
17
16
  */
@@ -21,10 +20,8 @@ export * as rpc from "./rpc";
21
20
  * `AssembledTransaction`. You can import these from the `/contract`
22
21
  * entrypoint, if your version of Node and your TypeScript configuration allow
23
22
  * it:
24
- *
25
23
  * @example
26
24
  * import { Client } from '@stellar/stellar-sdk/contract';
27
- * @private
28
25
  */
29
26
  export * as contract from "./contract";
30
27
  export * from "@stellar/stellar-base";
@@ -1,6 +1,9 @@
1
1
  import { Contract, SorobanDataBuilder, xdr } from "@stellar/stellar-base";
2
2
  export declare namespace Api {
3
3
  export interface GetHealthResponse {
4
+ latestLedger: number;
5
+ ledgerRetentionWindow: number;
6
+ oldestLedger: number;
4
7
  status: "healthy";
5
8
  }
6
9
  export interface LedgerEntryResult {
@@ -253,7 +256,7 @@ export declare namespace Api {
253
256
  }
254
257
  export interface RawEventResponse extends BaseEventResponse {
255
258
  contractId: string;
256
- topic: string[];
259
+ topic?: string[];
257
260
  value: string;
258
261
  }
259
262
  interface RawLedgerEntryChange {
@@ -303,7 +306,7 @@ export declare namespace Api {
303
306
  }
304
307
  export type SimulationAuthMode = "enforce" | "record" | "record_allow_nonroot";
305
308
  /**
306
- * Simplifies {@link Api.RawSimulateTransactionResponse} into separate interfaces
309
+ * Simplifies {@link RawSimulateTransactionResponse} into separate interfaces
307
310
  * based on status:
308
311
  * - on success, this includes all fields, though `result` is only present
309
312
  * if an invocation was simulated (since otherwise there's nothing to
@@ -358,9 +361,29 @@ export declare namespace Api {
358
361
  transactionData: SorobanDataBuilder;
359
362
  };
360
363
  }
364
+ /**
365
+ * Checks if a simulation response indicates an error.
366
+ * @param sim The simulation response to check.
367
+ * @returns True if the response indicates an error, false otherwise.
368
+ */
361
369
  export function isSimulationError(sim: SimulateTransactionResponse): sim is SimulateTransactionErrorResponse;
370
+ /**
371
+ * Checks if a simulation response indicates success.
372
+ * @param sim The simulation response to check.
373
+ * @returns True if the response indicates success, false otherwise.
374
+ */
362
375
  export function isSimulationSuccess(sim: SimulateTransactionResponse): sim is SimulateTransactionSuccessResponse;
376
+ /**
377
+ * Checks if a simulation response indicates that a restoration is needed.
378
+ * @param sim The simulation response to check.
379
+ * @returns True if the response indicates a restoration is needed, false otherwise.
380
+ */
363
381
  export function isSimulationRestore(sim: SimulateTransactionResponse): sim is SimulateTransactionRestoreResponse;
382
+ /**
383
+ * Checks if a simulation response is in raw (unparsed) form.
384
+ * @param sim The simulation response to check.
385
+ * @returns True if the response is raw, false otherwise.
386
+ */
364
387
  export function isSimulationRaw(sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse): sim is Api.RawSimulateTransactionResponse;
365
388
  interface RawSimulateHostFunctionResult {
366
389
  auth?: string[];
@@ -427,10 +450,11 @@ export declare namespace Api {
427
450
  latestLedger: number;
428
451
  /** present only on success, otherwise request malformed or no balance */
429
452
  balanceEntry?: {
430
- /** a 64-bit integer */
453
+ /** a 64-bit integer for trustlines, 128-bit value for contracts */
431
454
  amount: string;
432
455
  authorized: boolean;
433
456
  clawback: boolean;
457
+ revocable?: boolean;
434
458
  lastModifiedLedgerSeq?: number;
435
459
  liveUntilLedgerSeq?: number;
436
460
  };
@@ -12,7 +12,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
12
12
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
14
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
- var version = exports.version = "14.3.2";
15
+ var version = exports.version = "14.4.0";
16
16
  function createHttpClient(headers) {
17
17
  return (0, _httpClient.create)({
18
18
  headers: _objectSpread(_objectSpread({}, headers), {}, {
@@ -27,10 +27,11 @@ export interface Error<E = any> {
27
27
  /**
28
28
  * Sends the jsonrpc 'params' as a single 'param' object (no array support).
29
29
  *
30
+ * @param {HttpClient} client HttpClient instance to use for the request
30
31
  * @param {string} url URL to the RPC instance
31
32
  * @param {string} method RPC method name that should be called
32
33
  * @param {(any | null)} [param=null] params that should be supplied to the method
33
- * @returns {Promise<T>}
34
+ * @returns {Promise} Promise that resolves to the result of type T
34
35
  * @private
35
36
  */
36
37
  export declare function postObject<T>(client: HttpClient, url: string, method: string, param?: any): Promise<T>;
@@ -9,7 +9,7 @@ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try {
9
9
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
10
10
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11
11
  function hasOwnProperty(obj, prop) {
12
- return obj.hasOwnProperty(prop);
12
+ return Object.prototype.hasOwnProperty.call(obj, prop);
13
13
  }
14
14
  function postObject(_x, _x2, _x3) {
15
15
  return _postObject.apply(this, arguments);
@@ -59,10 +59,12 @@ function parseTransactionInfo(raw) {
59
59
  switch (meta.switch()) {
60
60
  case 3:
61
61
  case 4:
62
- var metaV = meta.value();
63
- if (metaV.sorobanMeta() !== null) {
64
- var _metaV$sorobanMeta$re, _metaV$sorobanMeta;
65
- info.returnValue = (_metaV$sorobanMeta$re = (_metaV$sorobanMeta = metaV.sorobanMeta()) === null || _metaV$sorobanMeta === void 0 ? void 0 : _metaV$sorobanMeta.returnValue()) !== null && _metaV$sorobanMeta$re !== void 0 ? _metaV$sorobanMeta$re : undefined;
62
+ {
63
+ var metaV = meta.value();
64
+ if (metaV.sorobanMeta() !== null) {
65
+ var _metaV$sorobanMeta$re, _metaV$sorobanMeta;
66
+ info.returnValue = (_metaV$sorobanMeta$re = (_metaV$sorobanMeta = metaV.sorobanMeta()) === null || _metaV$sorobanMeta === void 0 ? void 0 : _metaV$sorobanMeta.returnValue()) !== null && _metaV$sorobanMeta$re !== void 0 ? _metaV$sorobanMeta$re : undefined;
67
+ }
66
68
  }
67
69
  }
68
70
  if (raw.diagnosticEventsXdr) {
@@ -87,12 +89,13 @@ function parseRawEvents(raw) {
87
89
  oldestLedgerCloseTime: raw.oldestLedgerCloseTime,
88
90
  cursor: raw.cursor,
89
91
  events: ((_raw$events3 = raw.events) !== null && _raw$events3 !== void 0 ? _raw$events3 : []).map(function (evt) {
92
+ var _evt$topic;
90
93
  var clone = _objectSpread({}, evt);
91
94
  delete clone.contractId;
92
95
  return _objectSpread(_objectSpread(_objectSpread({}, clone), evt.contractId !== "" && {
93
96
  contractId: new _stellarBase.Contract(evt.contractId)
94
97
  }), {}, {
95
- topic: evt.topic.map(function (topic) {
98
+ topic: ((_evt$topic = evt.topic) !== null && _evt$topic !== void 0 ? _evt$topic : []).map(function (topic) {
96
99
  return _stellarBase.xdr.ScVal.fromXDR(topic, "base64");
97
100
  }),
98
101
  value: _stellarBase.xdr.ScVal.fromXDR(evt.value, "base64")
@@ -155,6 +155,7 @@ export declare class RpcServer {
155
155
  * @see
156
156
  * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}
157
157
  *
158
+ * @deprecated Use {@link getAssetBalance}, instead
158
159
  * @example
159
160
  * const accountId = "GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4";
160
161
  * const asset = new Asset(
@@ -187,6 +188,36 @@ export declare class RpcServer {
187
188
  * });
188
189
  */
189
190
  getClaimableBalance(id: string): Promise<xdr.ClaimableBalanceEntry>;
191
+ /**
192
+ * Fetch the balance of an asset held by an account or contract.
193
+ *
194
+ * The `address` argument may be provided as a string (as a {@link StrKey}),
195
+ * {@link Address}, or {@link Contract}.
196
+ *
197
+ * @param {string|Address|Contract} address The account or contract whose
198
+ * balance should be fetched.
199
+ * @param {Asset} asset The asset whose balance you want to inspect.
200
+ * @param {string} [networkPassphrase] optionally, when requesting the
201
+ * balance of a contract, the network passphrase to which this token
202
+ * applies. If omitted and necessary, a request about network information
203
+ * will be made (see {@link getNetwork}), since contract IDs for assets are
204
+ * specific to a network. You can refer to {@link Networks} for a list of
205
+ * built-in passphrases, e.g., `Networks.TESTNET`.
206
+ * @returns {Promise<Api.BalanceResponse>} Resolves with balance entry details
207
+ * when available.
208
+ *
209
+ * @throws {Error} If the supplied `address` is not a valid account or
210
+ * contract strkey.
211
+ *
212
+ * @example
213
+ * const usdc = new Asset(
214
+ * "USDC",
215
+ * "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5"
216
+ * );
217
+ * const balance = await server.getAssetBalance("GD...", usdc);
218
+ * console.log(balance.balanceEntry?.amount);
219
+ */
220
+ getAssetBalance(address: string | Address | Contract, asset: Asset, networkPassphrase?: string): Promise<Api.BalanceResponse>;
190
221
  /**
191
222
  * General node health check.
192
223
  *
@@ -320,6 +351,7 @@ export declare class RpcServer {
320
351
  * transaction completion and return a definitive state of success or failure.
321
352
  *
322
353
  * @param {string} hash the transaction you're polling for
354
+ * @param {[RpcServer.PollingOptions]} [opts] polling options
323
355
  * @param {number} [opts.attempts] (optional) the number of attempts to make
324
356
  * before returning the last-seen status. By default or on invalid inputs,
325
357
  * try 5 times.
@@ -644,7 +676,7 @@ export declare class RpcServer {
644
676
  * account, or the existing account if it's already funded with the
645
677
  * populated sequence number (note that the account will not be "topped
646
678
  * off" if it already exists)
647
- * @throws If Friendbot is not configured on this network or request failure
679
+ * @throws {Error} If Friendbot is not configured on this network or request failure
648
680
  *
649
681
  * @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}
650
682
  * @see {@link module:Friendbot.Api.Response}
@@ -679,8 +711,8 @@ export declare class RpcServer {
679
711
  *
680
712
  * This is a convenience wrapper around {@link Server.getLedgerEntries}.
681
713
  *
682
- * @param {string} address the contract (string `C...`) or account ID
683
- * (`G...`) whose balance of `sac` you want to know
714
+ * @param {string} address the contract (string `C...`) whose balance of
715
+ * `sac` you want to know
684
716
  * @param {Asset} sac the built-in SAC token (e.g. `USDC:GABC...`) that
685
717
  * you are querying from the given `contract`.
686
718
  * @param {string} [networkPassphrase] optionally, the network passphrase to
@@ -698,6 +730,7 @@ export declare class RpcServer {
698
730
  * @see getLedgerEntries
699
731
  * @see https://developers.stellar.org/docs/tokens/stellar-asset-contract
700
732
  *
733
+ * @deprecated Use {@link getAssetBalance}, instead
701
734
  * @example
702
735
  * // assume `address` is some contract or account with an XLM balance
703
736
  * // assume server is an instantiated `Server` instance.
@@ -733,7 +766,9 @@ export declare class RpcServer {
733
766
  * // Fetch ledgers starting from a specific sequence number
734
767
  * server.getLedgers({
735
768
  * startLedger: 36233,
736
- * limit: 10
769
+ * pagination: {
770
+ * limit: 10
771
+ * }
737
772
  * }).then((response) => {
738
773
  * console.log("Ledgers:", response.ledgers);
739
774
  * console.log("Latest Ledger:", response.latestLedger);
@@ -744,12 +779,16 @@ export declare class RpcServer {
744
779
  * // Paginate through ledgers using cursor
745
780
  * const firstPage = await server.getLedgers({
746
781
  * startLedger: 36233,
747
- * limit: 5
782
+ * pagination: {
783
+ * limit: 5
784
+ * }
748
785
  * });
749
786
  *
750
787
  * const nextPage = await server.getLedgers({
751
- * cursor: firstPage.cursor,
752
- * limit: 5
788
+ * pagination: {
789
+ * cursor: firstPage.cursor,
790
+ * limit: 5
791
+ * }
753
792
  * });
754
793
  */
755
794
  getLedgers(request: Api.GetLedgersRequest): Promise<Api.GetLedgersResponse>;