@stellar/stellar-sdk 16.0.0-rc.1 → 16.0.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 +22 -28
- package/dist/stellar-sdk-axios.js +245 -232
- package/dist/stellar-sdk-axios.js.map +1 -1
- package/dist/stellar-sdk-axios.min.js +1 -1
- package/dist/stellar-sdk-axios.min.js.map +1 -1
- package/dist/stellar-sdk.js +49 -36
- package/dist/stellar-sdk.js.map +1 -1
- package/dist/stellar-sdk.min.js +2 -2
- package/dist/stellar-sdk.min.js.map +1 -1
- package/lib/axios/cjs/base/auth.js +11 -11
- package/lib/axios/cjs/base/auth.js.map +1 -1
- package/lib/axios/cjs/base/keypair.js +1 -1
- package/lib/axios/cjs/base/keypair.js.map +1 -1
- package/lib/axios/cjs/base/transaction_builder.js +13 -1
- package/lib/axios/cjs/base/transaction_builder.js.map +1 -1
- package/lib/axios/cjs/bindings/config.js +1 -1
- package/lib/axios/cjs/bindings/config.js.map +1 -1
- package/lib/axios/cjs/bindings/wasm_fetcher.js +1 -1
- package/lib/axios/cjs/bindings/wasm_fetcher.js.map +1 -1
- package/lib/axios/cjs/contract/client.js.map +1 -1
- package/lib/axios/cjs/contract/spec.js.map +1 -1
- package/lib/axios/cjs/contract/types.js.map +1 -1
- package/lib/axios/cjs/contract/utils.js.map +1 -1
- package/lib/axios/cjs/contract/wasm_spec_parser.js +1 -1
- package/lib/axios/cjs/contract/wasm_spec_parser.js.map +1 -1
- package/lib/axios/cjs/horizon/call_builder.js.map +1 -1
- 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/horizon_axios_client.js.map +1 -1
- package/lib/axios/cjs/http-client/fetch-client.js +1 -1
- package/lib/axios/cjs/http-client/fetch-client.js.map +1 -1
- package/lib/axios/cjs/http-client/types.js.map +1 -1
- package/lib/axios/cjs/rpc/axios.js +1 -1
- package/lib/axios/cjs/rpc/axios.js.map +1 -1
- package/lib/axios/cjs/rpc/jsonrpc.js.map +1 -1
- package/lib/axios/cjs/rpc/server.js +2 -2
- package/lib/axios/cjs/rpc/server.js.map +1 -1
- package/lib/axios/cjs/webauth/challenge_transaction.js.map +1 -1
- package/lib/axios/esm/base/auth.d.ts +19 -7
- package/lib/axios/esm/base/auth.js +11 -11
- package/lib/axios/esm/base/auth.js.map +1 -1
- package/lib/axios/esm/base/keypair.js +1 -1
- package/lib/axios/esm/base/keypair.js.map +1 -1
- package/lib/axios/esm/base/transaction_builder.js +13 -1
- package/lib/axios/esm/base/transaction_builder.js.map +1 -1
- package/lib/axios/esm/bindings/config.js +1 -1
- package/lib/axios/esm/bindings/config.js.map +1 -1
- package/lib/axios/esm/bindings/wasm_fetcher.js +1 -1
- package/lib/axios/esm/bindings/wasm_fetcher.js.map +1 -1
- package/lib/axios/esm/contract/client.js.map +1 -1
- package/lib/axios/esm/contract/spec.js.map +1 -1
- package/lib/axios/esm/contract/types.js.map +1 -1
- package/lib/axios/esm/contract/utils.js.map +1 -1
- package/lib/axios/esm/contract/wasm_spec_parser.js +1 -1
- package/lib/axios/esm/contract/wasm_spec_parser.js.map +1 -1
- package/lib/axios/esm/horizon/call_builder.js.map +1 -1
- 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/horizon_axios_client.js.map +1 -1
- package/lib/axios/esm/http-client/fetch-client.js +1 -1
- package/lib/axios/esm/http-client/fetch-client.js.map +1 -1
- package/lib/axios/esm/http-client/types.js.map +1 -1
- package/lib/axios/esm/rpc/axios.js +1 -1
- package/lib/axios/esm/rpc/axios.js.map +1 -1
- package/lib/axios/esm/rpc/jsonrpc.js.map +1 -1
- package/lib/axios/esm/rpc/server.js +2 -2
- package/lib/axios/esm/rpc/server.js.map +1 -1
- package/lib/axios/esm/webauth/challenge_transaction.js.map +1 -1
- package/lib/cjs/base/auth.js +11 -11
- package/lib/cjs/base/auth.js.map +1 -1
- package/lib/cjs/base/keypair.js +1 -1
- package/lib/cjs/base/keypair.js.map +1 -1
- package/lib/cjs/base/transaction_builder.js +13 -1
- package/lib/cjs/base/transaction_builder.js.map +1 -1
- package/lib/cjs/bindings/config.js +1 -1
- package/lib/cjs/bindings/config.js.map +1 -1
- package/lib/cjs/bindings/wasm_fetcher.js +1 -1
- package/lib/cjs/bindings/wasm_fetcher.js.map +1 -1
- package/lib/cjs/contract/client.js.map +1 -1
- package/lib/cjs/contract/spec.js.map +1 -1
- package/lib/cjs/contract/types.js.map +1 -1
- package/lib/cjs/contract/utils.js.map +1 -1
- package/lib/cjs/contract/wasm_spec_parser.js +1 -1
- package/lib/cjs/contract/wasm_spec_parser.js.map +1 -1
- package/lib/cjs/horizon/call_builder.js.map +1 -1
- package/lib/cjs/horizon/horizon_api.js.map +1 -1
- package/lib/cjs/horizon/horizon_axios_client.js +1 -1
- package/lib/cjs/horizon/horizon_axios_client.js.map +1 -1
- package/lib/cjs/http-client/fetch-client.js +1 -1
- package/lib/cjs/http-client/fetch-client.js.map +1 -1
- package/lib/cjs/http-client/types.js.map +1 -1
- package/lib/cjs/rpc/axios.js +1 -1
- package/lib/cjs/rpc/axios.js.map +1 -1
- package/lib/cjs/rpc/jsonrpc.js.map +1 -1
- package/lib/cjs/rpc/server.js +2 -2
- package/lib/cjs/rpc/server.js.map +1 -1
- package/lib/cjs/webauth/challenge_transaction.js.map +1 -1
- package/lib/esm/base/auth.d.ts +19 -7
- package/lib/esm/base/auth.js +11 -11
- package/lib/esm/base/auth.js.map +1 -1
- package/lib/esm/base/keypair.js +1 -1
- package/lib/esm/base/keypair.js.map +1 -1
- package/lib/esm/base/transaction_builder.js +13 -1
- package/lib/esm/base/transaction_builder.js.map +1 -1
- package/lib/esm/bindings/config.js +1 -1
- package/lib/esm/bindings/config.js.map +1 -1
- package/lib/esm/bindings/wasm_fetcher.js +1 -1
- package/lib/esm/bindings/wasm_fetcher.js.map +1 -1
- package/lib/esm/contract/client.js.map +1 -1
- package/lib/esm/contract/spec.js.map +1 -1
- package/lib/esm/contract/types.js.map +1 -1
- package/lib/esm/contract/utils.js.map +1 -1
- package/lib/esm/contract/wasm_spec_parser.js +1 -1
- package/lib/esm/contract/wasm_spec_parser.js.map +1 -1
- package/lib/esm/horizon/call_builder.js.map +1 -1
- package/lib/esm/horizon/horizon_api.js.map +1 -1
- package/lib/esm/horizon/horizon_axios_client.js +1 -1
- package/lib/esm/horizon/horizon_axios_client.js.map +1 -1
- package/lib/esm/http-client/fetch-client.js +1 -1
- package/lib/esm/http-client/fetch-client.js.map +1 -1
- package/lib/esm/http-client/types.js.map +1 -1
- package/lib/esm/rpc/axios.js +1 -1
- package/lib/esm/rpc/axios.js.map +1 -1
- package/lib/esm/rpc/jsonrpc.js.map +1 -1
- package/lib/esm/rpc/server.js +2 -2
- package/lib/esm/rpc/server.js.map +1 -1
- package/lib/esm/webauth/challenge_transaction.js.map +1 -1
- package/package.json +2 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/http-client/types.ts"],"sourcesContent":["export type HttpResponseHeaders = Record<\n string,\n string | boolean | undefined\n> & {\n \"set-cookie\"?: string[];\n};\n\nexport interface HttpClientDefaults extends Omit<\n HttpClientRequestConfig,\n \"headers\"\n> {\n headers?: [string, string][] | Record<string, string> | Headers | undefined;\n}\n\nexport interface HttpClientResponse<T = any> {\n data: T;\n headers: HttpResponseHeaders;\n config: any;\n status: number;\n statusText: string;\n}\n\nexport interface CancelToken {\n promise: Promise<void>;\n throwIfRequested(): void;\n reason?: string;\n}\n\ntype HeadersInit = [string, string][] | Record<string, string> | Headers;\n\nexport interface HttpClientRequestConfig<D = any> {\n url?: string;\n method?: string;\n baseURL?: string;\n data?: D;\n timeout?: number;\n fetchOptions?: Record<string, any>;\n headers?: HeadersInit;\n params?: Record<string, any>;\n maxContentLength?: number;\n maxRedirects?: number;\n cancelToken?: CancelToken;\n adapter?: (config: HttpClientRequestConfig) => Promise<HttpClientResponse>;\n}\n\nexport interface HttpClient {\n get: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n delete: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n head: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n options: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n post: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n put: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n patch: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n postForm: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n putForm: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n patchForm: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n interceptors: {\n request: InterceptorManager<HttpClientRequestConfig>;\n response: InterceptorManager<HttpClientResponse>;\n };\n defaults: HttpClientDefaults;\n CancelToken: typeof CancelToken;\n isCancel: (value: any) => boolean;\n makeRequest: <T = any>(\n config: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n create: (config?: HttpClientRequestConfig) => HttpClient;\n}\n\nexport interface Interceptor<V> {\n fulfilled: (value: V) => V | Promise<V>;\n rejected?: (error: any) => any;\n}\n\nexport interface InterceptorManager<V> {\n use(\n fulfilled: (value: V) => V | Promise<V>,\n rejected?: (error: any) => any,\n ): number;\n eject(id: number): void;\n forEach(fn: (interceptor: Interceptor<V>) => void): void;\n handlers: Array<Interceptor<V> | null>;\n}\n\nexport class CancelToken {\n promise: Promise<void>;\n reason?: string;\n throwIfRequested(): void {\n if (this.reason) {\n throw new Error(this.reason);\n }\n }\n constructor(executor: (cancel: (reason?: string) => void) => void) {\n let resolvePromise: (value?: any) => void;\n this.promise = new Promise<void>((resolve) => {\n resolvePromise = resolve;\n });\n executor((reason?: string) => {\n this.reason = reason;\n resolvePromise();\n });\n }\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/http-client/types.ts"],"sourcesContent":["export type HttpResponseHeaders = Record<\n string,\n string | boolean | undefined\n> & {\n \"set-cookie\"?: string[];\n};\n\nexport interface HttpClientDefaults extends Omit<\n HttpClientRequestConfig,\n \"headers\"\n> {\n headers?: [string, string][] | Record<string, string> | Headers | undefined;\n}\n\nexport interface HttpClientResponse<T = any> {\n data: T;\n headers: HttpResponseHeaders;\n config: any;\n status: number;\n statusText: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- intentionally merged with the CancelToken class below to declare its members\nexport interface CancelToken {\n promise: Promise<void>;\n throwIfRequested(): void;\n reason?: string;\n}\n\ntype HeadersInit = [string, string][] | Record<string, string> | Headers;\n\nexport interface HttpClientRequestConfig<D = any> {\n url?: string;\n method?: string;\n baseURL?: string;\n data?: D;\n timeout?: number;\n fetchOptions?: Record<string, any>;\n headers?: HeadersInit;\n params?: Record<string, any>;\n maxContentLength?: number;\n maxRedirects?: number;\n cancelToken?: CancelToken;\n adapter?: (config: HttpClientRequestConfig) => Promise<HttpClientResponse>;\n}\n\nexport interface HttpClient {\n get: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n delete: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n head: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n options: <T = any>(\n url: string,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n post: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n put: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n patch: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n postForm: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n putForm: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n patchForm: <T = any>(\n url: string,\n data?: any,\n config?: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n interceptors: {\n request: InterceptorManager<HttpClientRequestConfig>;\n response: InterceptorManager<HttpClientResponse>;\n };\n defaults: HttpClientDefaults;\n CancelToken: typeof CancelToken;\n isCancel: (value: any) => boolean;\n makeRequest: <T = any>(\n config: HttpClientRequestConfig,\n ) => Promise<HttpClientResponse<T>>;\n create: (config?: HttpClientRequestConfig) => HttpClient;\n}\n\nexport interface Interceptor<V> {\n fulfilled: (value: V) => V | Promise<V>;\n rejected?: (error: any) => any;\n}\n\nexport interface InterceptorManager<V> {\n use(\n fulfilled: (value: V) => V | Promise<V>,\n rejected?: (error: any) => any,\n ): number;\n eject(id: number): void;\n forEach(fn: (interceptor: Interceptor<V>) => void): void;\n handlers: Array<Interceptor<V> | null>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging -- intentionally merged with the CancelToken interface above\nexport class CancelToken {\n promise: Promise<void>;\n reason?: string;\n throwIfRequested(): void {\n if (this.reason) {\n throw new Error(this.reason);\n }\n }\n constructor(executor: (cancel: (reason?: string) => void) => void) {\n let resolvePromise: (value?: any) => void;\n this.promise = new Promise<void>((resolve) => {\n resolvePromise = resolve;\n });\n executor((reason?: string) => {\n this.reason = reason;\n resolvePromise();\n });\n }\n}\n"],"names":[],"mappings":";;AA0HO,MAAM,WAAA,CAAY;AAAA,EACvB,OAAA;AAAA,EACA,MAAA;AAAA,EACA,gBAAA,GAAyB;AACvB,IAAA,IAAI,KAAK,MAAA,EAAQ;AACf,MAAA,MAAM,IAAI,KAAA,CAAM,IAAA,CAAK,MAAM,CAAA;AAAA,IAC7B;AAAA,EACF;AAAA,EACA,YAAY,QAAA,EAAuD;AACjE,IAAA,IAAI,cAAA;AACJ,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,OAAA,CAAc,CAAC,OAAA,KAAY;AAC5C,MAAA,cAAA,GAAiB,OAAA;AAAA,IACnB,CAAC,CAAA;AACD,IAAA,QAAA,CAAS,CAAC,MAAA,KAAoB;AAC5B,MAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,MAAA,cAAA,EAAe;AAAA,IACjB,CAAC,CAAA;AAAA,EACH;AACF;;;;"}
|
package/lib/cjs/rpc/axios.js
CHANGED
package/lib/cjs/rpc/axios.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","sources":["../../../src/rpc/axios.ts"],"sourcesContent":["import { create, type HttpClient } from \"../http-client/index.js\";\n\
|
|
1
|
+
{"version":3,"file":"axios.js","sources":["../../../src/rpc/axios.ts"],"sourcesContent":["import { create, type HttpClient } from \"../http-client/index.js\";\n\ndeclare const __PACKAGE_VERSION__: string;\nexport const version = __PACKAGE_VERSION__;\n\nexport function createHttpClient(headers?: Record<string, string>): HttpClient {\n return create({\n headers: {\n ...headers,\n \"X-Client-Name\": \"js-stellar-sdk\",\n \"X-Client-Version\": version,\n },\n });\n}\n"],"names":["create"],"mappings":";;;;AAGO,MAAM,OAAA,GAAU;AAEhB,SAAS,iBAAiB,OAAA,EAA8C;AAC7E,EAAA,OAAOA,kBAAA,CAAO;AAAA,IACZ,OAAA,EAAS;AAAA,MACP,GAAG,OAAA;AAAA,MACH,eAAA,EAAiB,gBAAA;AAAA,MACjB,kBAAA,EAAoB;AAAA;AACtB,GACD,CAAA;AACH;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc.js","sources":["../../../src/rpc/jsonrpc.ts"],"sourcesContent":["import type { HttpClient } from \"../http-client/index.js\";\n\nexport type Id = string | number;\n\nexport interface Request<T> {\n jsonrpc: \"2.0\";\n id: Id;\n method: string;\n params: T;\n}\n\nexport interface Notification<T> {\n jsonrpc: \"2.0\";\n method: string;\n params?: T;\n}\n\nexport type Response<T, E = any> = {\n jsonrpc: \"2.0\";\n id: Id;\n} & ({ error: Error<E> } | { result: T });\n\nexport interface Error<E = any> {\n code: number;\n message?: string;\n data?: E;\n}\n\n// Check if the given object X has a field Y, and make that available to\n// typescript typing.\nfunction hasOwnProperty<X extends {}, Y extends PropertyKey>(\n obj: X,\n prop: Y,\n): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\n/**\n * Sends the jsonrpc 'params' as a single 'param' object (no array support).\n *\n * @param client - HttpClient instance to use for the request\n * @param url - URL to the RPC instance\n * @param method - RPC method name that should be called\n * @param param - (optional) params that should be supplied to the method\n * @returns Promise that resolves to the result of type T\n * @hidden\n */\nexport async function postObject<T>(\n client: HttpClient,\n url: string,\n method: string,\n param: any = null,\n): Promise<T> {\n const response = await client.post<Response<T>>(url, {\n jsonrpc: \"2.0\",\n // TODO: Generate a unique request id\n id: 1,\n method,\n params: param,\n });\n if (hasOwnProperty(response.data, \"error\")) {\n throw response.data.error;\n } else {\n return response.data?.result;\n }\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"jsonrpc.js","sources":["../../../src/rpc/jsonrpc.ts"],"sourcesContent":["import type { HttpClient } from \"../http-client/index.js\";\n\nexport type Id = string | number;\n\nexport interface Request<T> {\n jsonrpc: \"2.0\";\n id: Id;\n method: string;\n params: T;\n}\n\nexport interface Notification<T> {\n jsonrpc: \"2.0\";\n method: string;\n params?: T;\n}\n\nexport type Response<T, E = any> = {\n jsonrpc: \"2.0\";\n id: Id;\n} & ({ error: Error<E> } | { result: T });\n\nexport interface Error<E = any> {\n code: number;\n message?: string;\n data?: E;\n}\n\n// Check if the given object X has a field Y, and make that available to\n// typescript typing.\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- `{}` is the intended constraint (any non-nullish value with own properties)\nfunction hasOwnProperty<X extends {}, Y extends PropertyKey>(\n obj: X,\n prop: Y,\n): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\n/**\n * Sends the jsonrpc 'params' as a single 'param' object (no array support).\n *\n * @param client - HttpClient instance to use for the request\n * @param url - URL to the RPC instance\n * @param method - RPC method name that should be called\n * @param param - (optional) params that should be supplied to the method\n * @returns Promise that resolves to the result of type T\n * @hidden\n */\nexport async function postObject<T>(\n client: HttpClient,\n url: string,\n method: string,\n param: any = null,\n): Promise<T> {\n const response = await client.post<Response<T>>(url, {\n jsonrpc: \"2.0\",\n // TODO: Generate a unique request id\n id: 1,\n method,\n params: param,\n });\n if (hasOwnProperty(response.data, \"error\")) {\n throw response.data.error;\n } else {\n return response.data?.result;\n }\n}\n"],"names":[],"mappings":";;AA+BA,SAAS,cAAA,CACP,KACA,IAAA,EAC+B;AAC/B,EAAA,OAAO,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAK,KAAK,IAAI,CAAA;AACvD;AAYA,eAAsB,UAAA,CACpB,MAAA,EACA,GAAA,EACA,MAAA,EACA,QAAa,IAAA,EACD;AACZ,EAAA,MAAM,QAAA,GAAW,MAAM,MAAA,CAAO,IAAA,CAAkB,GAAA,EAAK;AAAA,IACnD,OAAA,EAAS,KAAA;AAAA;AAAA,IAET,EAAA,EAAI,CAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA,EAAQ;AAAA,GACT,CAAA;AACD,EAAA,IAAI,cAAA,CAAe,QAAA,CAAS,IAAA,EAAM,OAAO,CAAA,EAAG;AAC1C,IAAA,MAAM,SAAS,IAAA,CAAK,KAAA;AAAA,EACtB,CAAA,MAAO;AACL,IAAA,OAAO,SAAS,IAAA,EAAM,MAAA;AAAA,EACxB;AACF;;;;"}
|
package/lib/cjs/rpc/server.js
CHANGED
|
@@ -209,8 +209,8 @@ class RpcServer {
|
|
|
209
209
|
async getClaimableBalance(id) {
|
|
210
210
|
let balanceId;
|
|
211
211
|
if (strkey.StrKey.isValidClaimableBalance(id)) {
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
const buffer$1 = strkey.StrKey.decodeClaimableBalance(id);
|
|
213
|
+
const v = buffer.Buffer.concat([
|
|
214
214
|
buffer.Buffer.from("\0\0\0"),
|
|
215
215
|
buffer$1.subarray(0, 1)
|
|
216
216
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sources":["../../../src/rpc/server.ts"],"sourcesContent":["/* tslint:disable:variable-name no-namespace */\nimport {\n Account,\n Address,\n Asset,\n Contract,\n FeeBumpTransaction,\n Keypair,\n StrKey,\n Transaction,\n nativeToScVal,\n scValToNative,\n xdr,\n} from \"../base/index.js\";\n\nimport type { TransactionBuilder } from \"../base/index.js\";\nimport type { Config } from \"../config.js\";\nimport { createHttpClient } from \"./axios.js\";\nimport type { Api as FriendbotApi } from \"../friendbot/index.js\";\nimport * as jsonrpc from \"./jsonrpc.js\";\nimport { Api } from \"./api.js\";\nimport { assembleTransaction } from \"./transaction.js\";\nimport {\n parseRawSendTransaction,\n parseRawSimulation,\n parseRawLedgerEntries,\n parseRawEvents,\n parseRawTransactions,\n parseTransactionInfo,\n parseRawLedger,\n parseRawLatestLedger,\n} from \"./parsers.js\";\nimport { Utils } from \"../utils.js\";\nimport type { HttpClient } from \"../http-client/index.js\";\n\n/**\n * Default transaction submission timeout for RPC requests, in milliseconds\n * @defaultValue 60000\n */\nexport const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000;\n\n/**\n * Specifies the durability namespace of contract-related ledger entries.\n *\n * @see {@link https://developers.stellar.org/docs/learn/smart-contract-internals/state-archival | State Archival docs}\n * @see {@link https://docs.rs/soroban-sdk/latest/soroban_sdk/storage/struct.Storage.html | Rust SDK Storage docs}\n */\nexport enum Durability {\n Temporary = \"temporary\",\n Persistent = \"persistent\",\n}\n\nexport namespace RpcServer {\n /**\n * @deprecated Use `Api.GetEventsRequest` instead.\n * @see {@link Api.GetEventsRequest}\n */\n export type GetEventsRequest = Api.GetEventsRequest;\n\n export interface PollingOptions {\n attempts?: number;\n sleepStrategy?: SleepStrategy;\n }\n\n /**\n * Describes additional resource leeways for transaction simulation.\n */\n export interface ResourceLeeway {\n /** Simulate the transaction with more CPU instructions available. */\n cpuInstructions: number;\n }\n\n /**\n * Options for configuring connections to RPC servers.\n */\n export interface Options {\n /** Allow connecting to http servers, default: `false`. This must be set to false in production deployments! */\n allowHttp?: boolean;\n /** Allow a timeout, default: 0. Allows user to avoid nasty lag. */\n timeout?: number;\n /** Additional headers that should be added to any requests to the RPC server. */\n headers?: Record<string, string>;\n }\n}\n\nconst DEFAULT_GET_TRANSACTION_TIMEOUT: number = 30;\n\n/// A strategy that will sleep 1 second each time\n\nexport const BasicSleepStrategy: SleepStrategy = (_iter: number) => 1000;\n\n/// A strategy that will sleep 1 second longer on each attempt\nexport const LinearSleepStrategy: SleepStrategy = (iter: number) => 1000 * iter;\n\n/**\n * A function that returns the number of *milliseconds* to sleep\n * on a given `iter`ation.\n */\nexport type SleepStrategy = (iter: number) => number;\n\nfunction findCreatedAccountSequenceInTransactionMeta(\n meta: xdr.TransactionMeta,\n): string {\n let operations: xdr.OperationMeta[] = [];\n switch (meta.switch()) {\n case 0:\n operations = meta.operations();\n break;\n case 1:\n case 2:\n case 3:\n case 4: // all four have the same interface\n operations = (meta.value() as xdr.TransactionMetaV4).operations();\n break;\n default:\n throw new Error(\"Unexpected transaction meta switch value\");\n }\n const sequenceNumber = operations\n .flatMap((op) => op.changes())\n .find(\n (c) =>\n c.switch() === xdr.LedgerEntryChangeType.ledgerEntryCreated() &&\n c.created().data().switch() === xdr.LedgerEntryType.account(),\n )\n ?.created()\n ?.data()\n ?.account()\n ?.seqNum()\n ?.toString();\n\n if (sequenceNumber) {\n return sequenceNumber;\n }\n throw new Error(\"No account created in transaction\");\n}\n\n/**\n * Handles the network connection to a Soroban RPC instance, exposing an\n * interface for requests to that instance.\n *\n *\n * @param serverURL - Soroban-RPC Server URL (ex. `http://localhost:8000/soroban/rpc`).\n * @param opts - (optional) Options object\n * - `allowHttp` (optional): Allows connecting to insecure http servers\n * (default: `false`). This must be set to false in production deployments!\n * You can also use {@link Config} class to set this globally.\n * - `headers` (optional): Allows setting custom headers\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods | API reference docs}\n */\nexport class RpcServer {\n public readonly serverURL: URL;\n /**\n * HTTP client instance for making requests to Horizon.\n * Exposes interceptors, defaults, and other configuration options.\n *\n * @example\n * ```ts\n * // Add authentication header\n * server.httpClient.defaults.headers['Authorization'] = 'Bearer token';\n *\n * // Add request interceptor\n * server.httpClient.interceptors.request.use((config) => {\n * console.log('Request:', config.url);\n * return config;\n * });\n * ```\n */\n public readonly httpClient: HttpClient;\n constructor(serverURL: string, opts: RpcServer.Options = {}) {\n /**\n * RPC Server URL (ex. `http://localhost:8000/soroban/rpc`).\n */\n this.serverURL = new URL(serverURL);\n this.httpClient = createHttpClient(opts.headers);\n if (this.serverURL.protocol !== \"https:\" && !opts.allowHttp) {\n throw new Error(\n \"Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set\",\n );\n }\n }\n\n /**\n * Fetch a minimal set of current info about a Stellar account.\n *\n * Needed to get the current sequence number for the account so you can build\n * a successful transaction with {@link TransactionBuilder}.\n *\n * @param address - The public address of the account to load.\n * @returns A promise which resolves to the {@link Account}\n * object with a populated sequence number\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const accountId = \"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\";\n * server.getAccount(accountId).then((account) => {\n * console.log(\"sequence:\", account.sequence);\n * });\n * ```\n */\n public async getAccount(address: string): Promise<Account> {\n const entry = await this.getAccountEntry(address);\n return new Account(address, entry.seqNum().toString());\n }\n\n /**\n * Fetch the full account entry for a Stellar account.\n *\n * @param address - The public address of the account to load.\n * @returns Resolves to the full on-chain account\n * entry\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const accountId = \"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\";\n * server.getAccountEntry(accountId).then((account) => {\n * console.log(\"sequence:\", account.balance().toString());\n * });\n * ```\n */\n public async getAccountEntry(address: string): Promise<xdr.AccountEntry> {\n const ledgerKey = xdr.LedgerKey.account(\n new xdr.LedgerKeyAccount({\n accountId: Keypair.fromPublicKey(address).xdrPublicKey(),\n }),\n );\n\n try {\n const resp = await this.getLedgerEntry(ledgerKey);\n return resp.val.account();\n } catch {\n throw new Error(`Account not found: ${address}`);\n }\n }\n\n /**\n * Fetch the full trustline entry for a Stellar account.\n *\n * @param account - The public address of the account whose trustline it is\n * @param asset - The trustline's asset\n * @returns Resolves to the full on-chain trustline\n * entry\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @deprecated Use {@link getAssetBalance}, instead\n * @example\n * ```ts\n * const accountId = \"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\";\n * const asset = new Asset(\n * \"USDC\",\n * \"GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5\"\n * );\n * server.getTrustline(accountId, asset).then((entry) => {\n * console.log(`{asset.toString()} balance for ${accountId}:\", entry.balance().toString());\n * });\n * ```\n */\n public async getTrustline(\n account: string,\n asset: Asset,\n ): Promise<xdr.TrustLineEntry> {\n const trustlineLedgerKey = xdr.LedgerKey.trustline(\n new xdr.LedgerKeyTrustLine({\n accountId: Keypair.fromPublicKey(account).xdrAccountId(),\n asset: asset.toTrustLineXDRObject(),\n }),\n );\n\n try {\n const entry = await this.getLedgerEntry(trustlineLedgerKey);\n return entry.val.trustLine();\n } catch {\n throw new Error(\n `Trustline for ${asset.getCode()}:${asset.getIssuer()} not found for ${account}`,\n );\n }\n }\n\n /**\n * Fetch the full claimable balance entry for a Stellar account.\n *\n * @param id - The strkey (`B...`) or hex (`00000000abcde...`) (both\n * IDs with and without the 000... version prefix are accepted) of the\n * claimable balance to load\n * @returns Resolves to the full on-chain\n * claimable balance entry\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const id = \"00000000178826fbfe339e1f5c53417c6fedfe2c05e8bec14303143ec46b38981b09c3f9\";\n * server.getClaimableBalance(id).then((entry) => {\n * console.log(`Claimable balance {id.substr(0, 12)} has:`);\n * console.log(` asset: ${Asset.fromXDRObject(entry.asset()).toString()}`;\n * console.log(` amount: ${entry.amount().toString()}`;\n * });\n * ```\n */\n public async getClaimableBalance(\n id: string,\n ): Promise<xdr.ClaimableBalanceEntry> {\n let balanceId;\n if (StrKey.isValidClaimableBalance(id)) {\n let buffer = StrKey.decodeClaimableBalance(id);\n\n // Pad the version byte to be a full int32 like in the XDR spec\n let v = Buffer.concat([\n Buffer.from(\"\\x00\\x00\\x00\"),\n buffer.subarray(0, 1),\n ]);\n\n // Slap on the rest of it and decode it\n balanceId = xdr.ClaimableBalanceId.fromXDR(\n Buffer.concat([v, buffer.subarray(1)]),\n );\n } else if (id.match(/[a-f0-9]{72}/i)) {\n balanceId = xdr.ClaimableBalanceId.fromXDR(id, \"hex\");\n } else if (id.match(/[a-f0-9]{64}/i)) {\n balanceId = xdr.ClaimableBalanceId.fromXDR(id.padStart(72, \"0\"), \"hex\");\n } else {\n throw new TypeError(`expected 72-char hex ID or strkey, not ${id}`);\n }\n\n const trustlineLedgerKey = xdr.LedgerKey.claimableBalance(\n new xdr.LedgerKeyClaimableBalance({ balanceId }),\n );\n\n try {\n const entry = await this.getLedgerEntry(trustlineLedgerKey);\n return entry.val.claimableBalance();\n } catch {\n throw new Error(`Claimable balance ${id} not found`);\n }\n }\n\n /**\n * Fetch the balance of an asset held by an account or contract.\n *\n * The `address` argument may be provided as a string (as a {@link StrKey}),\n * {@link Address}, or {@link Contract}.\n *\n * @param address - The account or contract whose\n * balance should be fetched.\n * @param asset - The asset whose balance you want to inspect.\n * @param networkPassphrase - (optional) optionally, when requesting the\n * balance of a contract, the network passphrase to which this token\n * applies. If omitted and necessary, a request about network information\n * will be made (see {@link getNetwork}), since contract IDs for assets are\n * specific to a network. You can refer to {@link Networks} for a list of\n * built-in passphrases, e.g., `Networks.TESTNET`.\n * @returns Resolves with balance entry details\n * when available.\n *\n * @throws If the supplied `address` is not a valid account or\n * contract strkey.\n *\n * @example\n * ```ts\n * const usdc = new Asset(\n * \"USDC\",\n * \"GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5\"\n * );\n * const balance = await server.getAssetBalance(\"GD...\", usdc);\n * console.log(balance.balanceEntry?.amount);\n * ```\n */\n public async getAssetBalance(\n address: string | Address | Contract,\n asset: Asset,\n networkPassphrase?: string,\n ): Promise<Api.BalanceResponse> {\n let addr: string = address as string;\n // Coalesce to a strkey\n if (typeof address === \"string\") {\n addr = address;\n } else if (address instanceof Address) {\n addr = address.toString();\n } else if (address instanceof Contract) {\n addr = address.toString();\n } else {\n // shouldn't happen, but be defensive\n throw new TypeError(`invalid address: ${address}`);\n }\n\n if (StrKey.isValidEd25519PublicKey(addr)) {\n const [tl, ll] = await Promise.all([\n this.getTrustline(addr, asset),\n this.getLatestLedger(),\n ]);\n\n return {\n latestLedger: ll.sequence,\n balanceEntry: {\n amount: tl.balance().toString(),\n // Extract actual flags from the coalesced value.\n authorized: Boolean(tl.flags() & 0x1), // AUTHORIZED_FLAG\n clawback: Boolean(tl.flags() & 0x4), // TRUSTLINE_CLAWBACK_ENABLED_FLAG\n authorizedToMaintainLiabilities: Boolean(tl.flags() & 0x2), // AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG\n revocable: Boolean(tl.flags() & 0x2), // AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG (deprecated, will be removed in a future major release)\n },\n };\n } else if (StrKey.isValidContract(addr)) {\n return this.getSACBalance(addr, asset, networkPassphrase);\n }\n\n throw new Error(`invalid address: ${address}`);\n }\n\n /**\n * General node health check.\n *\n * @returns A promise which resolves to the\n * {@link Api.GetHealthResponse} object with the status of the\n * server (e.g. \"healthy\").\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getHealth | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * server.getHealth().then((health) => {\n * console.log(\"status:\", health.status);\n * });\n * ```\n */\n\n public async getHealth(): Promise<Api.GetHealthResponse> {\n return jsonrpc.postObject<Api.GetHealthResponse>(\n this.httpClient,\n this.serverURL.toString(),\n \"getHealth\",\n );\n }\n\n /**\n * Reads the current value of contract data ledger entries directly.\n *\n * Allows you to directly inspect the current state of a contract. This is a\n * backup way to access your contract data which may not be available via\n * events or {@link rpc.Server.simulateTransaction}.\n *\n * @param contract - The contract ID containing the\n * data to load as a strkey (`C...` form), a {@link Contract}, or an\n * {@link Address} instance\n * @param key - The key of the contract data to load\n * @param durability - (optional) The \"durability\n * keyspace\" that this ledger key belongs to, which is either 'temporary'\n * or 'persistent' (the default), see {@link rpc.Durability}.\n * @returns The current data value\n *\n * **Warning:** If the data entry in question is a 'temporary' entry, it's\n * entirely possible that it has expired out of existence.\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const contractId = \"CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5\";\n * const key = xdr.ScVal.scvSymbol(\"counter\");\n * server.getContractData(contractId, key, Durability.Temporary).then(data => {\n * console.log(\"value:\", data.val);\n * console.log(\"liveUntilLedgerSeq:\", data.liveUntilLedgerSeq);\n * console.log(\"lastModified:\", data.lastModifiedLedgerSeq);\n * console.log(\"latestLedger:\", data.latestLedger);\n * });\n * ```\n */\n\n public async getContractData(\n contract: string | Address | Contract,\n key: xdr.ScVal,\n durability: Durability = Durability.Persistent,\n ): Promise<Api.LedgerEntryResult> {\n // coalesce `contract` param variants to an ScAddress\n let scAddress: xdr.ScAddress;\n if (typeof contract === \"string\") {\n scAddress = new Contract(contract).address().toScAddress();\n } else if (contract instanceof Address) {\n scAddress = contract.toScAddress();\n } else if (contract instanceof Contract) {\n scAddress = contract.address().toScAddress();\n } else {\n throw new TypeError(`unknown contract type: ${contract}`);\n }\n\n let xdrDurability: xdr.ContractDataDurability;\n switch (durability) {\n case Durability.Temporary:\n xdrDurability = xdr.ContractDataDurability.temporary();\n break;\n\n case Durability.Persistent:\n xdrDurability = xdr.ContractDataDurability.persistent();\n break;\n\n default:\n throw new TypeError(`invalid durability: ${durability}`);\n }\n\n const contractKey = xdr.LedgerKey.contractData(\n new xdr.LedgerKeyContractData({\n key,\n contract: scAddress,\n durability: xdrDurability,\n }),\n );\n\n try {\n return await this.getLedgerEntry(contractKey);\n } catch {\n throw {\n code: 404,\n message: `Contract data not found for ${Address.fromScAddress(\n scAddress,\n ).toString()} with key ${key.toXDR(\"base64\")} and durability: ${durability}`,\n };\n }\n }\n\n /**\n * Retrieves the WASM bytecode for a given contract.\n *\n * This method allows you to fetch the WASM bytecode associated with a contract\n * deployed on the Soroban network. The WASM bytecode represents the executable\n * code of the contract.\n *\n * @param contractId - The contract ID containing the WASM bytecode to retrieve\n * @returns A Buffer containing the WASM bytecode\n * @throws If the contract or its associated WASM bytecode cannot be\n * found on the network.\n *\n * @example\n * ```ts\n * const contractId = \"CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5\";\n * server.getContractWasmByContractId(contractId).then(wasmBuffer => {\n * console.log(\"WASM bytecode length:\", wasmBuffer.length);\n * // ... do something with the WASM bytecode ...\n * }).catch(err => {\n * console.error(\"Error fetching WASM bytecode:\", err);\n * });\n * ```\n */\n public async getContractWasmByContractId(\n contractId: string,\n ): Promise<Buffer> {\n const contractLedgerKey = new Contract(contractId).getFootprint();\n const response = await this.getLedgerEntries(contractLedgerKey);\n if (!response.entries.length || !response.entries[0]?.val) {\n return Promise.reject({\n code: 404,\n message: `Could not obtain contract hash from server`,\n });\n }\n\n const wasmHash = response.entries[0].val\n .contractData()\n .val()\n .instance()\n .executable()\n .wasmHash();\n\n return this.getContractWasmByHash(wasmHash);\n }\n\n /**\n * Retrieves the WASM bytecode for a given contract hash.\n *\n * This method allows you to fetch the WASM bytecode associated with a contract\n * deployed on the Soroban network using the contract's WASM hash. The WASM bytecode\n * represents the executable code of the contract.\n *\n * @param wasmHash - The WASM hash of the contract\n * @returns A Buffer containing the WASM bytecode\n * @throws If the contract or its associated WASM bytecode cannot be\n * found on the network.\n *\n * @example\n * ```ts\n * const wasmHash = Buffer.from(\"...\");\n * server.getContractWasmByHash(wasmHash).then(wasmBuffer => {\n * console.log(\"WASM bytecode length:\", wasmBuffer.length);\n * // ... do something with the WASM bytecode ...\n * }).catch(err => {\n * console.error(\"Error fetching WASM bytecode:\", err);\n * });\n * ```\n */\n public async getContractWasmByHash(\n wasmHash: Buffer | string,\n format: undefined | \"hex\" | \"base64\" = undefined,\n ): Promise<Buffer> {\n const wasmHashBuffer =\n typeof wasmHash === \"string\"\n ? Buffer.from(wasmHash, format)\n : (wasmHash as Buffer);\n\n const ledgerKeyWasmHash = xdr.LedgerKey.contractCode(\n new xdr.LedgerKeyContractCode({\n hash: wasmHashBuffer,\n }),\n );\n\n const responseWasm = await this.getLedgerEntries(ledgerKeyWasmHash);\n if (!responseWasm.entries.length || !responseWasm.entries[0]?.val) {\n return Promise.reject({\n code: 404,\n message: \"Could not obtain contract wasm from server\",\n });\n }\n const wasmBuffer = responseWasm.entries[0].val.contractCode().code();\n\n return wasmBuffer;\n }\n\n /**\n * Reads the current value of arbitrary ledger entries directly.\n *\n * Allows you to directly inspect the current state of contracts, contract's\n * code, accounts, or any other ledger entries.\n *\n * To fetch a contract's WASM byte-code, built the appropriate\n * {@link xdr.LedgerKeyContractCode} ledger entry key (or see\n * {@link Contract.getFootprint}).\n *\n * @param keys - One or more ledger entry keys to load\n * @returns The current on-chain\n * values for the given ledger keys\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n * @see RpcServer._getLedgerEntries\n * @example\n * ```ts\n * const contractId = \"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM\";\n * const key = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({\n * contractId: StrKey.decodeContract(contractId),\n * key: xdr.ScVal.scvSymbol(\"counter\"),\n * }));\n *\n * server.getLedgerEntries([key]).then(response => {\n * const ledgerData = response.entries[0];\n * console.log(\"key:\", ledgerData.key);\n * console.log(\"value:\", ledgerData.val);\n * console.log(\"liveUntilLedgerSeq:\", ledgerData.liveUntilLedgerSeq);\n * console.log(\"lastModified:\", ledgerData.lastModifiedLedgerSeq);\n * console.log(\"latestLedger:\", response.latestLedger);\n * });\n * ```\n */\n public getLedgerEntries(...keys: xdr.LedgerKey[]) {\n return this._getLedgerEntries(...keys).then(parseRawLedgerEntries);\n }\n\n public _getLedgerEntries(...keys: xdr.LedgerKey[]) {\n return jsonrpc.postObject<Api.RawGetLedgerEntriesResponse>(\n this.httpClient,\n this.serverURL.toString(),\n \"getLedgerEntries\",\n {\n keys: keys.map((k) => k.toXDR(\"base64\")),\n },\n );\n }\n\n public async getLedgerEntry(key: xdr.LedgerKey) {\n const results = await this._getLedgerEntries(key).then(\n parseRawLedgerEntries,\n );\n if (results.entries.length !== 1) {\n throw new Error(`failed to find an entry for key ${key.toXDR(\"base64\")}`);\n }\n return results.entries[0];\n }\n\n /**\n * Poll for a particular transaction with certain parameters.\n *\n * After submitting a transaction, clients can use this to poll for\n * transaction completion and return a definitive state of success or failure.\n *\n * @param hash - the transaction you're polling for\n * @param opts - (optional) polling options\n * - `attempts` (optional): (optional) the number of attempts to make\n * before returning the last-seen status. By default or on invalid inputs,\n * try 5 times.\n * - `sleepStrategy` (optional): (optional) the amount of time\n * to wait for between each attempt. By default, sleep for 1 second between\n * each attempt.\n *\n * @returns the response after a \"found\"\n * response (which may be success or failure) or the last response obtained\n * after polling the maximum number of specified attempts.\n *\n * @example\n * ```ts\n * const h = \"c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a\";\n * const txStatus = await server.pollTransaction(h, {\n * attempts: 100, // I'm a maniac\n * sleepStrategy: rpc.LinearSleepStrategy\n * }); // this will take 5,050 seconds to complete\n * ```\n */\n public async pollTransaction(\n hash: string,\n opts?: RpcServer.PollingOptions,\n ): Promise<Api.GetTransactionResponse> {\n const maxAttempts: number =\n (opts?.attempts ?? 0) < 1\n ? DEFAULT_GET_TRANSACTION_TIMEOUT\n : (opts?.attempts ?? DEFAULT_GET_TRANSACTION_TIMEOUT); // \"positive and defined user value or default\"\n\n let foundInfo: Api.GetTransactionResponse;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n foundInfo = await this.getTransaction(hash);\n if (foundInfo.status !== Api.GetTransactionStatus.NOT_FOUND) {\n return foundInfo;\n }\n\n await Utils.sleep((opts?.sleepStrategy ?? BasicSleepStrategy)(attempt));\n }\n\n return foundInfo!;\n }\n\n /**\n * Fetch the details of a submitted transaction.\n *\n * After submitting a transaction, clients should poll this to tell when the\n * transaction has completed.\n *\n * @param hash - Hex-encoded hash of the transaction to check\n * @returns The status, result, and\n * other details about the transaction\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction | getTransaction docs}\n *\n * @example\n * ```ts\n * const transactionHash = \"c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a\";\n * server.getTransaction(transactionHash).then((tx) => {\n * console.log(\"status:\", tx.status);\n * console.log(\"envelopeXdr:\", tx.envelopeXdr);\n * console.log(\"resultMetaXdr:\", tx.resultMetaXdr);\n * console.log(\"resultXdr:\", tx.resultXdr);\n * });\n * ```\n */\n\n public async getTransaction(\n hash: string,\n ): Promise<Api.GetTransactionResponse> {\n return this._getTransaction(hash).then((raw) => {\n const foundInfo: Omit<\n Api.GetSuccessfulTransactionResponse,\n keyof Api.GetMissingTransactionResponse\n > = {} as any;\n\n if (raw.status !== Api.GetTransactionStatus.NOT_FOUND) {\n Object.assign(foundInfo, parseTransactionInfo(raw));\n }\n\n const result: Api.GetTransactionResponse = {\n status: raw.status,\n txHash: hash,\n latestLedger: raw.latestLedger,\n latestLedgerCloseTime: raw.latestLedgerCloseTime,\n oldestLedger: raw.oldestLedger,\n oldestLedgerCloseTime: raw.oldestLedgerCloseTime,\n ...foundInfo,\n };\n\n return result;\n });\n }\n\n public async _getTransaction(\n hash: string,\n ): Promise<Api.RawGetTransactionResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getTransaction\",\n {\n hash,\n },\n );\n }\n\n /**\n * Fetch transactions starting from a given start ledger or a cursor. The end ledger is the latest ledger\n * in that RPC instance.\n *\n * @param request - The request parameters.\n * @returns - A promise that resolves to the transactions response.\n *\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransactions\n * @example\n * ```ts\n * server.getTransactions({\n * startLedger: 10000,\n * limit: 10,\n * }).then((response) => {\n * console.log(\"Transactions:\", response.transactions);\n * console.log(\"Latest Ledger:\", response.latestLedger);\n * console.log(\"Cursor:\", response.cursor);\n * });\n * ```\n */\n public async getTransactions(\n request: Api.GetTransactionsRequest,\n ): Promise<Api.GetTransactionsResponse> {\n return this._getTransactions(request).then(\n (raw: Api.RawGetTransactionsResponse) => {\n const result: Api.GetTransactionsResponse = {\n transactions: (raw.transactions || []).map(parseRawTransactions),\n latestLedger: raw.latestLedger,\n latestLedgerCloseTimestamp: raw.latestLedgerCloseTimestamp,\n oldestLedger: raw.oldestLedger,\n oldestLedgerCloseTimestamp: raw.oldestLedgerCloseTimestamp,\n cursor: raw.cursor,\n };\n return result;\n },\n );\n }\n\n async _getTransactions(\n request: Api.GetTransactionsRequest,\n ): Promise<Api.RawGetTransactionsResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getTransactions\",\n request,\n );\n }\n\n /**\n * Fetch all events that match a given set of filters.\n *\n * The given filters (see {@link Api.EventFilter}\n * for detailed fields) are combined only in a logical OR fashion, and all of\n * the fields in each filter are optional.\n *\n * To page through events, use the `pagingToken` field on the relevant\n * {@link Api.EventResponse} object to set the `cursor` parameter.\n *\n * @param request - Event filters {@link Api.GetEventsRequest},\n * @returns A paginatable set of the events\n * matching the given event filters\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents docs}\n *\n * @example\n * ```ts\n *\n * server.getEvents({\n * startLedger: 1000,\n * endLedger: 2000,\n * filters: [\n * {\n * type: \"contract\",\n * contractIds: [ \"deadb33f...\" ],\n * topics: [[ \"AAAABQAAAAh0cmFuc2Zlcg==\", \"AAAAAQB6Mcc=\", \"*\" ]]\n * }, {\n * type: \"system\",\n * contractIds: [ \"...c4f3b4b3...\" ],\n * topics: [[ \"*\" ], [ \"*\", \"AAAAAQB6Mcc=\" ]]\n * }, {\n * contractIds: [ \"...c4f3b4b3...\" ],\n * topics: [[ \"AAAABQAAAAh0cmFuc2Zlcg==\" ]]\n * }, {\n * type: \"diagnostic\",\n * topics: [[ \"AAAAAQB6Mcc=\" ]]\n * }\n * ],\n * limit: 10,\n * });\n * ```\n */\n\n public async getEvents(\n request: Api.GetEventsRequest,\n ): Promise<Api.GetEventsResponse> {\n return this._getEvents(request).then(parseRawEvents);\n }\n\n public async _getEvents(\n request: Api.GetEventsRequest,\n ): Promise<Api.RawGetEventsResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getEvents\",\n {\n filters: request.filters ?? [],\n pagination: {\n ...(request.cursor && { cursor: request.cursor }), // add if defined\n ...(request.limit && { limit: request.limit }),\n },\n ...(request.startLedger && {\n startLedger: request.startLedger,\n }),\n ...(request.endLedger && {\n endLedger: request.endLedger,\n }),\n },\n );\n }\n\n /**\n * Fetch metadata about the network this Soroban RPC server is connected to.\n *\n * @returns Metadata about the current\n * network this RPC server is connected to\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getNetwork | getNetwork docs}\n *\n * @example\n * ```ts\n * server.getNetwork().then((network) => {\n * console.log(\"friendbotUrl:\", network.friendbotUrl);\n * console.log(\"passphrase:\", network.passphrase);\n * console.log(\"protocolVersion:\", network.protocolVersion);\n * });\n * ```\n */\n\n public async getNetwork(): Promise<Api.GetNetworkResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getNetwork\",\n );\n }\n\n /**\n * Fetch the latest ledger meta info from network which this Soroban RPC\n * server is connected to.\n *\n * @returns metadata about the\n * latest ledger on the network that this RPC server is connected to\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLatestLedger | getLatestLedger docs}\n *\n * @example\n * ```ts\n * server.getLatestLedger().then((response) => {\n * console.log(\"hash:\", response.id);\n * console.log(\"sequence:\", response.sequence);\n * console.log(\"protocolVersion:\", response.protocolVersion);\n * });\n * ```\n */\n public async getLatestLedger(): Promise<Api.GetLatestLedgerResponse> {\n return this._getLatestLedger().then(parseRawLatestLedger);\n }\n\n public async _getLatestLedger(): Promise<Api.RawGetLatestLedgerResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getLatestLedger\",\n );\n }\n\n /**\n * Submit a trial contract invocation to get back return values, expected\n * ledger footprint, expected authorizations, and expected costs.\n *\n * @param tx - the transaction to simulate,\n * which should include exactly one operation (one of\n * {@link xdr.InvokeHostFunctionOp}, {@link xdr.ExtendFootprintTtlOp}, or\n * {@link xdr.RestoreFootprintOp}). Any provided footprint or auth\n * information will be ignored.\n * @param addlResources - (optional) any additional resources\n * to add to the simulation-provided ones, for example if you know you will\n * need extra CPU instructions\n * @param authMode - (optional) optionally, specify the type of\n * auth mode to use for simulation: `enforce` for enforcement mode,\n * `record` for recording mode, or `record_allow_nonroot` for recording\n * mode that allows non-root authorization\n *\n * @returns An object with the\n * cost, footprint, result/auth requirements (if applicable), and error of\n * the transaction\n *\n * @see\n * {@link https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/operations-and-transactions | transaction docs}\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction | simulateTransaction docs}\n * @see\n * {@link https://developers.stellar.org/docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation#authorization | authorization modes}\n * @see module:rpc.Server#prepareTransaction\n * @see module:rpc.assembleTransaction\n *\n * @example\n * ```ts\n * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';\n * const contract = new StellarSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = StellarSdk.BASE_FEE;\n * const transaction = new StellarSdk.TransactionBuilder(account, { fee })\n * // Uncomment the following line to build transactions for the live network. Be\n * // sure to also change the horizon hostname.\n * //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)\n * .setTimeout(30) // valid for the next 30s\n * // Add an operation to call increment() on the contract\n * .addOperation(contract.call(\"increment\"))\n * .build();\n *\n * server.simulateTransaction(transaction).then((sim) => {\n * console.log(\"cost:\", sim.cost);\n * console.log(\"result:\", sim.result);\n * console.log(\"error:\", sim.error);\n * console.log(\"latestLedger:\", sim.latestLedger);\n * });\n * ```\n */\n\n public async simulateTransaction(\n tx: Transaction | FeeBumpTransaction,\n addlResources?: RpcServer.ResourceLeeway,\n authMode?: Api.SimulationAuthMode,\n ): Promise<Api.SimulateTransactionResponse> {\n return this._simulateTransaction(tx, addlResources, authMode).then(\n parseRawSimulation,\n );\n }\n\n public async _simulateTransaction(\n transaction: Transaction | FeeBumpTransaction,\n addlResources?: RpcServer.ResourceLeeway,\n authMode?: Api.SimulationAuthMode,\n ): Promise<Api.RawSimulateTransactionResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"simulateTransaction\",\n {\n transaction: transaction.toXDR(),\n authMode,\n ...(addlResources !== undefined && {\n resourceConfig: {\n instructionLeeway: addlResources.cpuInstructions,\n },\n }),\n },\n );\n }\n\n /**\n * Submit a trial contract invocation, first run a simulation of the contract\n * invocation as defined on the incoming transaction, and apply the results to\n * a new copy of the transaction which is then returned. Setting the ledger\n * footprint and authorization, so the resulting transaction is ready for\n * signing & sending.\n *\n * The returned transaction will also have an updated fee that is the sum of\n * fee set on incoming transaction with the contract resource fees estimated\n * from simulation. It is advisable to check the fee on returned transaction\n * and validate or take appropriate measures for interaction with user to\n * confirm it is acceptable.\n *\n * You can call the {@link rpc.Server.simulateTransaction} method\n * directly first if you want to inspect estimated fees for a given\n * transaction in detail first, then re-assemble it manually or via\n * {@link rpc.assembleTransaction}.\n *\n * @param tx - the transaction to\n * prepare. It should include exactly one operation, which must be one of\n * {@link xdr.InvokeHostFunctionOp}, {@link xdr.ExtendFootprintTtlOp},\n * or {@link xdr.RestoreFootprintOp}.\n *\n * Any provided footprint will be overwritten. However, if your operation\n * has existing auth entries, they will be preferred over ALL auth entries\n * from the simulation. In other words, if you include auth entries, you\n * don't care about the auth returned from the simulation. Other fields\n * (footprint, etc.) will be filled as normal.\n * @returns A copy of the\n * transaction with the expected authorizations (in the case of\n * invocation), resources, and ledger footprints added. The transaction fee\n * will also automatically be padded with the contract's minimum resource\n * fees discovered from the simulation.\n * @throws * If simulation fails\n *\n * @see module:rpc.assembleTransaction\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction | simulateTransaction docs}\n *\n * @example\n * ```ts\n * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';\n * const contract = new StellarSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = StellarSdk.BASE_FEE;\n * const transaction = new StellarSdk.TransactionBuilder(account, { fee })\n * // Uncomment the following line to build transactions for the live network. Be\n * // sure to also change the horizon hostname.\n * //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)\n * .setTimeout(30) // valid for the next 30s\n * // Add an operation to call increment() on the contract\n * .addOperation(contract.call(\"increment\"))\n * .build();\n *\n * const preparedTransaction = await server.prepareTransaction(transaction);\n *\n * // Sign this transaction with the secret key\n * // NOTE: signing is transaction is network specific. Test network transactions\n * // won't work in the public network. To switch networks, use the Network object\n * // as explained above (look for StellarSdk.Network).\n * const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);\n * preparedTransaction.sign(sourceKeypair);\n *\n * server.sendTransaction(transaction).then(result => {\n * console.log(\"hash:\", result.hash);\n * console.log(\"status:\", result.status);\n * console.log(\"errorResultXdr:\", result.errorResultXdr);\n * });\n * ```\n */\n public async prepareTransaction(tx: Transaction | FeeBumpTransaction) {\n const simResponse = await this.simulateTransaction(tx);\n if (Api.isSimulationError(simResponse)) {\n throw new Error(simResponse.error);\n }\n\n return assembleTransaction(tx, simResponse).build();\n }\n\n /**\n * Submit a real transaction to the Stellar network.\n *\n * Unlike Horizon, RPC does not wait for transaction completion. It\n * simply validates the transaction and enqueues it. Clients should call\n * {@link rpc.Server.getTransaction} to learn about transaction\n * success/failure.\n *\n * @param transaction - to submit\n * @returns the\n * transaction id, status, and any error if available\n *\n * @see {@link https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/operations-and-transactions | transaction docs}\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/sendTransaction | sendTransaction docs}\n *\n * @example\n * ```ts\n * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';\n * const contract = new StellarSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = StellarSdk.BASE_FEE;\n * const transaction = new StellarSdk.TransactionBuilder(account, { fee })\n * // Uncomment the following line to build transactions for the live network. Be\n * // sure to also change the horizon hostname.\n * //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)\n * .setTimeout(30) // valid for the next 30s\n * // Add an operation to call increment() on the contract\n * .addOperation(contract.call(\"increment\"))\n * .build();\n *\n * // Sign this transaction with the secret key\n * // NOTE: signing is transaction is network specific. Test network transactions\n * // won't work in the public network. To switch networks, use the Network object\n * // as explained above (look for StellarSdk.Network).\n * const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);\n * transaction.sign(sourceKeypair);\n *\n * server.sendTransaction(transaction).then((result) => {\n * console.log(\"hash:\", result.hash);\n * console.log(\"status:\", result.status);\n * console.log(\"errorResultXdr:\", result.errorResultXdr);\n * });\n * ```\n */\n public async sendTransaction(\n transaction: Transaction | FeeBumpTransaction,\n ): Promise<Api.SendTransactionResponse> {\n return this._sendTransaction(transaction).then(parseRawSendTransaction);\n }\n\n public async _sendTransaction(\n transaction: Transaction | FeeBumpTransaction,\n ): Promise<Api.RawSendTransactionResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"sendTransaction\",\n {\n transaction: transaction.toXDR(),\n },\n );\n }\n\n /**\n * Fund a new account using the network's Friendbot faucet, if any.\n *\n * @param address - The address or account instance that we\n * want to create and fund with Friendbot\n * @param friendbotUrl - (optional) Optionally, an explicit address for\n * friendbot (by default: this calls the Soroban RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's Friendbot url).\n * @returns An {@link Account} object for the created\n * account, or the existing account if it's already funded with the\n * populated sequence number (note that the account will not be \"topped\n * off\" if it already exists)\n * @throws If Friendbot is not configured on this network or request failure\n *\n * @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}\n * @see {@link Friendbot.Api.Response}\n *\n * @deprecated Use {@link Server.fundAddress} instead, which supports both\n * account (G...) and contract (C...) addresses.\n *\n * @example\n * ```ts\n * server\n * .requestAirdrop(\"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\")\n * .then((accountCreated) => {\n * console.log(\"accountCreated:\", accountCreated);\n * }).catch((error) => {\n * console.error(\"error:\", error);\n * });\n * ```\n */\n public async requestAirdrop(\n address: string | Pick<Account, \"accountId\">,\n friendbotUrl?: string,\n ): Promise<Account> {\n const account = typeof address === \"string\" ? address : address.accountId();\n friendbotUrl = friendbotUrl || (await this.getNetwork()).friendbotUrl;\n if (!friendbotUrl) {\n throw new Error(\"No friendbot URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FriendbotApi.Response>(\n `${friendbotUrl}?addr=${encodeURIComponent(account)}`,\n );\n\n let meta: xdr.TransactionMeta;\n if (!response.data.result_meta_xdr) {\n const txMeta = await this.getTransaction(response.data.hash);\n if (txMeta.status !== Api.GetTransactionStatus.SUCCESS) {\n throw new Error(`Funding account ${address} failed`);\n }\n meta = txMeta.resultMetaXdr;\n } else {\n meta = xdr.TransactionMeta.fromXDR(\n response.data.result_meta_xdr,\n \"base64\",\n );\n }\n\n const sequence = findCreatedAccountSequenceInTransactionMeta(meta);\n return new Account(account, sequence);\n } catch (error: any) {\n if (error.response?.status === 400) {\n if (\n error.response.data?.detail?.includes(\"createAccountAlreadyExist\")\n ) {\n // Account already exists, load the sequence number\n return this.getAccount(account);\n }\n }\n throw error;\n }\n }\n\n /**\n * Fund an address using the network's Friendbot faucet, if any.\n *\n * This method supports both account (G...) and contract (C...) addresses.\n *\n * @param address - The address to fund. Can be either a Stellar\n * account (G...) or contract (C...) address.\n * @param friendbotUrl - (optional) Optionally, an explicit Friendbot URL\n * (by default: this calls the Stellar RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's Friendbot url).\n * @returns The transaction\n * response from the Friendbot funding transaction.\n * @throws If Friendbot is not configured on this network or the\n * funding transaction fails.\n *\n * @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}\n *\n * @example\n * ```ts\n * // Funding an account (G... address)\n * const tx = await server.fundAddress(\"GBZC6Y2Y7...\");\n * console.log(\"Funded! Hash:\", tx.txHash);\n * // If you need the Account object:\n * const account = await server.getAccount(\"GBZC6Y2Y7...\");\n * ```\n *\n * @example\n * ```ts\n * // Funding a contract (C... address)\n * const tx = await server.fundAddress(\"CBZC6Y2Y7...\");\n * console.log(\"Contract funded! Hash:\", tx.txHash);\n * ```\n */\n public async fundAddress(\n address: string,\n friendbotUrl?: string,\n ): Promise<Api.GetSuccessfulTransactionResponse> {\n if (\n !StrKey.isValidEd25519PublicKey(address) &&\n !StrKey.isValidContract(address)\n ) {\n throw new Error(\n `Invalid address: ${address}. Expected a Stellar account (G...) or contract (C...) address.`,\n );\n }\n\n friendbotUrl = friendbotUrl || (await this.getNetwork()).friendbotUrl;\n if (!friendbotUrl) {\n throw new Error(\"No friendbot URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FriendbotApi.Response>(\n `${friendbotUrl}?addr=${encodeURIComponent(address)}`,\n );\n\n const txResponse = await this.getTransaction(response.data.hash);\n if (txResponse.status !== Api.GetTransactionStatus.SUCCESS) {\n throw new Error(\n `Funding address ${address} failed: transaction status ${txResponse.status}`,\n );\n }\n\n return txResponse;\n } catch (error: any) {\n if (error.response?.status === 400) {\n throw new Error(error.response.data?.detail ?? \"Bad Request\");\n }\n throw error;\n }\n }\n\n /**\n * Provides an analysis of the recent fee stats for regular and smart\n * contract operations.\n *\n * @returns the fee stats\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getFeeStats\n */\n public async getFeeStats(): Promise<Api.GetFeeStatsResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getFeeStats\",\n );\n }\n\n /**\n * Provides information about the current version details of the Soroban RPC and captive-core\n *\n * @returns the version info\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getVersionInfo\n */\n public async getVersionInfo(): Promise<Api.GetVersionInfoResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getVersionInfo\",\n );\n }\n\n /**\n * Returns a contract's balance of a particular SAC asset, if any.\n *\n * This is a convenience wrapper around {@link Server.getLedgerEntries}.\n *\n * @param address - the contract (string `C...`) whose balance of\n * `sac` you want to know\n * @param sac - the built-in SAC token (e.g. `USDC:GABC...`) that\n * you are querying from the given `contract`.\n * @param networkPassphrase - (optional) optionally, the network passphrase to\n * which this token applies. If omitted, a request about network\n * information will be made (see {@link getNetwork}), since contract IDs\n * for assets are specific to a network. You can refer to {@link Networks}\n * for a list of built-in passphrases, e.g., `Networks.TESTNET`.\n *\n * @returns , which will contain the balance\n * entry details if and only if the request returned a valid balance ledger\n * entry. If it doesn't, the `balanceEntry` field will not exist.\n *\n * @throws If `address` is not a valid contract ID (C...).\n *\n * @see getLedgerEntries\n * @see https://developers.stellar.org/docs/tokens/stellar-asset-contract\n *\n * @deprecated Use {@link getAssetBalance}, instead\n * @example\n * ```ts\n * // assume `address` is some contract or account with an XLM balance\n * // assume server is an instantiated `Server` instance.\n * const entry = (await server.getSACBalance(\n * new Address(address),\n * Asset.native(),\n * Networks.PUBLIC\n * ));\n *\n * // assumes BigInt support:\n * console.log(\n * entry.balanceEntry ?\n * BigInt(entry.balanceEntry.amount) :\n * \"Address has no XLM\");\n * ```\n */\n public async getSACBalance(\n address: string | Address,\n sac: Asset,\n networkPassphrase?: string,\n ): Promise<Api.BalanceResponse> {\n const addressString =\n address instanceof Address ? address.toString() : address;\n\n if (!StrKey.isValidContract(addressString)) {\n throw new TypeError(`expected contract ID, got ${addressString}`);\n }\n\n // Call out to RPC if passphrase isn't provided.\n const passphrase: string =\n networkPassphrase ?? (await this.getNetwork().then((n) => n.passphrase));\n\n // Turn SAC into predictable contract ID\n const sacId = sac.contractId(passphrase);\n\n // Rust union enum type with \"Balance(ScAddress)\" structure\n const key = nativeToScVal([\"Balance\", addressString], {\n type: [\"symbol\", \"address\"],\n });\n\n // Note a quirk here: the contract address in the key is the *token*\n // rather than the *holding contract*. This is because each token stores a\n // balance entry for each contract, not the other way around (i.e. XLM\n // holds a reserve for contract X, rather that contract X having a balance\n // of N XLM).\n const ledgerKey = xdr.LedgerKey.contractData(\n new xdr.LedgerKeyContractData({\n contract: new Address(sacId).toScAddress(),\n durability: xdr.ContractDataDurability.persistent(),\n key,\n }),\n );\n\n const response = await this.getLedgerEntries(ledgerKey);\n if (response.entries.length === 0) {\n return { latestLedger: response.latestLedger };\n }\n\n const { lastModifiedLedgerSeq, liveUntilLedgerSeq, val } =\n response.entries[0];\n\n if (val.switch().value !== xdr.LedgerEntryType.contractData().value) {\n return { latestLedger: response.latestLedger };\n }\n\n const entry = scValToNative(val.contractData().val());\n\n // Since we are requesting a SAC's contract data, we know for a fact that\n // it should follow the expected structure format. Thus, we can presume\n // these fields exist:\n return {\n latestLedger: response.latestLedger,\n balanceEntry: {\n liveUntilLedgerSeq,\n lastModifiedLedgerSeq,\n amount: entry.amount.toString(),\n authorized: entry.authorized,\n clawback: entry.clawback,\n },\n };\n }\n\n /**\n * Fetch a detailed list of ledgers starting from a specified point.\n *\n * Returns ledger data with support for pagination as long as the requested\n * pages fall within the history retention of the RPC provider.\n *\n * @param request - The request parameters for fetching ledgers. {@link Api.GetLedgersRequest}\n * @returns A promise that resolves to the\n * ledgers response containing an array of ledger data and pagination info. {@link Api.GetLedgersResponse}\n *\n * @throws If startLedger is less than the oldest ledger stored in this\n * node, or greater than the latest ledger seen by this node.\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers docs}\n *\n * @example\n * ```ts\n * // Fetch ledgers starting from a specific sequence number\n * server.getLedgers({\n * startLedger: 36233,\n * pagination: {\n * limit: 10\n * }\n * }).then((response) => {\n * console.log(\"Ledgers:\", response.ledgers);\n * console.log(\"Latest Ledger:\", response.latestLedger);\n * console.log(\"Cursor:\", response.cursor);\n * });\n * ```\n *\n * @example\n * ```ts\n * // Paginate through ledgers using cursor\n * const firstPage = await server.getLedgers({\n * startLedger: 36233,\n * pagination: {\n * limit: 5\n * }\n * });\n *\n * const nextPage = await server.getLedgers({\n * pagination: {\n * cursor: firstPage.cursor,\n * limit: 5\n * }\n * });\n * ```\n */\n\n public async getLedgers(\n request: Api.GetLedgersRequest,\n ): Promise<Api.GetLedgersResponse> {\n return this._getLedgers(request).then((raw) => {\n const result: Api.GetLedgersResponse = {\n ledgers: (raw.ledgers || []).map(parseRawLedger),\n latestLedger: raw.latestLedger,\n latestLedgerCloseTime: raw.latestLedgerCloseTime,\n oldestLedger: raw.oldestLedger,\n oldestLedgerCloseTime: raw.oldestLedgerCloseTime,\n cursor: raw.cursor,\n };\n return result;\n });\n }\n\n public async _getLedgers(\n request: Api.GetLedgersRequest,\n ): Promise<Api.RawGetLedgersResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getLedgers\",\n request,\n );\n }\n}\n"],"names":["Durability","xdr","createHttpClient","Account","Keypair","StrKey","buffer","Buffer","address","Address","Contract","jsonrpc.postObject","contract","parseRawLedgerEntries","Api","Utils","parseTransactionInfo","parseRawTransactions","parseRawEvents","parseRawLatestLedger","parseRawSimulation","assembleTransaction","parseRawSendTransaction","account","nativeToScVal","scValToNative","parseRawLedger"],"mappings":";;;;;;;;;;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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmDA,MAAa,WACX,OAAA,EACiC;AACjC,IAAA,OAAO,KAAK,WAAA,CAAY,OAAO,CAAA,CAAE,IAAA,CAAK,CAAC,GAAA,KAAQ;AAC7C,MAAA,MAAM,MAAA,GAAiC;AAAA,QACrC,UAAU,GAAA,CAAI,OAAA,IAAW,EAAC,EAAG,IAAIC,sBAAc,CAAA;AAAA,QAC/C,cAAc,GAAA,CAAI,YAAA;AAAA,QAClB,uBAAuB,GAAA,CAAI,qBAAA;AAAA,QAC3B,cAAc,GAAA,CAAI,YAAA;AAAA,QAClB,uBAAuB,GAAA,CAAI,qBAAA;AAAA,QAC3B,QAAQ,GAAA,CAAI;AAAA,OACd;AACA,MAAA,OAAO,MAAA;AAAA,IACT,CAAC,CAAA;AAAA,EACH;AAAA,EAEA,MAAa,YACX,OAAA,EACoC;AACpC,IAAA,OAAOf,kBAAQ;AAAA,MACb,IAAA,CAAK,UAAA;AAAA,MACL,IAAA,CAAK,UAAU,QAAA,EAAS;AAAA,MACxB,YAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"server.js","sources":["../../../src/rpc/server.ts"],"sourcesContent":["/* tslint:disable:variable-name no-namespace */\nimport {\n Account,\n Address,\n Asset,\n Contract,\n FeeBumpTransaction,\n Keypair,\n StrKey,\n Transaction,\n nativeToScVal,\n scValToNative,\n xdr,\n} from \"../base/index.js\";\n\nimport type { TransactionBuilder } from \"../base/index.js\";\nimport type { Config } from \"../config.js\";\nimport { createHttpClient } from \"./axios.js\";\nimport type { Api as FriendbotApi } from \"../friendbot/index.js\";\nimport * as jsonrpc from \"./jsonrpc.js\";\nimport { Api } from \"./api.js\";\nimport { assembleTransaction } from \"./transaction.js\";\nimport {\n parseRawSendTransaction,\n parseRawSimulation,\n parseRawLedgerEntries,\n parseRawEvents,\n parseRawTransactions,\n parseTransactionInfo,\n parseRawLedger,\n parseRawLatestLedger,\n} from \"./parsers.js\";\nimport { Utils } from \"../utils.js\";\nimport type { HttpClient } from \"../http-client/index.js\";\n\n/**\n * Default transaction submission timeout for RPC requests, in milliseconds\n * @defaultValue 60000\n */\nexport const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000;\n\n/**\n * Specifies the durability namespace of contract-related ledger entries.\n *\n * @see {@link https://developers.stellar.org/docs/learn/smart-contract-internals/state-archival | State Archival docs}\n * @see {@link https://docs.rs/soroban-sdk/latest/soroban_sdk/storage/struct.Storage.html | Rust SDK Storage docs}\n */\nexport enum Durability {\n Temporary = \"temporary\",\n Persistent = \"persistent\",\n}\n\nexport namespace RpcServer {\n /**\n * @deprecated Use `Api.GetEventsRequest` instead.\n * @see {@link Api.GetEventsRequest}\n */\n export type GetEventsRequest = Api.GetEventsRequest;\n\n export interface PollingOptions {\n attempts?: number;\n sleepStrategy?: SleepStrategy;\n }\n\n /**\n * Describes additional resource leeways for transaction simulation.\n */\n export interface ResourceLeeway {\n /** Simulate the transaction with more CPU instructions available. */\n cpuInstructions: number;\n }\n\n /**\n * Options for configuring connections to RPC servers.\n */\n export interface Options {\n /** Allow connecting to http servers, default: `false`. This must be set to false in production deployments! */\n allowHttp?: boolean;\n /** Allow a timeout, default: 0. Allows user to avoid nasty lag. */\n timeout?: number;\n /** Additional headers that should be added to any requests to the RPC server. */\n headers?: Record<string, string>;\n }\n}\n\nconst DEFAULT_GET_TRANSACTION_TIMEOUT: number = 30;\n\n/// A strategy that will sleep 1 second each time\n\nexport const BasicSleepStrategy: SleepStrategy = (_iter: number) => 1000;\n\n/// A strategy that will sleep 1 second longer on each attempt\nexport const LinearSleepStrategy: SleepStrategy = (iter: number) => 1000 * iter;\n\n/**\n * A function that returns the number of *milliseconds* to sleep\n * on a given `iter`ation.\n */\nexport type SleepStrategy = (iter: number) => number;\n\nfunction findCreatedAccountSequenceInTransactionMeta(\n meta: xdr.TransactionMeta,\n): string {\n let operations: xdr.OperationMeta[] = [];\n switch (meta.switch()) {\n case 0:\n operations = meta.operations();\n break;\n case 1:\n case 2:\n case 3:\n case 4: // all four have the same interface\n operations = (meta.value() as xdr.TransactionMetaV4).operations();\n break;\n default:\n throw new Error(\"Unexpected transaction meta switch value\");\n }\n const sequenceNumber = operations\n .flatMap((op) => op.changes())\n .find(\n (c) =>\n c.switch() === xdr.LedgerEntryChangeType.ledgerEntryCreated() &&\n c.created().data().switch() === xdr.LedgerEntryType.account(),\n )\n ?.created()\n ?.data()\n ?.account()\n ?.seqNum()\n ?.toString();\n\n if (sequenceNumber) {\n return sequenceNumber;\n }\n throw new Error(\"No account created in transaction\");\n}\n\n/**\n * Handles the network connection to a Soroban RPC instance, exposing an\n * interface for requests to that instance.\n *\n *\n * @param serverURL - Soroban-RPC Server URL (ex. `http://localhost:8000/soroban/rpc`).\n * @param opts - (optional) Options object\n * - `allowHttp` (optional): Allows connecting to insecure http servers\n * (default: `false`). This must be set to false in production deployments!\n * You can also use {@link Config} class to set this globally.\n * - `headers` (optional): Allows setting custom headers\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods | API reference docs}\n */\nexport class RpcServer {\n public readonly serverURL: URL;\n /**\n * HTTP client instance for making requests to Horizon.\n * Exposes interceptors, defaults, and other configuration options.\n *\n * @example\n * ```ts\n * // Add authentication header\n * server.httpClient.defaults.headers['Authorization'] = 'Bearer token';\n *\n * // Add request interceptor\n * server.httpClient.interceptors.request.use((config) => {\n * console.log('Request:', config.url);\n * return config;\n * });\n * ```\n */\n public readonly httpClient: HttpClient;\n constructor(serverURL: string, opts: RpcServer.Options = {}) {\n /**\n * RPC Server URL (ex. `http://localhost:8000/soroban/rpc`).\n */\n this.serverURL = new URL(serverURL);\n this.httpClient = createHttpClient(opts.headers);\n if (this.serverURL.protocol !== \"https:\" && !opts.allowHttp) {\n throw new Error(\n \"Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set\",\n );\n }\n }\n\n /**\n * Fetch a minimal set of current info about a Stellar account.\n *\n * Needed to get the current sequence number for the account so you can build\n * a successful transaction with {@link TransactionBuilder}.\n *\n * @param address - The public address of the account to load.\n * @returns A promise which resolves to the {@link Account}\n * object with a populated sequence number\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const accountId = \"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\";\n * server.getAccount(accountId).then((account) => {\n * console.log(\"sequence:\", account.sequence);\n * });\n * ```\n */\n public async getAccount(address: string): Promise<Account> {\n const entry = await this.getAccountEntry(address);\n return new Account(address, entry.seqNum().toString());\n }\n\n /**\n * Fetch the full account entry for a Stellar account.\n *\n * @param address - The public address of the account to load.\n * @returns Resolves to the full on-chain account\n * entry\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const accountId = \"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\";\n * server.getAccountEntry(accountId).then((account) => {\n * console.log(\"sequence:\", account.balance().toString());\n * });\n * ```\n */\n public async getAccountEntry(address: string): Promise<xdr.AccountEntry> {\n const ledgerKey = xdr.LedgerKey.account(\n new xdr.LedgerKeyAccount({\n accountId: Keypair.fromPublicKey(address).xdrPublicKey(),\n }),\n );\n\n try {\n const resp = await this.getLedgerEntry(ledgerKey);\n return resp.val.account();\n } catch {\n throw new Error(`Account not found: ${address}`);\n }\n }\n\n /**\n * Fetch the full trustline entry for a Stellar account.\n *\n * @param account - The public address of the account whose trustline it is\n * @param asset - The trustline's asset\n * @returns Resolves to the full on-chain trustline\n * entry\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @deprecated Use {@link getAssetBalance}, instead\n * @example\n * ```ts\n * const accountId = \"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\";\n * const asset = new Asset(\n * \"USDC\",\n * \"GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5\"\n * );\n * server.getTrustline(accountId, asset).then((entry) => {\n * console.log(`{asset.toString()} balance for ${accountId}:\", entry.balance().toString());\n * });\n * ```\n */\n public async getTrustline(\n account: string,\n asset: Asset,\n ): Promise<xdr.TrustLineEntry> {\n const trustlineLedgerKey = xdr.LedgerKey.trustline(\n new xdr.LedgerKeyTrustLine({\n accountId: Keypair.fromPublicKey(account).xdrAccountId(),\n asset: asset.toTrustLineXDRObject(),\n }),\n );\n\n try {\n const entry = await this.getLedgerEntry(trustlineLedgerKey);\n return entry.val.trustLine();\n } catch {\n throw new Error(\n `Trustline for ${asset.getCode()}:${asset.getIssuer()} not found for ${account}`,\n );\n }\n }\n\n /**\n * Fetch the full claimable balance entry for a Stellar account.\n *\n * @param id - The strkey (`B...`) or hex (`00000000abcde...`) (both\n * IDs with and without the 000... version prefix are accepted) of the\n * claimable balance to load\n * @returns Resolves to the full on-chain\n * claimable balance entry\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const id = \"00000000178826fbfe339e1f5c53417c6fedfe2c05e8bec14303143ec46b38981b09c3f9\";\n * server.getClaimableBalance(id).then((entry) => {\n * console.log(`Claimable balance {id.substr(0, 12)} has:`);\n * console.log(` asset: ${Asset.fromXDRObject(entry.asset()).toString()}`;\n * console.log(` amount: ${entry.amount().toString()}`;\n * });\n * ```\n */\n public async getClaimableBalance(\n id: string,\n ): Promise<xdr.ClaimableBalanceEntry> {\n let balanceId;\n if (StrKey.isValidClaimableBalance(id)) {\n const buffer = StrKey.decodeClaimableBalance(id);\n\n // Pad the version byte to be a full int32 like in the XDR spec\n const v = Buffer.concat([\n Buffer.from(\"\\x00\\x00\\x00\"),\n buffer.subarray(0, 1),\n ]);\n\n // Slap on the rest of it and decode it\n balanceId = xdr.ClaimableBalanceId.fromXDR(\n Buffer.concat([v, buffer.subarray(1)]),\n );\n } else if (id.match(/[a-f0-9]{72}/i)) {\n balanceId = xdr.ClaimableBalanceId.fromXDR(id, \"hex\");\n } else if (id.match(/[a-f0-9]{64}/i)) {\n balanceId = xdr.ClaimableBalanceId.fromXDR(id.padStart(72, \"0\"), \"hex\");\n } else {\n throw new TypeError(`expected 72-char hex ID or strkey, not ${id}`);\n }\n\n const trustlineLedgerKey = xdr.LedgerKey.claimableBalance(\n new xdr.LedgerKeyClaimableBalance({ balanceId }),\n );\n\n try {\n const entry = await this.getLedgerEntry(trustlineLedgerKey);\n return entry.val.claimableBalance();\n } catch {\n throw new Error(`Claimable balance ${id} not found`);\n }\n }\n\n /**\n * Fetch the balance of an asset held by an account or contract.\n *\n * The `address` argument may be provided as a string (as a {@link StrKey}),\n * {@link Address}, or {@link Contract}.\n *\n * @param address - The account or contract whose\n * balance should be fetched.\n * @param asset - The asset whose balance you want to inspect.\n * @param networkPassphrase - (optional) optionally, when requesting the\n * balance of a contract, the network passphrase to which this token\n * applies. If omitted and necessary, a request about network information\n * will be made (see {@link getNetwork}), since contract IDs for assets are\n * specific to a network. You can refer to {@link Networks} for a list of\n * built-in passphrases, e.g., `Networks.TESTNET`.\n * @returns Resolves with balance entry details\n * when available.\n *\n * @throws If the supplied `address` is not a valid account or\n * contract strkey.\n *\n * @example\n * ```ts\n * const usdc = new Asset(\n * \"USDC\",\n * \"GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5\"\n * );\n * const balance = await server.getAssetBalance(\"GD...\", usdc);\n * console.log(balance.balanceEntry?.amount);\n * ```\n */\n public async getAssetBalance(\n address: string | Address | Contract,\n asset: Asset,\n networkPassphrase?: string,\n ): Promise<Api.BalanceResponse> {\n let addr: string = address as string;\n // Coalesce to a strkey\n if (typeof address === \"string\") {\n addr = address;\n } else if (address instanceof Address) {\n addr = address.toString();\n } else if (address instanceof Contract) {\n addr = address.toString();\n } else {\n // shouldn't happen, but be defensive\n throw new TypeError(`invalid address: ${address}`);\n }\n\n if (StrKey.isValidEd25519PublicKey(addr)) {\n const [tl, ll] = await Promise.all([\n this.getTrustline(addr, asset),\n this.getLatestLedger(),\n ]);\n\n return {\n latestLedger: ll.sequence,\n balanceEntry: {\n amount: tl.balance().toString(),\n // Extract actual flags from the coalesced value.\n authorized: Boolean(tl.flags() & 0x1), // AUTHORIZED_FLAG\n clawback: Boolean(tl.flags() & 0x4), // TRUSTLINE_CLAWBACK_ENABLED_FLAG\n authorizedToMaintainLiabilities: Boolean(tl.flags() & 0x2), // AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG\n revocable: Boolean(tl.flags() & 0x2), // AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG (deprecated, will be removed in a future major release)\n },\n };\n } else if (StrKey.isValidContract(addr)) {\n return this.getSACBalance(addr, asset, networkPassphrase);\n }\n\n throw new Error(`invalid address: ${address}`);\n }\n\n /**\n * General node health check.\n *\n * @returns A promise which resolves to the\n * {@link Api.GetHealthResponse} object with the status of the\n * server (e.g. \"healthy\").\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getHealth | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * server.getHealth().then((health) => {\n * console.log(\"status:\", health.status);\n * });\n * ```\n */\n\n public async getHealth(): Promise<Api.GetHealthResponse> {\n return jsonrpc.postObject<Api.GetHealthResponse>(\n this.httpClient,\n this.serverURL.toString(),\n \"getHealth\",\n );\n }\n\n /**\n * Reads the current value of contract data ledger entries directly.\n *\n * Allows you to directly inspect the current state of a contract. This is a\n * backup way to access your contract data which may not be available via\n * events or {@link rpc.Server.simulateTransaction}.\n *\n * @param contract - The contract ID containing the\n * data to load as a strkey (`C...` form), a {@link Contract}, or an\n * {@link Address} instance\n * @param key - The key of the contract data to load\n * @param durability - (optional) The \"durability\n * keyspace\" that this ledger key belongs to, which is either 'temporary'\n * or 'persistent' (the default), see {@link rpc.Durability}.\n * @returns The current data value\n *\n * **Warning:** If the data entry in question is a 'temporary' entry, it's\n * entirely possible that it has expired out of existence.\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n *\n * @example\n * ```ts\n * const contractId = \"CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5\";\n * const key = xdr.ScVal.scvSymbol(\"counter\");\n * server.getContractData(contractId, key, Durability.Temporary).then(data => {\n * console.log(\"value:\", data.val);\n * console.log(\"liveUntilLedgerSeq:\", data.liveUntilLedgerSeq);\n * console.log(\"lastModified:\", data.lastModifiedLedgerSeq);\n * console.log(\"latestLedger:\", data.latestLedger);\n * });\n * ```\n */\n\n public async getContractData(\n contract: string | Address | Contract,\n key: xdr.ScVal,\n durability: Durability = Durability.Persistent,\n ): Promise<Api.LedgerEntryResult> {\n // coalesce `contract` param variants to an ScAddress\n let scAddress: xdr.ScAddress;\n if (typeof contract === \"string\") {\n scAddress = new Contract(contract).address().toScAddress();\n } else if (contract instanceof Address) {\n scAddress = contract.toScAddress();\n } else if (contract instanceof Contract) {\n scAddress = contract.address().toScAddress();\n } else {\n throw new TypeError(`unknown contract type: ${contract}`);\n }\n\n let xdrDurability: xdr.ContractDataDurability;\n switch (durability) {\n case Durability.Temporary:\n xdrDurability = xdr.ContractDataDurability.temporary();\n break;\n\n case Durability.Persistent:\n xdrDurability = xdr.ContractDataDurability.persistent();\n break;\n\n default:\n throw new TypeError(`invalid durability: ${durability}`);\n }\n\n const contractKey = xdr.LedgerKey.contractData(\n new xdr.LedgerKeyContractData({\n key,\n contract: scAddress,\n durability: xdrDurability,\n }),\n );\n\n try {\n return await this.getLedgerEntry(contractKey);\n } catch {\n throw {\n code: 404,\n message: `Contract data not found for ${Address.fromScAddress(\n scAddress,\n ).toString()} with key ${key.toXDR(\"base64\")} and durability: ${durability}`,\n };\n }\n }\n\n /**\n * Retrieves the WASM bytecode for a given contract.\n *\n * This method allows you to fetch the WASM bytecode associated with a contract\n * deployed on the Soroban network. The WASM bytecode represents the executable\n * code of the contract.\n *\n * @param contractId - The contract ID containing the WASM bytecode to retrieve\n * @returns A Buffer containing the WASM bytecode\n * @throws If the contract or its associated WASM bytecode cannot be\n * found on the network.\n *\n * @example\n * ```ts\n * const contractId = \"CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5\";\n * server.getContractWasmByContractId(contractId).then(wasmBuffer => {\n * console.log(\"WASM bytecode length:\", wasmBuffer.length);\n * // ... do something with the WASM bytecode ...\n * }).catch(err => {\n * console.error(\"Error fetching WASM bytecode:\", err);\n * });\n * ```\n */\n public async getContractWasmByContractId(\n contractId: string,\n ): Promise<Buffer> {\n const contractLedgerKey = new Contract(contractId).getFootprint();\n const response = await this.getLedgerEntries(contractLedgerKey);\n if (!response.entries.length || !response.entries[0]?.val) {\n return Promise.reject({\n code: 404,\n message: `Could not obtain contract hash from server`,\n });\n }\n\n const wasmHash = response.entries[0].val\n .contractData()\n .val()\n .instance()\n .executable()\n .wasmHash();\n\n return this.getContractWasmByHash(wasmHash);\n }\n\n /**\n * Retrieves the WASM bytecode for a given contract hash.\n *\n * This method allows you to fetch the WASM bytecode associated with a contract\n * deployed on the Soroban network using the contract's WASM hash. The WASM bytecode\n * represents the executable code of the contract.\n *\n * @param wasmHash - The WASM hash of the contract\n * @returns A Buffer containing the WASM bytecode\n * @throws If the contract or its associated WASM bytecode cannot be\n * found on the network.\n *\n * @example\n * ```ts\n * const wasmHash = Buffer.from(\"...\");\n * server.getContractWasmByHash(wasmHash).then(wasmBuffer => {\n * console.log(\"WASM bytecode length:\", wasmBuffer.length);\n * // ... do something with the WASM bytecode ...\n * }).catch(err => {\n * console.error(\"Error fetching WASM bytecode:\", err);\n * });\n * ```\n */\n public async getContractWasmByHash(\n wasmHash: Buffer | string,\n format: undefined | \"hex\" | \"base64\" = undefined,\n ): Promise<Buffer> {\n const wasmHashBuffer =\n typeof wasmHash === \"string\"\n ? Buffer.from(wasmHash, format)\n : (wasmHash as Buffer);\n\n const ledgerKeyWasmHash = xdr.LedgerKey.contractCode(\n new xdr.LedgerKeyContractCode({\n hash: wasmHashBuffer,\n }),\n );\n\n const responseWasm = await this.getLedgerEntries(ledgerKeyWasmHash);\n if (!responseWasm.entries.length || !responseWasm.entries[0]?.val) {\n return Promise.reject({\n code: 404,\n message: \"Could not obtain contract wasm from server\",\n });\n }\n const wasmBuffer = responseWasm.entries[0].val.contractCode().code();\n\n return wasmBuffer;\n }\n\n /**\n * Reads the current value of arbitrary ledger entries directly.\n *\n * Allows you to directly inspect the current state of contracts, contract's\n * code, accounts, or any other ledger entries.\n *\n * To fetch a contract's WASM byte-code, built the appropriate\n * {@link xdr.LedgerKeyContractCode} ledger entry key (or see\n * {@link Contract.getFootprint}).\n *\n * @param keys - One or more ledger entry keys to load\n * @returns The current on-chain\n * values for the given ledger keys\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgerEntries | getLedgerEntries docs}\n * @see RpcServer._getLedgerEntries\n * @example\n * ```ts\n * const contractId = \"CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM\";\n * const key = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({\n * contractId: StrKey.decodeContract(contractId),\n * key: xdr.ScVal.scvSymbol(\"counter\"),\n * }));\n *\n * server.getLedgerEntries([key]).then(response => {\n * const ledgerData = response.entries[0];\n * console.log(\"key:\", ledgerData.key);\n * console.log(\"value:\", ledgerData.val);\n * console.log(\"liveUntilLedgerSeq:\", ledgerData.liveUntilLedgerSeq);\n * console.log(\"lastModified:\", ledgerData.lastModifiedLedgerSeq);\n * console.log(\"latestLedger:\", response.latestLedger);\n * });\n * ```\n */\n public getLedgerEntries(...keys: xdr.LedgerKey[]) {\n return this._getLedgerEntries(...keys).then(parseRawLedgerEntries);\n }\n\n public _getLedgerEntries(...keys: xdr.LedgerKey[]) {\n return jsonrpc.postObject<Api.RawGetLedgerEntriesResponse>(\n this.httpClient,\n this.serverURL.toString(),\n \"getLedgerEntries\",\n {\n keys: keys.map((k) => k.toXDR(\"base64\")),\n },\n );\n }\n\n public async getLedgerEntry(key: xdr.LedgerKey) {\n const results = await this._getLedgerEntries(key).then(\n parseRawLedgerEntries,\n );\n if (results.entries.length !== 1) {\n throw new Error(`failed to find an entry for key ${key.toXDR(\"base64\")}`);\n }\n return results.entries[0];\n }\n\n /**\n * Poll for a particular transaction with certain parameters.\n *\n * After submitting a transaction, clients can use this to poll for\n * transaction completion and return a definitive state of success or failure.\n *\n * @param hash - the transaction you're polling for\n * @param opts - (optional) polling options\n * - `attempts` (optional): (optional) the number of attempts to make\n * before returning the last-seen status. By default or on invalid inputs,\n * try 5 times.\n * - `sleepStrategy` (optional): (optional) the amount of time\n * to wait for between each attempt. By default, sleep for 1 second between\n * each attempt.\n *\n * @returns the response after a \"found\"\n * response (which may be success or failure) or the last response obtained\n * after polling the maximum number of specified attempts.\n *\n * @example\n * ```ts\n * const h = \"c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a\";\n * const txStatus = await server.pollTransaction(h, {\n * attempts: 100, // I'm a maniac\n * sleepStrategy: rpc.LinearSleepStrategy\n * }); // this will take 5,050 seconds to complete\n * ```\n */\n public async pollTransaction(\n hash: string,\n opts?: RpcServer.PollingOptions,\n ): Promise<Api.GetTransactionResponse> {\n const maxAttempts: number =\n (opts?.attempts ?? 0) < 1\n ? DEFAULT_GET_TRANSACTION_TIMEOUT\n : (opts?.attempts ?? DEFAULT_GET_TRANSACTION_TIMEOUT); // \"positive and defined user value or default\"\n\n let foundInfo: Api.GetTransactionResponse;\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n foundInfo = await this.getTransaction(hash);\n if (foundInfo.status !== Api.GetTransactionStatus.NOT_FOUND) {\n return foundInfo;\n }\n\n await Utils.sleep((opts?.sleepStrategy ?? BasicSleepStrategy)(attempt));\n }\n\n return foundInfo!;\n }\n\n /**\n * Fetch the details of a submitted transaction.\n *\n * After submitting a transaction, clients should poll this to tell when the\n * transaction has completed.\n *\n * @param hash - Hex-encoded hash of the transaction to check\n * @returns The status, result, and\n * other details about the transaction\n *\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction | getTransaction docs}\n *\n * @example\n * ```ts\n * const transactionHash = \"c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a\";\n * server.getTransaction(transactionHash).then((tx) => {\n * console.log(\"status:\", tx.status);\n * console.log(\"envelopeXdr:\", tx.envelopeXdr);\n * console.log(\"resultMetaXdr:\", tx.resultMetaXdr);\n * console.log(\"resultXdr:\", tx.resultXdr);\n * });\n * ```\n */\n\n public async getTransaction(\n hash: string,\n ): Promise<Api.GetTransactionResponse> {\n return this._getTransaction(hash).then((raw) => {\n const foundInfo: Omit<\n Api.GetSuccessfulTransactionResponse,\n keyof Api.GetMissingTransactionResponse\n > = {} as any;\n\n if (raw.status !== Api.GetTransactionStatus.NOT_FOUND) {\n Object.assign(foundInfo, parseTransactionInfo(raw));\n }\n\n const result: Api.GetTransactionResponse = {\n status: raw.status,\n txHash: hash,\n latestLedger: raw.latestLedger,\n latestLedgerCloseTime: raw.latestLedgerCloseTime,\n oldestLedger: raw.oldestLedger,\n oldestLedgerCloseTime: raw.oldestLedgerCloseTime,\n ...foundInfo,\n };\n\n return result;\n });\n }\n\n public async _getTransaction(\n hash: string,\n ): Promise<Api.RawGetTransactionResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getTransaction\",\n {\n hash,\n },\n );\n }\n\n /**\n * Fetch transactions starting from a given start ledger or a cursor. The end ledger is the latest ledger\n * in that RPC instance.\n *\n * @param request - The request parameters.\n * @returns - A promise that resolves to the transactions response.\n *\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransactions\n * @example\n * ```ts\n * server.getTransactions({\n * startLedger: 10000,\n * limit: 10,\n * }).then((response) => {\n * console.log(\"Transactions:\", response.transactions);\n * console.log(\"Latest Ledger:\", response.latestLedger);\n * console.log(\"Cursor:\", response.cursor);\n * });\n * ```\n */\n public async getTransactions(\n request: Api.GetTransactionsRequest,\n ): Promise<Api.GetTransactionsResponse> {\n return this._getTransactions(request).then(\n (raw: Api.RawGetTransactionsResponse) => {\n const result: Api.GetTransactionsResponse = {\n transactions: (raw.transactions || []).map(parseRawTransactions),\n latestLedger: raw.latestLedger,\n latestLedgerCloseTimestamp: raw.latestLedgerCloseTimestamp,\n oldestLedger: raw.oldestLedger,\n oldestLedgerCloseTimestamp: raw.oldestLedgerCloseTimestamp,\n cursor: raw.cursor,\n };\n return result;\n },\n );\n }\n\n async _getTransactions(\n request: Api.GetTransactionsRequest,\n ): Promise<Api.RawGetTransactionsResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getTransactions\",\n request,\n );\n }\n\n /**\n * Fetch all events that match a given set of filters.\n *\n * The given filters (see {@link Api.EventFilter}\n * for detailed fields) are combined only in a logical OR fashion, and all of\n * the fields in each filter are optional.\n *\n * To page through events, use the `pagingToken` field on the relevant\n * {@link Api.EventResponse} object to set the `cursor` parameter.\n *\n * @param request - Event filters {@link Api.GetEventsRequest},\n * @returns A paginatable set of the events\n * matching the given event filters\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getEvents | getEvents docs}\n *\n * @example\n * ```ts\n *\n * server.getEvents({\n * startLedger: 1000,\n * endLedger: 2000,\n * filters: [\n * {\n * type: \"contract\",\n * contractIds: [ \"deadb33f...\" ],\n * topics: [[ \"AAAABQAAAAh0cmFuc2Zlcg==\", \"AAAAAQB6Mcc=\", \"*\" ]]\n * }, {\n * type: \"system\",\n * contractIds: [ \"...c4f3b4b3...\" ],\n * topics: [[ \"*\" ], [ \"*\", \"AAAAAQB6Mcc=\" ]]\n * }, {\n * contractIds: [ \"...c4f3b4b3...\" ],\n * topics: [[ \"AAAABQAAAAh0cmFuc2Zlcg==\" ]]\n * }, {\n * type: \"diagnostic\",\n * topics: [[ \"AAAAAQB6Mcc=\" ]]\n * }\n * ],\n * limit: 10,\n * });\n * ```\n */\n\n public async getEvents(\n request: Api.GetEventsRequest,\n ): Promise<Api.GetEventsResponse> {\n return this._getEvents(request).then(parseRawEvents);\n }\n\n public async _getEvents(\n request: Api.GetEventsRequest,\n ): Promise<Api.RawGetEventsResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getEvents\",\n {\n filters: request.filters ?? [],\n pagination: {\n ...(request.cursor && { cursor: request.cursor }), // add if defined\n ...(request.limit && { limit: request.limit }),\n },\n ...(request.startLedger && {\n startLedger: request.startLedger,\n }),\n ...(request.endLedger && {\n endLedger: request.endLedger,\n }),\n },\n );\n }\n\n /**\n * Fetch metadata about the network this Soroban RPC server is connected to.\n *\n * @returns Metadata about the current\n * network this RPC server is connected to\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getNetwork | getNetwork docs}\n *\n * @example\n * ```ts\n * server.getNetwork().then((network) => {\n * console.log(\"friendbotUrl:\", network.friendbotUrl);\n * console.log(\"passphrase:\", network.passphrase);\n * console.log(\"protocolVersion:\", network.protocolVersion);\n * });\n * ```\n */\n\n public async getNetwork(): Promise<Api.GetNetworkResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getNetwork\",\n );\n }\n\n /**\n * Fetch the latest ledger meta info from network which this Soroban RPC\n * server is connected to.\n *\n * @returns metadata about the\n * latest ledger on the network that this RPC server is connected to\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLatestLedger | getLatestLedger docs}\n *\n * @example\n * ```ts\n * server.getLatestLedger().then((response) => {\n * console.log(\"hash:\", response.id);\n * console.log(\"sequence:\", response.sequence);\n * console.log(\"protocolVersion:\", response.protocolVersion);\n * });\n * ```\n */\n public async getLatestLedger(): Promise<Api.GetLatestLedgerResponse> {\n return this._getLatestLedger().then(parseRawLatestLedger);\n }\n\n public async _getLatestLedger(): Promise<Api.RawGetLatestLedgerResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getLatestLedger\",\n );\n }\n\n /**\n * Submit a trial contract invocation to get back return values, expected\n * ledger footprint, expected authorizations, and expected costs.\n *\n * @param tx - the transaction to simulate,\n * which should include exactly one operation (one of\n * {@link xdr.InvokeHostFunctionOp}, {@link xdr.ExtendFootprintTtlOp}, or\n * {@link xdr.RestoreFootprintOp}). Any provided footprint or auth\n * information will be ignored.\n * @param addlResources - (optional) any additional resources\n * to add to the simulation-provided ones, for example if you know you will\n * need extra CPU instructions\n * @param authMode - (optional) optionally, specify the type of\n * auth mode to use for simulation: `enforce` for enforcement mode,\n * `record` for recording mode, or `record_allow_nonroot` for recording\n * mode that allows non-root authorization\n *\n * @returns An object with the\n * cost, footprint, result/auth requirements (if applicable), and error of\n * the transaction\n *\n * @see\n * {@link https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/operations-and-transactions | transaction docs}\n * @see\n * {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction | simulateTransaction docs}\n * @see\n * {@link https://developers.stellar.org/docs/learn/fundamentals/contract-development/contract-interactions/transaction-simulation#authorization | authorization modes}\n * @see module:rpc.Server#prepareTransaction\n * @see module:rpc.assembleTransaction\n *\n * @example\n * ```ts\n * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';\n * const contract = new StellarSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = StellarSdk.BASE_FEE;\n * const transaction = new StellarSdk.TransactionBuilder(account, { fee })\n * // Uncomment the following line to build transactions for the live network. Be\n * // sure to also change the horizon hostname.\n * //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)\n * .setTimeout(30) // valid for the next 30s\n * // Add an operation to call increment() on the contract\n * .addOperation(contract.call(\"increment\"))\n * .build();\n *\n * server.simulateTransaction(transaction).then((sim) => {\n * console.log(\"cost:\", sim.cost);\n * console.log(\"result:\", sim.result);\n * console.log(\"error:\", sim.error);\n * console.log(\"latestLedger:\", sim.latestLedger);\n * });\n * ```\n */\n\n public async simulateTransaction(\n tx: Transaction | FeeBumpTransaction,\n addlResources?: RpcServer.ResourceLeeway,\n authMode?: Api.SimulationAuthMode,\n ): Promise<Api.SimulateTransactionResponse> {\n return this._simulateTransaction(tx, addlResources, authMode).then(\n parseRawSimulation,\n );\n }\n\n public async _simulateTransaction(\n transaction: Transaction | FeeBumpTransaction,\n addlResources?: RpcServer.ResourceLeeway,\n authMode?: Api.SimulationAuthMode,\n ): Promise<Api.RawSimulateTransactionResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"simulateTransaction\",\n {\n transaction: transaction.toXDR(),\n authMode,\n ...(addlResources !== undefined && {\n resourceConfig: {\n instructionLeeway: addlResources.cpuInstructions,\n },\n }),\n },\n );\n }\n\n /**\n * Submit a trial contract invocation, first run a simulation of the contract\n * invocation as defined on the incoming transaction, and apply the results to\n * a new copy of the transaction which is then returned. Setting the ledger\n * footprint and authorization, so the resulting transaction is ready for\n * signing & sending.\n *\n * The returned transaction will also have an updated fee that is the sum of\n * fee set on incoming transaction with the contract resource fees estimated\n * from simulation. It is advisable to check the fee on returned transaction\n * and validate or take appropriate measures for interaction with user to\n * confirm it is acceptable.\n *\n * You can call the {@link rpc.Server.simulateTransaction} method\n * directly first if you want to inspect estimated fees for a given\n * transaction in detail first, then re-assemble it manually or via\n * {@link rpc.assembleTransaction}.\n *\n * @param tx - the transaction to\n * prepare. It should include exactly one operation, which must be one of\n * {@link xdr.InvokeHostFunctionOp}, {@link xdr.ExtendFootprintTtlOp},\n * or {@link xdr.RestoreFootprintOp}.\n *\n * Any provided footprint will be overwritten. However, if your operation\n * has existing auth entries, they will be preferred over ALL auth entries\n * from the simulation. In other words, if you include auth entries, you\n * don't care about the auth returned from the simulation. Other fields\n * (footprint, etc.) will be filled as normal.\n * @returns A copy of the\n * transaction with the expected authorizations (in the case of\n * invocation), resources, and ledger footprints added. The transaction fee\n * will also automatically be padded with the contract's minimum resource\n * fees discovered from the simulation.\n * @throws * If simulation fails\n *\n * @see module:rpc.assembleTransaction\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/simulateTransaction | simulateTransaction docs}\n *\n * @example\n * ```ts\n * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';\n * const contract = new StellarSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = StellarSdk.BASE_FEE;\n * const transaction = new StellarSdk.TransactionBuilder(account, { fee })\n * // Uncomment the following line to build transactions for the live network. Be\n * // sure to also change the horizon hostname.\n * //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)\n * .setTimeout(30) // valid for the next 30s\n * // Add an operation to call increment() on the contract\n * .addOperation(contract.call(\"increment\"))\n * .build();\n *\n * const preparedTransaction = await server.prepareTransaction(transaction);\n *\n * // Sign this transaction with the secret key\n * // NOTE: signing is transaction is network specific. Test network transactions\n * // won't work in the public network. To switch networks, use the Network object\n * // as explained above (look for StellarSdk.Network).\n * const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);\n * preparedTransaction.sign(sourceKeypair);\n *\n * server.sendTransaction(transaction).then(result => {\n * console.log(\"hash:\", result.hash);\n * console.log(\"status:\", result.status);\n * console.log(\"errorResultXdr:\", result.errorResultXdr);\n * });\n * ```\n */\n public async prepareTransaction(tx: Transaction | FeeBumpTransaction) {\n const simResponse = await this.simulateTransaction(tx);\n if (Api.isSimulationError(simResponse)) {\n throw new Error(simResponse.error);\n }\n\n return assembleTransaction(tx, simResponse).build();\n }\n\n /**\n * Submit a real transaction to the Stellar network.\n *\n * Unlike Horizon, RPC does not wait for transaction completion. It\n * simply validates the transaction and enqueues it. Clients should call\n * {@link rpc.Server.getTransaction} to learn about transaction\n * success/failure.\n *\n * @param transaction - to submit\n * @returns the\n * transaction id, status, and any error if available\n *\n * @see {@link https://developers.stellar.org/docs/learn/fundamentals/stellar-data-structures/operations-and-transactions | transaction docs}\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/sendTransaction | sendTransaction docs}\n *\n * @example\n * ```ts\n * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE';\n * const contract = new StellarSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = StellarSdk.BASE_FEE;\n * const transaction = new StellarSdk.TransactionBuilder(account, { fee })\n * // Uncomment the following line to build transactions for the live network. Be\n * // sure to also change the horizon hostname.\n * //.setNetworkPassphrase(StellarSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(StellarSdk.Networks.FUTURENET)\n * .setTimeout(30) // valid for the next 30s\n * // Add an operation to call increment() on the contract\n * .addOperation(contract.call(\"increment\"))\n * .build();\n *\n * // Sign this transaction with the secret key\n * // NOTE: signing is transaction is network specific. Test network transactions\n * // won't work in the public network. To switch networks, use the Network object\n * // as explained above (look for StellarSdk.Network).\n * const sourceKeypair = StellarSdk.Keypair.fromSecret(sourceSecretKey);\n * transaction.sign(sourceKeypair);\n *\n * server.sendTransaction(transaction).then((result) => {\n * console.log(\"hash:\", result.hash);\n * console.log(\"status:\", result.status);\n * console.log(\"errorResultXdr:\", result.errorResultXdr);\n * });\n * ```\n */\n public async sendTransaction(\n transaction: Transaction | FeeBumpTransaction,\n ): Promise<Api.SendTransactionResponse> {\n return this._sendTransaction(transaction).then(parseRawSendTransaction);\n }\n\n public async _sendTransaction(\n transaction: Transaction | FeeBumpTransaction,\n ): Promise<Api.RawSendTransactionResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"sendTransaction\",\n {\n transaction: transaction.toXDR(),\n },\n );\n }\n\n /**\n * Fund a new account using the network's Friendbot faucet, if any.\n *\n * @param address - The address or account instance that we\n * want to create and fund with Friendbot\n * @param friendbotUrl - (optional) Optionally, an explicit address for\n * friendbot (by default: this calls the Soroban RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's Friendbot url).\n * @returns An {@link Account} object for the created\n * account, or the existing account if it's already funded with the\n * populated sequence number (note that the account will not be \"topped\n * off\" if it already exists)\n * @throws If Friendbot is not configured on this network or request failure\n *\n * @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}\n * @see {@link Friendbot.Api.Response}\n *\n * @deprecated Use {@link Server.fundAddress} instead, which supports both\n * account (G...) and contract (C...) addresses.\n *\n * @example\n * ```ts\n * server\n * .requestAirdrop(\"GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4\")\n * .then((accountCreated) => {\n * console.log(\"accountCreated:\", accountCreated);\n * }).catch((error) => {\n * console.error(\"error:\", error);\n * });\n * ```\n */\n public async requestAirdrop(\n address: string | Pick<Account, \"accountId\">,\n friendbotUrl?: string,\n ): Promise<Account> {\n const account = typeof address === \"string\" ? address : address.accountId();\n friendbotUrl = friendbotUrl || (await this.getNetwork()).friendbotUrl;\n if (!friendbotUrl) {\n throw new Error(\"No friendbot URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FriendbotApi.Response>(\n `${friendbotUrl}?addr=${encodeURIComponent(account)}`,\n );\n\n let meta: xdr.TransactionMeta;\n if (!response.data.result_meta_xdr) {\n const txMeta = await this.getTransaction(response.data.hash);\n if (txMeta.status !== Api.GetTransactionStatus.SUCCESS) {\n throw new Error(`Funding account ${address} failed`);\n }\n meta = txMeta.resultMetaXdr;\n } else {\n meta = xdr.TransactionMeta.fromXDR(\n response.data.result_meta_xdr,\n \"base64\",\n );\n }\n\n const sequence = findCreatedAccountSequenceInTransactionMeta(meta);\n return new Account(account, sequence);\n } catch (error: any) {\n if (error.response?.status === 400) {\n if (\n error.response.data?.detail?.includes(\"createAccountAlreadyExist\")\n ) {\n // Account already exists, load the sequence number\n return this.getAccount(account);\n }\n }\n throw error;\n }\n }\n\n /**\n * Fund an address using the network's Friendbot faucet, if any.\n *\n * This method supports both account (G...) and contract (C...) addresses.\n *\n * @param address - The address to fund. Can be either a Stellar\n * account (G...) or contract (C...) address.\n * @param friendbotUrl - (optional) Optionally, an explicit Friendbot URL\n * (by default: this calls the Stellar RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's Friendbot url).\n * @returns The transaction\n * response from the Friendbot funding transaction.\n * @throws If Friendbot is not configured on this network or the\n * funding transaction fails.\n *\n * @see {@link https://developers.stellar.org/docs/learn/fundamentals/networks#friendbot | Friendbot docs}\n *\n * @example\n * ```ts\n * // Funding an account (G... address)\n * const tx = await server.fundAddress(\"GBZC6Y2Y7...\");\n * console.log(\"Funded! Hash:\", tx.txHash);\n * // If you need the Account object:\n * const account = await server.getAccount(\"GBZC6Y2Y7...\");\n * ```\n *\n * @example\n * ```ts\n * // Funding a contract (C... address)\n * const tx = await server.fundAddress(\"CBZC6Y2Y7...\");\n * console.log(\"Contract funded! Hash:\", tx.txHash);\n * ```\n */\n public async fundAddress(\n address: string,\n friendbotUrl?: string,\n ): Promise<Api.GetSuccessfulTransactionResponse> {\n if (\n !StrKey.isValidEd25519PublicKey(address) &&\n !StrKey.isValidContract(address)\n ) {\n throw new Error(\n `Invalid address: ${address}. Expected a Stellar account (G...) or contract (C...) address.`,\n );\n }\n\n friendbotUrl = friendbotUrl || (await this.getNetwork()).friendbotUrl;\n if (!friendbotUrl) {\n throw new Error(\"No friendbot URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FriendbotApi.Response>(\n `${friendbotUrl}?addr=${encodeURIComponent(address)}`,\n );\n\n const txResponse = await this.getTransaction(response.data.hash);\n if (txResponse.status !== Api.GetTransactionStatus.SUCCESS) {\n throw new Error(\n `Funding address ${address} failed: transaction status ${txResponse.status}`,\n );\n }\n\n return txResponse;\n } catch (error: any) {\n if (error.response?.status === 400) {\n throw new Error(error.response.data?.detail ?? \"Bad Request\");\n }\n throw error;\n }\n }\n\n /**\n * Provides an analysis of the recent fee stats for regular and smart\n * contract operations.\n *\n * @returns the fee stats\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getFeeStats\n */\n public async getFeeStats(): Promise<Api.GetFeeStatsResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getFeeStats\",\n );\n }\n\n /**\n * Provides information about the current version details of the Soroban RPC and captive-core\n *\n * @returns the version info\n * @see https://developers.stellar.org/docs/data/rpc/api-reference/methods/getVersionInfo\n */\n public async getVersionInfo(): Promise<Api.GetVersionInfoResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getVersionInfo\",\n );\n }\n\n /**\n * Returns a contract's balance of a particular SAC asset, if any.\n *\n * This is a convenience wrapper around {@link Server.getLedgerEntries}.\n *\n * @param address - the contract (string `C...`) whose balance of\n * `sac` you want to know\n * @param sac - the built-in SAC token (e.g. `USDC:GABC...`) that\n * you are querying from the given `contract`.\n * @param networkPassphrase - (optional) optionally, the network passphrase to\n * which this token applies. If omitted, a request about network\n * information will be made (see {@link getNetwork}), since contract IDs\n * for assets are specific to a network. You can refer to {@link Networks}\n * for a list of built-in passphrases, e.g., `Networks.TESTNET`.\n *\n * @returns , which will contain the balance\n * entry details if and only if the request returned a valid balance ledger\n * entry. If it doesn't, the `balanceEntry` field will not exist.\n *\n * @throws If `address` is not a valid contract ID (C...).\n *\n * @see getLedgerEntries\n * @see https://developers.stellar.org/docs/tokens/stellar-asset-contract\n *\n * @deprecated Use {@link getAssetBalance}, instead\n * @example\n * ```ts\n * // assume `address` is some contract or account with an XLM balance\n * // assume server is an instantiated `Server` instance.\n * const entry = (await server.getSACBalance(\n * new Address(address),\n * Asset.native(),\n * Networks.PUBLIC\n * ));\n *\n * // assumes BigInt support:\n * console.log(\n * entry.balanceEntry ?\n * BigInt(entry.balanceEntry.amount) :\n * \"Address has no XLM\");\n * ```\n */\n public async getSACBalance(\n address: string | Address,\n sac: Asset,\n networkPassphrase?: string,\n ): Promise<Api.BalanceResponse> {\n const addressString =\n address instanceof Address ? address.toString() : address;\n\n if (!StrKey.isValidContract(addressString)) {\n throw new TypeError(`expected contract ID, got ${addressString}`);\n }\n\n // Call out to RPC if passphrase isn't provided.\n const passphrase: string =\n networkPassphrase ?? (await this.getNetwork().then((n) => n.passphrase));\n\n // Turn SAC into predictable contract ID\n const sacId = sac.contractId(passphrase);\n\n // Rust union enum type with \"Balance(ScAddress)\" structure\n const key = nativeToScVal([\"Balance\", addressString], {\n type: [\"symbol\", \"address\"],\n });\n\n // Note a quirk here: the contract address in the key is the *token*\n // rather than the *holding contract*. This is because each token stores a\n // balance entry for each contract, not the other way around (i.e. XLM\n // holds a reserve for contract X, rather that contract X having a balance\n // of N XLM).\n const ledgerKey = xdr.LedgerKey.contractData(\n new xdr.LedgerKeyContractData({\n contract: new Address(sacId).toScAddress(),\n durability: xdr.ContractDataDurability.persistent(),\n key,\n }),\n );\n\n const response = await this.getLedgerEntries(ledgerKey);\n if (response.entries.length === 0) {\n return { latestLedger: response.latestLedger };\n }\n\n const { lastModifiedLedgerSeq, liveUntilLedgerSeq, val } =\n response.entries[0];\n\n if (val.switch().value !== xdr.LedgerEntryType.contractData().value) {\n return { latestLedger: response.latestLedger };\n }\n\n const entry = scValToNative(val.contractData().val());\n\n // Since we are requesting a SAC's contract data, we know for a fact that\n // it should follow the expected structure format. Thus, we can presume\n // these fields exist:\n return {\n latestLedger: response.latestLedger,\n balanceEntry: {\n liveUntilLedgerSeq,\n lastModifiedLedgerSeq,\n amount: entry.amount.toString(),\n authorized: entry.authorized,\n clawback: entry.clawback,\n },\n };\n }\n\n /**\n * Fetch a detailed list of ledgers starting from a specified point.\n *\n * Returns ledger data with support for pagination as long as the requested\n * pages fall within the history retention of the RPC provider.\n *\n * @param request - The request parameters for fetching ledgers. {@link Api.GetLedgersRequest}\n * @returns A promise that resolves to the\n * ledgers response containing an array of ledger data and pagination info. {@link Api.GetLedgersResponse}\n *\n * @throws If startLedger is less than the oldest ledger stored in this\n * node, or greater than the latest ledger seen by this node.\n *\n * @see {@link https://developers.stellar.org/docs/data/rpc/api-reference/methods/getLedgers | getLedgers docs}\n *\n * @example\n * ```ts\n * // Fetch ledgers starting from a specific sequence number\n * server.getLedgers({\n * startLedger: 36233,\n * pagination: {\n * limit: 10\n * }\n * }).then((response) => {\n * console.log(\"Ledgers:\", response.ledgers);\n * console.log(\"Latest Ledger:\", response.latestLedger);\n * console.log(\"Cursor:\", response.cursor);\n * });\n * ```\n *\n * @example\n * ```ts\n * // Paginate through ledgers using cursor\n * const firstPage = await server.getLedgers({\n * startLedger: 36233,\n * pagination: {\n * limit: 5\n * }\n * });\n *\n * const nextPage = await server.getLedgers({\n * pagination: {\n * cursor: firstPage.cursor,\n * limit: 5\n * }\n * });\n * ```\n */\n\n public async getLedgers(\n request: Api.GetLedgersRequest,\n ): Promise<Api.GetLedgersResponse> {\n return this._getLedgers(request).then((raw) => {\n const result: Api.GetLedgersResponse = {\n ledgers: (raw.ledgers || []).map(parseRawLedger),\n latestLedger: raw.latestLedger,\n latestLedgerCloseTime: raw.latestLedgerCloseTime,\n oldestLedger: raw.oldestLedger,\n oldestLedgerCloseTime: raw.oldestLedgerCloseTime,\n cursor: raw.cursor,\n };\n return result;\n });\n }\n\n public async _getLedgers(\n request: Api.GetLedgersRequest,\n ): Promise<Api.RawGetLedgersResponse> {\n return jsonrpc.postObject(\n this.httpClient,\n this.serverURL.toString(),\n \"getLedgers\",\n request,\n );\n }\n}\n"],"names":["Durability","xdr","createHttpClient","Account","Keypair","StrKey","buffer","Buffer","address","Address","Contract","jsonrpc.postObject","contract","parseRawLedgerEntries","Api","Utils","parseTransactionInfo","parseRawTransactions","parseRawEvents","parseRawLatestLedger","parseRawSimulation","assembleTransaction","parseRawSendTransaction","account","nativeToScVal","scValToNative","parseRawLedger"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,IAAK,UAAA,qBAAAA,WAAAA,KAAL;AACL,EAAAA,YAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,YAAA,YAAA,CAAA,GAAa,YAAA;AAFH,EAAA,OAAAA,WAAAA;AAAA,CAAA,EAAA,UAAA,IAAA,EAAA;AAsCZ,MAAM,+BAAA,GAA0C,EAAA;AAIzC,MAAM,kBAAA,GAAoC,CAAC,KAAA,KAAkB;AAG7D,MAAM,mBAAA,GAAqC,CAAC,IAAA,KAAiB,GAAA,GAAO;AAQ3E,SAAS,4CACP,IAAA,EACQ;AACR,EAAA,IAAI,aAAkC,EAAC;AACvC,EAAA,QAAQ,IAAA,CAAK,QAAO;AAAG,IACrB,KAAK,CAAA;AACH,MAAA,UAAA,GAAa,KAAK,UAAA,EAAW;AAC7B,MAAA;AAAA,IACF,KAAK,CAAA;AAAA,IACL,KAAK,CAAA;AAAA,IACL,KAAK,CAAA;AAAA,IACL,KAAK,CAAA;AACH,MAAA,UAAA,GAAc,IAAA,CAAK,KAAA,EAAM,CAA4B,UAAA,EAAW;AAChE,MAAA;AAAA,IACF;AACE,MAAA,MAAM,IAAI,MAAM,0CAA0C,CAAA;AAAA;AAE9D,EAAA,MAAM,cAAA,GA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