@stellar/stellar-sdk 13.0.0-rc.1 → 13.0.0-rc.2

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 (82) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/dist/stellar-sdk-minimal.js +363 -93
  3. package/dist/stellar-sdk-minimal.min.js +1 -1
  4. package/dist/stellar-sdk-no-axios.js +380 -96
  5. package/dist/stellar-sdk-no-axios.min.js +1 -1
  6. package/dist/stellar-sdk-no-eventsource.js +363 -93
  7. package/dist/stellar-sdk-no-eventsource.min.js +1 -1
  8. package/dist/stellar-sdk.js +380 -96
  9. package/dist/stellar-sdk.min.js +1 -1
  10. package/lib/contract/assembled_transaction.d.ts +75 -3
  11. package/lib/contract/assembled_transaction.js +123 -34
  12. package/lib/contract/basic_node_signer.d.ts +3 -2
  13. package/lib/contract/basic_node_signer.js +16 -8
  14. package/lib/contract/client.d.ts +13 -1
  15. package/lib/contract/client.js +159 -48
  16. package/lib/contract/types.d.ts +72 -8
  17. package/lib/contract/types.js +1 -0
  18. package/lib/horizon/call_builder.d.ts +1 -1
  19. package/lib/horizon/horizon_axios_client.js +1 -1
  20. package/lib/horizon/server_api.d.ts +1 -0
  21. package/lib/horizon/server_api.js +5 -0
  22. package/lib/horizon/types/effects.d.ts +51 -51
  23. package/lib/horizon/types/trade.d.ts +3 -2
  24. package/lib/http-client/types.d.ts +1 -0
  25. package/lib/minimal/contract/assembled_transaction.d.ts +75 -3
  26. package/lib/minimal/contract/assembled_transaction.js +123 -34
  27. package/lib/minimal/contract/basic_node_signer.d.ts +3 -2
  28. package/lib/minimal/contract/basic_node_signer.js +16 -8
  29. package/lib/minimal/contract/client.d.ts +13 -1
  30. package/lib/minimal/contract/client.js +159 -48
  31. package/lib/minimal/contract/types.d.ts +72 -8
  32. package/lib/minimal/contract/types.js +1 -0
  33. package/lib/minimal/horizon/call_builder.d.ts +1 -1
  34. package/lib/minimal/horizon/horizon_axios_client.js +1 -1
  35. package/lib/minimal/horizon/server_api.d.ts +1 -0
  36. package/lib/minimal/horizon/server_api.js +5 -0
  37. package/lib/minimal/horizon/types/effects.d.ts +51 -51
  38. package/lib/minimal/horizon/types/trade.d.ts +3 -2
  39. package/lib/minimal/http-client/types.d.ts +1 -0
  40. package/lib/minimal/rpc/axios.js +1 -1
  41. package/lib/minimal/stellartoml/index.d.ts +1 -0
  42. package/lib/minimal/stellartoml/index.js +2 -0
  43. package/lib/no-axios/contract/assembled_transaction.d.ts +75 -3
  44. package/lib/no-axios/contract/assembled_transaction.js +123 -34
  45. package/lib/no-axios/contract/basic_node_signer.d.ts +3 -2
  46. package/lib/no-axios/contract/basic_node_signer.js +16 -8
  47. package/lib/no-axios/contract/client.d.ts +13 -1
  48. package/lib/no-axios/contract/client.js +159 -48
  49. package/lib/no-axios/contract/types.d.ts +72 -8
  50. package/lib/no-axios/contract/types.js +1 -0
  51. package/lib/no-axios/horizon/call_builder.d.ts +1 -1
  52. package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
  53. package/lib/no-axios/horizon/server_api.d.ts +1 -0
  54. package/lib/no-axios/horizon/server_api.js +5 -0
  55. package/lib/no-axios/horizon/types/effects.d.ts +51 -51
  56. package/lib/no-axios/horizon/types/trade.d.ts +3 -2
  57. package/lib/no-axios/http-client/types.d.ts +1 -0
  58. package/lib/no-axios/rpc/axios.js +1 -1
  59. package/lib/no-axios/stellartoml/index.d.ts +1 -0
  60. package/lib/no-axios/stellartoml/index.js +2 -0
  61. package/lib/no-eventsource/contract/assembled_transaction.d.ts +75 -3
  62. package/lib/no-eventsource/contract/assembled_transaction.js +123 -34
  63. package/lib/no-eventsource/contract/basic_node_signer.d.ts +3 -2
  64. package/lib/no-eventsource/contract/basic_node_signer.js +16 -8
  65. package/lib/no-eventsource/contract/client.d.ts +13 -1
  66. package/lib/no-eventsource/contract/client.js +159 -48
  67. package/lib/no-eventsource/contract/types.d.ts +72 -8
  68. package/lib/no-eventsource/contract/types.js +1 -0
  69. package/lib/no-eventsource/horizon/call_builder.d.ts +1 -1
  70. package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
  71. package/lib/no-eventsource/horizon/server_api.d.ts +1 -0
  72. package/lib/no-eventsource/horizon/server_api.js +5 -0
  73. package/lib/no-eventsource/horizon/types/effects.d.ts +51 -51
  74. package/lib/no-eventsource/horizon/types/trade.d.ts +3 -2
  75. package/lib/no-eventsource/http-client/types.d.ts +1 -0
  76. package/lib/no-eventsource/rpc/axios.js +1 -1
  77. package/lib/no-eventsource/stellartoml/index.d.ts +1 -0
  78. package/lib/no-eventsource/stellartoml/index.js +2 -0
  79. package/lib/rpc/axios.js +1 -1
  80. package/lib/stellartoml/index.d.ts +1 -0
  81. package/lib/stellartoml/index.js +2 -0
  82. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import { Keypair } from "@stellar/stellar-base";
