@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
@@ -1,4 +1,4 @@
1
- import { Memo, MemoType, Operation, Transaction, xdr } from "..";
1
+ import { Memo, MemoType, Operation, Transaction, xdr } from "@stellar/stellar-base";
2
2
  export type XDR_BASE64 = string;
3
3
  export type u32 = number;
4
4
  export type i32 = number;
@@ -15,7 +15,7 @@ export type Duration = bigint;
15
15
  * A "regular" transaction, as opposed to a FeeBumpTransaction.
16
16
  */
17
17
  export type Tx = Transaction<Memo<MemoType>, Operation[]>;
18
- export type ContractClientOptions = {
18
+ export type ClientOptions = {
19
19
  /**
20
20
  * The public key of the account that will send this transaction. You can
21
21
  * override this for specific methods later, like
@@ -59,15 +59,15 @@ export type ContractClientOptions = {
59
59
  */
60
60
  allowHttp?: boolean;
61
61
  /**
62
- * This gets filled in automatically from the ContractSpec if you use
63
- * {@link ContractClient.generate} to create your ContractClient.
62
+ * This gets filled in automatically from the ContractSpec when you
63
+ * instantiate a {@link Client}.
64
64
  *
65
65
  * Background: If the contract you're calling uses the `#[contracterror]`
66
66
  * macro to create an `Error` enum, then those errors get included in the
67
67
  * on-chain XDR that also describes your contract's methods. Each error will
68
68
  * have a specific number.
69
69
  *
70
- * A ContractClient makes method calls with an {@link AssembledTransaction}.
70
+ * A Client makes method calls with an {@link AssembledTransaction}.
71
71
  * When one of these method calls encounters an error, `AssembledTransaction`
72
72
  * will first attempt to parse the error as an "official" `contracterror`
73
73
  * error, by using this passed-in `errorTypes` object. See
@@ -85,15 +85,17 @@ export type MethodOptions = {
85
85
  */
86
86
  fee?: string;
87
87
  /**
88
- * The maximum amount of time to wait for the transaction to complete. Default: {@link DEFAULT_TIMEOUT}
88
+ * The maximum amount of time to wait for the transaction to complete.
89
+ * Default: {@link DEFAULT_TIMEOUT}
89
90
  */
90
91
  timeoutInSeconds?: number;
91
92
  /**
92
- * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true
93
+ * Whether to automatically simulate the transaction when constructing the
94
+ * AssembledTransaction. Default: true
93
95
  */
94
96
  simulate?: boolean;
95
97
  };
96
- export type AssembledTransactionOptions<T = string> = MethodOptions & ContractClientOptions & {
98
+ export type AssembledTransactionOptions<T = string> = MethodOptions & ClientOptions & {
97
99
  method: string;
98
100
  args?: any[];
99
101
  parseResultXdr: (xdr: xdr.ScVal) => T;
@@ -0,0 +1,40 @@
1
+ import { xdr } from "@stellar/stellar-base";
2
+ /**
3
+ * The default timeout for waiting for a transaction to be included in a block.
4
+ */
5
+ export declare const DEFAULT_TIMEOUT: number;
6
+ /**
7
+ * Keep calling a `fn` for `timeoutInSeconds` seconds, if `keepWaitingIf` is
8
+ * true. Returns an array of all attempts to call the function.
9
+ */
10
+ export declare function withExponentialBackoff<T>(
11
+ /** Function to call repeatedly */
12
+ fn: (previousFailure?: T) => Promise<T>,
13
+ /** Condition to check when deciding whether or not to call `fn` again */
14
+ keepWaitingIf: (result: T) => boolean,
15
+ /** How long to wait between the first and second call */
16
+ timeoutInSeconds: number,
17
+ /** What to multiply `timeoutInSeconds` by, each subsequent attempt */
18
+ exponentialFactor?: number,
19
+ /** Whether to log extra info */
20
+ verbose?: boolean): Promise<T[]>;
21
+ /**
22
+ * If contracts are implemented using the `#[contracterror]` macro, then the
23
+ * errors get included in the on-chain XDR that also describes your contract's
24
+ * methods. Each error will have a specific number. This Regular Expression
25
+ * matches these "expected error types" that a contract may throw, and helps
26
+ * {@link AssembledTransaction} parse these errors.
27
+ */
28
+ export declare const contractErrorPattern: RegExp;
29
+ /**
30
+ * A TypeScript type guard that checks if an object has a `toString` method.
31
+ */
32
+ export declare function implementsToString(
33
+ /** some object that may or may not have a `toString` method */
34
+ obj: unknown): obj is {
35
+ toString(): string;
36
+ };
37
+ /**
38
+ * Reads a binary stream of ScSpecEntries into an array for processing by ContractSpec
39
+ */
40
+ export declare function processSpecEntryStream(buffer: Buffer): xdr.ScSpecEntry[];
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.contractErrorPattern = exports.DEFAULT_TIMEOUT = void 0;
7
7
  exports.implementsToString = implementsToString;
8
+ exports.processSpecEntryStream = processSpecEntryStream;
8
9
  exports.withExponentialBackoff = withExponentialBackoff;
10
+ var _stellarBase = require("@stellar/stellar-base");
9
11
  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; }
10
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); }
11
13
  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); } }
