@stellar/stellar-sdk 12.0.1 → 12.2.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 (62) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/stellar-sdk.js +1415 -1114
  3. package/dist/stellar-sdk.min.js +1 -1
  4. package/lib/browser.d.ts +1 -1
  5. package/lib/browser.js +4 -4
  6. package/lib/config.js +5 -2
  7. package/lib/contract/assembled_transaction.d.ts +102 -29
  8. package/lib/contract/assembled_transaction.js +361 -127
  9. package/lib/contract/client.d.ts +1 -1
  10. package/lib/contract/client.js +5 -2
  11. package/lib/contract/sent_transaction.d.ts +14 -18
  12. package/lib/contract/sent_transaction.js +17 -33
  13. package/lib/contract/spec.d.ts +1 -1
  14. package/lib/contract/spec.js +921 -956
  15. package/lib/contract/types.d.ts +10 -0
  16. package/lib/contract/types.js +4 -1
  17. package/lib/contract/utils.d.ts +4 -6
  18. package/lib/contract/utils.js +20 -2
  19. package/lib/errors.d.ts +4 -4
  20. package/lib/federation/server.d.ts +1 -1
  21. package/lib/horizon/account_call_builder.d.ts +2 -3
  22. package/lib/horizon/account_response.d.ts +1 -1
  23. package/lib/horizon/assets_call_builder.d.ts +2 -3
  24. package/lib/horizon/call_builder.d.ts +8 -8
  25. package/lib/horizon/call_builder.js +2 -6
  26. package/lib/horizon/claimable_balances_call_builder.d.ts +3 -4
  27. package/lib/horizon/effect_call_builder.d.ts +2 -3
  28. package/lib/horizon/friendbot_builder.d.ts +0 -1
  29. package/lib/horizon/horizon_api.d.ts +5 -1
  30. package/lib/horizon/horizon_axios_client.js +6 -6
  31. package/lib/horizon/ledger_call_builder.d.ts +2 -3
  32. package/lib/horizon/liquidity_pool_call_builder.d.ts +2 -4
  33. package/lib/horizon/offer_call_builder.d.ts +2 -3
  34. package/lib/horizon/operation_call_builder.d.ts +3 -4
  35. package/lib/horizon/orderbook_call_builder.d.ts +0 -1
  36. package/lib/horizon/path_call_builder.d.ts +1 -2
  37. package/lib/horizon/payment_call_builder.d.ts +2 -3
  38. package/lib/horizon/server.d.ts +29 -10
  39. package/lib/horizon/server.js +98 -55
  40. package/lib/horizon/strict_receive_path_call_builder.d.ts +1 -2
  41. package/lib/horizon/strict_send_path_call_builder.d.ts +1 -2
  42. package/lib/horizon/trade_aggregation_call_builder.d.ts +9 -10
  43. package/lib/horizon/trade_aggregation_call_builder.js +3 -7
  44. package/lib/horizon/trades_call_builder.d.ts +2 -3
  45. package/lib/horizon/transaction_call_builder.d.ts +3 -4
  46. package/lib/horizon/types/assets.d.ts +1 -1
  47. package/lib/horizon/types/effects.d.ts +1 -1
  48. package/lib/horizon/types/offer.d.ts +1 -1
  49. package/lib/index.d.ts +0 -1
  50. package/lib/rpc/api.d.ts +29 -5
  51. package/lib/rpc/browser.d.ts +1 -1
  52. package/lib/rpc/browser.js +4 -4
  53. package/lib/rpc/index.d.ts +0 -1
  54. package/lib/rpc/jsonrpc.js +3 -3
  55. package/lib/rpc/parsers.d.ts +3 -3
  56. package/lib/rpc/parsers.js +23 -23
  57. package/lib/rpc/server.d.ts +13 -7
  58. package/lib/rpc/server.js +48 -56
  59. package/lib/rpc/transaction.d.ts +3 -4
  60. package/lib/rpc/transaction.js +23 -25
  61. package/lib/webauth/utils.js +3 -3
  62. package/package.json +24 -33
package/lib/browser.d.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import axios from "axios";
1
2
  export * from "./index";
2
3
  export * as StellarBase from "@stellar/stellar-base";
3
- import axios from "axios";
4
4
  export { axios };
5
5
  declare const _default: any;
6
6
  export default _default;
package/lib/browser.js CHANGED
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  var _exportNames = {
8
- StellarBase: true,
9
- axios: true
8
+ axios: true,
9
+ StellarBase: true
10
10
  };
11
11
  exports.StellarBase = void 0;
12
12
  Object.defineProperty(exports, "axios", {
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "axios", {
16
16
  }
17
17
  });
18
18
  exports.default = void 0;
19
+ var _axios = _interopRequireDefault(require("axios"));
19
20
  var _index = require("./index");