2
+ import { SignAuthEntry, SignTransaction } from "./types";
2
3
  /**
3
4
  * For use with {@link Client} and {@link module:contract.AssembledTransaction}.
4
5
  * Implements `signTransaction` and `signAuthEntry` with signatures expected by
@@ -12,6 +13,6 @@ import { Keypair } from "@stellar/stellar-base";
12
13
  * @param {string} networkPassphrase passphrase of network to sign for
13
14
  */
14
15
  export declare const basicNodeSigner: (keypair: Keypair, networkPassphrase: string) => {
15
- signTransaction: (tx: string) => Promise<string>;
16
- signAuthEntry: (entryXdr: string) => Promise<string>;
16
+ signTransaction: SignTransaction;
17
+ signAuthEntry: SignAuthEntry;
17
18
  };
@@ -12,38 +12,46 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
12
12
  var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
13
13
  return {
14
14
  signTransaction: function () {
15
- var _signTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(tx) {
15
+ var _signTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(xdr, opts) {
16
16
  var t;
17
17
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
- t = _stellarBase.TransactionBuilder.fromXDR(tx, networkPassphrase);
20
+ t = _stellarBase.TransactionBuilder.fromXDR(xdr, (opts === null || opts === void 0 ? void 0 : opts.networkPassphrase) || networkPassphrase);
21
21
  t.sign(keypair);
22
- return _context.abrupt("return", t.toXDR());
22
+ return _context.abrupt("return", {
23
+ signedTxXdr: t.toXDR(),
24
+ signerAddress: keypair.publicKey()
25
+ });
23
26
  case 3:
24
27
  case "end":
25
28
  return _context.stop();
26
29
  }
27
30
  }, _callee);
28
31
  }));
29
- function signTransaction(_x) {
32
+ function signTransaction(_x, _x2) {
30
33
  return _signTransaction.apply(this, arguments);
31
34
  }
32
35
  return signTransaction;
33
36
  }(),
