@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sources":["../../../src/federation/server.ts"],"sourcesContent":["import { StrKey } from \"../base/index.js\";\n\nimport { Config } from \"../config.js\";\nimport { BadResponseError } from \"../errors/index.js\";\nimport { Resolver } from \"../stellartoml/index.js\";\n\nimport type { Api } from \"./api.js\";\nimport { httpClient } from \"../http-client/index.js\";\nimport { validateDomain } from \"./utils.js\";\n\n/**\n * The maximum size of response from a federation server\n * @defaultValue 102400\n */\nexport const FEDERATION_RESPONSE_MAX_SIZE: number = 100 * 1024;\n\n/**\n * Federation.Server handles a network connection to a\n * [federation server](https://developers.stellar.org/docs/learn/encyclopedia/federation)\n * instance and exposes an interface for requests to that instance.\n *\n * @param serverURL - The federation server URL (ex. `https://acme.com/federation`).\n * @param domain - Domain this server represents\n * @param opts - (optional) Options object\n * @returns */\nexport class FederationServer {\n /**\n * The federation server URL (ex. `https://acme.com/federation`).\n */\n private readonly serverURL: URL; // TODO: public or private? readonly?\n\n /**\n * Domain this server represents.\n */\n private readonly domain: string; // TODO: public or private? readonly?\n\n /**\n * Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue.\n */\n private readonly timeout: number; // TODO: public or private? readonly?\n\n /**\n * A helper method for handling user inputs that contain `destination` value.\n * It accepts two types of values:\n *\n * * For Stellar address (ex. `bob*stellar.org`) it splits Stellar address and then tries to find information about\n * federation server in `stellar.toml` file for a given domain. It returns a `Promise` which resolves if federation\n * server exists and user has been found and rejects in all other cases.\n * * For Account ID (ex. `GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS`) it returns a `Promise` which\n * resolves if Account ID is valid and rejects in all other cases. Please note that this method does not check\n * if the account actually exists in a ledger.\n *\n * @example\n * ```ts\n * StellarSdk.FederationServer.resolve('bob*stellar.org')\n * .then(federationRecord => {\n * // {\n * // account_id: 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS',\n * // memo_type: 'id',\n * // memo: 100\n * // }\n * });\n * ```\n *\n * @see <a href=\"https://developers.stellar.org/docs/learn/encyclopedia/federation\" target=\"_blank\">Federation doc</a>\n * @see <a href=\"https://developers.stellar.org/docs/issuing-assets/publishing-asset-info\" target=\"_blank\">Stellar.toml doc</a>\n * @param value - Stellar Address (ex. `bob*stellar.org`)\n * @param opts - (optional) Options object\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the provided account ID is not a valid Ed25519 public key.\n */\n public static async resolve(\n value: string,\n opts: Api.Options = {},\n ): Promise<Api.Record> {\n // Check if `value` is in account ID format\n if (value.indexOf(\"*\") < 0) {\n if (!StrKey.isValidEd25519PublicKey(value)) {\n return Promise.reject(new Error(\"Invalid Account ID\"));\n }\n return Promise.resolve({ account_id: value });\n }\n\n const addressParts = value.split(\"*\");\n const [, domain] = addressParts;\n\n if (addressParts.length !== 2 || !domain) {\n return Promise.reject(new Error(\"Invalid Stellar address\"));\n }\n\n const federationServer = await FederationServer.createForDomain(\n domain,\n opts,\n );\n return federationServer.resolveAddress(value);\n }\n\n /**\n * Creates a `FederationServer` instance based on information from\n * [stellar.toml](https://developers.stellar.org/docs/issuing-assets/publishing-asset-info)\n * file for a given domain.\n *\n * If `stellar.toml` file does not exist for a given domain or it does not\n * contain information about a federation server Promise will reject.\n *\n * @example\n * ```ts\n * StellarSdk.FederationServer.createForDomain('acme.com')\n * .then(federationServer => {\n * // federationServer.resolveAddress('bob').then(...)\n * })\n * .catch(error => {\n * // stellar.toml does not exist or it does not contain information about federation server.\n * });\n * ```\n *\n * @see <a href=\"https://developers.stellar.org/docs/issuing-assets/publishing-asset-info\" target=\"_blank\">Stellar.toml doc</a>\n * @param domain - Domain to get federation server for\n * @param opts - (optional) Options object\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the domain's stellar.toml file does not contain a federation server field.\n */\n public static async createForDomain(\n domain: string,\n opts: Api.Options = {},\n ): Promise<FederationServer> {\n validateDomain(domain);\n const tomlObject = await Resolver.resolve(domain, opts);\n if (!tomlObject.FEDERATION_SERVER) {\n return Promise.reject(\n new Error(\"stellar.toml does not contain FEDERATION_SERVER field\"),\n );\n }\n return new FederationServer(tomlObject.FEDERATION_SERVER, domain, opts);\n }\n\n public constructor(\n serverURL: string,\n domain: string,\n opts: Api.Options = {},\n ) {\n this.serverURL = new URL(serverURL);\n this.domain = domain;\n validateDomain(domain);\n\n const allowHttp =\n typeof opts.allowHttp === \"undefined\"\n ? Config.isAllowHttp()\n : opts.allowHttp;\n\n this.timeout =\n typeof opts.timeout === \"undefined\" ? Config.getTimeout() : opts.timeout;\n\n if (this.serverURL.protocol !== \"https:\" && !allowHttp) {\n throw new Error(\"Cannot connect to insecure federation server\");\n }\n }\n\n /**\n * Get the federation record if the user was found for a given Stellar address\n * @see <a href=\"https://developers.stellar.org/docs/encyclopedia/federation\" target=\"_blank\">Federation doc</a>\n * @param address - Stellar address (ex. `bob*stellar.org`). If `FederationServer` was instantiated with `domain` param only username (ex. `bob`) can be passed.\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the federated address does not contain a domain, or if the server object was not instantiated with a `domain` parameter\n */\n public async resolveAddress(address: string): Promise<Api.Record> {\n let stellarAddress = address;\n if (address.indexOf(\"*\") < 0) {\n if (!this.domain) {\n return Promise.reject(\n new Error(\n \"Unknown domain. Make sure `address` contains a domain (ex. `bob*stellar.org`) or pass `domain` parameter when instantiating the server object.\",\n ),\n );\n }\n stellarAddress = `${address}*${this.domain}`;\n }\n const url = new URL(this.serverURL);\n url.search = \"\";\n url.searchParams.set(\"type\", \"name\");\n url.searchParams.set(\"q\", stellarAddress);\n return this._sendRequest(url);\n }\n\n /**\n * Given an account ID, get their federation record if the user was found\n * @see <a href=\"https://developers.stellar.org/docs/encyclopedia/federation\" target=\"_blank\">Federation doc</a>\n * @param accountId - Account ID (ex. `GBYNR2QJXLBCBTRN44MRORCMI4YO7FZPFBCNOKTOBCAAFC7KC3LNPRYS`)\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the federation server returns an invalid memo value.\n * @throws Will throw an error if the federation server's response exceeds the allowed maximum size.\n * @throws Will throw an error if the server query fails with an improper response.\n */\n public async resolveAccountId(accountId: string): Promise<Api.Record> {\n const url = new URL(this.serverURL);\n url.search = \"\";\n url.searchParams.set(\"type\", \"id\");\n url.searchParams.set(\"q\", accountId);\n return this._sendRequest(url);\n }\n\n /**\n * Given a transactionId, get the federation record if the sender of the transaction was found\n * @see <a href=\"https://developers.stellar.org/docs/glossary/federation/\" target=\"_blank\">Federation doc</a>\n * @param transactionId - Transaction ID (ex. `3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889`)\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the federation server returns an invalid memo value.\n * @throws Will throw an error if the federation server's response exceeds the allowed maximum size.\n * @throws Will throw an error if the server query fails with an improper response.\n */\n public async resolveTransactionId(\n transactionId: string,\n ): Promise<Api.Record> {\n const url = new URL(this.serverURL);\n url.search = \"\";\n url.searchParams.set(\"type\", \"txid\");\n url.searchParams.set(\"q\", transactionId);\n return this._sendRequest(url);\n }\n\n private async _sendRequest(url: URL) {\n const timeout = this.timeout;\n\n return httpClient\n .get(url.toString(), {\n maxContentLength: FEDERATION_RESPONSE_MAX_SIZE,\n timeout,\n })\n .then((response) => {\n if (\n typeof response.data.memo !== \"undefined\" &&\n typeof response.data.memo !== \"string\"\n ) {\n throw new Error(\"memo value should be of type string\");\n }\n return response.data;\n })\n .catch((response) => {\n if (response instanceof Error) {\n if (response.message.match(/^maxContentLength size/)) {\n throw new Error(\n `federation response exceeds allowed size of ${FEDERATION_RESPONSE_MAX_SIZE}`,\n );\n } else {\n return Promise.reject(response);\n }\n } else {\n return Promise.reject(\n new BadResponseError(\n `Server query failed. Server responded: ${response.status} ${response.statusText}`,\n response.data,\n ),\n );\n }\n });\n }\n}\n"],"names":["StrKey","validateDomain","Resolver","Config","httpClient","BadResponseError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAc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AAS;AAAA;AACX,SACF;AAAA,MACF;AAAA,IACF,CAAC,CAAA;AAAA,EACL;AACF;;;;;"}
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../../../src/federation/server.ts"],"sourcesContent":["import { StrKey } from \"../base/index.js\";\n\nimport { Config } from \"../config.js\";\nimport { BadResponseError } from \"../errors/index.js\";\nimport { wrapHttpError } from \"../errors/wrap_http_error.js\";\nimport { Resolver } from \"../stellartoml/index.js\";\n\nimport type { Api } from \"./api.js\";\nimport { httpClient } from \"../http-client/index.js\";\nimport { validateDomain } from \"./utils.js\";\n\n/**\n * The maximum size of response from a federation server\n * @defaultValue 102400\n */\nexport const FEDERATION_RESPONSE_MAX_SIZE: number = 100 * 1024;\n\n/**\n * Federation.Server handles a network connection to a\n * [federation server](https://developers.stellar.org/docs/learn/encyclopedia/federation)\n * instance and exposes an interface for requests to that instance.\n *\n * @param serverURL - The federation server URL (ex. `https://acme.com/federation`).\n * @param domain - Domain this server represents\n * @param opts - (optional) Options object\n * @returns */\nexport class FederationServer {\n /**\n * The federation server URL (ex. `https://acme.com/federation`).\n */\n private readonly serverURL: URL; // TODO: public or private? readonly?\n\n /**\n * Domain this server represents.\n */\n private readonly domain: string; // TODO: public or private? readonly?\n\n /**\n * Allow a timeout, default: 0. Allows user to avoid nasty lag due to TOML resolve issue.\n */\n private readonly timeout: number; // TODO: public or private? readonly?\n\n /**\n * A helper method for handling user inputs that contain `destination` value.\n * It accepts two types of values:\n *\n * * For Stellar address (ex. `bob*stellar.org`) it splits Stellar address and then tries to find information about\n * federation server in `stellar.toml` file for a given domain. It returns a `Promise` which resolves if federation\n * server exists and user has been found and rejects in all other cases.\n * * For Account ID (ex. `GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS`) it returns a `Promise` which\n * resolves if Account ID is valid and rejects in all other cases. Please note that this method does not check\n * if the account actually exists in a ledger.\n *\n * @example\n * ```ts\n * StellarSdk.FederationServer.resolve('bob*stellar.org')\n * .then(federationRecord => {\n * // {\n * // account_id: 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS',\n * // memo_type: 'id',\n * // memo: 100\n * // }\n * });\n * ```\n *\n * @see <a href=\"https://developers.stellar.org/docs/learn/encyclopedia/federation\" target=\"_blank\">Federation doc</a>\n * @see <a href=\"https://developers.stellar.org/docs/issuing-assets/publishing-asset-info\" target=\"_blank\">Stellar.toml doc</a>\n * @param value - Stellar Address (ex. `bob*stellar.org`)\n * @param opts - (optional) Options object\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the provided account ID is not a valid Ed25519 public key.\n */\n public static async resolve(\n value: string,\n opts: Api.Options = {},\n ): Promise<Api.Record> {\n // Check if `value` is in account ID format\n if (value.indexOf(\"*\") < 0) {\n if (!StrKey.isValidEd25519PublicKey(value)) {\n return Promise.reject(new Error(\"Invalid Account ID\"));\n }\n return Promise.resolve({ account_id: value });\n }\n\n const addressParts = value.split(\"*\");\n const [, domain] = addressParts;\n\n if (addressParts.length !== 2 || !domain) {\n return Promise.reject(new Error(\"Invalid Stellar address\"));\n }\n\n const federationServer = await FederationServer.createForDomain(\n domain,\n opts,\n );\n return federationServer.resolveAddress(value);\n }\n\n /**\n * Creates a `FederationServer` instance based on information from\n * [stellar.toml](https://developers.stellar.org/docs/issuing-assets/publishing-asset-info)\n * file for a given domain.\n *\n * If `stellar.toml` file does not exist for a given domain or it does not\n * contain information about a federation server Promise will reject.\n *\n * @example\n * ```ts\n * StellarSdk.FederationServer.createForDomain('acme.com')\n * .then(federationServer => {\n * // federationServer.resolveAddress('bob').then(...)\n * })\n * .catch(error => {\n * // stellar.toml does not exist or it does not contain information about federation server.\n * });\n * ```\n *\n * @see <a href=\"https://developers.stellar.org/docs/issuing-assets/publishing-asset-info\" target=\"_blank\">Stellar.toml doc</a>\n * @param domain - Domain to get federation server for\n * @param opts - (optional) Options object\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the domain's stellar.toml file does not contain a federation server field.\n */\n public static async createForDomain(\n domain: string,\n opts: Api.Options = {},\n ): Promise<FederationServer> {\n validateDomain(domain);\n const tomlObject = await Resolver.resolve(domain, opts);\n if (!tomlObject.FEDERATION_SERVER) {\n return Promise.reject(\n new Error(\"stellar.toml does not contain FEDERATION_SERVER field\"),\n );\n }\n return new FederationServer(tomlObject.FEDERATION_SERVER, domain, opts);\n }\n\n public constructor(\n serverURL: string,\n domain: string,\n opts: Api.Options = {},\n ) {\n this.serverURL = new URL(serverURL);\n this.domain = domain;\n validateDomain(domain);\n\n const allowHttp =\n typeof opts.allowHttp === \"undefined\"\n ? Config.isAllowHttp()\n : opts.allowHttp;\n\n this.timeout =\n typeof opts.timeout === \"undefined\" ? Config.getTimeout() : opts.timeout;\n\n if (this.serverURL.protocol !== \"https:\" && !allowHttp) {\n throw new Error(\"Cannot connect to insecure federation server\");\n }\n }\n\n /**\n * Get the federation record if the user was found for a given Stellar address\n * @see <a href=\"https://developers.stellar.org/docs/encyclopedia/federation\" target=\"_blank\">Federation doc</a>\n * @param address - Stellar address (ex. `bob*stellar.org`). If `FederationServer` was instantiated with `domain` param only username (ex. `bob`) can be passed.\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the federated address does not contain a domain, or if the server object was not instantiated with a `domain` parameter\n */\n public async resolveAddress(address: string): Promise<Api.Record> {\n let stellarAddress = address;\n if (address.indexOf(\"*\") < 0) {\n if (!this.domain) {\n return Promise.reject(\n new Error(\n \"Unknown domain. Make sure `address` contains a domain (ex. `bob*stellar.org`) or pass `domain` parameter when instantiating the server object.\",\n ),\n );\n }\n stellarAddress = `${address}*${this.domain}`;\n }\n const url = new URL(this.serverURL);\n url.search = \"\";\n url.searchParams.set(\"type\", \"name\");\n url.searchParams.set(\"q\", stellarAddress);\n return this._sendRequest(url);\n }\n\n /**\n * Given an account ID, get their federation record if the user was found\n * @see <a href=\"https://developers.stellar.org/docs/encyclopedia/federation\" target=\"_blank\">Federation doc</a>\n * @param accountId - Account ID (ex. `GBYNR2QJXLBCBTRN44MRORCMI4YO7FZPFBCNOKTOBCAAFC7KC3LNPRYS`)\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the federation server returns an invalid memo value.\n * @throws Will throw an error if the federation server's response exceeds the allowed maximum size.\n * @throws Will throw an error if the server query fails with an improper response.\n */\n public async resolveAccountId(accountId: string): Promise<Api.Record> {\n const url = new URL(this.serverURL);\n url.search = \"\";\n url.searchParams.set(\"type\", \"id\");\n url.searchParams.set(\"q\", accountId);\n return this._sendRequest(url);\n }\n\n /**\n * Given a transactionId, get the federation record if the sender of the transaction was found\n * @see <a href=\"https://developers.stellar.org/docs/glossary/federation/\" target=\"_blank\">Federation doc</a>\n * @param transactionId - Transaction ID (ex. `3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889`)\n * @returns A promise that resolves to the federation record\n * @throws Will throw an error if the federation server returns an invalid memo value.\n * @throws Will throw an error if the federation server's response exceeds the allowed maximum size.\n * @throws Will throw an error if the server query fails with an improper response.\n */\n public async resolveTransactionId(\n transactionId: string,\n ): Promise<Api.Record> {\n const url = new URL(this.serverURL);\n url.search = \"\";\n url.searchParams.set(\"type\", \"txid\");\n url.searchParams.set(\"q\", transactionId);\n return this._sendRequest(url);\n }\n\n private async _sendRequest(url: URL) {\n const timeout = this.timeout;\n\n return httpClient\n .get(url.toString(), {\n maxContentLength: FEDERATION_RESPONSE_MAX_SIZE,\n timeout,\n })\n .then((response) => {\n if (\n typeof response.data.memo !== \"undefined\" &&\n typeof response.data.memo !== \"string\"\n ) {\n throw new Error(\"memo value should be of type string\");\n }\n return response.data;\n })\n .catch((error) => {\n if (\n error instanceof Error &&\n error.message.match(/^maxContentLength size/)\n ) {\n throw new Error(\n `federation response exceeds allowed size of ${FEDERATION_RESPONSE_MAX_SIZE}`,\n );\n }\n return Promise.reject(\n wrapHttpError(\n error,\n (details) =>\n new BadResponseError(\n `Server query failed. Server responded: ${details.status} ${details.statusText}`,\n details,\n ),\n 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A,CAAA;AAAA,YAC9E;AAAA;AACF;AACJ,OACF;AAAA,IACF,CAAC,CAAA;AAAA,EACL;AACF;;;;;"}
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/int.js');
|
|
4
|
-
require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/hyper.js');
|
|
5
|
-
require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/unsigned-int.js');
|
|
6
|
-
require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/unsigned-hyper.js');
|
|
7
|
-
require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/xdr-type.js');
|
|
8
|
-
require('buffer');
|
|
9
|
-
require('../base/generated/curr_generated.js');
|
|
10
|
-
require('@noble/hashes/sha2.js');
|
|
11
|
-
require('../base/signing.js');
|
|
12
|
-
require('../base/keypair.js');
|
|
13
|
-
require('base32.js');
|
|
14
|
-
require('../base/util/continued_fraction.js');
|
|
15
|
-
require('../base/util/bignumber.js');
|
|
16
|
-
require('../base/transaction_builder.js');
|
|
17
3
|
var account = require('../base/account.js');
|
|
18
|
-
require('../base/muxed_account.js');
|
|
19
|
-
require('../base/scval.js');
|
|
20
|
-
require('../base/numbers/uint128.js');
|
|
21
|
-
require('../base/numbers/uint256.js');
|
|
22
|
-
require('../base/numbers/int128.js');
|
|
23
|
-
require('../base/numbers/int256.js');
|
|
24
4
|
|
|
25
5
|
class AccountResponse {
|
|
26
6
|
id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_response.js","sources":["../../../src/horizon/account_response.ts"],"sourcesContent":["/* tslint:disable:variable-name */\n\nimport { Account as BaseAccount } from \"../base/index.js\";\nimport type { TransactionBuilder, TransactionSource } from \"../base/index.js\";\nimport { HorizonApi } from \"./horizon_api.js\";\nimport { ServerApi } from \"./server_api.js\";\n\n/**\n * Do not create this object directly, use {@link Horizon.Server.loadAccount | Horizon.Server#loadAccount}.\n *\n * Returns information and links relating to a single account.\n * The balances section in the returned JSON will also list all the trust lines this account has set up.\n * It also contains {@link BaseAccount} object and exposes it's methods so can be used in {@link TransactionBuilder}.\n *\n * @see {@link https://developers.stellar.org/docs/data/horizon/api-reference/resources/accounts/object | Account Details}\n * @param response - Response from horizon account endpoint.\n * @returns AccountResponse instance\n */\nexport class AccountResponse implements TransactionSource {\n public readonly id!: string;\n public readonly paging_token!: string;\n public readonly account_id!: string;\n public sequence!: string;\n public readonly sequence_ledger?: number;\n public readonly sequence_time?: string;\n public readonly subentry_count!: number;\n public readonly home_domain?: string;\n public readonly inflation_destination?: string;\n public readonly last_modified_ledger!: number;\n public readonly last_modified_time!: string;\n public readonly thresholds!: HorizonApi.AccountThresholds;\n public readonly flags!: HorizonApi.Flags;\n public readonly balances!: HorizonApi.BalanceLine[];\n public readonly signers!: ServerApi.AccountRecordSigners[];\n public readonly num_sponsoring!: number;\n public readonly num_sponsored!: number;\n public readonly sponsor?: string;\n public readonly data!: (options: {\n value: string;\n }) => Promise<{ value: string }>;\n public readonly data_attr!: Record<string, string>;\n public readonly effects!: ServerApi.CallCollectionFunction<ServerApi.EffectRecord>;\n public readonly offers!: ServerApi.CallCollectionFunction<ServerApi.OfferRecord>;\n public readonly operations!: ServerApi.CallCollectionFunction<ServerApi.OperationRecord>;\n public readonly payments!: ServerApi.CallCollectionFunction<ServerApi.PaymentOperationRecord>;\n public readonly trades!: ServerApi.CallCollectionFunction<ServerApi.TradeRecord>;\n public readonly transactions!: ServerApi.CallCollectionFunction<ServerApi.TransactionRecord>;\n private readonly _baseAccount: BaseAccount;\n\n constructor(response: ServerApi.AccountRecord) {\n this._baseAccount = new BaseAccount(response.account_id, response.sequence);\n // Extract response fields\n this.effects = response.effects;\n this.offers = response.offers;\n this.operations = response.operations;\n this.payments = response.payments;\n this.trades = response.trades;\n this.data = response.data;\n this.transactions = response.transactions;\n this.id = response.id;\n this.paging_token = response.paging_token;\n this.account_id = response.account_id;\n this.sequence = response.sequence;\n this.sequence_ledger = response.sequence_ledger;\n this.sequence_time = response.sequence_time;\n this.subentry_count = response.subentry_count;\n this.home_domain = response.home_domain;\n this.inflation_destination = response.inflation_destination;\n this.last_modified_ledger = response.last_modified_ledger;\n this.last_modified_time = response.last_modified_time;\n this.thresholds = response.thresholds;\n this.flags = response.flags;\n this.balances = response.balances;\n this.signers = response.signers;\n this.data_attr = response.data_attr;\n this.sponsor = response.sponsor;\n this.num_sponsoring = response.num_sponsoring;\n this.num_sponsored = response.num_sponsored;\n }\n\n /**\n * Get Stellar account public key ex. `GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA`\n * @returns accountId\n */\n public accountId(): string {\n return this._baseAccount.accountId();\n }\n\n /**\n * Get the current sequence number\n * @returns sequenceNumber\n */\n public sequenceNumber(): string {\n return this._baseAccount.sequenceNumber();\n }\n\n /**\n * Increments sequence number in this object by one.\n * @returns */\n public incrementSequenceNumber(): void {\n this._baseAccount.incrementSequenceNumber();\n this.sequence = this._baseAccount.sequenceNumber();\n }\n}\n"],"names":["BaseAccount"],"mappings":"
|
|
1
|
+
{"version":3,"file":"account_response.js","sources":["../../../src/horizon/account_response.ts"],"sourcesContent":["/* tslint:disable:variable-name */\n\nimport { Account as BaseAccount } from \"../base/index.js\";\nimport type { TransactionBuilder, TransactionSource } from \"../base/index.js\";\nimport { HorizonApi } from \"./horizon_api.js\";\nimport { ServerApi } from \"./server_api.js\";\n\n/**\n * Do not create this object directly, use {@link Horizon.Server.loadAccount | Horizon.Server#loadAccount}.\n *\n * Returns information and links relating to a single account.\n * The balances section in the returned JSON will also list all the trust lines this account has set up.\n * It also contains {@link BaseAccount} object and exposes it's methods so can be used in {@link TransactionBuilder}.\n *\n * @see {@link https://developers.stellar.org/docs/data/horizon/api-reference/resources/accounts/object | Account Details}\n * @param response - Response from horizon account endpoint.\n * @returns AccountResponse instance\n */\nexport class AccountResponse implements TransactionSource {\n public readonly id!: string;\n public readonly paging_token!: string;\n public readonly account_id!: string;\n public sequence!: string;\n public readonly sequence_ledger?: number;\n public readonly sequence_time?: string;\n public readonly subentry_count!: number;\n public readonly home_domain?: string;\n public readonly inflation_destination?: string;\n public readonly last_modified_ledger!: number;\n public readonly last_modified_time!: string;\n public readonly thresholds!: HorizonApi.AccountThresholds;\n public readonly flags!: HorizonApi.Flags;\n public readonly balances!: HorizonApi.BalanceLine[];\n public readonly signers!: ServerApi.AccountRecordSigners[];\n public readonly num_sponsoring!: number;\n public readonly num_sponsored!: number;\n public readonly sponsor?: string;\n public readonly data!: (options: {\n value: string;\n }) => Promise<{ value: string }>;\n public readonly data_attr!: Record<string, string>;\n public readonly effects!: ServerApi.CallCollectionFunction<ServerApi.EffectRecord>;\n public readonly offers!: ServerApi.CallCollectionFunction<ServerApi.OfferRecord>;\n public readonly operations!: ServerApi.CallCollectionFunction<ServerApi.OperationRecord>;\n public readonly payments!: ServerApi.CallCollectionFunction<ServerApi.PaymentOperationRecord>;\n public readonly trades!: ServerApi.CallCollectionFunction<ServerApi.TradeRecord>;\n public readonly transactions!: ServerApi.CallCollectionFunction<ServerApi.TransactionRecord>;\n private readonly _baseAccount: BaseAccount;\n\n constructor(response: ServerApi.AccountRecord) {\n this._baseAccount = new BaseAccount(response.account_id, response.sequence);\n // Extract response fields\n this.effects = response.effects;\n this.offers = response.offers;\n this.operations = response.operations;\n this.payments = response.payments;\n this.trades = response.trades;\n this.data = response.data;\n this.transactions = response.transactions;\n this.id = response.id;\n this.paging_token = response.paging_token;\n this.account_id = response.account_id;\n this.sequence = response.sequence;\n this.sequence_ledger = response.sequence_ledger;\n this.sequence_time = response.sequence_time;\n this.subentry_count = response.subentry_count;\n this.home_domain = response.home_domain;\n this.inflation_destination = response.inflation_destination;\n this.last_modified_ledger = response.last_modified_ledger;\n this.last_modified_time = response.last_modified_time;\n this.thresholds = response.thresholds;\n this.flags = response.flags;\n this.balances = response.balances;\n this.signers = response.signers;\n this.data_attr = response.data_attr;\n this.sponsor = response.sponsor;\n this.num_sponsoring = response.num_sponsoring;\n this.num_sponsored = response.num_sponsored;\n }\n\n /**\n * Get Stellar account public key ex. `GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA`\n * @returns accountId\n */\n public accountId(): string {\n return this._baseAccount.accountId();\n }\n\n /**\n * Get the current sequence number\n * @returns sequenceNumber\n */\n public sequenceNumber(): string {\n return this._baseAccount.sequenceNumber();\n }\n\n /**\n * Increments sequence number in this object by one.\n * @returns */\n public incrementSequenceNumber(): void {\n this._baseAccount.incrementSequenceNumber();\n this.sequence = this._baseAccount.sequenceNumber();\n }\n}\n"],"names":["BaseAccount"],"mappings":";;;;AAkBO,MAAM,eAAA,CAA6C;AAAA,EACxC,EAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACT,QAAA;AAAA,EACS,eAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,qBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,UAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA,aAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EAGA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,YAAA;AAAA,EACC,YAAA;AAAA,EAEjB,YAAY,QAAA,EAAmC;AAC7C,IAAA,IAAA,CAAK,eAAe,IAAIA,eAAA,CAAY,QAAA,CAAS,UAAA,EAAY,SAAS,QAAQ,CAAA;AAE1E,IAAA,IAAA,CAAK,UAAU,QAAA,CAAS,OAAA;AACxB,IA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AAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,SAAA,GAAoB;AACzB,IAAA,OAAO,IAAA,CAAK,aAAa,SAAA,EAAU;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,cAAA,GAAyB;AAC9B,IAAA,OAAO,IAAA,CAAK,aAAa,cAAA,EAAe;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKO,uBAAA,GAAgC;AACrC,IAAA,IAAA,CAAK,aAAa,uBAAA,EAAwB;AAC1C,IAAA,IAAA,CAAK,QAAA,GAAW,IAAA,CAAK,YAAA,CAAa,cAAA,EAAe;AAAA,EACnD;AACF;;;;"}
|
|
@@ -79,6 +79,11 @@ exports.HorizonApi = void 0;
|
|
|
79
79
|
TransactionFailedResultCodes2["TX_NO_SOURCE_ACCOUNT"] = "tx_no_source_account";
|
|
80
80
|
TransactionFailedResultCodes2["TX_INSUFFICIENT_FEE"] = "tx_insufficient_fee";
|
|
81
81
|
TransactionFailedResultCodes2["TX_INTERNAL_ERROR"] = "tx_internal_error";
|
|
82
|
+
TransactionFailedResultCodes2["TX_BAD_SPONSORSHIP"] = "tx_bad_sponsorship";
|
|
83
|
+
TransactionFailedResultCodes2["TX_BAD_MIN_SEQ_AGE_OR_GAP"] = "tx_bad_min_seq_age_or_gap";
|
|
84
|
+
TransactionFailedResultCodes2["TX_MALFORMED"] = "tx_malformed";
|
|
85
|
+
TransactionFailedResultCodes2["TX_SOROBAN_INVALID"] = "tx_soroban_invalid";
|
|
86
|
+
TransactionFailedResultCodes2["TX_FROZEN_KEY_ACCESSED"] = "tx_frozen_key_accessed";
|
|
82
87
|
})(HorizonApi2.TransactionFailedResultCodes || (HorizonApi2.TransactionFailedResultCodes = {}));
|
|
83
88
|
})(exports.HorizonApi || (exports.HorizonApi = {}));
|
|
84
89
|
//# sourceMappingURL=horizon_api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizon_api.js","sources":["../../../src/horizon/horizon_api.ts"],"sourcesContent":["import type { AssetType, MemoType } from \"../base/index.js\";\n\n/* tslint:disable-next-line:no-namespace */\nexport namespace HorizonApi {\n export interface ResponseLink {\n href: string;\n templated?: boolean;\n }\n export interface BaseResponse<T extends string = never> {\n _links: { [key in T | \"self\"]: ResponseLink };\n }\n\n export interface SubmitTransactionResponse {\n hash: string;\n ledger: number;\n successful: boolean;\n envelope_xdr: string;\n result_xdr: string;\n result_meta_xdr: string;\n paging_token: string;\n }\n\n export interface SubmitAsyncTransactionResponse {\n hash: string;\n tx_status: string;\n error_result_xdr: string;\n }\n\n export interface FeeBumpTransactionResponse {\n hash: string;\n signatures: string[];\n }\n\n export interface InnerTransactionResponse {\n hash: string;\n signatures: string[];\n max_fee: string;\n }\n\n export interface TransactionPreconditions {\n timebounds?: {\n min_time: string;\n max_time: string;\n };\n ledgerbounds?: {\n min_ledger: number;\n max_ledger: number;\n };\n min_account_sequence?: string;\n min_account_sequence_age?: string;\n min_account_sequence_ledger_gap?: number;\n extra_signers?: string[];\n }\n\n export interface TransactionResponse\n extends\n SubmitTransactionResponse,\n BaseResponse<\n | \"account\"\n | \"ledger\"\n | \"operations\"\n | \"effects\"\n | \"succeeds\"\n | \"precedes\"\n > {\n created_at: string;\n fee_meta_xdr: string;\n fee_charged: number | string;\n max_fee: number | string;\n id: string;\n memo_type: MemoType;\n memo?: string;\n memo_bytes?: string;\n operation_count: number;\n paging_token: string;\n signatures: string[];\n source_account: string;\n source_account_sequence: string;\n fee_account: string;\n inner_transaction?: InnerTransactionResponse;\n fee_bump_transaction?: FeeBumpTransactionResponse;\n preconditions?: TransactionPreconditions;\n }\n\n export interface BalanceLineNative {\n balance: string;\n asset_type: AssetType.native;\n buying_liabilities: string;\n selling_liabilities: string;\n }\n export interface BalanceLineLiquidityPool {\n liquidity_pool_id: string;\n asset_type: AssetType.liquidityPoolShares;\n balance: string;\n limit: string;\n last_modified_ledger: number;\n is_authorized: boolean;\n is_authorized_to_maintain_liabilities: boolean;\n is_clawback_enabled: boolean;\n sponsor?: string;\n }\n export interface BalanceLineAsset<\n T extends AssetType.credit4 | AssetType.credit12 =\n | AssetType.credit4\n | AssetType.credit12,\n > {\n balance: string;\n limit: string;\n asset_type: T;\n asset_code: string;\n asset_issuer: string;\n buying_liabilities: string;\n selling_liabilities: string;\n last_modified_ledger: number;\n is_authorized: boolean;\n is_authorized_to_maintain_liabilities: boolean;\n is_clawback_enabled: boolean;\n sponsor?: string;\n }\n export type BalanceLine<T extends AssetType = AssetType> =\n T extends AssetType.native\n ? BalanceLineNative\n : T extends AssetType.credit4 | AssetType.credit12\n ? BalanceLineAsset<T>\n : T extends AssetType.liquidityPoolShares\n ? BalanceLineLiquidityPool\n : BalanceLineNative | BalanceLineAsset | BalanceLineLiquidityPool;\n\n export interface AssetAccounts {\n authorized: number;\n authorized_to_maintain_liabilities: number;\n unauthorized: number;\n }\n export interface AssetBalances {\n authorized: string;\n authorized_to_maintain_liabilities: string;\n unauthorized: string;\n }\n\n export interface PriceR {\n numerator: number;\n denominator: number;\n }\n\n export interface PriceRShorthand {\n n: number;\n d: number;\n }\n\n export interface AccountThresholds {\n low_threshold: number;\n med_threshold: number;\n high_threshold: number;\n }\n export interface Flags {\n auth_immutable: boolean;\n auth_required: boolean;\n auth_revocable: boolean;\n auth_clawback_enabled: boolean;\n }\n export interface AccountSigner {\n key: string;\n weight: number;\n type: string;\n sponsor?: string;\n }\n export interface AccountResponse extends BaseResponse<\n | \"transactions\"\n | \"operations\"\n | \"payments\"\n | \"effects\"\n | \"offers\"\n | \"trades\"\n | \"data\"\n > {\n id: string;\n paging_token: string;\n account_id: string;\n sequence: string;\n sequence_ledger?: number;\n sequence_time?: string;\n subentry_count: number;\n thresholds: AccountThresholds;\n last_modified_ledger: number;\n last_modified_time: string;\n flags: Flags;\n balances: BalanceLine[];\n signers: AccountSigner[];\n data: {\n [key: string]: string;\n };\n sponsor?: string;\n num_sponsoring: number;\n num_sponsored: number;\n }\n\n export enum LiquidityPoolType {\n constantProduct = \"constant_product\",\n }\n\n export enum OperationResponseType {\n createAccount = \"create_account\",\n payment = \"payment\",\n pathPayment = \"path_payment_strict_receive\",\n createPassiveOffer = \"create_passive_sell_offer\",\n manageOffer = \"manage_sell_offer\",\n setOptions = \"set_options\",\n changeTrust = \"change_trust\",\n allowTrust = \"allow_trust\",\n accountMerge = \"account_merge\",\n inflation = \"inflation\",\n manageData = \"manage_data\",\n bumpSequence = \"bump_sequence\",\n manageBuyOffer = \"manage_buy_offer\",\n pathPaymentStrictSend = \"path_payment_strict_send\",\n createClaimableBalance = \"create_claimable_balance\",\n claimClaimableBalance = \"claim_claimable_balance\",\n beginSponsoringFutureReserves = \"begin_sponsoring_future_reserves\",\n endSponsoringFutureReserves = \"end_sponsoring_future_reserves\",\n revokeSponsorship = \"revoke_sponsorship\",\n clawback = \"clawback\",\n clawbackClaimableBalance = \"clawback_claimable_balance\",\n setTrustLineFlags = \"set_trust_line_flags\",\n liquidityPoolDeposit = \"liquidity_pool_deposit\",\n liquidityPoolWithdraw = \"liquidity_pool_withdraw\",\n invokeHostFunction = \"invoke_host_function\",\n bumpFootprintExpiration = \"bump_footprint_expiration\",\n restoreFootprint = \"restore_footprint\",\n }\n export enum OperationResponseTypeI {\n createAccount = 0,\n payment = 1,\n pathPayment = 2,\n createPassiveOffer = 3,\n manageOffer = 4,\n setOptions = 5,\n changeTrust = 6,\n allowTrust = 7,\n accountMerge = 8,\n inflation = 9,\n manageData = 10,\n bumpSequence = 11,\n manageBuyOffer = 12,\n pathPaymentStrictSend = 13,\n createClaimableBalance = 14,\n claimClaimableBalance = 15,\n beginSponsoringFutureReserves = 16,\n endSponsoringFutureReserves = 17,\n revokeSponsorship = 18,\n clawback = 19,\n clawbackClaimableBalance = 20,\n setTrustLineFlags = 21,\n liquidityPoolDeposit = 22,\n liquidityPoolWithdraw = 23,\n invokeHostFunction = 24,\n bumpFootprintExpiration = 25,\n restoreFootprint = 26,\n }\n export interface BaseOperationResponse<\n T extends OperationResponseType = OperationResponseType,\n TI extends OperationResponseTypeI = OperationResponseTypeI,\n > extends BaseResponse<\"succeeds\" | \"precedes\" | \"effects\" | \"transaction\"> {\n id: string;\n paging_token: string;\n source_account: string;\n type: T;\n type_i: TI;\n created_at: string;\n transaction_hash: string;\n transaction_successful: boolean;\n }\n export interface CreateAccountOperationResponse extends BaseOperationResponse<\n OperationResponseType.createAccount,\n OperationResponseTypeI.createAccount\n > {\n account: string;\n funder: string;\n starting_balance: string;\n }\n export interface PaymentOperationResponse extends BaseOperationResponse<\n OperationResponseType.payment,\n OperationResponseTypeI.payment\n > {\n from: string;\n to: string;\n asset_type: AssetType;\n asset_code?: string;\n asset_issuer?: string;\n amount: string;\n to_muxed?: string;\n to_muxed_id?: string;\n }\n export interface PathPaymentOperationResponse extends BaseOperationResponse<\n OperationResponseType.pathPayment,\n OperationResponseTypeI.pathPayment\n > {\n amount: string;\n asset_code?: string;\n asset_issuer?: string;\n asset_type: AssetType;\n from: string;\n path: Array<{\n asset_code: string;\n asset_issuer: string;\n asset_type: AssetType;\n }>;\n source_amount: string;\n source_asset_code?: string;\n source_asset_issuer?: string;\n source_asset_type: AssetType;\n source_max: string;\n to: string;\n }\n export interface PathPaymentStrictSendOperationResponse extends BaseOperationResponse<\n OperationResponseType.pathPaymentStrictSend,\n OperationResponseTypeI.pathPaymentStrictSend\n > {\n amount: string;\n asset_code?: string;\n asset_issuer?: string;\n asset_type: AssetType;\n destination_min: string;\n from: string;\n path: Array<{\n asset_code: string;\n asset_issuer: string;\n asset_type: AssetType;\n }>;\n source_amount: string;\n source_asset_code?: string;\n source_asset_issuer?: string;\n source_asset_type: AssetType;\n to: string;\n }\n export interface ManageOfferOperationResponse extends BaseOperationResponse<\n OperationResponseType.manageOffer,\n OperationResponseTypeI.manageOffer\n > {\n offer_id: number | string;\n amount: string;\n buying_asset_type: AssetType;\n buying_asset_code?: string;\n buying_asset_issuer?: string;\n price: string;\n price_r: PriceR;\n selling_asset_type: AssetType;\n selling_asset_code?: string;\n selling_asset_issuer?: string;\n }\n export interface PassiveOfferOperationResponse extends BaseOperationResponse<\n OperationResponseType.createPassiveOffer,\n OperationResponseTypeI.createPassiveOffer\n > {\n offer_id: number | string;\n amount: string;\n buying_asset_type: AssetType;\n buying_asset_code?: string;\n buying_asset_issuer?: string;\n price: string;\n price_r: PriceR;\n selling_asset_type: AssetType;\n selling_asset_code?: string;\n selling_asset_issuer?: string;\n }\n export interface SetOptionsOperationResponse extends BaseOperationResponse<\n OperationResponseType.setOptions,\n OperationResponseTypeI.setOptions\n > {\n signer_key?: string;\n signer_weight?: number;\n master_key_weight?: number;\n low_threshold?: number;\n med_threshold?: number;\n high_threshold?: number;\n home_domain?: string;\n set_flags: Array<1 | 2 | 4>;\n set_flags_s: Array<\n | \"auth_required_flag\"\n | \"auth_revocable_flag\"\n | \"auth_clawback_enabled_flag\"\n >;\n clear_flags: Array<1 | 2 | 4>;\n clear_flags_s: Array<\n | \"auth_required_flag\"\n | \"auth_revocable_flag\"\n | \"auth_clawback_enabled_flag\"\n >;\n }\n export interface ChangeTrustOperationResponse extends BaseOperationResponse<\n OperationResponseType.changeTrust,\n OperationResponseTypeI.changeTrust\n > {\n asset_type:\n | AssetType.credit4\n | AssetType.credit12\n | AssetType.liquidityPoolShares;\n asset_code?: string;\n asset_issuer?: string;\n liquidity_pool_id?: string;\n trustee?: string;\n trustor: string;\n limit: string;\n }\n export interface AllowTrustOperationResponse extends BaseOperationResponse<\n OperationResponseType.allowTrust,\n OperationResponseTypeI.allowTrust\n > {\n asset_type: AssetType;\n asset_code: string;\n asset_issuer: string;\n authorize: boolean;\n authorize_to_maintain_liabilities: boolean;\n trustee: string;\n trustor: string;\n }\n export interface AccountMergeOperationResponse extends BaseOperationResponse<\n OperationResponseType.accountMerge,\n OperationResponseTypeI.accountMerge\n > {\n into: string;\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty interface names a public API response type\n export interface InflationOperationResponse extends BaseOperationResponse<\n OperationResponseType.inflation,\n OperationResponseTypeI.inflation\n > {}\n export interface ManageDataOperationResponse extends BaseOperationResponse<\n OperationResponseType.manageData,\n OperationResponseTypeI.manageData\n > {\n name: string;\n value: Buffer;\n }\n export interface BumpSequenceOperationResponse extends BaseOperationResponse<\n OperationResponseType.bumpSequence,\n OperationResponseTypeI.bumpSequence\n > {\n bump_to: string;\n }\n export interface Predicate {\n and?: Predicate[];\n or?: Predicate[];\n not?: Predicate;\n abs_before?: string;\n rel_before?: string;\n }\n\n export interface Claimant {\n destination: string;\n predicate: Predicate;\n }\n\n export interface CreateClaimableBalanceOperationResponse extends BaseOperationResponse<\n OperationResponseType.createClaimableBalance,\n OperationResponseTypeI.createClaimableBalance\n > {\n asset: string;\n amount: string;\n sponsor: string;\n claimants: Claimant[];\n }\n\n export interface ClaimClaimableBalanceOperationResponse extends BaseOperationResponse<\n OperationResponseType.claimClaimableBalance,\n OperationResponseTypeI.claimClaimableBalance\n > {\n balance_id: string;\n claimant: string;\n }\n\n export interface BeginSponsoringFutureReservesOperationResponse extends BaseOperationResponse<\n OperationResponseType.beginSponsoringFutureReserves,\n OperationResponseTypeI.beginSponsoringFutureReserves\n > {\n sponsored_id: string;\n }\n\n export interface EndSponsoringFutureReservesOperationResponse extends BaseOperationResponse<\n OperationResponseType.endSponsoringFutureReserves,\n OperationResponseTypeI.endSponsoringFutureReserves\n > {\n begin_sponsor: string;\n }\n\n export interface RevokeSponsorshipOperationResponse extends BaseOperationResponse<\n OperationResponseType.revokeSponsorship,\n OperationResponseTypeI.revokeSponsorship\n > {\n account_id?: string;\n claimable_balance_id?: string;\n data_account_id?: string;\n data_name?: string;\n offer_id?: string;\n trustline_account_id?: string;\n trustline_asset?: string;\n trustline_liquidity_pool_id?: string;\n signer_account_id?: string;\n signer_key?: string;\n }\n\n export interface ClawbackOperationResponse extends BaseOperationResponse<\n OperationResponseType.clawback,\n OperationResponseTypeI.clawback\n > {\n asset_type: AssetType;\n asset_code: string;\n asset_issuer: string;\n from: string;\n amount: string;\n }\n\n export interface ClawbackClaimableBalanceOperationResponse extends BaseOperationResponse<\n OperationResponseType.clawbackClaimableBalance,\n OperationResponseTypeI.clawbackClaimableBalance\n > {\n balance_id: string;\n }\n\n export interface SetTrustLineFlagsOperationResponse extends BaseOperationResponse<\n OperationResponseType.setTrustLineFlags,\n OperationResponseTypeI.setTrustLineFlags\n > {\n asset_type: AssetType;\n asset_code: string;\n asset_issuer: string;\n trustor: string;\n set_flags: Array<1 | 2 | 4>;\n clear_flags: Array<1 | 2 | 4>;\n }\n export interface Reserve {\n asset: string;\n amount: string;\n }\n export interface DepositLiquidityOperationResponse extends BaseOperationResponse<\n OperationResponseType.liquidityPoolDeposit,\n OperationResponseTypeI.liquidityPoolDeposit\n > {\n liquidity_pool_id: string;\n reserves_max: Reserve[];\n min_price: string;\n min_price_r: PriceRShorthand;\n max_price: string;\n max_price_r: PriceRShorthand;\n reserves_deposited: Reserve[];\n shares_received: string;\n }\n export interface WithdrawLiquidityOperationResponse extends BaseOperationResponse<\n OperationResponseType.liquidityPoolWithdraw,\n OperationResponseTypeI.liquidityPoolWithdraw\n > {\n liquidity_pool_id: string;\n reserves_min: Reserve[];\n shares: string;\n reserves_received: Reserve[];\n }\n\n export interface BalanceChange {\n asset_type: string;\n asset_code?: string;\n asset_issuer?: string;\n\n type: string;\n from: string;\n to: string;\n amount: string;\n destination_muxed_id?: string;\n }\n\n export interface InvokeHostFunctionOperationResponse extends BaseOperationResponse<\n OperationResponseType.invokeHostFunction,\n OperationResponseTypeI.invokeHostFunction\n > {\n function: string;\n parameters: {\n value: string;\n type: string;\n }[];\n address: string;\n salt: string;\n asset_balance_changes: BalanceChange[];\n }\n\n export interface BumpFootprintExpirationOperationResponse extends BaseOperationResponse<\n OperationResponseType.bumpFootprintExpiration,\n OperationResponseTypeI.bumpFootprintExpiration\n > {\n ledgers_to_expire: number;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty interface names a public API response type\n export interface RestoreFootprintOperationResponse extends BaseOperationResponse<\n OperationResponseType.restoreFootprint,\n OperationResponseTypeI.restoreFootprint\n > {}\n\n export interface ResponseCollection<T extends BaseResponse = BaseResponse> {\n _links: {\n self: ResponseLink;\n next: ResponseLink;\n prev: ResponseLink;\n };\n _embedded: {\n records: T[];\n };\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty interface names a public API response type\n export interface TransactionResponseCollection extends ResponseCollection<TransactionResponse> {}\n\n export interface FeeDistribution {\n max: string;\n min: string;\n mode: string;\n p10: string;\n p20: string;\n p30: string;\n p40: string;\n p50: string;\n p60: string;\n p70: string;\n p80: string;\n p90: string;\n p95: string;\n p99: string;\n }\n export interface FeeStatsResponse {\n last_ledger: string;\n last_ledger_base_fee: string;\n ledger_capacity_usage: string;\n fee_charged: FeeDistribution;\n max_fee: FeeDistribution;\n }\n\n export type ErrorResponseData =\n | ErrorResponseData.RateLimitExceeded\n | ErrorResponseData.InternalServerError\n | ErrorResponseData.TransactionFailed;\n\n export namespace ErrorResponseData {\n export interface Base {\n status: number;\n title: string;\n type: string; // TODO\n details: string; // TODO\n instance: string; // TODO\n }\n\n export interface RateLimitExceeded extends Base {\n status: 429;\n title: \"Rate Limit Exceeded\";\n }\n export interface InternalServerError extends Base {\n status: 500;\n title: \"Internal Server Error\";\n }\n export interface TransactionFailed extends Base {\n status: 400;\n title: \"Transaction Failed\";\n extras: TransactionFailedExtras;\n }\n }\n\n export enum TransactionFailedResultCodes {\n TX_FAILED = \"tx_failed\",\n TX_BAD_SEQ = \"tx_bad_seq\",\n TX_BAD_AUTH = \"tx_bad_auth\",\n TX_BAD_AUTH_EXTRA = \"tx_bad_auth_extra\",\n TX_FEE_BUMP_INNER_SUCCESS = \"tx_fee_bump_inner_success\",\n TX_FEE_BUMP_INNER_FAILED = \"tx_fee_bump_inner_failed\",\n TX_NOT_SUPPORTED = \"tx_not_supported\",\n TX_SUCCESS = \"tx_success\",\n TX_TOO_EARLY = \"tx_too_early\",\n TX_TOO_LATE = \"tx_too_late\",\n TX_MISSING_OPERATION = \"tx_missing_operation\",\n TX_INSUFFICIENT_BALANCE = \"tx_insufficient_balance\",\n TX_NO_SOURCE_ACCOUNT = \"tx_no_source_account\",\n TX_INSUFFICIENT_FEE = \"tx_insufficient_fee\",\n TX_INTERNAL_ERROR = \"tx_internal_error\",\n }\n\n export interface TransactionFailedExtras {\n envelope_xdr: string; // base64\n result_codes: {\n transaction: TransactionFailedResultCodes;\n operations: string[];\n };\n result_xdr: string;\n }\n\n export interface RootResponse {\n horizon_version: string;\n core_version: string;\n ingest_latest_ledger: number;\n history_latest_ledger: number;\n history_latest_ledger_closed_at: string;\n history_elder_ledger: number;\n core_latest_ledger: number;\n network_passphrase: string;\n current_protocol_version: number;\n supported_protocol_version: number;\n core_supported_protocol_version: number;\n }\n}\n"],"names":["HorizonApi","LiquidityPoolType","OperationResponseType","OperationResponseTypeI","TransactionFailedResultCodes"],"mappings":";;AAGiBA;AAAA,CAAV,CAAUA,WAAAA,KAAV;AAiME,EAAA,CAAA,CAAKC,kBAAAA,KAAL;AACL,IAAAA,mBAAA,iBAAA,CAAA,GAAkB,kBAAA;AAAA,EAAA,CAAA,EADRD,WAAAA,CAAA,iBAAA,KAAAA,WAAAA,CAAA,iBAAA,GAAA,EAAA,CAAA,CAAA;AAIL,EAAA,CAAA,CAAKE,sBAAAA,KAAL;AACL,IAAAA,uBAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,IAAAA,uBAAA,SAAA,CAAA,GAAU,SAAA;AACV,IAAAA,uBAAA,aAAA,CAAA,GAAc,6BAAA;AACd,IAAAA,uBAAA,oBAAA,CAAA,GAAqB,2BAAA;AACrB,IAAAA,uBAAA,aAAA,CAAA,GAAc,mBAAA;AACd,IAAAA,uBAAA,YAAA,CAAA,GAAa,aAAA;AACb,IAAAA,uBAAA,aAAA,CAAA,GAAc,cAAA;AACd,IAAAA,uBAAA,YAAA,CAAA,GAAa,aAAA;AACb,IAAAA,uBAAA,cAAA,CAAA,GAA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AA,CAAA,GAA0B,yBAAA;AAC1B,IAAAA,8BAAA,sBAAA,CAAA,GAAuB,sBAAA;AACvB,IAAAA,8BAAA,qBAAA,CAAA,GAAsB,qBAAA;AACtB,IAAAA,8BAAA,mBAAA,CAAA,GAAoB,mBAAA;AAAA,EAAA,CAAA,EAfVJ,WAAAA,CAAA,4BAAA,KAAAA,WAAAA,CAAA,4BAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EAlpBGA,kBAAA,KAAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;"}
|
|
1
|
+
{"version":3,"file":"horizon_api.js","sources":["../../../src/horizon/horizon_api.ts"],"sourcesContent":["import type { AssetType, MemoType } from \"../base/index.js\";\n\n/* tslint:disable-next-line:no-namespace */\nexport namespace HorizonApi {\n export interface ResponseLink {\n href: string;\n templated?: boolean;\n }\n export interface BaseResponse<T extends string = never> {\n _links: { [key in T | \"self\"]: ResponseLink };\n }\n\n export interface SubmitTransactionResponse {\n hash: string;\n ledger: number;\n successful: boolean;\n envelope_xdr: string;\n result_xdr: string;\n result_meta_xdr: string;\n paging_token: string;\n }\n\n export interface SubmitAsyncTransactionResponse {\n hash: string;\n tx_status: string;\n error_result_xdr: string;\n }\n\n export interface FeeBumpTransactionResponse {\n hash: string;\n signatures: string[];\n }\n\n export interface InnerTransactionResponse {\n hash: string;\n signatures: string[];\n max_fee: string;\n }\n\n export interface TransactionPreconditions {\n timebounds?: {\n min_time: string;\n max_time: string;\n };\n ledgerbounds?: {\n min_ledger: number;\n max_ledger: number;\n };\n min_account_sequence?: string;\n min_account_sequence_age?: string;\n min_account_sequence_ledger_gap?: number;\n extra_signers?: string[];\n }\n\n export interface TransactionResponse\n extends\n SubmitTransactionResponse,\n BaseResponse<\n | \"account\"\n | \"ledger\"\n | \"operations\"\n | \"effects\"\n | \"succeeds\"\n | \"precedes\"\n > {\n created_at: string;\n fee_meta_xdr: string;\n fee_charged: number | string;\n max_fee: number | string;\n id: string;\n memo_type: MemoType;\n memo?: string;\n memo_bytes?: string;\n operation_count: number;\n paging_token: string;\n signatures: string[];\n source_account: string;\n source_account_sequence: string;\n fee_account: string;\n inner_transaction?: InnerTransactionResponse;\n fee_bump_transaction?: FeeBumpTransactionResponse;\n preconditions?: TransactionPreconditions;\n }\n\n export interface BalanceLineNative {\n balance: string;\n asset_type: AssetType.native;\n buying_liabilities: string;\n selling_liabilities: string;\n }\n export interface BalanceLineLiquidityPool {\n liquidity_pool_id: string;\n asset_type: AssetType.liquidityPoolShares;\n balance: string;\n limit: string;\n last_modified_ledger: number;\n is_authorized: boolean;\n is_authorized_to_maintain_liabilities: boolean;\n is_clawback_enabled: boolean;\n sponsor?: string;\n }\n export interface BalanceLineAsset<\n T extends AssetType.credit4 | AssetType.credit12 =\n | AssetType.credit4\n | AssetType.credit12,\n > {\n balance: string;\n limit: string;\n asset_type: T;\n asset_code: string;\n asset_issuer: string;\n buying_liabilities: string;\n selling_liabilities: string;\n last_modified_ledger: number;\n is_authorized: boolean;\n is_authorized_to_maintain_liabilities: boolean;\n is_clawback_enabled: boolean;\n sponsor?: string;\n }\n export type BalanceLine<T extends AssetType = AssetType> =\n T extends AssetType.native\n ? BalanceLineNative\n : T extends AssetType.credit4 | AssetType.credit12\n ? BalanceLineAsset<T>\n : T extends AssetType.liquidityPoolShares\n ? BalanceLineLiquidityPool\n : BalanceLineNative | BalanceLineAsset | BalanceLineLiquidityPool;\n\n export interface AssetAccounts {\n authorized: number;\n authorized_to_maintain_liabilities: number;\n unauthorized: number;\n }\n export interface AssetBalances {\n authorized: string;\n authorized_to_maintain_liabilities: string;\n unauthorized: string;\n }\n\n export interface PriceR {\n numerator: number;\n denominator: number;\n }\n\n export interface PriceRShorthand {\n n: number;\n d: number;\n }\n\n export interface AccountThresholds {\n low_threshold: number;\n med_threshold: number;\n high_threshold: number;\n }\n export interface Flags {\n auth_immutable: boolean;\n auth_required: boolean;\n auth_revocable: boolean;\n auth_clawback_enabled: boolean;\n }\n export interface AccountSigner {\n key: string;\n weight: number;\n type: string;\n sponsor?: string;\n }\n export interface AccountResponse extends BaseResponse<\n | \"transactions\"\n | \"operations\"\n | \"payments\"\n | \"effects\"\n | \"offers\"\n | \"trades\"\n | \"data\"\n > {\n id: string;\n paging_token: string;\n account_id: string;\n sequence: string;\n sequence_ledger?: number;\n sequence_time?: string;\n subentry_count: number;\n thresholds: AccountThresholds;\n last_modified_ledger: number;\n last_modified_time: string;\n flags: Flags;\n balances: BalanceLine[];\n signers: AccountSigner[];\n data: {\n [key: string]: string;\n };\n sponsor?: string;\n num_sponsoring: number;\n num_sponsored: number;\n }\n\n export enum LiquidityPoolType {\n constantProduct = \"constant_product\",\n }\n\n export enum OperationResponseType {\n createAccount = \"create_account\",\n payment = \"payment\",\n pathPayment = \"path_payment_strict_receive\",\n createPassiveOffer = \"create_passive_sell_offer\",\n manageOffer = \"manage_sell_offer\",\n setOptions = \"set_options\",\n changeTrust = \"change_trust\",\n allowTrust = \"allow_trust\",\n accountMerge = \"account_merge\",\n inflation = \"inflation\",\n manageData = \"manage_data\",\n bumpSequence = \"bump_sequence\",\n manageBuyOffer = \"manage_buy_offer\",\n pathPaymentStrictSend = \"path_payment_strict_send\",\n createClaimableBalance = \"create_claimable_balance\",\n claimClaimableBalance = \"claim_claimable_balance\",\n beginSponsoringFutureReserves = \"begin_sponsoring_future_reserves\",\n endSponsoringFutureReserves = \"end_sponsoring_future_reserves\",\n revokeSponsorship = \"revoke_sponsorship\",\n clawback = \"clawback\",\n clawbackClaimableBalance = \"clawback_claimable_balance\",\n setTrustLineFlags = \"set_trust_line_flags\",\n liquidityPoolDeposit = \"liquidity_pool_deposit\",\n liquidityPoolWithdraw = \"liquidity_pool_withdraw\",\n invokeHostFunction = \"invoke_host_function\",\n bumpFootprintExpiration = \"bump_footprint_expiration\",\n restoreFootprint = \"restore_footprint\",\n }\n export enum OperationResponseTypeI {\n createAccount = 0,\n payment = 1,\n pathPayment = 2,\n createPassiveOffer = 3,\n manageOffer = 4,\n setOptions = 5,\n changeTrust = 6,\n allowTrust = 7,\n accountMerge = 8,\n inflation = 9,\n manageData = 10,\n bumpSequence = 11,\n manageBuyOffer = 12,\n pathPaymentStrictSend = 13,\n createClaimableBalance = 14,\n claimClaimableBalance = 15,\n beginSponsoringFutureReserves = 16,\n endSponsoringFutureReserves = 17,\n revokeSponsorship = 18,\n clawback = 19,\n clawbackClaimableBalance = 20,\n setTrustLineFlags = 21,\n liquidityPoolDeposit = 22,\n liquidityPoolWithdraw = 23,\n invokeHostFunction = 24,\n bumpFootprintExpiration = 25,\n restoreFootprint = 26,\n }\n export interface BaseOperationResponse<\n T extends OperationResponseType = OperationResponseType,\n TI extends OperationResponseTypeI = OperationResponseTypeI,\n > extends BaseResponse<\"succeeds\" | \"precedes\" | \"effects\" | \"transaction\"> {\n id: string;\n paging_token: string;\n source_account: string;\n type: T;\n type_i: TI;\n created_at: string;\n transaction_hash: string;\n transaction_successful: boolean;\n }\n export interface CreateAccountOperationResponse extends BaseOperationResponse<\n OperationResponseType.createAccount,\n OperationResponseTypeI.createAccount\n > {\n account: string;\n funder: string;\n starting_balance: string;\n }\n export interface PaymentOperationResponse extends BaseOperationResponse<\n OperationResponseType.payment,\n OperationResponseTypeI.payment\n > {\n from: string;\n to: string;\n asset_type: AssetType;\n asset_code?: string;\n asset_issuer?: string;\n amount: string;\n to_muxed?: string;\n to_muxed_id?: string;\n }\n export interface PathPaymentOperationResponse extends BaseOperationResponse<\n OperationResponseType.pathPayment,\n OperationResponseTypeI.pathPayment\n > {\n amount: string;\n asset_code?: string;\n asset_issuer?: string;\n asset_type: AssetType;\n from: string;\n path: Array<{\n asset_code: string;\n asset_issuer: string;\n asset_type: AssetType;\n }>;\n source_amount: string;\n source_asset_code?: string;\n source_asset_issuer?: string;\n source_asset_type: AssetType;\n source_max: string;\n to: string;\n }\n export interface PathPaymentStrictSendOperationResponse extends BaseOperationResponse<\n OperationResponseType.pathPaymentStrictSend,\n OperationResponseTypeI.pathPaymentStrictSend\n > {\n amount: string;\n asset_code?: string;\n asset_issuer?: string;\n asset_type: AssetType;\n destination_min: string;\n from: string;\n path: Array<{\n asset_code: string;\n asset_issuer: string;\n asset_type: AssetType;\n }>;\n source_amount: string;\n source_asset_code?: string;\n source_asset_issuer?: string;\n source_asset_type: AssetType;\n to: string;\n }\n export interface ManageOfferOperationResponse extends BaseOperationResponse<\n OperationResponseType.manageOffer,\n OperationResponseTypeI.manageOffer\n > {\n offer_id: number | string;\n amount: string;\n buying_asset_type: AssetType;\n buying_asset_code?: string;\n buying_asset_issuer?: string;\n price: string;\n price_r: PriceR;\n selling_asset_type: AssetType;\n selling_asset_code?: string;\n selling_asset_issuer?: string;\n }\n export interface PassiveOfferOperationResponse extends BaseOperationResponse<\n OperationResponseType.createPassiveOffer,\n OperationResponseTypeI.createPassiveOffer\n > {\n offer_id: number | string;\n amount: string;\n buying_asset_type: AssetType;\n buying_asset_code?: string;\n buying_asset_issuer?: string;\n price: string;\n price_r: PriceR;\n selling_asset_type: AssetType;\n selling_asset_code?: string;\n selling_asset_issuer?: string;\n }\n export interface SetOptionsOperationResponse extends BaseOperationResponse<\n OperationResponseType.setOptions,\n OperationResponseTypeI.setOptions\n > {\n signer_key?: string;\n signer_weight?: number;\n master_key_weight?: number;\n low_threshold?: number;\n med_threshold?: number;\n high_threshold?: number;\n home_domain?: string;\n set_flags: Array<1 | 2 | 4>;\n set_flags_s: Array<\n | \"auth_required_flag\"\n | \"auth_revocable_flag\"\n | \"auth_clawback_enabled_flag\"\n >;\n clear_flags: Array<1 | 2 | 4>;\n clear_flags_s: Array<\n | \"auth_required_flag\"\n | \"auth_revocable_flag\"\n | \"auth_clawback_enabled_flag\"\n >;\n }\n export interface ChangeTrustOperationResponse extends BaseOperationResponse<\n OperationResponseType.changeTrust,\n OperationResponseTypeI.changeTrust\n > {\n asset_type:\n | AssetType.credit4\n | AssetType.credit12\n | AssetType.liquidityPoolShares;\n asset_code?: string;\n asset_issuer?: string;\n liquidity_pool_id?: string;\n trustee?: string;\n trustor: string;\n limit: string;\n }\n export interface AllowTrustOperationResponse extends BaseOperationResponse<\n OperationResponseType.allowTrust,\n OperationResponseTypeI.allowTrust\n > {\n asset_type: AssetType;\n asset_code: string;\n asset_issuer: string;\n authorize: boolean;\n authorize_to_maintain_liabilities: boolean;\n trustee: string;\n trustor: string;\n }\n export interface AccountMergeOperationResponse extends BaseOperationResponse<\n OperationResponseType.accountMerge,\n OperationResponseTypeI.accountMerge\n > {\n into: string;\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty interface names a public API response type\n export interface InflationOperationResponse extends BaseOperationResponse<\n OperationResponseType.inflation,\n OperationResponseTypeI.inflation\n > {}\n export interface ManageDataOperationResponse extends BaseOperationResponse<\n OperationResponseType.manageData,\n OperationResponseTypeI.manageData\n > {\n name: string;\n value: Buffer;\n }\n export interface BumpSequenceOperationResponse extends BaseOperationResponse<\n OperationResponseType.bumpSequence,\n OperationResponseTypeI.bumpSequence\n > {\n bump_to: string;\n }\n export interface Predicate {\n and?: Predicate[];\n or?: Predicate[];\n not?: Predicate;\n abs_before?: string;\n rel_before?: string;\n }\n\n export interface Claimant {\n destination: string;\n predicate: Predicate;\n }\n\n export interface CreateClaimableBalanceOperationResponse extends BaseOperationResponse<\n OperationResponseType.createClaimableBalance,\n OperationResponseTypeI.createClaimableBalance\n > {\n asset: string;\n amount: string;\n sponsor: string;\n claimants: Claimant[];\n }\n\n export interface ClaimClaimableBalanceOperationResponse extends BaseOperationResponse<\n OperationResponseType.claimClaimableBalance,\n OperationResponseTypeI.claimClaimableBalance\n > {\n balance_id: string;\n claimant: string;\n }\n\n export interface BeginSponsoringFutureReservesOperationResponse extends BaseOperationResponse<\n OperationResponseType.beginSponsoringFutureReserves,\n OperationResponseTypeI.beginSponsoringFutureReserves\n > {\n sponsored_id: string;\n }\n\n export interface EndSponsoringFutureReservesOperationResponse extends BaseOperationResponse<\n OperationResponseType.endSponsoringFutureReserves,\n OperationResponseTypeI.endSponsoringFutureReserves\n > {\n begin_sponsor: string;\n }\n\n export interface RevokeSponsorshipOperationResponse extends BaseOperationResponse<\n OperationResponseType.revokeSponsorship,\n OperationResponseTypeI.revokeSponsorship\n > {\n account_id?: string;\n claimable_balance_id?: string;\n data_account_id?: string;\n data_name?: string;\n offer_id?: string;\n trustline_account_id?: string;\n trustline_asset?: string;\n trustline_liquidity_pool_id?: string;\n signer_account_id?: string;\n signer_key?: string;\n }\n\n export interface ClawbackOperationResponse extends BaseOperationResponse<\n OperationResponseType.clawback,\n OperationResponseTypeI.clawback\n > {\n asset_type: AssetType;\n asset_code: string;\n asset_issuer: string;\n from: string;\n amount: string;\n }\n\n export interface ClawbackClaimableBalanceOperationResponse extends BaseOperationResponse<\n OperationResponseType.clawbackClaimableBalance,\n OperationResponseTypeI.clawbackClaimableBalance\n > {\n balance_id: string;\n }\n\n export interface SetTrustLineFlagsOperationResponse extends BaseOperationResponse<\n OperationResponseType.setTrustLineFlags,\n OperationResponseTypeI.setTrustLineFlags\n > {\n asset_type: AssetType;\n asset_code: string;\n asset_issuer: string;\n trustor: string;\n set_flags: Array<1 | 2 | 4>;\n clear_flags: Array<1 | 2 | 4>;\n }\n export interface Reserve {\n asset: string;\n amount: string;\n }\n export interface DepositLiquidityOperationResponse extends BaseOperationResponse<\n OperationResponseType.liquidityPoolDeposit,\n OperationResponseTypeI.liquidityPoolDeposit\n > {\n liquidity_pool_id: string;\n reserves_max: Reserve[];\n min_price: string;\n min_price_r: PriceRShorthand;\n max_price: string;\n max_price_r: PriceRShorthand;\n reserves_deposited: Reserve[];\n shares_received: string;\n }\n export interface WithdrawLiquidityOperationResponse extends BaseOperationResponse<\n OperationResponseType.liquidityPoolWithdraw,\n OperationResponseTypeI.liquidityPoolWithdraw\n > {\n liquidity_pool_id: string;\n reserves_min: Reserve[];\n shares: string;\n reserves_received: Reserve[];\n }\n\n export interface BalanceChange {\n asset_type: string;\n asset_code?: string;\n asset_issuer?: string;\n\n type: string;\n from: string;\n to: string;\n amount: string;\n destination_muxed_id?: string;\n }\n\n export interface InvokeHostFunctionOperationResponse extends BaseOperationResponse<\n OperationResponseType.invokeHostFunction,\n OperationResponseTypeI.invokeHostFunction\n > {\n function: string;\n parameters: {\n value: string;\n type: string;\n }[];\n address: string;\n salt: string;\n asset_balance_changes: BalanceChange[];\n }\n\n export interface BumpFootprintExpirationOperationResponse extends BaseOperationResponse<\n OperationResponseType.bumpFootprintExpiration,\n OperationResponseTypeI.bumpFootprintExpiration\n > {\n ledgers_to_expire: number;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty interface names a public API response type\n export interface RestoreFootprintOperationResponse extends BaseOperationResponse<\n OperationResponseType.restoreFootprint,\n OperationResponseTypeI.restoreFootprint\n > {}\n\n export interface ResponseCollection<T extends BaseResponse = BaseResponse> {\n _links: {\n self: ResponseLink;\n next: ResponseLink;\n prev: ResponseLink;\n };\n _embedded: {\n records: T[];\n };\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type -- empty interface names a public API response type\n export interface TransactionResponseCollection extends ResponseCollection<TransactionResponse> {}\n\n export interface FeeDistribution {\n max: string;\n min: string;\n mode: string;\n p10: string;\n p20: string;\n p30: string;\n p40: string;\n p50: string;\n p60: string;\n p70: string;\n p80: string;\n p90: string;\n p95: string;\n p99: string;\n }\n export interface FeeStatsResponse {\n last_ledger: string;\n last_ledger_base_fee: string;\n ledger_capacity_usage: string;\n fee_charged: FeeDistribution;\n max_fee: FeeDistribution;\n }\n\n export type ErrorResponseData =\n | ErrorResponseData.RateLimitExceeded\n | ErrorResponseData.InternalServerError\n | ErrorResponseData.TransactionFailed;\n\n export namespace ErrorResponseData {\n export interface Base {\n status: number;\n title: string;\n type: string; // TODO\n details: string; // TODO\n instance: string; // TODO\n }\n\n export interface RateLimitExceeded extends Base {\n status: 429;\n title: \"Rate Limit Exceeded\";\n }\n export interface InternalServerError extends Base {\n status: 500;\n title: \"Internal Server Error\";\n }\n export interface TransactionFailed extends Base {\n status: 400;\n title: \"Transaction Failed\";\n extras: TransactionFailedExtras;\n }\n }\n\n export enum TransactionFailedResultCodes {\n TX_FAILED = \"tx_failed\",\n TX_BAD_SEQ = \"tx_bad_seq\",\n TX_BAD_AUTH = \"tx_bad_auth\",\n TX_BAD_AUTH_EXTRA = \"tx_bad_auth_extra\",\n TX_FEE_BUMP_INNER_SUCCESS = \"tx_fee_bump_inner_success\",\n TX_FEE_BUMP_INNER_FAILED = \"tx_fee_bump_inner_failed\",\n TX_NOT_SUPPORTED = \"tx_not_supported\",\n TX_SUCCESS = \"tx_success\",\n TX_TOO_EARLY = \"tx_too_early\",\n TX_TOO_LATE = \"tx_too_late\",\n TX_MISSING_OPERATION = \"tx_missing_operation\",\n TX_INSUFFICIENT_BALANCE = \"tx_insufficient_balance\",\n TX_NO_SOURCE_ACCOUNT = \"tx_no_source_account\",\n TX_INSUFFICIENT_FEE = \"tx_insufficient_fee\",\n TX_INTERNAL_ERROR = \"tx_internal_error\",\n TX_BAD_SPONSORSHIP = \"tx_bad_sponsorship\",\n TX_BAD_MIN_SEQ_AGE_OR_GAP = \"tx_bad_min_seq_age_or_gap\",\n TX_MALFORMED = \"tx_malformed\",\n TX_SOROBAN_INVALID = \"tx_soroban_invalid\",\n TX_FROZEN_KEY_ACCESSED = \"tx_frozen_key_accessed\",\n }\n\n export interface TransactionFailedExtras {\n envelope_xdr: string; // base64\n result_codes: {\n transaction: TransactionFailedResultCodes;\n /** Omitted by Horizon when the transaction failed a transaction-level\n * check (e.g. `tx_bad_seq`) and no operations were evaluated. Typed as\n * required for backwards compatibility; treat as possibly undefined\n * when reading the raw response, or use\n * `TransactionFailedError.getResultCodes()` which normalizes it.\n * TODO(next major): make this `operations?: string[]`. */\n operations: string[];\n };\n result_xdr: string;\n }\n\n export interface RootResponse {\n horizon_version: string;\n core_version: string;\n ingest_latest_ledger: number;\n history_latest_ledger: number;\n history_latest_ledger_closed_at: string;\n history_elder_ledger: number;\n core_latest_ledger: number;\n network_passphrase: string;\n current_protocol_version: number;\n supported_protocol_version: number;\n core_supported_protocol_version: number;\n }\n}\n"],"names":["HorizonApi","LiquidityPoolType","OperationResponseType","OperationResponseTypeI","TransactionFailedResultCodes"],"mappings":";;AAGiBA;AAAA,CAAV,CAAUA,WAAAA,KAAV;AAiME,EAAA,CAAA,CAAKC,kBAAAA,KAAL;AACL,IAAAA,mBAAA,iBAAA,CAAA,GAAkB,kBAAA;AAAA,EAAA,CAAA,EADRD,WAAAA,CAAA,iBAAA,KAAAA,WAAAA,CAAA,iBAAA,GAAA,EAAA,CAAA,CAAA;AAIL,EAAA,CAAA,CAAKE,sBAAAA,KAAL;AACL,IAAAA,uBAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,IAAAA,uBAAA,SAAA,CAAA,GAAU,SAAA;AACV,IAAAA,uBAAA,aAAA,CAAA,GAAc,6BAAA;AACd,IAAAA,uBAAA,oBAAA,CAAA,GAAqB,2BAAA;AACrB,IAAAA,uBAAA,aAAA,CAAA,GAAc,mBAAA;AACd,IAAAA,uBAAA,YAAA,CAAA,GAAa,aAAA;AACb,IAAAA,uBAAA,aAAA,CAAA,GAAc,cAAA;AACd,IAAAA,uBAAA,YAAA,CAAA,GAAa,aAAA;AACb,IAAAA,uBAAA,cAAA,CAAA,GAAe,eAAA;AACf,IAAAA,uBAAA,WAAA,CAAA,GAAY,WAAA;AACZ,IAAAA,uBAAA,YAAA,CAAA,GAAa,aAAA;AACb,IAAAA,uBAAA,cAAA,CAAA,GAAe,eAAA;AACf,IAAAA,uBAAA,gBAAA,CAAA,GAAiB,kBAAA;AACjB,IAAAA,uBAAA,uBAAA,CAAA,GAAwB,0BAAA;AACxB,IAAAA,uBAAA,wBAAA,CAAA,GAAyB,0BAAA;AACzB,IAAAA,uBAAA,uBAAA,CAAA,GAAwB,yBAAA;AACxB,IAAAA,uBAAA,+BAAA,CAAA,GAAgC,kCAAA;AAChC,IAAAA,uBAAA,6BAAA,CAAA,GAA8B,gCAAA;AAC9B,IAAAA,uBAAA,mBAAA,C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AA,WAAAA,CAAA,4BAAA,GAAA,EAAA,CAAA,CAAA;AAAA,CAAA,EAlpBGA,kBAAA,KAAAA,kBAAA,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -26,7 +26,9 @@ var call_builder = require('./call_builder.js');
|
|
|
26
26
|
var config = require('../config.js');
|
|
27
27
|
var not_found = require('../errors/not_found.js');
|
|
28
28
|
var bad_response = require('../errors/bad_response.js');
|
|
29
|
+
var transaction_failed = require('../errors/transaction_failed.js');
|
|
29
30
|
var account_requires_memo = require('../errors/account_requires_memo.js');
|
|
31
|
+
var wrap_http_error = require('../errors/wrap_http_error.js');
|
|
30
32
|
var account_call_builder = require('./account_call_builder.js');
|
|
31
33
|
var account_response = require('./account_response.js');
|
|
32
34
|
var assets_call_builder = require('./assets_call_builder.js');
|
|
@@ -52,6 +54,12 @@ const ACCOUNT_REQUIRES_MEMO = "MQ==";
|
|
|
52
54
|
function getAmountInLumens(amt) {
|
|
53
55
|
return new bignumber.default(amt).div(STROOPS_IN_LUMEN).toString();
|
|
54
56
|
}
|
|
57
|
+
function toSubmissionError(error) {
|
|
58
|
+
return wrap_http_error.wrapHttpError(error, (details) => {
|
|
59
|
+
const message = `Transaction submission failed. Server responded: ${details.status} ${details.statusText}`;
|
|
60
|
+
return details.data?.extras?.result_codes ? new transaction_failed.TransactionFailedError(message, details) : new bad_response.BadResponseError(message, details);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
55
63
|
class HorizonServer {
|
|
56
64
|
/**
|
|
57
65
|
* Horizon Server URL (ex. `https://horizon-testnet.stellar.org`)
|
|
@@ -280,8 +288,11 @@ class HorizonServer {
|
|
|
280
288
|
* - `skipMemoRequiredCheck` (optional): Allow skipping memo
|
|
281
289
|
* required check, default: `false`. See
|
|
282
290
|
* [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md).
|
|
283
|
-
* @returns Promise that resolves
|
|
284
|
-
*
|
|
291
|
+
* @returns Promise that resolves with the response from Horizon. Rejects
|
|
292
|
+
* with a {@link TransactionFailedError} when Horizon reports transaction
|
|
293
|
+
* result codes, a {@link BadResponseError} for any other HTTP error
|
|
294
|
+
* response (the underlying client error is preserved as `cause` on both),
|
|
295
|
+
* or the original error for network-level failures.
|
|
285
296
|
*/
|
|
286
297
|
async submitTransaction(transaction, opts = {
|
|
287
298
|
skipMemoRequiredCheck: false
|
|
@@ -421,17 +432,7 @@ class HorizonServer {
|
|
|
421
432
|
...response.data,
|
|
422
433
|
offerResults: hasManageOffer ? offerResults : void 0
|
|
423
434
|
};
|
|
424
|
-
}).catch((
|
|
425
|
-
if (response instanceof Error) {
|
|
426
|
-
return Promise.reject(response);
|
|
427
|
-
}
|
|
428
|
-
return Promise.reject(
|
|
429
|
-
new bad_response.BadResponseError(
|
|
430
|
-
`Transaction submission failed. Server responded: ${response.status} ${response.statusText}`,
|
|
431
|
-
response.data
|
|
432
|
-
)
|
|
433
|
-
);
|
|
434
|
-
});
|
|
435
|
+
}).catch((error) => Promise.reject(toSubmissionError(error)));
|
|
435
436
|
}
|
|
436
437
|
/**
|
|
437
438
|
* Submits an asynchronous transaction to the network. Unlike the synchronous version, which blocks
|
|
@@ -447,8 +448,11 @@ class HorizonServer {
|
|
|
447
448
|
* - `skipMemoRequiredCheck` (optional): Allow skipping memo
|
|
448
449
|
* required check, default: `false`. See
|
|
449
450
|
* [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md).
|
|
450
|
-
* @returns Promise that resolves
|
|
451
|
-
*
|
|
451
|
+
* @returns Promise that resolves with the response from Horizon. Rejects
|
|
452
|
+
* with a {@link TransactionFailedError} when Horizon reports transaction
|
|
453
|
+
* result codes, a {@link BadResponseError} for any other HTTP error
|
|
454
|
+
* response (the underlying client error is preserved as `cause` on both),
|
|
455
|
+
* or the original error for network-level failures.
|
|
452
456
|
*/
|
|
453
457
|
async submitAsyncTransaction(transaction, opts = {
|
|
454
458
|
skipMemoRequiredCheck: false
|
|
@@ -463,17 +467,7 @@ class HorizonServer {
|
|
|
463
467
|
url.pathname = url.pathname.split("/").concat(["transactions_async"]).filter((value) => value.length > 0).join("/");
|
|
464
468
|
return this.httpClient.post(url.toString(), `tx=${tx}`, {
|
|
465
469
|
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
466
|
-
}).then((response) => response.data).catch((
|
|
467
|
-
if (response instanceof Error) {
|
|
468
|
-
return Promise.reject(response);
|
|
469
|
-
}
|
|
470
|
-
return Promise.reject(
|
|
471
|
-
new bad_response.BadResponseError(
|
|
472
|
-
`Transaction submission failed. Server responded: ${response.status} ${response.statusText}`,
|
|
473
|
-
response.data
|
|
474
|
-
)
|
|
475
|
-
);
|
|
476
|
-
});
|
|
470
|
+
}).then((response) => response.data).catch((error) => Promise.reject(toSubmissionError(error)));
|
|
477
471
|
}
|
|
478
472
|
/**
|
|
479
473
|
* @returns New {@link AccountCallBuilder} object configured by a current Horizon server configuration.
|