stelar-sdk 12.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE +228 -0
  2. package/README.md +295 -0
  3. package/dist/stellar-sdk.js +59532 -0
  4. package/dist/stellar-sdk.min.js +2 -0
  5. package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
  6. package/jtjllzos.cjs +1 -0
  7. package/lib/browser.d.ts +6 -0
  8. package/lib/browser.js +37 -0
  9. package/lib/config.d.ts +52 -0
  10. package/lib/config.js +51 -0
  11. package/lib/contract/assembled_transaction.d.ts +547 -0
  12. package/lib/contract/assembled_transaction.js +721 -0
  13. package/lib/contract/basic_node_signer.d.ts +12 -0
  14. package/lib/contract/basic_node_signer.js +52 -0
  15. package/lib/contract/client.d.ts +52 -0
  16. package/lib/contract/client.js +180 -0
  17. package/lib/contract/index.d.ts +7 -0
  18. package/lib/contract/index.js +82 -0
  19. package/lib/contract/rust_result.d.ts +71 -0
  20. package/lib/contract/rust_result.js +66 -0
  21. package/lib/contract/sent_transaction.d.ts +79 -0
  22. package/lib/contract/sent_transaction.js +151 -0
  23. package/lib/contract/spec.d.ts +158 -0
  24. package/lib/contract/spec.js +1020 -0
  25. package/lib/contract/types.d.ts +112 -0
  26. package/lib/contract/types.js +8 -0
  27. package/lib/contract/utils.d.ts +39 -0
  28. package/lib/contract/utils.js +123 -0
  29. package/lib/errors.d.ts +59 -0
  30. package/lib/errors.js +99 -0
  31. package/lib/federation/api.d.ts +11 -0
  32. package/lib/federation/api.js +7 -0
  33. package/lib/federation/index.d.ts +2 -0
  34. package/lib/federation/index.js +24 -0
  35. package/lib/federation/server.d.ts +118 -0
  36. package/lib/federation/server.js +252 -0
  37. package/lib/friendbot/index.d.ts +5 -0
  38. package/lib/friendbot/index.js +7 -0
  39. package/lib/horizon/account_call_builder.d.ts +54 -0
  40. package/lib/horizon/account_call_builder.js +62 -0
  41. package/lib/horizon/account_response.d.ts +58 -0
  42. package/lib/horizon/account_response.js +49 -0
  43. package/lib/horizon/assets_call_builder.d.ts +26 -0
  44. package/lib/horizon/assets_call_builder.js +43 -0
  45. package/lib/horizon/call_builder.d.ts +128 -0
  46. package/lib/horizon/call_builder.js +356 -0
  47. package/lib/horizon/claimable_balances_call_builder.d.ts +48 -0
  48. package/lib/horizon/claimable_balances_call_builder.js +56 -0
  49. package/lib/horizon/effect_call_builder.d.ts +52 -0
  50. package/lib/horizon/effect_call_builder.js +56 -0
  51. package/lib/horizon/friendbot_builder.d.ts +4 -0
  52. package/lib/horizon/friendbot_builder.js +32 -0
  53. package/lib/horizon/horizon_api.d.ts +527 -0
  54. package/lib/horizon/horizon_api.js +96 -0
  55. package/lib/horizon/horizon_axios_client.d.ts +30 -0
  56. package/lib/horizon/horizon_axios_client.js +48 -0
  57. package/lib/horizon/index.d.ts +7 -0
  58. package/lib/horizon/index.js +78 -0
  59. package/lib/horizon/ledger_call_builder.d.ts +21 -0
  60. package/lib/horizon/ledger_call_builder.js +37 -0
  61. package/lib/horizon/liquidity_pool_call_builder.d.ts +36 -0
  62. package/lib/horizon/liquidity_pool_call_builder.js +59 -0
  63. package/lib/horizon/offer_call_builder.d.ts +63 -0
  64. package/lib/horizon/offer_call_builder.js +79 -0
  65. package/lib/horizon/operation_call_builder.d.ts +67 -0
  66. package/lib/horizon/operation_call_builder.js +69 -0
  67. package/lib/horizon/orderbook_call_builder.d.ts +15 -0
  68. package/lib/horizon/orderbook_call_builder.js +45 -0
  69. package/lib/horizon/path_call_builder.d.ts +30 -0
  70. package/lib/horizon/path_call_builder.js +41 -0
  71. package/lib/horizon/payment_call_builder.d.ts +35 -0
  72. package/lib/horizon/payment_call_builder.js +46 -0
  73. package/lib/horizon/server.d.ts +380 -0
  74. package/lib/horizon/server.js +549 -0
  75. package/lib/horizon/server_api.d.ts +278 -0
  76. package/lib/horizon/server_api.js +19 -0
  77. package/lib/horizon/strict_receive_path_call_builder.d.ts +33 -0
  78. package/lib/horizon/strict_receive_path_call_builder.js +50 -0
  79. package/lib/horizon/strict_send_path_call_builder.d.ts +33 -0
  80. package/lib/horizon/strict_send_path_call_builder.js +50 -0
  81. package/lib/horizon/trade_aggregation_call_builder.d.ts +47 -0
  82. package/lib/horizon/trade_aggregation_call_builder.js +76 -0
  83. package/lib/horizon/trades_call_builder.d.ts +49 -0
  84. package/lib/horizon/trades_call_builder.js +72 -0
  85. package/lib/horizon/transaction_call_builder.d.ts +57 -0
  86. package/lib/horizon/transaction_call_builder.js +64 -0
  87. package/lib/horizon/types/account.d.ts +5 -0
  88. package/lib/horizon/types/account.js +5 -0
  89. package/lib/horizon/types/assets.d.ts +19 -0
  90. package/lib/horizon/types/assets.js +5 -0
  91. package/lib/horizon/types/effects.d.ts +285 -0
  92. package/lib/horizon/types/effects.js +62 -0
  93. package/lib/horizon/types/offer.d.ts +20 -0
  94. package/lib/horizon/types/offer.js +5 -0
  95. package/lib/horizon/types/trade.d.ts +13 -0
  96. package/lib/horizon/types/trade.js +5 -0
  97. package/lib/index.d.ts +37 -0
  98. package/lib/index.js +77 -0
  99. package/lib/rpc/api.d.ts +348 -0
  100. package/lib/rpc/api.js +32 -0
  101. package/lib/rpc/axios.d.ts +3 -0
  102. package/lib/rpc/axios.js +16 -0
  103. package/lib/rpc/browser.d.ts +6 -0
  104. package/lib/rpc/browser.js +37 -0
  105. package/lib/rpc/index.d.ts +7 -0
  106. package/lib/rpc/index.js +72 -0
  107. package/lib/rpc/jsonrpc.d.ts +27 -0
  108. package/lib/rpc/jsonrpc.js +52 -0
  109. package/lib/rpc/parsers.d.ts +19 -0
  110. package/lib/rpc/parsers.js +155 -0
  111. package/lib/rpc/server.d.ts +514 -0
  112. package/lib/rpc/server.js +737 -0
  113. package/lib/rpc/transaction.d.ts +19 -0
  114. package/lib/rpc/transaction.js +53 -0
  115. package/lib/rpc/utils.d.ts +1 -0
  116. package/lib/rpc/utils.js +9 -0
  117. package/lib/stellartoml/index.d.ts +121 -0
  118. package/lib/stellartoml/index.js +77 -0
  119. package/lib/utils.d.ts +12 -0
  120. package/lib/utils.js +31 -0
  121. package/lib/webauth/errors.d.ts +4 -0
  122. package/lib/webauth/errors.js +36 -0
  123. package/lib/webauth/index.d.ts +2 -0
  124. package/lib/webauth/index.js +27 -0
  125. package/lib/webauth/utils.d.ts +294 -0
  126. package/lib/webauth/utils.js +332 -0
  127. package/package.json +155 -0
  128. package/types/dom-monkeypatch.d.ts +126 -0