34
37
  signAuthEntry: function () {
35
- var _signAuthEntry = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(entryXdr) {
38
+ var _signAuthEntry = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(authEntry) {
39
+ var signedAuthEntry;
36
40
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
37
41
  while (1) switch (_context2.prev = _context2.next) {
38
42
  case 0:
39
- return _context2.abrupt("return", keypair.sign((0, _stellarBase.hash)(Buffer.from(entryXdr, "base64"))).toString("base64"));
40
- case 1:
43
+ signedAuthEntry = keypair.sign((0, _stellarBase.hash)(Buffer.from(authEntry, "base64"))).toString("base64");
44
+ return _context2.abrupt("return", {
45
+ signedAuthEntry: signedAuthEntry,
46
+ signerAddress: keypair.publicKey()
47
+ });
48
+ case 2:
41
49
  case "end":
42
50
  return _context2.stop();
43
51
  }
44
52
  }, _callee2);
45
53
  }));
46
- function signAuthEntry(_x2) {
54
+ function signAuthEntry(_x3) {
47
55
  return _signAuthEntry.apply(this, arguments);
48
56
  }
49
57
  return signAuthEntry;
@@ -1,6 +1,6 @@
1
1
  import { Spec } from "./spec";
2
2
  import { AssembledTransaction } from "./assembled_transaction";
3
- import type { ClientOptions } from "./types";
3
+ import type { ClientOptions, MethodOptions } from "./types";
4
4
  /**
5
5
  * Generate a class from the contract spec that where each contract method
6
6
  * gets included with an identical name.
@@ -18,6 +18,18 @@ import type { ClientOptions } from "./types";
18
18
  export declare class Client {
19
19
  readonly spec: Spec;
20
20
  readonly options: ClientOptions;
21
+ static deploy<T = Client>(
22
+ /** Constructor/Initialization Args for the contract's `__constructor` method */
23
+ args: Record<string, any> | null,
24
+ /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */
25
+ options: MethodOptions & Omit<ClientOptions, "contractId"> & {
26
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
27
+ wasmHash: Buffer | string;
28
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
29
+ salt?: Buffer | Uint8Array;
30
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
31
+ format?: "hex" | "base64";
32
+ }): Promise<AssembledTransaction<T>>;
21
33
  constructor(spec: Spec, options: ClientOptions);
