@stellar/stellar-sdk 12.0.0-rc.2 → 12.0.0-rc.3

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 (50) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +1 -1
  3. package/dist/stellar-sdk.js +1643 -466
  4. package/dist/stellar-sdk.min.js +1 -1
  5. package/lib/{contract_client → contract}/assembled_transaction.d.ts +59 -40
  6. package/lib/{contract_client → contract}/assembled_transaction.js +128 -146
  7. package/lib/{contract_client → contract}/basic_node_signer.d.ts +2 -2
  8. package/lib/{contract_client → contract}/basic_node_signer.js +3 -3
  9. package/lib/contract/client.d.ts +51 -0
  10. package/lib/contract/client.js +177 -0
  11. package/lib/contract/index.d.ts +7 -0
  12. package/lib/{contract_client → contract}/index.js +19 -8
  13. package/lib/{contract_client → contract}/sent_transaction.d.ts +21 -10
  14. package/lib/{contract_client → contract}/sent_transaction.js +27 -13
  15. package/lib/{contract_spec.d.ts → contract/spec.d.ts} +3 -3
  16. package/lib/{contract_spec.js → contract/spec.js} +160 -160
  17. package/lib/{contract_client → contract}/types.d.ts +10 -8
  18. package/lib/contract/utils.d.ts +40 -0
  19. package/lib/{contract_client → contract}/utils.js +12 -2
  20. package/lib/index.d.ts +26 -2
  21. package/lib/index.js +10 -16
  22. package/lib/rpc/index.d.ts +7 -0
  23. package/lib/{soroban → rpc}/server.d.ts +49 -0
  24. package/lib/{soroban → rpc}/server.js +199 -118
  25. package/package.json +20 -3
  26. package/lib/contract_client/client.d.ts +0 -17
  27. package/lib/contract_client/client.js +0 -57
  28. package/lib/contract_client/index.d.ts +0 -6
  29. package/lib/contract_client/utils.d.ts +0 -23
  30. package/lib/rust_types/index.d.ts +0 -1
  31. package/lib/rust_types/index.js +0 -16
  32. package/lib/soroban/index.d.ts +0 -7
  33. /package/lib/{rust_types/result.d.ts → contract/rust_result.d.ts} +0 -0
  34. /package/lib/{rust_types/result.js → contract/rust_result.js} +0 -0
  35. /package/lib/{contract_client → contract}/types.js +0 -0
  36. /package/lib/{soroban → rpc}/api.d.ts +0 -0
  37. /package/lib/{soroban → rpc}/api.js +0 -0
  38. /package/lib/{soroban → rpc}/axios.d.ts +0 -0
  39. /package/lib/{soroban → rpc}/axios.js +0 -0
  40. /package/lib/{soroban → rpc}/browser.d.ts +0 -0
  41. /package/lib/{soroban → rpc}/browser.js +0 -0
  42. /package/lib/{soroban → rpc}/index.js +0 -0
  43. /package/lib/{soroban → rpc}/jsonrpc.d.ts +0 -0
  44. /package/lib/{soroban → rpc}/jsonrpc.js +0 -0
  45. /package/lib/{soroban → rpc}/parsers.d.ts +0 -0
  46. /package/lib/{soroban → rpc}/parsers.js +0 -0
  47. /package/lib/{soroban → rpc}/transaction.d.ts +0 -0
  48. /package/lib/{soroban → rpc}/transaction.js +0 -0
  49. /package/lib/{soroban → rpc}/utils.d.ts +0 -0
  50. /package/lib/{soroban → rpc}/utils.js +0 -0
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Client = void 0;
7
+ var _spec = require("./spec");
8
+ var _rpc = require("../rpc");
9
+ var _assembled_transaction = require("./assembled_transaction");
10
+ 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
+ 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(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
15
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
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
+ 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
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
22
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
23
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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
+ var Client = exports.Client = function () {
27
+ function Client(spec, options) {
28
+ var _this = this;
29
+ _classCallCheck(this, Client);
30
+ _defineProperty(this, "txFromJSON", function (json) {
31
+ var _JSON$parse = JSON.parse(json),
32
+ method = _JSON$parse.method,
33
+ tx = _objectWithoutProperties(_JSON$parse, _excluded);
34
+ return _assembled_transaction.AssembledTransaction.fromJSON(_objectSpread(_objectSpread({}, _this.options), {}, {
35
+ method: method,
36
+ parseResultXdr: function parseResultXdr(result) {
37
+ return _this.spec.funcResToNative(method, result);
38
+ }
39
+ }), tx);
40
+ });
41
+ this.spec = spec;
42
+ this.options = options;
43
+ this.spec.funcs().forEach(function (xdrFn) {
44
+ var method = xdrFn.name().toString();
45
+ var assembleTransaction = function assembleTransaction(args, methodOptions) {
46
+ return _assembled_transaction.AssembledTransaction.build(_objectSpread(_objectSpread(_objectSpread({
47
+ method: method,
48
+ args: args && spec.funcArgsToScVals(method, args)
49
+ }, options), methodOptions), {}, {
50
+ errorTypes: spec.errorCases().reduce(function (acc, curr) {
51
+ return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, curr.value(), {
52
+ message: curr.doc().toString()
53
+ }));
54
+ }, {}),
55
+ parseResultXdr: function parseResultXdr(result) {
56
+ return spec.funcResToNative(method, result);
57
+ }
58
+ }));
59
+ };
60
+ _this[method] = spec.getFunc(method).inputs().length === 0 ? function (opts) {
61
+ return assembleTransaction(undefined, opts);
62
+ } : assembleTransaction;
63
+ });
64
+ }
65
+ return _createClass(Client, null, [{
66
+ key: "fromWasmHash",
67
+ value: (function () {
68
+ var _fromWasmHash = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(wasmHash, options) {
69
+ var format,
70
+ rpcUrl,
71
+ allowHttp,
72
+ serverOpts,
73
+ server,
74
+ wasm,
75
+ _args = arguments;
76
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
77
+ while (1) switch (_context.prev = _context.next) {
78
+ case 0:
79
+ format = _args.length > 2 && _args[2] !== undefined ? _args[2] : "hex";
80
+ if (!(!options || !options.rpcUrl)) {
81
+ _context.next = 3;
82
+ break;
83
+ }
84
+ throw new TypeError('options must contain rpcUrl');
85
+ case 3:
86
+ rpcUrl = options.rpcUrl, allowHttp = options.allowHttp;
87
+ serverOpts = {
88
+ allowHttp: allowHttp
89
+ };
90
+ server = new _rpc.Server(rpcUrl, serverOpts);
91
+ _context.next = 8;
92
+ return server.getContractWasmByHash(wasmHash, format);
93
+ case 8:
94
+ wasm = _context.sent;
95
+ return _context.abrupt("return", Client.fromWasm(wasm, options));
96
+ case 10:
97
+ case "end":
98
+ return _context.stop();
99
+ }
100
+ }, _callee);
101
+ }));
102
+ function fromWasmHash(_x, _x2) {
103
+ return _fromWasmHash.apply(this, arguments);
104
+ }
105
+ return fromWasmHash;
106
+ }())
107
+ }, {
108
+ key: "fromWasm",
109
+ value: (function () {
110
+ var _fromWasm = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(wasm, options) {
111
+ var wasmModule, xdrSections, bufferSection, specEntryArray, spec;
112
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
113
+ while (1) switch (_context2.prev = _context2.next) {
114
+ case 0:
115
+ _context2.next = 2;
116
+ return WebAssembly.compile(wasm);
117
+ case 2:
118
+ wasmModule = _context2.sent;
119
+ xdrSections = WebAssembly.Module.customSections(wasmModule, "contractspecv0");
120
+ if (!(xdrSections.length === 0)) {
121
+ _context2.next = 6;
122
+ break;
123
+ }
124
+ throw new Error('Could not obtain contract spec from wasm');
125
+ case 6:
126
+ bufferSection = Buffer.from(xdrSections[0]);
127
+ specEntryArray = (0, _utils.processSpecEntryStream)(bufferSection);
128
+ spec = new _spec.Spec(specEntryArray);
129
+ return _context2.abrupt("return", new Client(spec, options));
130
+ case 10:
131
+ case "end":
132
+ return _context2.stop();
133
+ }
134
+ }, _callee2);
135
+ }));
136
+ function fromWasm(_x3, _x4) {
137
+ return _fromWasm.apply(this, arguments);
138
+ }
139
+ return fromWasm;
140
+ }())
141
+ }, {
142
+ key: "from",
143
+ value: (function () {
144
+ var _from = _asyncToGenerator(_regeneratorRuntime().mark(function _callee3(options) {
145
+ var rpcUrl, contractId, allowHttp, serverOpts, server, wasm;
146
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
147
+ while (1) switch (_context3.prev = _context3.next) {
148
+ case 0:
149
+ if (!(!options || !options.rpcUrl || !options.contractId)) {
150
+ _context3.next = 2;
151
+ break;
152
+ }
153
+ throw new TypeError('options must contain rpcUrl and contractId');
154
+ case 2:
155
+ rpcUrl = options.rpcUrl, contractId = options.contractId, allowHttp = options.allowHttp;
156
+ serverOpts = {
157
+ allowHttp: allowHttp
158
+ };
159
+ server = new _rpc.Server(rpcUrl, serverOpts);
160
+ _context3.next = 7;
161
+ return server.getContractWasmByContractId(contractId);
162
+ case 7:
163
+ wasm = _context3.sent;
164
+ return _context3.abrupt("return", Client.fromWasm(wasm, options));
165
+ case 9:
166
+ case "end":
167
+ return _context3.stop();
168
+ }
169
+ }, _callee3);
170
+ }));
171
+ function from(_x5) {
172
+ return _from.apply(this, arguments);
173
+ }
174
+ return from;
175
+ }())
176
+ }]);
177
+ }();
@@ -0,0 +1,7 @@
1
+ export * from "./assembled_transaction";
2
+ export * from "./basic_node_signer";
3
+ export * from "./client";
4
+ export * from "./rust_result";
5
+ export * from "./sent_transaction";
6
+ export * from "./spec";
7
+ export * from "./types";
@@ -36,6 +36,17 @@ Object.keys(_client).forEach(function (key) {
36
36
  }
37
37
  });
