@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
@@ -359,6 +359,56 @@ export declare class AssembledTransaction<T> {
359
359
  prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
360
360
  stackTraceLimit: number;
361
361
  };
362
+ SimulationFailed: {
363
+ new (message?: string): {
364
+ name: string;
365
+ message: string;
366
+ stack?: string;
367
+ };
368
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
369
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
370
+ stackTraceLimit: number;
371
+ };
372
+ InternalWalletError: {
373
+ new (message?: string): {
374
+ name: string;
375
+ message: string;
376
+ stack?: string;
377
+ };
378
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
379
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
380
+ stackTraceLimit: number;
381
+ };
382
+ ExternalServiceError: {
383
+ new (message?: string): {
384
+ name: string;
385
+ message: string;
386
+ stack?: string;
387
+ };
388
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
389
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
390
+ stackTraceLimit: number;
391
+ };
392
+ InvalidClientRequest: {
393
+ new (message?: string): {
394
+ name: string;
395
+ message: string;
396
+ stack?: string;
397
+ };
398
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
399
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
400
+ stackTraceLimit: number;
401
+ };
402
+ UserRejected: {
403
+ new (message?: string): {
404
+ name: string;
405
+ message: string;
406
+ stack?: string;
407
+ };
408
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
409
+ prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
410
+ stackTraceLimit: number;
411
+ };
362
412
  };
363
413
  /**
364
414
  * Serialize the AssembledTransaction to a JSON string. This is useful for
@@ -383,10 +433,11 @@ export declare class AssembledTransaction<T> {
383
433
  * Deserialize the AssembledTransaction from a base64-encoded XDR string.
384
434
  */
385
435
  static fromXDR<T>(options: Omit<AssembledTransactionOptions<T>, "args" | "method" | "parseResultXdr">, encodedXDR: string, spec: Spec): AssembledTransaction<T>;
436
+ private handleWalletError;
386
437
  private constructor();
387
438
  /**
388
- * Construct a new AssembledTransaction. This is the only way to create a new
389
- * AssembledTransaction; the main constructor is private.
439
+ * Construct a new AssembledTransaction. This is the main way to create a new
440
+ * AssembledTransaction; the constructor is private.
390
441
  *
391
442
  * This is an asynchronous constructor for two reasons:
392
443
  *
@@ -397,6 +448,9 @@ export declare class AssembledTransaction<T> {
397
448
  * If you don't want to simulate the transaction, you can set `simulate` to
398
449
  * `false` in the options.
399
450
  *
451
+ * If you need to create an operation other than `invokeHostFunction`, you
452
+ * can use {@link AssembledTransaction.buildWithOp} instead.
453
+ *
400
454
  * @example
401
455
  * const tx = await AssembledTransaction.build({
402
456
  * ...,
@@ -404,6 +458,24 @@ export declare class AssembledTransaction<T> {
404
458
  * })
405
459
  */
406
460
  static build<T>(options: AssembledTransactionOptions<T>): Promise<AssembledTransaction<T>>;
461
+ /**
462
+ * Construct a new AssembledTransaction, specifying an Operation other than
463
+ * `invokeHostFunction` (the default used by {@link AssembledTransaction.build}).
464
+ *
465
+ * Note: `AssembledTransaction` currently assumes these operations can be
466
+ * simulated. This is not true for classic operations; only for those used by
467
+ * Soroban Smart Contracts like `invokeHostFunction` and `createCustomContract`.
468
+ *
469
+ * @example
470
+ * const tx = await AssembledTransaction.buildWithOp(
471
+ * Operation.createCustomContract({ ... });
472
+ * {
473
+ * ...,
474
+ * simulate: false,
475
+ * }
476
+ * )
477
+ */
478
+ static buildWithOp<T>(operation: xdr.Operation, options: AssembledTransactionOptions<T>): Promise<AssembledTransaction<T>>;
407
479
  private static buildFootprintRestoreTransaction;