22
34
  /**
23
35
  * Generates a Client instance from the provided ClientOptions and the contract's wasm hash.
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.Client = void 0;
8
+ var _stellarBase = require("@stellar/stellar-base");
7
9
  var _spec = require("./spec");
8
10
  var _rpc = require("../rpc");
9
11
  var _assembled_transaction = require("./assembled_transaction");
10
12
  var _utils = require("./utils");
11
- var _excluded = ["method"];
12
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
+ var _excluded = ["method"],
14
+ _excluded2 = ["wasmHash", "salt", "format", "fee", "timeoutInSeconds", "simulate"];
13
15
  function _regeneratorRuntime() { "use strict"; _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
14
- 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); }
15
- 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); }); }; }
16
16
  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; }
17
17
  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; }
18
18
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
@@ -23,6 +23,81 @@ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r),
23
23
  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; }
24
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
25
  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); }
26
+ 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); }
27
+ 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); }); }; }
28
+ var CONSTRUCTOR_FUNC = "__constructor";
29
+ function specFromWasm(_x) {
30
+ return _specFromWasm.apply(this, arguments);
31
+ }
32
+ function _specFromWasm() {
33
+ _specFromWasm = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(wasm) {
34
+ var wasmModule, xdrSections, bufferSection, specEntryArray, spec;
35
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
36
+ while (1) switch (_context5.prev = _context5.next) {
37
+ case 0:
38
+ _context5.next = 2;
39
+ return WebAssembly.compile(wasm);
40
+ case 2:
41
+ wasmModule = _context5.sent;
42
+ xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
43
+ if (!(xdrSections.length === 0)) {
44
+ _context5.next = 6;
45
+ break;
46
+ }
47
+ throw new Error("Could not obtain contract spec from wasm");
48
+ case 6:
49
+ bufferSection = Buffer.from(xdrSections[0]);
50
+ specEntryArray = (0, _utils.processSpecEntryStream)(bufferSection);
51
+ spec = new _spec.Spec(specEntryArray);
52
+ return _context5.abrupt("return", spec);
53
+ case 10:
54
+ case "end":
55
+ return _context5.stop();
56
+ }
57
+ }, _callee5);
58
+ }));
59
+ return _specFromWasm.apply(this, arguments);
60
+ }
61
+ function specFromWasmHash(_x2, _x3) {
62
+ return _specFromWasmHash.apply(this, arguments);
63
+ }
64
+ function _specFromWasmHash() {
65
+ _specFromWasmHash = _asyncToGenerator(_regeneratorRuntime().mark(function _callee6(wasmHash, options) {
66
+ var format,
67
+ rpcUrl,
68
+ allowHttp,
69
+ serverOpts,
70
+ server,
71
+ wasm,
72
+ _args6 = arguments;
73
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
74
+ while (1) switch (_context6.prev = _context6.next) {
75
+ case 0:
76
+ format = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : "hex";
77
+ if (!(!options || !options.rpcUrl)) {
78
+ _context6.next = 3;
79
+ break;
80
+ }
81
+ throw new TypeError("options must contain rpcUrl");
82
+ case 3:
83
+ rpcUrl = options.rpcUrl, allowHttp = options.allowHttp;
84
+ serverOpts = {
85
+ allowHttp: allowHttp
86
+ };
87
+ server = new _rpc.Server(rpcUrl, serverOpts);
88
+ _context6.next = 8;
89
+ return server.getContractWasmByHash(wasmHash, format);
90
+ case 8:
91
+ wasm = _context6.sent;
92
+ return _context6.abrupt("return", specFromWasm(wasm));
93
+ case 10:
94
+ case "end":
95
+ return _context6.stop();
96
+ }
97
+ }, _callee6);
98
+ }));
99
+ return _specFromWasmHash.apply(this, arguments);
100
+ }
26
101
  var Client = exports.Client = function () {
27
102
  function Client(spec, options) {
28
103
  var _this = this;
@@ -45,6 +120,9 @@ var Client = exports.Client = function () {
45
120
  this.options = options;
46
121
  this.spec.funcs().forEach(function (xdrFn) {
47
122
  var method = xdrFn.name().toString();
123
+ if (method === CONSTRUCTOR_FUNC) {
124
+ return;
125
+ }
48
126
  var assembleTransaction = function assembleTransaction(args, methodOptions) {
49
127
  return _assembled_transaction.AssembledTransaction.build(_objectSpread(_objectSpread(_objectSpread({
50
128
  method: method,
@@ -66,22 +144,65 @@ var Client = exports.Client = function () {
66
144
  });
67
145
  }
68
146
  return _createClass(Client, null, [{
147
+ key: "deploy",
148
+ value: function () {
149
+ var _deploy = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(args, options) {
150
+ var wasmHash, salt, format, fee, timeoutInSeconds, simulate, clientOptions, spec, operation;
151
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
152
+ while (1) switch (_context.prev = _context.next) {
153
+ case 0:
154
+ wasmHash = options.wasmHash, salt = options.salt, format = options.format, fee = options.fee, timeoutInSeconds = options.timeoutInSeconds, simulate = options.simulate, clientOptions = _objectWithoutProperties(options, _excluded2);
155
+ _context.next = 3;
156
+ return specFromWasmHash(wasmHash, clientOptions, format);
157
+ case 3:
158
+ spec = _context.sent;
159
+ operation = _stellarBase.Operation.createCustomContract({
160
+ address: new _stellarBase.Address(options.publicKey),
161
+ wasmHash: typeof wasmHash === "string" ? Buffer.from(wasmHash, format !== null && format !== void 0 ? format : "hex") : wasmHash,
162
+ salt: salt,
163
+ constructorArgs: args ? spec.funcArgsToScVals(CONSTRUCTOR_FUNC, args) : []
164
+ });
165
+ return _context.abrupt("return", _assembled_transaction.AssembledTransaction.buildWithOp(operation, _objectSpread(_objectSpread({
166
+ fee: fee,
167
+ timeoutInSeconds: timeoutInSeconds,
168
+ simulate: simulate
169
+ }, clientOptions), {}, {
170
+ contractId: "ignored",
171
+ method: CONSTRUCTOR_FUNC,
172
+ parseResultXdr: function parseResultXdr(result) {
173
+ return new Client(spec, _objectSpread(_objectSpread({}, clientOptions), {}, {
174
+ contractId: _stellarBase.Address.fromScVal(result).toString()
175
+ }));
176
+ }
177
+ })));
178
+ case 6:
179
+ case "end":
180
+ return _context.stop();
181
+ }
182
+ }, _callee);
183
+ }));
184
+ function deploy(_x4, _x5) {
185
+ return _deploy.apply(this, arguments);
186
+ }
187
+ return deploy;
188
+ }()
189
+ }, {
69
190
  key: "fromWasmHash",
70
191
  value: (function () {
71
- var _fromWasmHash = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(wasmHash, options) {
192
+ var _fromWasmHash = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(wasmHash, options) {
72
193
  var format,
73
194
  rpcUrl,
74
195
  allowHttp,
75
196
  serverOpts,
76
197
  server,
77
198
  wasm,
78
- _args = arguments;
79
- return _regeneratorRuntime().wrap(function _callee$(_context) {
80
- while (1) switch (_context.prev = _context.next) {
199
+ _args2 = arguments;
200
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
201
+ while (1) switch (_context2.prev = _context2.next) {
81
202
  case 0:
82
- format = _args.length > 2 && _args[2] !== undefined ? _args[2] : "hex";
203
+ format = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : "hex";
83
204
  if (!(!options || !options.rpcUrl)) {
84
- _context.next = 3;
205
+ _context2.next = 3;
85
206
  break;
86
207
  }
87
208
  throw new TypeError('options must contain rpcUrl');
@@ -91,18 +212,18 @@ var Client = exports.Client = function () {
91
212
  allowHttp: allowHttp
92
213
  };
93
214
  server = new _rpc.Server(rpcUrl, serverOpts);
94
- _context.next = 8;
215
+ _context2.next = 8;
95
216
  return server.getContractWasmByHash(wasmHash, format);
96
217
  case 8:
97
- wasm = _context.sent;
98
- return _context.abrupt("return", Client.fromWasm(wasm, options));
218
+ wasm = _context2.sent;
219
+ return _context2.abrupt("return", Client.fromWasm(wasm, options));
99
220
  case 10:
100
221
  case "end":
101
- return _context.stop();
222
+ return _context2.stop();
102
223
  }
103
- }, _callee);
224
+ }, _callee2);
104
225
  }));
105
- function fromWasmHash(_x, _x2) {
226
+ function fromWasmHash(_x6, _x7) {
106
227
  return _fromWasmHash.apply(this, arguments);
107
228
  }
108
229
  return fromWasmHash;
@@ -110,33 +231,23 @@ var Client = exports.Client = function () {
110
231
  }, {
111
232
  key: "fromWasm",
112
233
  value: (function () {
113
- var _fromWasm = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(wasm, options) {
114
- var wasmModule, xdrSections, bufferSection, specEntryArray, spec;
115
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
116
- while (1) switch (_context2.prev = _context2.next) {
234
+ var _fromWasm = _asyncToGenerator(_regeneratorRuntime().mark(function _callee3(wasm, options) {
235
+ var spec;
236
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
237
+ while (1) switch (_context3.prev = _context3.next) {
117
238
  case 0:
118
- _context2.next = 2;
119
- return WebAssembly.compile(wasm);
239
+ _context3.next = 2;
240
+ return specFromWasm(wasm);
120
241
  case 2:
121
- wasmModule = _context2.sent;
122
- xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
123
- if (!(xdrSections.length === 0)) {
124
- _context2.next = 6;
125
- break;
126
- }
127
- throw new Error('Could not obtain contract spec from wasm');
128
- case 6:
129
- bufferSection = Buffer.from(xdrSections[0]);
130
- specEntryArray = (0, _utils.processSpecEntryStream)(bufferSection);
131
- spec = new _spec.Spec(specEntryArray);
132
- return _context2.abrupt("return", new Client(spec, options));
133
- case 10:
242
+ spec = _context3.sent;
243
+ return _context3.abrupt("return", new Client(spec, options));
244
+ case 4:
134
245
  case "end":
135
- return _context2.stop();
246
+ return _context3.stop();
136
247
  }
137
- }, _callee2);
248
+ }, _callee3);
138
249
  }));
139
- function fromWasm(_x3, _x4) {
250
+ function fromWasm(_x8, _x9) {
140
251
  return _fromWasm.apply(this, arguments);
141
252
  }
142
253
  return fromWasm;
@@ -144,13 +255,13 @@ var Client = exports.Client = function () {
144
255
  }, {
145
256
  key: "from",
146
257
  value: (function () {
147
- var _from = _asyncToGenerator(_regeneratorRuntime().mark(function _callee3(options) {
258
+ var _from = _asyncToGenerator(_regeneratorRuntime().mark(function _callee4(options) {
148
259
  var rpcUrl, contractId, allowHttp, serverOpts, server, wasm;
149
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
150
- while (1) switch (_context3.prev = _context3.next) {
260
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
261
+ while (1) switch (_context4.prev = _context4.next) {
151
262
  case 0:
152
263
  if (!(!options || !options.rpcUrl || !options.contractId)) {
153
- _context3.next = 2;
264
+ _context4.next = 2;
154
265
  break;
155
266
  }
156
267
  throw new TypeError('options must contain rpcUrl and contractId');
@@ -160,18 +271,18 @@ var Client = exports.Client = function () {
160
271
  allowHttp: allowHttp
161
272
  };
162
273
  server = new _rpc.Server(rpcUrl, serverOpts);
163
- _context3.next = 7;
274
+ _context4.next = 7;
164
275
  return server.getContractWasmByContractId(contractId);
165
276
  case 7:
166
- wasm = _context3.sent;
167
- return _context3.abrupt("return", Client.fromWasm(wasm, options));
277
+ wasm = _context4.sent;
278
+ return _context4.abrupt("return", Client.fromWasm(wasm, options));
168
279
  case 9:
169
280
  case "end":
170
- return _context3.stop();
281
+ return _context4.stop();
171
282
  }
172
- }, _callee3);
283
+ }, _callee4);
173
284
  }));
174
- function from(_x5) {
285
+ function from(_x10) {
175
286
  return _from.apply(this, arguments);
176
287
  }
177
288
  return from;
@@ -49,6 +49,61 @@ export type Duration = bigint;
49
49
  * @type {Transaction<Memo<MemoType>, Operation[]>}
50
50
  */