@@ -0,0 +1,112 @@
1
+ import { Memo, MemoType, Operation, Transaction, xdr } from "@stellar/stellar-base";
2
+ export type XDR_BASE64 = string;
3
+ export type u32 = number;
4
+ export type i32 = number;
5
+ export type u64 = bigint;
6
+ export type i64 = bigint;
7
+ export type u128 = bigint;
8
+ export type i128 = bigint;
9
+ export type u256 = bigint;
10
+ export type i256 = bigint;
11
+ export type Option<T> = T | undefined;
12
+ export type Typepoint = bigint;
13
+ export type Duration = bigint;
14
+ /**
15
+ * A "regular" transaction, as opposed to a FeeBumpTransaction.
16
+ */
17
+ export type Tx = Transaction<Memo<MemoType>, Operation[]>;
18
+ export type ClientOptions = {
19
+ /**
20
+ * The public key of the account that will send this transaction. You can
21
+ * override this for specific methods later, like
22
+ * {@link AssembledTransaction#signAndSend} and
23
+ * {@link AssembledTransaction#signAuthEntries}.
24
+ */
25
+ publicKey?: string;
26
+ /**
27
+ * A function to sign the transaction using the private key corresponding to
28
+ * the given `publicKey`. You do not need to provide this, for read-only
29
+ * calls, which only need to be simulated. If you do not need to sign and
30
+ * send, there is no need to provide this. If you do not provide it during
31
+ * initialization, you can provide it later when you call
32
+ * {@link AssembledTransaction#signAndSend}.
33
+ *
34
+ * Matches signature of `signTransaction` from Freighter.
35
+ */
36
+ signTransaction?: (tx: XDR_BASE64, opts?: {
37
+ network?: string;
38
+ networkPassphrase?: string;
39
+ accountToSign?: string;
40
+ }) => Promise<XDR_BASE64>;
41
+ /**
42
+ * A function to sign a specific auth entry for a transaction, using the
43
+ * private key corresponding to the provided `publicKey`. This is only needed
44
+ * for multi-auth transactions, in which one transaction is signed by
45
+ * multiple parties. If you do not provide it during initialization, you can
46
+ * provide it later when you call {@link AssembledTransaction#signAuthEntries}.
47
+ *
48
+ * Matches signature of `signAuthEntry` from Freighter.
49
+ */
50
+ signAuthEntry?: (entryXdr: XDR_BASE64, opts?: {
51
+ accountToSign?: string;
52
+ }) => Promise<XDR_BASE64>;
53
+ contractId: string;
54
+ networkPassphrase: string;
55
+ rpcUrl: string;
56
+ /**
57
+ * If true, will allow HTTP requests to the Soroban network. If false, will
58
+ * only allow HTTPS requests. @default false
59
+ */
60
+ allowHttp?: boolean;
61
+ /**
62
+ * This gets filled in automatically from the ContractSpec when you
63
+ * instantiate a {@link Client}.
64
+ *
65
+ * Background: If the contract you're calling uses the `#[contracterror]`
66
+ * macro to create an `Error` enum, then those errors get included in the
67
+ * on-chain XDR that also describes your contract's methods. Each error will
68
+ * have a specific number.
69
+ *
70
+ * A Client makes method calls with an {@link AssembledTransaction}.
71
+ * When one of these method calls encounters an error, `AssembledTransaction`
72
+ * will first attempt to parse the error as an "official" `contracterror`
73
+ * error, by using this passed-in `errorTypes` object. See
74
+ * {@link AssembledTransaction#parseError}. If `errorTypes` is blank or no
75
+ * matching error is found, then it will throw the raw error.
76
+ * @default {}
77
+ */
78
+ errorTypes?: Record<number, {
79
+ message: string;
80
+ }>;
81
+ };
82
+ export type MethodOptions = {
83
+ /**
84
+ * The fee to pay for the transaction. Default: {@link BASE_FEE}
85
+ */
86
+ fee?: string;
87
+ /**
88
+ * The maximum amount of time to wait for the transaction to complete.
89
+ * Default: {@link DEFAULT_TIMEOUT}
90
+ */
91
+ timeoutInSeconds?: number;
92
+ /**
93
+ * Whether to automatically simulate the transaction when constructing the
94
+ * AssembledTransaction. Default: true
95
+ */
96
+ simulate?: boolean;
97
+ /**
98
+ * If true, will automatically attempt to restore the transaction if there
99
+ * are archived entries that need renewal. @default false
100
+ */
101
+ restore?: boolean;
102
+ };
103
+ export type AssembledTransactionOptions<T = string> = MethodOptions & ClientOptions & {
104
+ method: string;
105
+ args?: any[];
106
+ parseResultXdr: (xdr: xdr.ScVal) => T;
107
+ };
108
+ /**
109
+ * The default timeout for waiting for a transaction to be included in a block.
110
+ */
111
+ export declare const DEFAULT_TIMEOUT: number;
112
+ export declare const NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NULL_ACCOUNT = exports.DEFAULT_TIMEOUT = void 0;
7
+ var DEFAULT_TIMEOUT = exports.DEFAULT_TIMEOUT = 5 * 60;
8
+ var NULL_ACCOUNT = exports.NULL_ACCOUNT = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
@@ -0,0 +1,39 @@
1
+ import { xdr, Account } from "@stellar/stellar-base";
2
+ import { Server } from "../rpc/server";
3
+ import { AssembledTransactionOptions } from "./types";
4
+ /**
5
+ * Keep calling a `fn` for `timeoutInSeconds` seconds, if `keepWaitingIf` is
6
+ * true. Returns an array of all attempts to call the function.
7
+ */
8
+ export declare function withExponentialBackoff<T>(
9
+ /** Function to call repeatedly */
10
+ fn: (previousFailure?: T) => Promise<T>,
11
+ /** Condition to check when deciding whether or not to call `fn` again */
12
+ keepWaitingIf: (result: T) => boolean,
13
+ /** How long to wait between the first and second call */
14
+ timeoutInSeconds: number,
15
+ /** What to multiply `timeoutInSeconds` by, each subsequent attempt */
16
+ exponentialFactor?: number,
17
+ /** Whether to log extra info */
18
+ verbose?: boolean): Promise<T[]>;
19
+ /**
20
+ * If contracts are implemented using the `#[contracterror]` macro, then the
21
+ * errors get included in the on-chain XDR that also describes your contract's
22
+ * methods. Each error will have a specific number. This Regular Expression
23
+ * matches these "expected error types" that a contract may throw, and helps
24
+ * {@link AssembledTransaction} parse these errors.
25
+ */
26
+ export declare const contractErrorPattern: RegExp;
27
+ /**
28
+ * A TypeScript type guard that checks if an object has a `toString` method.
29
+ */
30
+ export declare function implementsToString(
31
+ /** some object that may or may not have a `toString` method */
32
+ obj: unknown): obj is {
33
+ toString(): string;
34
+ };
35
+ /**
36
+ * Reads a binary stream of ScSpecEntries into an array for processing by ContractSpec
37
+ */
38
+ export declare function processSpecEntryStream(buffer: Buffer): xdr.ScSpecEntry[];
39
+ export declare function getAccount<T>(options: AssembledTransactionOptions<T>, server: Server): Promise<Account>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.contractErrorPattern = void 0;
7
+ exports.getAccount = getAccount;
8
+ exports.implementsToString = implementsToString;
9
+ exports.processSpecEntryStream = processSpecEntryStream;
10
+ exports.withExponentialBackoff = withExponentialBackoff;
11
+ var _stellarBase = require("@stellar/stellar-base");
12
+ var _types = require("./types");
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 _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); }
15
+ 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); }
16
+ 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); }); }; }
17
+ function withExponentialBackoff(_x, _x2, _x3) {
18
+ return _withExponentialBackoff.apply(this, arguments);
19
+ }
20
+ function _withExponentialBackoff() {
21
+ _withExponentialBackoff = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(fn, keepWaitingIf, timeoutInSeconds) {
22
+ var exponentialFactor,
23
+ verbose,
24
+ attempts,
25
+ count,
26
+ waitUntil,
27
+ waitTime,
28
+ totalWaitTime,
29
+ _args = arguments;
30
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
31
+ while (1) switch (_context.prev = _context.next) {
32
+ case 0:
33
+ exponentialFactor = _args.length > 3 && _args[3] !== undefined ? _args[3] : 1.5;
34
+ verbose = _args.length > 4 && _args[4] !== undefined ? _args[4] : false;
35
+ attempts = [];
36
+ count = 0;
37
+ _context.t0 = attempts;
38
+ _context.next = 7;
39
+ return fn();
40
+ case 7:
41
+ _context.t1 = _context.sent;
42
+ _context.t0.push.call(_context.t0, _context.t1);
43
+ if (keepWaitingIf(attempts[attempts.length - 1])) {
44
+ _context.next = 11;
45
+ break;
46
+ }
47
+ return _context.abrupt("return", attempts);
48
+ case 11:
49
+ waitUntil = new Date(Date.now() + timeoutInSeconds * 1000).valueOf();
50
+ waitTime = 1000;
51
+ totalWaitTime = waitTime;
52
+ case 14:
53
+ if (!(Date.now() < waitUntil && keepWaitingIf(attempts[attempts.length - 1]))) {
54
+ _context.next = 30;
55
+ break;
56
+ }
57
+ count += 1;
58
+ if (verbose) {
59
+ 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)"));
60
+ }
61
+ _context.next = 19;
62
+ return new Promise(function (res) {
63
+ return setTimeout(res, waitTime);
64
+ });
65
+ case 19:
66
+ waitTime *= exponentialFactor;
67
+ if (new Date(Date.now() + waitTime).valueOf() > waitUntil) {
68
+ waitTime = waitUntil - Date.now();
69
+ if (verbose) {
70
+ console.info("was gonna wait too long; new waitTime: ".concat(waitTime, "ms"));
71
+ }
72
+ }
73
+ totalWaitTime = waitTime + totalWaitTime;
74
+ _context.t2 = attempts;
75
+ _context.next = 25;
76
+ return fn(attempts[attempts.length - 1]);
77
+ case 25:
78
+ _context.t3 = _context.sent;
79
+ _context.t2.push.call(_context.t2, _context.t3);
80
+ if (verbose && keepWaitingIf(attempts[attempts.length - 1])) {
81
+ console.info("".concat(count, ". Called ").concat(fn, "; ").concat(attempts.length, " prev attempts. Most recent: ").concat(JSON.stringify(attempts[attempts.length - 1], null, 2)));
82
+ }
83
+ _context.next = 14;
84
+ break;
85
+ case 30:
86
+ return _context.abrupt("return", attempts);
87
+ case 31:
88
+ case "end":
89
+ return _context.stop();
90
+ }
91
+ }, _callee);
92
+ }));
93
+ return _withExponentialBackoff.apply(this, arguments);
94
+ }
95
+ var contractErrorPattern = exports.contractErrorPattern = /Error\(Contract, #(\d+)\)/;
96
+ function implementsToString(obj) {
97
+ return _typeof(obj) === "object" && obj !== null && "toString" in obj;
98
+ }
99
+ function processSpecEntryStream(buffer) {
100
+ var reader = new _stellarBase.cereal.XdrReader(buffer);
101
+ var res = [];
102
+ while (!reader.eof) {
103
+ res.push(_stellarBase.xdr.ScSpecEntry.read(reader));
104
+ }
105
+ return res;
106
+ }
107
+ function getAccount(_x4, _x5) {
108
+ return _getAccount.apply(this, arguments);
109
+ }
110
+ function _getAccount() {
111
+ _getAccount = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(options, server) {
112
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
113
+ while (1) switch (_context2.prev = _context2.next) {
114
+ case 0:
115
+ return _context2.abrupt("return", options.publicKey ? server.getAccount(options.publicKey) : new _stellarBase.Account(_types.NULL_ACCOUNT, "0"));
116
+ case 1:
117
+ case "end":
118
+ return _context2.stop();
119
+ }
120
+ }, _callee2);
121
+ }));
122
+ return _getAccount.apply(this, arguments);
123
+ }
@@ -0,0 +1,59 @@
1
+ import { HorizonApi } from "./horizon/horizon_api";
2
+ export declare class NetworkError extends Error {
3
+ response: {
4
+ data?: HorizonApi.ErrorResponseData;
5
+ status?: number;
6
+ statusText?: string;
7
+ url?: string;
8
+ };
9
+ __proto__: NetworkError;
10
+ constructor(message: string, response: any);
11
+ getResponse(): {
12
+ data?: HorizonApi.ErrorResponseData;
13
+ status?: number;
14
+ statusText?: string;
15
+ url?: string;
16
+ };
17
+ }
18
+ export declare class NotFoundError extends NetworkError {
19
+ constructor(message: string, response: any);
20
+ }
21
+ export declare class BadRequestError extends NetworkError {
22
+ constructor(message: string, response: any);
23
+ }
24
+ export declare class BadResponseError extends NetworkError {
25
+ constructor(message: string, response: any);
26
+ }
27
+ /**
28
+ * AccountRequiresMemoError is raised when a transaction is trying to submit an
29
+ * operation to an account which requires a memo. See
30
+ * [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md)
31
+ * for more information.
32
+ *
33
+ * This error contains two attributes to help you identify the account requiring
34
+ * the memo and the operation where the account is the destination
35
+ *
36
+ * ```
37
+ * console.log('The following account requires a memo ', err.accountId)
38
+ * console.log('The account is used in operation: ', err.operationIndex)
39
+ * ```
40
+ *
41
+ */
42
+ export declare class AccountRequiresMemoError extends Error {
43
+ __proto__: AccountRequiresMemoError;
44
+ /**
45
+ * accountId account which requires a memo.
46
+ */
47
+ accountId: string;
48
+ /**
49
+ * operationIndex operation where accountId is the destination.
50
+ */
51
+ operationIndex: number;
52
+ /**
53
+ * Create an AccountRequiresMemoError
54
+ * @param {message} message - error message
55
+ * @param {string} accountId - The account which requires a memo.
56
+ * @param {number} operationIndex - The index of the operation where `accountId` is the destination.
57
+ */
58
+ constructor(message: string, accountId: string, operationIndex: number);
59
+ }
package/lib/errors.js ADDED
@@ -0,0 +1,99 @@
1
+ "use strict";
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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.NotFoundError = exports.NetworkError = exports.BadResponseError = exports.BadRequestError = exports.AccountRequiresMemoError = void 0;
8
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
9
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
10
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
14
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
15
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
16
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
17
+ function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); }
18
+ function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
19
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
20
+ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } }
21
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
22
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
+ var NetworkError = exports.NetworkError = function (_Error) {
24
+ function NetworkError(message, response) {
25
+ var _this;
26
+ _classCallCheck(this, NetworkError);
27
+ var trueProto = (this instanceof NetworkError ? this.constructor : void 0).prototype;
28
+ _this = _callSuper(this, NetworkError, [message]);
29
+ _this.__proto__ = trueProto;
30
+ _this.constructor = NetworkError;
31
+ _this.response = response;
32
+ return _this;
33
+ }
34
+ _inherits(NetworkError, _Error);
35
+ return _createClass(NetworkError, [{
36
+ key: "getResponse",
37
+ value: function getResponse() {
38
+ return this.response;
39
+ }
40
+ }]);
41
+ }(_wrapNativeSuper(Error));
42
+ var NotFoundError = exports.NotFoundError = function (_NetworkError) {
43
+ function NotFoundError(message, response) {
44
+ var _this2;
45
+ _classCallCheck(this, NotFoundError);
46
+ var trueProto = (this instanceof NotFoundError ? this.constructor : void 0).prototype;
47
+ _this2 = _callSuper(this, NotFoundError, [message, response]);
48
+ _this2.__proto__ = trueProto;
49
+ _this2.constructor = NotFoundError;
50
+ _this2.name = "NotFoundError";
51
+ return _this2;
52
+ }
53
+ _inherits(NotFoundError, _NetworkError);
54
+ return _createClass(NotFoundError);
55
+ }(NetworkError);
56
+ var BadRequestError = exports.BadRequestError = function (_NetworkError2) {
57
+ function BadRequestError(message, response) {
58
+ var _this3;
59
+ _classCallCheck(this, BadRequestError);
60
+ var trueProto = (this instanceof BadRequestError ? this.constructor : void 0).prototype;
61
+ _this3 = _callSuper(this, BadRequestError, [message, response]);
62
+ _this3.__proto__ = trueProto;
63
+ _this3.constructor = BadRequestError;
64
+ _this3.name = "BadRequestError";
65
+ return _this3;
66
+ }
67
+ _inherits(BadRequestError, _NetworkError2);
68
+ return _createClass(BadRequestError);
69
+ }(NetworkError);
70
+ var BadResponseError = exports.BadResponseError = function (_NetworkError3) {
71
+ function BadResponseError(message, response) {
72
+ var _this4;
73
+ _classCallCheck(this, BadResponseError);
74
+ var trueProto = (this instanceof BadResponseError ? this.constructor : void 0).prototype;
75
+ _this4 = _callSuper(this, BadResponseError, [message, response]);
76
+ _this4.__proto__ = trueProto;
77
+ _this4.constructor = BadResponseError;
78
+ _this4.name = "BadResponseError";
79
+ return _this4;
80
+ }
81
+ _inherits(BadResponseError, _NetworkError3);
82
+ return _createClass(BadResponseError);
83
+ }(NetworkError);
84
+ var AccountRequiresMemoError = exports.AccountRequiresMemoError = function (_Error2) {
85
+ function AccountRequiresMemoError(message, accountId, operationIndex) {
86
+ var _this5;
87
+ _classCallCheck(this, AccountRequiresMemoError);
88
+ var trueProto = (this instanceof AccountRequiresMemoError ? this.constructor : void 0).prototype;
89
+ _this5 = _callSuper(this, AccountRequiresMemoError, [message]);
90
+ _this5.__proto__ = trueProto;
91
+ _this5.constructor = AccountRequiresMemoError;
92
+ _this5.name = "AccountRequiresMemoError";
93
+ _this5.accountId = accountId;
94
+ _this5.operationIndex = operationIndex;
95
+ return _this5;
96
+ }
97
+ _inherits(AccountRequiresMemoError, _Error2);
98
+ return _createClass(AccountRequiresMemoError);
99
+ }(_wrapNativeSuper(Error));
@@ -0,0 +1,11 @@
1
+ export declare namespace Api {
2
+ interface Record {
3
+ account_id: string;
4
+ memo_type?: string;
5
+ memo?: string;
6
+ }
7
+ interface Options {
8
+ allowHttp?: boolean;
9
+ timeout?: number;
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Api = void 0;
7
+ var Api;
@@ -0,0 +1,2 @@
1
+ export { FederationServer as Server, FEDERATION_RESPONSE_MAX_SIZE } from './server';
2
+ export * as Api from './api';
@@ -0,0 +1,24 @@
1
+ "use strict";
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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Api = void 0;
8
+ Object.defineProperty(exports, "FEDERATION_RESPONSE_MAX_SIZE", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _server.FEDERATION_RESPONSE_MAX_SIZE;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "Server", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _server.FederationServer;
18
+ }
19
+ });
20
+ var _server = require("./server");
21
+ var _Api = _interopRequireWildcard(require("./api"));
22
+ exports.Api = _Api;
23
+ 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); }
24
+ 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; }
@@ -0,0 +1,118 @@
1
+ import { Api } from "./api";
2
+ export declare const FEDERATION_RESPONSE_MAX_SIZE: number;
3
+ /**
4
+ * FederationServer handles a network connection to a
5
+ * [federation server](https://developers.stellar.org/docs/glossary/federation/)
6
+ * instance and exposes an interface for requests to that instance.
7
+ * @class
8
+ * @param {string} serverURL The federation server URL (ex. `https://acme.com/federation`).
9
+ * @param {string} domain Domain this server represents
10
+ * @param {object} [opts] options object
11
+ * @param {boolean} [opts.allowHttp] - Allow connecting to http servers, default: `false`. This must be set to false in production deployments! You can also use {@link Config} class to set this globally.
12
+ * @param {number} [opts.timeout] - Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue. You can also use {@link Config} class to set this globally.
13
+ * @returns {void}
14
+ */
15
+ export declare class FederationServer {
16
+ /**
17
+ * The federation server URL (ex. `https://acme.com/federation`).
18
+ *
19
+ * @memberof FederationServer
20
+ */
21
+ private readonly serverURL;
22
+ /**
23
+ * Domain this server represents.
24
+ *
25
+ * @type {string}
26
+ * @memberof FederationServer
27
+ */
28
+ private readonly domain;
29
+ /**
30
+ * Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue.
31
+ *
32
+ * @type {number}
33
+ * @memberof FederationServer
34
+ */
35
+ private readonly timeout;
36
+ /**
37
+ * A helper method for handling user inputs that contain `destination` value.
38
+ * It accepts two types of values:
39
+ *
40
+ * * For Stellar address (ex. `bob*stellar.org`) it splits Stellar address and then tries to find information about
41
+ * federation server in `stellar.toml` file for a given domain. It returns a `Promise` which resolves if federation
42
+ * server exists and user has been found and rejects in all other cases.
43
+ * * For Account ID (ex. `GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS`) it returns a `Promise` which
44
+ * resolves if Account ID is valid and rejects in all other cases. Please note that this method does not check
45
+ * if the account actually exists in a ledger.
46
+ *
47
+ * Example:
48
+ * ```js
49
+ * StellarSdk.FederationServer.resolve('bob*stellar.org')
50
+ * .then(federationRecord => {
51
+ * // {
52
+ * // account_id: 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS',
53
+ * // memo_type: 'id',
54
+ * // memo: 100
55
+ * // }
56
+ * });
57
+ * ```
58
+ *
59
+ * @see <a href="https://developers.stellar.org/docs/glossary/federation/" target="_blank">Federation doc</a>
60
+ * @see <a href="https://developers.stellar.org/docs/issuing-assets/publishing-asset-info/" target="_blank">Stellar.toml doc</a>
61
+ * @param {string} value Stellar Address (ex. `bob*stellar.org`)
62
+ * @param {object} [opts] Options object
63
+ * @param {boolean} [opts.allowHttp] - Allow connecting to http servers, default: `false`. This must be set to false in production deployments!
64
+ * @param {number} [opts.timeout] - Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue.
65
+ * @returns {Promise} `Promise` that resolves to a JSON object with this shape:
66
+ * * `account_id` - Account ID of the destination,
67
+ * * `memo_type` (optional) - Memo type that needs to be attached to a transaction,
68
+ * * `memo` (optional) - Memo value that needs to be attached to a transaction.
69
+ */
70
+ static resolve(value: string, opts?: Api.Options): Promise<Api.Record>;
71
+ /**
72
+ * Creates a `FederationServer` instance based on information from
73
+ * [stellar.toml](https://developers.stellar.org/docs/issuing-assets/publishing-asset-info/)
74
+ * file for a given domain.
75
+ *
76
+ * If `stellar.toml` file does not exist for a given domain or it does not
77
+ * contain information about a federation server Promise will reject.
78
+ * ```js
79
+ * StellarSdk.FederationServer.createForDomain('acme.com')
80
+ * .then(federationServer => {
81
+ * // federationServer.resolveAddress('bob').then(...)
82
+ * })
83
+ * .catch(error => {
84
+ * // stellar.toml does not exist or it does not contain information about federation server.
85
+ * });
86
+ * ```
87
+ * @see <a href="https://developers.stellar.org/docs/issuing-assets/publishing-asset-info/" target="_blank">Stellar.toml doc</a>
88
+ * @param {string} domain Domain to get federation server for
89
+ * @param {object} [opts] Options object
90
+ * @param {boolean} [opts.allowHttp] - Allow connecting to http servers, default: `false`. This must be set to false in production deployments!
91
+ * @param {number} [opts.timeout] - Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue.
92
+ * @returns {Promise} `Promise` that resolves to a FederationServer object
93
+ */
94
+ static createForDomain(domain: string, opts?: Api.Options): Promise<FederationServer>;
95
+ constructor(serverURL: string, domain: string, opts?: Api.Options);
96
+ /**
97
+ * Get the federation record if the user was found for a given Stellar address
98
+ * @see <a href="https://developers.stellar.org/docs/glossary/federation/" target="_blank">Federation doc</a>
99
+ * @param {string} address Stellar address (ex. `bob*stellar.org`). If `FederationServer` was instantiated with `domain` param only username (ex. `bob`) can be passed.
100
+ * @returns {Promise} Promise that resolves to the federation record
101
+ */
102
+ resolveAddress(address: string): Promise<Api.Record>;
103
+ /**
104
+ * Given an account ID, get their federation record if the user was found
105
+ * @see <a href="https://developers.stellar.org/docs/glossary/federation/" target="_blank">Federation doc</a>
106
+ * @param {string} accountId Account ID (ex. `GBYNR2QJXLBCBTRN44MRORCMI4YO7FZPFBCNOKTOBCAAFC7KC3LNPRYS`)
107
+ * @returns {Promise} A promise that resolves to the federation record
108
+ */
109
+ resolveAccountId(accountId: string): Promise<Api.Record>;
110
+ /**
111
+ * Given a transactionId, get the federation record if the sender of the transaction was found
112
+ * @see <a href="https://developers.stellar.org/docs/glossary/federation/" target="_blank">Federation doc</a>
113
+ * @param {string} transactionId Transaction ID (ex. `3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889`)
114
+ * @returns {Promise} A promise that resolves to the federation record
115
+ */
116
+ resolveTransactionId(transactionId: string): Promise<Api.Record>;
117
+ private _sendRequest;
118
+ }