408
480
  simulate: ({ restore }?: {
409
481
  restore?: boolean;
@@ -511,7 +583,7 @@ export declare class AssembledTransaction<T> {
511
583
  * If you have a pro use-case and need to override the default `authorizeEntry` function, rather than using the one in @stellar/stellar-base, you can do that! Your function needs to take at least the first argument, `entry: xdr.SorobanAuthorizationEntry`, and return a `Promise<xdr.SorobanAuthorizationEntry>`.
512
584
  *
513
585
  * Note that you if you pass this, then `signAuthEntry` will be ignored.
514
- */
586
+ */
515
587
  authorizeEntry?: typeof stellarBaseAuthorizeEntry;
516
588
  }) => Promise<void>;
517
589
  /**
@@ -132,7 +132,10 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
132
132
  signTransaction,
133
133
  sigsNeeded,
134
134
  timeoutInSeconds,
135
+ signOpts,
136
+ _yield$signTransactio,
135
137
  signature,
138
+ error,
136
139
  _args2 = arguments;
137
140
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
138
141
  while (1) switch (_context2.prev = _context2.next) {
@@ -171,14 +174,21 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
171
174
  timebounds: undefined,
172
175
  sorobanData: _this.simulationData.transactionData
173
176
  }).setTimeout(timeoutInSeconds).build();
174
- _context2.next = 14;
175
- return signTransaction(_this.built.toXDR(), {
177
+ signOpts = {
176
178
  networkPassphrase: _this.options.networkPassphrase
177
- });
178
- case 14:
179
- signature = _context2.sent;
179
+ };
180
+ if (_this.options.address) signOpts.address = _this.options.address;
181
+ if (_this.options.submit !== undefined) signOpts.submit = _this.options.submit;
182
+ if (_this.options.submitUrl) signOpts.submitUrl = _this.options.submitUrl;
183
+ _context2.next = 18;
184
+ return signTransaction(_this.built.toXDR(), signOpts);
185
+ case 18:
186
+ _yield$signTransactio = _context2.sent;
187
+ signature = _yield$signTransactio.signedTxXdr;
188
+ error = _yield$signTransactio.error;
189
+ _this.handleWalletError(error);
180
190
  _this.signed = _stellarBase.TransactionBuilder.fromXDR(signature, _this.options.networkPassphrase);
181
- case 16:
191
+ case 23:
182
192
  case "end":
183
193
  return _context2.stop();
184
194
  }
@@ -190,27 +200,37 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
190
200
  force,
191
201
  _ref6$signTransaction,
192
202
  signTransaction,
203
+ originalSubmit,
193
204
  _args3 = arguments;
194
205
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
195
206
  while (1) switch (_context3.prev = _context3.next) {
196
207
  case 0:
197
208
  _ref6 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref6$force = _ref6.force, force = _ref6$force === void 0 ? false : _ref6$force, _ref6$signTransaction = _ref6.signTransaction, signTransaction = _ref6$signTransaction === void 0 ? _this.options.signTransaction : _ref6$signTransaction;
198
209
  if (_this.signed) {
199
- _context3.next = 4;
210
+ _context3.next = 10;
200
211
  break;
201
212
  }
202
- _context3.next = 4;
213
+ originalSubmit = _this.options.submit;
214
+ if (_this.options.submit) {
215
+ _this.options.submit = false;
216
+ }
217
+ _context3.prev = 4;
218
+ _context3.next = 7;
203
219
  return _this.sign({
204
220
  force: force,
205
221
  signTransaction: signTransaction
206
222
  });
207
- case 4:
223
+ case 7:
224
+ _context3.prev = 7;
225
+ _this.options.submit = originalSubmit;
226
+ return _context3.finish(7);
227
+ case 10:
208
228
  return _context3.abrupt("return", _this.send());
209
- case 5:
229
+ case 11:
210
230
  case "end":
211
231
  return _context3.stop();
212
232
  }
213
- }, _callee3);
233
+ }, _callee3, null, [[4,, 7, 10]]);
214
234
  })));
215
235
  _defineProperty(this, "needsNonInvokerSigningBy", function () {
216
236
  var _rawInvokeHostFunctio;
@@ -325,18 +345,21 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
325
345
  _context6.t1 = entry;
326
346
  _context6.t2 = function () {
327
347
  var _ref11 = _asyncToGenerator(_regeneratorRuntime().mark(function _callee5(preimage) {
348
+ var _yield$sign, signedAuthEntry, error;
328
349
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
329
350
  while (1) switch (_context5.prev = _context5.next) {
330
351
  case 0:
331
- _context5.t0 = Buffer;
332
- _context5.next = 3;
352
+ _context5.next = 2;
333
353
  return sign(preimage.toXDR("base64"), {
334
- accountToSign: address
354
+ address: address
335
355
  });
336
- case 3:
337
- _context5.t1 = _context5.sent;
338
- return _context5.abrupt("return", _context5.t0.from.call(_context5.t0, _context5.t1, "base64"));
339
- case 5:
356
+ case 2:
357
+ _yield$sign = _context5.sent;
358
+ signedAuthEntry = _yield$sign.signedAuthEntry;
359
+ error = _yield$sign.error;
360
+ _this.handleWalletError(error);
361
+ return _context5.abrupt("return", Buffer.from(signedAuthEntry, "base64"));
362
+ case 7:
340
363
  case "end":
341
364
  return _context5.stop();
342
365
  }
@@ -424,6 +447,26 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
424
447
  if (!this.built) throw new Error("Transaction has not yet been simulated; " + "call `AssembledTransaction.simulate` first.");
425
448
  return (_this$built2 = this.built) === null || _this$built2 === void 0 ? void 0 : _this$built2.toEnvelope().toXDR('base64');
426
449
  }
450
+ }, {
451
+ key: "handleWalletError",
452
+ value: function handleWalletError(error) {
453
+ if (!error) return;
454
+ var message = error.message,
455
+ code = error.code;
456
+ var fullMessage = "".concat(message).concat(error.ext ? " (".concat(error.ext.join(', '), ")") : '');
457
+ switch (code) {
458
+ case -1:
459
+ throw new AssembledTransaction.Errors.InternalWalletError(fullMessage);
460
+ case -2:
461
+ throw new AssembledTransaction.Errors.ExternalServiceError(fullMessage);
462
+ case -3:
463
+ throw new AssembledTransaction.Errors.InvalidClientRequest(fullMessage);
464
+ case -4:
465
+ throw new AssembledTransaction.Errors.UserRejected(fullMessage);
466
+ default:
467
+ throw new Error("Unhandled error: ".concat(fullMessage));
468
+ }
469
+ }
427
470
  }, {
428
471
  key: "simulationData",
429
472
  get: function get() {
@@ -439,7 +482,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
439
482
  throw new AssembledTransaction.Errors.NotYetSimulated("Transaction has not yet been simulated");
440
483
  }
441
484
  if (_api.Api.isSimulationError(simulation)) {
442
- throw new Error("Transaction simulation failed: \"".concat(simulation.error, "\""));
485
+ throw new AssembledTransaction.Errors.SimulationFailed("Transaction simulation failed: \"".concat(simulation.error, "\""));
443
486
  }
444
487
  if (_api.Api.isSimulationRestore(simulation)) {
445
488
  throw new AssembledTransaction.Errors.ExpiredState("You need to restore some contract state before you can invoke this method.\n" + 'You can set `restore` to true in the method options in order to ' + 'automatically restore the contract state when needed.');
@@ -495,7 +538,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
495
538
  throw new Error("The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.");
496
539
  case 2:
497
540
  _context8.next = 4;
498
- return _sent_transaction.SentTransaction.init(undefined, this);
541
+ return _sent_transaction.SentTransaction.init(this);
499
542
  case 4:
500
543
  sent = _context8.sent;
501
544
  return _context8.abrupt("return", sent);
@@ -615,41 +658,47 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
615
658
  }
616
659
  }, {
617
660
  key: "build",
661
+ value: function build(options) {
662
+ var _options$args;
663
+ var contract = new _stellarBase.Contract(options.contractId);
664
+ return AssembledTransaction.buildWithOp(contract.call.apply(contract, [options.method].concat(_toConsumableArray((_options$args = options.args) !== null && _options$args !== void 0 ? _options$args : []))), options);
665
+ }
666
+ }, {
667
+ key: "buildWithOp",
618
668
  value: (function () {
619
- var _build = _asyncToGenerator(_regeneratorRuntime().mark(function _callee9(options) {
620
- var _options$fee, _options$args, _options$timeoutInSec;
621
- var tx, contract, account;
669
+ var _buildWithOp = _asyncToGenerator(_regeneratorRuntime().mark(function _callee9(operation, options) {
670
+ var _options$fee, _options$timeoutInSec;
671
+ var tx, account;
622
672
  return _regeneratorRuntime().wrap(function _callee9$(_context10) {
623
673
  while (1) switch (_context10.prev = _context10.next) {
624
674
  case 0:
625
675
  tx = new AssembledTransaction(options);
626
- contract = new _stellarBase.Contract(options.contractId);
627
- _context10.next = 4;
676
+ _context10.next = 3;
628
677
  return (0, _utils.getAccount)(options, tx.server);
629
- case 4:
678
+ case 3:
630
679
  account = _context10.sent;
631
680
  tx.raw = new _stellarBase.TransactionBuilder(account, {
632
681
  fee: (_options$fee = options.fee) !== null && _options$fee !== void 0 ? _options$fee : _stellarBase.BASE_FEE,
633
682
  networkPassphrase: options.networkPassphrase
634
- }).addOperation(contract.call.apply(contract, [options.method].concat(_toConsumableArray((_options$args = options.args) !== null && _options$args !== void 0 ? _options$args : [])))).setTimeout((_options$timeoutInSec = options.timeoutInSeconds) !== null && _options$timeoutInSec !== void 0 ? _options$timeoutInSec : _types.DEFAULT_TIMEOUT);
683
+ }).setTimeout((_options$timeoutInSec = options.timeoutInSeconds) !== null && _options$timeoutInSec !== void 0 ? _options$timeoutInSec : _types.DEFAULT_TIMEOUT).addOperation(operation);
635
684
  if (!options.simulate) {
636
- _context10.next = 9;
685
+ _context10.next = 8;
637
686
  break;
638
687
  }
639
- _context10.next = 9;
688
+ _context10.next = 8;
640
689
  return tx.simulate();
641
- case 9:
690
+ case 8:
642
691
  return _context10.abrupt("return", tx);
643
- case 10:
692
+ case 9:
644
693
  case "end":
645
694
  return _context10.stop();
646
695
  }
647
696
  }, _callee9);
648
697
  }));
649
- function build(_x4) {
650
- return _build.apply(this, arguments);
698
+ function buildWithOp(_x4, _x5) {
699
+ return _buildWithOp.apply(this, arguments);
651
700
  }
652
- return build;
701
+ return buildWithOp;
653
702
  }())
654
703
  }, {
655
704
  key: "buildFootprintRestoreTransaction",
@@ -677,7 +726,7 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
677
726
  }
678
727
  }, _callee10);
679
728
  }));
680
- function buildFootprintRestoreTransaction(_x5, _x6, _x7, _x8) {
729
+ function buildFootprintRestoreTransaction(_x6, _x7, _x8, _x9) {
681
730
  return _buildFootprintRestoreTransaction.apply(this, arguments);
682
731
  }
683
732
  return buildFootprintRestoreTransaction;
@@ -748,5 +797,45 @@ _defineProperty(AssembledTransaction, "Errors", {
748
797
  }
749
798
  _inherits(FakeAccountError, _Error8);
750
799
  return _createClass(FakeAccountError);
800
+ }(_wrapNativeSuper(Error)),
801
+ SimulationFailed: function (_Error9) {
802
+ function SimulationFailedError() {
803
+ _classCallCheck(this, SimulationFailedError);
804
+ return _callSuper(this, SimulationFailedError, arguments);
805
+ }
806
+ _inherits(SimulationFailedError, _Error9);
807
+ return _createClass(SimulationFailedError);
808
+ }(_wrapNativeSuper(Error)),
809
+ InternalWalletError: function (_Error10) {
810
+ function InternalWalletError() {
811
+ _classCallCheck(this, InternalWalletError);
812
+ return _callSuper(this, InternalWalletError, arguments);
813
+ }
814
+ _inherits(InternalWalletError, _Error10);
815
+ return _createClass(InternalWalletError);
816
+ }(_wrapNativeSuper(Error)),
817
+ ExternalServiceError: function (_Error11) {
818
+ function ExternalServiceError() {
819
+ _classCallCheck(this, ExternalServiceError);
820
+ return _callSuper(this, ExternalServiceError, arguments);
821
+ }
822
+ _inherits(ExternalServiceError, _Error11);
823
+ return _createClass(ExternalServiceError);
824
+ }(_wrapNativeSuper(Error)),
825
+ InvalidClientRequest: function (_Error12) {
826
+ function InvalidClientRequestError() {
827
+ _classCallCheck(this, InvalidClientRequestError);
828
+ return _callSuper(this, InvalidClientRequestError, arguments);
829
+ }
830
+ _inherits(InvalidClientRequestError, _Error12);
831
+ return _createClass(InvalidClientRequestError);
832
+ }(_wrapNativeSuper(Error)),
833
+ UserRejected: function (_Error13) {
834
+ function UserRejectedError() {
835
+ _classCallCheck(this, UserRejectedError);
836
+ return _callSuper(this, UserRejectedError, arguments);
837
+ }
838
+ _inherits(UserRejectedError, _Error13);
839
+ return _createClass(UserRejectedError);
751
840
  }(_wrapNativeSuper(Error))
752
841
  });
@@ -1,4 +1,5 @@
1
1
  import { Keypair } from "@stellar/stellar-base";
2
+ import { SignAuthEntry, SignTransaction } from "./types";
2
3
  /**
3
4
  * For use with {@link Client} and {@link module:contract.AssembledTransaction}.
4
5
  * Implements `signTransaction` and `signAuthEntry` with signatures expected by
@@ -12,6 +13,6 @@ import { Keypair } from "@stellar/stellar-base";
12
13
  * @param {string} networkPassphrase passphrase of network to sign for
13
14
  */
14
15
  export declare const basicNodeSigner: (keypair: Keypair, networkPassphrase: string) => {
15
- signTransaction: (tx: string) => Promise<string>;
16
- signAuthEntry: (entryXdr: string) => Promise<string>;
16
+ signTransaction: SignTransaction;
17
+ signAuthEntry: SignAuthEntry;
17
18
  };
@@ -12,38 +12,46 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
12
12
  var basicNodeSigner = exports.basicNodeSigner = function basicNodeSigner(keypair, networkPassphrase) {
13
13
  return {
14
14
  signTransaction: function () {
15
- var _signTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(tx) {
15
+ var _signTransaction = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(xdr, opts) {
16
16
  var t;
17
17
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
- t = _stellarBase.TransactionBuilder.fromXDR(tx, networkPassphrase);
20
+ t = _stellarBase.TransactionBuilder.fromXDR(xdr, (opts === null || opts === void 0 ? void 0 : opts.networkPassphrase) || networkPassphrase);
21
21
  t.sign(keypair);
22
- return _context.abrupt("return", t.toXDR());
22
+ return _context.abrupt("return", {
23
+ signedTxXdr: t.toXDR(),
24
+ signerAddress: keypair.publicKey()
25
+ });
23
26
  case 3:
24
27
  case "end":
25
28
  return _context.stop();
26
29
  }
27
30
  }, _callee);
28
31
  }));