51
51
  export type Tx = Transaction<Memo<MemoType>, Operation[]>;
52
+ export interface WalletError {
53
+ message: string;
54
+ code: number;
55
+ ext?: Array<string>;
56
+ }
57
+ /**
58
+ * A function to request a wallet to sign a built transaction
59
+ *
60
+ * This function takes an XDR provided by the requester and applies a signature to it.
61
+ * It returns a base64-encoded string XDR-encoded Transaction Envelope with Decorated Signatures
62
+ * and the signer address back to the requester.
63
+ *
64
+ * @param xdr - The XDR string representing the transaction to be signed.
65
+ * @param opts - Options for signing the transaction.
66
+ * @param opts.networkPassphrase - The network's passphrase on which the transaction is intended to be signed.
67
+ * @param opts.address - The public key of the account that should be used to sign.
68
+ * @param opts.submit - If set to true, submits the transaction immediately after signing.
69
+ * @param opts.submitUrl - The URL of the network to which the transaction should be submitted, if applicable.
70
+ *
71
+ * @returns A promise resolving to an object with the signed transaction XDR and optional signer address and error.
72
+ */
73
+ export type SignTransaction = (xdr: string, opts?: {
74
+ networkPassphrase?: string;
75
+ address?: string;
76
+ submit?: boolean;
77
+ submitUrl?: string;
78
+ }) => Promise<{
79
+ signedTxXdr: string;
80
+ signerAddress?: string;
81
+ } & {
82
+ error?: WalletError;
83
+ }>;
84
+ /**
85
+ * A function to request a wallet to sign an authorization entry preimage.
86
+ *
87
+ * Similar to signing a transaction, this function takes an authorization entry preimage provided by the
88
+ * requester and applies a signature to it.
89
+ * It returns a signed hash of the same authorization entry and the signer address back to the requester.
90
+ *
91
+ * @param authEntry - The authorization entry preimage to be signed.
92
+ * @param opts - Options for signing the authorization entry.
93
+ * @param opts.networkPassphrase - The network's passphrase on which the authorization entry is intended to be signed.
94
+ * @param opts.address - The public key of the account that should be used to sign.
95
+ *
96
+ * @returns A promise resolving to an object with the signed authorization entry and optional signer address and error.
97
+ */
98
+ export type SignAuthEntry = (authEntry: string, opts?: {
99
+ networkPassphrase?: string;
100
+ address?: string;
101
+ }) => Promise<{
102
+ signedAuthEntry: string;
103
+ signerAddress?: string;
104
+ } & {
105
+ error?: WalletError;
106
+ }>;
52
107
  /**
53
108
  * Options for a smart contract client.
54
109
  * @memberof module:contract
@@ -71,11 +126,7 @@ export type ClientOptions = {
71
126
  *
72
127
  * Matches signature of `signTransaction` from Freighter.
73
128
  */
