@stellar/typescript-wallet-sdk 1.1.3 → 1.2.1
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.
- package/examples/sep24/README.md +22 -0
- package/examples/sep24/sep24.ts +199 -0
- package/lib/bundle.js +369 -36
- package/lib/bundle.js.map +1 -1
- package/lib/bundle_browser.js +369 -36
- package/lib/bundle_browser.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/walletSdk/Auth/WalletSigner.d.ts +23 -1
- package/lib/walletSdk/Exceptions/index.d.ts +5 -1
- package/lib/walletSdk/Horizon/Transaction/CommonTransactionBuilder.d.ts +18 -0
- package/lib/walletSdk/Horizon/Transaction/SponsoringBuilder.d.ts +10 -0
- package/lib/walletSdk/Horizon/Transaction/TransactionBuilder.d.ts +42 -9
- package/lib/walletSdk/Horizon/index.d.ts +1 -0
- package/lib/walletSdk/Types/auth.d.ts +3 -0
- package/lib/walletSdk/Types/horizon.d.ts +11 -1
- package/lib/walletSdk/Types/index.d.ts +7 -0
- package/lib/walletSdk/Utils/extractAxiosErrorData.d.ts +2 -0
- package/lib/walletSdk/Utils/index.d.ts +1 -0
- package/lib/walletSdk/index.d.ts +2 -1
- package/package.json +5 -3
- package/src/index.ts +1 -0
- package/src/walletSdk/Anchor/Sep24.ts +2 -0
- package/src/walletSdk/Auth/WalletSigner.ts +64 -1
- package/src/walletSdk/Auth/index.ts +1 -1
- package/src/walletSdk/Exceptions/index.ts +22 -2
- package/src/walletSdk/Horizon/Stellar.ts +1 -0
- package/src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts +75 -0
- package/src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts +58 -0
- package/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +116 -34
- package/src/walletSdk/Horizon/index.ts +1 -0
- package/src/walletSdk/Types/auth.ts +4 -0
- package/src/walletSdk/Types/horizon.ts +12 -1
- package/src/walletSdk/Types/index.ts +8 -1
- package/src/walletSdk/Utils/extractAxiosErrorData.ts +28 -0
- package/src/walletSdk/Utils/index.ts +1 -0
- package/src/walletSdk/index.ts +7 -1
- package/test/stellar.test.ts +198 -1
- package/test/transaction.test.ts +325 -0
- package/test/wallet.test.ts +43 -0
package/lib/bundle.js
CHANGED
|
@@ -39826,7 +39826,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
39826
39826
|
return result;
|
|
39827
39827
|
};
|
|
39828
39828
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
39829
|
-
exports.Keypair = exports.walletSdk = exports.Exceptions = exports.Utils = exports.Watcher = exports.Recovery = exports.TransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = exports.DefaultSigner = exports.Sep10 = exports.FiatAssetId = exports.NativeAssetId = exports.IssuedAssetId = exports.Sep24 = exports.Anchor = exports.ApplicationConfiguration = exports.StellarConfiguration = exports.Config = exports.Wallet = exports.Types = void 0;
|
|
39829
|
+
exports.Keypair = exports.walletSdk = exports.Exceptions = exports.Utils = exports.Watcher = exports.Recovery = exports.SponsoringBuilder = exports.TransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = exports.DefaultSigner = exports.Sep10 = exports.FiatAssetId = exports.NativeAssetId = exports.IssuedAssetId = exports.Sep24 = exports.Anchor = exports.ApplicationConfiguration = exports.StellarConfiguration = exports.Config = exports.Wallet = exports.Types = void 0;
|
|
39830
39830
|
/**
|
|
39831
39831
|
* Types
|
|
39832
39832
|
*/
|
|
@@ -39857,6 +39857,7 @@ Object.defineProperty(exports, "SigningKeypair", ({ enumerable: true, get: funct
|
|
|
39857
39857
|
Object.defineProperty(exports, "AccountService", ({ enumerable: true, get: function () { return Horizon_1.AccountService; } }));
|
|
39858
39858
|
Object.defineProperty(exports, "Stellar", ({ enumerable: true, get: function () { return Horizon_1.Stellar; } }));
|
|
39859
39859
|
Object.defineProperty(exports, "TransactionBuilder", ({ enumerable: true, get: function () { return Horizon_1.TransactionBuilder; } }));
|
|
39860
|
+
Object.defineProperty(exports, "SponsoringBuilder", ({ enumerable: true, get: function () { return Horizon_1.SponsoringBuilder; } }));
|
|
39860
39861
|
var Recovery_1 = __webpack_require__(/*! ./walletSdk/Recovery */ "./src/walletSdk/Recovery/index.ts");
|
|
39861
39862
|
Object.defineProperty(exports, "Recovery", ({ enumerable: true, get: function () { return Recovery_1.Recovery; } }));
|
|
39862
39863
|
var Watcher_1 = __webpack_require__(/*! ./walletSdk/Watcher */ "./src/walletSdk/Watcher/index.ts");
|
|
@@ -40410,7 +40411,7 @@ exports.FiatAssetId = FiatAssetId;
|
|
|
40410
40411
|
/*!********************************************!*\
|
|
40411
40412
|
!*** ./src/walletSdk/Auth/WalletSigner.ts ***!
|
|
40412
40413
|
\********************************************/
|
|
40413
|
-
/***/ (function(__unused_webpack_module, exports) {
|
|
40414
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
40414
40415
|
|
|
40415
40416
|
"use strict";
|
|
40416
40417
|
|
|
@@ -40451,7 +40452,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
40451
40452
|
}
|
|
40452
40453
|
};
|
|
40453
40454
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
40454
|
-
exports.DefaultSigner = void 0;
|
|
40455
|
+
exports.DomainSigner = exports.DefaultSigner = void 0;
|
|
40456
|
+
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js");
|
|
40457
|
+
var __1 = __webpack_require__(/*! ../ */ "./src/walletSdk/index.ts");
|
|
40455
40458
|
exports.DefaultSigner = {
|
|
40456
40459
|
signWithClientAccount: function (_a) {
|
|
40457
40460
|
var transaction = _a.transaction, accountKp = _a.accountKp;
|
|
@@ -40464,6 +40467,51 @@ exports.DefaultSigner = {
|
|
|
40464
40467
|
});
|
|
40465
40468
|
}); },
|
|
40466
40469
|
};
|
|
40470
|
+
/**
|
|
40471
|
+
* Represents a Domain Signer used for signing Stellar transactions with a domain server.
|
|
40472
|
+
*
|
|
40473
|
+
* @class
|
|
40474
|
+
* @implements {WalletSigner}
|
|
40475
|
+
*/
|
|
40476
|
+
var DomainSigner = /** @class */ (function () {
|
|
40477
|
+
/**
|
|
40478
|
+
* Create a new instance of the DomainSigner class.
|
|
40479
|
+
*
|
|
40480
|
+
* @constructor
|
|
40481
|
+
* @param {string} url - The URL of the domain server.
|
|
40482
|
+
* @param {HttpHeaders} headers - The HTTP headers for requests to the domain server.
|
|
40483
|
+
* These headers can be used for authentication purposes.
|
|
40484
|
+
*/
|
|
40485
|
+
function DomainSigner(url, headers) {
|
|
40486
|
+
this.url = url;
|
|
40487
|
+
this.client = __1.DefaultClient;
|
|
40488
|
+
this.headers = headers;
|
|
40489
|
+
}
|
|
40490
|
+
DomainSigner.prototype.signWithClientAccount = function (_a) {
|
|
40491
|
+
var transaction = _a.transaction, accountKp = _a.accountKp;
|
|
40492
|
+
transaction.sign(accountKp.keypair);
|
|
40493
|
+
return transaction;
|
|
40494
|
+
};
|
|
40495
|
+
DomainSigner.prototype.signWithDomainAccount = function (_a) {
|
|
40496
|
+
var transactionXDR = _a.transactionXDR, networkPassphrase = _a.networkPassphrase, accountKp = _a.accountKp;
|
|
40497
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
40498
|
+
var response;
|
|
40499
|
+
return __generator(this, function (_b) {
|
|
40500
|
+
switch (_b.label) {
|
|
40501
|
+
case 0: return [4 /*yield*/, this.client.post(this.url, {
|
|
40502
|
+
transactionXDR: transactionXDR,
|
|
40503
|
+
networkPassphrase: networkPassphrase,
|
|
40504
|
+
}, { headers: this.headers })];
|
|
40505
|
+
case 1:
|
|
40506
|
+
response = _b.sent();
|
|
40507
|
+
return [2 /*return*/, stellar_sdk_1.TransactionBuilder.fromXDR(response.data.transaction, networkPassphrase)];
|
|
40508
|
+
}
|
|
40509
|
+
});
|
|
40510
|
+
});
|
|
40511
|
+
};
|
|
40512
|
+
return DomainSigner;
|
|
40513
|
+
}());
|
|
40514
|
+
exports.DomainSigner = DomainSigner;
|
|
40467
40515
|
|
|
40468
40516
|
|
|
40469
40517
|
/***/ }),
|
|
@@ -40540,7 +40588,7 @@ var Sep10 = /** @class */ (function () {
|
|
|
40540
40588
|
case 0: return [4 /*yield*/, this.challenge({
|
|
40541
40589
|
accountKp: accountKp,
|
|
40542
40590
|
memoId: memoId,
|
|
40543
|
-
clientDomain: clientDomain,
|
|
40591
|
+
clientDomain: clientDomain || this.cfg.app.defaultClientDomain,
|
|
40544
40592
|
})];
|
|
40545
40593
|
case 1:
|
|
40546
40594
|
challengeResponse = _b.sent();
|
|
@@ -40664,7 +40712,7 @@ var validateToken = function (token) {
|
|
|
40664
40712
|
/*!*******************************************!*\
|
|
40665
40713
|
!*** ./src/walletSdk/Exceptions/index.ts ***!
|
|
40666
40714
|
\*******************************************/
|
|
40667
|
-
/***/ (function(__unused_webpack_module, exports) {
|
|
40715
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
40668
40716
|
|
|
40669
40717
|
"use strict";
|
|
40670
40718
|
|
|
@@ -40683,12 +40731,28 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
40683
40731
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
40684
40732
|
};
|
|
40685
40733
|
})();
|
|
40734
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40735
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40736
|
+
};
|
|
40686
40737
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
40687
|
-
exports.WithdrawalTxMemoError = exports.WithdrawalTxMissingMemoError = exports.WithdrawalTxNotPendingUserTransferStartError = exports.OperationsLimitExceededError = exports.SignerRequiredError = exports.TransactionSubmitWithFeeIncreaseFailedError = exports.ExpiredTokenError = exports.InvalidTokenError = exports.MissingTokenError = exports.InsufficientStartingBalanceError = exports.TransactionSubmitFailedError = exports.AccountDoesNotExistError = exports.InvalidTransactionsResponseError = exports.InvalidTransactionResponseError = exports.MissingTransactionIdError = exports.ClientDomainWithMemoError = exports.InvalidMemoError = exports.AssetNotSupportedError = exports.ServerRequestFailedError = void 0;
|
|
40738
|
+
exports.WithdrawalTxMemoError = exports.PathPayOnlyOneAmountError = exports.WithdrawalTxMissingMemoError = exports.WithdrawalTxNotPendingUserTransferStartError = exports.OperationsLimitExceededError = exports.SignerRequiredError = exports.TransactionSubmitWithFeeIncreaseFailedError = exports.ExpiredTokenError = exports.InvalidTokenError = exports.MissingTokenError = exports.InsufficientStartingBalanceError = exports.TransactionSubmitFailedError = exports.AccountDoesNotExistError = exports.InvalidTransactionsResponseError = exports.InvalidTransactionResponseError = exports.MissingTransactionIdError = exports.ClientDomainWithMemoError = exports.InvalidMemoError = exports.AssetNotSupportedError = exports.ServerRequestFailedError = void 0;
|
|
40739
|
+
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/node/axios.cjs"));
|
|
40740
|
+
var Utils_1 = __webpack_require__(/*! ../Utils */ "./src/walletSdk/Utils/index.ts");
|
|
40688
40741
|
var ServerRequestFailedError = /** @class */ (function (_super) {
|
|
40689
40742
|
__extends(ServerRequestFailedError, _super);
|
|
40690
40743
|
function ServerRequestFailedError(e) {
|
|
40691
|
-
var _this =
|
|
40744
|
+
var _this = this;
|
|
40745
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
40746
|
+
var errorData = (0, Utils_1.extractAxiosErrorData)(e);
|
|
40747
|
+
var message = errorData.responseData && Object.keys(errorData.responseData).length > 0
|
|
40748
|
+
? JSON.stringify(errorData.responseData)
|
|
40749
|
+
: errorData.statusText;
|
|
40750
|
+
_this = _super.call(this, "Server request failed with error: ".concat(errorData.status, " ").concat(message)) || this;
|
|
40751
|
+
_this.data = errorData;
|
|
40752
|
+
}
|
|
40753
|
+
else {
|
|
40754
|
+
_this = _super.call(this, "Server request failed with error: ".concat(e)) || this;
|
|
40755
|
+
}
|
|
40692
40756
|
Object.setPrototypeOf(_this, ServerRequestFailedError.prototype);
|
|
40693
40757
|
return _this;
|
|
40694
40758
|
}
|
|
@@ -40865,6 +40929,16 @@ var WithdrawalTxMissingMemoError = /** @class */ (function (_super) {
|
|
|
40865
40929
|
return WithdrawalTxMissingMemoError;
|
|
40866
40930
|
}(Error));
|
|
40867
40931
|
exports.WithdrawalTxMissingMemoError = WithdrawalTxMissingMemoError;
|
|
40932
|
+
var PathPayOnlyOneAmountError = /** @class */ (function (_super) {
|
|
40933
|
+
__extends(PathPayOnlyOneAmountError, _super);
|
|
40934
|
+
function PathPayOnlyOneAmountError() {
|
|
40935
|
+
var _this = _super.call(this, "Must give sendAmount or destAmount value, but not both") || this;
|
|
40936
|
+
Object.setPrototypeOf(_this, PathPayOnlyOneAmountError.prototype);
|
|
40937
|
+
return _this;
|
|
40938
|
+
}
|
|
40939
|
+
return PathPayOnlyOneAmountError;
|
|
40940
|
+
}(Error));
|
|
40941
|
+
exports.PathPayOnlyOneAmountError = PathPayOnlyOneAmountError;
|
|
40868
40942
|
var WithdrawalTxMemoError = /** @class */ (function (_super) {
|
|
40869
40943
|
__extends(WithdrawalTxMemoError, _super);
|
|
40870
40944
|
function WithdrawalTxMemoError() {
|
|
@@ -41273,6 +41347,140 @@ var Stellar = /** @class */ (function () {
|
|
|
41273
41347
|
exports.Stellar = Stellar;
|
|
41274
41348
|
|
|
41275
41349
|
|
|
41350
|
+
/***/ }),
|
|
41351
|
+
|
|
41352
|
+
/***/ "./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts":
|
|
41353
|
+
/*!***********************************************************************!*\
|
|
41354
|
+
!*** ./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts ***!
|
|
41355
|
+
\***********************************************************************/
|
|
41356
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
41357
|
+
|
|
41358
|
+
"use strict";
|
|
41359
|
+
|
|
41360
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41361
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41362
|
+
};
|
|
41363
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41364
|
+
exports.CommonTransactionBuilder = void 0;
|
|
41365
|
+
var stellar_sdk_1 = __importDefault(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js"));
|
|
41366
|
+
var CommonTransactionBuilder = /** @class */ (function () {
|
|
41367
|
+
function CommonTransactionBuilder(sourceAddress, operations) {
|
|
41368
|
+
this.sourceAddress = sourceAddress;
|
|
41369
|
+
this.operations = operations;
|
|
41370
|
+
}
|
|
41371
|
+
CommonTransactionBuilder.prototype.addAssetSupport = function (asset, trustLimit) {
|
|
41372
|
+
this.operations.push(stellar_sdk_1.default.Operation.changeTrust({
|
|
41373
|
+
asset: asset.toAsset(),
|
|
41374
|
+
limit: trustLimit,
|
|
41375
|
+
source: this.sourceAddress,
|
|
41376
|
+
}));
|
|
41377
|
+
return this;
|
|
41378
|
+
};
|
|
41379
|
+
CommonTransactionBuilder.prototype.removeAssetSupport = function (asset) {
|
|
41380
|
+
return this.addAssetSupport(asset, "0");
|
|
41381
|
+
};
|
|
41382
|
+
CommonTransactionBuilder.prototype.addAccountSigner = function (signerAddress, signerWeight) {
|
|
41383
|
+
this.operations.push(stellar_sdk_1.default.Operation.setOptions({
|
|
41384
|
+
source: this.sourceAddress,
|
|
41385
|
+
signer: {
|
|
41386
|
+
ed25519PublicKey: signerAddress.publicKey,
|
|
41387
|
+
weight: signerWeight,
|
|
41388
|
+
},
|
|
41389
|
+
}));
|
|
41390
|
+
return this;
|
|
41391
|
+
};
|
|
41392
|
+
CommonTransactionBuilder.prototype.removeAccountSigner = function (signerAddress) {
|
|
41393
|
+
return this.addAccountSigner(signerAddress, 0);
|
|
41394
|
+
};
|
|
41395
|
+
CommonTransactionBuilder.prototype.lockAccountMasterKey = function () {
|
|
41396
|
+
this.operations.push(stellar_sdk_1.default.Operation.setOptions({
|
|
41397
|
+
source: this.sourceAddress,
|
|
41398
|
+
masterWeight: 0,
|
|
41399
|
+
}));
|
|
41400
|
+
return this;
|
|
41401
|
+
};
|
|
41402
|
+
CommonTransactionBuilder.prototype.setThreshold = function (_a) {
|
|
41403
|
+
var low = _a.low, medium = _a.medium, high = _a.high;
|
|
41404
|
+
this.operations.push(stellar_sdk_1.default.Operation.setOptions({
|
|
41405
|
+
source: this.sourceAddress,
|
|
41406
|
+
lowThreshold: low,
|
|
41407
|
+
medThreshold: medium,
|
|
41408
|
+
highThreshold: high,
|
|
41409
|
+
}));
|
|
41410
|
+
return this;
|
|
41411
|
+
};
|
|
41412
|
+
return CommonTransactionBuilder;
|
|
41413
|
+
}());
|
|
41414
|
+
exports.CommonTransactionBuilder = CommonTransactionBuilder;
|
|
41415
|
+
|
|
41416
|
+
|
|
41417
|
+
/***/ }),
|
|
41418
|
+
|
|
41419
|
+
/***/ "./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts":
|
|
41420
|
+
/*!****************************************************************!*\
|
|
41421
|
+
!*** ./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts ***!
|
|
41422
|
+
\****************************************************************/
|
|
41423
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
41424
|
+
|
|
41425
|
+
"use strict";
|
|
41426
|
+
|
|
41427
|
+
var __extends = (this && this.__extends) || (function () {
|
|
41428
|
+
var extendStatics = function (d, b) {
|
|
41429
|
+
extendStatics = Object.setPrototypeOf ||
|
|
41430
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
41431
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
41432
|
+
return extendStatics(d, b);
|
|
41433
|
+
};
|
|
41434
|
+
return function (d, b) {
|
|
41435
|
+
if (typeof b !== "function" && b !== null)
|
|
41436
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
41437
|
+
extendStatics(d, b);
|
|
41438
|
+
function __() { this.constructor = d; }
|
|
41439
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
41440
|
+
};
|
|
41441
|
+
})();
|
|
41442
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41443
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41444
|
+
};
|
|
41445
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41446
|
+
exports.SponsoringBuilder = void 0;
|
|
41447
|
+
var stellar_sdk_1 = __importDefault(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js"));
|
|
41448
|
+
var CommonTransactionBuilder_1 = __webpack_require__(/*! ./CommonTransactionBuilder */ "./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts");
|
|
41449
|
+
var SponsoringBuilder = /** @class */ (function (_super) {
|
|
41450
|
+
__extends(SponsoringBuilder, _super);
|
|
41451
|
+
function SponsoringBuilder(sponsoredAddress, sponsorAccount, operations, buildingFunction) {
|
|
41452
|
+
var _this = _super.call(this, sponsoredAddress, operations) || this;
|
|
41453
|
+
_this.sponsorAccount = sponsorAccount;
|
|
41454
|
+
_this.startSponsoring();
|
|
41455
|
+
buildingFunction(_this);
|
|
41456
|
+
_this.stopSponsoring();
|
|
41457
|
+
return _this;
|
|
41458
|
+
}
|
|
41459
|
+
SponsoringBuilder.prototype.createAccount = function (newAccount, startingBalance) {
|
|
41460
|
+
if (startingBalance === void 0) { startingBalance = 0; }
|
|
41461
|
+
this.operations.push(stellar_sdk_1.default.Operation.createAccount({
|
|
41462
|
+
destination: newAccount.publicKey,
|
|
41463
|
+
startingBalance: startingBalance.toString(),
|
|
41464
|
+
source: this.sponsorAccount.publicKey,
|
|
41465
|
+
}));
|
|
41466
|
+
return this;
|
|
41467
|
+
};
|
|
41468
|
+
SponsoringBuilder.prototype.startSponsoring = function () {
|
|
41469
|
+
this.operations.push(stellar_sdk_1.default.Operation.beginSponsoringFutureReserves({
|
|
41470
|
+
sponsoredId: this.sourceAddress,
|
|
41471
|
+
source: this.sponsorAccount.publicKey,
|
|
41472
|
+
}));
|
|
41473
|
+
};
|
|
41474
|
+
SponsoringBuilder.prototype.stopSponsoring = function () {
|
|
41475
|
+
this.operations.push(stellar_sdk_1.default.Operation.endSponsoringFutureReserves({
|
|
41476
|
+
source: this.sourceAddress,
|
|
41477
|
+
}));
|
|
41478
|
+
};
|
|
41479
|
+
return SponsoringBuilder;
|
|
41480
|
+
}(CommonTransactionBuilder_1.CommonTransactionBuilder));
|
|
41481
|
+
exports.SponsoringBuilder = SponsoringBuilder;
|
|
41482
|
+
|
|
41483
|
+
|
|
41276
41484
|
/***/ }),
|
|
41277
41485
|
|
|
41278
41486
|
/***/ "./src/walletSdk/Horizon/Transaction/TransactionBuilder.ts":
|
|
@@ -41283,6 +41491,21 @@ exports.Stellar = Stellar;
|
|
|
41283
41491
|
|
|
41284
41492
|
"use strict";
|
|
41285
41493
|
|
|
41494
|
+
var __extends = (this && this.__extends) || (function () {
|
|
41495
|
+
var extendStatics = function (d, b) {
|
|
41496
|
+
extendStatics = Object.setPrototypeOf ||
|
|
41497
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
41498
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
41499
|
+
return extendStatics(d, b);
|
|
41500
|
+
};
|
|
41501
|
+
return function (d, b) {
|
|
41502
|
+
if (typeof b !== "function" && b !== null)
|
|
41503
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
41504
|
+
extendStatics(d, b);
|
|
41505
|
+
function __() { this.constructor = d; }
|
|
41506
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
41507
|
+
};
|
|
41508
|
+
})();
|
|
41286
41509
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
41287
41510
|
if (k2 === undefined) k2 = k;
|
|
41288
41511
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -41311,21 +41534,28 @@ exports.TransactionBuilder = void 0;
|
|
|
41311
41534
|
var stellar_sdk_1 = __importStar(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/lib/index.js"));
|
|
41312
41535
|
var Exceptions_1 = __webpack_require__(/*! ../../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
41313
41536
|
var Types_1 = __webpack_require__(/*! ../../Types */ "./src/walletSdk/Types/index.ts");
|
|
41314
|
-
var
|
|
41537
|
+
var Exceptions_2 = __webpack_require__(/*! ../../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
41538
|
+
var CommonTransactionBuilder_1 = __webpack_require__(/*! ./CommonTransactionBuilder */ "./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts");
|
|
41539
|
+
var SponsoringBuilder_1 = __webpack_require__(/*! ./SponsoringBuilder */ "./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts");
|
|
41540
|
+
var TransactionBuilder = /** @class */ (function (_super) {
|
|
41541
|
+
__extends(TransactionBuilder, _super);
|
|
41315
41542
|
function TransactionBuilder(cfg, sourceAccount, baseFee, memo, timebounds) {
|
|
41316
|
-
|
|
41317
|
-
|
|
41318
|
-
this.builder = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
|
|
41543
|
+
var _this = _super.call(this, sourceAccount.accountId(), []) || this;
|
|
41544
|
+
_this.builder = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
|
|
41319
41545
|
fee: baseFee ? baseFee.toString() : cfg.stellar.baseFee.toString(),
|
|
41320
41546
|
timebounds: timebounds,
|
|
41321
41547
|
memo: memo,
|
|
41322
41548
|
networkPassphrase: cfg.stellar.network,
|
|
41323
41549
|
});
|
|
41324
41550
|
if (!timebounds) {
|
|
41325
|
-
|
|
41551
|
+
_this.builder.setTimeout(cfg.stellar.defaultTimeout);
|
|
41326
41552
|
}
|
|
41327
|
-
|
|
41553
|
+
return _this;
|
|
41328
41554
|
}
|
|
41555
|
+
TransactionBuilder.prototype.sponsoring = function (sponsorAccount, buildingFunction, sponsoredAccount) {
|
|
41556
|
+
new SponsoringBuilder_1.SponsoringBuilder(sponsoredAccount ? sponsoredAccount.publicKey : this.sourceAddress, sponsorAccount, this.operations, buildingFunction);
|
|
41557
|
+
return this;
|
|
41558
|
+
};
|
|
41329
41559
|
TransactionBuilder.prototype.createAccount = function (newAccount, startingBalance) {
|
|
41330
41560
|
if (startingBalance === void 0) { startingBalance = 1; }
|
|
41331
41561
|
if (startingBalance < 1) {
|
|
@@ -41334,7 +41564,7 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
41334
41564
|
this.operations.push(stellar_sdk_1.default.Operation.createAccount({
|
|
41335
41565
|
destination: newAccount.publicKey,
|
|
41336
41566
|
startingBalance: startingBalance.toString(),
|
|
41337
|
-
source: this.
|
|
41567
|
+
source: this.sourceAddress,
|
|
41338
41568
|
}));
|
|
41339
41569
|
return this;
|
|
41340
41570
|
};
|
|
@@ -41346,6 +41576,73 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
41346
41576
|
}));
|
|
41347
41577
|
return this;
|
|
41348
41578
|
};
|
|
41579
|
+
/**
|
|
41580
|
+
* Creates and adds a path payment operation to the transaction builder.
|
|
41581
|
+
*
|
|
41582
|
+
* @param {string} destinationAddress - The destination Stellar address to which the payment is sent.
|
|
41583
|
+
* @param {StellarAssetId} sendAsset - The asset to be sent.
|
|
41584
|
+
* @param {StellarAssetId} destAsset - The asset the destination will receive.
|
|
41585
|
+
* @param {string} [sendAmount] - The amount to be sent. Must specify either sendAmount or destAmount,
|
|
41586
|
+
* but not both.
|
|
41587
|
+
* @param {string} [destAmount] - The amount to be received by the destination. Must specify either sendAmount or destAmount,
|
|
41588
|
+
* but not both.
|
|
41589
|
+
* @param {string} [destMin] - The minimum amount of the destination asset to be receive. This is a
|
|
41590
|
+
* protective measure, it allows you to specify a lower bound for an acceptable conversion. Only used
|
|
41591
|
+
* if using sendAmount.
|
|
41592
|
+
* (optional, default is ".0000001").
|
|
41593
|
+
* @param {string} [sendMax] - The maximum amount of the destination asset to be sent. This is a
|
|
41594
|
+
* protective measure, it allows you to specify an upper bound for an acceptable conversion. Only used
|
|
41595
|
+
* if using destAmount.
|
|
41596
|
+
* (optional, default is int64 max).
|
|
41597
|
+
*
|
|
41598
|
+
* @returns {TransactionBuilder} - Returns the current TransactionBuilder instance for method chaining.
|
|
41599
|
+
*/
|
|
41600
|
+
TransactionBuilder.prototype.pathPay = function (_a) {
|
|
41601
|
+
var destinationAddress = _a.destinationAddress, sendAsset = _a.sendAsset, destAsset = _a.destAsset, sendAmount = _a.sendAmount, destAmount = _a.destAmount, destMin = _a.destMin, sendMax = _a.sendMax;
|
|
41602
|
+
if ((sendAmount && destAmount) || (!sendAmount && !destAmount)) {
|
|
41603
|
+
throw new Exceptions_2.PathPayOnlyOneAmountError();
|
|
41604
|
+
}
|
|
41605
|
+
if (sendAmount) {
|
|
41606
|
+
this.operations.push(stellar_sdk_1.default.Operation.pathPaymentStrictSend({
|
|
41607
|
+
destination: destinationAddress,
|
|
41608
|
+
sendAsset: sendAsset.toAsset(),
|
|
41609
|
+
sendAmount: sendAmount,
|
|
41610
|
+
destAsset: destAsset.toAsset(),
|
|
41611
|
+
destMin: destMin || ".0000001",
|
|
41612
|
+
}));
|
|
41613
|
+
}
|
|
41614
|
+
else {
|
|
41615
|
+
this.operations.push(stellar_sdk_1.default.Operation.pathPaymentStrictReceive({
|
|
41616
|
+
destination: destinationAddress,
|
|
41617
|
+
sendAsset: sendAsset.toAsset(),
|
|
41618
|
+
destAmount: destAmount,
|
|
41619
|
+
destAsset: destAsset.toAsset(),
|
|
41620
|
+
sendMax: sendMax || "922337203685.4775807",
|
|
41621
|
+
}));
|
|
41622
|
+
}
|
|
41623
|
+
return this;
|
|
41624
|
+
};
|
|
41625
|
+
/**
|
|
41626
|
+
* Swap assets using the Stellar network. This swaps using the
|
|
41627
|
+
* pathPaymentStrictReceive operation.
|
|
41628
|
+
*
|
|
41629
|
+
* @param {StellarAssetId} fromAsset - The source asset to be sent.
|
|
41630
|
+
* @param {StellarAssetId} toAsset - The destination asset to receive.
|
|
41631
|
+
* @param {string} amount - The amount of the source asset to be sent.
|
|
41632
|
+
* @param {string} [destMin] - (Optional) The minimum amount of the destination asset to be received.
|
|
41633
|
+
*
|
|
41634
|
+
* @returns {TransactionBuilder} Returns the current instance of the TransactionBuilder for method chaining.
|
|
41635
|
+
*/
|
|
41636
|
+
TransactionBuilder.prototype.swap = function (fromAsset, toAsset, amount, destMin) {
|
|
41637
|
+
this.pathPay({
|
|
41638
|
+
destinationAddress: this.sourceAddress,
|
|
41639
|
+
sendAsset: fromAsset,
|
|
41640
|
+
destAsset: toAsset,
|
|
41641
|
+
sendAmount: amount,
|
|
41642
|
+
destMin: destMin,
|
|
41643
|
+
});
|
|
41644
|
+
return this;
|
|
41645
|
+
};
|
|
41349
41646
|
TransactionBuilder.prototype.addOperation = function (op) {
|
|
41350
41647
|
this.builder.addOperation(op);
|
|
41351
41648
|
return this;
|
|
@@ -41354,24 +41651,6 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
41354
41651
|
this.builder.addMemo(memo);
|
|
41355
41652
|
return this;
|
|
41356
41653
|
};
|
|
41357
|
-
TransactionBuilder.prototype.addAssetSupport = function (asset, trustLimit) {
|
|
41358
|
-
this.operations.push(stellar_sdk_1.default.Operation.changeTrust({
|
|
41359
|
-
asset: asset.toAsset(),
|
|
41360
|
-
limit: trustLimit,
|
|
41361
|
-
source: this.sourceAccount,
|
|
41362
|
-
}));
|
|
41363
|
-
return this;
|
|
41364
|
-
};
|
|
41365
|
-
TransactionBuilder.prototype.removeAssetSupport = function (asset) {
|
|
41366
|
-
return this.addAssetSupport(asset, "0");
|
|
41367
|
-
};
|
|
41368
|
-
TransactionBuilder.prototype.build = function () {
|
|
41369
|
-
var _this = this;
|
|
41370
|
-
this.operations.forEach(function (op) {
|
|
41371
|
-
_this.builder.addOperation(op);
|
|
41372
|
-
});
|
|
41373
|
-
return this.builder.build();
|
|
41374
|
-
};
|
|
41375
41654
|
TransactionBuilder.prototype.transferWithdrawalTransaction = function (transaction, assetId) {
|
|
41376
41655
|
if (transaction.status !== Types_1.TransactionStatus.pending_user_transfer_start) {
|
|
41377
41656
|
throw new Exceptions_1.WithdrawalTxNotPendingUserTransferStartError(transaction.status);
|
|
@@ -41394,8 +41673,15 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
41394
41673
|
}
|
|
41395
41674
|
return this.transfer(transaction.withdraw_anchor_account, assetId, transaction.amount_in);
|
|
41396
41675
|
};
|
|
41676
|
+
TransactionBuilder.prototype.build = function () {
|
|
41677
|
+
var _this = this;
|
|
41678
|
+
this.operations.forEach(function (op) {
|
|
41679
|
+
_this.builder.addOperation(op);
|
|
41680
|
+
});
|
|
41681
|
+
return this.builder.build();
|
|
41682
|
+
};
|
|
41397
41683
|
return TransactionBuilder;
|
|
41398
|
-
}());
|
|
41684
|
+
}(CommonTransactionBuilder_1.CommonTransactionBuilder));
|
|
41399
41685
|
exports.TransactionBuilder = TransactionBuilder;
|
|
41400
41686
|
|
|
41401
41687
|
|
|
@@ -41410,7 +41696,7 @@ exports.TransactionBuilder = TransactionBuilder;
|
|
|
41410
41696
|
"use strict";
|
|
41411
41697
|
|
|
41412
41698
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41413
|
-
exports.TransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = void 0;
|
|
41699
|
+
exports.SponsoringBuilder = exports.TransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = void 0;
|
|
41414
41700
|
var Account_1 = __webpack_require__(/*! ./Account */ "./src/walletSdk/Horizon/Account.ts");
|
|
41415
41701
|
Object.defineProperty(exports, "PublicKeypair", ({ enumerable: true, get: function () { return Account_1.PublicKeypair; } }));
|
|
41416
41702
|
Object.defineProperty(exports, "SigningKeypair", ({ enumerable: true, get: function () { return Account_1.SigningKeypair; } }));
|
|
@@ -41420,6 +41706,8 @@ var Stellar_1 = __webpack_require__(/*! ./Stellar */ "./src/walletSdk/Horizon/St
|
|
|
41420
41706
|
Object.defineProperty(exports, "Stellar", ({ enumerable: true, get: function () { return Stellar_1.Stellar; } }));
|
|
41421
41707
|
var TransactionBuilder_1 = __webpack_require__(/*! ./Transaction/TransactionBuilder */ "./src/walletSdk/Horizon/Transaction/TransactionBuilder.ts");
|
|
41422
41708
|
Object.defineProperty(exports, "TransactionBuilder", ({ enumerable: true, get: function () { return TransactionBuilder_1.TransactionBuilder; } }));
|
|
41709
|
+
var SponsoringBuilder_1 = __webpack_require__(/*! ./Transaction/SponsoringBuilder */ "./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts");
|
|
41710
|
+
Object.defineProperty(exports, "SponsoringBuilder", ({ enumerable: true, get: function () { return SponsoringBuilder_1.SponsoringBuilder; } }));
|
|
41423
41711
|
|
|
41424
41712
|
|
|
41425
41713
|
/***/ }),
|
|
@@ -41675,6 +41963,49 @@ var camelToSnakeCaseObject = function (obj) {
|
|
|
41675
41963
|
exports.camelToSnakeCaseObject = camelToSnakeCaseObject;
|
|
41676
41964
|
|
|
41677
41965
|
|
|
41966
|
+
/***/ }),
|
|
41967
|
+
|
|
41968
|
+
/***/ "./src/walletSdk/Utils/extractAxiosErrorData.ts":
|
|
41969
|
+
/*!******************************************************!*\
|
|
41970
|
+
!*** ./src/walletSdk/Utils/extractAxiosErrorData.ts ***!
|
|
41971
|
+
\******************************************************/
|
|
41972
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
41973
|
+
|
|
41974
|
+
"use strict";
|
|
41975
|
+
|
|
41976
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41977
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41978
|
+
};
|
|
41979
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
41980
|
+
exports.extractAxiosErrorData = void 0;
|
|
41981
|
+
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/node/axios.cjs"));
|
|
41982
|
+
// Based on https://axios-http.com/docs/handling_errors
|
|
41983
|
+
var extractAxiosErrorData = function (error) {
|
|
41984
|
+
if (!axios_1.default.isAxiosError(error)) {
|
|
41985
|
+
return { responseData: JSON.stringify(error) };
|
|
41986
|
+
}
|
|
41987
|
+
if (error.response) {
|
|
41988
|
+
return {
|
|
41989
|
+
status: error.response.status,
|
|
41990
|
+
statusText: error.response.statusText,
|
|
41991
|
+
responseData: error.response.data,
|
|
41992
|
+
headers: error.response.headers,
|
|
41993
|
+
};
|
|
41994
|
+
}
|
|
41995
|
+
else if (error.request) {
|
|
41996
|
+
// The request was made but no response was received
|
|
41997
|
+
return {
|
|
41998
|
+
statusText: "No response received from request: ".concat(JSON.stringify(error.request)),
|
|
41999
|
+
};
|
|
42000
|
+
}
|
|
42001
|
+
else {
|
|
42002
|
+
// Something happened in setting up the request that triggered an Error
|
|
42003
|
+
return { statusText: "Failed request with error: ".concat(error.message) };
|
|
42004
|
+
}
|
|
42005
|
+
};
|
|
42006
|
+
exports.extractAxiosErrorData = extractAxiosErrorData;
|
|
42007
|
+
|
|
42008
|
+
|
|
41678
42009
|
/***/ }),
|
|
41679
42010
|
|
|
41680
42011
|
/***/ "./src/walletSdk/Utils/getResultCode.ts":
|
|
@@ -41725,6 +42056,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
41725
42056
|
__exportStar(__webpack_require__(/*! ./camelToSnakeCase */ "./src/walletSdk/Utils/camelToSnakeCase.ts"), exports);
|
|
41726
42057
|
__exportStar(__webpack_require__(/*! ./toml */ "./src/walletSdk/Utils/toml.ts"), exports);
|
|
41727
42058
|
__exportStar(__webpack_require__(/*! ./url */ "./src/walletSdk/Utils/url.ts"), exports);
|
|
42059
|
+
__exportStar(__webpack_require__(/*! ./extractAxiosErrorData */ "./src/walletSdk/Utils/extractAxiosErrorData.ts"), exports);
|
|
41728
42060
|
|
|
41729
42061
|
|
|
41730
42062
|
/***/ }),
|
|
@@ -42264,9 +42596,10 @@ exports.DefaultClient = axios_1.default.create({
|
|
|
42264
42596
|
headers: __assign({}, walletHeaders),
|
|
42265
42597
|
});
|
|
42266
42598
|
var ApplicationConfiguration = /** @class */ (function () {
|
|
42267
|
-
function ApplicationConfiguration(defaultSigner, defaultClient) {
|
|
42599
|
+
function ApplicationConfiguration(defaultSigner, defaultClient, defaultClientDomain) {
|
|
42268
42600
|
this.defaultSigner = defaultSigner || Auth_1.DefaultSigner;
|
|
42269
42601
|
this.defaultClient = defaultClient || exports.DefaultClient;
|
|
42602
|
+
this.defaultClientDomain = defaultClientDomain;
|
|
42270
42603
|
}
|
|
42271
42604
|
return ApplicationConfiguration;
|
|
42272
42605
|
}());
|
|
@@ -57243,7 +57576,7 @@ module.exports = JSON.parse('{"name":"stellar-sdk","version":"11.0.0-beta.3","de
|
|
|
57243
57576
|
/***/ ((module) => {
|
|
57244
57577
|
|
|
57245
57578
|
"use strict";
|
|
57246
|
-
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"1.1
|
|
57579
|
+
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"1.2.1","engines":{"node":">=18"},"browser":"./lib/bundle_browser.js","main":"./lib/bundle.js","types":"./lib/index.d.ts","license":"Apache-2.0","private":false,"devDependencies":{"@babel/preset-env":"^7.20.2","@stellar/eslint-config":"^2.1.2","@stellar/prettier-config":"^1.0.1","@stellar/tsconfig":"^1.0.2","@types/jest":"^29.4.0","@types/lodash":"^4.14.194","@types/sinon":"^10.0.15","babel-jest":"^29.4.1","crypto-browserify":"^3.12.0","eslint":"^8.33.0","husky":"^8.0.0","jest":"^29.4.1","npm-run-all":"^4.1.5","prettier":"^2.0.5","pretty-quick":"^2.0.1","sinon":"^15.1.0","stream-browserify":"^3.0.0","ts-jest":"^29.0.5","ts-loader":"^9.4.2","ts-node":"^10.9.1","tslib":"^2.5.0","typescript":"^5.0.4","webpack":"^5.83.1","webpack-cli":"^5.1.1"},"dependencies":{"axios":"^1.4.0","https-browserify":"^1.0.0","jws":"^4.0.0","lodash":"^4.17.21","query-string":"^7.1.3","stellar-sdk":"^11.0.0-beta.3","stream-http":"^3.2.0","url":"^0.11.0","util":"^0.12.5","utility-types":"^3.10.0"},"scripts":{"prepare":"husky install","test":"jest --watchAll","build:web":"webpack --config webpack.config.js","build:node":"webpack --env NODE=true --config webpack.config.js","build":"run-p build:web build:node","example:sep24":"ts-node examples/sep24/sep24.ts"}}');
|
|
57247
57580
|
|
|
57248
57581
|
/***/ })
|
|
57249
57582
|
|