@stellar/stellar-sdk 14.4.3 → 14.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -0
- package/bin/stellar-js +4 -0
- package/dist/stellar-sdk-minimal.js +11450 -10315
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +7459 -6324
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +11597 -10483
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +10647 -9533
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/bindings/client.d.ts +30 -0
- package/lib/bindings/client.js +134 -0
- package/lib/bindings/config.d.ts +34 -0
- package/lib/bindings/config.js +83 -0
- package/lib/bindings/generator.d.ts +176 -0
- package/lib/bindings/generator.js +131 -0
- package/lib/bindings/index.d.ts +6 -0
- package/lib/bindings/index.js +75 -0
- package/lib/bindings/sac-spec.d.ts +1 -0
- package/lib/bindings/sac-spec.js +7 -0
- package/lib/bindings/types.d.ts +66 -0
- package/lib/bindings/types.js +184 -0
- package/lib/bindings/utils.d.ts +49 -0
- package/lib/bindings/utils.js +223 -0
- package/lib/bindings/wasm_fetcher.d.ts +25 -0
- package/lib/bindings/wasm_fetcher.js +225 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +171 -0
- package/lib/cli/util.d.ts +55 -0
- package/lib/cli/util.js +254 -0
- package/lib/contract/client.js +2 -1
- package/lib/horizon/call_builder.js +30 -6
- package/lib/horizon/horizon_axios_client.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +9 -1
- package/lib/minimal/bindings/client.d.ts +30 -0
- package/lib/minimal/bindings/client.js +134 -0
- package/lib/minimal/bindings/config.d.ts +34 -0
- package/lib/minimal/bindings/config.js +83 -0
- package/lib/minimal/bindings/generator.d.ts +176 -0
- package/lib/minimal/bindings/generator.js +131 -0
- package/lib/minimal/bindings/index.d.ts +6 -0
- package/lib/minimal/bindings/index.js +75 -0
- package/lib/minimal/bindings/sac-spec.d.ts +1 -0
- package/lib/minimal/bindings/sac-spec.js +7 -0
- package/lib/minimal/bindings/types.d.ts +66 -0
- package/lib/minimal/bindings/types.js +184 -0
- package/lib/minimal/bindings/utils.d.ts +49 -0
- package/lib/minimal/bindings/utils.js +223 -0
- package/lib/minimal/bindings/wasm_fetcher.d.ts +25 -0
- package/lib/minimal/bindings/wasm_fetcher.js +225 -0
- package/lib/minimal/cli/index.d.ts +2 -0
- package/lib/minimal/cli/index.js +171 -0
- package/lib/minimal/cli/util.d.ts +55 -0
- package/lib/minimal/cli/util.js +254 -0
- package/lib/minimal/contract/client.js +2 -1
- package/lib/minimal/horizon/call_builder.js +30 -6
- package/lib/minimal/horizon/horizon_axios_client.js +1 -1
- package/lib/minimal/index.d.ts +1 -0
- package/lib/minimal/index.js +9 -1
- package/lib/minimal/rpc/axios.js +1 -1
- package/lib/minimal/rpc/server.d.ts +35 -1
- package/lib/minimal/rpc/server.js +110 -43
- package/lib/minimal/stellartoml/index.d.ts +3 -0
- package/lib/no-axios/bindings/client.d.ts +30 -0
- package/lib/no-axios/bindings/client.js +134 -0
- package/lib/no-axios/bindings/config.d.ts +34 -0
- package/lib/no-axios/bindings/config.js +83 -0
- package/lib/no-axios/bindings/generator.d.ts +176 -0
- package/lib/no-axios/bindings/generator.js +131 -0
- package/lib/no-axios/bindings/index.d.ts +6 -0
- package/lib/no-axios/bindings/index.js +75 -0
- package/lib/no-axios/bindings/sac-spec.d.ts +1 -0
- package/lib/no-axios/bindings/sac-spec.js +7 -0
- package/lib/no-axios/bindings/types.d.ts +66 -0
- package/lib/no-axios/bindings/types.js +184 -0
- package/lib/no-axios/bindings/utils.d.ts +49 -0
- package/lib/no-axios/bindings/utils.js +223 -0
- package/lib/no-axios/bindings/wasm_fetcher.d.ts +25 -0
- package/lib/no-axios/bindings/wasm_fetcher.js +225 -0
- package/lib/no-axios/cli/index.d.ts +2 -0
- package/lib/no-axios/cli/index.js +171 -0
- package/lib/no-axios/cli/util.d.ts +55 -0
- package/lib/no-axios/cli/util.js +254 -0
- package/lib/no-axios/contract/client.js +2 -1
- package/lib/no-axios/horizon/call_builder.js +30 -6
- package/lib/no-axios/horizon/horizon_axios_client.js +1 -1
- package/lib/no-axios/index.d.ts +1 -0
- package/lib/no-axios/index.js +9 -1
- package/lib/no-axios/rpc/axios.js +1 -1
- package/lib/no-axios/rpc/server.d.ts +35 -1
- package/lib/no-axios/rpc/server.js +110 -43
- package/lib/no-axios/stellartoml/index.d.ts +3 -0
- package/lib/no-eventsource/bindings/client.d.ts +30 -0
- package/lib/no-eventsource/bindings/client.js +134 -0
- package/lib/no-eventsource/bindings/config.d.ts +34 -0
- package/lib/no-eventsource/bindings/config.js +83 -0
- package/lib/no-eventsource/bindings/generator.d.ts +176 -0
- package/lib/no-eventsource/bindings/generator.js +131 -0
- package/lib/no-eventsource/bindings/index.d.ts +6 -0
- package/lib/no-eventsource/bindings/index.js +75 -0
- package/lib/no-eventsource/bindings/sac-spec.d.ts +1 -0
- package/lib/no-eventsource/bindings/sac-spec.js +7 -0
- package/lib/no-eventsource/bindings/types.d.ts +66 -0
- package/lib/no-eventsource/bindings/types.js +184 -0
- package/lib/no-eventsource/bindings/utils.d.ts +49 -0
- package/lib/no-eventsource/bindings/utils.js +223 -0
- package/lib/no-eventsource/bindings/wasm_fetcher.d.ts +25 -0
- package/lib/no-eventsource/bindings/wasm_fetcher.js +225 -0
- package/lib/no-eventsource/cli/index.d.ts +2 -0
- package/lib/no-eventsource/cli/index.js +171 -0
- package/lib/no-eventsource/cli/util.d.ts +55 -0
- package/lib/no-eventsource/cli/util.js +254 -0
- package/lib/no-eventsource/contract/client.js +2 -1
- package/lib/no-eventsource/horizon/call_builder.js +30 -6
- package/lib/no-eventsource/horizon/horizon_axios_client.js +1 -1
- package/lib/no-eventsource/index.d.ts +1 -0
- package/lib/no-eventsource/index.js +9 -1
- package/lib/no-eventsource/rpc/axios.js +1 -1
- package/lib/no-eventsource/rpc/server.d.ts +35 -1
- package/lib/no-eventsource/rpc/server.js +110 -43
- package/lib/no-eventsource/stellartoml/index.d.ts +3 -0
- package/lib/rpc/axios.js +1 -1
- package/lib/rpc/server.d.ts +35 -1
- package/lib/rpc/server.js +110 -43
- package/lib/stellartoml/index.d.ts +3 -0
- package/package.json +10 -4
- package/CHANGELOG.md +0 -2023
|
@@ -12,7 +12,7 @@ var _api = require("./api");
|
|
|
12
12
|
var _transaction = require("./transaction");
|
|
13
13
|
var _parsers = require("./parsers");
|
|
14
14
|
var _utils = require("../utils");
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t1 in e) "default" !== _t1 && {}.hasOwnProperty.call(e, _t1) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t1)) && (i.get || i.set) ? o(f, _t1, i) : f[_t1] = e[_t1]); return f; })(e, t); }
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
18
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -899,15 +899,82 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
899
899
|
return requestAirdrop;
|
|
900
900
|
}())
|
|
901
901
|
}, {
|
|
902
|
-
key: "
|
|
902
|
+
key: "fundAddress",
|
|
903
903
|
value: (function () {
|
|
904
|
-
var
|
|
904
|
+
var _fundAddress = _asyncToGenerator(_regenerator().m(function _callee24(address, friendbotUrl) {
|
|
905
|
+
var response, txResponse, _error$response2, _error$response$data$, _error$response$data, _t8, _t9;
|
|
905
906
|
return _regenerator().w(function (_context24) {
|
|
906
|
-
while (1) switch (_context24.n) {
|
|
907
|
+
while (1) switch (_context24.p = _context24.n) {
|
|
907
908
|
case 0:
|
|
908
|
-
|
|
909
|
+
if (!(!_stellarBase.StrKey.isValidEd25519PublicKey(address) && !_stellarBase.StrKey.isValidContract(address))) {
|
|
910
|
+
_context24.n = 1;
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
throw new Error("Invalid address: ".concat(address, ". Expected a Stellar account (G...) or contract (C...) address."));
|
|
914
|
+
case 1:
|
|
915
|
+
_t8 = friendbotUrl;
|
|
916
|
+
if (_t8) {
|
|
917
|
+
_context24.n = 3;
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
_context24.n = 2;
|
|
921
|
+
return this.getNetwork();
|
|
922
|
+
case 2:
|
|
923
|
+
_t8 = _context24.v.friendbotUrl;
|
|
924
|
+
case 3:
|
|
925
|
+
friendbotUrl = _t8;
|
|
926
|
+
if (friendbotUrl) {
|
|
927
|
+
_context24.n = 4;
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
throw new Error("No friendbot URL configured for current network");
|
|
931
|
+
case 4:
|
|
932
|
+
_context24.p = 4;
|
|
933
|
+
_context24.n = 5;
|
|
934
|
+
return this.httpClient.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(address)));
|
|
935
|
+
case 5:
|
|
936
|
+
response = _context24.v;
|
|
937
|
+
_context24.n = 6;
|
|
938
|
+
return this.getTransaction(response.data.hash);
|
|
939
|
+
case 6:
|
|
940
|
+
txResponse = _context24.v;
|
|
941
|
+
if (!(txResponse.status !== _api.Api.GetTransactionStatus.SUCCESS)) {
|
|
942
|
+
_context24.n = 7;
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
throw new Error("Funding address ".concat(address, " failed: transaction status ").concat(txResponse.status));
|
|
946
|
+
case 7:
|
|
947
|
+
return _context24.a(2, txResponse);
|
|
948
|
+
case 8:
|
|
949
|
+
_context24.p = 8;
|
|
950
|
+
_t9 = _context24.v;
|
|
951
|
+
if (!(((_error$response2 = _t9.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 400)) {
|
|
952
|
+
_context24.n = 9;
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
throw new Error((_error$response$data$ = (_error$response$data = _t9.response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.detail) !== null && _error$response$data$ !== void 0 ? _error$response$data$ : "Bad Request");
|
|
956
|
+
case 9:
|
|
957
|
+
throw _t9;
|
|
958
|
+
case 10:
|
|
959
|
+
return _context24.a(2);
|
|
909
960
|
}
|
|
910
|
-
}, _callee24, this);
|
|
961
|
+
}, _callee24, this, [[4, 8]]);
|
|
962
|
+
}));
|
|
963
|
+
function fundAddress(_x31, _x32) {
|
|
964
|
+
return _fundAddress.apply(this, arguments);
|
|
965
|
+
}
|
|
966
|
+
return fundAddress;
|
|
967
|
+
}())
|
|
968
|
+
}, {
|
|
969
|
+
key: "getFeeStats",
|
|
970
|
+
value: (function () {
|
|
971
|
+
var _getFeeStats = _asyncToGenerator(_regenerator().m(function _callee25() {
|
|
972
|
+
return _regenerator().w(function (_context25) {
|
|
973
|
+
while (1) switch (_context25.n) {
|
|
974
|
+
case 0:
|
|
975
|
+
return _context25.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getFeeStats"));
|
|
976
|
+
}
|
|
977
|
+
}, _callee25, this);
|
|
911
978
|
}));
|
|
912
979
|
function getFeeStats() {
|
|
913
980
|
return _getFeeStats.apply(this, arguments);
|
|
@@ -917,13 +984,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
917
984
|
}, {
|
|
918
985
|
key: "getVersionInfo",
|
|
919
986
|
value: (function () {
|
|
920
|
-
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function
|
|
921
|
-
return _regenerator().w(function (
|
|
922
|
-
while (1) switch (
|
|
987
|
+
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function _callee26() {
|
|
988
|
+
return _regenerator().w(function (_context26) {
|
|
989
|
+
while (1) switch (_context26.n) {
|
|
923
990
|
case 0:
|
|
924
|
-
return
|
|
991
|
+
return _context26.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getVersionInfo"));
|
|
925
992
|
}
|
|
926
|
-
},
|
|
993
|
+
}, _callee26, this);
|
|
927
994
|
}));
|
|
928
995
|
function getVersionInfo() {
|
|
929
996
|
return _getVersionInfo.apply(this, arguments);
|
|
@@ -933,34 +1000,34 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
933
1000
|
}, {
|
|
934
1001
|
key: "getSACBalance",
|
|
935
1002
|
value: (function () {
|
|
936
|
-
var _getSACBalance = _asyncToGenerator(_regenerator().m(function
|
|
937
|
-
var addressString, passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry,
|
|
938
|
-
return _regenerator().w(function (
|
|
939
|
-
while (1) switch (
|
|
1003
|
+
var _getSACBalance = _asyncToGenerator(_regenerator().m(function _callee27(address, sac, networkPassphrase) {
|
|
1004
|
+
var addressString, passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry, _t0;
|
|
1005
|
+
return _regenerator().w(function (_context27) {
|
|
1006
|
+
while (1) switch (_context27.n) {
|
|
940
1007
|
case 0:
|
|
941
1008
|
addressString = address instanceof _stellarBase.Address ? address.toString() : address;
|
|
942
1009
|
if (_stellarBase.StrKey.isValidContract(addressString)) {
|
|
943
|
-
|
|
1010
|
+
_context27.n = 1;
|
|
944
1011
|
break;
|
|
945
1012
|
}
|
|
946
1013
|
throw new TypeError("expected contract ID, got ".concat(addressString));
|
|
947
1014
|
case 1:
|
|
948
1015
|
if (!(networkPassphrase !== null && networkPassphrase !== void 0)) {
|
|
949
|
-
|
|
1016
|
+
_context27.n = 2;
|
|
950
1017
|
break;
|
|
951
1018
|
}
|
|
952
|
-
|
|
953
|
-
|
|
1019
|
+
_t0 = networkPassphrase;
|
|
1020
|
+
_context27.n = 4;
|
|
954
1021
|
break;
|
|
955
1022
|
case 2:
|
|
956
|
-
|
|
1023
|
+
_context27.n = 3;
|
|
957
1024
|
return this.getNetwork().then(function (n) {
|
|
958
1025
|
return n.passphrase;
|
|
959
1026
|
});
|
|
960
1027
|
case 3:
|
|
961
|
-
|
|
1028
|
+
_t0 = _context27.v;
|
|
962
1029
|
case 4:
|
|
963
|
-
passphrase =
|
|
1030
|
+
passphrase = _t0;
|
|
964
1031
|
sacId = sac.contractId(passphrase);
|
|
965
1032
|
key = (0, _stellarBase.nativeToScVal)(["Balance", addressString], {
|
|
966
1033
|
type: ["symbol", "address"]
|
|
@@ -970,29 +1037,29 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
970
1037
|
durability: _stellarBase.xdr.ContractDataDurability.persistent(),
|
|
971
1038
|
key: key
|
|
972
1039
|
}));
|
|
973
|
-
|
|
1040
|
+
_context27.n = 5;
|
|
974
1041
|
return this.getLedgerEntries(ledgerKey);
|
|
975
1042
|
case 5:
|
|
976
|
-
response =
|
|
1043
|
+
response = _context27.v;
|
|
977
1044
|
if (!(response.entries.length === 0)) {
|
|
978
|
-
|
|
1045
|
+
_context27.n = 6;
|
|
979
1046
|
break;
|
|
980
1047
|
}
|
|
981
|
-
return
|
|
1048
|
+
return _context27.a(2, {
|
|
982
1049
|
latestLedger: response.latestLedger
|
|
983
1050
|
});
|
|
984
1051
|
case 6:
|
|
985
1052
|
_response$entries$2 = response.entries[0], lastModifiedLedgerSeq = _response$entries$2.lastModifiedLedgerSeq, liveUntilLedgerSeq = _response$entries$2.liveUntilLedgerSeq, val = _response$entries$2.val;
|
|
986
1053
|
if (!(val.switch().value !== _stellarBase.xdr.LedgerEntryType.contractData().value)) {
|
|
987
|
-
|
|
1054
|
+
_context27.n = 7;
|
|
988
1055
|
break;
|
|
989
1056
|
}
|
|
990
|
-
return
|
|
1057
|
+
return _context27.a(2, {
|
|
991
1058
|
latestLedger: response.latestLedger
|
|
992
1059
|
});
|
|
993
1060
|
case 7:
|
|
994
1061
|
entry = (0, _stellarBase.scValToNative)(val.contractData().val());
|
|
995
|
-
return
|
|
1062
|
+
return _context27.a(2, {
|
|
996
1063
|
latestLedger: response.latestLedger,
|
|
997
1064
|
balanceEntry: {
|
|
998
1065
|
liveUntilLedgerSeq: liveUntilLedgerSeq,
|
|
@@ -1003,9 +1070,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1003
1070
|
}
|
|
1004
1071
|
});
|
|
1005
1072
|
}
|
|
1006
|
-
},
|
|
1073
|
+
}, _callee27, this);
|
|
1007
1074
|
}));
|
|
1008
|
-
function getSACBalance(
|
|
1075
|
+
function getSACBalance(_x33, _x34, _x35) {
|
|
1009
1076
|
return _getSACBalance.apply(this, arguments);
|
|
1010
1077
|
}
|
|
1011
1078
|
return getSACBalance;
|
|
@@ -1013,11 +1080,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1013
1080
|
}, {
|
|
1014
1081
|
key: "getLedgers",
|
|
1015
1082
|
value: (function () {
|
|
1016
|
-
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function
|
|
1017
|
-
return _regenerator().w(function (
|
|
1018
|
-
while (1) switch (
|
|
1083
|
+
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function _callee28(request) {
|
|
1084
|
+
return _regenerator().w(function (_context28) {
|
|
1085
|
+
while (1) switch (_context28.n) {
|
|
1019
1086
|
case 0:
|
|
1020
|
-
return
|
|
1087
|
+
return _context28.a(2, this._getLedgers(request).then(function (raw) {
|
|
1021
1088
|
var result = {
|
|
1022
1089
|
ledgers: (raw.ledgers || []).map(_parsers.parseRawLedger),
|
|
1023
1090
|
latestLedger: raw.latestLedger,
|
|
@@ -1029,9 +1096,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1029
1096
|
return result;
|
|
1030
1097
|
}));
|
|
1031
1098
|
}
|
|
1032
|
-
},
|
|
1099
|
+
}, _callee28, this);
|
|
1033
1100
|
}));
|
|
1034
|
-
function getLedgers(
|
|
1101
|
+
function getLedgers(_x36) {
|
|
1035
1102
|
return _getLedgers2.apply(this, arguments);
|
|
1036
1103
|
}
|
|
1037
1104
|
return getLedgers;
|
|
@@ -1039,15 +1106,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1039
1106
|
}, {
|
|
1040
1107
|
key: "_getLedgers",
|
|
1041
1108
|
value: function () {
|
|
1042
|
-
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function
|
|
1043
|
-
return _regenerator().w(function (
|
|
1044
|
-
while (1) switch (
|
|
1109
|
+
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function _callee29(request) {
|
|
1110
|
+
return _regenerator().w(function (_context29) {
|
|
1111
|
+
while (1) switch (_context29.n) {
|
|
1045
1112
|
case 0:
|
|
1046
|
-
return
|
|
1113
|
+
return _context29.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLedgers", request));
|
|
1047
1114
|
}
|
|
1048
|
-
},
|
|
1115
|
+
}, _callee29, this);
|
|
1049
1116
|
}));
|
|
1050
|
-
function _getLedgers(
|
|
1117
|
+
function _getLedgers(_x37) {
|
|
1051
1118
|
return _getLedgers3.apply(this, arguments);
|
|
1052
1119
|
}
|
|
1053
1120
|
return _getLedgers;
|
|
@@ -41,6 +41,7 @@ export declare namespace Api {
|
|
|
41
41
|
}
|
|
42
42
|
type Url = string;
|
|
43
43
|
type PublicKey = string;
|
|
44
|
+
type ContractId = string;
|
|
44
45
|
type ISODateTime = string;
|
|
45
46
|
interface Documentation {
|
|
46
47
|
ORG_NAME?: string;
|
|
@@ -117,6 +118,8 @@ export declare namespace Api {
|
|
|
117
118
|
TRANSFER_SERVER?: Url;
|
|
118
119
|
KYC_SERVER?: Url;
|
|
119
120
|
WEB_AUTH_ENDPOINT?: Url;
|
|
121
|
+
WEB_AUTH_FOR_CONTRACTS_ENDPOINT?: Url;
|
|
122
|
+
WEB_AUTH_CONTRACT_ID?: ContractId;
|
|
120
123
|
FEDERATION_SERVER?: Url;
|
|
121
124
|
SIGNING_KEY?: PublicKey;
|
|
122
125
|
HORIZON_URL?: Url;
|
package/lib/rpc/axios.js
CHANGED
|
@@ -12,7 +12,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
12
12
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
14
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
var version = exports.version = "14.
|
|
15
|
+
var version = exports.version = "14.6.0";
|
|
16
16
|
function createHttpClient(headers) {
|
|
17
17
|
return (0, _httpClient.create)({
|
|
18
18
|
headers: _objectSpread(_objectSpread({}, headers), {}, {
|
package/lib/rpc/server.d.ts
CHANGED
|
@@ -351,7 +351,7 @@ export declare class RpcServer {
|
|
|
351
351
|
* transaction completion and return a definitive state of success or failure.
|
|
352
352
|
*
|
|
353
353
|
* @param {string} hash the transaction you're polling for
|
|
354
|
-
* @param {
|
|
354
|
+
* @param {RpcServer.PollingOptions} [opts] polling options
|
|
355
355
|
* @param {number} [opts.attempts] (optional) the number of attempts to make
|
|
356
356
|
* before returning the last-seen status. By default or on invalid inputs,
|
|
357
357
|
* try 5 times.
|
|
@@ -681,6 +681,9 @@ export declare class RpcServer {
|
|
|
681
681
|
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}
|
|
682
682
|
* @see {@link module:Friendbot.Api.Response}
|
|
683
683
|
*
|
|
684
|
+
* @deprecated Use {@link Server.fundAddress} instead, which supports both
|
|
685
|
+
* account (G...) and contract (C...) addresses.
|
|
686
|
+
*
|
|
684
687
|
* @example
|
|
685
688
|
* server
|
|
686
689
|
* .requestAirdrop("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4")
|
|
@@ -691,6 +694,37 @@ export declare class RpcServer {
|
|
|
691
694
|
* });
|
|
692
695
|
*/
|
|
693
696
|
requestAirdrop(address: string | Pick<Account, "accountId">, friendbotUrl?: string): Promise<Account>;
|
|
697
|
+
/**
|
|
698
|
+
* Fund an address using the network's Friendbot faucet, if any.
|
|
699
|
+
*
|
|
700
|
+
* This method supports both account (G...) and contract (C...) addresses.
|
|
701
|
+
*
|
|
702
|
+
* @param {string} address The address to fund. Can be either a Stellar
|
|
703
|
+
* account (G...) or contract (C...) address.
|
|
704
|
+
* @param {string} [friendbotUrl] Optionally, an explicit Friendbot URL
|
|
705
|
+
* (by default: this calls the Stellar RPC
|
|
706
|
+
* {@link module:rpc.Server#getNetwork | getNetwork} method to try to
|
|
707
|
+
* discover this network's Friendbot url).
|
|
708
|
+
* @returns {Promise<Api.GetSuccessfulTransactionResponse>} The transaction
|
|
709
|
+
* response from the Friendbot funding transaction.
|
|
710
|
+
* @throws {Error} If Friendbot is not configured on this network or the
|
|
711
|
+
* funding transaction fails.
|
|
712
|
+
*
|
|
713
|
+
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
* // Funding an account (G... address)
|
|
717
|
+
* const tx = await server.fundAddress("GBZC6Y2Y7...");
|
|
718
|
+
* console.log("Funded! Hash:", tx.txHash);
|
|
719
|
+
* // If you need the Account object:
|
|
720
|
+
* const account = await server.getAccount("GBZC6Y2Y7...");
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* // Funding a contract (C... address)
|
|
724
|
+
* const tx = await server.fundAddress("CBZC6Y2Y7...");
|
|
725
|
+
* console.log("Contract funded! Hash:", tx.txHash);
|
|
726
|
+
*/
|
|
727
|
+
fundAddress(address: string, friendbotUrl?: string): Promise<Api.GetSuccessfulTransactionResponse>;
|
|
694
728
|
/**
|
|
695
729
|
* Provides an analysis of the recent fee stats for regular and smart
|
|
696
730
|
* contract operations.
|
package/lib/rpc/server.js
CHANGED
|
@@ -12,7 +12,7 @@ var _api = require("./api");
|
|
|
12
12
|
var _transaction = require("./transaction");
|
|
13
13
|
var _parsers = require("./parsers");
|
|
14
14
|
var _utils = require("../utils");
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t1 in e) "default" !== _t1 && {}.hasOwnProperty.call(e, _t1) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t1)) && (i.get || i.set) ? o(f, _t1, i) : f[_t1] = e[_t1]); return f; })(e, t); }
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
18
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -899,15 +899,82 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
899
899
|
return requestAirdrop;
|
|
900
900
|
}())
|
|
901
901
|
}, {
|
|
902
|
-
key: "
|
|
902
|
+
key: "fundAddress",
|
|
903
903
|
value: (function () {
|
|
904
|
-
var
|
|
904
|
+
var _fundAddress = _asyncToGenerator(_regenerator().m(function _callee24(address, friendbotUrl) {
|
|
905
|
+
var response, txResponse, _error$response2, _error$response$data$, _error$response$data, _t8, _t9;
|
|
905
906
|
return _regenerator().w(function (_context24) {
|
|
906
|
-
while (1) switch (_context24.n) {
|
|
907
|
+
while (1) switch (_context24.p = _context24.n) {
|
|
907
908
|
case 0:
|
|
908
|
-
|
|
909
|
+
if (!(!_stellarBase.StrKey.isValidEd25519PublicKey(address) && !_stellarBase.StrKey.isValidContract(address))) {
|
|
910
|
+
_context24.n = 1;
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
throw new Error("Invalid address: ".concat(address, ". Expected a Stellar account (G...) or contract (C...) address."));
|
|
914
|
+
case 1:
|
|
915
|
+
_t8 = friendbotUrl;
|
|
916
|
+
if (_t8) {
|
|
917
|
+
_context24.n = 3;
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
_context24.n = 2;
|
|
921
|
+
return this.getNetwork();
|
|
922
|
+
case 2:
|
|
923
|
+
_t8 = _context24.v.friendbotUrl;
|
|
924
|
+
case 3:
|
|
925
|
+
friendbotUrl = _t8;
|
|
926
|
+
if (friendbotUrl) {
|
|
927
|
+
_context24.n = 4;
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
throw new Error("No friendbot URL configured for current network");
|
|
931
|
+
case 4:
|
|
932
|
+
_context24.p = 4;
|
|
933
|
+
_context24.n = 5;
|
|
934
|
+
return this.httpClient.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(address)));
|
|
935
|
+
case 5:
|
|
936
|
+
response = _context24.v;
|
|
937
|
+
_context24.n = 6;
|
|
938
|
+
return this.getTransaction(response.data.hash);
|
|
939
|
+
case 6:
|
|
940
|
+
txResponse = _context24.v;
|
|
941
|
+
if (!(txResponse.status !== _api.Api.GetTransactionStatus.SUCCESS)) {
|
|
942
|
+
_context24.n = 7;
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
throw new Error("Funding address ".concat(address, " failed: transaction status ").concat(txResponse.status));
|
|
946
|
+
case 7:
|
|
947
|
+
return _context24.a(2, txResponse);
|
|
948
|
+
case 8:
|
|
949
|
+
_context24.p = 8;
|
|
950
|
+
_t9 = _context24.v;
|
|
951
|
+
if (!(((_error$response2 = _t9.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 400)) {
|
|
952
|
+
_context24.n = 9;
|
|
953
|
+
break;
|
|
954
|
+
}
|
|
955
|
+
throw new Error((_error$response$data$ = (_error$response$data = _t9.response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.detail) !== null && _error$response$data$ !== void 0 ? _error$response$data$ : "Bad Request");
|
|
956
|
+
case 9:
|
|
957
|
+
throw _t9;
|
|
958
|
+
case 10:
|
|
959
|
+
return _context24.a(2);
|
|
909
960
|
}
|
|
910
|
-
}, _callee24, this);
|
|
961
|
+
}, _callee24, this, [[4, 8]]);
|
|
962
|
+
}));
|
|
963
|
+
function fundAddress(_x31, _x32) {
|
|
964
|
+
return _fundAddress.apply(this, arguments);
|
|
965
|
+
}
|
|
966
|
+
return fundAddress;
|
|
967
|
+
}())
|
|
968
|
+
}, {
|
|
969
|
+
key: "getFeeStats",
|
|
970
|
+
value: (function () {
|
|
971
|
+
var _getFeeStats = _asyncToGenerator(_regenerator().m(function _callee25() {
|
|
972
|
+
return _regenerator().w(function (_context25) {
|
|
973
|
+
while (1) switch (_context25.n) {
|
|
974
|
+
case 0:
|
|
975
|
+
return _context25.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getFeeStats"));
|
|
976
|
+
}
|
|
977
|
+
}, _callee25, this);
|
|
911
978
|
}));
|
|
912
979
|
function getFeeStats() {
|
|
913
980
|
return _getFeeStats.apply(this, arguments);
|
|
@@ -917,13 +984,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
917
984
|
}, {
|
|
918
985
|
key: "getVersionInfo",
|
|
919
986
|
value: (function () {
|
|
920
|
-
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function
|
|
921
|
-
return _regenerator().w(function (
|
|
922
|
-
while (1) switch (
|
|
987
|
+
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function _callee26() {
|
|
988
|
+
return _regenerator().w(function (_context26) {
|
|
989
|
+
while (1) switch (_context26.n) {
|
|
923
990
|
case 0:
|
|
924
|
-
return
|
|
991
|
+
return _context26.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getVersionInfo"));
|
|
925
992
|
}
|
|
926
|
-
},
|
|
993
|
+
}, _callee26, this);
|
|
927
994
|
}));
|
|
928
995
|
function getVersionInfo() {
|
|
929
996
|
return _getVersionInfo.apply(this, arguments);
|
|
@@ -933,34 +1000,34 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
933
1000
|
}, {
|
|
934
1001
|
key: "getSACBalance",
|
|
935
1002
|
value: (function () {
|
|
936
|
-
var _getSACBalance = _asyncToGenerator(_regenerator().m(function
|
|
937
|
-
var addressString, passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry,
|
|
938
|
-
return _regenerator().w(function (
|
|
939
|
-
while (1) switch (
|
|
1003
|
+
var _getSACBalance = _asyncToGenerator(_regenerator().m(function _callee27(address, sac, networkPassphrase) {
|
|
1004
|
+
var addressString, passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry, _t0;
|
|
1005
|
+
return _regenerator().w(function (_context27) {
|
|
1006
|
+
while (1) switch (_context27.n) {
|
|
940
1007
|
case 0:
|
|
941
1008
|
addressString = address instanceof _stellarBase.Address ? address.toString() : address;
|
|
942
1009
|
if (_stellarBase.StrKey.isValidContract(addressString)) {
|
|
943
|
-
|
|
1010
|
+
_context27.n = 1;
|
|
944
1011
|
break;
|
|
945
1012
|
}
|
|
946
1013
|
throw new TypeError("expected contract ID, got ".concat(addressString));
|
|
947
1014
|
case 1:
|
|
948
1015
|
if (!(networkPassphrase !== null && networkPassphrase !== void 0)) {
|
|
949
|
-
|
|
1016
|
+
_context27.n = 2;
|
|
950
1017
|
break;
|
|
951
1018
|
}
|
|
952
|
-
|
|
953
|
-
|
|
1019
|
+
_t0 = networkPassphrase;
|
|
1020
|
+
_context27.n = 4;
|
|
954
1021
|
break;
|
|
955
1022
|
case 2:
|
|
956
|
-
|
|
1023
|
+
_context27.n = 3;
|
|
957
1024
|
return this.getNetwork().then(function (n) {
|
|
958
1025
|
return n.passphrase;
|
|
959
1026
|
});
|
|
960
1027
|
case 3:
|
|
961
|
-
|
|
1028
|
+
_t0 = _context27.v;
|
|
962
1029
|
case 4:
|
|
963
|
-
passphrase =
|
|
1030
|
+
passphrase = _t0;
|
|
964
1031
|
sacId = sac.contractId(passphrase);
|
|
965
1032
|
key = (0, _stellarBase.nativeToScVal)(["Balance", addressString], {
|
|
966
1033
|
type: ["symbol", "address"]
|
|
@@ -970,29 +1037,29 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
970
1037
|
durability: _stellarBase.xdr.ContractDataDurability.persistent(),
|
|
971
1038
|
key: key
|
|
972
1039
|
}));
|
|
973
|
-
|
|
1040
|
+
_context27.n = 5;
|
|
974
1041
|
return this.getLedgerEntries(ledgerKey);
|
|
975
1042
|
case 5:
|
|
976
|
-
response =
|
|
1043
|
+
response = _context27.v;
|
|
977
1044
|
if (!(response.entries.length === 0)) {
|
|
978
|
-
|
|
1045
|
+
_context27.n = 6;
|
|
979
1046
|
break;
|
|
980
1047
|
}
|
|
981
|
-
return
|
|
1048
|
+
return _context27.a(2, {
|
|
982
1049
|
latestLedger: response.latestLedger
|
|
983
1050
|
});
|
|
984
1051
|
case 6:
|
|
985
1052
|
_response$entries$2 = response.entries[0], lastModifiedLedgerSeq = _response$entries$2.lastModifiedLedgerSeq, liveUntilLedgerSeq = _response$entries$2.liveUntilLedgerSeq, val = _response$entries$2.val;
|
|
986
1053
|
if (!(val.switch().value !== _stellarBase.xdr.LedgerEntryType.contractData().value)) {
|
|
987
|
-
|
|
1054
|
+
_context27.n = 7;
|
|
988
1055
|
break;
|
|
989
1056
|
}
|
|
990
|
-
return
|
|
1057
|
+
return _context27.a(2, {
|
|
991
1058
|
latestLedger: response.latestLedger
|
|
992
1059
|
});
|
|
993
1060
|
case 7:
|
|
994
1061
|
entry = (0, _stellarBase.scValToNative)(val.contractData().val());
|
|
995
|
-
return
|
|
1062
|
+
return _context27.a(2, {
|
|
996
1063
|
latestLedger: response.latestLedger,
|
|
997
1064
|
balanceEntry: {
|
|
998
1065
|
liveUntilLedgerSeq: liveUntilLedgerSeq,
|
|
@@ -1003,9 +1070,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1003
1070
|
}
|
|
1004
1071
|
});
|
|
1005
1072
|
}
|
|
1006
|
-
},
|
|
1073
|
+
}, _callee27, this);
|
|
1007
1074
|
}));
|
|
1008
|
-
function getSACBalance(
|
|
1075
|
+
function getSACBalance(_x33, _x34, _x35) {
|
|
1009
1076
|
return _getSACBalance.apply(this, arguments);
|
|
1010
1077
|
}
|
|
1011
1078
|
return getSACBalance;
|
|
@@ -1013,11 +1080,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1013
1080
|
}, {
|
|
1014
1081
|
key: "getLedgers",
|
|
1015
1082
|
value: (function () {
|
|
1016
|
-
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function
|
|
1017
|
-
return _regenerator().w(function (
|
|
1018
|
-
while (1) switch (
|
|
1083
|
+
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function _callee28(request) {
|
|
1084
|
+
return _regenerator().w(function (_context28) {
|
|
1085
|
+
while (1) switch (_context28.n) {
|
|
1019
1086
|
case 0:
|
|
1020
|
-
return
|
|
1087
|
+
return _context28.a(2, this._getLedgers(request).then(function (raw) {
|
|
1021
1088
|
var result = {
|
|
1022
1089
|
ledgers: (raw.ledgers || []).map(_parsers.parseRawLedger),
|
|
1023
1090
|
latestLedger: raw.latestLedger,
|
|
@@ -1029,9 +1096,9 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1029
1096
|
return result;
|
|
1030
1097
|
}));
|
|
1031
1098
|
}
|
|
1032
|
-
},
|
|
1099
|
+
}, _callee28, this);
|
|
1033
1100
|
}));
|
|
1034
|
-
function getLedgers(
|
|
1101
|
+
function getLedgers(_x36) {
|
|
1035
1102
|
return _getLedgers2.apply(this, arguments);
|
|
1036
1103
|
}
|
|
1037
1104
|
return getLedgers;
|
|
@@ -1039,15 +1106,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1039
1106
|
}, {
|
|
1040
1107
|
key: "_getLedgers",
|
|
1041
1108
|
value: function () {
|
|
1042
|
-
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function
|
|
1043
|
-
return _regenerator().w(function (
|
|
1044
|
-
while (1) switch (
|
|
1109
|
+
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function _callee29(request) {
|
|
1110
|
+
return _regenerator().w(function (_context29) {
|
|
1111
|
+
while (1) switch (_context29.n) {
|
|
1045
1112
|
case 0:
|
|
1046
|
-
return
|
|
1113
|
+
return _context29.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLedgers", request));
|
|
1047
1114
|
}
|
|
1048
|
-
},
|
|
1115
|
+
}, _callee29, this);
|
|
1049
1116
|
}));
|
|
1050
|
-
function _getLedgers(
|
|
1117
|
+
function _getLedgers(_x37) {
|
|
1051
1118
|
return _getLedgers3.apply(this, arguments);
|
|
1052
1119
|
}
|
|
1053
1120
|
return _getLedgers;
|
|
@@ -41,6 +41,7 @@ export declare namespace Api {
|
|
|
41
41
|
}
|
|
42
42
|
type Url = string;
|
|
43
43
|
type PublicKey = string;
|
|
44
|
+
type ContractId = string;
|
|
44
45
|
type ISODateTime = string;
|
|
45
46
|
interface Documentation {
|
|
46
47
|
ORG_NAME?: string;
|
|
@@ -117,6 +118,8 @@ export declare namespace Api {
|
|
|
117
118
|
TRANSFER_SERVER?: Url;
|
|
118
119
|
KYC_SERVER?: Url;
|
|
119
120
|
WEB_AUTH_ENDPOINT?: Url;
|
|
121
|
+
WEB_AUTH_FOR_CONTRACTS_ENDPOINT?: Url;
|
|
122
|
+
WEB_AUTH_CONTRACT_ID?: ContractId;
|
|
120
123
|
FEDERATION_SERVER?: Url;
|
|
121
124
|
SIGNING_KEY?: PublicKey;
|
|
122
125
|
HORIZON_URL?: Url;
|