@@ -51,7 +53,7 @@ function _withExponentialBackoff() {
51
53
  _context.next = 30;
52
54
  break;
53
55
  }
54
- count++;
56
+ count += 1;
55
57
  if (verbose) {
56
58
  console.info("Waiting ".concat(waitTime, "ms before trying again (bringing the total wait time to ").concat(totalWaitTime, "ms so far, of total ").concat(timeoutInSeconds * 1000, "ms)"));
57
59
  }
@@ -60,7 +62,7 @@ function _withExponentialBackoff() {
60
62
  return setTimeout(res, waitTime);
61
63
  });
62
64
  case 19:
63
- waitTime = waitTime * exponentialFactor;
65
+ waitTime *= exponentialFactor;
64
66
  if (new Date(Date.now() + waitTime).valueOf() > waitUntil) {
65
67
  waitTime = waitUntil - Date.now();
66
68
  if (verbose) {
@@ -92,4 +94,12 @@ function _withExponentialBackoff() {
92
94
  var contractErrorPattern = exports.contractErrorPattern = /Error\(Contract, #(\d+)\)/;
93
95
  function implementsToString(obj) {
94
96
  return _typeof(obj) === "object" && obj !== null && "toString" in obj;
97
+ }
98
+ function processSpecEntryStream(buffer) {
99
+ var reader = new _stellarBase.cereal.XdrReader(buffer);
100
+ var res = [];
101
+ while (!reader.eof) {
102
+ res.push(_stellarBase.xdr.ScSpecEntry.read(reader));
103
+ }
104
+ return res;
95
105
  }
package/lib/index.d.ts CHANGED
@@ -6,8 +6,32 @@ export * as Federation from './federation';
6
6
  export * as WebAuth from './webauth';
7
7
  export * as Friendbot from './friendbot';
8
8
  export * as Horizon from './horizon';
9
- export * as SorobanRpc from './soroban';
10
- export * from './contract_spec';
9
+ /**
10
+ * Tools for interacting with the Soroban RPC server, such as `Server`,
11
+ * `assembleTransaction`, and the `Api` types. You can import these from the
12
+ * `/rpc` entrypoint, if your version of Node and your TypeScript configuration
13
+ * allow it:
14
+ *
15
+ * ```ts
16
+ * import { Server } from '@stellar/stellar-sdk/rpc';
17
+ * ```
18
+ */
19
+ export * as rpc from './rpc';
20
+ /**
21
+ * @deprecated Use `rpc` instead
22
+ */
23
+ export * as SorobanRpc from './rpc';
24
+ /**
25
+ * Tools for interacting with smart contracts, such as `Client`, `Spec`, and
26
+ * `AssembledTransaction`. You can import these from the `/contract`
27
+ * entrypoint, if your version of Node and your TypeScript configuration allow
28
+ * it:
29
+ *
30
+ * ```ts
31
+ * import { Client } from '@stellar/stellar-sdk/contract';
32
+ * ```
33
+ */
34
+ export * as contract from './contract';
11
35
  export * from '@stellar/stellar-base';
12
36
  declare const _default: any;
13
37
  export default _default;
package/lib/index.js CHANGED
@@ -12,7 +12,9 @@ var _exportNames = {
12
12
  WebAuth: true,
13
13
  Friendbot: true,
14
14
  Horizon: true,
15
- SorobanRpc: true
15
+ rpc: true,
16
+ SorobanRpc: true,
17
+ contract: true
16
18
  };
17
19
  Object.defineProperty(exports, "Config", {
18
20
  enumerable: true,
@@ -27,7 +29,7 @@ Object.defineProperty(exports, "Utils", {
27
29
  return _utils.Utils;
28
30
  }
29
31
  });
30
- exports.default = exports.WebAuth = void 0;
32
+ exports.rpc = exports.default = exports.contract = exports.WebAuth = void 0;
31
33
  var _errors = require("./errors");
32
34
  Object.keys(_errors).forEach(function (key) {
33
35
  if (key === "default" || key === "__esModule") return;
@@ -52,20 +54,12 @@ var _Friendbot = _interopRequireWildcard(require("./friendbot"));
52
54
  exports.Friendbot = _Friendbot;
53
55
  var _Horizon = _interopRequireWildcard(require("./horizon"));
54
56
  exports.Horizon = _Horizon;
55
- var _SorobanRpc = _interopRequireWildcard(require("./soroban"));
56
- exports.SorobanRpc = _SorobanRpc;
57
- var _contract_spec = require("./contract_spec");
58
- Object.keys(_contract_spec).forEach(function (key) {
59
- if (key === "default" || key === "__esModule") return;
60
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
61
- if (key in exports && exports[key] === _contract_spec[key]) return;
62
- Object.defineProperty(exports, key, {
63
- enumerable: true,
64
- get: function get() {
65
- return _contract_spec[key];
66
- }
67
- });
68
- });
57
+ var _rpc = _interopRequireWildcard(require("./rpc"));
58
+ var _SorobanRpc = _rpc;
59
+ exports.rpc = _rpc;
60
+ exports.SorobanRpc = _rpc;
61
+ var _contract = _interopRequireWildcard(require("./contract"));
62
+ exports.contract = _contract;
69
63
  var _stellarBase = require("@stellar/stellar-base");
70
64
  Object.keys(_stellarBase).forEach(function (key) {
71
65
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,7 @@
1
+ export * from "./api";
2
+ export { Server, Durability } from "./server";
3
+ export { default as AxiosClient } from "./axios";
4
+ export { parseRawSimulation, parseRawEvents } from "./parsers";
5
+ export * from "./transaction";
6
+ declare const _default: any;
7
+ export default _default;
@@ -110,6 +110,55 @@ export declare class Server {
110
110
  * });
111
111
  */
112
112
  getContractData(contract: string | Address | Contract, key: xdr.ScVal, durability?: Durability): Promise<Api.LedgerEntryResult>;
113
+ /**
114
+ * Retrieves the WASM bytecode for a given contract.
115
+ *
116
+ * This method allows you to fetch the WASM bytecode associated with a contract
117
+ * deployed on the Soroban network. The WASM bytecode represents the executable
118
+ * code of the contract.
119
+ *
120
+ * @param {string} contractId the contract ID containing the
121
+ * WASM bytecode to retrieve
122
+ *
123
+ * @returns {Promise<Buffer>} a Buffer containing the WASM bytecode
124
+ *
125
+ * @throws {Error} If the contract or its associated WASM bytecode cannot be
126
+ * found on the network.
127
+ *
128
+ * @example
129
+ * const contractId = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5";
130
+ * server.getContractWasmByContractId(contractId).then(wasmBuffer => {
131
+ * console.log("WASM bytecode length:", wasmBuffer.length);
132
+ * // ... do something with the WASM bytecode ...
133
+ * }).catch(err => {
134
+ * console.error("Error fetching WASM bytecode:", err);
135
+ * });
136
+ */
137
+ getContractWasmByContractId(contractId: string): Promise<Buffer>;
138
+ /**
139
+ * Retrieves the WASM bytecode for a given contract hash.
140
+ *
141
+ * This method allows you to fetch the WASM bytecode associated with a contract
142
+ * deployed on the Soroban network using the contract's WASM hash. The WASM bytecode
143
+ * represents the executable code of the contract.
144
+ *
145
+ * @param {Buffer} wasmHash the WASM hash of the contract
146
+ *
147
+ * @returns {Promise<Buffer>} a Buffer containing the WASM bytecode
148
+ *
149
+ * @throws {Error} If the contract or its associated WASM bytecode cannot be
150
+ * found on the network.
151
+ *
152
+ * @example
153
+ * const wasmHash = Buffer.from("...");
154
+ * server.getContractWasmByHash(wasmHash).then(wasmBuffer => {
155
+ * console.log("WASM bytecode length:", wasmBuffer.length);
156
+ * // ... do something with the WASM bytecode ...
157
+ * }).catch(err => {
158
+ * console.error("Error fetching WASM bytecode:", err);
159
+ * });
160
+ */
161
+ getContractWasmByHash(wasmHash: Buffer | string, format?: undefined | "hex" | "base64"): Promise<Buffer>;
113
162
  /**
114
163
  * Reads the current value of arbitrary ledger entries directly.
115
164
  *