20
21
  Object.keys(_index).forEach(function (key) {
21
22
  if (key === "default" || key === "__esModule") return;
@@ -30,8 +31,7 @@ Object.keys(_index).forEach(function (key) {
30
31
  });
31
32
  var _StellarBase = _interopRequireWildcard(require("@stellar/stellar-base"));
32
33
  exports.StellarBase = _StellarBase;
33
- var _axios = _interopRequireDefault(require("axios"));
34
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
35
34
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
36
35
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
36
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
37
37
  var _default = exports.default = module.exports;
package/lib/config.js CHANGED
@@ -8,13 +8,16 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
8
8
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
9
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
10
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ 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; }
11
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
15
  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); }
13
16
  var defaultConfig = {
14
17
  allowHttp: false,
15
18
  timeout: 0
16
19
  };
17
- var config = Object.assign({}, defaultConfig);
20
+ var config = _objectSpread({}, defaultConfig);
18
21
  var Config = exports.Config = function () {
19
22
  function Config() {
20
23
  _classCallCheck(this, Config);
@@ -42,7 +45,7 @@ var Config = exports.Config = function () {
42
45
  }, {
43
46
  key: "setDefault",
44
47
  value: function setDefault() {
45
- config = Object.assign({}, defaultConfig);
48
+ config = _objectSpread({}, defaultConfig);
46
49
  }
47
50
  }]);
48
51
  }();
@@ -1,9 +1,8 @@
1
- /// <reference types="node" />
2
- import { TransactionBuilder, xdr } from "@stellar/stellar-base";
1
+ import { Account, SorobanDataBuilder, TransactionBuilder, xdr } from "@stellar/stellar-base";
3
2
  import type { AssembledTransactionOptions, ClientOptions, Tx, XDR_BASE64 } from "./types";
4
3
  import { Api } from "../rpc/api";
5
4
  import { SentTransaction } from "./sent_transaction";
6
- export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
5
+ import { Spec } from "./spec";
7
6
  /**
8
7
  * The main workhorse of {@link Client}. This class is used to wrap a
9
8
  * transaction-under-construction and provide high-level interfaces to the most
@@ -267,6 +266,10 @@ export declare class AssembledTransaction<T> {
267
266
  * `rpcUrl` in the options.
268
267
  */
269
268
  private server;
269
+ /**
270
+ * The signed transaction.
271
+ */
272
+ signed?: Tx;
270
273
  /**
271
274
  * A list of the most important errors that various AssembledTransaction
272
275
  * methods can throw. Feel free to catch specific errors in your application
@@ -274,72 +277,82 @@ export declare class AssembledTransaction<T> {
274
277
  */