29
- function signTransaction(_x) {
32
+ function signTransaction(_x, _x2) {
30
33
  return _signTransaction.apply(this, arguments);
31
34
  }
32
35
  return signTransaction;
33
36
  }(),
34
37
  signAuthEntry: function () {
35
- var _signAuthEntry = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(entryXdr) {
38
+ var _signAuthEntry = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(authEntry) {
39
+ var signedAuthEntry;
36
40
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
37
41
  while (1) switch (_context2.prev = _context2.next) {
38
42
  case 0:
39
- return _context2.abrupt("return", keypair.sign((0, _stellarBase.hash)(Buffer.from(entryXdr, "base64"))).toString("base64"));
40
- case 1:
43
+ signedAuthEntry = keypair.sign((0, _stellarBase.hash)(Buffer.from(authEntry, "base64"))).toString("base64");
44
+ return _context2.abrupt("return", {
45
+ signedAuthEntry: signedAuthEntry,
46
+ signerAddress: keypair.publicKey()
47
+ });
48
+ case 2:
41
49
  case "end":
42
50
  return _context2.stop();
43
51
  }
44
52
  }, _callee2);
45
53
  }));
46
- function signAuthEntry(_x2) {
54
+ function signAuthEntry(_x3) {
47
55
  return _signAuthEntry.apply(this, arguments);
48
56
  }
49
57
  return signAuthEntry;
@@ -1,6 +1,6 @@
1
1
  import { Spec } from "./spec";
2
2
  import { AssembledTransaction } from "./assembled_transaction";
3
- import type { ClientOptions } from "./types";
3
+ import type { ClientOptions, MethodOptions } from "./types";
4
4
  /**
5
5
  * Generate a class from the contract spec that where each contract method
6
6
  * gets included with an identical name.
@@ -18,6 +18,18 @@ import type { ClientOptions } from "./types";
18
18
  export declare class Client {
19
19
  readonly spec: Spec;
20
20
  readonly options: ClientOptions;
21
+ static deploy<T = Client>(
22
+ /** Constructor/Initialization Args for the contract's `__constructor` method */
23
+ args: Record<string, any> | null,
24
+ /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */
25
+ options: MethodOptions & Omit<ClientOptions, "contractId"> & {
26
+ /** The hash of the Wasm blob, which must already be installed on-chain. */
27
+ wasmHash: Buffer | string;
28
+ /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
29
+ salt?: Buffer | Uint8Array;
30
+ /** The format used to decode `wasmHash`, if it's provided as a string. */
31
+ format?: "hex" | "base64";
32
+ }): Promise<AssembledTransaction<T>>;
21
33
  constructor(spec: Spec, options: ClientOptions);
22
34
  /**
23
35
  * Generates a Client instance from the provided ClientOptions and the contract's wasm hash.