74
- signTransaction?: (tx: XDR_BASE64, opts?: {
75
- network?: string;
76
- networkPassphrase?: string;
77
- accountToSign?: string;
78
- }) => Promise<XDR_BASE64>;
129
+ signTransaction?: SignTransaction;
79
130
  /**
80
131
  * A function to sign a specific auth entry for a transaction, using the
81
132
  * private key corresponding to the provided `publicKey`. This is only needed
@@ -85,9 +136,7 @@ export type ClientOptions = {
85
136
  *
86
137
  * Matches signature of `signAuthEntry` from Freighter.
87
138
  */
88
- signAuthEntry?: (entryXdr: XDR_BASE64, opts?: {
89
- accountToSign?: string;
90
- }) => Promise<XDR_BASE64>;
139
+ signAuthEntry?: SignAuthEntry;
91
140
  /** The address of the contract the client will interact with. */
92
141
  contractId: string;
93
142
  /**
@@ -160,6 +209,21 @@ export type AssembledTransactionOptions<T = string> = MethodOptions & ClientOpti
160
209
  method: string;
161
210
  args?: any[];
162
211
  parseResultXdr: (xdr: xdr.ScVal) => T;
212
+ /**
213
+ * The address of the account that should sign the transaction. Useful when
214
+ * a wallet holds multiple addresses to ensure signing with the intended one.
215
+ */
216
+ address?: string;
217
+ /**
218
+ * This option will be passed through to the SEP43-compatible wallet extension. If true, and if the wallet supports it, the transaction will be signed and immediately submitted to the network by the wallet, bypassing the submit logic in {@link SentTransaction}.
219
+ * @default false
220
+ */
221
+ submit?: boolean;
222
+ /**
223
+ * The URL of the network to which the transaction should be submitted.
224
+ * Only applicable when 'submit' is set to true.
225
+ */
226
+ submitUrl?: string;
163
227
  };
