@stellar/typescript-wallet-sdk 1.2.0 → 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/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 +1 -1
- package/src/walletSdk/Exceptions/index.ts +16 -2
- package/src/walletSdk/Horizon/Stellar.ts +1 -0
- 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/test/wallet.test.ts +19 -0
package/lib/bundle_browser.js
CHANGED
|
@@ -85393,7 +85393,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
85393
85393
|
return result;
|
|
85394
85394
|
};
|
|
85395
85395
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
85396
|
-
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;
|
|
85396
|
+
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;
|
|
85397
85397
|
/**
|
|
85398
85398
|
* Types
|
|
85399
85399
|
*/
|
|
@@ -85424,6 +85424,7 @@ Object.defineProperty(exports, "SigningKeypair", ({ enumerable: true, get: funct
|
|
|
85424
85424
|
Object.defineProperty(exports, "AccountService", ({ enumerable: true, get: function () { return Horizon_1.AccountService; } }));
|
|
85425
85425
|
Object.defineProperty(exports, "Stellar", ({ enumerable: true, get: function () { return Horizon_1.Stellar; } }));
|
|
85426
85426
|
Object.defineProperty(exports, "TransactionBuilder", ({ enumerable: true, get: function () { return Horizon_1.TransactionBuilder; } }));
|
|
85427
|
+
Object.defineProperty(exports, "SponsoringBuilder", ({ enumerable: true, get: function () { return Horizon_1.SponsoringBuilder; } }));
|
|
85427
85428
|
var Recovery_1 = __webpack_require__(/*! ./walletSdk/Recovery */ "./src/walletSdk/Recovery/index.ts");
|
|
85428
85429
|
Object.defineProperty(exports, "Recovery", ({ enumerable: true, get: function () { return Recovery_1.Recovery; } }));
|
|
85429
85430
|
var Watcher_1 = __webpack_require__(/*! ./walletSdk/Watcher */ "./src/walletSdk/Watcher/index.ts");
|
|
@@ -85977,7 +85978,7 @@ exports.FiatAssetId = FiatAssetId;
|
|
|
85977
85978
|
/*!********************************************!*\
|
|
85978
85979
|
!*** ./src/walletSdk/Auth/WalletSigner.ts ***!
|
|
85979
85980
|
\********************************************/
|
|
85980
|
-
/***/ (function(__unused_webpack_module, exports) {
|
|
85981
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
85981
85982
|
|
|
85982
85983
|
"use strict";
|
|
85983
85984
|
|
|
@@ -86018,7 +86019,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
86018
86019
|
}
|
|
86019
86020
|
};
|
|
86020
86021
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
86021
|
-
exports.DefaultSigner = void 0;
|
|
86022
|
+
exports.DomainSigner = exports.DefaultSigner = void 0;
|
|
86023
|
+
var stellar_sdk_1 = __webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/dist/stellar-sdk.js");
|
|
86024
|
+
var __1 = __webpack_require__(/*! ../ */ "./src/walletSdk/index.ts");
|
|
86022
86025
|
exports.DefaultSigner = {
|
|
86023
86026
|
signWithClientAccount: function (_a) {
|
|
86024
86027
|
var transaction = _a.transaction, accountKp = _a.accountKp;
|
|
@@ -86031,6 +86034,51 @@ exports.DefaultSigner = {
|
|
|
86031
86034
|
});
|
|
86032
86035
|
}); },
|
|
86033
86036
|
};
|
|
86037
|
+
/**
|
|
86038
|
+
* Represents a Domain Signer used for signing Stellar transactions with a domain server.
|
|
86039
|
+
*
|
|
86040
|
+
* @class
|
|
86041
|
+
* @implements {WalletSigner}
|
|
86042
|
+
*/
|
|
86043
|
+
var DomainSigner = /** @class */ (function () {
|
|
86044
|
+
/**
|
|
86045
|
+
* Create a new instance of the DomainSigner class.
|
|
86046
|
+
*
|
|
86047
|
+
* @constructor
|
|
86048
|
+
* @param {string} url - The URL of the domain server.
|
|
86049
|
+
* @param {HttpHeaders} headers - The HTTP headers for requests to the domain server.
|
|
86050
|
+
* These headers can be used for authentication purposes.
|
|
86051
|
+
*/
|
|
86052
|
+
function DomainSigner(url, headers) {
|
|
86053
|
+
this.url = url;
|
|
86054
|
+
this.client = __1.DefaultClient;
|
|
86055
|
+
this.headers = headers;
|
|
86056
|
+
}
|
|
86057
|
+
DomainSigner.prototype.signWithClientAccount = function (_a) {
|
|
86058
|
+
var transaction = _a.transaction, accountKp = _a.accountKp;
|
|
86059
|
+
transaction.sign(accountKp.keypair);
|
|
86060
|
+
return transaction;
|
|
86061
|
+
};
|
|
86062
|
+
DomainSigner.prototype.signWithDomainAccount = function (_a) {
|
|
86063
|
+
var transactionXDR = _a.transactionXDR, networkPassphrase = _a.networkPassphrase, accountKp = _a.accountKp;
|
|
86064
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86065
|
+
var response;
|
|
86066
|
+
return __generator(this, function (_b) {
|
|
86067
|
+
switch (_b.label) {
|
|
86068
|
+
case 0: return [4 /*yield*/, this.client.post(this.url, {
|
|
86069
|
+
transactionXDR: transactionXDR,
|
|
86070
|
+
networkPassphrase: networkPassphrase,
|
|
86071
|
+
}, { headers: this.headers })];
|
|
86072
|
+
case 1:
|
|
86073
|
+
response = _b.sent();
|
|
86074
|
+
return [2 /*return*/, stellar_sdk_1.TransactionBuilder.fromXDR(response.data.transaction, networkPassphrase)];
|
|
86075
|
+
}
|
|
86076
|
+
});
|
|
86077
|
+
});
|
|
86078
|
+
};
|
|
86079
|
+
return DomainSigner;
|
|
86080
|
+
}());
|
|
86081
|
+
exports.DomainSigner = DomainSigner;
|
|
86034
86082
|
|
|
86035
86083
|
|
|
86036
86084
|
/***/ }),
|
|
@@ -86107,7 +86155,7 @@ var Sep10 = /** @class */ (function () {
|
|
|
86107
86155
|
case 0: return [4 /*yield*/, this.challenge({
|
|
86108
86156
|
accountKp: accountKp,
|
|
86109
86157
|
memoId: memoId,
|
|
86110
|
-
clientDomain: clientDomain,
|
|
86158
|
+
clientDomain: clientDomain || this.cfg.app.defaultClientDomain,
|
|
86111
86159
|
})];
|
|
86112
86160
|
case 1:
|
|
86113
86161
|
challengeResponse = _b.sent();
|
|
@@ -86231,7 +86279,7 @@ var validateToken = function (token) {
|
|
|
86231
86279
|
/*!*******************************************!*\
|
|
86232
86280
|
!*** ./src/walletSdk/Exceptions/index.ts ***!
|
|
86233
86281
|
\*******************************************/
|
|
86234
|
-
/***/ (function(__unused_webpack_module, exports) {
|
|
86282
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
86235
86283
|
|
|
86236
86284
|
"use strict";
|
|
86237
86285
|
|
|
@@ -86250,12 +86298,28 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
86250
86298
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
86251
86299
|
};
|
|
86252
86300
|
})();
|
|
86301
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
86302
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
86303
|
+
};
|
|
86253
86304
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
86254
|
-
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;
|
|
86305
|
+
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;
|
|
86306
|
+
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/browser/axios.cjs"));
|
|
86307
|
+
var Utils_1 = __webpack_require__(/*! ../Utils */ "./src/walletSdk/Utils/index.ts");
|
|
86255
86308
|
var ServerRequestFailedError = /** @class */ (function (_super) {
|
|
86256
86309
|
__extends(ServerRequestFailedError, _super);
|
|
86257
86310
|
function ServerRequestFailedError(e) {
|
|
86258
|
-
var _this =
|
|
86311
|
+
var _this = this;
|
|
86312
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
86313
|
+
var errorData = (0, Utils_1.extractAxiosErrorData)(e);
|
|
86314
|
+
var message = errorData.responseData && Object.keys(errorData.responseData).length > 0
|
|
86315
|
+
? JSON.stringify(errorData.responseData)
|
|
86316
|
+
: errorData.statusText;
|
|
86317
|
+
_this = _super.call(this, "Server request failed with error: ".concat(errorData.status, " ").concat(message)) || this;
|
|
86318
|
+
_this.data = errorData;
|
|
86319
|
+
}
|
|
86320
|
+
else {
|
|
86321
|
+
_this = _super.call(this, "Server request failed with error: ".concat(e)) || this;
|
|
86322
|
+
}
|
|
86259
86323
|
Object.setPrototypeOf(_this, ServerRequestFailedError.prototype);
|
|
86260
86324
|
return _this;
|
|
86261
86325
|
}
|
|
@@ -86432,6 +86496,16 @@ var WithdrawalTxMissingMemoError = /** @class */ (function (_super) {
|
|
|
86432
86496
|
return WithdrawalTxMissingMemoError;
|
|
86433
86497
|
}(Error));
|
|
86434
86498
|
exports.WithdrawalTxMissingMemoError = WithdrawalTxMissingMemoError;
|
|
86499
|
+
var PathPayOnlyOneAmountError = /** @class */ (function (_super) {
|
|
86500
|
+
__extends(PathPayOnlyOneAmountError, _super);
|
|
86501
|
+
function PathPayOnlyOneAmountError() {
|
|
86502
|
+
var _this = _super.call(this, "Must give sendAmount or destAmount value, but not both") || this;
|
|
86503
|
+
Object.setPrototypeOf(_this, PathPayOnlyOneAmountError.prototype);
|
|
86504
|
+
return _this;
|
|
86505
|
+
}
|
|
86506
|
+
return PathPayOnlyOneAmountError;
|
|
86507
|
+
}(Error));
|
|
86508
|
+
exports.PathPayOnlyOneAmountError = PathPayOnlyOneAmountError;
|
|
86435
86509
|
var WithdrawalTxMemoError = /** @class */ (function (_super) {
|
|
86436
86510
|
__extends(WithdrawalTxMemoError, _super);
|
|
86437
86511
|
function WithdrawalTxMemoError() {
|
|
@@ -86840,6 +86914,140 @@ var Stellar = /** @class */ (function () {
|
|
|
86840
86914
|
exports.Stellar = Stellar;
|
|
86841
86915
|
|
|
86842
86916
|
|
|
86917
|
+
/***/ }),
|
|
86918
|
+
|
|
86919
|
+
/***/ "./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts":
|
|
86920
|
+
/*!***********************************************************************!*\
|
|
86921
|
+
!*** ./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts ***!
|
|
86922
|
+
\***********************************************************************/
|
|
86923
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
86924
|
+
|
|
86925
|
+
"use strict";
|
|
86926
|
+
|
|
86927
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
86928
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
86929
|
+
};
|
|
86930
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
86931
|
+
exports.CommonTransactionBuilder = void 0;
|
|
86932
|
+
var stellar_sdk_1 = __importDefault(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/dist/stellar-sdk.js"));
|
|
86933
|
+
var CommonTransactionBuilder = /** @class */ (function () {
|
|
86934
|
+
function CommonTransactionBuilder(sourceAddress, operations) {
|
|
86935
|
+
this.sourceAddress = sourceAddress;
|
|
86936
|
+
this.operations = operations;
|
|
86937
|
+
}
|
|
86938
|
+
CommonTransactionBuilder.prototype.addAssetSupport = function (asset, trustLimit) {
|
|
86939
|
+
this.operations.push(stellar_sdk_1.default.Operation.changeTrust({
|
|
86940
|
+
asset: asset.toAsset(),
|
|
86941
|
+
limit: trustLimit,
|
|
86942
|
+
source: this.sourceAddress,
|
|
86943
|
+
}));
|
|
86944
|
+
return this;
|
|
86945
|
+
};
|
|
86946
|
+
CommonTransactionBuilder.prototype.removeAssetSupport = function (asset) {
|
|
86947
|
+
return this.addAssetSupport(asset, "0");
|
|
86948
|
+
};
|
|
86949
|
+
CommonTransactionBuilder.prototype.addAccountSigner = function (signerAddress, signerWeight) {
|
|
86950
|
+
this.operations.push(stellar_sdk_1.default.Operation.setOptions({
|
|
86951
|
+
source: this.sourceAddress,
|
|
86952
|
+
signer: {
|
|
86953
|
+
ed25519PublicKey: signerAddress.publicKey,
|
|
86954
|
+
weight: signerWeight,
|
|
86955
|
+
},
|
|
86956
|
+
}));
|
|
86957
|
+
return this;
|
|
86958
|
+
};
|
|
86959
|
+
CommonTransactionBuilder.prototype.removeAccountSigner = function (signerAddress) {
|
|
86960
|
+
return this.addAccountSigner(signerAddress, 0);
|
|
86961
|
+
};
|
|
86962
|
+
CommonTransactionBuilder.prototype.lockAccountMasterKey = function () {
|
|
86963
|
+
this.operations.push(stellar_sdk_1.default.Operation.setOptions({
|
|
86964
|
+
source: this.sourceAddress,
|
|
86965
|
+
masterWeight: 0,
|
|
86966
|
+
}));
|
|
86967
|
+
return this;
|
|
86968
|
+
};
|
|
86969
|
+
CommonTransactionBuilder.prototype.setThreshold = function (_a) {
|
|
86970
|
+
var low = _a.low, medium = _a.medium, high = _a.high;
|
|
86971
|
+
this.operations.push(stellar_sdk_1.default.Operation.setOptions({
|
|
86972
|
+
source: this.sourceAddress,
|
|
86973
|
+
lowThreshold: low,
|
|
86974
|
+
medThreshold: medium,
|
|
86975
|
+
highThreshold: high,
|
|
86976
|
+
}));
|
|
86977
|
+
return this;
|
|
86978
|
+
};
|
|
86979
|
+
return CommonTransactionBuilder;
|
|
86980
|
+
}());
|
|
86981
|
+
exports.CommonTransactionBuilder = CommonTransactionBuilder;
|
|
86982
|
+
|
|
86983
|
+
|
|
86984
|
+
/***/ }),
|
|
86985
|
+
|
|
86986
|
+
/***/ "./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts":
|
|
86987
|
+
/*!****************************************************************!*\
|
|
86988
|
+
!*** ./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts ***!
|
|
86989
|
+
\****************************************************************/
|
|
86990
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
86991
|
+
|
|
86992
|
+
"use strict";
|
|
86993
|
+
|
|
86994
|
+
var __extends = (this && this.__extends) || (function () {
|
|
86995
|
+
var extendStatics = function (d, b) {
|
|
86996
|
+
extendStatics = Object.setPrototypeOf ||
|
|
86997
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
86998
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
86999
|
+
return extendStatics(d, b);
|
|
87000
|
+
};
|
|
87001
|
+
return function (d, b) {
|
|
87002
|
+
if (typeof b !== "function" && b !== null)
|
|
87003
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
87004
|
+
extendStatics(d, b);
|
|
87005
|
+
function __() { this.constructor = d; }
|
|
87006
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
87007
|
+
};
|
|
87008
|
+
})();
|
|
87009
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
87010
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87011
|
+
};
|
|
87012
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
87013
|
+
exports.SponsoringBuilder = void 0;
|
|
87014
|
+
var stellar_sdk_1 = __importDefault(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/dist/stellar-sdk.js"));
|
|
87015
|
+
var CommonTransactionBuilder_1 = __webpack_require__(/*! ./CommonTransactionBuilder */ "./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts");
|
|
87016
|
+
var SponsoringBuilder = /** @class */ (function (_super) {
|
|
87017
|
+
__extends(SponsoringBuilder, _super);
|
|
87018
|
+
function SponsoringBuilder(sponsoredAddress, sponsorAccount, operations, buildingFunction) {
|
|
87019
|
+
var _this = _super.call(this, sponsoredAddress, operations) || this;
|
|
87020
|
+
_this.sponsorAccount = sponsorAccount;
|
|
87021
|
+
_this.startSponsoring();
|
|
87022
|
+
buildingFunction(_this);
|
|
87023
|
+
_this.stopSponsoring();
|
|
87024
|
+
return _this;
|
|
87025
|
+
}
|
|
87026
|
+
SponsoringBuilder.prototype.createAccount = function (newAccount, startingBalance) {
|
|
87027
|
+
if (startingBalance === void 0) { startingBalance = 0; }
|
|
87028
|
+
this.operations.push(stellar_sdk_1.default.Operation.createAccount({
|
|
87029
|
+
destination: newAccount.publicKey,
|
|
87030
|
+
startingBalance: startingBalance.toString(),
|
|
87031
|
+
source: this.sponsorAccount.publicKey,
|
|
87032
|
+
}));
|
|
87033
|
+
return this;
|
|
87034
|
+
};
|
|
87035
|
+
SponsoringBuilder.prototype.startSponsoring = function () {
|
|
87036
|
+
this.operations.push(stellar_sdk_1.default.Operation.beginSponsoringFutureReserves({
|
|
87037
|
+
sponsoredId: this.sourceAddress,
|
|
87038
|
+
source: this.sponsorAccount.publicKey,
|
|
87039
|
+
}));
|
|
87040
|
+
};
|
|
87041
|
+
SponsoringBuilder.prototype.stopSponsoring = function () {
|
|
87042
|
+
this.operations.push(stellar_sdk_1.default.Operation.endSponsoringFutureReserves({
|
|
87043
|
+
source: this.sourceAddress,
|
|
87044
|
+
}));
|
|
87045
|
+
};
|
|
87046
|
+
return SponsoringBuilder;
|
|
87047
|
+
}(CommonTransactionBuilder_1.CommonTransactionBuilder));
|
|
87048
|
+
exports.SponsoringBuilder = SponsoringBuilder;
|
|
87049
|
+
|
|
87050
|
+
|
|
86843
87051
|
/***/ }),
|
|
86844
87052
|
|
|
86845
87053
|
/***/ "./src/walletSdk/Horizon/Transaction/TransactionBuilder.ts":
|
|
@@ -86850,6 +87058,21 @@ exports.Stellar = Stellar;
|
|
|
86850
87058
|
|
|
86851
87059
|
"use strict";
|
|
86852
87060
|
|
|
87061
|
+
var __extends = (this && this.__extends) || (function () {
|
|
87062
|
+
var extendStatics = function (d, b) {
|
|
87063
|
+
extendStatics = Object.setPrototypeOf ||
|
|
87064
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
87065
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
87066
|
+
return extendStatics(d, b);
|
|
87067
|
+
};
|
|
87068
|
+
return function (d, b) {
|
|
87069
|
+
if (typeof b !== "function" && b !== null)
|
|
87070
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
87071
|
+
extendStatics(d, b);
|
|
87072
|
+
function __() { this.constructor = d; }
|
|
87073
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
87074
|
+
};
|
|
87075
|
+
})();
|
|
86853
87076
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
86854
87077
|
if (k2 === undefined) k2 = k;
|
|
86855
87078
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -86878,21 +87101,28 @@ exports.TransactionBuilder = void 0;
|
|
|
86878
87101
|
var stellar_sdk_1 = __importStar(__webpack_require__(/*! stellar-sdk */ "./node_modules/stellar-sdk/dist/stellar-sdk.js"));
|
|
86879
87102
|
var Exceptions_1 = __webpack_require__(/*! ../../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
86880
87103
|
var Types_1 = __webpack_require__(/*! ../../Types */ "./src/walletSdk/Types/index.ts");
|
|
86881
|
-
var
|
|
87104
|
+
var Exceptions_2 = __webpack_require__(/*! ../../Exceptions */ "./src/walletSdk/Exceptions/index.ts");
|
|
87105
|
+
var CommonTransactionBuilder_1 = __webpack_require__(/*! ./CommonTransactionBuilder */ "./src/walletSdk/Horizon/Transaction/CommonTransactionBuilder.ts");
|
|
87106
|
+
var SponsoringBuilder_1 = __webpack_require__(/*! ./SponsoringBuilder */ "./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts");
|
|
87107
|
+
var TransactionBuilder = /** @class */ (function (_super) {
|
|
87108
|
+
__extends(TransactionBuilder, _super);
|
|
86882
87109
|
function TransactionBuilder(cfg, sourceAccount, baseFee, memo, timebounds) {
|
|
86883
|
-
|
|
86884
|
-
|
|
86885
|
-
this.builder = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
|
|
87110
|
+
var _this = _super.call(this, sourceAccount.accountId(), []) || this;
|
|
87111
|
+
_this.builder = new stellar_sdk_1.TransactionBuilder(sourceAccount, {
|
|
86886
87112
|
fee: baseFee ? baseFee.toString() : cfg.stellar.baseFee.toString(),
|
|
86887
87113
|
timebounds: timebounds,
|
|
86888
87114
|
memo: memo,
|
|
86889
87115
|
networkPassphrase: cfg.stellar.network,
|
|
86890
87116
|
});
|
|
86891
87117
|
if (!timebounds) {
|
|
86892
|
-
|
|
87118
|
+
_this.builder.setTimeout(cfg.stellar.defaultTimeout);
|
|
86893
87119
|
}
|
|
86894
|
-
|
|
87120
|
+
return _this;
|
|
86895
87121
|
}
|
|
87122
|
+
TransactionBuilder.prototype.sponsoring = function (sponsorAccount, buildingFunction, sponsoredAccount) {
|
|
87123
|
+
new SponsoringBuilder_1.SponsoringBuilder(sponsoredAccount ? sponsoredAccount.publicKey : this.sourceAddress, sponsorAccount, this.operations, buildingFunction);
|
|
87124
|
+
return this;
|
|
87125
|
+
};
|
|
86896
87126
|
TransactionBuilder.prototype.createAccount = function (newAccount, startingBalance) {
|
|
86897
87127
|
if (startingBalance === void 0) { startingBalance = 1; }
|
|
86898
87128
|
if (startingBalance < 1) {
|
|
@@ -86901,7 +87131,7 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
86901
87131
|
this.operations.push(stellar_sdk_1.default.Operation.createAccount({
|
|
86902
87132
|
destination: newAccount.publicKey,
|
|
86903
87133
|
startingBalance: startingBalance.toString(),
|
|
86904
|
-
source: this.
|
|
87134
|
+
source: this.sourceAddress,
|
|
86905
87135
|
}));
|
|
86906
87136
|
return this;
|
|
86907
87137
|
};
|
|
@@ -86913,6 +87143,73 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
86913
87143
|
}));
|
|
86914
87144
|
return this;
|
|
86915
87145
|
};
|
|
87146
|
+
/**
|
|
87147
|
+
* Creates and adds a path payment operation to the transaction builder.
|
|
87148
|
+
*
|
|
87149
|
+
* @param {string} destinationAddress - The destination Stellar address to which the payment is sent.
|
|
87150
|
+
* @param {StellarAssetId} sendAsset - The asset to be sent.
|
|
87151
|
+
* @param {StellarAssetId} destAsset - The asset the destination will receive.
|
|
87152
|
+
* @param {string} [sendAmount] - The amount to be sent. Must specify either sendAmount or destAmount,
|
|
87153
|
+
* but not both.
|
|
87154
|
+
* @param {string} [destAmount] - The amount to be received by the destination. Must specify either sendAmount or destAmount,
|
|
87155
|
+
* but not both.
|
|
87156
|
+
* @param {string} [destMin] - The minimum amount of the destination asset to be receive. This is a
|
|
87157
|
+
* protective measure, it allows you to specify a lower bound for an acceptable conversion. Only used
|
|
87158
|
+
* if using sendAmount.
|
|
87159
|
+
* (optional, default is ".0000001").
|
|
87160
|
+
* @param {string} [sendMax] - The maximum amount of the destination asset to be sent. This is a
|
|
87161
|
+
* protective measure, it allows you to specify an upper bound for an acceptable conversion. Only used
|
|
87162
|
+
* if using destAmount.
|
|
87163
|
+
* (optional, default is int64 max).
|
|
87164
|
+
*
|
|
87165
|
+
* @returns {TransactionBuilder} - Returns the current TransactionBuilder instance for method chaining.
|
|
87166
|
+
*/
|
|
87167
|
+
TransactionBuilder.prototype.pathPay = function (_a) {
|
|
87168
|
+
var destinationAddress = _a.destinationAddress, sendAsset = _a.sendAsset, destAsset = _a.destAsset, sendAmount = _a.sendAmount, destAmount = _a.destAmount, destMin = _a.destMin, sendMax = _a.sendMax;
|
|
87169
|
+
if ((sendAmount && destAmount) || (!sendAmount && !destAmount)) {
|
|
87170
|
+
throw new Exceptions_2.PathPayOnlyOneAmountError();
|
|
87171
|
+
}
|
|
87172
|
+
if (sendAmount) {
|
|
87173
|
+
this.operations.push(stellar_sdk_1.default.Operation.pathPaymentStrictSend({
|
|
87174
|
+
destination: destinationAddress,
|
|
87175
|
+
sendAsset: sendAsset.toAsset(),
|
|
87176
|
+
sendAmount: sendAmount,
|
|
87177
|
+
destAsset: destAsset.toAsset(),
|
|
87178
|
+
destMin: destMin || ".0000001",
|
|
87179
|
+
}));
|
|
87180
|
+
}
|
|
87181
|
+
else {
|
|
87182
|
+
this.operations.push(stellar_sdk_1.default.Operation.pathPaymentStrictReceive({
|
|
87183
|
+
destination: destinationAddress,
|
|
87184
|
+
sendAsset: sendAsset.toAsset(),
|
|
87185
|
+
destAmount: destAmount,
|
|
87186
|
+
destAsset: destAsset.toAsset(),
|
|
87187
|
+
sendMax: sendMax || "922337203685.4775807",
|
|
87188
|
+
}));
|
|
87189
|
+
}
|
|
87190
|
+
return this;
|
|
87191
|
+
};
|
|
87192
|
+
/**
|
|
87193
|
+
* Swap assets using the Stellar network. This swaps using the
|
|
87194
|
+
* pathPaymentStrictReceive operation.
|
|
87195
|
+
*
|
|
87196
|
+
* @param {StellarAssetId} fromAsset - The source asset to be sent.
|
|
87197
|
+
* @param {StellarAssetId} toAsset - The destination asset to receive.
|
|
87198
|
+
* @param {string} amount - The amount of the source asset to be sent.
|
|
87199
|
+
* @param {string} [destMin] - (Optional) The minimum amount of the destination asset to be received.
|
|
87200
|
+
*
|
|
87201
|
+
* @returns {TransactionBuilder} Returns the current instance of the TransactionBuilder for method chaining.
|
|
87202
|
+
*/
|
|
87203
|
+
TransactionBuilder.prototype.swap = function (fromAsset, toAsset, amount, destMin) {
|
|
87204
|
+
this.pathPay({
|
|
87205
|
+
destinationAddress: this.sourceAddress,
|
|
87206
|
+
sendAsset: fromAsset,
|
|
87207
|
+
destAsset: toAsset,
|
|
87208
|
+
sendAmount: amount,
|
|
87209
|
+
destMin: destMin,
|
|
87210
|
+
});
|
|
87211
|
+
return this;
|
|
87212
|
+
};
|
|
86916
87213
|
TransactionBuilder.prototype.addOperation = function (op) {
|
|
86917
87214
|
this.builder.addOperation(op);
|
|
86918
87215
|
return this;
|
|
@@ -86921,24 +87218,6 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
86921
87218
|
this.builder.addMemo(memo);
|
|
86922
87219
|
return this;
|
|
86923
87220
|
};
|
|
86924
|
-
TransactionBuilder.prototype.addAssetSupport = function (asset, trustLimit) {
|
|
86925
|
-
this.operations.push(stellar_sdk_1.default.Operation.changeTrust({
|
|
86926
|
-
asset: asset.toAsset(),
|
|
86927
|
-
limit: trustLimit,
|
|
86928
|
-
source: this.sourceAccount,
|
|
86929
|
-
}));
|
|
86930
|
-
return this;
|
|
86931
|
-
};
|
|
86932
|
-
TransactionBuilder.prototype.removeAssetSupport = function (asset) {
|
|
86933
|
-
return this.addAssetSupport(asset, "0");
|
|
86934
|
-
};
|
|
86935
|
-
TransactionBuilder.prototype.build = function () {
|
|
86936
|
-
var _this = this;
|
|
86937
|
-
this.operations.forEach(function (op) {
|
|
86938
|
-
_this.builder.addOperation(op);
|
|
86939
|
-
});
|
|
86940
|
-
return this.builder.build();
|
|
86941
|
-
};
|
|
86942
87221
|
TransactionBuilder.prototype.transferWithdrawalTransaction = function (transaction, assetId) {
|
|
86943
87222
|
if (transaction.status !== Types_1.TransactionStatus.pending_user_transfer_start) {
|
|
86944
87223
|
throw new Exceptions_1.WithdrawalTxNotPendingUserTransferStartError(transaction.status);
|
|
@@ -86961,8 +87240,15 @@ var TransactionBuilder = /** @class */ (function () {
|
|
|
86961
87240
|
}
|
|
86962
87241
|
return this.transfer(transaction.withdraw_anchor_account, assetId, transaction.amount_in);
|
|
86963
87242
|
};
|
|
87243
|
+
TransactionBuilder.prototype.build = function () {
|
|
87244
|
+
var _this = this;
|
|
87245
|
+
this.operations.forEach(function (op) {
|
|
87246
|
+
_this.builder.addOperation(op);
|
|
87247
|
+
});
|
|
87248
|
+
return this.builder.build();
|
|
87249
|
+
};
|
|
86964
87250
|
return TransactionBuilder;
|
|
86965
|
-
}());
|
|
87251
|
+
}(CommonTransactionBuilder_1.CommonTransactionBuilder));
|
|
86966
87252
|
exports.TransactionBuilder = TransactionBuilder;
|
|
86967
87253
|
|
|
86968
87254
|
|
|
@@ -86977,7 +87263,7 @@ exports.TransactionBuilder = TransactionBuilder;
|
|
|
86977
87263
|
"use strict";
|
|
86978
87264
|
|
|
86979
87265
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
86980
|
-
exports.TransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = void 0;
|
|
87266
|
+
exports.SponsoringBuilder = exports.TransactionBuilder = exports.Stellar = exports.AccountService = exports.SigningKeypair = exports.PublicKeypair = void 0;
|
|
86981
87267
|
var Account_1 = __webpack_require__(/*! ./Account */ "./src/walletSdk/Horizon/Account.ts");
|
|
86982
87268
|
Object.defineProperty(exports, "PublicKeypair", ({ enumerable: true, get: function () { return Account_1.PublicKeypair; } }));
|
|
86983
87269
|
Object.defineProperty(exports, "SigningKeypair", ({ enumerable: true, get: function () { return Account_1.SigningKeypair; } }));
|
|
@@ -86987,6 +87273,8 @@ var Stellar_1 = __webpack_require__(/*! ./Stellar */ "./src/walletSdk/Horizon/St
|
|
|
86987
87273
|
Object.defineProperty(exports, "Stellar", ({ enumerable: true, get: function () { return Stellar_1.Stellar; } }));
|
|
86988
87274
|
var TransactionBuilder_1 = __webpack_require__(/*! ./Transaction/TransactionBuilder */ "./src/walletSdk/Horizon/Transaction/TransactionBuilder.ts");
|
|
86989
87275
|
Object.defineProperty(exports, "TransactionBuilder", ({ enumerable: true, get: function () { return TransactionBuilder_1.TransactionBuilder; } }));
|
|
87276
|
+
var SponsoringBuilder_1 = __webpack_require__(/*! ./Transaction/SponsoringBuilder */ "./src/walletSdk/Horizon/Transaction/SponsoringBuilder.ts");
|
|
87277
|
+
Object.defineProperty(exports, "SponsoringBuilder", ({ enumerable: true, get: function () { return SponsoringBuilder_1.SponsoringBuilder; } }));
|
|
86990
87278
|
|
|
86991
87279
|
|
|
86992
87280
|
/***/ }),
|
|
@@ -87242,6 +87530,49 @@ var camelToSnakeCaseObject = function (obj) {
|
|
|
87242
87530
|
exports.camelToSnakeCaseObject = camelToSnakeCaseObject;
|
|
87243
87531
|
|
|
87244
87532
|
|
|
87533
|
+
/***/ }),
|
|
87534
|
+
|
|
87535
|
+
/***/ "./src/walletSdk/Utils/extractAxiosErrorData.ts":
|
|
87536
|
+
/*!******************************************************!*\
|
|
87537
|
+
!*** ./src/walletSdk/Utils/extractAxiosErrorData.ts ***!
|
|
87538
|
+
\******************************************************/
|
|
87539
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
87540
|
+
|
|
87541
|
+
"use strict";
|
|
87542
|
+
|
|
87543
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
87544
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
87545
|
+
};
|
|
87546
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
87547
|
+
exports.extractAxiosErrorData = void 0;
|
|
87548
|
+
var axios_1 = __importDefault(__webpack_require__(/*! axios */ "./node_modules/axios/dist/browser/axios.cjs"));
|
|
87549
|
+
// Based on https://axios-http.com/docs/handling_errors
|
|
87550
|
+
var extractAxiosErrorData = function (error) {
|
|
87551
|
+
if (!axios_1.default.isAxiosError(error)) {
|
|
87552
|
+
return { responseData: JSON.stringify(error) };
|
|
87553
|
+
}
|
|
87554
|
+
if (error.response) {
|
|
87555
|
+
return {
|
|
87556
|
+
status: error.response.status,
|
|
87557
|
+
statusText: error.response.statusText,
|
|
87558
|
+
responseData: error.response.data,
|
|
87559
|
+
headers: error.response.headers,
|
|
87560
|
+
};
|
|
87561
|
+
}
|
|
87562
|
+
else if (error.request) {
|
|
87563
|
+
// The request was made but no response was received
|
|
87564
|
+
return {
|
|
87565
|
+
statusText: "No response received from request: ".concat(JSON.stringify(error.request)),
|
|
87566
|
+
};
|
|
87567
|
+
}
|
|
87568
|
+
else {
|
|
87569
|
+
// Something happened in setting up the request that triggered an Error
|
|
87570
|
+
return { statusText: "Failed request with error: ".concat(error.message) };
|
|
87571
|
+
}
|
|
87572
|
+
};
|
|
87573
|
+
exports.extractAxiosErrorData = extractAxiosErrorData;
|
|
87574
|
+
|
|
87575
|
+
|
|
87245
87576
|
/***/ }),
|
|
87246
87577
|
|
|
87247
87578
|
/***/ "./src/walletSdk/Utils/getResultCode.ts":
|
|
@@ -87292,6 +87623,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
87292
87623
|
__exportStar(__webpack_require__(/*! ./camelToSnakeCase */ "./src/walletSdk/Utils/camelToSnakeCase.ts"), exports);
|
|
87293
87624
|
__exportStar(__webpack_require__(/*! ./toml */ "./src/walletSdk/Utils/toml.ts"), exports);
|
|
87294
87625
|
__exportStar(__webpack_require__(/*! ./url */ "./src/walletSdk/Utils/url.ts"), exports);
|
|
87626
|
+
__exportStar(__webpack_require__(/*! ./extractAxiosErrorData */ "./src/walletSdk/Utils/extractAxiosErrorData.ts"), exports);
|
|
87295
87627
|
|
|
87296
87628
|
|
|
87297
87629
|
/***/ }),
|
|
@@ -87831,9 +88163,10 @@ exports.DefaultClient = axios_1.default.create({
|
|
|
87831
88163
|
headers: __assign({}, walletHeaders),
|
|
87832
88164
|
});
|
|
87833
88165
|
var ApplicationConfiguration = /** @class */ (function () {
|
|
87834
|
-
function ApplicationConfiguration(defaultSigner, defaultClient) {
|
|
88166
|
+
function ApplicationConfiguration(defaultSigner, defaultClient, defaultClientDomain) {
|
|
87835
88167
|
this.defaultSigner = defaultSigner || Auth_1.DefaultSigner;
|
|
87836
88168
|
this.defaultClient = defaultClient || exports.DefaultClient;
|
|
88169
|
+
this.defaultClientDomain = defaultClientDomain;
|
|
87837
88170
|
}
|
|
87838
88171
|
return ApplicationConfiguration;
|
|
87839
88172
|
}());
|
|
@@ -93232,7 +93565,7 @@ module.exports = JSON.parse('{"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1
|
|
|
93232
93565
|
/***/ ((module) => {
|
|
93233
93566
|
|
|
93234
93567
|
"use strict";
|
|
93235
|
-
module.exports = JSON.parse('{"name":"@stellar/typescript-wallet-sdk","version":"1.1
|
|
93568
|
+
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"}}');
|
|
93236
93569
|
|
|
93237
93570
|
/***/ })
|
|
93238
93571
|
|