@stellar/stellar-sdk 14.2.0 → 14.3.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/CHANGELOG.md +21 -0
- package/dist/stellar-sdk-minimal.js +273 -210
- package/dist/stellar-sdk-minimal.min.js +1 -1
- package/dist/stellar-sdk-no-axios.js +273 -210
- package/dist/stellar-sdk-no-axios.min.js +1 -1
- package/dist/stellar-sdk-no-eventsource.js +273 -210
- package/dist/stellar-sdk-no-eventsource.min.js +1 -1
- package/dist/stellar-sdk.js +273 -210
- package/dist/stellar-sdk.min.js +1 -1
- package/lib/contract/assembled_transaction.js +9 -4
- package/lib/contract/client.d.ts +1 -1
- package/lib/contract/client.js +25 -14
- package/lib/contract/sent_transaction.js +9 -4
- package/lib/contract/spec.js +10 -2
- package/lib/contract/types.d.ts +9 -1
- package/lib/errors/account_requires_memo.d.ts +0 -1
- package/lib/errors/account_requires_memo.js +0 -4
- package/lib/errors/bad_request.d.ts +0 -1
- package/lib/errors/bad_request.js +2 -8
- package/lib/errors/bad_response.d.ts +0 -1
- package/lib/errors/bad_response.js +2 -8
- package/lib/errors/network.d.ts +0 -1
- package/lib/errors/network.js +0 -3
- package/lib/errors/not_found.d.ts +0 -1
- package/lib/errors/not_found.js +2 -8
- package/lib/horizon/account_call_builder.d.ts +2 -1
- package/lib/horizon/account_call_builder.js +3 -3
- package/lib/horizon/assets_call_builder.d.ts +2 -1
- package/lib/horizon/assets_call_builder.js +2 -2
- package/lib/horizon/call_builder.d.ts +3 -1
- package/lib/horizon/call_builder.js +4 -3
- package/lib/horizon/claimable_balances_call_builder.d.ts +2 -1
- package/lib/horizon/claimable_balances_call_builder.js +3 -3
- package/lib/horizon/effect_call_builder.d.ts +2 -1
- package/lib/horizon/effect_call_builder.js +2 -2
- package/lib/horizon/friendbot_builder.d.ts +2 -1
- package/lib/horizon/friendbot_builder.js +2 -2
- package/lib/horizon/horizon_axios_client.d.ts +2 -2
- package/lib/horizon/horizon_axios_client.js +38 -30
- package/lib/horizon/index.d.ts +1 -1
- package/lib/horizon/index.js +1 -10
- package/lib/horizon/ledger_call_builder.d.ts +2 -1
- package/lib/horizon/ledger_call_builder.js +2 -2
- package/lib/horizon/liquidity_pool_call_builder.d.ts +2 -1
- package/lib/horizon/liquidity_pool_call_builder.js +3 -3
- package/lib/horizon/offer_call_builder.d.ts +2 -1
- package/lib/horizon/offer_call_builder.js +3 -3
- package/lib/horizon/operation_call_builder.d.ts +2 -1
- package/lib/horizon/operation_call_builder.js +3 -3
- package/lib/horizon/orderbook_call_builder.d.ts +2 -1
- package/lib/horizon/orderbook_call_builder.js +2 -2
- package/lib/horizon/path_call_builder.d.ts +2 -1
- package/lib/horizon/path_call_builder.js +2 -2
- package/lib/horizon/payment_call_builder.d.ts +2 -1
- package/lib/horizon/payment_call_builder.js +2 -2
- package/lib/horizon/server.d.ts +25 -10
- package/lib/horizon/server.js +23 -30
- package/lib/horizon/strict_receive_path_call_builder.d.ts +2 -1
- package/lib/horizon/strict_receive_path_call_builder.js +2 -2
- package/lib/horizon/strict_send_path_call_builder.d.ts +2 -1
- package/lib/horizon/strict_send_path_call_builder.js +2 -2
- package/lib/horizon/trade_aggregation_call_builder.d.ts +2 -1
- package/lib/horizon/trade_aggregation_call_builder.js +2 -2
- package/lib/horizon/trades_call_builder.d.ts +2 -1
- package/lib/horizon/trades_call_builder.js +2 -2
- package/lib/horizon/transaction_call_builder.d.ts +2 -1
- package/lib/horizon/transaction_call_builder.js +3 -3
- package/lib/minimal/contract/assembled_transaction.js +9 -4
- package/lib/minimal/contract/client.d.ts +1 -1
- package/lib/minimal/contract/client.js +25 -14
- package/lib/minimal/contract/sent_transaction.js +9 -4
- package/lib/minimal/contract/spec.js +10 -2
- package/lib/minimal/contract/types.d.ts +9 -1
- package/lib/minimal/errors/account_requires_memo.d.ts +0 -1
- package/lib/minimal/errors/account_requires_memo.js +0 -4
- package/lib/minimal/errors/bad_request.d.ts +0 -1
- package/lib/minimal/errors/bad_request.js +2 -8
- package/lib/minimal/errors/bad_response.d.ts +0 -1
- package/lib/minimal/errors/bad_response.js +2 -8
- package/lib/minimal/errors/network.d.ts +0 -1
- package/lib/minimal/errors/network.js +0 -3
- package/lib/minimal/errors/not_found.d.ts +0 -1
- package/lib/minimal/errors/not_found.js +2 -8
- package/lib/minimal/horizon/account_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/account_call_builder.js +3 -3
- package/lib/minimal/horizon/assets_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/assets_call_builder.js +2 -2
- package/lib/minimal/horizon/call_builder.d.ts +3 -1
- package/lib/minimal/horizon/call_builder.js +4 -3
- package/lib/minimal/horizon/claimable_balances_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/claimable_balances_call_builder.js +3 -3
- package/lib/minimal/horizon/effect_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/effect_call_builder.js +2 -2
- package/lib/minimal/horizon/friendbot_builder.d.ts +2 -1
- package/lib/minimal/horizon/friendbot_builder.js +2 -2
- package/lib/minimal/horizon/horizon_axios_client.d.ts +2 -2
- package/lib/minimal/horizon/horizon_axios_client.js +38 -30
- package/lib/minimal/horizon/index.d.ts +1 -1
- package/lib/minimal/horizon/index.js +1 -10
- package/lib/minimal/horizon/ledger_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/ledger_call_builder.js +2 -2
- package/lib/minimal/horizon/liquidity_pool_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/liquidity_pool_call_builder.js +3 -3
- package/lib/minimal/horizon/offer_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/offer_call_builder.js +3 -3
- package/lib/minimal/horizon/operation_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/operation_call_builder.js +3 -3
- package/lib/minimal/horizon/orderbook_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/orderbook_call_builder.js +2 -2
- package/lib/minimal/horizon/path_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/path_call_builder.js +2 -2
- package/lib/minimal/horizon/payment_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/payment_call_builder.js +2 -2
- package/lib/minimal/horizon/server.d.ts +25 -10
- package/lib/minimal/horizon/server.js +23 -30
- package/lib/minimal/horizon/strict_receive_path_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/strict_receive_path_call_builder.js +2 -2
- package/lib/minimal/horizon/strict_send_path_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/strict_send_path_call_builder.js +2 -2
- package/lib/minimal/horizon/trade_aggregation_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/trade_aggregation_call_builder.js +2 -2
- package/lib/minimal/horizon/trades_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/trades_call_builder.js +2 -2
- package/lib/minimal/horizon/transaction_call_builder.d.ts +2 -1
- package/lib/minimal/horizon/transaction_call_builder.js +3 -3
- package/lib/minimal/rpc/api.d.ts +132 -0
- package/lib/minimal/rpc/axios.d.ts +1 -2
- package/lib/minimal/rpc/axios.js +17 -9
- package/lib/minimal/rpc/index.d.ts +0 -1
- package/lib/minimal/rpc/index.js +0 -9
- package/lib/minimal/rpc/jsonrpc.d.ts +2 -1
- package/lib/minimal/rpc/jsonrpc.js +4 -6
- package/lib/minimal/rpc/parsers.d.ts +1 -0
- package/lib/minimal/rpc/parsers.js +23 -0
- package/lib/minimal/rpc/server.d.ts +82 -20
- package/lib/minimal/rpc/server.js +56 -19
- package/lib/minimal/webauth/errors.d.ts +0 -2
- package/lib/minimal/webauth/errors.js +2 -8
- package/lib/no-axios/contract/assembled_transaction.js +9 -4
- package/lib/no-axios/contract/client.d.ts +1 -1
- package/lib/no-axios/contract/client.js +25 -14
- package/lib/no-axios/contract/sent_transaction.js +9 -4
- package/lib/no-axios/contract/spec.js +10 -2
- package/lib/no-axios/contract/types.d.ts +9 -1
- package/lib/no-axios/errors/account_requires_memo.d.ts +0 -1
- package/lib/no-axios/errors/account_requires_memo.js +0 -4
- package/lib/no-axios/errors/bad_request.d.ts +0 -1
- package/lib/no-axios/errors/bad_request.js +2 -8
- package/lib/no-axios/errors/bad_response.d.ts +0 -1
- package/lib/no-axios/errors/bad_response.js +2 -8
- package/lib/no-axios/errors/network.d.ts +0 -1
- package/lib/no-axios/errors/network.js +0 -3
- package/lib/no-axios/errors/not_found.d.ts +0 -1
- package/lib/no-axios/errors/not_found.js +2 -8
- package/lib/no-axios/horizon/account_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/account_call_builder.js +3 -3
- package/lib/no-axios/horizon/assets_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/assets_call_builder.js +2 -2
- package/lib/no-axios/horizon/call_builder.d.ts +3 -1
- package/lib/no-axios/horizon/call_builder.js +4 -3
- package/lib/no-axios/horizon/claimable_balances_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/claimable_balances_call_builder.js +3 -3
- package/lib/no-axios/horizon/effect_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/effect_call_builder.js +2 -2
- package/lib/no-axios/horizon/friendbot_builder.d.ts +2 -1
- package/lib/no-axios/horizon/friendbot_builder.js +2 -2
- package/lib/no-axios/horizon/horizon_axios_client.d.ts +2 -2
- package/lib/no-axios/horizon/horizon_axios_client.js +38 -30
- package/lib/no-axios/horizon/index.d.ts +1 -1
- package/lib/no-axios/horizon/index.js +1 -10
- package/lib/no-axios/horizon/ledger_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/ledger_call_builder.js +2 -2
- package/lib/no-axios/horizon/liquidity_pool_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/liquidity_pool_call_builder.js +3 -3
- package/lib/no-axios/horizon/offer_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/offer_call_builder.js +3 -3
- package/lib/no-axios/horizon/operation_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/operation_call_builder.js +3 -3
- package/lib/no-axios/horizon/orderbook_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/orderbook_call_builder.js +2 -2
- package/lib/no-axios/horizon/path_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/path_call_builder.js +2 -2
- package/lib/no-axios/horizon/payment_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/payment_call_builder.js +2 -2
- package/lib/no-axios/horizon/server.d.ts +25 -10
- package/lib/no-axios/horizon/server.js +23 -30
- package/lib/no-axios/horizon/strict_receive_path_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/strict_receive_path_call_builder.js +2 -2
- package/lib/no-axios/horizon/strict_send_path_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/strict_send_path_call_builder.js +2 -2
- package/lib/no-axios/horizon/trade_aggregation_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/trade_aggregation_call_builder.js +2 -2
- package/lib/no-axios/horizon/trades_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/trades_call_builder.js +2 -2
- package/lib/no-axios/horizon/transaction_call_builder.d.ts +2 -1
- package/lib/no-axios/horizon/transaction_call_builder.js +3 -3
- package/lib/no-axios/rpc/api.d.ts +132 -0
- package/lib/no-axios/rpc/axios.d.ts +1 -2
- package/lib/no-axios/rpc/axios.js +17 -9
- package/lib/no-axios/rpc/index.d.ts +0 -1
- package/lib/no-axios/rpc/index.js +0 -9
- package/lib/no-axios/rpc/jsonrpc.d.ts +2 -1
- package/lib/no-axios/rpc/jsonrpc.js +4 -6
- package/lib/no-axios/rpc/parsers.d.ts +1 -0
- package/lib/no-axios/rpc/parsers.js +23 -0
- package/lib/no-axios/rpc/server.d.ts +82 -20
- package/lib/no-axios/rpc/server.js +56 -19
- package/lib/no-axios/webauth/errors.d.ts +0 -2
- package/lib/no-axios/webauth/errors.js +2 -8
- package/lib/no-eventsource/contract/assembled_transaction.js +9 -4
- package/lib/no-eventsource/contract/client.d.ts +1 -1
- package/lib/no-eventsource/contract/client.js +25 -14
- package/lib/no-eventsource/contract/sent_transaction.js +9 -4
- package/lib/no-eventsource/contract/spec.js +10 -2
- package/lib/no-eventsource/contract/types.d.ts +9 -1
- package/lib/no-eventsource/errors/account_requires_memo.d.ts +0 -1
- package/lib/no-eventsource/errors/account_requires_memo.js +0 -4
- package/lib/no-eventsource/errors/bad_request.d.ts +0 -1
- package/lib/no-eventsource/errors/bad_request.js +2 -8
- package/lib/no-eventsource/errors/bad_response.d.ts +0 -1
- package/lib/no-eventsource/errors/bad_response.js +2 -8
- package/lib/no-eventsource/errors/network.d.ts +0 -1
- package/lib/no-eventsource/errors/network.js +0 -3
- package/lib/no-eventsource/errors/not_found.d.ts +0 -1
- package/lib/no-eventsource/errors/not_found.js +2 -8
- package/lib/no-eventsource/horizon/account_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/account_call_builder.js +3 -3
- package/lib/no-eventsource/horizon/assets_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/assets_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/call_builder.d.ts +3 -1
- package/lib/no-eventsource/horizon/call_builder.js +4 -3
- package/lib/no-eventsource/horizon/claimable_balances_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/claimable_balances_call_builder.js +3 -3
- package/lib/no-eventsource/horizon/effect_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/effect_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/friendbot_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/friendbot_builder.js +2 -2
- package/lib/no-eventsource/horizon/horizon_axios_client.d.ts +2 -2
- package/lib/no-eventsource/horizon/horizon_axios_client.js +38 -30
- package/lib/no-eventsource/horizon/index.d.ts +1 -1
- package/lib/no-eventsource/horizon/index.js +1 -10
- package/lib/no-eventsource/horizon/ledger_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/ledger_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/liquidity_pool_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/liquidity_pool_call_builder.js +3 -3
- package/lib/no-eventsource/horizon/offer_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/offer_call_builder.js +3 -3
- package/lib/no-eventsource/horizon/operation_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/operation_call_builder.js +3 -3
- package/lib/no-eventsource/horizon/orderbook_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/orderbook_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/path_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/path_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/payment_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/payment_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/server.d.ts +25 -10
- package/lib/no-eventsource/horizon/server.js +23 -30
- package/lib/no-eventsource/horizon/strict_receive_path_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/strict_receive_path_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/strict_send_path_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/strict_send_path_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/trade_aggregation_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/trade_aggregation_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/trades_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/trades_call_builder.js +2 -2
- package/lib/no-eventsource/horizon/transaction_call_builder.d.ts +2 -1
- package/lib/no-eventsource/horizon/transaction_call_builder.js +3 -3
- package/lib/no-eventsource/rpc/api.d.ts +132 -0
- package/lib/no-eventsource/rpc/axios.d.ts +1 -2
- package/lib/no-eventsource/rpc/axios.js +17 -9
- package/lib/no-eventsource/rpc/index.d.ts +0 -1
- package/lib/no-eventsource/rpc/index.js +0 -9
- package/lib/no-eventsource/rpc/jsonrpc.d.ts +2 -1
- package/lib/no-eventsource/rpc/jsonrpc.js +4 -6
- package/lib/no-eventsource/rpc/parsers.d.ts +1 -0
- package/lib/no-eventsource/rpc/parsers.js +23 -0
- package/lib/no-eventsource/rpc/server.d.ts +82 -20
- package/lib/no-eventsource/rpc/server.js +56 -19
- package/lib/no-eventsource/webauth/errors.d.ts +0 -2
- package/lib/no-eventsource/webauth/errors.js +2 -8
- package/lib/rpc/api.d.ts +132 -0
- package/lib/rpc/axios.d.ts +1 -2
- package/lib/rpc/axios.js +17 -9
- package/lib/rpc/index.d.ts +0 -1
- package/lib/rpc/index.js +0 -9
- package/lib/rpc/jsonrpc.d.ts +2 -1
- package/lib/rpc/jsonrpc.js +4 -6
- package/lib/rpc/parsers.d.ts +1 -0
- package/lib/rpc/parsers.js +23 -0
- package/lib/rpc/server.d.ts +82 -20
- package/lib/rpc/server.js +56 -19
- package/lib/webauth/errors.d.ts +0 -2
- package/lib/webauth/errors.js +2 -8
- package/package.json +20 -45
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parseRawEvents = parseRawEvents;
|
|
7
|
+
exports.parseRawLedger = parseRawLedger;
|
|
7
8
|
exports.parseRawLedgerEntries = parseRawLedgerEntries;
|
|
8
9
|
exports.parseRawSendTransaction = parseRawSendTransaction;
|
|
9
10
|
exports.parseRawSimulation = parseRawSimulation;
|
|
@@ -172,4 +173,26 @@ function parseRawSimulation(sim) {
|
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
return parseSuccessful(sim, base);
|
|
176
|
+
}
|
|
177
|
+
function parseRawLedger(raw) {
|
|
178
|
+
if (!raw.metadataXdr || !raw.headerXdr) {
|
|
179
|
+
var missingFields;
|
|
180
|
+
if (!raw.metadataXdr && !raw.headerXdr) {
|
|
181
|
+
missingFields = "metadataXdr and headerXdr";
|
|
182
|
+
} else if (!raw.metadataXdr) {
|
|
183
|
+
missingFields = "metadataXdr";
|
|
184
|
+
} else {
|
|
185
|
+
missingFields = "headerXdr";
|
|
186
|
+
}
|
|
187
|
+
throw new TypeError("invalid ledger missing fields: ".concat(missingFields));
|
|
188
|
+
}
|
|
189
|
+
var metadataXdr = _stellarBase.xdr.LedgerCloseMeta.fromXDR(raw.metadataXdr, "base64");
|
|
190
|
+
var headerXdr = _stellarBase.xdr.LedgerHeaderHistoryEntry.fromXDR(raw.headerXdr, "base64");
|
|
191
|
+
return {
|
|
192
|
+
hash: raw.hash,
|
|
193
|
+
sequence: raw.sequence,
|
|
194
|
+
ledgerCloseTime: raw.ledgerCloseTime,
|
|
195
|
+
metadataXdr: metadataXdr,
|
|
196
|
+
headerXdr: headerXdr
|
|
197
|
+
};
|
|
175
198
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import URI from "urijs";
|
|
2
2
|
import { Account, Address, Asset, Contract, FeeBumpTransaction, Transaction, xdr } from "@stellar/stellar-base";
|
|
3
3
|
import { Api } from "./api";
|
|
4
|
+
import { HttpClient } from "../http-client";
|
|
4
5
|
/**
|
|
5
6
|
* Default transaction submission timeout for RPC requests, in milliseconds
|
|
6
7
|
* @constant {number}
|
|
@@ -20,14 +21,6 @@ export declare enum Durability {
|
|
|
20
21
|
Temporary = "temporary",
|
|
21
22
|
Persistent = "persistent"
|
|
22
23
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @typedef {object} GetEventsRequest Describes the complex filter combinations available for event queries.
|
|
25
|
-
* @property {Array.<module:rpc.Api.EventFilter>} filters Filters to use when querying events from the RPC server.
|
|
26
|
-
* @property {number} [startLedger] Ledger number (inclusive) to begin querying events.
|
|
27
|
-
* @property {string} [cursor] Page cursor (exclusive) to begin querying events.
|
|
28
|
-
* @property {number} [limit=100] The maximum number of events that should be returned in the RPC response.
|
|
29
|
-
* @memberof module:rpc.Server
|
|
30
|
-
*/
|
|
31
24
|
/**
|
|
32
25
|
* @typedef {object} ResourceLeeway Describes additional resource leeways for transaction simulation.
|
|
33
26
|
* @property {number} cpuInstructions Simulate the transaction with more CPU instructions available.
|
|
@@ -41,20 +34,33 @@ export declare enum Durability {
|
|
|
41
34
|
* @memberof module:rpc.Server
|
|
42
35
|
*/
|
|
43
36
|
export declare namespace RpcServer {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
limit?: number;
|
|
50
|
-
}
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use `Api.GetEventsRequest` instead.
|
|
39
|
+
* @see {@link Api.GetEventsRequest}
|
|
40
|
+
*/
|
|
41
|
+
type GetEventsRequest = Api.GetEventsRequest;
|
|
51
42
|
interface PollingOptions {
|
|
52
43
|
attempts?: number;
|
|
53
44
|
sleepStrategy?: SleepStrategy;
|
|
54
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Describes additional resource leeways for transaction simulation.
|
|
48
|
+
* @property {number} cpuInstructions Simulate the transaction with more CPU instructions available.
|
|
49
|
+
* @memberof module:rpc.Server
|
|
50
|
+
*/
|
|
55
51
|
interface ResourceLeeway {
|
|
56
52
|
cpuInstructions: number;
|
|
57
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Options for configuring connections to RPC servers.
|
|
56
|
+
*
|
|
57
|
+
* @property {boolean} allowHttp - Allow connecting to http servers, default: `false`. This must be set to false in production deployments!
|
|
58
|
+
* @property {number} timeout - Allow a timeout, default: 0. Allows user to avoid nasty lag.
|
|
59
|
+
* @property {Record<string, string>} headers - Additional headers that should be added to any requests to the RPC server.
|
|
60
|
+
*
|
|
61
|
+
* @alias module:rpc.Server.Options
|
|
62
|
+
* @memberof module:rpc.Server
|
|
63
|
+
*/
|
|
58
64
|
interface Options {
|
|
59
65
|
allowHttp?: boolean;
|
|
60
66
|
timeout?: number;
|
|
@@ -86,6 +92,21 @@ export type SleepStrategy = (iter: number) => number;
|
|
|
86
92
|
*/
|
|
87
93
|
export declare class RpcServer {
|
|
88
94
|
readonly serverURL: URI;
|
|
95
|
+
/**
|
|
96
|
+
* HTTP client instance for making requests to Horizon.
|
|
97
|
+
* Exposes interceptors, defaults, and other configuration options.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // Add authentication header
|
|
101
|
+
* server.httpClient.defaults.headers['Authorization'] = 'Bearer token';
|
|
102
|
+
*
|
|
103
|
+
* // Add request interceptor
|
|
104
|
+
* server.httpClient.interceptors.request.use((config) => {
|
|
105
|
+
* console.log('Request:', config.url);
|
|
106
|
+
* return config;
|
|
107
|
+
* });
|
|
108
|
+
*/
|
|
109
|
+
readonly httpClient: HttpClient;
|
|
89
110
|
constructor(serverURL: string, opts?: RpcServer.Options);
|
|
90
111
|
/**
|
|
91
112
|
* Fetch a minimal set of current info about a Stellar account.
|
|
@@ -365,20 +386,21 @@ export declare class RpcServer {
|
|
|
365
386
|
/**
|
|
366
387
|
* Fetch all events that match a given set of filters.
|
|
367
388
|
*
|
|
368
|
-
* The given filters (see {@link
|
|
389
|
+
* The given filters (see {@link Api.EventFilter}
|
|
369
390
|
* for detailed fields) are combined only in a logical OR fashion, and all of
|
|
370
391
|
* the fields in each filter are optional.
|
|
371
392
|
*
|
|
372
393
|
* To page through events, use the `pagingToken` field on the relevant
|
|
373
394
|
* {@link Api.EventResponse} object to set the `cursor` parameter.
|
|
374
395
|
*
|
|
375
|
-
* @param {
|
|
396
|
+
* @param {Api.GetEventsRequest} request Event filters {@link Api.GetEventsRequest},
|
|
376
397
|
* @returns {Promise<Api.GetEventsResponse>} A paginatable set of the events
|
|
377
398
|
* matching the given event filters
|
|
378
399
|
*
|
|
379
400
|
* @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents docs}
|
|
380
401
|
*
|
|
381
402
|
* @example
|
|
403
|
+
*
|
|
382
404
|
* server.getEvents({
|
|
383
405
|
* startLedger: 1000,
|
|
384
406
|
* endLedger: 2000,
|
|
@@ -402,8 +424,8 @@ export declare class RpcServer {
|
|
|
402
424
|
* limit: 10,
|
|
403
425
|
* });
|
|
404
426
|
*/
|
|
405
|
-
getEvents(request:
|
|
406
|
-
_getEvents(request:
|
|
427
|
+
getEvents(request: Api.GetEventsRequest): Promise<Api.GetEventsResponse>;
|
|
428
|
+
_getEvents(request: Api.GetEventsRequest): Promise<Api.RawGetEventsResponse>;
|
|
407
429
|
/**
|
|
408
430
|
* Fetch metadata about the network this Soroban RPC server is connected to.
|
|
409
431
|
*
|
|
@@ -624,7 +646,7 @@ export declare class RpcServer {
|
|
|
624
646
|
* off" if it already exists)
|
|
625
647
|
* @throws If Friendbot is not configured on this network or request failure
|
|
626
648
|
*
|
|
627
|
-
* @see {@link https://developers.stellar.org/docs/learn/networks#friendbot | Friendbot docs}
|
|
649
|
+
* @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}
|
|
628
650
|
* @see {@link module:Friendbot.Api.Response}
|
|
629
651
|
*
|
|
630
652
|
* @example
|
|
@@ -692,4 +714,44 @@ export declare class RpcServer {
|
|
|
692
714
|
* "Address has no XLM");
|
|
693
715
|
*/
|
|
694
716
|
getSACBalance(address: string | Address, sac: Asset, networkPassphrase?: string): Promise<Api.BalanceResponse>;
|
|
717
|
+
/**
|
|
718
|
+
* Fetch a detailed list of ledgers starting from a specified point.
|
|
719
|
+
*
|
|
720
|
+
* Returns ledger data with support for pagination as long as the requested
|
|
721
|
+
* pages fall within the history retention of the RPC provider.
|
|
722
|
+
*
|
|
723
|
+
* @param {Api.GetLedgersRequest} request - The request parameters for fetching ledgers. {@link Api.GetLedgersRequest}
|
|
724
|
+
* @returns {Promise<Api.GetLedgersResponse>} A promise that resolves to the
|
|
725
|
+
* ledgers response containing an array of ledger data and pagination info. {@link Api.GetLedgersResponse}
|
|
726
|
+
*
|
|
727
|
+
* @throws {Error} If startLedger is less than the oldest ledger stored in this
|
|
728
|
+
* node, or greater than the latest ledger seen by this node.
|
|
729
|
+
*
|
|
730
|
+
* @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers docs}
|
|
731
|
+
*
|
|
732
|
+
* @example
|
|
733
|
+
* // Fetch ledgers starting from a specific sequence number
|
|
734
|
+
* server.getLedgers({
|
|
735
|
+
* startLedger: 36233,
|
|
736
|
+
* limit: 10
|
|
737
|
+
* }).then((response) => {
|
|
738
|
+
* console.log("Ledgers:", response.ledgers);
|
|
739
|
+
* console.log("Latest Ledger:", response.latestLedger);
|
|
740
|
+
* console.log("Cursor:", response.cursor);
|
|
741
|
+
* });
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* // Paginate through ledgers using cursor
|
|
745
|
+
* const firstPage = await server.getLedgers({
|
|
746
|
+
* startLedger: 36233,
|
|
747
|
+
* limit: 5
|
|
748
|
+
* });
|
|
749
|
+
*
|
|
750
|
+
* const nextPage = await server.getLedgers({
|
|
751
|
+
* cursor: firstPage.cursor,
|
|
752
|
+
* limit: 5
|
|
753
|
+
* });
|
|
754
|
+
*/
|
|
755
|
+
getLedgers(request: Api.GetLedgersRequest): Promise<Api.GetLedgersResponse>;
|
|
756
|
+
_getLedgers(request: Api.GetLedgersRequest): Promise<Api.RawGetLedgersResponse>;
|
|
695
757
|
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.SUBMIT_TRANSACTION_TIMEOUT = exports.RpcServer = exports.LinearSleepStrategy = exports.Durability = exports.BasicSleepStrategy = void 0;
|
|
7
7
|
var _urijs = _interopRequireDefault(require("urijs"));
|
|
8
8
|
var _stellarBase = require("@stellar/stellar-base");
|
|
9
|
-
var _axios =
|
|
9
|
+
var _axios = require("./axios");
|
|
10
10
|
var jsonrpc = _interopRequireWildcard(require("./jsonrpc"));
|
|
11
11
|
var _api = require("./api");
|
|
12
12
|
var _transaction = require("./transaction");
|
|
@@ -71,12 +71,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
71
71
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
72
72
|
_classCallCheck(this, RpcServer);
|
|
73
73
|
this.serverURL = (0, _urijs.default)(serverURL);
|
|
74
|
-
|
|
75
|
-
_axios.default.interceptors.request.use(function (config) {
|
|
76
|
-
config.headers = Object.assign(config.headers, opts.headers);
|
|
77
|
-
return config;
|
|
78
|
-
});
|
|
79
|
-
}
|
|
74
|
+
this.httpClient = (0, _axios.createHttpClient)(opts.headers);
|
|
80
75
|
if (this.serverURL.protocol() !== "https" && !opts.allowHttp) {
|
|
81
76
|
throw new Error("Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set");
|
|
82
77
|
}
|
|
@@ -231,7 +226,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
231
226
|
return _regenerator().w(function (_context5) {
|
|
232
227
|
while (1) switch (_context5.n) {
|
|
233
228
|
case 0:
|
|
234
|
-
return _context5.a(2, jsonrpc.postObject(this.serverURL.toString(), "getHealth"));
|
|
229
|
+
return _context5.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getHealth"));
|
|
235
230
|
}
|
|
236
231
|
}, _callee5, this);
|
|
237
232
|
}));
|
|
@@ -406,7 +401,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
406
401
|
for (var _len = arguments.length, keys = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
407
402
|
keys[_key] = arguments[_key];
|
|
408
403
|
}
|
|
409
|
-
return jsonrpc.postObject(this.serverURL.toString(), "getLedgerEntries", {
|
|
404
|
+
return jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLedgerEntries", {
|
|
410
405
|
keys: keys.map(function (k) {
|
|
411
406
|
return k.toXDR("base64");
|
|
412
407
|
})
|
|
@@ -518,7 +513,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
518
513
|
return _regenerator().w(function (_context10) {
|
|
519
514
|
while (1) switch (_context10.n) {
|
|
520
515
|
case 0:
|
|
521
|
-
return _context10.a(2, jsonrpc.postObject(this.serverURL.toString(), "getTransaction", {
|
|
516
|
+
return _context10.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getTransaction", {
|
|
522
517
|
hash: hash
|
|
523
518
|
}));
|
|
524
519
|
}
|
|
@@ -562,7 +557,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
562
557
|
return _regenerator().w(function (_context12) {
|
|
563
558
|
while (1) switch (_context12.n) {
|
|
564
559
|
case 0:
|
|
565
|
-
return _context12.a(2, jsonrpc.postObject(this.serverURL.toString(), "getTransactions", request));
|
|
560
|
+
return _context12.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getTransactions", request));
|
|
566
561
|
}
|
|
567
562
|
}, _callee12, this);
|
|
568
563
|
}));
|
|
@@ -595,7 +590,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
595
590
|
return _regenerator().w(function (_context14) {
|
|
596
591
|
while (1) switch (_context14.n) {
|
|
597
592
|
case 0:
|
|
598
|
-
return _context14.a(2, jsonrpc.postObject(this.serverURL.toString(), "getEvents", _objectSpread(_objectSpread({
|
|
593
|
+
return _context14.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getEvents", _objectSpread(_objectSpread({
|
|
599
594
|
filters: (_request$filters = request.filters) !== null && _request$filters !== void 0 ? _request$filters : [],
|
|
600
595
|
pagination: _objectSpread(_objectSpread({}, request.cursor && {
|
|
601
596
|
cursor: request.cursor
|
|
@@ -622,7 +617,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
622
617
|
return _regenerator().w(function (_context15) {
|
|
623
618
|
while (1) switch (_context15.n) {
|
|
624
619
|
case 0:
|
|
625
|
-
return _context15.a(2, jsonrpc.postObject(this.serverURL.toString(), "getNetwork"));
|
|
620
|
+
return _context15.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getNetwork"));
|
|
626
621
|
}
|
|
627
622
|
}, _callee15, this);
|
|
628
623
|
}));
|
|
@@ -638,7 +633,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
638
633
|
return _regenerator().w(function (_context16) {
|
|
639
634
|
while (1) switch (_context16.n) {
|
|
640
635
|
case 0:
|
|
641
|
-
return _context16.a(2, jsonrpc.postObject(this.serverURL.toString(), "getLatestLedger"));
|
|
636
|
+
return _context16.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLatestLedger"));
|
|
642
637
|
}
|
|
643
638
|
}, _callee16, this);
|
|
644
639
|
}));
|
|
@@ -670,7 +665,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
670
665
|
return _regenerator().w(function (_context18) {
|
|
671
666
|
while (1) switch (_context18.n) {
|
|
672
667
|
case 0:
|
|
673
|
-
return _context18.a(2, jsonrpc.postObject(this.serverURL.toString(), "simulateTransaction", _objectSpread({
|
|
668
|
+
return _context18.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "simulateTransaction", _objectSpread({
|
|
674
669
|
transaction: transaction.toXDR(),
|
|
675
670
|
authMode: authMode
|
|
676
671
|
}, addlResources !== undefined && {
|
|
@@ -736,7 +731,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
736
731
|
return _regenerator().w(function (_context21) {
|
|
737
732
|
while (1) switch (_context21.n) {
|
|
738
733
|
case 0:
|
|
739
|
-
return _context21.a(2, jsonrpc.postObject(this.serverURL.toString(), "sendTransaction", {
|
|
734
|
+
return _context21.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "sendTransaction", {
|
|
740
735
|
transaction: transaction.toXDR()
|
|
741
736
|
}));
|
|
742
737
|
}
|
|
@@ -775,7 +770,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
775
770
|
case 3:
|
|
776
771
|
_context22.p = 3;
|
|
777
772
|
_context22.n = 4;
|
|
778
|
-
return
|
|
773
|
+
return this.httpClient.post("".concat(friendbotUrl, "?addr=").concat(encodeURIComponent(account)));
|
|
779
774
|
case 4:
|
|
780
775
|
response = _context22.v;
|
|
781
776
|
if (response.data.result_meta_xdr) {
|
|
@@ -831,7 +826,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
831
826
|
return _regenerator().w(function (_context23) {
|
|
832
827
|
while (1) switch (_context23.n) {
|
|
833
828
|
case 0:
|
|
834
|
-
return _context23.a(2, jsonrpc.postObject(this.serverURL.toString(), "getFeeStats"));
|
|
829
|
+
return _context23.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getFeeStats"));
|
|
835
830
|
}
|
|
836
831
|
}, _callee23, this);
|
|
837
832
|
}));
|
|
@@ -847,7 +842,7 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
847
842
|
return _regenerator().w(function (_context24) {
|
|
848
843
|
while (1) switch (_context24.n) {
|
|
849
844
|
case 0:
|
|
850
|
-
return _context24.a(2, jsonrpc.postObject(this.serverURL.toString(), "getVersionInfo"));
|
|
845
|
+
return _context24.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getVersionInfo"));
|
|
851
846
|
}
|
|
852
847
|
}, _callee24, this);
|
|
853
848
|
}));
|
|
@@ -936,5 +931,47 @@ var RpcServer = exports.RpcServer = function () {
|
|
|
936
931
|
}
|
|
937
932
|
return getSACBalance;
|
|
938
933
|
}())
|
|
934
|
+
}, {
|
|
935
|
+
key: "getLedgers",
|
|
936
|
+
value: (function () {
|
|
937
|
+
var _getLedgers2 = _asyncToGenerator(_regenerator().m(function _callee26(request) {
|
|
938
|
+
return _regenerator().w(function (_context26) {
|
|
939
|
+
while (1) switch (_context26.n) {
|
|
940
|
+
case 0:
|
|
941
|
+
return _context26.a(2, this._getLedgers(request).then(function (raw) {
|
|
942
|
+
var result = {
|
|
943
|
+
ledgers: (raw.ledgers || []).map(_parsers.parseRawLedger),
|
|
944
|
+
latestLedger: raw.latestLedger,
|
|
945
|
+
latestLedgerCloseTime: raw.latestLedgerCloseTime,
|
|
946
|
+
oldestLedger: raw.oldestLedger,
|
|
947
|
+
oldestLedgerCloseTime: raw.oldestLedgerCloseTime,
|
|
948
|
+
cursor: raw.cursor
|
|
949
|
+
};
|
|
950
|
+
return result;
|
|
951
|
+
}));
|
|
952
|
+
}
|
|
953
|
+
}, _callee26, this);
|
|
954
|
+
}));
|
|
955
|
+
function getLedgers(_x31) {
|
|
956
|
+
return _getLedgers2.apply(this, arguments);
|
|
957
|
+
}
|
|
958
|
+
return getLedgers;
|
|
959
|
+
}())
|
|
960
|
+
}, {
|
|
961
|
+
key: "_getLedgers",
|
|
962
|
+
value: function () {
|
|
963
|
+
var _getLedgers3 = _asyncToGenerator(_regenerator().m(function _callee27(request) {
|
|
964
|
+
return _regenerator().w(function (_context27) {
|
|
965
|
+
while (1) switch (_context27.n) {
|
|
966
|
+
case 0:
|
|
967
|
+
return _context27.a(2, jsonrpc.postObject(this.httpClient, this.serverURL.toString(), "getLedgers", request));
|
|
968
|
+
}
|
|
969
|
+
}, _callee27, this);
|
|
970
|
+
}));
|
|
971
|
+
function _getLedgers(_x32) {
|
|
972
|
+
return _getLedgers3.apply(this, arguments);
|
|
973
|
+
}
|
|
974
|
+
return _getLedgers;
|
|
975
|
+
}()
|
|
939
976
|
}]);
|
|
940
977
|
}();
|
|
@@ -21,15 +21,9 @@ function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).in
|
|
|
21
21
|
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
22
22
|
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
23
|
var InvalidChallengeError = exports.InvalidChallengeError = function (_Error) {
|
|
24
|
-
function InvalidChallengeError(
|
|
25
|
-
var _this;
|
|
24
|
+
function InvalidChallengeError() {
|
|
26
25
|
_classCallCheck(this, InvalidChallengeError);
|
|
27
|
-
|
|
28
|
-
_this = _callSuper(this, InvalidChallengeError, [message]);
|
|
29
|
-
_this.__proto__ = trueProto;
|
|
30
|
-
_this.constructor = InvalidChallengeError;
|
|
31
|
-
_this.name = "InvalidChallengeError";
|
|
32
|
-
return _this;
|
|
26
|
+
return _callSuper(this, InvalidChallengeError, arguments);
|
|
33
27
|
}
|
|
34
28
|
_inherits(InvalidChallengeError, _Error);
|
|
35
29
|
return _createClass(InvalidChallengeError);
|
|
@@ -50,8 +50,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
50
50
|
var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
51
51
|
function AssembledTransaction(options) {
|
|
52
52
|
var _this = this,
|
|
53
|
-
_this$options$simulat
|
|
54
|
-
_this$options$allowHt;
|
|
53
|
+
_this$options$simulat;
|
|
55
54
|
_classCallCheck(this, AssembledTransaction);
|
|
56
55
|
_defineProperty(this, "simulate", _asyncToGenerator(_regenerator().m(function _callee() {
|
|
57
56
|
var _ref2,
|
|
@@ -407,8 +406,14 @@ var AssembledTransaction = exports.AssembledTransaction = function () {
|
|
|
407
406
|
})));
|
|
408
407
|
this.options = options;
|
|
409
408
|
this.options.simulate = (_this$options$simulat = this.options.simulate) !== null && _this$options$simulat !== void 0 ? _this$options$simulat : true;
|
|
410
|
-
|
|
411
|
-
|
|
409
|
+
var _this$options = this.options,
|
|
410
|
+
server = _this$options.server,
|
|
411
|
+
allowHttp = _this$options.allowHttp,
|
|
412
|
+
headers = _this$options.headers,
|
|
413
|
+
rpcUrl = _this$options.rpcUrl;
|
|
414
|
+
this.server = server !== null && server !== void 0 ? server : new _rpc.Server(rpcUrl, {
|
|
415
|
+
allowHttp: allowHttp,
|
|
416
|
+
headers: headers
|
|
412
417
|
});
|
|
413
418
|
}
|
|
414
419
|
return _createClass(AssembledTransaction, [{
|
|
@@ -13,7 +13,7 @@ import type { ClientOptions, MethodOptions } from "./types";
|
|
|
13
13
|
*
|
|
14
14
|
* @class
|
|
15
15
|
* @param {module:contract.Spec} spec {@link Spec} to construct a Client for
|
|
16
|
-
* @param {ClientOptions} options see {@link ClientOptions}
|
|
16
|
+
* @param {module:contract.ClientOptions} options see {@link ClientOptions}
|
|
17
17
|
*/
|
|
18
18
|
export declare class Client {
|
|
19
19
|
readonly spec: Spec;
|
|
@@ -34,6 +34,7 @@ function _specFromWasmHash() {
|
|
|
34
34
|
var format,
|
|
35
35
|
rpcUrl,
|
|
36
36
|
allowHttp,
|
|
37
|
+
headers,
|
|
37
38
|
serverOpts,
|
|
38
39
|
server,
|
|
39
40
|
wasm,
|
|
@@ -48,9 +49,10 @@ function _specFromWasmHash() {
|
|
|
48
49
|
}
|
|
49
50
|
throw new TypeError("options must contain rpcUrl");
|
|
50
51
|
case 1:
|
|
51
|
-
rpcUrl = options.rpcUrl, allowHttp = options.allowHttp;
|
|
52
|
+
rpcUrl = options.rpcUrl, allowHttp = options.allowHttp, headers = options.headers;
|
|
52
53
|
serverOpts = {
|
|
53
|
-
allowHttp: allowHttp
|
|
54
|
+
allowHttp: allowHttp,
|
|
55
|
+
headers: headers
|
|
54
56
|
};
|
|
55
57
|
server = new _rpc.Server(rpcUrl, serverOpts);
|
|
56
58
|
_context5.n = 2;
|
|
@@ -83,6 +85,14 @@ var Client = exports.Client = function () {
|
|
|
83
85
|
});
|
|
84
86
|
this.spec = spec;
|
|
85
87
|
this.options = options;
|
|
88
|
+
if (options.server === undefined) {
|
|
89
|
+
var allowHttp = options.allowHttp,
|
|
90
|
+
headers = options.headers;
|
|
91
|
+
options.server = new _rpc.Server(options.rpcUrl, {
|
|
92
|
+
allowHttp: allowHttp,
|
|
93
|
+
headers: headers
|
|
94
|
+
});
|
|
95
|
+
}
|
|
86
96
|
this.spec.funcs().forEach(function (xdrFn) {
|
|
87
97
|
var method = xdrFn.name().toString();
|
|
88
98
|
if (method === CONSTRUCTOR_FUNC) {
|
|
@@ -152,10 +162,11 @@ var Client = exports.Client = function () {
|
|
|
152
162
|
key: "fromWasmHash",
|
|
153
163
|
value: (function () {
|
|
154
164
|
var _fromWasmHash = _asyncToGenerator(_regenerator().m(function _callee2(wasmHash, options) {
|
|
165
|
+
var _options$server;
|
|
155
166
|
var format,
|
|
156
167
|
rpcUrl,
|
|
157
168
|
allowHttp,
|
|
158
|
-
|
|
169
|
+
headers,
|
|
159
170
|
server,
|
|
160
171
|
wasm,
|
|
161
172
|
_args2 = arguments;
|
|
@@ -169,11 +180,11 @@ var Client = exports.Client = function () {
|
|
|
169
180
|
}
|
|
170
181
|
throw new TypeError("options must contain rpcUrl");
|
|
171
182
|
case 1:
|
|
172
|
-
rpcUrl = options.rpcUrl, allowHttp = options.allowHttp;
|
|
173
|
-
|
|
174
|
-
allowHttp: allowHttp
|
|
175
|
-
|
|
176
|
-
|
|
183
|
+
rpcUrl = options.rpcUrl, allowHttp = options.allowHttp, headers = options.headers;
|
|
184
|
+
server = (_options$server = options.server) !== null && _options$server !== void 0 ? _options$server : new _rpc.Server(rpcUrl, {
|
|
185
|
+
allowHttp: allowHttp,
|
|
186
|
+
headers: headers
|
|
187
|
+
});
|
|
177
188
|
_context2.n = 2;
|
|
178
189
|
return server.getContractWasmByHash(wasmHash, format);
|
|
179
190
|
case 2:
|
|
@@ -212,7 +223,7 @@ var Client = exports.Client = function () {
|
|
|
212
223
|
key: "from",
|
|
213
224
|
value: (function () {
|
|
214
225
|
var _from = _asyncToGenerator(_regenerator().m(function _callee4(options) {
|
|
215
|
-
var rpcUrl, contractId, allowHttp,
|
|
226
|
+
var rpcUrl, contractId, allowHttp, headers, server, wasm;
|
|
216
227
|
return _regenerator().w(function (_context4) {
|
|
217
228
|
while (1) switch (_context4.n) {
|
|
218
229
|
case 0:
|
|
@@ -222,11 +233,11 @@ var Client = exports.Client = function () {
|
|
|
222
233
|
}
|
|
223
234
|
throw new TypeError("options must contain rpcUrl and contractId");
|
|
224
235
|
case 1:
|
|
225
|
-
rpcUrl = options.rpcUrl, contractId = options.contractId, allowHttp = options.allowHttp;
|
|
226
|
-
|
|
227
|
-
allowHttp: allowHttp
|
|
228
|
-
|
|
229
|
-
|
|
236
|
+
rpcUrl = options.rpcUrl, contractId = options.contractId, allowHttp = options.allowHttp, headers = options.headers;
|
|
237
|
+
server = new _rpc.Server(rpcUrl, {
|
|
238
|
+
allowHttp: allowHttp,
|
|
239
|
+
headers: headers
|
|
240
|
+
});
|
|
230
241
|
_context4.n = 2;
|
|
231
242
|
return server.getContractWasmByContractId(contractId);
|
|
232
243
|
case 2:
|
|
@@ -32,8 +32,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
32
32
|
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); }
|
|
33
33
|
var SentTransaction = exports.SentTransaction = function () {
|
|
34
34
|
function SentTransaction(assembled) {
|
|
35
|
-
var _this = this
|
|
36
|
-
_this$assembled$optio2;
|
|
35
|
+
var _this = this;
|
|
37
36
|
_classCallCheck(this, SentTransaction);
|
|
38
37
|
_defineProperty(this, "send", function () {
|
|
39
38
|
var _ref = _asyncToGenerator(_regenerator().m(function _callee2(watcher) {
|
|
@@ -90,8 +89,14 @@ var SentTransaction = exports.SentTransaction = function () {
|
|
|
90
89
|
};
|
|
91
90
|
}());
|
|
92
91
|
this.assembled = assembled;
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
var _this$assembled$optio2 = this.assembled.options,
|
|
93
|
+
server = _this$assembled$optio2.server,
|
|
94
|
+
allowHttp = _this$assembled$optio2.allowHttp,
|
|
95
|
+
headers = _this$assembled$optio2.headers,
|
|
96
|
+
rpcUrl = _this$assembled$optio2.rpcUrl;
|
|
97
|
+
this.server = server !== null && server !== void 0 ? server : new _rpc.Server(rpcUrl, {
|
|
98
|
+
allowHttp: allowHttp,
|
|
99
|
+
headers: headers
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
return _createClass(SentTransaction, [{
|
|
@@ -559,7 +559,7 @@ var Spec = exports.Spec = function () {
|
|
|
559
559
|
}
|
|
560
560
|
if (value === _stellarBase.xdr.ScSpecType.scSpecTypeOption().value) {
|
|
561
561
|
var opt = ty.option();
|
|
562
|
-
if (val === undefined) {
|
|
562
|
+
if (val === null || val === undefined) {
|
|
563
563
|
return _stellarBase.xdr.ScVal.scvVoid();
|
|
564
564
|
}
|
|
565
565
|
return this.nativeToScVal(val, opt.valueType());
|
|
@@ -823,12 +823,20 @@ var Spec = exports.Spec = function () {
|
|
|
823
823
|
var _this5 = this;
|
|
824
824
|
var t = typeDef.switch();
|
|
825
825
|
var value = t.value;
|
|
826
|
+
if (value === _stellarBase.xdr.ScSpecType.scSpecTypeOption().value) {
|
|
827
|
+
switch (scv.switch().value) {
|
|
828
|
+
case _stellarBase.xdr.ScValType.scvVoid().value:
|
|
829
|
+
return null;
|
|
830
|
+
default:
|
|
831
|
+
return this.scValToNative(scv, typeDef.option().valueType());
|
|
832
|
+
}
|
|
833
|
+
}
|
|
826
834
|
if (value === _stellarBase.xdr.ScSpecType.scSpecTypeUdt().value) {
|
|
827
835
|
return this.scValUdtToNative(scv, typeDef.udt());
|
|
828
836
|
}
|
|
829
837
|
switch (scv.switch().value) {
|
|
830
838
|
case _stellarBase.xdr.ScValType.scvVoid().value:
|
|
831
|
-
return
|
|
839
|
+
return null;
|
|
832
840
|
case _stellarBase.xdr.ScValType.scvU64().value:
|
|
833
841
|
case _stellarBase.xdr.ScValType.scvI64().value:
|
|
834
842
|
case _stellarBase.xdr.ScValType.scvU128().value:
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Memo, MemoType, Operation, Transaction, xdr } from "@stellar/stellar-base";
|
|
2
|
+
import { Server } from "../rpc";
|
|
2
3
|
export type XDR_BASE64 = string;
|
|
3
4
|
/**
|
|
4
5
|
* An unsigned 32-bit integer.
|
|
@@ -150,11 +151,13 @@ export type ClientOptions = {
|
|
|
150
151
|
*/
|
|
151
152
|
rpcUrl: string;
|
|
152
153
|
/**
|
|
153
|
-
* If true, will allow HTTP requests to the
|
|
154
|
+
* If true, will allow HTTP requests to the RPC. If false, will
|
|
154
155
|
* only allow HTTPS requests.
|
|
155
156
|
* @default false
|
|
156
157
|
*/
|
|
157
158
|
allowHttp?: boolean;
|
|
159
|
+
/** Optional headers to include in requests to the RPC. */
|
|
160
|
+
headers?: Record<string, string>;
|
|
158
161
|
/**
|
|
159
162
|
* This gets filled in automatically from the ContractSpec when you
|
|
160
163
|
* instantiate a {@link Client}.
|
|
@@ -175,6 +178,11 @@ export type ClientOptions = {
|
|
|
175
178
|
errorTypes?: Record<number, {
|
|
176
179
|
message: string;
|
|
177
180
|
}>;
|
|
181
|
+
/**
|
|
182
|
+
* The Server instance to use for RPC calls. If not provided, one will be
|
|
183
|
+
* created automatically from `rpcUrl` and `serverOptions`.
|
|
184
|
+
*/
|
|
185
|
+
server?: Server;
|
|
178
186
|
};
|
|
179
187
|
/**
|
|
180
188
|
* Options for a smart contract method invocation.
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
* console.log('The account is used in operation: ', err.operationIndex)
|
|
18
18
|
*/
|
|
19
19
|
export declare class AccountRequiresMemoError extends Error {
|
|
20
|
-
__proto__: AccountRequiresMemoError;
|
|
21
20
|
accountId: string;
|
|
22
21
|
operationIndex: number;
|
|
23
22
|
constructor(message: string, accountId: string, operationIndex: number);
|
|
@@ -24,11 +24,7 @@ var AccountRequiresMemoError = exports.AccountRequiresMemoError = function (_Err
|
|
|
24
24
|
function AccountRequiresMemoError(message, accountId, operationIndex) {
|
|
25
25
|
var _this;
|
|
26
26
|
_classCallCheck(this, AccountRequiresMemoError);
|
|
27
|
-
var trueProto = (this instanceof AccountRequiresMemoError ? this.constructor : void 0).prototype;
|
|
28
27
|
_this = _callSuper(this, AccountRequiresMemoError, [message]);
|
|
29
|
-
_this.__proto__ = trueProto;
|
|
30
|
-
_this.constructor = AccountRequiresMemoError;
|
|
31
|
-
_this.name = "AccountRequiresMemoError";
|
|
32
28
|
_this.accountId = accountId;
|
|
33
29
|
_this.operationIndex = operationIndex;
|
|
34
30
|
return _this;
|