164
228
  /**
165
229
  * The default timebounds, in seconds, during which a transaction will be valid.
@@ -4,5 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.NULL_ACCOUNT = exports.DEFAULT_TIMEOUT = void 0;
7
+ var _stellarBase = require("@stellar/stellar-base");
7
8
  var DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 5 * 60;
8
9
  var NULL_ACCOUNT = exports.NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
@@ -35,7 +35,7 @@ export declare class CallBuilder<T extends HorizonApi.FeeStatsResponse | Horizon
35
35
  * @param {number} [options.reconnectTimeout] Custom stream connection timeout in ms, default is 15 seconds.
36
36
  * @returns {Function} Close function. Run to close the connection and stop listening for new events.
37
37
  */
38
- stream(options?: EventSourceOptions<T>): () => void;
38
+ stream(options?: EventSourceOptions<T extends ServerApi.CollectionPage<infer U> ? U : T>): () => void;
39
39
  /**
40
40
  * Sets `cursor` parameter for the current call. Returns the CallBuilder object on which this method has been called.
41
41
  * @see [Paging](https://developers.stellar.org/api/introduction/pagination/)
@@ -10,7 +10,7 @@ var _urijs = _interopRequireDefault(require("urijs"));
10
10
  var _httpClient = require("../http-client");
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
- var version = exports.version = "13.0.0-rc.1";
13
+ var version = exports.version = "13.0.0-rc.2";
14
14
  var SERVER_TIME_MAP = exports.SERVER_TIME_MAP = {};
15
15
  var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
16
16
  headers: {
@@ -23,6 +23,7 @@ export declare namespace ServerApi {
23
23
  export type CallCollectionFunction<T extends HorizonApi.BaseResponse = HorizonApi.BaseResponse> = (options?: CallFunctionTemplateOptions) => Promise<CollectionPage<T>>;
24
24
  type BaseEffectRecordFromTypes = Effects.AccountCreated | Effects.AccountCredited | Effects.AccountDebited | Effects.AccountThresholdsUpdated | Effects.AccountHomeDomainUpdated | Effects.AccountFlagsUpdated | Effects.DataCreated | Effects.DataRemoved | Effects.DataUpdated | Effects.SequenceBumped | Effects.SignerCreated | Effects.SignerRemoved | Effects.SignerUpdated | Effects.TrustlineCreated | Effects.TrustlineRemoved | Effects.TrustlineUpdated | Effects.TrustlineAuthorized | Effects.TrustlineDeauthorized | Effects.TrustlineAuthorizedToMaintainLiabilities | Effects.ClaimableBalanceCreated | Effects.ClaimableBalanceClaimed | Effects.ClaimableBalanceClaimantCreated | Effects.AccountSponsorshipCreated | Effects.AccountSponsorshipRemoved | Effects.AccountSponsorshipUpdated | Effects.TrustlineSponsorshipCreated | Effects.TrustlineSponsorshipUpdated | Effects.TrustlineSponsorshipRemoved | Effects.DateSponsorshipCreated | Effects.DateSponsorshipUpdated | Effects.DateSponsorshipRemoved | Effects.ClaimableBalanceSponsorshipCreated | Effects.ClaimableBalanceSponsorshipRemoved | Effects.ClaimableBalanceSponsorshipUpdated | Effects.SignerSponsorshipCreated | Effects.SignerSponsorshipUpdated | Effects.SignerSponsorshipRemoved | Effects.LiquidityPoolDeposited | Effects.LiquidityPoolWithdrew | Effects.LiquidityPoolCreated | Effects.LiquidityPoolRemoved | Effects.LiquidityPoolRevoked | Effects.LiquidityPoolTrade | Effects.ContractCredited | Effects.ContractDebited | Trade;
25
25
  export type EffectRecord = BaseEffectRecordFromTypes & EffectRecordMethods;
26
+ export const EffectType: typeof Effects.EffectType;
26
27
  export interface ClaimableBalanceRecord extends HorizonApi.BaseResponse {
27
28
  id: string;
28
29
  paging_token: string;
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.ServerApi = void 0;
7
8
  var _horizon_api = require("./horizon_api");
9
+ var Effects = _interopRequireWildcard(require("./types/effects"));
10
+ 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); }
11
+ 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; }
8
12
  var ServerApi;
9
13
  (function (_ServerApi) {
14
+ var EffectType = _ServerApi.EffectType = Effects.EffectType;
10
15
  var TradeType = function (TradeType) {
11
16
  TradeType["all"] = "all";
12
17
  TradeType["liquidityPools"] = "liquidity_pool";