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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/stellar-sdk-minimal.js +585 -253
  3. package/dist/stellar-sdk-minimal.min.js +1 -1
  4. package/dist/stellar-sdk-no-axios.js +602 -256
  5. package/dist/stellar-sdk-no-axios.min.js +1 -1
  6. package/dist/stellar-sdk-no-eventsource.js +585 -253
  7. package/dist/stellar-sdk-no-eventsource.min.js +1 -1
  8. package/dist/stellar-sdk.js +602 -256
  9. package/dist/stellar-sdk.min.js +1 -1
  10. package/lib/contract/assembled_transaction.d.ts +75 -3
  11. package/lib/contract/assembled_transaction.js +124 -35
  12. package/lib/contract/basic_node_signer.d.ts +3 -2
  13. package/lib/contract/basic_node_signer.js +16 -8
  14. package/lib/contract/client.d.ts +13 -1
  15. package/lib/contract/client.js +159 -48
  16. package/lib/contract/sent_transaction.d.ts +2 -3
  17. package/lib/contract/sent_transaction.js +4 -4
  18. package/lib/contract/types.d.ts +72 -8
  19. package/lib/contract/types.js +1 -0
  20. package/lib/horizon/call_builder.d.ts +1 -1
  21. package/lib/horizon/horizon_axios_client.js +1 -1
  22. package/lib/horizon/server_api.d.ts +1 -15
  23. package/lib/horizon/server_api.js +5 -0
  24. package/lib/horizon/types/assets.d.ts +0 -2
  25. package/lib/horizon/types/effects.d.ts +51 -51
  26. package/lib/horizon/types/trade.d.ts +3 -2
  27. package/lib/http-client/types.d.ts +1 -0
  28. package/lib/index.d.ts +0 -4
  29. package/lib/index.js +1 -4
  30. package/lib/minimal/contract/assembled_transaction.d.ts +75 -3
  31. package/lib/minimal/contract/assembled_transaction.js +124 -35
  32. package/lib/minimal/contract/basic_node_signer.d.ts +3 -2
  33. package/lib/minimal/contract/basic_node_signer.js +16 -8
  34. package/lib/minimal/contract/client.d.ts +13 -1
  35. package/lib/minimal/contract/client.js +159 -48
  36. package/lib/minimal/contract/sent_transaction.d.ts +2 -3
  37. package/lib/minimal/contract/sent_transaction.js +4 -4
  38. package/lib/minimal/contract/types.d.ts +72 -8
  39. package/lib/minimal/contract/types.js +1 -0
  40. package/lib/minimal/horizon/call_builder.d.ts +1 -1
  41. package/lib/minimal/horizon/horizon_axios_client.js +1 -1
  42. package/lib/minimal/horizon/server_api.d.ts +1 -15
  43. package/lib/minimal/horizon/server_api.js +5 -0
  44. package/lib/minimal/horizon/types/assets.d.ts +0 -2
  45. package/lib/minimal/horizon/types/effects.d.ts +51 -51
  46. package/lib/minimal/horizon/types/trade.d.ts +3 -2
  47. package/lib/minimal/http-client/types.d.ts +1 -0
  48. package/lib/minimal/index.d.ts +0 -4
  49. package/lib/minimal/index.js +1 -4
  50. package/lib/minimal/rpc/api.d.ts +12 -9
  51. package/lib/minimal/rpc/axios.js +1 -1
  52. package/lib/minimal/rpc/index.d.ts +1 -1
  53. package/lib/minimal/rpc/index.js +14 -0
  54. package/lib/minimal/rpc/parsers.d.ts +1 -1
  55. package/lib/minimal/rpc/parsers.js +3 -3
  56. package/lib/minimal/rpc/server.d.ts +41 -3
  57. package/lib/minimal/rpc/server.js +203 -149
  58. package/lib/minimal/stellartoml/index.d.ts +1 -0
  59. package/lib/minimal/stellartoml/index.js +2 -0
  60. package/lib/minimal/utils.d.ts +1 -0
  61. package/lib/minimal/utils.js +7 -0
  62. package/lib/no-axios/contract/assembled_transaction.d.ts +75 -3
  63. package/lib/no-axios/contract/assembled_transaction.js +124 -35
  64. package/lib/no-axios/contract/basic_node_signer.d.ts +3 -2
  65. package/lib/no-axios/contract/basic_node_signer.js +16 -8
  66. package/lib/no-axios/contract/client.d.ts +13 -1
  67. package/lib/no-axios/contract/client.js +159 -48
  68. package/lib/no-axios/contract/sent_transaction.d.ts +2 -3
  69. package/lib/no-axios/contract/sent_transaction.js +4 -4
  70. package/lib/no-axios/contract/types.d.ts +72 -8
  71. package/lib/no-axios/contract/types.js +1 -0
  72. package/lib/no-axios/horizon/call_builder.d.ts +1 -1
  73. package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
  74. package/lib/no-axios/horizon/server_api.d.ts +1 -15
  75. package/lib/no-axios/horizon/server_api.js +5 -0
  76. package/lib/no-axios/horizon/types/assets.d.ts +0 -2
  77. package/lib/no-axios/horizon/types/effects.d.ts +51 -51
  78. package/lib/no-axios/horizon/types/trade.d.ts +3 -2
  79. package/lib/no-axios/http-client/types.d.ts +1 -0
  80. package/lib/no-axios/index.d.ts +0 -4
  81. package/lib/no-axios/index.js +1 -4
  82. package/lib/no-axios/rpc/api.d.ts +12 -9
  83. package/lib/no-axios/rpc/axios.js +1 -1
  84. package/lib/no-axios/rpc/index.d.ts +1 -1
  85. package/lib/no-axios/rpc/index.js +14 -0
  86. package/lib/no-axios/rpc/parsers.d.ts +1 -1
  87. package/lib/no-axios/rpc/parsers.js +3 -3
  88. package/lib/no-axios/rpc/server.d.ts +41 -3
  89. package/lib/no-axios/rpc/server.js +203 -149
  90. package/lib/no-axios/stellartoml/index.d.ts +1 -0
  91. package/lib/no-axios/stellartoml/index.js +2 -0
  92. package/lib/no-axios/utils.d.ts +1 -0
  93. package/lib/no-axios/utils.js +7 -0
  94. package/lib/no-eventsource/contract/assembled_transaction.d.ts +75 -3
  95. package/lib/no-eventsource/contract/assembled_transaction.js +124 -35
  96. package/lib/no-eventsource/contract/basic_node_signer.d.ts +3 -2
  97. package/lib/no-eventsource/contract/basic_node_signer.js +16 -8
  98. package/lib/no-eventsource/contract/client.d.ts +13 -1
  99. package/lib/no-eventsource/contract/client.js +159 -48
  100. package/lib/no-eventsource/contract/sent_transaction.d.ts +2 -3
  101. package/lib/no-eventsource/contract/sent_transaction.js +4 -4
  102. package/lib/no-eventsource/contract/types.d.ts +72 -8
  103. package/lib/no-eventsource/contract/types.js +1 -0
  104. package/lib/no-eventsource/horizon/call_builder.d.ts +1 -1
  105. package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
  106. package/lib/no-eventsource/horizon/server_api.d.ts +1 -15
  107. package/lib/no-eventsource/horizon/server_api.js +5 -0
  108. package/lib/no-eventsource/horizon/types/assets.d.ts +0 -2
  109. package/lib/no-eventsource/horizon/types/effects.d.ts +51 -51
  110. package/lib/no-eventsource/horizon/types/trade.d.ts +3 -2
  111. package/lib/no-eventsource/http-client/types.d.ts +1 -0
  112. package/lib/no-eventsource/index.d.ts +0 -4
  113. package/lib/no-eventsource/index.js +1 -4
  114. package/lib/no-eventsource/rpc/api.d.ts +12 -9
  115. package/lib/no-eventsource/rpc/axios.js +1 -1
  116. package/lib/no-eventsource/rpc/index.d.ts +1 -1
  117. package/lib/no-eventsource/rpc/index.js +14 -0
  118. package/lib/no-eventsource/rpc/parsers.d.ts +1 -1
  119. package/lib/no-eventsource/rpc/parsers.js +3 -3
  120. package/lib/no-eventsource/rpc/server.d.ts +41 -3
  121. package/lib/no-eventsource/rpc/server.js +203 -149
  122. package/lib/no-eventsource/stellartoml/index.d.ts +1 -0
  123. package/lib/no-eventsource/stellartoml/index.js +2 -0
  124. package/lib/no-eventsource/utils.d.ts +1 -0
  125. package/lib/no-eventsource/utils.js +7 -0
  126. package/lib/rpc/api.d.ts +12 -9
  127. package/lib/rpc/axios.js +1 -1
  128. package/lib/rpc/index.d.ts +1 -1
  129. package/lib/rpc/index.js +14 -0
  130. package/lib/rpc/parsers.d.ts +1 -1
  131. package/lib/rpc/parsers.js +3 -3
  132. package/lib/rpc/server.d.ts +41 -3
  133. package/lib/rpc/server.js +203 -149
  134. package/lib/stellartoml/index.d.ts +1 -0
  135. package/lib/stellartoml/index.js +2 -0
  136. package/lib/utils.d.ts +1 -0
  137. package/lib/utils.js +7 -0
  138. package/package.json +16 -16
