@stellar/stellar-sdk 15.0.1 → 15.1.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/dist/stellar-sdk-minimal.js +711 -264
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +711 -264
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +335 -207
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +335 -207
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/bindings/config.js +1 -3
- package/lib/contract/assembled_transaction.d.ts +5 -0
- package/lib/contract/assembled_transaction.js +23 -22
- package/lib/contract/spec.js +18 -6
- package/lib/contract/utils.js +13 -13
- package/lib/federation/server.js +6 -3
- package/lib/federation/utils.d.ts +1 -0
- package/lib/federation/utils.js +11 -0
- package/lib/horizon/account_response.d.ts +1 -0
- package/lib/horizon/account_response.js +26 -13
- package/lib/horizon/call_builder.js +6 -5
- package/lib/horizon/horizon_axios_client.js +3 -2
- package/lib/horizon/server.js +3 -1
- package/lib/horizon/server_api.d.ts +1 -0
- package/lib/http-client/fetch-client.js +435 -64
- package/lib/minimal/bindings/config.js +1 -3
- package/lib/minimal/contract/assembled_transaction.d.ts +5 -0
- package/lib/minimal/contract/assembled_transaction.js +23 -22
- package/lib/minimal/contract/spec.js +18 -6
- package/lib/minimal/contract/utils.js +13 -13
- package/lib/minimal/federation/server.js +6 -3
- package/lib/minimal/federation/utils.d.ts +1 -0
- package/lib/minimal/federation/utils.js +11 -0
- package/lib/minimal/horizon/account_response.d.ts +1 -0
- package/lib/minimal/horizon/account_response.js +26 -13
- package/lib/minimal/horizon/call_builder.js +6 -5
- package/lib/minimal/horizon/horizon_axios_client.js +3 -2
- package/lib/minimal/horizon/server.js +3 -1
- package/lib/minimal/horizon/server_api.d.ts +1 -0
- package/lib/minimal/http-client/fetch-client.js +435 -64
- package/lib/minimal/rpc/api.d.ts +15 -0
- package/lib/minimal/rpc/axios.js +1 -1
- package/lib/minimal/rpc/parsers.d.ts +1 -0
- package/lib/minimal/rpc/parsers.js +26 -2
- package/lib/minimal/rpc/server.d.ts +1 -0
- package/lib/minimal/rpc/server.js +134 -117
- package/lib/minimal/webauth/challenge_transaction.js +3 -0
- package/lib/no-axios/bindings/config.js +1 -3
- package/lib/no-axios/contract/assembled_transaction.d.ts +5 -0
- package/lib/no-axios/contract/assembled_transaction.js +23 -22
- package/lib/no-axios/contract/spec.js +18 -6
- package/lib/no-axios/contract/utils.js +13 -13
- package/lib/no-axios/federation/server.js +6 -3
- package/lib/no-axios/federation/utils.d.ts +1 -0
- package/lib/no-axios/federation/utils.js +11 -0
- package/lib/no-axios/horizon/account_response.d.ts +1 -0
- package/lib/no-axios/horizon/account_response.js +26 -13
- package/lib/no-axios/horizon/call_builder.js +6 -5
- package/lib/no-axios/horizon/horizon_axios_client.js +3 -2
- package/lib/no-axios/horizon/server.js +3 -1
- package/lib/no-axios/horizon/server_api.d.ts +1 -0
- package/lib/no-axios/http-client/fetch-client.js +435 -64
- package/lib/no-axios/rpc/api.d.ts +15 -0
- package/lib/no-axios/rpc/axios.js +1 -1
- package/lib/no-axios/rpc/parsers.d.ts +1 -0
- package/lib/no-axios/rpc/parsers.js +26 -2
- package/lib/no-axios/rpc/server.d.ts +1 -0
- package/lib/no-axios/rpc/server.js +134 -117
- package/lib/no-axios/webauth/challenge_transaction.js +3 -0
- package/lib/no-eventsource/bindings/config.js +1 -3
- package/lib/no-eventsource/contract/assembled_transaction.d.ts +5 -0
- package/lib/no-eventsource/contract/assembled_transaction.js +23 -22
- package/lib/no-eventsource/contract/spec.js +18 -6
- package/lib/no-eventsource/contract/utils.js +13 -13
- package/lib/no-eventsource/federation/server.js +6 -3
- package/lib/no-eventsource/federation/utils.d.ts +1 -0
- package/lib/no-eventsource/federation/utils.js +11 -0
- package/lib/no-eventsource/horizon/account_response.d.ts +1 -0
- package/lib/no-eventsource/horizon/account_response.js +26 -13
- package/lib/no-eventsource/horizon/call_builder.js +6 -5
- package/lib/no-eventsource/horizon/horizon_axios_client.js +3 -2
- package/lib/no-eventsource/horizon/server.js +3 -1
- package/lib/no-eventsource/horizon/server_api.d.ts +1 -0
- package/lib/no-eventsource/http-client/fetch-client.js +435 -64
- package/lib/no-eventsource/rpc/api.d.ts +15 -0
- package/lib/no-eventsource/rpc/axios.js +1 -1
- package/lib/no-eventsource/rpc/parsers.d.ts +1 -0
- package/lib/no-eventsource/rpc/parsers.js +26 -2
- package/lib/no-eventsource/rpc/server.d.ts +1 -0
- package/lib/no-eventsource/rpc/server.js +134 -117
- package/lib/no-eventsource/webauth/challenge_transaction.js +3 -0
- package/lib/rpc/api.d.ts +15 -0
- package/lib/rpc/axios.js +1 -1
- package/lib/rpc/parsers.d.ts +1 -0
- package/lib/rpc/parsers.js +26 -2
- package/lib/rpc/server.d.ts +1 -0
- package/lib/rpc/server.js +134 -117
- package/lib/webauth/challenge_transaction.js +3 -0
- package/package.json +6 -5
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parseRawEvents = parseRawEvents;
|
|
7
|
+
exports.parseRawLatestLedger = parseRawLatestLedger;
|
|
7
8
|
exports.parseRawLedger = parseRawLedger;
|
|
8
9
|
exports.parseRawLedgerEntries = parseRawLedgerEntries;
|
|
9
10
|
exports.parseRawSendTransaction = parseRawSendTransaction;
|
|
@@ -126,7 +127,7 @@ function parseSuccessful(sim, partial) {
|
|
|
126
127
|
var success = _objectSpread(_objectSpread(_objectSpread({}, partial), {}, {
|
|
127
128
|
transactionData: new _stellarBase.SorobanDataBuilder(sim.transactionData),
|
|
128
129
|
minResourceFee: sim.minResourceFee
|
|
129
|
-
}, ((_sim$results$length = (_sim$results = sim.results) === null || _sim$results === void 0 ? void 0 : _sim$results.length) !== null && _sim$results$length !== void 0 ? _sim$results$length : 0 > 0
|
|
130
|
+
}, ((_sim$results$length = (_sim$results = sim.results) === null || _sim$results === void 0 ? void 0 : _sim$results.length) !== null && _sim$results$length !== void 0 ? _sim$results$length : 0) > 0 && {
|
|
130
131
|
result: sim.results.map(function (row) {
|
|
131
132
|
var _row$auth;
|
|
132
133
|
return {
|
|
@@ -136,7 +137,7 @@ function parseSuccessful(sim, partial) {
|
|
|
136
137
|
retval: row.xdr ? _stellarBase.xdr.ScVal.fromXDR(row.xdr, "base64") : _stellarBase.xdr.ScVal.scvVoid()
|
|
137
138
|
};
|
|
138
139
|
})[0]
|
|
139
|
-
}), ((_sim$stateChanges$len = (_sim$stateChanges = sim.stateChanges) === null || _sim$stateChanges === void 0 ? void 0 : _sim$stateChanges.length) !== null && _sim$stateChanges$len !== void 0 ? _sim$stateChanges$len : 0 > 0
|
|
140
|
+
}), ((_sim$stateChanges$len = (_sim$stateChanges = sim.stateChanges) === null || _sim$stateChanges === void 0 ? void 0 : _sim$stateChanges.length) !== null && _sim$stateChanges$len !== void 0 ? _sim$stateChanges$len : 0) > 0 && {
|
|
140
141
|
stateChanges: (_sim$stateChanges2 = sim.stateChanges) === null || _sim$stateChanges2 === void 0 ? void 0 : _sim$stateChanges2.map(function (entryChange) {
|
|
141
142
|
return {
|
|
142
143
|
type: entryChange.type,
|
|
@@ -198,4 +199,27 @@ function parseRawLedger(raw) {
|
|
|
198
199
|
metadataXdr: metadataXdr,
|
|
199
200
|
headerXdr: headerXdr
|
|
200
201
|
};
|
|
202
|
+
}
|
|
203
|
+
function parseRawLatestLedger(raw) {
|
|
204
|
+
var headerXdr = _stellarBase.xdr.LedgerHeader.fromXDR(raw.headerXdr, "base64");
|
|
205
|
+
var metadataXdr = _stellarBase.xdr.LedgerCloseMeta.fromXDR(raw.metadataXdr, "base64");
|
|
206
|
+
var missingFields;
|
|
207
|
+
if (!raw.metadataXdr && !raw.headerXdr) {
|
|
208
|
+
missingFields = "metadataXdr and headerXdr";
|
|
209
|
+
} else if (!raw.metadataXdr) {
|
|
210
|
+
missingFields = "metadataXdr";
|
|
211
|
+
} else if (!raw.headerXdr) {
|
|
212
|
+
missingFields = "headerXdr";
|
|
213
|
+
}
|
|
214
|
+
if (missingFields) {
|
|
215
|
+
throw new TypeError("invalid getLatestLedger response missing fields: ".concat(missingFields));
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
id: raw.id,
|
|
219
|
+
sequence: raw.sequence,
|
|
220
|
+
protocolVersion: raw.protocolVersion,
|
|
221
|
+
closeTime: raw.closeTime,
|
|
222
|
+
headerXdr: headerXdr,
|
|
223
|
+
metadataXdr: metadataXdr
|
|
224
|
+
};
|
|
201
225
|
}
|
|
@@ -491,6 +491,7 @@ export declare class RpcServer {
|
|
|
491
491
|
* });
|
|
492
492
|
*/
|
|
493
493
|
getLatestLedger(): Promise<Api.GetLatestLedgerResponse>;
|
|
494
|
+
_getLatestLedger(): Promise<Api.RawGetLatestLedgerResponse>;
|
|
494
495
|
/**
|
|
495
496
|
* Submit a trial contract invocation to get back return values, expected
|
|
496
497
|
* ledger footprint, expected authorizations, and expected costs.
|
|
@@ -275,9 +275,10 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
275
275
|
latestLedger: ll.sequence,
|
|
276
276
|
balanceEntry: {
|
|
277
277
|
amount: tl.balance().toString(),
|
|
278
|
-
authorized: Boolean(tl.flags() &
|
|
279
|
-
clawback: Boolean(tl.flags() &
|
|
280
|
-
|
|
278
|
+
authorized: Boolean(tl.flags() & 0x1),
|
|
279
|
+
clawback: Boolean(tl.flags() & 0x4),
|
|
280
|
+
authorizedToMaintainLiabilities: Boolean(tl.flags() & 0x2),
|
|
281
|
+
revocable: Boolean(tl.flags() & 0x2)
|
|
281
282
|
}
|
|
282
283
|
});
|
|
283
284
|
case 6:
|
|
@@ -525,7 +526,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
525
526
|
maxAttempts = ((_opts$attempts = opts === null || opts === void 0 ? void 0 : opts.attempts) !== null && _opts$attempts !== void 0 ? _opts$attempts : 0) < 1 ? DEFAULT_GET_TRANSACTION_TIMEOUT : (_opts$attempts2 = opts === null || opts === void 0 ? void 0 : opts.attempts) !== null && _opts$attempts2 !== void 0 ? _opts$attempts2 : DEFAULT_GET_TRANSACTION_TIMEOUT;
|
|
526
527
|
attempt = 1;
|
|
527
528
|
case 1:
|
|
528
|
-
if (!(attempt
|
|
529
|
+
if (!(attempt <= maxAttempts)) {
|
|
529
530
|
_context1.n = 5;
|
|
530
531
|
break;
|
|
531
532
|
}
|
|
@@ -708,30 +709,46 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
708
709
|
}, {
|
|
709
710
|
key: "getLatestLedger",
|
|
710
711
|
value: (function () {
|
|
711
|
-
var
|
|
712
|
+
var _getLatestLedger2 = _asyncToGenerator(_regenerator().m(function _callee17() {
|
|
712
713
|
return _regenerator().w(function (_context17) {
|
|
713
714
|
while (1) switch (_context17.n) {
|
|
714
715
|
case 0:
|
|
715
|
-
return _context17.a(2,
|
|
716
|
+
return _context17.a(2, this._getLatestLedger().then(_parsers.parseRawLatestLedger));
|
|
716
717
|
}
|
|
717
718
|
}, _callee17, this);
|
|
718
719
|
}));
|
|
719
720
|
function getLatestLedger() {
|
|
720
|
-
return
|
|
721
|
+
return _getLatestLedger2.apply(this, arguments);
|
|
721
722
|
}
|
|
722
723
|
return getLatestLedger;
|
|
723
724
|
}())
|
|
724
725
|
}, {
|
|
725
|
-
key: "
|
|
726
|
-
value:
|
|
727
|
-
var
|
|
726
|
+
key: "_getLatestLedger",
|
|
727
|
+
value: function () {
|
|
728
|
+
var _getLatestLedger3 = _asyncToGenerator(_regenerator().m(function _callee18() {
|
|
728
729
|
return _regenerator().w(function (_context18) {
|
|
729
730
|
while (1) switch (_context18.n) {
|
|
730
731
|
case 0:
|
|
731
|
-
return _context18.a(2, this.
|
|
732
|
+
return _context18.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLatestLedger"));
|
|
732
733
|
}
|
|
733
734
|
}, _callee18, this);
|
|
734
735
|
}));
|
|
736
|
+
function _getLatestLedger() {
|
|
737
|
+
return _getLatestLedger3.apply(this, arguments);
|
|
738
|
+
}
|
|
739
|
+
return _getLatestLedger;
|
|
740
|
+
}()
|
|
741
|
+
}, {
|
|
742
|
+
key: "simulateTransaction",
|
|
743
|
+
value: (function () {
|
|
744
|
+
var _simulateTransaction2 = _asyncToGenerator(_regenerator().m(function _callee19(tx, addlResources, authMode) {
|
|
745
|
+
return _regenerator().w(function (_context19) {
|
|
746
|
+
while (1) switch (_context19.n) {
|
|
747
|
+
case 0:
|
|
748
|
+
return _context19.a(2, this._simulateTransaction(tx, addlResources, authMode).then(_parsers.parseRawSimulation));
|
|
749
|
+
}
|
|
750
|
+
}, _callee19, this);
|
|
751
|
+
}));
|
|
735
752
|
function simulateTransaction(_x20, _x21, _x22) {
|
|
736
753
|
return _simulateTransaction2.apply(this, arguments);
|
|
737
754
|
}
|
|
@@ -740,11 +757,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
740
757
|
}, {
|
|
741
758
|
key: "_simulateTransaction",
|
|
742
759
|
value: function () {
|
|
743
|
-
var _simulateTransaction3 = _asyncToGenerator(_regenerator().m(function
|
|
744
|
-
return _regenerator().w(function (
|
|
745
|
-
while (1) switch (
|
|
760
|
+
var _simulateTransaction3 = _asyncToGenerator(_regenerator().m(function _callee20(transaction, addlResources, authMode) {
|
|
761
|
+
return _regenerator().w(function (_context20) {
|
|
762
|
+
while (1) switch (_context20.n) {
|
|
746
763
|
case 0:
|
|
747
|
-
return
|
|
764
|
+
return _context20.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "simulateTransaction", _objectSpread({
|
|
748
765
|
transaction: transaction.toXDR(),
|
|
749
766
|
authMode: authMode
|
|
750
767
|
}, addlResources !== undefined && {
|
|
@@ -753,7 +770,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
753
770
|
}
|
|
754
771
|
})));
|
|
755
772
|
}
|
|
756
|
-
},
|
|
773
|
+
}, _callee20, this);
|
|
757
774
|
}));
|
|
758
775
|
function _simulateTransaction(_x23, _x24, _x25) {
|
|
759
776
|
return _simulateTransaction3.apply(this, arguments);
|
|
@@ -763,24 +780,24 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
763
780
|
}, {
|
|
764
781
|
key: "prepareTransaction",
|
|
765
782
|
value: (function () {
|
|
766
|
-
var _prepareTransaction = _asyncToGenerator(_regenerator().m(function
|
|
783
|
+
var _prepareTransaction = _asyncToGenerator(_regenerator().m(function _callee21(tx) {
|
|
767
784
|
var simResponse;
|
|
768
|
-
return _regenerator().w(function (
|
|
769
|
-
while (1) switch (
|
|
785
|
+
return _regenerator().w(function (_context21) {
|
|
786
|
+
while (1) switch (_context21.n) {
|
|
770
787
|
case 0:
|
|
771
|
-
|
|
788
|
+
_context21.n = 1;
|
|
772
789
|
return this.simulateTransaction(tx);
|
|
773
790
|
case 1:
|
|
774
|
-
simResponse =
|
|
791
|
+
simResponse = _context21.v;
|
|
775
792
|
if (!_api.Api.isSimulationError(simResponse)) {
|
|
776
|
-
|
|
793
|
+
_context21.n = 2;
|
|
777
794
|
break;
|
|
778
795
|
}
|
|
779
796
|
throw new Error(simResponse.error);
|
|
780
797
|
case 2:
|
|
781
|
-
return
|
|
798
|
+
return _context21.a(2, (0, _transaction.assembleTransaction)(tx, simResponse).build());
|
|
782
799
|
}
|
|
783
|
-
},
|
|
800
|
+
}, _callee21, this);
|
|
784
801
|
}));
|
|
785
802
|
function prepareTransaction(_x26) {
|
|
786
803
|
return _prepareTransaction.apply(this, arguments);
|
|
@@ -790,13 +807,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
790
807
|
}, {
|
|
791
808
|
key: "sendTransaction",
|
|
792
809
|
value: (function () {
|
|
793
|
-
var _sendTransaction2 = _asyncToGenerator(_regenerator().m(function
|
|
794
|
-
return _regenerator().w(function (
|
|
795
|
-
while (1) switch (
|
|
810
|
+
var _sendTransaction2 = _asyncToGenerator(_regenerator().m(function _callee22(transaction) {
|
|
811
|
+
return _regenerator().w(function (_context22) {
|
|
812
|
+
while (1) switch (_context22.n) {
|
|
796
813
|
case 0:
|
|
797
|
-
return
|
|
814
|
+
return _context22.a(2, this._sendTransaction(transaction).then(_parsers.parseRawSendTransaction));
|
|
798
815
|
}
|
|
799
|
-
},
|
|
816
|
+
}, _callee22, this);
|
|
800
817
|
}));
|
|
801
818
|
function sendTransaction(_x27) {
|
|
802
819
|
return _sendTransaction2.apply(this, arguments);
|
|
@@ -806,15 +823,15 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
806
823
|
}, {
|
|
807
824
|
key: "_sendTransaction",
|
|
808
825
|
value: function () {
|
|
809
|
-
var _sendTransaction3 = _asyncToGenerator(_regenerator().m(function
|
|
810
|
-
return _regenerator().w(function (
|
|
811
|
-
while (1) switch (
|
|
826
|
+
var _sendTransaction3 = _asyncToGenerator(_regenerator().m(function _callee23(transaction) {
|
|
827
|
+
return _regenerator().w(function (_context23) {
|
|
828
|
+
while (1) switch (_context23.n) {
|
|
812
829
|
case 0:
|
|
813
|
-
return
|
|
830
|
+
return _context23.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "sendTransaction", {
|
|
814
831
|
transaction: transaction.toXDR()
|
|
815
832
|
}));
|
|
816
833
|
}
|
|
817
|
-
},
|
|
834
|
+
}, _callee23, this);
|
|
818
835
|
}));
|
|
819
836
|
function _sendTransaction(_x28) {
|
|
820
837
|
return _sendTransaction3.apply(this, arguments);
|
|
@@ -824,74 +841,74 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
824
841
|
}, {
|
|
825
842
|
key: "requestAirdrop",
|
|
826
843
|
value: (function () {
|
|
827
|
-
var _requestAirdrop = _asyncToGenerator(_regenerator().m(function
|
|
828
|
-
var account, response, meta, txMeta, sequence, _error$response, _error$response$
|
|
829
|
-
return _regenerator().w(function (
|
|
830
|
-
while (1) switch (
|
|
844
|
+
var _requestAirdrop = _asyncToGenerator(_regenerator().m(function _callee24(address, friendbotUrl) {
|
|
845
|
+
var account, response, meta, txMeta, sequence, _error$response, _error$response$data, _t6, _t7;
|
|
846
|
+
return _regenerator().w(function (_context24) {
|
|
847
|
+
while (1) switch (_context24.p = _context24.n) {
|
|
831
848
|
case 0:
|
|
832
849
|
account = typeof address === "string" ? address : address.accountId();
|
|
833
850
|
_t6 = friendbotUrl;
|
|
834
851
|
if (_t6) {
|
|
835
|
-
|
|
852
|
+
_context24.n = 2;
|
|
836
853
|
break;
|
|
837
854
|
}
|
|
838
|
-
|
|
855
|
+
_context24.n = 1;
|
|
839
856
|
return this.getNetwork();
|
|
840
857
|
case 1:
|
|
841
|
-
_t6 =
|
|
858
|
+
_t6 = _context24.v.friendbotUrl;
|
|
842
859
|
case 2:
|
|
843
860
|
friendbotUrl = _t6;
|
|
844
861
|
if (friendbotUrl) {
|
|
845
|
-
|
|
862
|
+
_context24.n = 3;
|
|
846
863
|
break;
|
|
847
864
|
}
|
|
848
865
|
throw new Error("No friendbot URL configured for current network");
|
|
849
866
|
case 3:
|
|
850
|
-
|
|
851
|
-
|
|
867
|
+
_context24.p = 3;
|
|
868
|
+
_context24.n = 4;
|
|
852
869
|
return this.httpClient.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(account)));
|
|
853
870
|
case 4:
|
|
854
|
-
response =
|
|
871
|
+
response = _context24.v;
|
|
855
872
|
if (response.data.result_meta_xdr) {
|
|
856
|
-
|
|
873
|
+
_context24.n = 7;
|
|
857
874
|
break;
|
|
858
875
|
}
|
|
859
|
-
|
|
876
|
+
_context24.n = 5;
|
|
860
877
|
return this.getTransaction(response.data.hash);
|
|
861
878
|
case 5:
|
|
862
|
-
txMeta =
|
|
879
|
+
txMeta = _context24.v;
|
|
863
880
|
if (!(txMeta.status !== _api.Api.GetTransactionStatus.SUCCESS)) {
|
|
864
|
-
|
|
881
|
+
_context24.n = 6;
|
|
865
882
|
break;
|
|
866
883
|
}
|
|
867
884
|
throw new Error("Funding account ".concat(address, " failed"));
|
|
868
885
|
case 6:
|
|
869
886
|
meta = txMeta.resultMetaXdr;
|
|
870
|
-
|
|
887
|
+
_context24.n = 8;
|
|
871
888
|
break;
|
|
872
889
|
case 7:
|
|
873
890
|
meta = _stellarBase.xdr.TransactionMeta.fromXDR(response.data.result_meta_xdr, "base64");
|
|
874
891
|
case 8:
|
|
875
892
|
sequence = findCreatedAccountSequenceInTransactionMeta(meta);
|
|
876
|
-
return
|
|
893
|
+
return _context24.a(2, new _stellarBase.Account(account, sequence));
|
|
877
894
|
case 9:
|
|
878
|
-
|
|
879
|
-
_t7 =
|
|
895
|
+
_context24.p = 9;
|
|
896
|
+
_t7 = _context24.v;
|
|
880
897
|
if (!(((_error$response = _t7.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 400)) {
|
|
881
|
-
|
|
898
|
+
_context24.n = 10;
|
|
882
899
|
break;
|
|
883
900
|
}
|
|
884
|
-
if (!((_error$response$
|
|
885
|
-
|
|
901
|
+
if (!((_error$response$data = _t7.response.data) !== null && _error$response$data !== void 0 && (_error$response$data = _error$response$data.detail) !== null && _error$response$data !== void 0 && _error$response$data.includes("createAccountAlreadyExist"))) {
|
|
902
|
+
_context24.n = 10;
|
|
886
903
|
break;
|
|
887
904
|
}
|
|
888
|
-
return
|
|
905
|
+
return _context24.a(2, this.getAccount(account));
|
|
889
906
|
case 10:
|
|
890
907
|
throw _t7;
|
|
891
908
|
case 11:
|
|
892
|
-
return
|
|
909
|
+
return _context24.a(2);
|
|
893
910
|
}
|
|
894
|
-
},
|
|
911
|
+
}, _callee24, this, [[3, 9]]);
|
|
895
912
|
}));
|
|
896
913
|
function requestAirdrop(_x29, _x30) {
|
|
897
914
|
return _requestAirdrop.apply(this, arguments);
|
|
@@ -901,64 +918,64 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
901
918
|
}, {
|
|
902
919
|
key: "fundAddress",
|
|
903
920
|
value: (function () {
|
|
904
|
-
var _fundAddress = _asyncToGenerator(_regenerator().m(function
|
|
905
|
-
var response, txResponse, _error$response2, _error$response$data$, _error$response$
|
|
906
|
-
return _regenerator().w(function (
|
|
907
|
-
while (1) switch (
|
|
921
|
+
var _fundAddress = _asyncToGenerator(_regenerator().m(function _callee25(address, friendbotUrl) {
|
|
922
|
+
var response, txResponse, _error$response2, _error$response$data$, _error$response$data2, _t8, _t9;
|
|
923
|
+
return _regenerator().w(function (_context25) {
|
|
924
|
+
while (1) switch (_context25.p = _context25.n) {
|
|
908
925
|
case 0:
|
|
909
926
|
if (!(!_stellarBase.StrKey.isValidEd25519PublicKey(address) && !_stellarBase.StrKey.isValidContract(address))) {
|
|
910
|
-
|
|
927
|
+
_context25.n = 1;
|
|
911
928
|
break;
|
|
912
929
|
}
|
|
913
930
|
throw new Error("Invalid address: ".concat(address, ". Expected a Stellar account (G...) or contract (C...) address."));
|
|
914
931
|
case 1:
|
|
915
932
|
_t8 = friendbotUrl;
|
|
916
933
|
if (_t8) {
|
|
917
|
-
|
|
934
|
+
_context25.n = 3;
|
|
918
935
|
break;
|
|
919
936
|
}
|
|
920
|
-
|
|
937
|
+
_context25.n = 2;
|
|
921
938
|
return this.getNetwork();
|
|
922
939
|
case 2:
|
|
923
|
-
_t8 =
|
|
940
|
+
_t8 = _context25.v.friendbotUrl;
|
|
924
941
|
case 3:
|
|
925
942
|
friendbotUrl = _t8;
|
|
926
943
|
if (friendbotUrl) {
|
|
927
|
-
|
|
944
|
+
_context25.n = 4;
|
|
928
945
|
break;
|
|
929
946
|
}
|
|
930
947
|
throw new Error("No friendbot URL configured for current network");
|
|
931
948
|
case 4:
|
|
932
|
-
|
|
933
|
-
|
|
949
|
+
_context25.p = 4;
|
|
950
|
+
_context25.n = 5;
|
|
934
951
|
return this.httpClient.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(address)));
|
|
935
952
|
case 5:
|
|
936
|
-
response =
|
|
937
|
-
|
|
953
|
+
response = _context25.v;
|
|
954
|
+
_context25.n = 6;
|
|
938
955
|
return this.getTransaction(response.data.hash);
|
|
939
956
|
case 6:
|
|
940
|
-
txResponse =
|
|
957
|
+
txResponse = _context25.v;
|
|
941
958
|
if (!(txResponse.status !== _api.Api.GetTransactionStatus.SUCCESS)) {
|
|
942
|
-
|
|
959
|
+
_context25.n = 7;
|
|
943
960
|
break;
|
|
944
961
|
}
|
|
945
962
|
throw new Error("Funding address ".concat(address, " failed: transaction status ").concat(txResponse.status));
|
|
946
963
|
case 7:
|
|
947
|
-
return
|
|
964
|
+
return _context25.a(2, txResponse);
|
|
948
965
|
case 8:
|
|
949
|
-
|
|
950
|
-
_t9 =
|
|
966
|
+
_context25.p = 8;
|
|
967
|
+
_t9 = _context25.v;
|
|
951
968
|
if (!(((_error$response2 = _t9.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) === 400)) {
|
|
952
|
-
|
|
969
|
+
_context25.n = 9;
|
|
953
970
|
break;
|
|
954
971
|
}
|
|
955
|
-
throw new Error((_error$response$data$ = (_error$response$
|
|
972
|
+
throw new Error((_error$response$data$ = (_error$response$data2 = _t9.response.data) === null || _error$response$data2 === void 0 ? void 0 : _error$response$data2.detail) !== null && _error$response$data$ !== void 0 ? _error$response$data$ : "Bad Request");
|
|
956
973
|
case 9:
|
|
957
974
|
throw _t9;
|
|
958
975
|
case 10:
|
|
959
|
-
return
|
|
976
|
+
return _context25.a(2);
|
|
960
977
|
}
|
|
961
|
-
},
|
|
978
|
+
}, _callee25, this, [[4, 8]]);
|
|
962
979
|
}));
|
|
963
980
|
function fundAddress(_x31, _x32) {
|
|
964
981
|
return _fundAddress.apply(this, arguments);
|
|
@@ -968,13 +985,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
968
985
|
}, {
|
|
969
986
|
key: "getFeeStats",
|
|
970
987
|
value: (function () {
|
|
971
|
-
var _getFeeStats = _asyncToGenerator(_regenerator().m(function
|
|
972
|
-
return _regenerator().w(function (
|
|
973
|
-
while (1) switch (
|
|
988
|
+
var _getFeeStats = _asyncToGenerator(_regenerator().m(function _callee26() {
|
|
989
|
+
return _regenerator().w(function (_context26) {
|
|
990
|
+
while (1) switch (_context26.n) {
|
|
974
991
|
case 0:
|
|
975
|
-
return
|
|
992
|
+
return _context26.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getFeeStats"));
|
|
976
993
|
}
|
|
977
|
-
},
|
|
994
|
+
}, _callee26, this);
|
|
978
995
|
}));
|
|
979
996
|
function getFeeStats() {
|
|
980
997
|
return _getFeeStats.apply(this, arguments);
|
|
@@ -984,13 +1001,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
984
1001
|
}, {
|
|
985
1002
|
key: "getVersionInfo",
|
|
986
1003
|
value: (function () {
|
|
987
|
-
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function
|
|
988
|
-
return _regenerator().w(function (
|
|
989
|
-
while (1) switch (
|
|
1004
|
+
var _getVersionInfo = _asyncToGenerator(_regenerator().m(function _callee27() {
|
|
1005
|
+
return _regenerator().w(function (_context27) {
|
|
1006
|
+
while (1) switch (_context27.n) {
|
|
990
1007
|
case 0:
|
|
991
|
-
return
|
|
1008
|
+
return _context27.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getVersionInfo"));
|
|
992
1009
|
}
|
|
993
|
-
},
|
|
1010
|
+
}, _callee27, this);
|
|
994
1011
|
}));
|
|
995
1012
|
function getVersionInfo() {
|
|
996
1013
|
return _getVersionInfo.apply(this, arguments);
|
|
@@ -1000,32 +1017,32 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1000
1017
|
}, {
|
|
1001
1018
|
key: "getSACBalance",
|
|
1002
1019
|
value: (function () {
|
|
1003
|
-
var _getSACBalance = _asyncToGenerator(_regenerator().m(function
|
|
1020
|
+
var _getSACBalance = _asyncToGenerator(_regenerator().m(function _callee28(address, sac, networkPassphrase) {
|
|
1004
1021
|
var addressString, passphrase, sacId, key, ledgerKey, response, _response$entries$2, lastModifiedLedgerSeq, liveUntilLedgerSeq, val, entry, _t0;
|
|
1005
|
-
return _regenerator().w(function (
|
|
1006
|
-
while (1) switch (
|
|
1022
|
+
return _regenerator().w(function (_context28) {
|
|
1023
|
+
while (1) switch (_context28.n) {
|
|
1007
1024
|
case 0:
|
|
1008
1025
|
addressString = address instanceof _stellarBase.Address ? address.toString() : address;
|
|
1009
1026
|
if (_stellarBase.StrKey.isValidContract(addressString)) {
|
|
1010
|
-
|
|
1027
|
+
_context28.n = 1;
|
|
1011
1028
|
break;
|
|
1012
1029
|
}
|
|
1013
1030
|
throw new TypeError("expected contract ID, got ".concat(addressString));
|
|
1014
1031
|
case 1:
|
|
1015
1032
|
if (!(networkPassphrase !== null && networkPassphrase !== void 0)) {
|
|
1016
|
-
|
|
1033
|
+
_context28.n = 2;
|
|
1017
1034
|
break;
|
|
1018
1035
|
}
|
|
1019
1036
|
_t0 = networkPassphrase;
|
|
1020
|
-
|
|
1037
|
+
_context28.n = 4;
|
|
1021
1038
|
break;
|
|
1022
1039
|
case 2:
|
|
1023
|
-
|
|
1040
|
+
_context28.n = 3;
|
|
1024
1041
|
return this.getNetwork().then(function (n) {
|
|
1025
1042
|
return n.passphrase;
|
|
1026
1043
|
});
|
|
1027
1044
|
case 3:
|
|
1028
|
-
_t0 =
|
|
1045
|
+
_t0 = _context28.v;
|
|
1029
1046
|
case 4:
|
|
1030
1047
|
passphrase = _t0;
|
|
1031
1048
|
sacId = sac.contractId(passphrase);
|
|
@@ -1037,29 +1054,29 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1037
1054
|
durability: _stellarBase.xdr.ContractDataDurability.persistent(),
|
|
1038
1055
|
key: key
|
|
1039
1056
|
}));
|
|
1040
|
-
|
|
1057
|
+
_context28.n = 5;
|
|
1041
1058
|
return this.getLedgerEntries(ledgerKey);
|
|
1042
1059
|
case 5:
|
|
1043
|
-
response =
|
|
1060
|
+
response = _context28.v;
|
|
1044
1061
|
if (!(response.entries.length === 0)) {
|
|
1045
|
-
|
|
1062
|
+
_context28.n = 6;
|
|
1046
1063
|
break;
|
|
1047
1064
|
}
|
|
1048
|
-
return
|
|
1065
|
+
return _context28.a(2, {
|
|
1049
1066
|
latestLedger: response.latestLedger
|
|
1050
1067
|
});
|
|
1051
1068
|
case 6:
|
|
1052
1069
|
_response$entries$2 = response.entries[0], lastModifiedLedgerSeq = _response$entries$2.lastModifiedLedgerSeq, liveUntilLedgerSeq = _response$entries$2.liveUntilLedgerSeq, val = _response$entries$2.val;
|
|
1053
1070
|
if (!(val.switch().value !== _stellarBase.xdr.LedgerEntryType.contractData().value)) {
|
|
1054
|
-
|
|
1071
|
+
_context28.n = 7;
|
|
1055
1072
|
break;
|
|
1056
1073
|
}
|
|
1057
|
-
return
|
|
1074
|
+
return _context28.a(2, {
|
|
1058
1075
|
latestLedger: response.latestLedger
|
|
1059
1076
|
});
|
|
1060
1077
|
case 7:
|
|
1061
1078
|
entry = (0, _stellarBase.scValToNative)(val.contractData().val());
|
|
1062
|
-
return
|
|
1079
|
+
return _context28.a(2, {
|
|
1063
1080
|
latestLedger: response.latestLedger,
|
|
1064
1081
|
balanceEntry: {
|
|
1065
1082
|
liveUntilLedgerSeq: liveUntilLedgerSeq,
|
|
@@ -1070,7 +1087,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1070
1087
|
}
|
|
1071
1088
|
});
|
|
1072
1089
|
}
|
|
1073
|
-
},
|
|
1090
|
+
}, _callee28, this);
|
|
1074
1091
|
}));
|
|
1075
1092
|
function getSACBalance(_x33, _x34, _x35) {
|
|
1076
1093
|
return _getSACBalance.apply(this, arguments);
|
|
@@ -1080,11 +1097,11 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1080
1097
|
}, {
|
|
1081
1098
|
key: "getLedgers",
|
|
1082
1099
|
value: (function () {
|
|
1083
|
-
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function
|
|
1084
|
-
return _regenerator().w(function (
|
|
1085
|
-
while (1) switch (
|
|
1100
|
+
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function _callee29(request) {
|
|
1101
|
+
return _regenerator().w(function (_context29) {
|
|
1102
|
+
while (1) switch (_context29.n) {
|
|
1086
1103
|
case 0:
|
|
1087
|
-
return
|
|
1104
|
+
return _context29.a(2, this._getLedgers(request).then(function (raw) {
|
|
1088
1105
|
var result = {
|
|
1089
1106
|
ledgers: (raw.ledgers || []).map(_parsers.parseRawLedger),
|
|
1090
1107
|
latestLedger: raw.latestLedger,
|
|
@@ -1096,7 +1113,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1096
1113
|
return result;
|
|
1097
1114
|
}));
|
|
1098
1115
|
}
|
|
1099
|
-
},
|
|
1116
|
+
}, _callee29, this);
|
|
1100
1117
|
}));
|
|
1101
1118
|
function getLedgers(_x36) {
|
|
1102
1119
|
return _getLedgers2.apply(this, arguments);
|
|
@@ -1106,13 +1123,13 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
1106
1123
|
}, {
|
|
1107
1124
|
key: "_getLedgers",
|
|
1108
1125
|
value: function () {
|
|
1109
|
-
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function
|
|
1110
|
-
return _regenerator().w(function (
|
|
1111
|
-
while (1) switch (
|
|
1126
|
+
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function _callee30(request) {
|
|
1127
|
+
return _regenerator().w(function (_context30) {
|
|
1128
|
+
while (1) switch (_context30.n) {
|
|
1112
1129
|
case 0:
|
|
1113
|
-
return
|
|
1130
|
+
return _context30.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLedgers", request));
|
|
1114
1131
|
}
|
|
1115
|
-
},
|
|
1132
|
+
}, _callee30, this);
|
|
1116
1133
|
}));
|
|
1117
1134
|
function _getLedgers(_x37) {
|
|
1118
1135
|
return _getLedgers3.apply(this, arguments);
|
|
@@ -273,6 +273,9 @@ function verifyChallengeTxSigners(challengeTx, serverAccountID, networkPassphras
|
|
|
273
273
|
if (clientSigningKey) {
|
|
274
274
|
signersFound.splice(signersFound.indexOf(clientSigningKey), 1);
|
|
275
275
|
}
|
|
276
|
+
if (signersFound.length === 0) {
|
|
277
|
+
throw new _errors.InvalidChallengeError("None of the given signers match the transaction signatures");
|
|
278
|
+
}
|
|
276
279
|
return signersFound;
|
|
277
280
|
}
|
|
278
281
|
function verifyChallengeTxThreshold(challengeTx, serverAccountID, networkPassphrase, threshold, signerSummary, homeDomains, webAuthDomain) {
|
package/lib/rpc/api.d.ts
CHANGED
|
@@ -45,6 +45,19 @@ export declare namespace Api {
|
|
|
45
45
|
id: string;
|
|
46
46
|
sequence: number;
|
|
47
47
|
protocolVersion: string;
|
|
48
|
+
closeTime: string;
|
|
49
|
+
headerXdr: xdr.LedgerHeader;
|
|
50
|
+
metadataXdr: xdr.LedgerCloseMeta;
|
|
51
|
+
}
|
|
52
|
+
export interface RawGetLatestLedgerResponse {
|
|
53
|
+
id: string;
|
|
54
|
+
sequence: number;
|
|
55
|
+
protocolVersion: string;
|
|
56
|
+
closeTime: string;
|
|
57
|
+
/** a base-64 encoded {@link xdr.LedgerHeader} instance */
|
|
58
|
+
headerXdr: string;
|
|
59
|
+
/** a base-64 encoded {@link xdr.LedgerCloseMeta} instance */
|
|
60
|
+
metadataXdr: string;
|
|
48
61
|
}
|
|
49
62
|
export enum GetTransactionStatus {
|
|
50
63
|
SUCCESS = "SUCCESS",
|
|
@@ -454,6 +467,8 @@ export declare namespace Api {
|
|
|
454
467
|
amount: string;
|
|
455
468
|
authorized: boolean;
|
|
456
469
|
clawback: boolean;
|
|
470
|
+
authorizedToMaintainLiabilities?: boolean;
|
|
471
|
+
/** @deprecated Please use `authorizedToMaintainLiabilities` instead */
|
|
457
472
|
revocable?: boolean;
|
|
458
473
|
lastModifiedLedgerSeq?: number;
|
|
459
474
|
liveUntilLedgerSeq?: number;
|
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 = "15.0
|
|
15
|
+
var version = exports.version = "15.1.0";
|
|
16
16
|
function createHttpClient(headers) {
|
|
17
17
|
return (0, _httpClient.create)({
|
|
18
18
|
headers: _objectSpread(_objectSpread({}, headers), {}, {
|
package/lib/rpc/parsers.d.ts
CHANGED
|
@@ -44,3 +44,4 @@ export declare function parseRawLedgerEntries(raw: Api.RawGetLedgerEntriesRespon
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function parseRawSimulation(sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse): Api.SimulateTransactionResponse;
|
|
46
46
|
export declare function parseRawLedger(raw: Api.RawLedgerResponse): Api.LedgerResponse;
|
|
47
|
+
export declare function parseRawLatestLedger(raw: Api.RawGetLatestLedgerResponse): Api.GetLatestLedgerResponse;
|