@stellar/stellar-sdk 16.0.1 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -2
- package/dist/stellar-sdk-axios.js +5401 -3690
- package/dist/stellar-sdk-axios.js.map +1 -1
- package/dist/stellar-sdk-axios.min.js +12 -11
- package/dist/stellar-sdk-axios.min.js.map +1 -1
- package/dist/stellar-sdk.js +4850 -3681
- package/dist/stellar-sdk.js.map +1 -1
- package/dist/stellar-sdk.min.js +17 -17
- package/dist/stellar-sdk.min.js.map +1 -1
- package/lib/axios/cjs/base/auth.js +147 -30
- package/lib/axios/cjs/base/auth.js.map +1 -1
- package/lib/axios/cjs/base/index.js +113 -0
- package/lib/axios/cjs/base/index.js.map +1 -0
- package/lib/axios/cjs/base/keypair.js +39 -0
- package/lib/axios/cjs/base/keypair.js.map +1 -1
- package/lib/axios/cjs/base/scval.js +34 -0
- package/lib/axios/cjs/base/scval.js.map +1 -1
- package/lib/axios/cjs/bindings/client.js +170 -0
- package/lib/axios/cjs/bindings/client.js.map +1 -1
- package/lib/axios/cjs/bindings/config.js +1 -1
- package/lib/axios/cjs/bindings/generator.js +45 -16
- package/lib/axios/cjs/bindings/generator.js.map +1 -1
- package/lib/axios/cjs/bindings/types.js +151 -1
- package/lib/axios/cjs/bindings/types.js.map +1 -1
- package/lib/axios/cjs/bindings/utils.js +10 -0
- package/lib/axios/cjs/bindings/utils.js.map +1 -1
- package/lib/axios/cjs/cli/index.js +19 -22
- package/lib/axios/cjs/cli/index.js.map +1 -1
- package/lib/axios/cjs/cli/util.js +1 -20
- package/lib/axios/cjs/cli/util.js.map +1 -1
- package/lib/axios/cjs/contract/assembled_transaction.js +39 -17
- package/lib/axios/cjs/contract/assembled_transaction.js.map +1 -1
- package/lib/axios/cjs/contract/basic_node_signer.js +8 -42
- package/lib/axios/cjs/contract/basic_node_signer.js.map +1 -1
- package/lib/axios/cjs/contract/client.js +56 -3
- package/lib/axios/cjs/contract/client.js.map +1 -1
- package/lib/axios/cjs/contract/event_spec.js +164 -0
- package/lib/axios/cjs/contract/event_spec.js.map +1 -0
- package/lib/axios/cjs/contract/index.js +2 -0
- package/lib/axios/cjs/contract/index.js.map +1 -1
- package/lib/axios/cjs/contract/sent_transaction.js +0 -20
- package/lib/axios/cjs/contract/sent_transaction.js.map +1 -1
- package/lib/axios/cjs/contract/signer.js +96 -0
- package/lib/axios/cjs/contract/signer.js.map +1 -0
- package/lib/axios/cjs/contract/spec.js +107 -3
- package/lib/axios/cjs/contract/spec.js.map +1 -1
- package/lib/axios/cjs/contract/types.js.map +1 -1
- package/lib/axios/cjs/errors/transaction_failed.js +62 -0
- package/lib/axios/cjs/errors/transaction_failed.js.map +1 -0
- package/lib/axios/cjs/errors/wrap_http_error.js +20 -0
- package/lib/axios/cjs/errors/wrap_http_error.js.map +1 -0
- package/lib/axios/cjs/federation/server.js +15 -35
- package/lib/axios/cjs/federation/server.js.map +1 -1
- package/lib/axios/cjs/horizon/account_response.js +0 -20
- package/lib/axios/cjs/horizon/account_response.js.map +1 -1
- package/lib/axios/cjs/horizon/horizon_api.js +5 -0
- package/lib/axios/cjs/horizon/horizon_api.js.map +1 -1
- package/lib/axios/cjs/horizon/horizon_axios_client.js +1 -1
- package/lib/axios/cjs/horizon/server.js +20 -26
- package/lib/axios/cjs/horizon/server.js.map +1 -1
- package/lib/axios/cjs/index.js +66 -65
- package/lib/axios/cjs/index.js.map +1 -1
- package/lib/axios/cjs/rpc/api.js.map +1 -1
- package/lib/axios/cjs/rpc/axios.js +1 -1
- package/lib/axios/cjs/rpc/server.js +181 -13
- package/lib/axios/cjs/rpc/server.js.map +1 -1
- package/lib/axios/cjs/rpc/transaction.js +2 -20
- package/lib/axios/cjs/rpc/transaction.js.map +1 -1
- package/lib/axios/cjs/webauth/challenge_transaction.js +7 -22
- package/lib/axios/cjs/webauth/challenge_transaction.js.map +1 -1
- package/lib/axios/cjs/webauth/utils.js +1 -20
- package/lib/axios/cjs/webauth/utils.js.map +1 -1
- package/lib/axios/esm/base/auth.d.ts +181 -13
- package/lib/axios/esm/base/auth.js +146 -31
- package/lib/axios/esm/base/auth.js.map +1 -1
- package/lib/axios/esm/base/index.d.ts +2 -2
- package/lib/axios/esm/base/index.js +44 -0
- package/lib/axios/esm/base/index.js.map +1 -0
- package/lib/axios/esm/base/keypair.d.ts +27 -0
- package/lib/axios/esm/base/keypair.js +39 -0
- package/lib/axios/esm/base/keypair.js.map +1 -1
- package/lib/axios/esm/base/scval.d.ts +4 -0
- package/lib/axios/esm/base/scval.js +34 -0
- package/lib/axios/esm/base/scval.js.map +1 -1
- package/lib/axios/esm/bindings/client.d.ts +39 -0
- package/lib/axios/esm/bindings/client.js +171 -1
- package/lib/axios/esm/bindings/client.js.map +1 -1
- package/lib/axios/esm/bindings/config.js +1 -1
- package/lib/axios/esm/bindings/generator.d.ts +34 -0
- package/lib/axios/esm/bindings/generator.js +45 -16
- package/lib/axios/esm/bindings/generator.js.map +1 -1
- package/lib/axios/esm/bindings/types.d.ts +42 -0
- package/lib/axios/esm/bindings/types.js +153 -3
- package/lib/axios/esm/bindings/types.js.map +1 -1
- package/lib/axios/esm/bindings/utils.d.ts +10 -0
- package/lib/axios/esm/bindings/utils.js +9 -1
- package/lib/axios/esm/bindings/utils.js.map +1 -1
- package/lib/axios/esm/cli/index.js +19 -22
- package/lib/axios/esm/cli/index.js.map +1 -1
- package/lib/axios/esm/cli/util.d.ts +1 -1
- package/lib/axios/esm/cli/util.js +1 -20
- package/lib/axios/esm/cli/util.js.map +1 -1
- package/lib/axios/esm/contract/assembled_transaction.d.ts +7 -5
- package/lib/axios/esm/contract/assembled_transaction.js +39 -17
- package/lib/axios/esm/contract/assembled_transaction.js.map +1 -1
- package/lib/axios/esm/contract/basic_node_signer.d.ts +3 -0
- package/lib/axios/esm/contract/basic_node_signer.js +8 -42
- package/lib/axios/esm/contract/basic_node_signer.js.map +1 -1
- package/lib/axios/esm/contract/client.d.ts +49 -3
- package/lib/axios/esm/contract/client.js +56 -3
- package/lib/axios/esm/contract/client.js.map +1 -1
- package/lib/axios/esm/contract/event_spec.d.ts +78 -0
- package/lib/axios/esm/contract/event_spec.js +159 -0
- package/lib/axios/esm/contract/event_spec.js.map +1 -0
- package/lib/axios/esm/contract/index.d.ts +3 -0
- package/lib/axios/esm/contract/index.js +1 -0
- package/lib/axios/esm/contract/index.js.map +1 -1
- package/lib/axios/esm/contract/sent_transaction.js +0 -20
- package/lib/axios/esm/contract/sent_transaction.js.map +1 -1
- package/lib/axios/esm/contract/signer.d.ts +104 -0
- package/lib/axios/esm/contract/signer.js +91 -0
- package/lib/axios/esm/contract/signer.js.map +1 -0
- package/lib/axios/esm/contract/spec.d.ts +84 -0
- package/lib/axios/esm/contract/spec.js +107 -3
- package/lib/axios/esm/contract/spec.js.map +1 -1
- package/lib/axios/esm/contract/types.d.ts +25 -8
- package/lib/axios/esm/contract/types.js.map +1 -1
- package/lib/axios/esm/errors/index.d.ts +1 -0
- package/lib/axios/esm/errors/transaction_failed.d.ts +55 -0
- package/lib/axios/esm/errors/transaction_failed.js +60 -0
- package/lib/axios/esm/errors/transaction_failed.js.map +1 -0
- package/lib/axios/esm/errors/wrap_http_error.d.ts +20 -0
- package/lib/axios/esm/errors/wrap_http_error.js +18 -0
- package/lib/axios/esm/errors/wrap_http_error.js.map +1 -0
- package/lib/axios/esm/federation/server.js +15 -35
- package/lib/axios/esm/federation/server.js.map +1 -1
- package/lib/axios/esm/horizon/account_response.js +0 -20
- package/lib/axios/esm/horizon/account_response.js.map +1 -1
- package/lib/axios/esm/horizon/horizon_api.d.ts +12 -1
- package/lib/axios/esm/horizon/horizon_api.js +5 -0
- package/lib/axios/esm/horizon/horizon_api.js.map +1 -1
- package/lib/axios/esm/horizon/horizon_axios_client.js +1 -1
- package/lib/axios/esm/horizon/server.d.ts +10 -4
- package/lib/axios/esm/horizon/server.js +20 -26
- package/lib/axios/esm/horizon/server.js.map +1 -1
- package/lib/axios/esm/index.js +27 -29
- package/lib/axios/esm/index.js.map +1 -1
- package/lib/axios/esm/rpc/api.d.ts +21 -0
- package/lib/axios/esm/rpc/api.js.map +1 -1
- package/lib/axios/esm/rpc/axios.js +1 -1
- package/lib/axios/esm/rpc/server.d.ts +115 -3
- package/lib/axios/esm/rpc/server.js +181 -13
- package/lib/axios/esm/rpc/server.js.map +1 -1
- package/lib/axios/esm/rpc/transaction.js +2 -20
- package/lib/axios/esm/rpc/transaction.js.map +1 -1
- package/lib/axios/esm/webauth/challenge_transaction.js +7 -22
- package/lib/axios/esm/webauth/challenge_transaction.js.map +1 -1
- package/lib/axios/esm/webauth/utils.js +1 -20
- package/lib/axios/esm/webauth/utils.js.map +1 -1
- package/lib/cjs/base/auth.js +147 -30
- package/lib/cjs/base/auth.js.map +1 -1
- package/lib/cjs/base/index.js +113 -0
- package/lib/cjs/base/index.js.map +1 -0
- package/lib/cjs/base/keypair.js +39 -0
- package/lib/cjs/base/keypair.js.map +1 -1
- package/lib/cjs/base/scval.js +34 -0
- package/lib/cjs/base/scval.js.map +1 -1
- package/lib/cjs/bindings/client.js +170 -0
- package/lib/cjs/bindings/client.js.map +1 -1
- package/lib/cjs/bindings/config.js +1 -1
- package/lib/cjs/bindings/generator.js +45 -16
- package/lib/cjs/bindings/generator.js.map +1 -1
- package/lib/cjs/bindings/types.js +151 -1
- package/lib/cjs/bindings/types.js.map +1 -1
- package/lib/cjs/bindings/utils.js +10 -0
- package/lib/cjs/bindings/utils.js.map +1 -1
- package/lib/cjs/cli/index.js +19 -22
- package/lib/cjs/cli/index.js.map +1 -1
- package/lib/cjs/cli/util.js +1 -20
- package/lib/cjs/cli/util.js.map +1 -1
- package/lib/cjs/contract/assembled_transaction.js +39 -17
- package/lib/cjs/contract/assembled_transaction.js.map +1 -1
- package/lib/cjs/contract/basic_node_signer.js +8 -42
- package/lib/cjs/contract/basic_node_signer.js.map +1 -1
- package/lib/cjs/contract/client.js +56 -3
- package/lib/cjs/contract/client.js.map +1 -1
- package/lib/cjs/contract/event_spec.js +164 -0
- package/lib/cjs/contract/event_spec.js.map +1 -0
- package/lib/cjs/contract/index.js +2 -0
- package/lib/cjs/contract/index.js.map +1 -1
- package/lib/cjs/contract/sent_transaction.js +0 -20
- package/lib/cjs/contract/sent_transaction.js.map +1 -1
- package/lib/cjs/contract/signer.js +96 -0
- package/lib/cjs/contract/signer.js.map +1 -0
- package/lib/cjs/contract/spec.js +107 -3
- package/lib/cjs/contract/spec.js.map +1 -1
- package/lib/cjs/contract/types.js.map +1 -1
- package/lib/cjs/errors/transaction_failed.js +62 -0
- package/lib/cjs/errors/transaction_failed.js.map +1 -0
- package/lib/cjs/errors/wrap_http_error.js +20 -0
- package/lib/cjs/errors/wrap_http_error.js.map +1 -0
- package/lib/cjs/federation/server.js +15 -35
- package/lib/cjs/federation/server.js.map +1 -1
- package/lib/cjs/horizon/account_response.js +0 -20
- package/lib/cjs/horizon/account_response.js.map +1 -1
- package/lib/cjs/horizon/horizon_api.js +5 -0
- package/lib/cjs/horizon/horizon_api.js.map +1 -1
- package/lib/cjs/horizon/horizon_axios_client.js +1 -1
- package/lib/cjs/horizon/server.js +20 -26
- package/lib/cjs/horizon/server.js.map +1 -1
- package/lib/cjs/index.js +66 -65
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/rpc/api.js.map +1 -1
- package/lib/cjs/rpc/axios.js +1 -1
- package/lib/cjs/rpc/server.js +181 -13
- package/lib/cjs/rpc/server.js.map +1 -1
- package/lib/cjs/rpc/transaction.js +2 -20
- package/lib/cjs/rpc/transaction.js.map +1 -1
- package/lib/cjs/webauth/challenge_transaction.js +7 -22
- package/lib/cjs/webauth/challenge_transaction.js.map +1 -1
- package/lib/cjs/webauth/utils.js +1 -20
- package/lib/cjs/webauth/utils.js.map +1 -1
- package/lib/esm/base/auth.d.ts +181 -13
- package/lib/esm/base/auth.js +146 -31
- package/lib/esm/base/auth.js.map +1 -1
- package/lib/esm/base/index.d.ts +2 -2
- package/lib/esm/base/index.js +44 -0
- package/lib/esm/base/index.js.map +1 -0
- package/lib/esm/base/keypair.d.ts +27 -0
- package/lib/esm/base/keypair.js +39 -0
- package/lib/esm/base/keypair.js.map +1 -1
- package/lib/esm/base/scval.d.ts +4 -0
- package/lib/esm/base/scval.js +34 -0
- package/lib/esm/base/scval.js.map +1 -1
- package/lib/esm/bindings/client.d.ts +39 -0
- package/lib/esm/bindings/client.js +171 -1
- package/lib/esm/bindings/client.js.map +1 -1
- package/lib/esm/bindings/config.js +1 -1
- package/lib/esm/bindings/generator.d.ts +34 -0
- package/lib/esm/bindings/generator.js +45 -16
- package/lib/esm/bindings/generator.js.map +1 -1
- package/lib/esm/bindings/types.d.ts +42 -0
- package/lib/esm/bindings/types.js +153 -3
- package/lib/esm/bindings/types.js.map +1 -1
- package/lib/esm/bindings/utils.d.ts +10 -0
- package/lib/esm/bindings/utils.js +9 -1
- package/lib/esm/bindings/utils.js.map +1 -1
- package/lib/esm/cli/index.js +19 -22
- package/lib/esm/cli/index.js.map +1 -1
- package/lib/esm/cli/util.d.ts +1 -1
- package/lib/esm/cli/util.js +1 -20
- package/lib/esm/cli/util.js.map +1 -1
- package/lib/esm/contract/assembled_transaction.d.ts +7 -5
- package/lib/esm/contract/assembled_transaction.js +39 -17
- package/lib/esm/contract/assembled_transaction.js.map +1 -1
- package/lib/esm/contract/basic_node_signer.d.ts +3 -0
- package/lib/esm/contract/basic_node_signer.js +8 -42
- package/lib/esm/contract/basic_node_signer.js.map +1 -1
- package/lib/esm/contract/client.d.ts +49 -3
- package/lib/esm/contract/client.js +56 -3
- package/lib/esm/contract/client.js.map +1 -1
- package/lib/esm/contract/event_spec.d.ts +78 -0
- package/lib/esm/contract/event_spec.js +159 -0
- package/lib/esm/contract/event_spec.js.map +1 -0
- package/lib/esm/contract/index.d.ts +3 -0
- package/lib/esm/contract/index.js +1 -0
- package/lib/esm/contract/index.js.map +1 -1
- package/lib/esm/contract/sent_transaction.js +0 -20
- package/lib/esm/contract/sent_transaction.js.map +1 -1
- package/lib/esm/contract/signer.d.ts +104 -0
- package/lib/esm/contract/signer.js +91 -0
- package/lib/esm/contract/signer.js.map +1 -0
- package/lib/esm/contract/spec.d.ts +84 -0
- package/lib/esm/contract/spec.js +107 -3
- package/lib/esm/contract/spec.js.map +1 -1
- package/lib/esm/contract/types.d.ts +25 -8
- package/lib/esm/contract/types.js.map +1 -1
- package/lib/esm/errors/index.d.ts +1 -0
- package/lib/esm/errors/transaction_failed.d.ts +55 -0
- package/lib/esm/errors/transaction_failed.js +60 -0
- package/lib/esm/errors/transaction_failed.js.map +1 -0
- package/lib/esm/errors/wrap_http_error.d.ts +20 -0
- package/lib/esm/errors/wrap_http_error.js +18 -0
- package/lib/esm/errors/wrap_http_error.js.map +1 -0
- package/lib/esm/federation/server.js +15 -35
- package/lib/esm/federation/server.js.map +1 -1
- package/lib/esm/horizon/account_response.js +0 -20
- package/lib/esm/horizon/account_response.js.map +1 -1
- package/lib/esm/horizon/horizon_api.d.ts +12 -1
- package/lib/esm/horizon/horizon_api.js +5 -0
- package/lib/esm/horizon/horizon_api.js.map +1 -1
- package/lib/esm/horizon/horizon_axios_client.js +1 -1
- package/lib/esm/horizon/server.d.ts +10 -4
- package/lib/esm/horizon/server.js +20 -26
- package/lib/esm/horizon/server.js.map +1 -1
- package/lib/esm/index.js +27 -29
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/rpc/api.d.ts +21 -0
- package/lib/esm/rpc/api.js.map +1 -1
- package/lib/esm/rpc/axios.js +1 -1
- package/lib/esm/rpc/server.d.ts +115 -3
- package/lib/esm/rpc/server.js +181 -13
- package/lib/esm/rpc/server.js.map +1 -1
- package/lib/esm/rpc/transaction.js +2 -20
- package/lib/esm/rpc/transaction.js.map +1 -1
- package/lib/esm/webauth/challenge_transaction.js +7 -22
- package/lib/esm/webauth/challenge_transaction.js.map +1 -1
- package/lib/esm/webauth/utils.js +1 -20
- package/lib/esm/webauth/utils.js.map +1 -1
- package/package.json +35 -30
package/lib/esm/rpc/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sources":["../../../src/rpc/api.ts"],"sourcesContent":["import { Contract, SorobanDataBuilder, xdr } from \"../base/index.js\";\n\n/* tslint:disable-next-line:no-namespace */\nexport namespace Api {\n export interface GetHealthResponse {\n latestLedger: number;\n ledgerRetentionWindow: number;\n oldestLedger: number;\n status: \"healthy\";\n }\n\n export interface LedgerEntryResult {\n lastModifiedLedgerSeq?: number;\n key: xdr.LedgerKey;\n val: xdr.LedgerEntryData;\n liveUntilLedgerSeq?: number;\n }\n\n export interface RawLedgerEntryResult {\n lastModifiedLedgerSeq?: number;\n /** a base-64 encoded {@link xdr.LedgerKey} instance */\n key: string;\n /** a base-64 encoded {@link xdr.LedgerEntryData} instance */\n xdr: string;\n /**\n * optional, a future ledger number upon which this entry will expire\n * based on https://github.com/stellar/soroban-tools/issues/1010\n */\n liveUntilLedgerSeq?: number;\n }\n\n /** An XDR-parsed version of {@link RawLedgerEntryResult} */\n export interface GetLedgerEntriesResponse {\n entries: LedgerEntryResult[];\n latestLedger: number;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries */\n export interface RawGetLedgerEntriesResponse {\n entries?: RawLedgerEntryResult[];\n latestLedger: number;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getNetwork */\n export interface GetNetworkResponse {\n friendbotUrl?: string;\n passphrase: string;\n protocolVersion: string;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLatestLedger */\n export interface GetLatestLedgerResponse {\n id: string;\n sequence: number;\n protocolVersion: string;\n closeTime: string;\n headerXdr: xdr.LedgerHeader;\n metadataXdr: xdr.LedgerCloseMeta;\n }\n\n export interface RawGetLatestLedgerResponse {\n id: string;\n sequence: number;\n protocolVersion: string;\n closeTime: string;\n /** a base-64 encoded {@link xdr.LedgerHeader} instance */\n headerXdr: string;\n /** a base-64 encoded {@link xdr.LedgerCloseMeta} instance */\n metadataXdr: string;\n }\n\n export enum GetTransactionStatus {\n SUCCESS = \"SUCCESS\",\n NOT_FOUND = \"NOT_FOUND\",\n FAILED = \"FAILED\",\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction */\n export type GetTransactionResponse =\n | GetSuccessfulTransactionResponse\n | GetFailedTransactionResponse\n | GetMissingTransactionResponse;\n\n interface GetAnyTransactionResponse {\n status: GetTransactionStatus;\n txHash: string;\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n }\n\n export interface GetMissingTransactionResponse extends GetAnyTransactionResponse {\n status: GetTransactionStatus.NOT_FOUND;\n }\n\n export interface GetFailedTransactionResponse extends GetAnyTransactionResponse {\n status: GetTransactionStatus.FAILED;\n\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n envelopeXdr: xdr.TransactionEnvelope;\n resultXdr: xdr.TransactionResult;\n resultMetaXdr: xdr.TransactionMeta;\n diagnosticEventsXdr?: xdr.DiagnosticEvent[];\n events: TransactionEvents;\n }\n\n export interface GetSuccessfulTransactionResponse extends GetAnyTransactionResponse {\n status: GetTransactionStatus.SUCCESS;\n\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n envelopeXdr: xdr.TransactionEnvelope;\n resultXdr: xdr.TransactionResult;\n resultMetaXdr: xdr.TransactionMeta;\n diagnosticEventsXdr?: xdr.DiagnosticEvent[];\n\n returnValue?: xdr.ScVal; // present iff resultMeta is a v3|v4\n events: TransactionEvents;\n }\n\n export interface RawGetTransactionResponse {\n status: GetTransactionStatus;\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n txHash: string;\n\n // the fields below are set if status is SUCCESS\n applicationOrder?: number;\n feeBump?: boolean;\n ledger?: number;\n createdAt?: number;\n\n envelopeXdr?: string;\n resultXdr?: string;\n resultMetaXdr?: string;\n diagnosticEventsXdr?: string[];\n\n events?: RawTransactionEvents;\n }\n\n export type GetTransactionsRequest =\n | {\n startLedger: number;\n pagination?: {\n cursor?: never;\n limit?: number;\n };\n }\n | {\n startLedger?: never;\n pagination: {\n cursor: string;\n limit?: number;\n };\n };\n\n export interface RawTransactionEvents {\n transactionEventsXdr?: string[];\n contractEventsXdr?: string[][];\n }\n\n export interface RawTransactionInfo {\n status: GetTransactionStatus;\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n txHash: string;\n\n envelopeXdr?: string;\n resultXdr?: string;\n resultMetaXdr?: string;\n diagnosticEventsXdr?: string[];\n\n events?: RawTransactionEvents;\n }\n\n export interface TransactionEvents {\n transactionEventsXdr: xdr.TransactionEvent[];\n contractEventsXdr: xdr.ContractEvent[][];\n }\n\n export interface TransactionInfo {\n status: GetTransactionStatus;\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n txHash: string;\n\n envelopeXdr: xdr.TransactionEnvelope;\n resultXdr: xdr.TransactionResult;\n resultMetaXdr: xdr.TransactionMeta;\n returnValue?: xdr.ScVal;\n diagnosticEventsXdr?: xdr.DiagnosticEvent[];\n\n events: TransactionEvents;\n }\n\n export interface GetTransactionsResponse {\n transactions: TransactionInfo[];\n latestLedger: number;\n latestLedgerCloseTimestamp: number;\n oldestLedger: number;\n oldestLedgerCloseTimestamp: number;\n cursor: string;\n }\n\n export interface RawGetTransactionsResponse {\n transactions: RawTransactionInfo[] | null;\n latestLedger: number;\n latestLedgerCloseTimestamp: number;\n oldestLedger: number;\n oldestLedgerCloseTimestamp: number;\n cursor: string;\n }\n\n export type EventType = \"contract\" | \"system\";\n\n export interface EventFilter {\n type?: EventType;\n contractIds?: string[];\n topics?: string[][];\n }\n\n interface RetentionState {\n latestLedger: number;\n oldestLedger: number;\n latestLedgerCloseTime: string;\n oldestLedgerCloseTime: string;\n }\n\n /**\n * Request parameters for fetching events from the Stellar network.\n *\n * **Important**: This type enforces mutually exclusive pagination modes:\n * - **Ledger range mode**: Use `startLedger` and `endLedger` (cursor must be omitted)\n * - **Cursor pagination mode**: Use `cursor` (startLedger and endLedger must be omitted)\n *\n * @example\n * ```ts\n * // ✅ Correct: Ledger range mode\n * const rangeRequest: GetEventsRequest = {\n * filters: [],\n * startLedger: 1000,\n * endLedger: 2000,\n * limit: 100\n * };\n * ```\n *\n * @example\n * ```ts\n * // ✅ Correct: Cursor pagination mode\n * const cursorRequest: GetEventsRequest = {\n * filters: [],\n * cursor: \"some-cursor-value\",\n * limit: 100\n * };\n * ```\n *\n * @example\n * ```ts\n * // ❌ Invalid: Cannot mix cursor with ledger range\n * const invalidRequest = {\n * filters: [],\n * startLedger: 1000, // ❌ Cannot use with cursor\n * endLedger: 2000, // ❌ Cannot use with cursor\n * cursor: \"cursor\", // ❌ Cannot use with ledger range\n * limit: 100\n * };\n * ```\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents API reference}\n */\n export type GetEventsRequest =\n | {\n filters: Api.EventFilter[];\n startLedger: number;\n endLedger?: number;\n cursor?: never; // explicitly exclude cursor\n limit?: number;\n }\n | {\n filters: Api.EventFilter[];\n cursor: string;\n startLedger?: never; // explicitly exclude startLedger\n endLedger?: never; // explicitly exclude endLedger\n limit?: number;\n };\n\n export interface GetEventsResponse extends RetentionState {\n events: EventResponse[];\n cursor: string;\n }\n\n export interface EventResponse extends BaseEventResponse {\n contractId?: Contract;\n topic: xdr.ScVal[];\n value: xdr.ScVal;\n }\n\n export interface RawGetEventsResponse extends RetentionState {\n events: RawEventResponse[];\n cursor: string;\n }\n\n interface BaseEventResponse {\n id: string;\n type: EventType;\n ledger: number;\n ledgerClosedAt: string;\n transactionIndex: number;\n operationIndex: number;\n inSuccessfulContractCall: boolean;\n txHash: string;\n }\n\n export interface RawEventResponse extends BaseEventResponse {\n contractId: string;\n topic?: string[];\n value: string;\n }\n\n interface RawLedgerEntryChange {\n type: number;\n /** This is LedgerKey in base64 */\n key: string;\n /** This is xdr.LedgerEntry in base64 */\n before: string | null;\n /** This is xdr.LedgerEntry in base64 */\n after: string | null;\n }\n\n export interface LedgerEntryChange {\n type: number;\n key: xdr.LedgerKey;\n before: xdr.LedgerEntry | null;\n after: xdr.LedgerEntry | null;\n }\n\n export type SendTransactionStatus =\n | \"PENDING\"\n | \"DUPLICATE\"\n | \"TRY_AGAIN_LATER\"\n | \"ERROR\";\n\n export interface SendTransactionResponse extends BaseSendTransactionResponse {\n errorResult?: xdr.TransactionResult;\n diagnosticEvents?: xdr.DiagnosticEvent[];\n }\n\n export interface RawSendTransactionResponse extends BaseSendTransactionResponse {\n /**\n * This is a base64-encoded instance of {@link xdr.TransactionResult}, set\n * only when `status` is `\"ERROR\"`.\n *\n * It contains details on why the network rejected the transaction.\n */\n errorResultXdr?: string;\n /**\n * This is a base64-encoded instance of an array of\n * {@link xdr.DiagnosticEvent}s, set only when `status` is `\"ERROR\"` and\n * diagnostic events are enabled on the server.\n */\n diagnosticEventsXdr?: string[];\n }\n\n export interface BaseSendTransactionResponse {\n status: SendTransactionStatus;\n hash: string;\n latestLedger: number;\n latestLedgerCloseTime: number;\n }\n\n export interface SimulateHostFunctionResult {\n auth: xdr.SorobanAuthorizationEntry[];\n retval: xdr.ScVal;\n }\n\n export type SimulationAuthMode =\n | \"enforce\"\n | \"record\"\n | \"record_allow_nonroot\";\n\n /**\n * Simplifies {@link RawSimulateTransactionResponse} into separate interfaces\n * based on status:\n * - on success, this includes all fields, though `result` is only present\n * if an invocation was simulated (since otherwise there's nothing to\n * \"resultify\")\n * - if there was an expiration error, this includes error and restoration\n * fields\n * - for all other errors, this only includes error fields\n *\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction\n */\n export type SimulateTransactionResponse =\n | SimulateTransactionSuccessResponse\n | SimulateTransactionRestoreResponse\n | SimulateTransactionErrorResponse;\n\n export interface BaseSimulateTransactionResponse {\n /** always present: the JSON-RPC request ID */\n id: string;\n\n /** always present: the LCL known to the server when responding */\n latestLedger: number;\n\n /**\n * The field is always present, but may be empty in cases where:\n * - you didn't simulate an invocation or\n * - there were no events\n */\n events: xdr.DiagnosticEvent[];\n\n /** a private field to mark the schema as parsed */\n _parsed: boolean;\n }\n\n /** Includes simplified fields only present on success. */\n export interface SimulateTransactionSuccessResponse extends BaseSimulateTransactionResponse {\n transactionData: SorobanDataBuilder;\n minResourceFee: string;\n\n /** present only for invocation simulation */\n result?: SimulateHostFunctionResult;\n\n /** State Difference information */\n stateChanges?: LedgerEntryChange[];\n }\n\n /** Includes details about why the simulation failed */\n export interface SimulateTransactionErrorResponse extends BaseSimulateTransactionResponse {\n error: string;\n events: xdr.DiagnosticEvent[];\n }\n\n export interface SimulateTransactionRestoreResponse extends SimulateTransactionSuccessResponse {\n result: SimulateHostFunctionResult; // not optional now\n\n /**\n * Indicates that a restoration is necessary prior to submission.\n *\n * In other words, seeing a restoration preamble means that your invocation\n * was executed AS IF the required ledger entries were present, and this\n * field includes information about what you need to restore for the\n * simulation to succeed.\n */\n restorePreamble: {\n minResourceFee: string;\n transactionData: SorobanDataBuilder;\n };\n }\n\n /**\n * Checks if a simulation response indicates an error.\n * @param sim - The simulation response to check.\n * @returns True if the response indicates an error, false otherwise.\n */\n export function isSimulationError(\n sim: SimulateTransactionResponse,\n ): sim is SimulateTransactionErrorResponse {\n return \"error\" in sim;\n }\n\n /**\n * Checks if a simulation response indicates success.\n * @param sim - The simulation response to check.\n * @returns True if the response indicates success, false otherwise.\n */\n export function isSimulationSuccess(\n sim: SimulateTransactionResponse,\n ): sim is SimulateTransactionSuccessResponse {\n return \"transactionData\" in sim;\n }\n\n /**\n * Checks if a simulation response indicates that a restoration is needed.\n * @param sim - The simulation response to check.\n * @returns True if the response indicates a restoration is needed, false otherwise.\n */\n export function isSimulationRestore(\n sim: SimulateTransactionResponse,\n ): sim is SimulateTransactionRestoreResponse {\n return (\n isSimulationSuccess(sim) &&\n \"restorePreamble\" in sim &&\n !!sim.restorePreamble.transactionData\n );\n }\n\n /**\n * Checks if a simulation response is in raw (unparsed) form.\n * @param sim - The simulation response to check.\n * @returns True if the response is raw, false otherwise.\n */\n export function isSimulationRaw(\n sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse,\n ): sim is Api.RawSimulateTransactionResponse {\n return !(sim as Api.SimulateTransactionResponse)._parsed;\n }\n\n interface RawSimulateHostFunctionResult {\n // each string is SorobanAuthorizationEntry XDR in base64\n auth?: string[];\n // invocation return value: the ScVal in base64\n xdr: string;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction */\n export interface RawSimulateTransactionResponse {\n id: string;\n latestLedger: number;\n error?: string;\n /** This is an xdr.SorobanTransactionData in base64 */\n transactionData?: string;\n /** These are xdr.DiagnosticEvents in base64 */\n events?: string[];\n minResourceFee?: string;\n /**\n * This will only contain a single element if present, because only a single\n * invokeHostFunctionOperation is supported per transaction.\n * */\n results?: RawSimulateHostFunctionResult[];\n /** Present if succeeded but has expired ledger entries */\n restorePreamble?: {\n minResourceFee: string;\n transactionData: string;\n };\n\n /** State difference information */\n stateChanges?: RawLedgerEntryChange[];\n }\n\n export interface GetVersionInfoResponse {\n version: string;\n commitHash: string;\n buildTimestamp: string;\n captiveCoreVersion: string;\n protocolVersion: number; // uint32\n\n /// @deprecated\n commit_hash: string;\n /// @deprecated\n build_timestamp: string;\n /// @deprecated\n captive_core_version: string;\n /// @deprecated\n protocol_version: number; // uint32\n }\n\n export interface GetFeeStatsResponse {\n sorobanInclusionFee: FeeDistribution;\n inclusionFee: FeeDistribution;\n latestLedger: number; // uint32\n }\n\n interface FeeDistribution {\n max: string; // uint64\n min: string; // uint64\n mode: string; // uint64\n p10: string; // uint64\n p20: string; // uint64\n p30: string; // uint64\n p40: string; // uint64\n p50: string; // uint64\n p60: string; // uint64\n p70: string; // uint64\n p80: string; // uint64\n p90: string; // uint64\n p95: string; // uint64\n p99: string; // uint64\n\n transactionCount: string; // uint32\n ledgerCount: number; // uint32\n }\n\n export interface BalanceResponse {\n latestLedger: number;\n /** present only on success, otherwise request malformed or no balance */\n balanceEntry?: {\n /** a 64-bit integer for trustlines, 128-bit value for contracts */\n amount: string;\n authorized: boolean;\n clawback: boolean;\n authorizedToMaintainLiabilities?: boolean; // only present for trustlines\n /** @deprecated Please use `authorizedToMaintainLiabilities` instead */\n revocable?: boolean;\n lastModifiedLedgerSeq?: number;\n liveUntilLedgerSeq?: number;\n };\n }\n\n /**\n * Request parameters for fetching a sequential list of ledgers.\n *\n * This type supports two distinct pagination modes that are mutually exclusive:\n * - **Ledger-based pagination**: Use `startLedger` to begin fetching from a specific ledger sequence\n * - **Cursor-based pagination**: Use `cursor` to continue from a previous response's pagination token\n *\n * @example\n * ```ts\n * // Ledger-based pagination - start from specific ledger\n * const ledgerRequest: GetLedgersRequest = {\n * startLedger: 36233,\n * pagination: {\n * limit: 10\n * }\n * };\n * ```\n *\n * @example\n * ```ts\n * // Cursor-based pagination - continue from previous response\n * const cursorRequest: GetLedgersRequest = {\n * pagination: {\n * cursor: \"36234\",\n * limit: 5\n * }\n * };\n * ```\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers API reference}\n */\n export type GetLedgersRequest =\n | {\n /**\n * Ledger sequence number to start fetching from (inclusive).\n * Must be omitted if cursor is provided. Cannot be less than the oldest ledger or greater\n * than the latest ledger stored on the RPC node.\n */\n startLedger: number;\n /** Pagination configuration for the request. */\n pagination?: {\n cursor?: never;\n /**\n * Maximum number of ledgers to return per page.\n * Valid range: 1-10000. Defaults to 100 if not specified.\n */\n limit?: number;\n };\n }\n | {\n startLedger?: never;\n /** Pagination configuration for the request. */\n pagination: {\n /**\n * Page cursor for continuing pagination from a previous\n * response. Must be omitted if startLedger is provided.\n */\n cursor: string;\n /**\n * Maximum number of ledgers to return per page.\n * Valid range: 1-10000. Defaults to 100 if not specified.\n */\n limit?: number;\n };\n };\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers */\n export interface GetLedgersResponse {\n ledgers: LedgerResponse[];\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n cursor: string;\n }\n\n export interface RawGetLedgersResponse {\n ledgers: RawLedgerResponse[];\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n cursor: string;\n }\n\n export interface LedgerResponse {\n hash: string;\n sequence: number;\n ledgerCloseTime: string;\n headerXdr: xdr.LedgerHeaderHistoryEntry;\n metadataXdr: xdr.LedgerCloseMeta;\n }\n\n export interface RawLedgerResponse {\n hash: string;\n sequence: number;\n ledgerCloseTime: string;\n /** a base-64 encoded {@link xdr.LedgerHeaderHistoryEntry} instance */\n headerXdr: string;\n /** a base-64 encoded {@link xdr.LedgerCloseMeta} instance */\n metadataXdr: string;\n }\n}\n"],"names":["Api","GetTransactionStatus"],"mappings":"AAGO,IAAU;AAAA,CAAV,CAAUA,IAAAA,KAAV;AAoEE,EAAA,CAAA,CAAKC,qBAAAA,KAAL;AACL,IAAAA,sBAAA,SAAA,CAAA,GAAU,SAAA;AACV,IAAAA,sBAAA,WAAA,CAAA,GAAY,WAAA;AACZ,IAAAA,sBAAA,QAAA,CAAA,GAAS,QAAA;AAAA,EAAA,CAAA,EAHCD,IAAAA,CAAA,oBAAA,KAAAA,IAAAA,CAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;AA4YL,EAAA,SAAS,kBACd,GAAA,EACyC;AACzC,IAAA,OAAO,OAAA,IAAW,GAAA;AAAA,EACpB;AAJO,EAAAA,IAAAA,CAAS,iBAAA,GAAA,iBAAA;AAWT,EAAA,SAAS,oBACd,GAAA,EAC2C;AAC3C,IAAA,OAAO,iBAAA,IAAqB,GAAA;AAAA,EAC9B;AAJO,EAAAA,IAAAA,CAAS,mBAAA,GAAA,mBAAA;AAWT,EAAA,SAAS,oBACd,GAAA,EAC2C;AAC3C,IAAA,OACE,mBAAA,CAAoB,GAAG,CAAA,IACvB,iBAAA,IAAqB,OACrB,CAAC,CAAC,IAAI,eAAA,CAAgB,eAAA;AAAA,EAE1B;AARO,EAAAA,IAAAA,CAAS,mBAAA,GAAA,mBAAA;AAeT,EAAA,SAAS,gBACd,GAAA,EAC2C;AAC3C,IAAA,OAAO,CAAE,GAAA,CAAwC,OAAA;AAAA,EACnD;AAJO,EAAAA,IAAAA,CAAS,eAAA,GAAA,eAAA;AAAA,CAAA,EArfD,GAAA,KAAA,GAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../../../src/rpc/api.ts"],"sourcesContent":["import { Contract, SorobanDataBuilder, xdr } from \"../base/index.js\";\n\n/* tslint:disable-next-line:no-namespace */\nexport namespace Api {\n export interface GetHealthResponse {\n latestLedger: number;\n ledgerRetentionWindow: number;\n oldestLedger: number;\n status: \"healthy\";\n }\n\n export interface LedgerEntryResult {\n lastModifiedLedgerSeq?: number;\n key: xdr.LedgerKey;\n val: xdr.LedgerEntryData;\n liveUntilLedgerSeq?: number;\n }\n\n export interface RawLedgerEntryResult {\n lastModifiedLedgerSeq?: number;\n /** a base-64 encoded {@link xdr.LedgerKey} instance */\n key: string;\n /** a base-64 encoded {@link xdr.LedgerEntryData} instance */\n xdr: string;\n /**\n * optional, a future ledger number upon which this entry will expire\n * based on https://github.com/stellar/soroban-tools/issues/1010\n */\n liveUntilLedgerSeq?: number;\n }\n\n /** An XDR-parsed version of {@link RawLedgerEntryResult} */\n export interface GetLedgerEntriesResponse {\n entries: LedgerEntryResult[];\n latestLedger: number;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries */\n export interface RawGetLedgerEntriesResponse {\n entries?: RawLedgerEntryResult[];\n latestLedger: number;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getNetwork */\n export interface GetNetworkResponse {\n friendbotUrl?: string;\n passphrase: string;\n protocolVersion: string;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLatestLedger */\n export interface GetLatestLedgerResponse {\n id: string;\n sequence: number;\n protocolVersion: string;\n closeTime: string;\n headerXdr: xdr.LedgerHeader;\n metadataXdr: xdr.LedgerCloseMeta;\n }\n\n export interface RawGetLatestLedgerResponse {\n id: string;\n sequence: number;\n protocolVersion: string;\n closeTime: string;\n /** a base-64 encoded {@link xdr.LedgerHeader} instance */\n headerXdr: string;\n /** a base-64 encoded {@link xdr.LedgerCloseMeta} instance */\n metadataXdr: string;\n }\n\n export enum GetTransactionStatus {\n SUCCESS = \"SUCCESS\",\n NOT_FOUND = \"NOT_FOUND\",\n FAILED = \"FAILED\",\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction */\n export type GetTransactionResponse =\n | GetSuccessfulTransactionResponse\n | GetFailedTransactionResponse\n | GetMissingTransactionResponse;\n\n interface GetAnyTransactionResponse {\n status: GetTransactionStatus;\n txHash: string;\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n }\n\n export interface GetMissingTransactionResponse extends GetAnyTransactionResponse {\n status: GetTransactionStatus.NOT_FOUND;\n }\n\n export interface GetFailedTransactionResponse extends GetAnyTransactionResponse {\n status: GetTransactionStatus.FAILED;\n\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n envelopeXdr: xdr.TransactionEnvelope;\n resultXdr: xdr.TransactionResult;\n resultMetaXdr: xdr.TransactionMeta;\n diagnosticEventsXdr?: xdr.DiagnosticEvent[];\n events: TransactionEvents;\n }\n\n export interface GetSuccessfulTransactionResponse extends GetAnyTransactionResponse {\n status: GetTransactionStatus.SUCCESS;\n\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n envelopeXdr: xdr.TransactionEnvelope;\n resultXdr: xdr.TransactionResult;\n resultMetaXdr: xdr.TransactionMeta;\n diagnosticEventsXdr?: xdr.DiagnosticEvent[];\n\n returnValue?: xdr.ScVal; // present iff resultMeta is a v3|v4\n events: TransactionEvents;\n }\n\n export interface RawGetTransactionResponse {\n status: GetTransactionStatus;\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n txHash: string;\n\n // the fields below are set if status is SUCCESS\n applicationOrder?: number;\n feeBump?: boolean;\n ledger?: number;\n createdAt?: number;\n\n envelopeXdr?: string;\n resultXdr?: string;\n resultMetaXdr?: string;\n diagnosticEventsXdr?: string[];\n\n events?: RawTransactionEvents;\n }\n\n export type GetTransactionsRequest =\n | {\n startLedger: number;\n pagination?: {\n cursor?: never;\n limit?: number;\n };\n }\n | {\n startLedger?: never;\n pagination: {\n cursor: string;\n limit?: number;\n };\n };\n\n export interface RawTransactionEvents {\n transactionEventsXdr?: string[];\n contractEventsXdr?: string[][];\n }\n\n export interface RawTransactionInfo {\n status: GetTransactionStatus;\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n txHash: string;\n\n envelopeXdr?: string;\n resultXdr?: string;\n resultMetaXdr?: string;\n diagnosticEventsXdr?: string[];\n\n events?: RawTransactionEvents;\n }\n\n export interface TransactionEvents {\n transactionEventsXdr: xdr.TransactionEvent[];\n contractEventsXdr: xdr.ContractEvent[][];\n }\n\n export interface TransactionInfo {\n status: GetTransactionStatus;\n ledger: number;\n createdAt: number;\n applicationOrder: number;\n feeBump: boolean;\n txHash: string;\n\n envelopeXdr: xdr.TransactionEnvelope;\n resultXdr: xdr.TransactionResult;\n resultMetaXdr: xdr.TransactionMeta;\n returnValue?: xdr.ScVal;\n diagnosticEventsXdr?: xdr.DiagnosticEvent[];\n\n events: TransactionEvents;\n }\n\n export interface GetTransactionsResponse {\n transactions: TransactionInfo[];\n latestLedger: number;\n latestLedgerCloseTimestamp: number;\n oldestLedger: number;\n oldestLedgerCloseTimestamp: number;\n cursor: string;\n }\n\n export interface RawGetTransactionsResponse {\n transactions: RawTransactionInfo[] | null;\n latestLedger: number;\n latestLedgerCloseTimestamp: number;\n oldestLedger: number;\n oldestLedgerCloseTimestamp: number;\n cursor: string;\n }\n\n export type EventType = \"contract\" | \"system\";\n\n export interface EventFilter {\n type?: EventType;\n contractIds?: string[];\n topics?: string[][];\n }\n\n interface RetentionState {\n latestLedger: number;\n oldestLedger: number;\n latestLedgerCloseTime: string;\n oldestLedgerCloseTime: string;\n }\n\n /**\n * Request parameters for fetching events from the Stellar network.\n *\n * **Important**: This type enforces mutually exclusive pagination modes:\n * - **Ledger range mode**: Use `startLedger` and `endLedger` (cursor must be omitted)\n * - **Cursor pagination mode**: Use `cursor` (startLedger and endLedger must be omitted)\n *\n * @example\n * ```ts\n * // ✅ Correct: Ledger range mode\n * const rangeRequest: GetEventsRequest = {\n * filters: [],\n * startLedger: 1000,\n * endLedger: 2000,\n * limit: 100\n * };\n * ```\n *\n * @example\n * ```ts\n * // ✅ Correct: Cursor pagination mode\n * const cursorRequest: GetEventsRequest = {\n * filters: [],\n * cursor: \"some-cursor-value\",\n * limit: 100\n * };\n * ```\n *\n * @example\n * ```ts\n * // ❌ Invalid: Cannot mix cursor with ledger range\n * const invalidRequest = {\n * filters: [],\n * startLedger: 1000, // ❌ Cannot use with cursor\n * endLedger: 2000, // ❌ Cannot use with cursor\n * cursor: \"cursor\", // ❌ Cannot use with ledger range\n * limit: 100\n * };\n * ```\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents API reference}\n */\n export type GetEventsRequest =\n | {\n filters: Api.EventFilter[];\n startLedger: number;\n endLedger?: number;\n cursor?: never; // explicitly exclude cursor\n limit?: number;\n }\n | {\n filters: Api.EventFilter[];\n cursor: string;\n startLedger?: never; // explicitly exclude startLedger\n endLedger?: never; // explicitly exclude endLedger\n limit?: number;\n };\n\n export interface GetEventsResponse extends RetentionState {\n events: EventResponse[];\n cursor: string;\n }\n\n export interface EventResponse extends BaseEventResponse {\n contractId?: Contract;\n topic: xdr.ScVal[];\n value: xdr.ScVal;\n }\n\n export interface RawGetEventsResponse extends RetentionState {\n events: RawEventResponse[];\n cursor: string;\n }\n\n interface BaseEventResponse {\n id: string;\n type: EventType;\n ledger: number;\n ledgerClosedAt: string;\n transactionIndex: number;\n operationIndex: number;\n inSuccessfulContractCall: boolean;\n txHash: string;\n }\n\n export interface RawEventResponse extends BaseEventResponse {\n contractId: string;\n topic?: string[];\n value: string;\n }\n\n interface RawLedgerEntryChange {\n type: number;\n /** This is LedgerKey in base64 */\n key: string;\n /** This is xdr.LedgerEntry in base64 */\n before: string | null;\n /** This is xdr.LedgerEntry in base64 */\n after: string | null;\n }\n\n export interface LedgerEntryChange {\n type: number;\n key: xdr.LedgerKey;\n before: xdr.LedgerEntry | null;\n after: xdr.LedgerEntry | null;\n }\n\n export type SendTransactionStatus =\n | \"PENDING\"\n | \"DUPLICATE\"\n | \"TRY_AGAIN_LATER\"\n | \"ERROR\";\n\n export interface SendTransactionResponse extends BaseSendTransactionResponse {\n errorResult?: xdr.TransactionResult;\n diagnosticEvents?: xdr.DiagnosticEvent[];\n }\n\n export interface RawSendTransactionResponse extends BaseSendTransactionResponse {\n /**\n * This is a base64-encoded instance of {@link xdr.TransactionResult}, set\n * only when `status` is `\"ERROR\"`.\n *\n * It contains details on why the network rejected the transaction.\n */\n errorResultXdr?: string;\n /**\n * This is a base64-encoded instance of an array of\n * {@link xdr.DiagnosticEvent}s, set only when `status` is `\"ERROR\"` and\n * diagnostic events are enabled on the server.\n */\n diagnosticEventsXdr?: string[];\n }\n\n export interface BaseSendTransactionResponse {\n status: SendTransactionStatus;\n hash: string;\n latestLedger: number;\n latestLedgerCloseTime: number;\n }\n\n export interface SimulateHostFunctionResult {\n auth: xdr.SorobanAuthorizationEntry[];\n retval: xdr.ScVal;\n }\n\n export type SimulationAuthMode =\n | \"enforce\"\n | \"record\"\n | \"record_allow_nonroot\";\n\n /**\n * Simplifies {@link RawSimulateTransactionResponse} into separate interfaces\n * based on status:\n * - on success, this includes all fields, though `result` is only present\n * if an invocation was simulated (since otherwise there's nothing to\n * \"resultify\")\n * - if there was an expiration error, this includes error and restoration\n * fields\n * - for all other errors, this only includes error fields\n *\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction\n */\n export type SimulateTransactionResponse =\n | SimulateTransactionSuccessResponse\n | SimulateTransactionRestoreResponse\n | SimulateTransactionErrorResponse;\n\n export interface BaseSimulateTransactionResponse {\n /** always present: the JSON-RPC request ID */\n id: string;\n\n /** always present: the LCL known to the server when responding */\n latestLedger: number;\n\n /**\n * The field is always present, but may be empty in cases where:\n * - you didn't simulate an invocation or\n * - there were no events\n */\n events: xdr.DiagnosticEvent[];\n\n /** a private field to mark the schema as parsed */\n _parsed: boolean;\n }\n\n /** Includes simplified fields only present on success. */\n export interface SimulateTransactionSuccessResponse extends BaseSimulateTransactionResponse {\n transactionData: SorobanDataBuilder;\n minResourceFee: string;\n\n /** present only for invocation simulation */\n result?: SimulateHostFunctionResult;\n\n /** State Difference information */\n stateChanges?: LedgerEntryChange[];\n }\n\n /** Includes details about why the simulation failed */\n export interface SimulateTransactionErrorResponse extends BaseSimulateTransactionResponse {\n error: string;\n events: xdr.DiagnosticEvent[];\n }\n\n export interface SimulateTransactionRestoreResponse extends SimulateTransactionSuccessResponse {\n result: SimulateHostFunctionResult; // not optional now\n\n /**\n * Indicates that a restoration is necessary prior to submission.\n *\n * In other words, seeing a restoration preamble means that your invocation\n * was executed AS IF the required ledger entries were present, and this\n * field includes information about what you need to restore for the\n * simulation to succeed.\n */\n restorePreamble: {\n minResourceFee: string;\n transactionData: SorobanDataBuilder;\n };\n }\n\n /**\n * Checks if a simulation response indicates an error.\n * @param sim - The simulation response to check.\n * @returns True if the response indicates an error, false otherwise.\n */\n export function isSimulationError(\n sim: SimulateTransactionResponse,\n ): sim is SimulateTransactionErrorResponse {\n return \"error\" in sim;\n }\n\n /**\n * Checks if a simulation response indicates success.\n * @param sim - The simulation response to check.\n * @returns True if the response indicates success, false otherwise.\n */\n export function isSimulationSuccess(\n sim: SimulateTransactionResponse,\n ): sim is SimulateTransactionSuccessResponse {\n return \"transactionData\" in sim;\n }\n\n /**\n * Checks if a simulation response indicates that a restoration is needed.\n * @param sim - The simulation response to check.\n * @returns True if the response indicates a restoration is needed, false otherwise.\n */\n export function isSimulationRestore(\n sim: SimulateTransactionResponse,\n ): sim is SimulateTransactionRestoreResponse {\n return (\n isSimulationSuccess(sim) &&\n \"restorePreamble\" in sim &&\n !!sim.restorePreamble.transactionData\n );\n }\n\n /**\n * Checks if a simulation response is in raw (unparsed) form.\n * @param sim - The simulation response to check.\n * @returns True if the response is raw, false otherwise.\n */\n export function isSimulationRaw(\n sim: Api.SimulateTransactionResponse | Api.RawSimulateTransactionResponse,\n ): sim is Api.RawSimulateTransactionResponse {\n return !(sim as Api.SimulateTransactionResponse)._parsed;\n }\n\n interface RawSimulateHostFunctionResult {\n // each string is SorobanAuthorizationEntry XDR in base64\n auth?: string[];\n // invocation return value: the ScVal in base64\n xdr: string;\n }\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction */\n export interface RawSimulateTransactionResponse {\n id: string;\n latestLedger: number;\n error?: string;\n /** This is an xdr.SorobanTransactionData in base64 */\n transactionData?: string;\n /** These are xdr.DiagnosticEvents in base64 */\n events?: string[];\n minResourceFee?: string;\n /**\n * This will only contain a single element if present, because only a single\n * invokeHostFunctionOperation is supported per transaction.\n * */\n results?: RawSimulateHostFunctionResult[];\n /** Present if succeeded but has expired ledger entries */\n restorePreamble?: {\n minResourceFee: string;\n transactionData: string;\n };\n\n /** State difference information */\n stateChanges?: RawLedgerEntryChange[];\n }\n\n export interface GetVersionInfoResponse {\n version: string;\n commitHash: string;\n buildTimestamp: string;\n captiveCoreVersion: string;\n protocolVersion: number; // uint32\n\n /// @deprecated\n commit_hash: string;\n /// @deprecated\n build_timestamp: string;\n /// @deprecated\n captive_core_version: string;\n /// @deprecated\n protocol_version: number; // uint32\n }\n\n export interface GetFeeStatsResponse {\n sorobanInclusionFee: FeeDistribution;\n inclusionFee: FeeDistribution;\n latestLedger: number; // uint32\n }\n\n interface FeeDistribution {\n max: string; // uint64\n min: string; // uint64\n mode: string; // uint64\n p10: string; // uint64\n p20: string; // uint64\n p30: string; // uint64\n p40: string; // uint64\n p50: string; // uint64\n p60: string; // uint64\n p70: string; // uint64\n p80: string; // uint64\n p90: string; // uint64\n p95: string; // uint64\n p99: string; // uint64\n\n transactionCount: string; // uint32\n ledgerCount: number; // uint32\n }\n\n export interface BalanceResponse {\n latestLedger: number;\n /** present only on success, otherwise request malformed or no balance */\n balanceEntry?: {\n /** a 64-bit integer for trustlines, 128-bit value for contracts */\n amount: string;\n authorized: boolean;\n clawback: boolean;\n authorizedToMaintainLiabilities?: boolean; // only present for trustlines\n /** @deprecated Please use `authorizedToMaintainLiabilities` instead */\n revocable?: boolean;\n lastModifiedLedgerSeq?: number;\n liveUntilLedgerSeq?: number;\n };\n }\n\n /**\n * Request parameters for fetching a sequential list of ledgers.\n *\n * This type supports two distinct pagination modes that are mutually exclusive:\n * - **Ledger-based pagination**: Use `startLedger` to begin fetching from a specific ledger sequence\n * - **Cursor-based pagination**: Use `cursor` to continue from a previous response's pagination token\n *\n * @example\n * ```ts\n * // Ledger-based pagination - start from specific ledger\n * const ledgerRequest: GetLedgersRequest = {\n * startLedger: 36233,\n * pagination: {\n * limit: 10\n * }\n * };\n * ```\n *\n * @example\n * ```ts\n * // Cursor-based pagination - continue from previous response\n * const cursorRequest: GetLedgersRequest = {\n * pagination: {\n * cursor: \"36234\",\n * limit: 5\n * }\n * };\n * ```\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers API reference}\n */\n export type GetLedgersRequest =\n | {\n /**\n * Ledger sequence number to start fetching from (inclusive).\n * Must be omitted if cursor is provided. Cannot be less than the oldest ledger or greater\n * than the latest ledger stored on the RPC node.\n */\n startLedger: number;\n /** Pagination configuration for the request. */\n pagination?: {\n cursor?: never;\n /**\n * Maximum number of ledgers to return per page.\n * Valid range: 1-10000. Defaults to 100 if not specified.\n */\n limit?: number;\n };\n }\n | {\n startLedger?: never;\n /** Pagination configuration for the request. */\n pagination: {\n /**\n * Page cursor for continuing pagination from a previous\n * response. Must be omitted if startLedger is provided.\n */\n cursor: string;\n /**\n * Maximum number of ledgers to return per page.\n * Valid range: 1-10000. Defaults to 100 if not specified.\n */\n limit?: number;\n };\n };\n\n /** @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers */\n export interface GetLedgersResponse {\n ledgers: LedgerResponse[];\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n cursor: string;\n }\n\n export interface RawGetLedgersResponse {\n ledgers: RawLedgerResponse[];\n latestLedger: number;\n latestLedgerCloseTime: number;\n oldestLedger: number;\n oldestLedgerCloseTime: number;\n cursor: string;\n }\n\n export interface LedgerResponse {\n hash: string;\n sequence: number;\n ledgerCloseTime: string;\n headerXdr: xdr.LedgerHeaderHistoryEntry;\n metadataXdr: xdr.LedgerCloseMeta;\n }\n\n export interface RawLedgerResponse {\n hash: string;\n sequence: number;\n ledgerCloseTime: string;\n /** a base-64 encoded {@link xdr.LedgerHeaderHistoryEntry} instance */\n headerXdr: string;\n /** a base-64 encoded {@link xdr.LedgerCloseMeta} instance */\n metadataXdr: string;\n }\n\n /** A single input parameter of a {@link ContractMethod}. */\n export interface ContractMethodInput {\n /** the declared parameter name */\n name: string;\n /** a human-readable type name, e.g. `U32`, `Address`, or a UDT's name */\n type: string;\n }\n\n /**\n * A callable method declared in a contract's spec, as returned by\n * `RpcServer.getContractMethods`.\n */\n export interface ContractMethod {\n /** the on-chain method name */\n name: string;\n /** the method's parameters, in declaration order */\n inputs: ContractMethodInput[];\n /** human-readable return type name(s); empty when the method returns void */\n outputs: string[];\n /** the method's spec doc string, when the contract declares one */\n doc?: string;\n }\n}\n"],"names":["Api","GetTransactionStatus"],"mappings":"AAGO,IAAU;AAAA,CAAV,CAAUA,IAAAA,KAAV;AAoEE,EAAA,CAAA,CAAKC,qBAAAA,KAAL;AACL,IAAAA,sBAAA,SAAA,CAAA,GAAU,SAAA;AACV,IAAAA,sBAAA,WAAA,CAAA,GAAY,WAAA;AACZ,IAAAA,sBAAA,QAAA,CAAA,GAAS,QAAA;AAAA,EAAA,CAAA,EAHCD,IAAAA,CAAA,oBAAA,KAAAA,IAAAA,CAAA,oBAAA,GAAA,EAAA,CAAA,CAAA;AA4YL,EAAA,SAAS,kBACd,GAAA,EACyC;AACzC,IAAA,OAAO,OAAA,IAAW,GAAA;AAAA,EACpB;AAJO,EAAAA,IAAAA,CAAS,iBAAA,GAAA,iBAAA;AAWT,EAAA,SAAS,oBACd,GAAA,EAC2C;AAC3C,IAAA,OAAO,iBAAA,IAAqB,GAAA;AAAA,EAC9B;AAJO,EAAAA,IAAAA,CAAS,mBAAA,GAAA,mBAAA;AAWT,EAAA,SAAS,oBACd,GAAA,EAC2C;AAC3C,IAAA,OACE,mBAAA,CAAoB,GAAG,CAAA,IACvB,iBAAA,IAAqB,OACrB,CAAC,CAAC,IAAI,eAAA,CAAgB,eAAA;AAAA,EAE1B;AARO,EAAAA,IAAAA,CAAS,mBAAA,GAAA,mBAAA;AAeT,EAAA,SAAS,gBACd,GAAA,EAC2C;AAC3C,IAAA,OAAO,CAAE,GAAA,CAAwC,OAAA;AAAA,EACnD;AAJO,EAAAA,IAAAA,CAAS,eAAA,GAAA,eAAA;AAAA,CAAA,EArfD,GAAA,KAAA,GAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/lib/esm/rpc/axios.js
CHANGED
package/lib/esm/rpc/server.d.ts
CHANGED
|
@@ -257,6 +257,25 @@ export declare class RpcServer {
|
|
|
257
257
|
* ```
|
|
258
258
|
*/
|
|
259
259
|
getContractData(contract: string | Address | Contract, key: xdr.ScVal, durability?: Durability): Promise<Api.LedgerEntryResult>;
|
|
260
|
+
/**
|
|
261
|
+
* Retrieves the deployed contract instance for a given contract ID.
|
|
262
|
+
*
|
|
263
|
+
* The instance describes the contract's executable — either a Wasm hash or
|
|
264
|
+
* the built-in Stellar Asset Contract — along with its instance storage.
|
|
265
|
+
*
|
|
266
|
+
* @param contractId - The contract ID (`C...`) to look up
|
|
267
|
+
* @returns The contract's `xdr.ScContractInstance`
|
|
268
|
+
* @throws If the contract instance cannot be found on the network.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* const instance = await server.getContractInstance(
|
|
273
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
274
|
+
* );
|
|
275
|
+
* console.log(instance.executable().switch().name);
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
getContractInstance(contractId: string): Promise<xdr.ScContractInstance>;
|
|
260
279
|
/**
|
|
261
280
|
* Retrieves the WASM bytecode for a given contract.
|
|
262
281
|
*
|
|
@@ -264,10 +283,14 @@ export declare class RpcServer {
|
|
|
264
283
|
* deployed on the Soroban network. The WASM bytecode represents the executable
|
|
265
284
|
* code of the contract.
|
|
266
285
|
*
|
|
286
|
+
* This only works for Wasm-based contracts. A built-in Stellar Asset Contract
|
|
287
|
+
* (SAC) has no Wasm bytecode on-chain, so this throws for a SAC; use
|
|
288
|
+
* {@link contract.Client.from} to build a client from the embedded SAC spec.
|
|
289
|
+
*
|
|
267
290
|
* @param contractId - The contract ID containing the WASM bytecode to retrieve
|
|
268
291
|
* @returns A Buffer containing the WASM bytecode
|
|
269
292
|
* @throws If the contract or its associated WASM bytecode cannot be
|
|
270
|
-
* found on the network.
|
|
293
|
+
* found on the network, or if the contract is a Stellar Asset Contract (SAC).
|
|
271
294
|
*
|
|
272
295
|
* @example
|
|
273
296
|
* ```ts
|
|
@@ -305,6 +328,86 @@ export declare class RpcServer {
|
|
|
305
328
|
* ```
|
|
306
329
|
*/
|
|
307
330
|
getContractWasmByHash(wasmHash: Buffer | string, format?: undefined | "hex" | "base64"): Promise<Buffer>;
|
|
331
|
+
/**
|
|
332
|
+
* Performs a read-only call to a contract method and returns the decoded result.
|
|
333
|
+
*
|
|
334
|
+
* This is a convenience wrapper for one-line contract state queries: it builds
|
|
335
|
+
* a {@link contract.Client} for the contract, simulates the method call, and
|
|
336
|
+
* returns the spec-decoded return value — no manual transaction assembly,
|
|
337
|
+
* signing, or submission required.
|
|
338
|
+
*
|
|
339
|
+
* Works for both Wasm contracts and built-in Stellar Asset Contracts (SACs):
|
|
340
|
+
* the embedded SAC spec is used automatically for SACs (see
|
|
341
|
+
* {@link contract.Client.from}). The query reuses this server's transport
|
|
342
|
+
* (headers, interceptors, `allowHttp`).
|
|
343
|
+
*
|
|
344
|
+
* @typeParam T - the expected (decoded) return type of the method
|
|
345
|
+
* @param contractId - the contract to query (`C...`)
|
|
346
|
+
* @param method - the contract method to call
|
|
347
|
+
* @param args - named arguments for the method, keyed by parameter name
|
|
348
|
+
* (omit for methods that take no arguments)
|
|
349
|
+
* @param networkPassphrase - (optional) the network passphrase. If omitted, a
|
|
350
|
+
* request about network information will be made (see {@link getNetwork}).
|
|
351
|
+
* You can refer to {@link Networks} for a list of built-in passphrases,
|
|
352
|
+
* e.g., `Networks.TESTNET`.
|
|
353
|
+
* @returns An object with the method's decoded return value (`result`) and
|
|
354
|
+
* `isReadCall`: whether this specific call is a side-effect-free read that
|
|
355
|
+
* needs no signature (it wrote no state and required no authorization).
|
|
356
|
+
* `isReadCall` is per-call, not per-method: it reflects the given `args`.
|
|
357
|
+
* Since `queryContract` never signs or sends, `isReadCall: false` means the
|
|
358
|
+
* `result` is a simulation preview of a call that would change state.
|
|
359
|
+
* @throws If the contract has no such method, or if the simulation fails.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* const { result: decimals, isReadCall } = await server.queryContract<number>(
|
|
364
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
365
|
+
* "decimals",
|
|
366
|
+
* );
|
|
367
|
+
* const { result: balance } = await server.queryContract<bigint>(
|
|
368
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
369
|
+
* "balance",
|
|
370
|
+
* { id: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ" },
|
|
371
|
+
* );
|
|
372
|
+
* ```
|
|
373
|
+
*/
|
|
374
|
+
queryContract<T = any>(contractId: string, method: string, args?: Record<string, unknown>, networkPassphrase?: string): Promise<{
|
|
375
|
+
result: T;
|
|
376
|
+
isReadCall: boolean;
|
|
377
|
+
}>;
|
|
378
|
+
/**
|
|
379
|
+
* Lists a contract's callable methods and their signatures.
|
|
380
|
+
*
|
|
381
|
+
* A discovery helper for tooling, dapps, and agents that need to inspect an
|
|
382
|
+
* arbitrary contract without knowing its interface up front. It resolves the
|
|
383
|
+
* contract's spec (embedded in the Wasm for regular contracts, or the
|
|
384
|
+
* built-in spec for Stellar Asset Contracts — see {@link contract.Client.from})
|
|
385
|
+
* and reports each declared function's name, inputs, and outputs. No method
|
|
386
|
+
* is invoked or simulated; this performs only the spec lookup.
|
|
387
|
+
*
|
|
388
|
+
* The complement to {@link queryContract}: list methods here, then call a
|
|
389
|
+
* read-only one with `server.queryContract(contractId, method, args?)`.
|
|
390
|
+
*
|
|
391
|
+
* @param contractId - the contract to inspect (`C...`)
|
|
392
|
+
* @param networkPassphrase - (optional) the network passphrase. If omitted, a
|
|
393
|
+
* request about network information will be made (see {@link getNetwork}).
|
|
394
|
+
* You can refer to {@link Networks} for a list of built-in passphrases,
|
|
395
|
+
* e.g., `Networks.TESTNET`.
|
|
396
|
+
* @returns The contract's methods, in the order they appear in the spec
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```ts
|
|
400
|
+
* const methods = await server.getContractMethods(
|
|
401
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
402
|
+
* );
|
|
403
|
+
* // [
|
|
404
|
+
* // { name: "decimals", inputs: [], outputs: ["U32"] },
|
|
405
|
+
* // { name: "balance", inputs: [{ name: "id", type: "Address" }], outputs: ["I128"] },
|
|
406
|
+
* // { name: "transfer", inputs: [...], outputs: [] },
|
|
407
|
+
* // ]
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
getContractMethods(contractId: string, networkPassphrase?: string): Promise<Api.ContractMethod[]>;
|
|
308
411
|
/**
|
|
309
412
|
* Reads the current value of arbitrary ledger entries directly.
|
|
310
413
|
*
|
|
@@ -518,6 +621,15 @@ export declare class RpcServer {
|
|
|
518
621
|
* auth mode to use for simulation: `enforce` for enforcement mode,
|
|
519
622
|
* `record` for recording mode, or `record_allow_nonroot` for recording
|
|
520
623
|
* mode that allows non-root authorization
|
|
624
|
+
* @param useUpgradedAuth - (optional) opt simulation into recording
|
|
625
|
+
* v2 address credentials (CAP-71) instead of the legacy v1 address
|
|
626
|
+
* credentials. Best-effort: it only affects the recording auth modes and
|
|
627
|
+
* is silently ignored on protocol versions whose host cannot emit v2
|
|
628
|
+
* credentials.
|
|
629
|
+
*
|
|
630
|
+
* **Deprecated**: this flag is transitional. Once the network returns v2
|
|
631
|
+
* credentials by default (protocol 28), it becomes a no-op — do not rely
|
|
632
|
+
* on omitting it to keep receiving the legacy v1 format.
|
|
521
633
|
*
|
|
522
634
|
* @returns An object with the
|
|
523
635
|
* cost, footprint, result/auth requirements (if applicable), and error of
|
|
@@ -557,8 +669,8 @@ export declare class RpcServer {
|
|
|
557
669
|
* });
|
|
558
670
|
* ```
|
|
559
671
|
*/
|
|
560
|
-
simulateTransaction(tx: Transaction | FeeBumpTransaction, addlResources?: RpcServer.ResourceLeeway, authMode?: Api.SimulationAuthMode): Promise<Api.SimulateTransactionResponse>;
|
|
561
|
-
_simulateTransaction(transaction: Transaction | FeeBumpTransaction, addlResources?: RpcServer.ResourceLeeway, authMode?: Api.SimulationAuthMode): Promise<Api.RawSimulateTransactionResponse>;
|
|
672
|
+
simulateTransaction(tx: Transaction | FeeBumpTransaction, addlResources?: RpcServer.ResourceLeeway, authMode?: Api.SimulationAuthMode, useUpgradedAuth?: boolean): Promise<Api.SimulateTransactionResponse>;
|
|
673
|
+
_simulateTransaction(transaction: Transaction | FeeBumpTransaction, addlResources?: RpcServer.ResourceLeeway, authMode?: Api.SimulationAuthMode, useUpgradedAuth?: boolean): Promise<Api.RawSimulateTransactionResponse>;
|
|
562
674
|
/**
|
|
563
675
|
* Submit a trial contract invocation, first run a simulation of the contract
|
|
564
676
|
* invocation as defined on the incoming transaction, and apply the results to
|
package/lib/esm/rpc/server.js
CHANGED
|
@@ -59,6 +59,12 @@ function findCreatedAccountSequenceInTransactionMeta(meta) {
|
|
|
59
59
|
}
|
|
60
60
|
throw new Error("No account created in transaction");
|
|
61
61
|
}
|
|
62
|
+
function contractSpecTypeName(td) {
|
|
63
|
+
if (td.switch().value === types.ScSpecType.scSpecTypeUdt().value) {
|
|
64
|
+
return td.udt().name().toString();
|
|
65
|
+
}
|
|
66
|
+
return td.switch().name.replace(/^scSpecType/, "");
|
|
67
|
+
}
|
|
62
68
|
class RpcServer {
|
|
63
69
|
serverURL;
|
|
64
70
|
/**
|
|
@@ -395,6 +401,35 @@ class RpcServer {
|
|
|
395
401
|
};
|
|
396
402
|
}
|
|
397
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Retrieves the deployed contract instance for a given contract ID.
|
|
406
|
+
*
|
|
407
|
+
* The instance describes the contract's executable — either a Wasm hash or
|
|
408
|
+
* the built-in Stellar Asset Contract — along with its instance storage.
|
|
409
|
+
*
|
|
410
|
+
* @param contractId - The contract ID (`C...`) to look up
|
|
411
|
+
* @returns The contract's `xdr.ScContractInstance`
|
|
412
|
+
* @throws If the contract instance cannot be found on the network.
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* ```ts
|
|
416
|
+
* const instance = await server.getContractInstance(
|
|
417
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
418
|
+
* );
|
|
419
|
+
* console.log(instance.executable().switch().name);
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
async getContractInstance(contractId) {
|
|
423
|
+
const contractLedgerKey = new Contract(contractId).getFootprint();
|
|
424
|
+
const response = await this.getLedgerEntries(contractLedgerKey);
|
|
425
|
+
if (!response.entries.length || !response.entries[0]?.val) {
|
|
426
|
+
return Promise.reject({
|
|
427
|
+
code: 404,
|
|
428
|
+
message: "Could not obtain contract instance from server"
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
return response.entries[0].val.contractData().val().instance();
|
|
432
|
+
}
|
|
398
433
|
/**
|
|
399
434
|
* Retrieves the WASM bytecode for a given contract.
|
|
400
435
|
*
|
|
@@ -402,10 +437,14 @@ class RpcServer {
|
|
|
402
437
|
* deployed on the Soroban network. The WASM bytecode represents the executable
|
|
403
438
|
* code of the contract.
|
|
404
439
|
*
|
|
440
|
+
* This only works for Wasm-based contracts. A built-in Stellar Asset Contract
|
|
441
|
+
* (SAC) has no Wasm bytecode on-chain, so this throws for a SAC; use
|
|
442
|
+
* {@link contract.Client.from} to build a client from the embedded SAC spec.
|
|
443
|
+
*
|
|
405
444
|
* @param contractId - The contract ID containing the WASM bytecode to retrieve
|
|
406
445
|
* @returns A Buffer containing the WASM bytecode
|
|
407
446
|
* @throws If the contract or its associated WASM bytecode cannot be
|
|
408
|
-
* found on the network.
|
|
447
|
+
* found on the network, or if the contract is a Stellar Asset Contract (SAC).
|
|
409
448
|
*
|
|
410
449
|
* @example
|
|
411
450
|
* ```ts
|
|
@@ -419,16 +458,14 @@ class RpcServer {
|
|
|
419
458
|
* ```
|
|
420
459
|
*/
|
|
421
460
|
async getContractWasmByContractId(contractId) {
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
if (!response.entries.length || !response.entries[0]?.val) {
|
|
461
|
+
const instance = await this.getContractInstance(contractId);
|
|
462
|
+
if (instance.executable().switch() === types.ContractExecutableType.contractExecutableStellarAsset()) {
|
|
425
463
|
return Promise.reject({
|
|
426
|
-
code:
|
|
427
|
-
message: `
|
|
464
|
+
code: 400,
|
|
465
|
+
message: `Contract ${contractId} is a Stellar Asset Contract (SAC), which has no Wasm bytecode. Use contract.Client.from() to build a client from the built-in SAC spec instead.`
|
|
428
466
|
});
|
|
429
467
|
}
|
|
430
|
-
|
|
431
|
-
return this.getContractWasmByHash(wasmHash);
|
|
468
|
+
return this.getContractWasmByHash(instance.executable().wasmHash());
|
|
432
469
|
}
|
|
433
470
|
/**
|
|
434
471
|
* Retrieves the WASM bytecode for a given contract hash.
|
|
@@ -470,6 +507,124 @@ class RpcServer {
|
|
|
470
507
|
const wasmBuffer = responseWasm.entries[0].val.contractCode().code();
|
|
471
508
|
return wasmBuffer;
|
|
472
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Performs a read-only call to a contract method and returns the decoded result.
|
|
512
|
+
*
|
|
513
|
+
* This is a convenience wrapper for one-line contract state queries: it builds
|
|
514
|
+
* a {@link contract.Client} for the contract, simulates the method call, and
|
|
515
|
+
* returns the spec-decoded return value — no manual transaction assembly,
|
|
516
|
+
* signing, or submission required.
|
|
517
|
+
*
|
|
518
|
+
* Works for both Wasm contracts and built-in Stellar Asset Contracts (SACs):
|
|
519
|
+
* the embedded SAC spec is used automatically for SACs (see
|
|
520
|
+
* {@link contract.Client.from}). The query reuses this server's transport
|
|
521
|
+
* (headers, interceptors, `allowHttp`).
|
|
522
|
+
*
|
|
523
|
+
* @typeParam T - the expected (decoded) return type of the method
|
|
524
|
+
* @param contractId - the contract to query (`C...`)
|
|
525
|
+
* @param method - the contract method to call
|
|
526
|
+
* @param args - named arguments for the method, keyed by parameter name
|
|
527
|
+
* (omit for methods that take no arguments)
|
|
528
|
+
* @param networkPassphrase - (optional) the network passphrase. If omitted, a
|
|
529
|
+
* request about network information will be made (see {@link getNetwork}).
|
|
530
|
+
* You can refer to {@link Networks} for a list of built-in passphrases,
|
|
531
|
+
* e.g., `Networks.TESTNET`.
|
|
532
|
+
* @returns An object with the method's decoded return value (`result`) and
|
|
533
|
+
* `isReadCall`: whether this specific call is a side-effect-free read that
|
|
534
|
+
* needs no signature (it wrote no state and required no authorization).
|
|
535
|
+
* `isReadCall` is per-call, not per-method: it reflects the given `args`.
|
|
536
|
+
* Since `queryContract` never signs or sends, `isReadCall: false` means the
|
|
537
|
+
* `result` is a simulation preview of a call that would change state.
|
|
538
|
+
* @throws If the contract has no such method, or if the simulation fails.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```ts
|
|
542
|
+
* const { result: decimals, isReadCall } = await server.queryContract<number>(
|
|
543
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
544
|
+
* "decimals",
|
|
545
|
+
* );
|
|
546
|
+
* const { result: balance } = await server.queryContract<bigint>(
|
|
547
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
548
|
+
* "balance",
|
|
549
|
+
* { id: "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ" },
|
|
550
|
+
* );
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
async queryContract(contractId, method, args = {}, networkPassphrase) {
|
|
554
|
+
const passphrase = networkPassphrase ?? (await this.getNetwork()).passphrase;
|
|
555
|
+
const { Client } = await import('../contract/client.js');
|
|
556
|
+
const client = await Client.from({
|
|
557
|
+
contractId,
|
|
558
|
+
rpcUrl: this.serverURL.toString(),
|
|
559
|
+
networkPassphrase: passphrase,
|
|
560
|
+
server: this
|
|
561
|
+
});
|
|
562
|
+
const isContractMethod = client.spec.funcs().some((fn) => fn.name().toString() === method);
|
|
563
|
+
const { sanitizeIdentifier } = await import('../bindings/utils.js');
|
|
564
|
+
const invoke = client[sanitizeIdentifier(method)];
|
|
565
|
+
if (!isContractMethod || typeof invoke !== "function") {
|
|
566
|
+
throw new TypeError(`Contract ${contractId} has no method '${method}'`);
|
|
567
|
+
}
|
|
568
|
+
const assembled = await invoke(args);
|
|
569
|
+
return { result: assembled.result, isReadCall: assembled.isReadCall };
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Lists a contract's callable methods and their signatures.
|
|
573
|
+
*
|
|
574
|
+
* A discovery helper for tooling, dapps, and agents that need to inspect an
|
|
575
|
+
* arbitrary contract without knowing its interface up front. It resolves the
|
|
576
|
+
* contract's spec (embedded in the Wasm for regular contracts, or the
|
|
577
|
+
* built-in spec for Stellar Asset Contracts — see {@link contract.Client.from})
|
|
578
|
+
* and reports each declared function's name, inputs, and outputs. No method
|
|
579
|
+
* is invoked or simulated; this performs only the spec lookup.
|
|
580
|
+
*
|
|
581
|
+
* The complement to {@link queryContract}: list methods here, then call a
|
|
582
|
+
* read-only one with `server.queryContract(contractId, method, args?)`.
|
|
583
|
+
*
|
|
584
|
+
* @param contractId - the contract to inspect (`C...`)
|
|
585
|
+
* @param networkPassphrase - (optional) the network passphrase. If omitted, a
|
|
586
|
+
* request about network information will be made (see {@link getNetwork}).
|
|
587
|
+
* You can refer to {@link Networks} for a list of built-in passphrases,
|
|
588
|
+
* e.g., `Networks.TESTNET`.
|
|
589
|
+
* @returns The contract's methods, in the order they appear in the spec
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```ts
|
|
593
|
+
* const methods = await server.getContractMethods(
|
|
594
|
+
* "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5",
|
|
595
|
+
* );
|
|
596
|
+
* // [
|
|
597
|
+
* // { name: "decimals", inputs: [], outputs: ["U32"] },
|
|
598
|
+
* // { name: "balance", inputs: [{ name: "id", type: "Address" }], outputs: ["I128"] },
|
|
599
|
+
* // { name: "transfer", inputs: [...], outputs: [] },
|
|
600
|
+
* // ]
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
603
|
+
async getContractMethods(contractId, networkPassphrase) {
|
|
604
|
+
const passphrase = networkPassphrase ?? (await this.getNetwork()).passphrase;
|
|
605
|
+
const { Client } = await import('../contract/client.js');
|
|
606
|
+
const client = await Client.from({
|
|
607
|
+
contractId,
|
|
608
|
+
rpcUrl: this.serverURL.toString(),
|
|
609
|
+
networkPassphrase: passphrase,
|
|
610
|
+
server: this
|
|
611
|
+
});
|
|
612
|
+
return client.spec.funcs().map((fn) => {
|
|
613
|
+
const doc = fn.doc().toString();
|
|
614
|
+
const method = {
|
|
615
|
+
name: fn.name().toString(),
|
|
616
|
+
inputs: fn.inputs().map((input) => ({
|
|
617
|
+
name: input.name().toString(),
|
|
618
|
+
type: contractSpecTypeName(input.type())
|
|
619
|
+
})),
|
|
620
|
+
outputs: fn.outputs().map(contractSpecTypeName)
|
|
621
|
+
};
|
|
622
|
+
if (doc) {
|
|
623
|
+
method.doc = doc;
|
|
624
|
+
}
|
|
625
|
+
return method;
|
|
626
|
+
});
|
|
627
|
+
}
|
|
473
628
|
/**
|
|
474
629
|
* Reads the current value of arbitrary ledger entries directly.
|
|
475
630
|
*
|
|
@@ -796,6 +951,15 @@ class RpcServer {
|
|
|
796
951
|
* auth mode to use for simulation: `enforce` for enforcement mode,
|
|
797
952
|
* `record` for recording mode, or `record_allow_nonroot` for recording
|
|
798
953
|
* mode that allows non-root authorization
|
|
954
|
+
* @param useUpgradedAuth - (optional) opt simulation into recording
|
|
955
|
+
* v2 address credentials (CAP-71) instead of the legacy v1 address
|
|
956
|
+
* credentials. Best-effort: it only affects the recording auth modes and
|
|
957
|
+
* is silently ignored on protocol versions whose host cannot emit v2
|
|
958
|
+
* credentials.
|
|
959
|
+
*
|
|
960
|
+
* **Deprecated**: this flag is transitional. Once the network returns v2
|
|
961
|
+
* credentials by default (protocol 28), it becomes a no-op — do not rely
|
|
962
|
+
* on omitting it to keep receiving the legacy v1 format.
|
|
799
963
|
*
|
|
800
964
|
* @returns An object with the
|
|
801
965
|
* cost, footprint, result/auth requirements (if applicable), and error of
|
|
@@ -835,12 +999,15 @@ class RpcServer {
|
|
|
835
999
|
* });
|
|
836
1000
|
* ```
|
|
837
1001
|
*/
|
|
838
|
-
async simulateTransaction(tx, addlResources, authMode) {
|
|
839
|
-
return this._simulateTransaction(
|
|
840
|
-
|
|
841
|
-
|
|
1002
|
+
async simulateTransaction(tx, addlResources, authMode, useUpgradedAuth) {
|
|
1003
|
+
return this._simulateTransaction(
|
|
1004
|
+
tx,
|
|
1005
|
+
addlResources,
|
|
1006
|
+
authMode,
|
|
1007
|
+
useUpgradedAuth
|
|
1008
|
+
).then(parseRawSimulation);
|
|
842
1009
|
}
|
|
843
|
-
async _simulateTransaction(transaction, addlResources, authMode) {
|
|
1010
|
+
async _simulateTransaction(transaction, addlResources, authMode, useUpgradedAuth) {
|
|
844
1011
|
return postObject(
|
|
845
1012
|
this.httpClient,
|
|
846
1013
|
this.serverURL.toString(),
|
|
@@ -848,6 +1015,7 @@ class RpcServer {
|
|
|
848
1015
|
{
|
|
849
1016
|
transaction: transaction.toXDR(),
|
|
850
1017
|
authMode,
|
|
1018
|
+
...useUpgradedAuth !== void 0 && { useUpgradedAuth },
|
|
851
1019
|
...addlResources !== void 0 && {
|
|
852
1020
|
resourceConfig: {
|
|
853
1021
|
instructionLeeway: addlResources.cpuInstructions
|