38
38
  });
39
+ var _rust_result = require("./rust_result");
40
+ Object.keys(_rust_result).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _rust_result[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _rust_result[key];
47
+ }
48
+ });
49
+ });
39
50
  var _sent_transaction = require("./sent_transaction");
40
51
  Object.keys(_sent_transaction).forEach(function (key) {
41
52
  if (key === "default" || key === "__esModule") return;
@@ -47,25 +58,25 @@ Object.keys(_sent_transaction).forEach(function (key) {
47
58
  }
48
59
  });
49
60
  });
50
- var _types = require("./types");
51
- Object.keys(_types).forEach(function (key) {
61
+ var _spec = require("./spec");
62
+ Object.keys(_spec).forEach(function (key) {
52
63
  if (key === "default" || key === "__esModule") return;
53
- if (key in exports && exports[key] === _types[key]) return;
64
+ if (key in exports && exports[key] === _spec[key]) return;
54
65
  Object.defineProperty(exports, key, {
55
66
  enumerable: true,
56
67
  get: function get() {
57
- return _types[key];
68
+ return _spec[key];
58
69
  }
59
70
  });
60
71
  });
61
- var _utils = require("./utils");
62
- Object.keys(_utils).forEach(function (key) {
72
+ var _types = require("./types");
73
+ Object.keys(_types).forEach(function (key) {
63
74
  if (key === "default" || key === "__esModule") return;
64
- if (key in exports && exports[key] === _utils[key]) return;
75
+ if (key in exports && exports[key] === _types[key]) return;
65
76
  Object.defineProperty(exports, key, {
66
77
  enumerable: true,
67
78
  get: function get() {
68
- return _utils[key];
79
+ return _types[key];
69
80
  }
70
81
  });
71
82
  });
@@ -1,6 +1,7 @@
1
- import type { ContractClientOptions, Tx } from "./types";
2
- import { SorobanRpc } from "..";
3
- import { AssembledTransaction } from "./assembled_transaction";
1
+ import type { ClientOptions, Tx } from "./types";
2
+ import { Server } from "../rpc/server";
3
+ import { Api } from "../rpc/api";
4
+ import type { AssembledTransaction } from "./assembled_transaction";
4
5
  /**
5
6
  * A transaction that has been sent to the Soroban network. This happens in two steps:
6
7
  *
@@ -16,27 +17,27 @@ import { AssembledTransaction } from "./assembled_transaction";
16
17
  * `getTransactionResponse`.
17
18
  */
18
19
  export declare class SentTransaction<T> {
19
- signTransaction: ContractClientOptions["signTransaction"];
20
+ signTransaction: ClientOptions["signTransaction"];
20
21
  assembled: AssembledTransaction<T>;
21
- server: SorobanRpc.Server;
22
+ server: Server;
22
23
  signed?: Tx;
23
24
  /**
24
25
  * The result of calling `sendTransaction` to broadcast the transaction to the
25
26
  * network.
26
27
  */
27
- sendTransactionResponse?: SorobanRpc.Api.SendTransactionResponse;
28
+ sendTransactionResponse?: Api.SendTransactionResponse;
28
29
  /**
29
30
  * If `sendTransaction` completes successfully (which means it has `status: 'PENDING'`),
30
31
  * then `getTransaction` will be called in a loop for
31
32
  * {@link MethodOptions.timeoutInSeconds} seconds. This array contains all
32
33
  * the results of those calls.
33
34
  */
34
- getTransactionResponseAll?: SorobanRpc.Api.GetTransactionResponse[];
35
+ getTransactionResponseAll?: Api.GetTransactionResponse[];
35
36
  /**
36
37
  * The most recent result of calling `getTransaction`, from the
37
38
  * `getTransactionResponseAll` array.
38
39
  */
39
- getTransactionResponse?: SorobanRpc.Api.GetTransactionResponse;
40
+ getTransactionResponse?: Api.GetTransactionResponse;
40
41
  static Errors: {
41
42
  SendFailed: {
42
43
  new (message?: string): {
@@ -58,14 +59,24 @@ export declare class SentTransaction<T> {
58
59
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
59
60
  stackTraceLimit: number;
60
61
  };
62
+ TransactionStillPending: {
63
+ new (message?: string): {
64
+ name: string;
65
+ message: string;
66
+ stack?: string | undefined;
67
+ };
68
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
69
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
70
+ stackTraceLimit: number;
71
+ };
61
72
  };
62
- constructor(signTransaction: ContractClientOptions["signTransaction"], assembled: AssembledTransaction<T>);
73
+ constructor(signTransaction: ClientOptions["signTransaction"], assembled: AssembledTransaction<T>);
63
74
  /**
64
75
  * Initialize a `SentTransaction` from an existing `AssembledTransaction` and
65
76
  * a `signTransaction` function. This will also send the transaction to the
66
77
  * network.
67
78
  */
68
- static init: <T_1>(signTransaction: ContractClientOptions["signTransaction"], assembled: AssembledTransaction<T_1>) => Promise<SentTransaction<T_1>>;
79
+ static init: <U>(signTransaction: ClientOptions["signTransaction"], assembled: AssembledTransaction<U>) => Promise<SentTransaction<U>>;
69
80
  private send;
70
81
  get result(): T;
71
82
  }
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.SentTransaction = void 0;
7
- var _ = require("..");
7
+ var _stellarBase = require("@stellar/stellar-base");
8
+ var _server = require("../rpc/server");
9
+ var _api = require("../rpc/api");
8
10
  var _utils = require("./utils");
9
11
  var _SentTransaction;
10
12
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
@@ -39,10 +41,10 @@ var SentTransaction = exports.SentTransaction = function () {
39
41
  while (1) switch (_context.prev = _context.next) {
40
42
  case 0:
41
43
  timeoutInSeconds = (_this$assembled$optio = _this.assembled.options.timeoutInSeconds) !== null && _this$assembled$optio !== void 0 ? _this$assembled$optio : _utils.DEFAULT_TIMEOUT;
42
- _this.assembled.built = _.TransactionBuilder.cloneFrom(_this.assembled.built, {
44
+ _this.assembled.built = _stellarBase.TransactionBuilder.cloneFrom(_this.assembled.built, {
43
45
  fee: _this.assembled.built.fee,
44
46
  timebounds: undefined,
45
- sorobanData: new _.SorobanDataBuilder(_this.assembled.simulationData.transactionData.toXDR()).build()
47
+ sorobanData: new _stellarBase.SorobanDataBuilder(_this.assembled.simulationData.transactionData.toXDR()).build()
46
48
  }).setTimeout(timeoutInSeconds).build();
47
49
  _context.next = 4;
48
50
  return _this.signTransaction(_this.assembled.built.toXDR(), {
@@ -50,7 +52,7 @@ var SentTransaction = exports.SentTransaction = function () {
50
52
  });
51
53
  case 4:
52
54
  signature = _context.sent;
53
- _this.signed = _.TransactionBuilder.fromXDR(signature, _this.assembled.options.networkPassphrase);
55
+ _this.signed = _stellarBase.TransactionBuilder.fromXDR(signature, _this.assembled.options.networkPassphrase);
54
56
  _context.next = 8;
55
57
  return _this.server.sendTransaction(_this.signed);
56
58
  case 8:
@@ -59,23 +61,26 @@ var SentTransaction = exports.SentTransaction = function () {
59
61
  _context.next = 11;
60
62
  break;
61
63
  }
62
- throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n" + JSON.stringify(_this.sendTransactionResponse, null, 2));
64
+ throw new SentTransaction.Errors.SendFailed("Sending the transaction to the network failed!\n".concat(JSON.stringify(_this.sendTransactionResponse, null, 2)));
63
65
  case 11:
64
66
  hash = _this.sendTransactionResponse.hash;
65
67
  _context.next = 14;
66
68
  return (0, _utils.withExponentialBackoff)(function () {
67
69
  return _this.server.getTransaction(hash);
68
70
  }, function (resp) {
69
- return resp.status === _.SorobanRpc.Api.GetTransactionStatus.NOT_FOUND;
71
+ return resp.status === _api.Api.GetTransactionStatus.NOT_FOUND;
70
72
  }, timeoutInSeconds);
71
73
  case 14:
72
74
  _this.getTransactionResponseAll = _context.sent;
73
75
  _this.getTransactionResponse = _this.getTransactionResponseAll[_this.getTransactionResponseAll.length - 1];
74
- if (_this.getTransactionResponse.status === _.SorobanRpc.Api.GetTransactionStatus.NOT_FOUND) {
75
- console.error("Waited ".concat(timeoutInSeconds, " seconds for transaction to complete, but it did not. ") + "Returning anyway. Check the transaction status manually. " + "Sent transaction: ".concat(JSON.stringify(_this.sendTransactionResponse, null, 2), "\n") + "All attempts to get the result: ".concat(JSON.stringify(_this.getTransactionResponseAll, null, 2)));
76
+ if (!(_this.getTransactionResponse.status === _api.Api.GetTransactionStatus.NOT_FOUND)) {
77
+ _context.next = 18;
78
+ break;
76
79
  }
77
- return _context.abrupt("return", _this);
80
+ throw new SentTransaction.Errors.TransactionStillPending("Waited ".concat(timeoutInSeconds, " seconds for transaction to complete, but it did not. ") + "Returning anyway. Check the transaction status manually. " + "Sent transaction: ".concat(JSON.stringify(_this.sendTransactionResponse, null, 2), "\n") + "All attempts to get the result: ".concat(JSON.stringify(_this.getTransactionResponseAll, null, 2)));
78
81
  case 18:
82
+ return _context.abrupt("return", _this);
83
+ case 19:
79
84
  case "end":
80
85
  return _context.stop();
81
86
  }
@@ -86,7 +91,7 @@ var SentTransaction = exports.SentTransaction = function () {
86
91
  if (!signTransaction) {
87
92
  throw new Error("You must provide a `signTransaction` function to send a transaction");
88
93
  }
89
- this.server = new _.SorobanRpc.Server(this.assembled.options.rpcUrl, {
94
+ this.server = new _server.Server(this.assembled.options.rpcUrl, {
90
95
  allowHttp: (_this$assembled$optio2 = this.assembled.options.allowHttp) !== null && _this$assembled$optio2 !== void 0 ? _this$assembled$optio2 : false
91
96
  });
92
97
  }
@@ -128,11 +133,19 @@ _defineProperty(SentTransaction, "Errors", {
128
133
  }
129
134
  _inherits(SendResultOnlyError, _Error2);
130
135
  return _createClass(SendResultOnlyError);
136
+ }(_wrapNativeSuper(Error)),
137
+ TransactionStillPending: function (_Error3) {
138
+ function TransactionStillPendingError() {
139
+ _classCallCheck(this, TransactionStillPendingError);
140
+ return _callSuper(this, TransactionStillPendingError, arguments);
141
+ }
142
+ _inherits(TransactionStillPendingError, _Error3);
143
+ return _createClass(TransactionStillPendingError);
131
144
  }(_wrapNativeSuper(Error))
132
145
  });
133
146
  _defineProperty(SentTransaction, "init", function () {
134
147
  var _ref2 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(signTransaction, assembled) {
135
- var tx;
148
+ var tx, sent;
136
149
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
137
150
  while (1) switch (_context2.prev = _context2.next) {
138
151
  case 0:
@@ -140,8 +153,9 @@ _defineProperty(SentTransaction, "init", function () {
140
153
  _context2.next = 3;
141
154
  return tx.send();
142
155
  case 3:
143
- return _context2.abrupt("return", _context2.sent);
144
- case 4:
156
+ sent = _context2.sent;
157
+ return _context2.abrupt("return", sent);
158
+ case 5:
145
159
  case "end":
146
160
  return _context2.stop();
147
161
  }
@@ -1,5 +1,5 @@
1
- import { JSONSchema7 } from "json-schema";
2
- import { xdr } from ".";
1
+ import type { JSONSchema7 } from "json-schema";
2
+ import { xdr } from "@stellar/stellar-base";
3
3
  export interface Union<T> {
4
4
  tag: string;
5
5
  values?: T;
@@ -29,7 +29,7 @@ export interface Union<T> {
29
29
  * console.log(result); // {success: true}
30
30
  * ```
31
31
  */
32
- export declare class ContractSpec {
32
+ export declare class Spec {
33
33
  entries: xdr.ScSpecEntry[];
34
34
  /**
35
35
  * Constructs a new ContractSpec from an array of XDR spec entries.