275
278
  static Errors: {
276
279
  ExpiredState: {
277
- new (message?: string | undefined): {
280
+ new (message?: string): {
281
+ name: string;
282
+ message: string;
283
+ stack?: string;
284
+ };
285
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
286
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
287
+ stackTraceLimit: number;
288
+ };
289
+ RestorationFailure: {
290
+ new (message?: string): {
278
291
  name: string;
279
292
  message: string;
280
- stack?: string | undefined;
293
+ stack?: string;
281
294
  };
282
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
295
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
283
296
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
284
297
  stackTraceLimit: number;
285
298
  };
286
299
  NeedsMoreSignatures: {
287
- new (message?: string | undefined): {
300
+ new (message?: string): {
288
301
  name: string;
289
302
  message: string;
290
- stack?: string | undefined;
303
+ stack?: string;
291
304
  };
292
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
305
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
293
306
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
294
307
  stackTraceLimit: number;
295
308
  };
296
309
  NoSignatureNeeded: {
297
- new (message?: string | undefined): {
310
+ new (message?: string): {
298
311
  name: string;
299
312
  message: string;
300
- stack?: string | undefined;
313
+ stack?: string;
301
314
  };
302
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
315
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
303
316
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
304
317
  stackTraceLimit: number;
305
318
  };
306
319
  NoUnsignedNonInvokerAuthEntries: {
307
- new (message?: string | undefined): {
320
+ new (message?: string): {
308
321
  name: string;
309
322
  message: string;
310
- stack?: string | undefined;
323
+ stack?: string;
311
324
  };
312
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
325
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
313
326
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
314
327
  stackTraceLimit: number;
315
328
  };
316
329
  NoSigner: {
317
- new (message?: string | undefined): {
330
+ new (message?: string): {
318
331
  name: string;
319
332
  message: string;
320
- stack?: string | undefined;
333
+ stack?: string;
321
334
  };
322
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
335
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
323
336
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
324
337
  stackTraceLimit: number;
325
338
  };
326
339
  NotYetSimulated: {
327
- new (message?: string | undefined): {
340
+ new (message?: string): {
328
341
  name: string;
329
342
  message: string;
330
- stack?: string | undefined;
343
+ stack?: string;
331
344
  };
332
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
345
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
333
346
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
334
347
  stackTraceLimit: number;
335
348
  };
336
349
  FakeAccount: {
337
- new (message?: string | undefined): {
350
+ new (message?: string): {
338
351
  name: string;
339
352
  message: string;
340
- stack?: string | undefined;
353
+ stack?: string;
341
354
  };
342
- captureStackTrace(targetObject: object, constructorOpt?: Function | undefined): void;
355
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
343
356
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
344
357
  stackTraceLimit: number;
345
358
  };
@@ -359,6 +372,14 @@ export declare class AssembledTransaction<T> {
359
372
  };
360
373
  simulationTransactionData: XDR_BASE64;
361
374
  }): AssembledTransaction<T>;
375
+ /**
376
+ * Serialize the AssembledTransaction to a base64-encoded XDR string.
377
+ */
378
+ toXDR(): string;
379
+ /**
380
+ * Deserialize the AssembledTransaction from a base64-encoded XDR string.
381
+ */
382
+ static fromXDR<T>(options: Omit<AssembledTransactionOptions<T>, "args" | "method" | "parseResultXdr">, encodedXDR: string, spec: Spec): AssembledTransaction<T>;
362
383
  private constructor();
363
384
  /**
364
385
  * Construct a new AssembledTransaction. This is the only way to create a new
@@ -379,7 +400,10 @@ export declare class AssembledTransaction<T> {
379
400
  * })
380
401
  */
381
402
  static build<T>(options: AssembledTransactionOptions<T>): Promise<AssembledTransaction<T>>;
382
- simulate: () => Promise<this>;
403
+ private static buildFootprintRestoreTransaction;
404
+ simulate: ({ restore }?: {
405
+ restore?: boolean;
406
+ }) => Promise<this>;
383
407
  get simulationData(): {
384
408
  result: Api.SimulateHostFunctionResult;
385
409
  transactionData: xdr.SorobanTransactionData;
@@ -387,12 +411,30 @@ export declare class AssembledTransaction<T> {
387
411
  get result(): T;
388
412
  private parseError;
389
413
  /**
390
- * Sign the transaction with the `wallet`, included previously. If you did
391
- * not previously include one, you need to include one now that at least
392
- * includes the `signTransaction` method. After signing, this method will
393
- * send the transaction to the network and return a `SentTransaction` that
414
+ * Sign the transaction with the signTransaction function included previously.
415
+ * If you did not previously include one, you need to include one now.
416
+ */
417
+ sign: ({ force, signTransaction, }?: {
418
+ /**
419
+ * If `true`, sign and send the transaction even if it is a read call
420
+ */
421
+ force?: boolean;
422
+ /**
423
+ * You must provide this here if you did not provide one before
424
+ */
425
+ signTransaction?: ClientOptions["signTransaction"];
426
+ }) => Promise<void>;
427
+ /**
428
+ * Sends the transaction to the network to return a `SentTransaction` that
394
429
  * keeps track of all the attempts to fetch the transaction.
395
430
  */
431
+ send(): Promise<SentTransaction<T>>;
432
+ /**
433
+ * Sign the transaction with the `signTransaction` function included previously.
434
+ * If you did not previously include one, you need to include one now.
435
+ * After signing, this method will send the transaction to the network and
436
+ * return a `SentTransaction` that keeps track * of all the attempts to fetch the transaction.
437
+ */
396
438
  signAndSend: ({ force, signTransaction, }?: {
397
439
  /**
398
440
  * If `true`, sign and send the transaction even if it is a read call
@@ -473,4 +515,35 @@ export declare class AssembledTransaction<T> {
473
515
  * returns `false`, then you need to call `signAndSend` on this transaction.
474
516
  */
475
517
  get isReadCall(): boolean;
518
+ /**
519
+ * Restores the footprint (resource ledger entries that can be read or written)
520
+ * of an expired transaction.
521
+ *
522
+ * The method will:
523
+ * 1. Build a new transaction aimed at restoring the necessary resources.
524
+ * 2. Sign this new transaction if a `signTransaction` handler is provided.
525
+ * 3. Send the signed transaction to the network.
526
+ * 4. Await and return the response from the network.
527
+ *
528
+ * Preconditions:
529
+ * - A `signTransaction` function must be provided during the Client initialization.
530
+ * - The provided `restorePreamble` should include a minimum resource fee and valid
531
+ * transaction data.
532
+ *
533
+ * @throws {Error} - Throws an error if no `signTransaction` function is provided during
534
+ * Client initialization.
535
+ * @throws {AssembledTransaction.Errors.RestoreFailure} - Throws a custom error if the
536
+ * restore transaction fails, providing the details of the failure.
537
+ */
538
+ restoreFootprint(
539
+ /**
540
+ * The preamble object containing data required to
541
+ * build the restore transaction.
542
+ */
543
+ restorePreamble: {
544
+ minResourceFee: string;
545
+ transactionData: SorobanDataBuilder;
546
+ },
547
+ /** The account that is executing the footprint restore operation. If omitted, will use the account from the AssembledTransaction. */
548
+ account?: Account): Promise<Api.GetTransactionResponse>;
476
549
  }