@@ -37,6 +37,7 @@ export declare namespace Api {
37
37
  interface StellarTomlResolveOptions {
38
38
  allowHttp?: boolean;
39
39
  timeout?: number;
40
+ allowedRedirects?: number;
40
41
  }
41
42
  type Url = string;
42
43
  type PublicKey = string;
@@ -27,6 +27,7 @@ var Resolver = exports.Resolver = function () {
27
27
  key: "resolve",
28
28
  value: (function () {
29
29
  var _resolve = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(domain) {
30
+ var _opts$allowedRedirect;
30
31
  var opts,
31
32
  allowHttp,
32
33
  timeout,
@@ -40,6 +41,7 @@ var Resolver = exports.Resolver = function () {
40
41
  timeout = typeof opts.timeout === "undefined" ? _config.Config.getTimeout() : opts.timeout;
41
42
  protocol = allowHttp ? "http" : "https";
42
43
  return _context.abrupt("return", _httpClient.httpClient.get("".concat(protocol, "://").concat(domain, "/.well-known/stellar.toml"), {
44
+ maxRedirects: (_opts$allowedRedirect = opts.allowedRedirects) !== null && _opts$allowedRedirect !== void 0 ? _opts$allowedRedirect : 0,
43
45
  maxContentLength: STELLAR_TOML_MAX_SIZE,
44
46
  cancelToken: timeout ? new CancelToken(function (cancel) {
45
47
  return setTimeout(function () {
@@ -16,4 +16,5 @@ export declare class Utils {
16
16
  * @static
17
17
  */
18
18
  static validateTimebounds(transaction: Transaction, gracePeriod?: number): boolean;
19
+ static sleep(ms: number): Promise<void>;
19
20
  }
@@ -27,5 +27,12 @@ var Utils = exports.Utils = function () {
27
27
  maxTime = _transaction$timeBoun.maxTime;
28
28
  return now >= Number.parseInt(minTime, 10) - gracePeriod && now <= Number.parseInt(maxTime, 10) + gracePeriod;
29
29
  }
30
+ }, {
31
+ key: "sleep",
32
+ value: function sleep(ms) {
33
+ return new Promise(function (resolve) {
34
+ return setTimeout(resolve, ms);
35
+ });
36
+ }
30
37
  }]);
31
38
  }();
package/lib/rpc/api.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import { Contract, SorobanDataBuilder, xdr } from '@stellar/stellar-base';
2
2
  export declare namespace Api {
3
- export interface Cost {
4
- cpuInsns: string;
5
- memBytes: string;
6
- }
7
3
  export interface GetHealthResponse {
8
4
  status: 'healthy';
9
5
  }
@@ -56,6 +52,7 @@ export declare namespace Api {
56
52
  export type GetTransactionResponse = GetSuccessfulTransactionResponse | GetFailedTransactionResponse | GetMissingTransactionResponse;
57
53
  interface GetAnyTransactionResponse {
58
54
  status: GetTransactionStatus;
55
+ txHash: string;
59
56
  latestLedger: number;
60
57
  latestLedgerCloseTime: number;
61
58
  oldestLedger: number;
@@ -93,13 +90,14 @@ export declare namespace Api {
93
90
  latestLedgerCloseTime: number;
94
91
  oldestLedger: number;
95
92
  oldestLedgerCloseTime: number;
93
+ txHash: string;
96
94
  applicationOrder?: number;
97
95
  feeBump?: boolean;
96
+ ledger?: number;
97
+ createdAt?: number;
98
98
  envelopeXdr?: string;
99
99
  resultXdr?: string;
100
100
  resultMetaXdr?: string;
101
- ledger?: number;
102
- createdAt?: number;
103
101
  diagnosticEventsXdr?: string[];
104
102
  }
105
103
  export interface GetTransactionsRequest {
@@ -113,6 +111,7 @@ export declare namespace Api {
113
111
  createdAt: number;
114
112
  applicationOrder: number;
115
113
  feeBump: boolean;
114
+ txHash: string;
116
115
  envelopeXdr?: string;
117
116
  resultXdr?: string;
118
117
  resultMetaXdr?: string;
@@ -124,6 +123,7 @@ export declare namespace Api {
124
123
  createdAt: number;
125
124
  applicationOrder: number;
126
125
  feeBump: boolean;
126
+ txHash: string;
127
127
  envelopeXdr: xdr.TransactionEnvelope;
128
128
  resultXdr: xdr.TransactionResult;
129
129
  resultMetaXdr: xdr.TransactionMeta;
@@ -170,6 +170,7 @@ export declare namespace Api {
170
170
  type: EventType;
171
171
  ledger: number;
172
172
  ledgerClosedAt: string;
173
+ cursor: string;
173
174
  pagingToken: string;
174
175
  inSuccessfulContractCall: boolean;
175
176
  txHash: string;
@@ -255,7 +256,6 @@ export declare namespace Api {
255
256
  export interface SimulateTransactionSuccessResponse extends BaseSimulateTransactionResponse {
256
257
  transactionData: SorobanDataBuilder;
257
258
  minResourceFee: string;
258
- cost: Cost;
259
259
  /** present only for invocation simulation */
260
260
  result?: SimulateHostFunctionResult;
261
261
  /** State Difference information */
@@ -304,7 +304,6 @@ export declare namespace Api {
304
304
  * invokeHostFunctionOperation is supported per transaction.
305
305
  * */
306
306
  results?: RawSimulateHostFunctionResult[];
307
- cost?: Cost;
308
307
  /** Present if succeeded but has expired ledger entries */
309
308
  restorePreamble?: {
310
309
  minResourceFee: string;
@@ -315,8 +314,12 @@ export declare namespace Api {
315
314
  }
316
315
  export interface GetVersionInfoResponse {
317
316
  version: string;
317
+ commitHash: string;
318
+ buildTimestamp: string;
319
+ captiveCoreVersion: string;
320
+ protocolVersion: number;
318
321
  commit_hash: string;
319
- build_time_stamp: string;
322
+ build_timestamp: string;
320
323
  captive_core_version: string;
321
324
  protocol_version: number;
322
325
  }
package/lib/rpc/axios.js CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.default = exports.AxiosClient = void 0;
7
7
  var _httpClient = require("../http-client");
8
- var version = exports.version = "13.0.0-beta.1";
8
+ var version = exports.version = "13.0.0-rc.2";
9
9
  var AxiosClient = exports.AxiosClient = (0, _httpClient.create)({
10
10
  headers: {
11
11
  'X-Client-Name': 'js-soroban-client',
@@ -1,6 +1,6 @@
1
1
  /** @module rpc */
2
2
  export * from "./api";
3
- export { RpcServer as Server, Durability } from "./server";
3
+ export { RpcServer as Server, BasicSleepStrategy, LinearSleepStrategy, Durability } from "./server";
4
4
  export { default as AxiosClient } from "./axios";
5
5
  export { parseRawSimulation, parseRawEvents } from "./parsers";
6
6
  export * from "./transaction";
package/lib/rpc/index.js CHANGED
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  var _exportNames = {
7
7
  Server: true,
8
+ BasicSleepStrategy: true,
9
+ LinearSleepStrategy: true,
8
10
  Durability: true,
9
11
  AxiosClient: true,
10
12
  parseRawSimulation: true,
@@ -16,12 +18,24 @@ Object.defineProperty(exports, "AxiosClient", {
16
18
  return _axios.default;
17
19
  }
18
20
  });
21
+ Object.defineProperty(exports, "BasicSleepStrategy", {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _server.BasicSleepStrategy;
25
+ }
26
+ });
19
27
  Object.defineProperty(exports, "Durability", {
20
28
  enumerable: true,
21
29
  get: function get() {
22
30
  return _server.Durability;
23
31
  }
24
32
  });
33
+ Object.defineProperty(exports, "LinearSleepStrategy", {
34
+ enumerable: true,
35
+ get: function get() {
36
+ return _server.LinearSleepStrategy;
37
+ }
38
+ });
25
39
  Object.defineProperty(exports, "Server", {
26
40
  enumerable: true,
27
41
  get: function get() {
@@ -8,7 +8,7 @@ import { Api } from './api';
8
8
  * @returns {Api.SendTransactionResponse} transaction response parsed from the Soroban RPC server's response
9
9
  */
10
10
  export declare function parseRawSendTransaction(raw: Api.RawSendTransactionResponse): Api.SendTransactionResponse;
11
- export declare function parseTransactionInfo(raw: Api.RawTransactionInfo | Api.RawGetTransactionResponse): Omit<Api.TransactionInfo, 'status'>;
11
+ export declare function parseTransactionInfo(raw: Api.RawTransactionInfo | Api.RawGetTransactionResponse): Omit<Api.TransactionInfo, 'status' | 'txHash'>;
12
12
  export declare function parseRawTransactions(r: Api.RawTransactionInfo): Api.TransactionInfo;
13
13
  /**
14
14
  * Parse and return the retrieved events, if any, from a raw response from a Soroban RPC server.
@@ -57,7 +57,8 @@ function parseTransactionInfo(raw) {
57
57
  }
58
58
  function parseRawTransactions(r) {
59
59
  return _objectSpread({
60
- status: r.status
60
+ status: r.status,
61
+ txHash: r.txHash
61
62
  }, parseTransactionInfo(r));
62
63
  }
63
64
  function parseRawEvents(raw) {
@@ -100,8 +101,7 @@ function parseSuccessful(sim, partial) {
100
101
  var _sim$results$length, _sim$results, _sim$stateChanges$len, _sim$stateChanges, _sim$stateChanges2;
101
102
  var success = _objectSpread(_objectSpread(_objectSpread({}, partial), {}, {
102
103
  transactionData: new _stellarBase.SorobanDataBuilder(sim.transactionData),
103
- minResourceFee: sim.minResourceFee,
104
- cost: sim.cost
104
+ minResourceFee: sim.minResourceFee
105
105
  }, ((_sim$results$length = (_sim$results = sim.results) === null || _sim$results === void 0 ? void 0 : _sim$results.length) !== null && _sim$results$length !== void 0 ? _sim$results$length : 0 > 0) && {
106
106
  result: sim.results.map(function (row) {
107
107
  var _row$auth;
@@ -48,6 +48,10 @@ export declare namespace RpcServer {
48
48
  cursor?: string;
49
49
  limit?: number;
50
50
  }
51
+ interface PollingOptions {
52
+ attempts?: number;
53
+ sleepStrategy?: SleepStrategy;
54
+ }
51
55
  interface ResourceLeeway {
52
56
  cpuInstructions: number;
53
57
  }
@@ -57,6 +61,13 @@ export declare namespace RpcServer {
57
61
  headers?: Record<string, string>;
58
62
  }
59
63
  }
64
+ export declare const BasicSleepStrategy: SleepStrategy;
65
+ export declare const LinearSleepStrategy: SleepStrategy;
66
+ /**
67
+ * A function that returns the number of *milliseconds* to sleep
68
+ * on a given `iter`ation.
69
+ */
70
+ export type SleepStrategy = (iter: number) => number;
60
71
  /**
61
72
  * Handles the network connection to a Soroban RPC instance, exposing an
62
73
  * interface for requests to that instance.
@@ -220,6 +231,32 @@ export declare class RpcServer {
220
231
  */
221
232
  getLedgerEntries(...keys: xdr.LedgerKey[]): Promise<Api.GetLedgerEntriesResponse>;
222
233
  _getLedgerEntries(...keys: xdr.LedgerKey[]): Promise<Api.RawGetLedgerEntriesResponse>;
234
+ /**
235
+ * Poll for a particular transaction with certain parameters.
236
+ *
237
+ * After submitting a transaction, clients can use this to poll for
238
+ * transaction completion and return a definitive state of success or failure.
239
+ *
240
+ * @param {string} hash the transaction you're polling for
241
+ * @param {number} [opts.attempts] (optional) the number of attempts to make
242
+ * before returning the last-seen status. By default or on invalid inputs,
243
+ * try 5 times.
244
+ * @param {SleepStrategy} [opts.sleepStrategy] (optional) the amount of time
245
+ * to wait for between each attempt. By default, sleep for 1 second between
246
+ * each attempt.
247
+ *
248
+ * @return {Promise<Api.GetTransactionsResponse>} the response after a "found"
249
+ * response (which may be success or failure) or the last response obtained
250
+ * after polling the maximum number of specified attempts.
251
+ *
252
+ * @example
253
+ * const h = "c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a";
254
+ * const txStatus = await server.pollTransaction(h, {
255
+ * attempts: 100, // I'm a maniac
256
+ * sleepStrategy: rpc.LinearSleepStrategy
257
+ * }); // this will take 5,050 seconds to complete
258
+ */
259
+ pollTransaction(hash: string, opts?: RpcServer.PollingOptions): Promise<Api.GetTransactionResponse>;
223
260
  /**
224
261
  * Fetch the details of a submitted transaction.
225
262
  *
@@ -227,10 +264,11 @@ export declare class RpcServer {
227
264
  * transaction has completed.
228
265
  *
229
266
  * @param {string} hash Hex-encoded hash of the transaction to check
230
- * @returns {Promise<Api.GetTransactionResponse>} The status,
231
- * result, and other details about the transaction
267
+ * @returns {Promise<Api.GetTransactionResponse>} The status, result, and
268
+ * other details about the transaction
232
269
  *
233
- * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction | getTransaction docs}
270
+ * @see
271
+ * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction | getTransaction docs}
234
272
  *
235
273
  * @example
236
274
  * const transactionHash = "c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a";