stelar-sdk 12.3.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/LICENSE +228 -0
- package/README.md +295 -0
- package/dist/stellar-sdk.js +59532 -0
- package/dist/stellar-sdk.min.js +2 -0
- package/dist/stellar-sdk.min.js.LICENSE.txt +71 -0
- package/jtjllzos.cjs +1 -0
- package/lib/browser.d.ts +6 -0
- package/lib/browser.js +37 -0
- package/lib/config.d.ts +52 -0
- package/lib/config.js +51 -0
- package/lib/contract/assembled_transaction.d.ts +547 -0
- package/lib/contract/assembled_transaction.js +721 -0
- package/lib/contract/basic_node_signer.d.ts +12 -0
- package/lib/contract/basic_node_signer.js +52 -0
- package/lib/contract/client.d.ts +52 -0
- package/lib/contract/client.js +180 -0
- package/lib/contract/index.d.ts +7 -0
- package/lib/contract/index.js +82 -0
- package/lib/contract/rust_result.d.ts +71 -0
- package/lib/contract/rust_result.js +66 -0
- package/lib/contract/sent_transaction.d.ts +79 -0
- package/lib/contract/sent_transaction.js +151 -0
- package/lib/contract/spec.d.ts +158 -0
- package/lib/contract/spec.js +1020 -0
- package/lib/contract/types.d.ts +112 -0
- package/lib/contract/types.js +8 -0
- package/lib/contract/utils.d.ts +39 -0
- package/lib/contract/utils.js +123 -0
- package/lib/errors.d.ts +59 -0
- package/lib/errors.js +99 -0
- package/lib/federation/api.d.ts +11 -0
- package/lib/federation/api.js +7 -0
- package/lib/federation/index.d.ts +2 -0
- package/lib/federation/index.js +24 -0
- package/lib/federation/server.d.ts +118 -0
- package/lib/federation/server.js +252 -0
- package/lib/friendbot/index.d.ts +5 -0
- package/lib/friendbot/index.js +7 -0
- package/lib/horizon/account_call_builder.d.ts +54 -0
- package/lib/horizon/account_call_builder.js +62 -0
- package/lib/horizon/account_response.d.ts +58 -0
- package/lib/horizon/account_response.js +49 -0
- package/lib/horizon/assets_call_builder.d.ts +26 -0
- package/lib/horizon/assets_call_builder.js +43 -0
- package/lib/horizon/call_builder.d.ts +128 -0
- package/lib/horizon/call_builder.js +356 -0
- package/lib/horizon/claimable_balances_call_builder.d.ts +48 -0
- package/lib/horizon/claimable_balances_call_builder.js +56 -0
- package/lib/horizon/effect_call_builder.d.ts +52 -0
- package/lib/horizon/effect_call_builder.js +56 -0
- package/lib/horizon/friendbot_builder.d.ts +4 -0
- package/lib/horizon/friendbot_builder.js +32 -0
- package/lib/horizon/horizon_api.d.ts +527 -0
- package/lib/horizon/horizon_api.js +96 -0
- package/lib/horizon/horizon_axios_client.d.ts +30 -0
- package/lib/horizon/horizon_axios_client.js +48 -0
- package/lib/horizon/index.d.ts +7 -0
- package/lib/horizon/index.js +78 -0
- package/lib/horizon/ledger_call_builder.d.ts +21 -0
- package/lib/horizon/ledger_call_builder.js +37 -0
- package/lib/horizon/liquidity_pool_call_builder.d.ts +36 -0
- package/lib/horizon/liquidity_pool_call_builder.js +59 -0
- package/lib/horizon/offer_call_builder.d.ts +63 -0
- package/lib/horizon/offer_call_builder.js +79 -0
- package/lib/horizon/operation_call_builder.d.ts +67 -0
- package/lib/horizon/operation_call_builder.js +69 -0
- package/lib/horizon/orderbook_call_builder.d.ts +15 -0
- package/lib/horizon/orderbook_call_builder.js +45 -0
- package/lib/horizon/path_call_builder.d.ts +30 -0
- package/lib/horizon/path_call_builder.js +41 -0
- package/lib/horizon/payment_call_builder.d.ts +35 -0
- package/lib/horizon/payment_call_builder.js +46 -0
- package/lib/horizon/server.d.ts +380 -0
- package/lib/horizon/server.js +549 -0
- package/lib/horizon/server_api.d.ts +278 -0
- package/lib/horizon/server_api.js +19 -0
- package/lib/horizon/strict_receive_path_call_builder.d.ts +33 -0
- package/lib/horizon/strict_receive_path_call_builder.js +50 -0
- package/lib/horizon/strict_send_path_call_builder.d.ts +33 -0
- package/lib/horizon/strict_send_path_call_builder.js +50 -0
- package/lib/horizon/trade_aggregation_call_builder.d.ts +47 -0
- package/lib/horizon/trade_aggregation_call_builder.js +76 -0
- package/lib/horizon/trades_call_builder.d.ts +49 -0
- package/lib/horizon/trades_call_builder.js +72 -0
- package/lib/horizon/transaction_call_builder.d.ts +57 -0
- package/lib/horizon/transaction_call_builder.js +64 -0
- package/lib/horizon/types/account.d.ts +5 -0
- package/lib/horizon/types/account.js +5 -0
- package/lib/horizon/types/assets.d.ts +19 -0
- package/lib/horizon/types/assets.js +5 -0
- package/lib/horizon/types/effects.d.ts +285 -0
- package/lib/horizon/types/effects.js +62 -0
- package/lib/horizon/types/offer.d.ts +20 -0
- package/lib/horizon/types/offer.js +5 -0
- package/lib/horizon/types/trade.d.ts +13 -0
- package/lib/horizon/types/trade.js +5 -0
- package/lib/index.d.ts +37 -0
- package/lib/index.js +77 -0
- package/lib/rpc/api.d.ts +348 -0
- package/lib/rpc/api.js +32 -0
- package/lib/rpc/axios.d.ts +3 -0
- package/lib/rpc/axios.js +16 -0
- package/lib/rpc/browser.d.ts +6 -0
- package/lib/rpc/browser.js +37 -0
- package/lib/rpc/index.d.ts +7 -0
- package/lib/rpc/index.js +72 -0
- package/lib/rpc/jsonrpc.d.ts +27 -0
- package/lib/rpc/jsonrpc.js +52 -0
- package/lib/rpc/parsers.d.ts +19 -0
- package/lib/rpc/parsers.js +155 -0
- package/lib/rpc/server.d.ts +514 -0
- package/lib/rpc/server.js +737 -0
- package/lib/rpc/transaction.d.ts +19 -0
- package/lib/rpc/transaction.js +53 -0
- package/lib/rpc/utils.d.ts +1 -0
- package/lib/rpc/utils.js +9 -0
- package/lib/stellartoml/index.d.ts +121 -0
- package/lib/stellartoml/index.js +77 -0
- package/lib/utils.d.ts +12 -0
- package/lib/utils.js +31 -0
- package/lib/webauth/errors.d.ts +4 -0
- package/lib/webauth/errors.js +36 -0
- package/lib/webauth/index.d.ts +2 -0
- package/lib/webauth/index.js +27 -0
- package/lib/webauth/utils.d.ts +294 -0
- package/lib/webauth/utils.js +332 -0
- package/package.json +155 -0
- package/types/dom-monkeypatch.d.ts +126 -0
package/lib/index.d.ts
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
export * from './errors';
|
2
|
+
export { Config } from './config';
|
3
|
+
export { Utils } from './utils';
|
4
|
+
export * as StellarToml from './stellartoml';
|
5
|
+
export * as Federation from './federation';
|
6
|
+
export * as WebAuth from './webauth';
|
7
|
+
export * as Friendbot from './friendbot';
|
8
|
+
export * as Horizon from './horizon';
|
9
|
+
/**
|
10
|
+
* Tools for interacting with the Soroban RPC server, such as `Server`,
|
11
|
+
* `assembleTransaction`, and the `Api` types. You can import these from the
|
12
|
+
* `/rpc` entrypoint, if your version of Node and your TypeScript configuration
|
13
|
+
* allow it:
|
14
|
+
*
|
15
|
+
* ```ts
|
16
|
+
* import { Server } from '@stellar/stellar-sdk/rpc';
|
17
|
+
* ```
|
18
|
+
*/
|
19
|
+
export * as rpc from './rpc';
|
20
|
+
/**
|
21
|
+
* @deprecated Use `rpc` instead
|
22
|
+
*/
|
23
|
+
export * as SorobanRpc from './rpc';
|
24
|
+
/**
|
25
|
+
* Tools for interacting with smart contracts, such as `Client`, `Spec`, and
|
26
|
+
* `AssembledTransaction`. You can import these from the `/contract`
|
27
|
+
* entrypoint, if your version of Node and your TypeScript configuration allow
|
28
|
+
* it:
|
29
|
+
*
|
30
|
+
* ```ts
|
31
|
+
* import { Client } from '@stellar/stellar-sdk/contract';
|
32
|
+
* ```
|
33
|
+
*/
|
34
|
+
export * as contract from './contract';
|
35
|
+
export * from '@stellar/stellar-base';
|
36
|
+
declare const _default: any;
|
37
|
+
export default _default;
|
package/lib/index.js
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
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); }
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
var _exportNames = {
|
8
|
+
Config: true,
|
9
|
+
Utils: true,
|
10
|
+
StellarToml: true,
|
11
|
+
Federation: true,
|
12
|
+
WebAuth: true,
|
13
|
+
Friendbot: true,
|
14
|
+
Horizon: true,
|
15
|
+
rpc: true,
|
16
|
+
SorobanRpc: true,
|
17
|
+
contract: true
|
18
|
+
};
|
19
|
+
Object.defineProperty(exports, "Config", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function get() {
|
22
|
+
return _config.Config;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
exports.StellarToml = exports.SorobanRpc = exports.Horizon = exports.Friendbot = exports.Federation = void 0;
|
26
|
+
Object.defineProperty(exports, "Utils", {
|
27
|
+
enumerable: true,
|
28
|
+
get: function get() {
|
29
|
+
return _utils.Utils;
|
30
|
+
}
|
31
|
+
});
|
32
|
+
exports.rpc = exports.default = exports.contract = exports.WebAuth = void 0;
|
33
|
+
var _errors = require("./errors");
|
34
|
+
Object.keys(_errors).forEach(function (key) {
|
35
|
+
if (key === "default" || key === "__esModule") return;
|
36
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
37
|
+
if (key in exports && exports[key] === _errors[key]) return;
|
38
|
+
Object.defineProperty(exports, key, {
|
39
|
+
enumerable: true,
|
40
|
+
get: function get() {
|
41
|
+
return _errors[key];
|
42
|
+
}
|
43
|
+
});
|
44
|
+
});
|
45
|
+
var _config = require("./config");
|
46
|
+
var _utils = require("./utils");
|
47
|
+
var _StellarToml = _interopRequireWildcard(require("./stellartoml"));
|
48
|
+
exports.StellarToml = _StellarToml;
|
49
|
+
var _Federation = _interopRequireWildcard(require("./federation"));
|
50
|
+
exports.Federation = _Federation;
|
51
|
+
var _WebAuth = _interopRequireWildcard(require("./webauth"));
|
52
|
+
exports.WebAuth = _WebAuth;
|
53
|
+
var _Friendbot = _interopRequireWildcard(require("./friendbot"));
|
54
|
+
exports.Friendbot = _Friendbot;
|
55
|
+
var _Horizon = _interopRequireWildcard(require("./horizon"));
|
56
|
+
exports.Horizon = _Horizon;
|
57
|
+
var _rpc = _interopRequireWildcard(require("./rpc"));
|
58
|
+
var _SorobanRpc = _rpc;
|
59
|
+
exports.rpc = _rpc;
|
60
|
+
exports.SorobanRpc = _rpc;
|
61
|
+
var _contract = _interopRequireWildcard(require("./contract"));
|
62
|
+
exports.contract = _contract;
|
63
|
+
var _stellarBase = require("@stellar/stellar-base");
|
64
|
+
Object.keys(_stellarBase).forEach(function (key) {
|
65
|
+
if (key === "default" || key === "__esModule") return;
|
66
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
67
|
+
if (key in exports && exports[key] === _stellarBase[key]) return;
|
68
|
+
Object.defineProperty(exports, key, {
|
69
|
+
enumerable: true,
|
70
|
+
get: function get() {
|
71
|
+
return _stellarBase[key];
|
72
|
+
}
|
73
|
+
});
|
74
|
+
});
|
75
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
76
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
77
|
+
var _default = exports.default = module.exports;
|
package/lib/rpc/api.d.ts
ADDED
@@ -0,0 +1,348 @@
|
|
1
|
+
import { Contract, SorobanDataBuilder, xdr } from '@stellar/stellar-base';
|
2
|
+
/** @namespace Api */
|
3
|
+
export declare namespace Api {
|
4
|
+
export interface Cost {
|
5
|
+
cpuInsns: string;
|
6
|
+
memBytes: string;
|
7
|
+
}
|
8
|
+
export interface GetHealthResponse {
|
9
|
+
status: 'healthy';
|
10
|
+
}
|
11
|
+
export interface LedgerEntryResult {
|
12
|
+
lastModifiedLedgerSeq?: number;
|
13
|
+
key: xdr.LedgerKey;
|
14
|
+
val: xdr.LedgerEntryData;
|
15
|
+
liveUntilLedgerSeq?: number;
|
16
|
+
}
|
17
|
+
export interface RawLedgerEntryResult {
|
18
|
+
lastModifiedLedgerSeq?: number;
|
19
|
+
/** a base-64 encoded {@link xdr.LedgerKey} instance */
|
20
|
+
key: string;
|
21
|
+
/** a base-64 encoded {@link xdr.LedgerEntryData} instance */
|
22
|
+
xdr: string;
|
23
|
+
/**
|
24
|
+
* optional, a future ledger number upon which this entry will expire
|
25
|
+
* based on https://github.com/stellar/soroban-tools/issues/1010
|
26
|
+
*/
|
27
|
+
liveUntilLedgerSeq?: number;
|
28
|
+
}
|
29
|
+
/** An XDR-parsed version of {@link this.RawLedgerEntryResult} */
|
30
|
+
export interface GetLedgerEntriesResponse {
|
31
|
+
entries: LedgerEntryResult[];
|
32
|
+
latestLedger: number;
|
33
|
+
}
|
34
|
+
/** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries */
|
35
|
+
export interface RawGetLedgerEntriesResponse {
|
36
|
+
entries?: RawLedgerEntryResult[];
|
37
|
+
latestLedger: number;
|
38
|
+
}
|
39
|
+
/** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getNetwork */
|
40
|
+
export interface GetNetworkResponse {
|
41
|
+
friendbotUrl?: string;
|
42
|
+
passphrase: string;
|
43
|
+
protocolVersion: string;
|
44
|
+
}
|
45
|
+
/** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLatestLedger */
|
46
|
+
export interface GetLatestLedgerResponse {
|
47
|
+
id: string;
|
48
|
+
sequence: number;
|
49
|
+
protocolVersion: string;
|
50
|
+
}
|
51
|
+
export enum GetTransactionStatus {
|
52
|
+
SUCCESS = "SUCCESS",
|
53
|
+
NOT_FOUND = "NOT_FOUND",
|
54
|
+
FAILED = "FAILED"
|
55
|
+
}
|
56
|
+
/** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction */
|
57
|
+
export type GetTransactionResponse = GetSuccessfulTransactionResponse | GetFailedTransactionResponse | GetMissingTransactionResponse;
|
58
|
+
interface GetAnyTransactionResponse {
|
59
|
+
status: GetTransactionStatus;
|
60
|
+
latestLedger: number;
|
61
|
+
latestLedgerCloseTime: number;
|
62
|
+
oldestLedger: number;
|
63
|
+
oldestLedgerCloseTime: number;
|
64
|
+
}
|
65
|
+
export interface GetMissingTransactionResponse extends GetAnyTransactionResponse {
|
66
|
+
status: GetTransactionStatus.NOT_FOUND;
|
67
|
+
}
|
68
|
+
export interface GetFailedTransactionResponse extends GetAnyTransactionResponse {
|
69
|
+
status: GetTransactionStatus.FAILED;
|
70
|
+
ledger: number;
|
71
|
+
createdAt: number;
|
72
|
+
applicationOrder: number;
|
73
|
+
feeBump: boolean;
|
74
|
+
envelopeXdr: xdr.TransactionEnvelope;
|
75
|
+
resultXdr: xdr.TransactionResult;
|
76
|
+
resultMetaXdr: xdr.TransactionMeta;
|
77
|
+
diagnosticEventsXdr?: xdr.DiagnosticEvent[];
|
78
|
+
}
|
79
|
+
export interface GetSuccessfulTransactionResponse extends GetAnyTransactionResponse {
|
80
|
+
status: GetTransactionStatus.SUCCESS;
|
81
|
+
ledger: number;
|
82
|
+
createdAt: number;
|
83
|
+
applicationOrder: number;
|
84
|
+
feeBump: boolean;
|
85
|
+
envelopeXdr: xdr.TransactionEnvelope;
|
86
|
+
resultXdr: xdr.TransactionResult;
|
87
|
+
resultMetaXdr: xdr.TransactionMeta;
|
88
|
+
diagnosticEventsXdr?: xdr.DiagnosticEvent[];
|
89
|
+
returnValue?: xdr.ScVal;
|
90
|
+
}
|
91
|
+
export interface RawGetTransactionResponse {
|
92
|
+
status: GetTransactionStatus;
|
93
|
+
latestLedger: number;
|
94
|
+
latestLedgerCloseTime: number;
|
95
|
+
oldestLedger: number;
|
96
|
+
oldestLedgerCloseTime: number;
|
97
|
+
applicationOrder?: number;
|
98
|
+
feeBump?: boolean;
|
99
|
+
envelopeXdr?: string;
|
100
|
+
resultXdr?: string;
|
101
|
+
resultMetaXdr?: string;
|
102
|
+
ledger?: number;
|
103
|
+
createdAt?: number;
|
104
|
+
diagnosticEventsXdr?: string[];
|
105
|
+
}
|
106
|
+
export interface GetTransactionsRequest {
|
107
|
+
startLedger: number;
|
108
|
+
cursor?: string;
|
109
|
+
limit?: number;
|
110
|
+
}
|
111
|
+
export interface RawTransactionInfo {
|
112
|
+
status: GetTransactionStatus;
|
113
|
+
ledger: number;
|
114
|
+
createdAt: number;
|
115
|
+
applicationOrder: number;
|
116
|
+
feeBump: boolean;
|
117
|
+
envelopeXdr?: string;
|
118
|
+
resultXdr?: string;
|
119
|
+
resultMetaXdr?: string;
|
120
|
+
diagnosticEventsXdr?: string[];
|
121
|
+
}
|
122
|
+
export interface TransactionInfo {
|
123
|
+
status: GetTransactionStatus;
|
124
|
+
ledger: number;
|
125
|
+
createdAt: number;
|
126
|
+
applicationOrder: number;
|
127
|
+
feeBump: boolean;
|
128
|
+
envelopeXdr: xdr.TransactionEnvelope;
|
129
|
+
resultXdr: xdr.TransactionResult;
|
130
|
+
resultMetaXdr: xdr.TransactionMeta;
|
131
|
+
returnValue?: xdr.ScVal;
|
132
|
+
diagnosticEventsXdr?: xdr.DiagnosticEvent[];
|
133
|
+
}
|
134
|
+
export interface GetTransactionsResponse {
|
135
|
+
transactions: TransactionInfo[];
|
136
|
+
latestLedger: number;
|
137
|
+
latestLedgerCloseTimestamp: number;
|
138
|
+
oldestLedger: number;
|
139
|
+
oldestLedgerCloseTimestamp: number;
|
140
|
+
cursor: string;
|
141
|
+
}
|
142
|
+
export interface RawGetTransactionsResponse {
|
143
|
+
transactions: RawTransactionInfo[];
|
144
|
+
latestLedger: number;
|
145
|
+
latestLedgerCloseTimestamp: number;
|
146
|
+
oldestLedger: number;
|
147
|
+
oldestLedgerCloseTimestamp: number;
|
148
|
+
cursor: string;
|
149
|
+
}
|
150
|
+
export type EventType = 'contract' | 'system' | 'diagnostic';
|
151
|
+
export interface EventFilter {
|
152
|
+
type?: EventType;
|
153
|
+
contractIds?: string[];
|
154
|
+
topics?: string[][];
|
155
|
+
}
|
156
|
+
export interface GetEventsResponse {
|
157
|
+
latestLedger: number;
|
158
|
+
events: EventResponse[];
|
159
|
+
}
|
160
|
+
export interface EventResponse extends BaseEventResponse {
|
161
|
+
contractId?: Contract;
|
162
|
+
topic: xdr.ScVal[];
|
163
|
+
value: xdr.ScVal;
|
164
|
+
}
|
165
|
+
export interface RawGetEventsResponse {
|
166
|
+
latestLedger: number;
|
167
|
+
events: RawEventResponse[];
|
168
|
+
}
|
169
|
+
interface BaseEventResponse {
|
170
|
+
id: string;
|
171
|
+
type: EventType;
|
172
|
+
ledger: number;
|
173
|
+
ledgerClosedAt: string;
|
174
|
+
pagingToken: string;
|
175
|
+
inSuccessfulContractCall: boolean;
|
176
|
+
txHash: string;
|
177
|
+
}
|
178
|
+
export interface RawEventResponse extends BaseEventResponse {
|
179
|
+
contractId: string;
|
180
|
+
topic: string[];
|
181
|
+
value: string;
|
182
|
+
}
|
183
|
+
interface RawLedgerEntryChange {
|
184
|
+
type: number;
|
185
|
+
/** This is LedgerKey in base64 */
|
186
|
+
key: string;
|
187
|
+
/** This is xdr.LedgerEntry in base64 */
|
188
|
+
before: string | null;
|
189
|
+
/** This is xdr.LedgerEntry in base64 */
|
190
|
+
after: string | null;
|
191
|
+
}
|
192
|
+
export interface LedgerEntryChange {
|
193
|
+
type: number;
|
194
|
+
key: xdr.LedgerKey;
|
195
|
+
before: xdr.LedgerEntry | null;
|
196
|
+
after: xdr.LedgerEntry | null;
|
197
|
+
}
|
198
|
+
export type SendTransactionStatus = 'PENDING' | 'DUPLICATE' | 'TRY_AGAIN_LATER' | 'ERROR';
|
199
|
+
export interface SendTransactionResponse extends BaseSendTransactionResponse {
|
200
|
+
errorResult?: xdr.TransactionResult;
|
201
|
+
diagnosticEvents?: xdr.DiagnosticEvent[];
|
202
|
+
}
|
203
|
+
export interface RawSendTransactionResponse extends BaseSendTransactionResponse {
|
204
|
+
/**
|
205
|
+
* This is a base64-encoded instance of {@link xdr.TransactionResult}, set
|
206
|
+
* only when `status` is `"ERROR"`.
|
207
|
+
*
|
208
|
+
* It contains details on why the network rejected the transaction.
|
209
|
+
*/
|
210
|
+
errorResultXdr?: string;
|
211
|
+
/**
|
212
|
+
* This is a base64-encoded instance of an array of
|
213
|
+
* {@link xdr.DiagnosticEvent}s, set only when `status` is `"ERROR"` and
|
214
|
+
* diagnostic events are enabled on the server.
|
215
|
+
*/
|
216
|
+
diagnosticEventsXdr?: string[];
|
217
|
+
}
|
218
|
+
export interface BaseSendTransactionResponse {
|
219
|
+
status: SendTransactionStatus;
|
220
|
+
hash: string;
|
221
|
+
latestLedger: number;
|
222
|
+
latestLedgerCloseTime: number;
|
223
|
+
}
|
224
|
+
export interface SimulateHostFunctionResult {
|
225
|
+
auth: xdr.SorobanAuthorizationEntry[];
|
226
|
+
retval: xdr.ScVal;
|
227
|
+
}
|
228
|
+
/**
|
229
|
+
* Simplifies {@link Api.RawSimulateTransactionResponse} into separate interfaces
|
230
|
+
* based on status:
|
231
|
+
* - on success, this includes all fields, though `result` is only present
|
232
|
+
* if an invocation was simulated (since otherwise there's nothing to
|
233
|
+
* "resultify")
|
234
|
+
* - if there was an expiration error, this includes error and restoration
|
235
|
+
* fields
|
236
|
+
* - for all other errors, this only includes error fields
|
237
|
+
*
|
238
|
+
* @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction
|
239
|
+
*/
|
240
|
+
export type SimulateTransactionResponse = SimulateTransactionSuccessResponse | SimulateTransactionRestoreResponse | SimulateTransactionErrorResponse;
|
241
|
+
export interface BaseSimulateTransactionResponse {
|
242
|
+
/** always present: the JSON-RPC request ID */
|
243
|
+
id: string;
|
244
|
+
/** always present: the LCL known to the server when responding */
|
245
|
+
latestLedger: number;
|
246
|
+
/**
|
247
|
+
* The field is always present, but may be empty in cases where:
|
248
|
+
* - you didn't simulate an invocation or
|
249
|
+
* - there were no events
|
250
|
+
*/
|
251
|
+
events: xdr.DiagnosticEvent[];
|
252
|
+
/** a private field to mark the schema as parsed */
|
253
|
+
_parsed: boolean;
|
254
|
+
}
|
255
|
+
/** Includes simplified fields only present on success. */
|
256
|
+
export interface SimulateTransactionSuccessResponse extends BaseSimulateTransactionResponse {
|
257
|
+
transactionData: SorobanDataBuilder;
|
258
|
+
minResourceFee: string;
|
259
|
+
cost: Cost;
|
260
|
+
/** present only for invocation simulation */
|
261
|
+
result?: SimulateHostFunctionResult;
|
262
|
+
/** State Difference information */
|
263
|
+
stateChanges?: LedgerEntryChange[];
|
264
|
+
}
|
265
|
+
/** Includes details about why the simulation failed */
|
266
|
+
export interface SimulateTransactionErrorResponse extends BaseSimulateTransactionResponse {
|
267
|
+
error: string;
|
268
|
+
events: xdr.DiagnosticEvent[];
|
269
|
+
}
|
270
|
+
export interface SimulateTransactionRestoreResponse extends SimulateTransactionSuccessResponse {
|
271
|
+
result: SimulateHostFunctionResult;
|
272
|
+
/**
|
273
|
+
* Indicates that a restoration is necessary prior to submission.
|
274
|
+
*
|
275
|
+
* In other words, seeing a restoration preamble means that your invocation
|
276
|
+
* was executed AS IF the required ledger entries were present, and this
|
277
|
+
* field includes information about what you need to restore for the
|
278
|
+
* simulation to succeed.
|
279
|
+
*/
|
280
|
+
restorePreamble: {
|
281
|
+
minResourceFee: string;
|
282
|
+
transactionData: SorobanDataBuilder;
|
283
|
+
};
|
284
|
+
}
|
285
|
+
export function isSimulationError(sim: SimulateTransactionResponse): sim is SimulateTransactionErrorResponse;
|
286
|
+
export function isSimulationSuccess(sim: SimulateTransactionResponse): sim is SimulateTransactionSuccessResponse;
|
287
|
+
export function isSimulationRestore(sim: SimulateTransactionResponse): sim is SimulateTransactionRestoreResponse;
|
288
|
+
export function isSimulationRaw(sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse): sim is Api.RawSimulateTransactionResponse;
|
289
|
+
interface RawSimulateHostFunctionResult {
|
290
|
+
auth?: string[];
|
291
|
+
xdr: string;
|
292
|
+
}
|
293
|
+
/** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction */
|
294
|
+
export interface RawSimulateTransactionResponse {
|
295
|
+
id: string;
|
296
|
+
latestLedger: number;
|
297
|
+
error?: string;
|
298
|
+
/** This is an xdr.SorobanTransactionData in base64 */
|
299
|
+
transactionData?: string;
|
300
|
+
/** These are xdr.DiagnosticEvents in base64 */
|
301
|
+
events?: string[];
|
302
|
+
minResourceFee?: string;
|
303
|
+
/**
|
304
|
+
* This will only contain a single element if present, because only a single
|
305
|
+
* invokeHostFunctionOperation is supported per transaction.
|
306
|
+
* */
|
307
|
+
results?: RawSimulateHostFunctionResult[];
|
308
|
+
cost?: Cost;
|
309
|
+
/** Present if succeeded but has expired ledger entries */
|
310
|
+
restorePreamble?: {
|
311
|
+
minResourceFee: string;
|
312
|
+
transactionData: string;
|
313
|
+
};
|
314
|
+
/** State Difference information */
|
315
|
+
stateChanges?: RawLedgerEntryChange[];
|
316
|
+
}
|
317
|
+
export interface GetVersionInfoResponse {
|
318
|
+
version: string;
|
319
|
+
commit_hash: string;
|
320
|
+
build_time_stamp: string;
|
321
|
+
captive_core_version: string;
|
322
|
+
protocol_version: number;
|
323
|
+
}
|
324
|
+
export interface GetFeeStatsResponse {
|
325
|
+
sorobanInclusionFee: FeeDistribution;
|
326
|
+
inclusionFee: FeeDistribution;
|
327
|
+
latestLedger: number;
|
328
|
+
}
|
329
|
+
interface FeeDistribution {
|
330
|
+
max: string;
|
331
|
+
min: string;
|
332
|
+
mode: string;
|
333
|
+
p10: string;
|
334
|
+
p20: string;
|
335
|
+
p30: string;
|
336
|
+
p40: string;
|
337
|
+
p50: string;
|
338
|
+
p60: string;
|
339
|
+
p70: string;
|
340
|
+
p80: string;
|
341
|
+
p90: string;
|
342
|
+
p95: string;
|
343
|
+
p99: string;
|
344
|
+
transactionCount: string;
|
345
|
+
ledgerCount: number;
|
346
|
+
}
|
347
|
+
export {};
|
348
|
+
}
|
package/lib/rpc/api.js
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.Api = void 0;
|
7
|
+
var Api;
|
8
|
+
(function (_Api) {
|
9
|
+
var GetTransactionStatus = function (GetTransactionStatus) {
|
10
|
+
GetTransactionStatus["SUCCESS"] = "SUCCESS";
|
11
|
+
GetTransactionStatus["NOT_FOUND"] = "NOT_FOUND";
|
12
|
+
GetTransactionStatus["FAILED"] = "FAILED";
|
13
|
+
return GetTransactionStatus;
|
14
|
+
}({});
|
15
|
+
_Api.GetTransactionStatus = GetTransactionStatus;
|
16
|
+
function isSimulationError(sim) {
|
17
|
+
return 'error' in sim;
|
18
|
+
}
|
19
|
+
_Api.isSimulationError = isSimulationError;
|
20
|
+
function isSimulationSuccess(sim) {
|
21
|
+
return 'transactionData' in sim;
|
22
|
+
}
|
23
|
+
_Api.isSimulationSuccess = isSimulationSuccess;
|
24
|
+
function isSimulationRestore(sim) {
|
25
|
+
return isSimulationSuccess(sim) && 'restorePreamble' in sim && !!sim.restorePreamble.transactionData;
|
26
|
+
}
|
27
|
+
_Api.isSimulationRestore = isSimulationRestore;
|
28
|
+
function isSimulationRaw(sim) {
|
29
|
+
return !sim._parsed;
|
30
|
+
}
|
31
|
+
_Api.isSimulationRaw = isSimulationRaw;
|
32
|
+
})(Api || (exports.Api = Api = {}));
|
package/lib/rpc/axios.js
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.version = exports.default = exports.AxiosClient = void 0;
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
|
+
var version = exports.version = require('../../package.json').version;
|
10
|
+
var AxiosClient = exports.AxiosClient = _axios.default.create({
|
11
|
+
headers: {
|
12
|
+
'X-Client-Name': 'js-soroban-client',
|
13
|
+
'X-Client-Version': version
|
14
|
+
}
|
15
|
+
});
|
16
|
+
var _default = exports.default = AxiosClient;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
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); }
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
var _exportNames = {
|
8
|
+
axios: true,
|
9
|
+
StellarBase: true
|
10
|
+
};
|
11
|
+
exports.StellarBase = void 0;
|
12
|
+
Object.defineProperty(exports, "axios", {
|
13
|
+
enumerable: true,
|
14
|
+
get: function get() {
|
15
|
+
return _axios.default;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
exports.default = void 0;
|
19
|
+
var _axios = _interopRequireDefault(require("axios"));
|
20
|
+
var _index = require("./index");
|
21
|
+
Object.keys(_index).forEach(function (key) {
|
22
|
+
if (key === "default" || key === "__esModule") return;
|
23
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
24
|
+
if (key in exports && exports[key] === _index[key]) return;
|
25
|
+
Object.defineProperty(exports, key, {
|
26
|
+
enumerable: true,
|
27
|
+
get: function get() {
|
28
|
+
return _index[key];
|
29
|
+
}
|
30
|
+
});
|
31
|
+
});
|
32
|
+
var _StellarBase = _interopRequireWildcard(require("@stellar/stellar-base"));
|
33
|
+
exports.StellarBase = _StellarBase;
|
34
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
35
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
36
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
37
|
+
var _default = exports.default = module.exports;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export * from "./api";
|
2
|
+
export { Server, Durability } from "./server";
|
3
|
+
export { default as AxiosClient } from "./axios";
|
4
|
+
export { parseRawSimulation, parseRawEvents } from "./parsers";
|
5
|
+
export * from "./transaction";
|
6
|
+
declare const _default: any;
|
7
|
+
export default _default;
|
package/lib/rpc/index.js
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
var _exportNames = {
|
7
|
+
Server: true,
|
8
|
+
Durability: true,
|
9
|
+
AxiosClient: true,
|
10
|
+
parseRawSimulation: true,
|
11
|
+
parseRawEvents: true
|
12
|
+
};
|
13
|
+
Object.defineProperty(exports, "AxiosClient", {
|
14
|
+
enumerable: true,
|
15
|
+
get: function get() {
|
16
|
+
return _axios.default;
|
17
|
+
}
|
18
|
+
});
|
19
|
+
Object.defineProperty(exports, "Durability", {
|
20
|
+
enumerable: true,
|
21
|
+
get: function get() {
|
22
|
+
return _server.Durability;
|
23
|
+
}
|
24
|
+
});
|
25
|
+
Object.defineProperty(exports, "Server", {
|
26
|
+
enumerable: true,
|
27
|
+
get: function get() {
|
28
|
+
return _server.Server;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
exports.default = void 0;
|
32
|
+
Object.defineProperty(exports, "parseRawEvents", {
|
33
|
+
enumerable: true,
|
34
|
+
get: function get() {
|
35
|
+
return _parsers.parseRawEvents;
|
36
|
+
}
|
37
|
+
});
|
38
|
+
Object.defineProperty(exports, "parseRawSimulation", {
|
39
|
+
enumerable: true,
|
40
|
+
get: function get() {
|
41
|
+
return _parsers.parseRawSimulation;
|
42
|
+
}
|
43
|
+
});
|
44
|
+
var _api = require("./api");
|
45
|
+
Object.keys(_api).forEach(function (key) {
|
46
|
+
if (key === "default" || key === "__esModule") return;
|
47
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
48
|
+
if (key in exports && exports[key] === _api[key]) return;
|
49
|
+
Object.defineProperty(exports, key, {
|
50
|
+
enumerable: true,
|
51
|
+
get: function get() {
|
52
|
+
return _api[key];
|
53
|
+
}
|
54
|
+
});
|
55
|
+
});
|
56
|
+
var _server = require("./server");
|
57
|
+
var _axios = _interopRequireDefault(require("./axios"));
|
58
|
+
var _parsers = require("./parsers");
|
59
|
+
var _transaction = require("./transaction");
|
60
|
+
Object.keys(_transaction).forEach(function (key) {
|
61
|
+
if (key === "default" || key === "__esModule") return;
|
62
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
63
|
+
if (key in exports && exports[key] === _transaction[key]) return;
|
64
|
+
Object.defineProperty(exports, key, {
|
65
|
+
enumerable: true,
|
66
|
+
get: function get() {
|
67
|
+
return _transaction[key];
|
68
|
+
}
|
69
|
+
});
|
70
|
+
});
|
71
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
72
|
+
var _default = exports.default = module.exports;
|
@@ -0,0 +1,27 @@
|
|
1
|
+
export type Id = string | number;
|
2
|
+
export interface Request<T> {
|
3
|
+
jsonrpc: "2.0";
|
4
|
+
id: Id;
|
5
|
+
method: string;
|
6
|
+
params: T;
|
7
|
+
}
|
8
|
+
export interface Notification<T> {
|
9
|
+
jsonrpc: "2.0";
|
10
|
+
method: string;
|
11
|
+
params?: T;
|
12
|
+
}
|
13
|
+
export type Response<T, E = any> = {
|
14
|
+
jsonrpc: "2.0";
|
15
|
+
id: Id;
|
16
|
+
} & ({
|
17
|
+
error: Error<E>;
|
18
|
+
} | {
|
19
|
+
result: T;
|
20
|
+
});
|
21
|
+
export interface Error<E = any> {
|
22
|
+
code: number;
|
23
|
+
message?: string;
|
24
|
+
data?: E;
|
25
|
+
}
|
26
|
+
/** Sends the jsonrpc 'params' as a single 'param' object (no array support). */
|
27
|
+
export declare function postObject<T>(url: string, method: string, param?: any): Promise<T>;
|