@digitalworld/digital-world-sdk 16.0.0 → 16.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +5 -5
  2. package/dist/digital-world-sdk-axios.js +52 -47
  3. package/dist/digital-world-sdk-axios.js.map +1 -1
  4. package/dist/digital-world-sdk-axios.min.js +1 -1
  5. package/dist/digital-world-sdk-axios.min.js.map +1 -1
  6. package/dist/digital-world-sdk.js +52 -47
  7. package/dist/digital-world-sdk.js.map +1 -1
  8. package/dist/digital-world-sdk.min.js +6 -6
  9. package/dist/digital-world-sdk.min.js.map +1 -1
  10. package/lib/axios/cjs/base/contract.js +2 -2
  11. package/lib/axios/cjs/base/contract.js.map +1 -1
  12. package/lib/axios/cjs/base/invocation.js.map +1 -1
  13. package/lib/axios/cjs/base/numbers/sc_int.js +1 -1
  14. package/lib/axios/cjs/base/numbers/sc_int.js.map +1 -1
  15. package/lib/axios/cjs/base/operation.js +1 -1
  16. package/lib/axios/cjs/base/operation.js.map +1 -1
  17. package/lib/axios/cjs/base/operations/invoke_host_function.js +2 -2
  18. package/lib/axios/cjs/base/operations/invoke_host_function.js.map +1 -1
  19. package/lib/axios/cjs/base/operations/revoke_sponsorship.js.map +1 -1
  20. package/lib/axios/cjs/bindings/config.js +4 -4
  21. package/lib/axios/cjs/bindings/config.js.map +1 -1
  22. package/lib/axios/cjs/bindings/generator.js +4 -4
  23. package/lib/axios/cjs/bindings/generator.js.map +1 -1
  24. package/lib/axios/cjs/bindings/types.js.map +1 -1
  25. package/lib/axios/cjs/bindings/utils.js +2 -2
  26. package/lib/axios/cjs/bindings/utils.js.map +1 -1
  27. package/lib/axios/cjs/bindings/wasm_fetcher.js +2 -2
  28. package/lib/axios/cjs/bindings/wasm_fetcher.js.map +1 -1
  29. package/lib/axios/cjs/contract/assembled_transaction.js.map +1 -1
  30. package/lib/axios/cjs/contract/spec.js +1 -1
  31. package/lib/axios/cjs/contract/spec.js.map +1 -1
  32. package/lib/axios/cjs/contract/types.js.map +1 -1
  33. package/lib/axios/cjs/gateway/gateway_axios_client.js +1 -1
  34. package/lib/axios/cjs/gateway/server_api.js.map +1 -1
  35. package/lib/axios/cjs/rpc/api.js.map +1 -1
  36. package/lib/axios/cjs/rpc/axios.js +1 -1
  37. package/lib/axios/cjs/rpc/server.js +32 -27
  38. package/lib/axios/cjs/rpc/server.js.map +1 -1
  39. package/lib/axios/cjs/webauth/utils.js.map +1 -1
  40. package/lib/axios/esm/base/contract.d.ts +4 -4
  41. package/lib/axios/esm/base/contract.js +2 -2
  42. package/lib/axios/esm/base/contract.js.map +1 -1
  43. package/lib/axios/esm/base/invocation.d.ts +2 -2
  44. package/lib/axios/esm/base/invocation.js.map +1 -1
  45. package/lib/axios/esm/base/numbers/sc_int.d.ts +2 -2
  46. package/lib/axios/esm/base/numbers/sc_int.js +1 -1
  47. package/lib/axios/esm/base/numbers/sc_int.js.map +1 -1
  48. package/lib/axios/esm/base/operation.d.ts +2 -2
  49. package/lib/axios/esm/base/operation.js +2 -2
  50. package/lib/axios/esm/base/operation.js.map +1 -1
  51. package/lib/axios/esm/base/operations/index.d.ts +1 -1
  52. package/lib/axios/esm/base/operations/invoke_host_function.d.ts +5 -5
  53. package/lib/axios/esm/base/operations/invoke_host_function.js +2 -2
  54. package/lib/axios/esm/base/operations/invoke_host_function.js.map +1 -1
  55. package/lib/axios/esm/base/operations/revoke_sponsorship.d.ts +1 -1
  56. package/lib/axios/esm/base/operations/revoke_sponsorship.js.map +1 -1
  57. package/lib/axios/esm/base/operations/types.d.ts +2 -2
  58. package/lib/axios/esm/bindings/config.js +4 -4
  59. package/lib/axios/esm/bindings/config.js.map +1 -1
  60. package/lib/axios/esm/bindings/generator.d.ts +7 -7
  61. package/lib/axios/esm/bindings/generator.js +4 -4
  62. package/lib/axios/esm/bindings/generator.js.map +1 -1
  63. package/lib/axios/esm/bindings/types.d.ts +1 -1
  64. package/lib/axios/esm/bindings/types.js.map +1 -1
  65. package/lib/axios/esm/bindings/utils.d.ts +4 -4
  66. package/lib/axios/esm/bindings/utils.js +2 -2
  67. package/lib/axios/esm/bindings/utils.js.map +1 -1
  68. package/lib/axios/esm/bindings/wasm_fetcher.js +2 -2
  69. package/lib/axios/esm/bindings/wasm_fetcher.js.map +1 -1
  70. package/lib/axios/esm/contract/assembled_transaction.d.ts +1 -1
  71. package/lib/axios/esm/contract/assembled_transaction.js.map +1 -1
  72. package/lib/axios/esm/contract/spec.js +1 -1
  73. package/lib/axios/esm/contract/spec.js.map +1 -1
  74. package/lib/axios/esm/contract/types.d.ts +2 -2
  75. package/lib/axios/esm/contract/types.js.map +1 -1
  76. package/lib/axios/esm/gateway/gateway_axios_client.js +1 -1
  77. package/lib/axios/esm/gateway/server_api.d.ts +2 -2
  78. package/lib/axios/esm/gateway/server_api.js.map +1 -1
  79. package/lib/axios/esm/rpc/api.d.ts +1 -1
  80. package/lib/axios/esm/rpc/api.js.map +1 -1
  81. package/lib/axios/esm/rpc/axios.js +1 -1
  82. package/lib/axios/esm/rpc/browser.d.ts +1 -1
  83. package/lib/axios/esm/rpc/server.d.ts +26 -26
  84. package/lib/axios/esm/rpc/server.js +32 -27
  85. package/lib/axios/esm/rpc/server.js.map +1 -1
  86. package/lib/axios/esm/webauth/utils.d.ts +2 -2
  87. package/lib/axios/esm/webauth/utils.js.map +1 -1
  88. package/lib/cjs/base/contract.js +2 -2
  89. package/lib/cjs/base/contract.js.map +1 -1
  90. package/lib/cjs/base/invocation.js.map +1 -1
  91. package/lib/cjs/base/numbers/sc_int.js +1 -1
  92. package/lib/cjs/base/numbers/sc_int.js.map +1 -1
  93. package/lib/cjs/base/operation.js +1 -1
  94. package/lib/cjs/base/operation.js.map +1 -1
  95. package/lib/cjs/base/operations/invoke_host_function.js +2 -2
  96. package/lib/cjs/base/operations/invoke_host_function.js.map +1 -1
  97. package/lib/cjs/base/operations/revoke_sponsorship.js.map +1 -1
  98. package/lib/cjs/bindings/config.js +4 -4
  99. package/lib/cjs/bindings/config.js.map +1 -1
  100. package/lib/cjs/bindings/generator.js +4 -4
  101. package/lib/cjs/bindings/generator.js.map +1 -1
  102. package/lib/cjs/bindings/types.js.map +1 -1
  103. package/lib/cjs/bindings/utils.js +2 -2
  104. package/lib/cjs/bindings/utils.js.map +1 -1
  105. package/lib/cjs/bindings/wasm_fetcher.js +2 -2
  106. package/lib/cjs/bindings/wasm_fetcher.js.map +1 -1
  107. package/lib/cjs/contract/assembled_transaction.js.map +1 -1
  108. package/lib/cjs/contract/spec.js +1 -1
  109. package/lib/cjs/contract/spec.js.map +1 -1
  110. package/lib/cjs/contract/types.js.map +1 -1
  111. package/lib/cjs/gateway/gateway_axios_client.js +1 -1
  112. package/lib/cjs/gateway/server_api.js.map +1 -1
  113. package/lib/cjs/rpc/api.js.map +1 -1
  114. package/lib/cjs/rpc/axios.js +1 -1
  115. package/lib/cjs/rpc/server.js +32 -27
  116. package/lib/cjs/rpc/server.js.map +1 -1
  117. package/lib/cjs/webauth/utils.js.map +1 -1
  118. package/lib/esm/base/contract.d.ts +4 -4
  119. package/lib/esm/base/contract.js +2 -2
  120. package/lib/esm/base/contract.js.map +1 -1
  121. package/lib/esm/base/invocation.d.ts +2 -2
  122. package/lib/esm/base/invocation.js.map +1 -1
  123. package/lib/esm/base/numbers/sc_int.d.ts +2 -2
  124. package/lib/esm/base/numbers/sc_int.js +1 -1
  125. package/lib/esm/base/numbers/sc_int.js.map +1 -1
  126. package/lib/esm/base/operation.d.ts +2 -2
  127. package/lib/esm/base/operation.js +2 -2
  128. package/lib/esm/base/operation.js.map +1 -1
  129. package/lib/esm/base/operations/index.d.ts +1 -1
  130. package/lib/esm/base/operations/invoke_host_function.d.ts +5 -5
  131. package/lib/esm/base/operations/invoke_host_function.js +2 -2
  132. package/lib/esm/base/operations/invoke_host_function.js.map +1 -1
  133. package/lib/esm/base/operations/revoke_sponsorship.d.ts +1 -1
  134. package/lib/esm/base/operations/revoke_sponsorship.js.map +1 -1
  135. package/lib/esm/base/operations/types.d.ts +2 -2
  136. package/lib/esm/bindings/config.js +4 -4
  137. package/lib/esm/bindings/config.js.map +1 -1
  138. package/lib/esm/bindings/generator.d.ts +7 -7
  139. package/lib/esm/bindings/generator.js +4 -4
  140. package/lib/esm/bindings/generator.js.map +1 -1
  141. package/lib/esm/bindings/types.d.ts +1 -1
  142. package/lib/esm/bindings/types.js.map +1 -1
  143. package/lib/esm/bindings/utils.d.ts +4 -4
  144. package/lib/esm/bindings/utils.js +2 -2
  145. package/lib/esm/bindings/utils.js.map +1 -1
  146. package/lib/esm/bindings/wasm_fetcher.js +2 -2
  147. package/lib/esm/bindings/wasm_fetcher.js.map +1 -1
  148. package/lib/esm/contract/assembled_transaction.d.ts +1 -1
  149. package/lib/esm/contract/assembled_transaction.js.map +1 -1
  150. package/lib/esm/contract/spec.js +1 -1
  151. package/lib/esm/contract/spec.js.map +1 -1
  152. package/lib/esm/contract/types.d.ts +2 -2
  153. package/lib/esm/contract/types.js.map +1 -1
  154. package/lib/esm/gateway/gateway_axios_client.js +1 -1
  155. package/lib/esm/gateway/server_api.d.ts +2 -2
  156. package/lib/esm/gateway/server_api.js.map +1 -1
  157. package/lib/esm/rpc/api.d.ts +1 -1
  158. package/lib/esm/rpc/api.js.map +1 -1
  159. package/lib/esm/rpc/axios.js +1 -1
  160. package/lib/esm/rpc/browser.d.ts +1 -1
  161. package/lib/esm/rpc/server.d.ts +26 -26
  162. package/lib/esm/rpc/server.js +32 -27
  163. package/lib/esm/rpc/server.js.map +1 -1
  164. package/lib/esm/webauth/utils.d.ts +2 -2
  165. package/lib/esm/webauth/utils.js.map +1 -1
  166. package/package.json +41 -39
@@ -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 FaucetApi } from \"../faucet/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(\"faucetUrl:\", 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 Faucet, if any.\n *\n * @param address - The address or account instance that we\n * want to create and fund with the Faucet\n * @param faucetUrl - (optional) Optionally, an explicit address for\n * the faucet (by default: this calls the Soroban RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's faucet 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 the faucet is not configured on this network or request failure\n *\n * @see {@link Faucet.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 faucetUrl?: string,\n ): Promise<Account> {\n const account = typeof address === \"string\" ? address : address.accountId();\n faucetUrl = faucetUrl || (await this.getNetwork()).friendbotUrl;\n if (!faucetUrl) {\n throw new Error(\"No faucet URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FaucetApi.Response>(\n `${faucetUrl}?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 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 faucetUrl - (optional) Optionally, an explicit faucet URL\n * (by default: this calls the Stellar RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's faucet url).\n * @returns The transaction\n * response from the faucet funding transaction.\n * @throws If the faucet is not configured on this network or the\n * funding transaction fails.\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 faucetUrl?: 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 faucetUrl = faucetUrl || (await this.getNetwork()).friendbotUrl;\n if (!faucetUrl) {\n throw new Error(\"No faucet URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FaucetApi.Response>(\n `${faucetUrl}?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","jsonrpc.postObject"],"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,GAAiB,WACpB,OAAA,CAAQ,CAAC,OAAO,EAAA,CAAG,OAAA,EAAS,CAAA,CAC5B,IAAA;AAAA,IACC,CAAC,CAAA,KACC,CAAA,CAAE,QAAO,KAAMC,KAAA,CAAI,sBAAsB,kBAAA,EAAmB,IAC5D,CAAA,CAAE,OAAA,GAAU,IAAA,EAAK,CAAE,QAAO,K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ACF;AAAA,EACF;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;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,IAAI,cAAc,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,OAAOC,UAAQ;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 FaucetApi } from \"../faucet/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 Digital World 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 Digital World 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 Digital World 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 Digital World 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(\"faucetUrl:\", 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 DigitalWorldSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = DigitalWorldSdk.BASE_FEE;\n * const transaction = new DigitalWorldSdk.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(DigitalWorldSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(DigitalWorldSdk.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 DigitalWorldSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = DigitalWorldSdk.BASE_FEE;\n * const transaction = new DigitalWorldSdk.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(DigitalWorldSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(DigitalWorldSdk.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 DigitalWorldSdk.Network).\n * const sourceKeypair = DigitalWorldSdk.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 Digital World 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 DigitalWorldSdk.Contract(contractId);\n *\n * // Right now, this is just the default fee for this example.\n * const fee = DigitalWorldSdk.BASE_FEE;\n * const transaction = new DigitalWorldSdk.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(DigitalWorldSdk.Networks.PUBLIC)\n * .setNetworkPassphrase(DigitalWorldSdk.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 DigitalWorldSdk.Network).\n * const sourceKeypair = DigitalWorldSdk.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 Faucet, if any.\n *\n * @param address - The address or account instance that we\n * want to create and fund with the Faucet\n * @param faucetUrl - (optional) Optionally, an explicit address for\n * the faucet (by default: this calls the Soroban RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's faucet 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 the faucet is not configured on this network or request failure\n *\n * @see {@link Faucet.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 faucetUrl?: string,\n ): Promise<Account> {\n const account = typeof address === \"string\" ? address : address.accountId();\n if (\n !StrKey.isValidEd25519PublicKey(account) &&\n !StrKey.isValidContract(account)\n ) {\n throw new Error(\n `Invalid address: ${account}. Expected a Digital World account (G...) or contract (C...) address.`,\n );\n }\n faucetUrl = faucetUrl || (await this.getNetwork()).friendbotUrl;\n if (!faucetUrl) {\n throw new Error(\"No faucet URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FaucetApi.Response>(\n `${faucetUrl}?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 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 Digital World\n * account (G...) or contract (C...) address.\n * @param faucetUrl - (optional) Optionally, an explicit faucet URL\n * (by default: this calls the Digital World RPC\n * {@link rpc.Server.getNetwork | getNetwork} method to try to\n * discover this network's faucet url).\n * @returns The transaction\n * response from the faucet funding transaction.\n * @throws If the faucet is not configured on this network or the\n * funding transaction fails.\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 faucetUrl?: 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 Digital World account (G...) or contract (C...) address.`,\n );\n }\n\n faucetUrl = faucetUrl || (await this.getNetwork()).friendbotUrl;\n if (!faucetUrl) {\n throw new Error(\"No faucet URL configured for current network\");\n }\n\n try {\n const response = await this.httpClient.post<FaucetApi.Response>(\n `${faucetUrl}?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","jsonrpc.postObject"],"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,GAAiB,WACpB,OAAA,CAAQ,CAAC,OAAO,EAAA,CAAG,OAAA,EAAS,CAAA,CAC5B,IAAA;AAA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,UAAU,QAAA,EAAS;AAAA,MACxB,YAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;"}
@@ -17,7 +17,7 @@ import { FeeBumpTransaction, Transaction } from "../base/index.js";
17
17
  * ```ts
18
18
  * let keypair1 = Keypair.random();
19
19
  * let keypair2 = Keypair.random();
20
- * const account = new StellarSdk.Account(keypair1.publicKey(), "-1");
20
+ * const account = new DigitalWorldSdk.Account(keypair1.publicKey(), "-1");
21
21
  *
22
22
  * const transaction = new TransactionBuilder(account, { fee: 100 })
23
23
  * .setTimeout(30)
@@ -39,7 +39,7 @@ export declare function gatherTxSigners(transaction: FeeBumpTransaction | Transa
39
39
  * @example
40
40
  * ```ts
41
41
  * let keypair = Keypair.random();
42
- * const account = new StellarSdk.Account(keypair.publicKey(), "-1");
42
+ * const account = new DigitalWorldSdk.Account(keypair.publicKey(), "-1");
43
43
  *
44
44
  * const transaction = new TransactionBuilder(account, { fee: 100 })
45
45
  * .setTimeout(30)
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/webauth/utils.ts"],"sourcesContent":["/**\n * Digital World Web Authentication\n * @see {@link https://docs.digitalworld.global/protocol/sep-10 | SEP-10 Specification}\n */\n\nimport { FeeBumpTransaction, Keypair, Transaction } from \"../base/index.js\";\nimport { InvalidChallengeError } from \"./errors.js\";\n/**\n * Checks if a transaction has been signed by one or more of the given signers,\n * returning a list of non-repeated signers that were found to have signed the\n * given transaction.\n *\n * @param transaction - The signed transaction.\n * @param signers - The signer's public keys.\n * @returns A list of signers that were found to have signed\n * the transaction.\n *\n * @example\n * ```ts\n * let keypair1 = Keypair.random();\n * let keypair2 = Keypair.random();\n * const account = new StellarSdk.Account(keypair1.publicKey(), \"-1\");\n *\n * const transaction = new TransactionBuilder(account, { fee: 100 })\n * .setTimeout(30)\n * .build();\n *\n * transaction.sign(keypair1, keypair2)\n * WebAuth.gatherTxSigners(transaction, [keypair1.publicKey(), keypair2.publicKey()])\n * ```\n */\nexport function gatherTxSigners(\n transaction: FeeBumpTransaction | Transaction,\n signers: string[],\n): string[] {\n const hashedSignatureBase = transaction.hash();\n\n const txSignatures = [...transaction.signatures]; // shallow copy for safe splicing\n const signersFound = new Set<string>();\n\n for (const signer of signers) {\n if (txSignatures.length === 0) {\n break;\n }\n\n let keypair: Keypair;\n try {\n keypair = Keypair.fromPublicKey(signer); // This can throw a few different errors\n } catch (err: any) {\n throw new InvalidChallengeError(\n `Signer is not a valid address: ${err.message}`,\n );\n }\n\n for (let i = 0; i < txSignatures.length; i++) {\n const decSig = txSignatures[i];\n\n if (!decSig.hint().equals(keypair.signatureHint())) {\n continue;\n }\n\n if (keypair.verify(hashedSignatureBase, decSig.signature())) {\n signersFound.add(signer);\n txSignatures.splice(i, 1);\n break;\n }\n }\n }\n\n return Array.from(signersFound);\n}\n\n/**\n * Verifies if a transaction was signed by the given account id.\n *\n * @param transaction - The signed transaction.\n * @param accountID - The signer's public key.\n * @returns Whether or not `accountID` was found to have signed the\n * transaction.\n *\n * @example\n * ```ts\n * let keypair = Keypair.random();\n * const account = new StellarSdk.Account(keypair.publicKey(), \"-1\");\n *\n * const transaction = new TransactionBuilder(account, { fee: 100 })\n * .setTimeout(30)\n * .build();\n *\n * transaction.sign(keypair)\n * WebAuth.verifyTxSignedBy(transaction, keypair.publicKey())\n * ```\n */\nexport function verifyTxSignedBy(\n transaction: FeeBumpTransaction | Transaction,\n accountID: string,\n): boolean {\n return gatherTxSigners(transaction, [accountID]).length !== 0;\n}\n\n/**\n * A parsed and validated challenge transaction, and some of its constituent details.\n */\nexport type ChallengeTxDetails = {\n /** The challenge transaction. */\n tx: Transaction;\n /** The Digital World public key (master key) used to sign the Manage Data operation. */\n clientAccountId: string;\n /** The matched home domain. */\n matchedHomeDomain: string;\n /** The memo attached to the transaction, which will be null if not present */\n memo?: string;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BO,SAAS,eAAA,CACd,aACA,OAAA,EACU;AACV,EAAA,MA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ent":["/**\n * Digital World Web Authentication\n * @see {@link https://docs.digitalworld.global/protocol/sep-10 | SEP-10 Specification}\n */\n\nimport { FeeBumpTransaction, Keypair, Transaction } from \"../base/index.js\";\nimport { InvalidChallengeError } from \"./errors.js\";\n/**\n * Checks if a transaction has been signed by one or more of the given signers,\n * returning a list of non-repeated signers that were found to have signed the\n * given transaction.\n *\n * @param transaction - The signed transaction.\n * @param signers - The signer's public keys.\n * @returns A list of signers that were found to have signed\n * the transaction.\n *\n * @example\n * ```ts\n * let keypair1 = Keypair.random();\n * let keypair2 = Keypair.random();\n * const account = new DigitalWorldSdk.Account(keypair1.publicKey(), \"-1\");\n *\n * const transaction = new TransactionBuilder(account, { fee: 100 })\n * .setTimeout(30)\n * .build();\n *\n * transaction.sign(keypair1, keypair2)\n * WebAuth.gatherTxSigners(transaction, [keypair1.publicKey(), keypair2.publicKey()])\n * ```\n */\nexport function gatherTxSigners(\n transaction: FeeBumpTransaction | Transaction,\n signers: string[],\n): string[] {\n const hashedSignatureBase = transaction.hash();\n\n const txSignatures = [...transaction.signatures]; // shallow copy for safe splicing\n const signersFound = new Set<string>();\n\n for (const signer of signers) {\n if (txSignatures.length === 0) {\n break;\n }\n\n let keypair: Keypair;\n try {\n keypair = Keypair.fromPublicKey(signer); // This can throw a few different errors\n } catch (err: any) {\n throw new InvalidChallengeError(\n `Signer is not a valid address: ${err.message}`,\n );\n }\n\n for (let i = 0; i < txSignatures.length; i++) {\n const decSig = txSignatures[i];\n\n if (!decSig.hint().equals(keypair.signatureHint())) {\n continue;\n }\n\n if (keypair.verify(hashedSignatureBase, decSig.signature())) {\n signersFound.add(signer);\n txSignatures.splice(i, 1);\n break;\n }\n }\n }\n\n return Array.from(signersFound);\n}\n\n/**\n * Verifies if a transaction was signed by the given account id.\n *\n * @param transaction - The signed transaction.\n * @param accountID - The signer's public key.\n * @returns Whether or not `accountID` was found to have signed the\n * transaction.\n *\n * @example\n * ```ts\n * let keypair = Keypair.random();\n * const account = new DigitalWorldSdk.Account(keypair.publicKey(), \"-1\");\n *\n * const transaction = new TransactionBuilder(account, { fee: 100 })\n * .setTimeout(30)\n * .build();\n *\n * transaction.sign(keypair)\n * WebAuth.verifyTxSignedBy(transaction, keypair.publicKey())\n * ```\n */\nexport function verifyTxSignedBy(\n transaction: FeeBumpTransaction | Transaction,\n accountID: string,\n): boolean {\n return gatherTxSigners(transaction, [accountID]).length !== 0;\n}\n\n/**\n * A parsed and validated challenge transaction, and some of its constituent details.\n */\nexport type ChallengeTxDetails = {\n /** The challenge transaction. */\n tx: Transaction;\n /** The Digital World public key (master key) used to sign the Manage Data operation. */\n clientAccountId: string;\n /** The matched home domain. */\n matchedHomeDomain: string;\n /** The memo attached to the transaction, which will be null if not present */\n memo?: string;\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BO,SAAS,eAAA,CACd,aACA,OAAA,EACU;AACV,EAAA,MAAM,mBAAA,GAAsB,YAAY,IAAA,EAAK;AAE7C,EAAA,MAAM,YAAA,GAAe,CAAC,GAAG,WAAA,CAAY,UAAU,CAAA;AAC/C,EAAA,MAAM,YAAA,uBAAmB,GAAA,EAAY;AAErC,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,IAAI,YAAA,CAAa,WAAW,CAAA,EAAG;AAC7B,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,OAAA;AACJ,IAAA,IAAI;AACF,MAAA,OAAA,GAAU,OAAA,CAAQ,cAAc,MAAM,CAAA;AAAA,IACxC,SAAS,GAAA,EAAU;AACjB,MAAA,MAAM,IAAI,qBAAA;AAAA,QACR,CAAA,+BAAA,EAAkC,IAAI,OAAO,CAAA;AAAA,OAC/C;AAAA,IACF;AAEA,IAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,YAAA,CAAa,QAAQ,CAAA,EAAA,EAAK;AAC5C,MAAA,MAAM,MAAA,GAAS,aAAa,CAAC,CAAA;AAE7B,MAAA,IAAI,CAAC,OAAO,IAAA,EAAK,CAAE,OAAO,OAAA,CAAQ,aAAA,EAAe,CAAA,EAAG;AAClD,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,QAAQ,MAAA,CAAO,mBAAA,EAAqB,MAAA,CAAO,SAAA,EAAW,CAAA,EAAG;AAC3D,QAAA,YAAA,CAAa,IAAI,MAAM,CAAA;AACvB,QAAA,YAAA,CAAa,MAAA,CAAO,GAAG,CAAC,CAAA;AACxB,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,KAAA,CAAM,KAAK,YAAY,CAAA;AAChC;AAuBO,SAAS,gBAAA,CACd,aACA,SAAA,EACS;AACT,EAAA,OAAO,gBAAgB,WAAA,EAAa,CAAC,SAAS,CAAC,EAAE,MAAA,KAAW,CAAA;AAC9D;;;;"}
@@ -19,7 +19,7 @@ class Contract {
19
19
  }
20
20
  }
21
21
  /**
22
- * Returns Stellar contract ID as a strkey, ex.
22
+ * Returns Digital World contract ID as a strkey, ex.
23
23
  * `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`.
24
24
  */
25
25
  contractId() {
@@ -42,7 +42,7 @@ class Contract {
42
42
  * @see Operation.invokeHostFunction
43
43
  * @see Operation.invokeContractFunction
44
44
  * @see Operation.createCustomContract
45
- * @see Operation.createStellarAssetContract
45
+ * @see Operation.createDigitalWorldAssetContract
46
46
  * @see Operation.uploadContractWasm
47
47
  */
48
48
  call(method, ...params) {
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sources":["../../../src/base/contract.ts"],"sourcesContent":["import { Address } from \"./address.js\";\nimport { Operation } from \"./operation.js\";\nimport xdr from \"./xdr.js\";\nimport { StrKey } from \"./strkey.js\";\n\n/**\n * Create a new Contract object.\n *\n * `Contract` represents a single contract in the Stellar network, embodying the\n * interface of the contract. See\n * [Contracts](https://soroban.stellar.org/docs/learn/interacting-with-contracts)\n * for more information about how contracts work in Stellar.\n */\nexport class Contract {\n private _id: Buffer;\n\n /**\n * @param contractId - ID of the contract (ex.\n * `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`).\n */\n constructor(contractId: string) {\n try {\n // First, try it as a strkey\n this._id = StrKey.decodeContract(contractId);\n } catch {\n throw new Error(`Invalid contract ID: ${contractId}`);\n }\n }\n\n /**\n * Returns Stellar contract ID as a strkey, ex.\n * `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`.\n */\n contractId(): string {\n return StrKey.encodeContract(this._id);\n }\n\n /** Returns the ID as a strkey (C...). */\n toString(): string {\n return this.contractId();\n }\n\n /** Returns the wrapped address of this contract. */\n address(): Address {\n return Address.contract(this._id);\n }\n\n /**\n * Returns an operation that will invoke this contract call.\n *\n * @param method - name of the method to call\n * @param params - arguments to pass to the method, as an array of xdr.ScVal\n *\n * @see Operation.invokeHostFunction\n * @see Operation.invokeContractFunction\n * @see Operation.createCustomContract\n * @see Operation.createStellarAssetContract\n * @see Operation.uploadContractWasm\n */\n call(\n method: string,\n ...params: xdr.ScVal[]\n ): xdr.Operation<Operation.InvokeHostFunction> {\n return Operation.invokeContractFunction({\n contract: this.address().toString(),\n function: method,\n args: params,\n });\n }\n\n /**\n * Returns the read-only footprint entries necessary for any invocations to\n * this contract, for convenience when manually adding it to your\n * transaction's overall footprint or doing bump/restore operations.\n */\n getFootprint(): xdr.LedgerKey {\n return xdr.LedgerKey.contractData(\n new xdr.LedgerKeyContractData({\n contract: this.address().toScAddress(),\n key: xdr.ScVal.scvLedgerKeyContractInstance(),\n durability: xdr.ContractDataDurability.persistent(),\n }),\n );\n }\n}\n"],"names":["StrKey","Address","Operation","xdr"],"mappings":";;;;;;;AAaO,MAAM,QAAA,CAAS;AAAA,EACZ,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,YAAY,UAAA,EAAoB;AAC9B,IAAA,IAAI;AAEF,MAAA,IA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base/contract.ts"],"sourcesContent":["import { Address } from \"./address.js\";\nimport { Operation } from \"./operation.js\";\nimport xdr from \"./xdr.js\";\nimport { StrKey } from \"./strkey.js\";\n\n/**\n * Create a new Contract object.\n *\n * `Contract` represents a single contract in the Digital World network, embodying the\n * interface of the contract. See\n * [Contracts](https://soroban.stellar.org/docs/learn/interacting-with-contracts)\n * for more information about how contracts work in Digital World.\n */\nexport class Contract {\n private _id: Buffer;\n\n /**\n * @param contractId - ID of the contract (ex.\n * `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`).\n */\n constructor(contractId: string) {\n try {\n // First, try it as a strkey\n this._id = StrKey.decodeContract(contractId);\n } catch {\n throw new Error(`Invalid contract ID: ${contractId}`);\n }\n }\n\n /**\n * Returns Digital World contract ID as a strkey, ex.\n * `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`.\n */\n contractId(): string {\n return StrKey.encodeContract(this._id);\n }\n\n /** Returns the ID as a strkey (C...). */\n toString(): string {\n return this.contractId();\n }\n\n /** Returns the wrapped address of this contract. */\n address(): Address {\n return Address.contract(this._id);\n }\n\n /**\n * Returns an operation that will invoke this contract call.\n *\n * @param method - name of the method to call\n * @param params - arguments to pass to the method, as an array of xdr.ScVal\n *\n * @see Operation.invokeHostFunction\n * @see Operation.invokeContractFunction\n * @see Operation.createCustomContract\n * @see Operation.createDigitalWorldAssetContract\n * @see Operation.uploadContractWasm\n */\n call(\n method: string,\n ...params: xdr.ScVal[]\n ): xdr.Operation<Operation.InvokeHostFunction> {\n return Operation.invokeContractFunction({\n contract: this.address().toString(),\n function: method,\n args: params,\n });\n }\n\n /**\n * Returns the read-only footprint entries necessary for any invocations to\n * this contract, for convenience when manually adding it to your\n * transaction's overall footprint or doing bump/restore operations.\n */\n getFootprint(): xdr.LedgerKey {\n return xdr.LedgerKey.contractData(\n new xdr.LedgerKeyContractData({\n contract: this.address().toScAddress(),\n key: xdr.ScVal.scvLedgerKeyContractInstance(),\n durability: xdr.ContractDataDurability.persistent(),\n }),\n );\n }\n}\n"],"names":["StrKey","Address","Operation","xdr"],"mappings":";;;;;;;AAaO,MAAM,QAAA,CAAS;AAAA,EACZ,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,YAAY,UAAA,EAAoB;AAC9B,IAAA,IAAI;AAEF,MAAA,IAAA,CAAK,GAAA,GAAMA,aAAA,CAAO,cAAA,CAAe,UAAU,CAAA;AAAA,IAC7C,CAAA,CAAA,MAAQ;AACN,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,qBAAA,EAAwB,UAAU,CAAA,CAAE,CAAA;AAAA,IACtD;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAA,GAAqB;AACnB,IAAA,OAAOA,aAAA,CAAO,cAAA,CAAe,IAAA,CAAK,GAAG,CAAA;AAAA,EACvC;AAAA;AAAA,EAGA,QAAA,GAAmB;AACjB,IAAA,OAAO,KAAK,UAAA,EAAW;AAAA,EACzB;AAAA;AAAA,EAGA,OAAA,GAAmB;AACjB,IAAA,OAAOC,eAAA,CAAQ,QAAA,CAAS,IAAA,CAAK,GAAG,CAAA;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,IAAA,CACE,WACG,MAAA,EAC0C;AAC7C,IAAA,OAAOC,oBAAU,sBAAA,CAAuB;AAAA,MACtC,QAAA,EAAU,IAAA,CAAK,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,MAClC,QAAA,EAAU,MAAA;AAAA,MACV,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,YAAA,GAA8B;AAC5B,IAAA,OAAOC,uBAAI,SAAA,CAAU,YAAA;AAAA,MACnB,IAAIA,uBAAI,qBAAA,CAAsB;AAAA,QAC5B,QAAA,EAAU,IAAA,CAAK,OAAA,EAAQ,CAAE,WAAA,EAAY;AAAA,QACrC,GAAA,EAAKA,sBAAA,CAAI,KAAA,CAAM,4BAAA,EAA6B;AAAA,QAC5C,UAAA,EAAYA,sBAAA,CAAI,sBAAA,CAAuB,UAAA;AAAW,OACnD;AAAA,KACH;AAAA,EACF;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"invocation.js","sources":["../../../src/base/invocation.ts"],"sourcesContent":["import xdr from \"./xdr.js\";\nimport { Asset } from \"./asset.js\";\nimport { Address } from \"./address.js\";\nimport { scValToNative } from \"./scval.js\";\n\nexport interface WasmCreateDetails {\n hash: string;\n address: string;\n salt: string;\n\n constructorArgs?: any[];\n}\n\n/**\n * Details about a contract creation invocation.\n *\n * - `type` indicates if this creation was a custom contract (`'wasm'`) or a\n * wrapping of an existing Stellar asset (`'sac'`)\n * - `asset` is set when `type=='sac'`, containing the canonical {@link Asset}\n * being wrapped by this Stellar Asset Contract\n * - `wasm` is set when `type=='wasm'`, containing additional creation parameters\n */\nexport interface CreateInvocation {\n type: \"sac\" | \"wasm\";\n asset?: string;\n wasm?: WasmCreateDetails;\n}\n\n/**\n * Details about a contract function execution invocation.\n *\n * - `source` is the strkey of the contract (`C...`) being invoked\n * - `function` is the name of the function being invoked\n * - `args` are the natively-represented parameters to the function invocation\n * (see {@link scValToNative} for rules on how they're represented as JS types)\n */\nexport interface ExecuteInvocation {\n source: string;\n function: string;\n\n args: any[];\n}\n\n/**\n * A node in the invocation tree.\n *\n * - `type` is the type of invocation occurring, either contract creation or\n * host function execution\n * - `args` are the parameters to the invocation, depending on the type\n * - `invocations` are any sub-invocations that may occur as a result of this\n * invocation (i.e. a tree of call stacks)\n */\nexport interface InvocationTree {\n type: \"create\" | \"execute\";\n args: CreateInvocation | ExecuteInvocation;\n invocations: InvocationTree[];\n}\n\n/**\n * A callback used when walking an invocation tree.\n *\n * Returning exactly `false` is a hint to stop exploring deeper from this node;\n * other return values are ignored.\n *\n * @param node - the currently explored node\n * @param depth - the depth of the tree this node is occurring at (the\n * root starts at a depth of 1)\n * @param parent - this node's parent node, if any (i.e. this doesn't\n * exist at the root)\n */\nexport type InvocationWalker = (\n node: xdr.SorobanAuthorizedInvocation,\n depth: number,\n parent?: xdr.SorobanAuthorizedInvocation,\n) => boolean | null | void;\n\n/**\n * Turns a raw invocation tree into a human-readable format.\n *\n * This is designed to make the invocation tree easier to understand in order to\n * inform users about the side-effects of their contract calls. This will help\n * make informed decisions about whether or not a particular invocation will\n * result in what you expect it to.\n *\n * @param root - the raw XDR of the invocation,\n * likely acquired from transaction simulation. this is either from the\n * {@link Operation.invokeHostFunction} itself (the `func` field), or from\n * the authorization entries ({@link xdr.SorobanAuthorizationEntry}, the\n * `rootInvocation` field)\n *\n * @example\n * Here, we show a browser modal after simulating an arbitrary transaction,\n * `tx`, which we assume has an `Operation.invokeHostFunction` inside of it:\n *\n * ```ts\n * import { Server, buildInvocationTree } from '@stellar/stellar-sdk';\n *\n * const s = new Server(\"fill in accordingly\");\n *\n * s.simulateTransaction(tx).then(\n * (resp: SorobanRpc.SimulateTransactionResponse) => {\n * if (SorobanRpc.isSuccessfulSim(resp) && resp.result) {\n * // bold assumption: there's a valid result with an auth entry\n * const auth = resp.result.auth;\n * if (auth && auth.length > 0) {\n * alert(\n * \"You are authorizing the following invocation:\\n\" +\n * JSON.stringify(\n * buildInvocationTree(auth[0].rootInvocation()),\n * null,\n * 2\n * )\n * );\n * }\n * }\n * }\n * );\n * ```\n */\nexport function buildInvocationTree(\n root: xdr.SorobanAuthorizedInvocation,\n): InvocationTree {\n const fn = root.function();\n\n const output: Partial<InvocationTree> = {};\n const inner = fn.value();\n\n switch (fn.switch().value) {\n // sorobanAuthorizedFunctionTypeContractFn\n case 0: {\n const invokeArgs = fn.contractFn();\n output.type = \"execute\";\n output.args = {\n source: Address.fromScAddress(invokeArgs.contractAddress()).toString(),\n function: invokeArgs.functionName().toString(),\n\n args: invokeArgs.args().map((arg) => scValToNative(arg)),\n };\n break;\n }\n\n // sorobanAuthorizedFunctionTypeCreateContractHostFn\n // sorobanAuthorizedFunctionTypeCreateContractV2HostFn\n case 1: // fallthrough: just no ctor args in V1\n case 2: {\n const createArgs = inner as\n | xdr.CreateContractArgs\n | xdr.CreateContractArgsV2;\n const createV2 = fn.switch().value === 2;\n output.type = \"create\";\n const createInvocation: Partial<CreateInvocation> = {};\n\n // If the executable is a WASM, the preimage MUST be an address. If it's a\n // token, the preimage MUST be an asset. This is a cheeky way to check\n // that, because wasm=0, token=1 and address=0, asset=1 in the XDR switch\n // values.\n //\n // The first part may not be true in V2, but we'd need to update this code\n // anyway so it can still be an error.\n const [exec, preimage] = [\n createArgs.executable(),\n createArgs.contractIdPreimage(),\n ];\n if (!!exec.switch().value !== !!preimage.switch().value) {\n throw new Error(\n `creation function appears invalid: ${JSON.stringify(\n inner,\n )} (should be wasm+address or token+asset)`,\n );\n }\n\n switch (exec.switch().value) {\n // contractExecutableWasm\n case 0: {\n const details = preimage.fromAddress();\n\n createInvocation.type = \"wasm\";\n createInvocation.wasm = {\n salt: Buffer.from(details.salt()).toString(\"hex\"),\n hash: exec.wasmHash().toString(\"hex\"),\n address: Address.fromScAddress(details.address()).toString(),\n // only apply constructor args for WASM+CreateV2 scenario\n ...(createV2 && {\n constructorArgs: (inner as xdr.CreateContractArgsV2)\n .constructorArgs()\n\n .map((arg) => scValToNative(arg)),\n }), // empty indicates V2 and no ctor, undefined indicates V1\n };\n break;\n }\n\n // contractExecutableStellarAsset\n case 1:\n createInvocation.type = \"sac\";\n createInvocation.asset = Asset.fromOperation(\n preimage.fromAsset(),\n ).toString();\n break;\n\n default:\n throw new Error(`unknown creation type: ${JSON.stringify(exec)}`);\n }\n\n output.args = createInvocation as CreateInvocation;\n break;\n }\n\n default:\n throw new Error(\n `unknown invocation type (${fn.switch().value}): ${JSON.stringify(fn)}`,\n );\n }\n\n output.invocations = root.subInvocations().map((i) => buildInvocationTree(i));\n return output as InvocationTree;\n}\n\n/**\n * Executes a callback function on each node in the tree until stopped.\n *\n * Nodes are walked in a depth-first order. Returning `false` from the callback\n * stops further depth exploration at that node, but it does not stop the walk\n * in a \"global\" view.\n *\n * @param root - the tree to explore\n * @param callback - the callback to execute for each node\n */\nexport function walkInvocationTree(\n root: xdr.SorobanAuthorizedInvocation,\n callback: InvocationWalker,\n): void {\n walkHelper(root, 1, callback);\n}\n\nfunction walkHelper(\n node: xdr.SorobanAuthorizedInvocation,\n depth: number,\n callback: InvocationWalker,\n parent?: xdr.SorobanAuthorizedInvocation,\n): void {\n if (callback(node, depth, parent) === false /* allow void rv */) {\n return;\n }\n\n node\n .subInvocations()\n .forEach((i) => walkHelper(i, depth + 1, callback, node));\n}\n"],"names":["Address","scValToNative","Buffer","Asset"],"mappings":";;;;;;;AAuHO,SAAS,oBACd,IAAA,EACgB;AAChB,EAAA,MAAM,EAAA,GAAK,KAAK,QAAA,EAAS;AAEzB,EAAA,MAAM,SAAkC,EAAC;AACzC,EAAA,MAAM,KAAA,GAAQ,GAAG,KAAA,EAAM;AAEvB,EAAA,QAAQ,EAAA,CAAG,MAAA,EAAO,CAAE,KAAA;AAAO;AAAA,IAEzB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,UAAA,GAAa,GAAG,UAAA,EAAW;AACjC,MAAA,MAAA,CAAO,IAAA,GAAO,SAAA;AACd,MAAA,MAAA,CAAO,IAAA,GAAO;AAAA,QACZ,QAAQA,eAAA,CAAQ,aAAA,CAAc,WAAW,eAAA,EAAiB,EAAE,QAAA,EAAS;AAAA,QACrE,QAAA,EAAU,UAAA,CAAW,YAAA,EAAa,CAAE,QAAA,EAAS;AAAA,QAE7C,IAAA,EAAM,WAAW,IAAA,EAAK,CAAE,IAAI,CAAC,GAAA,KAAQC,mBAAA,CAAc,GAAG,CAAC;AAAA,OACzD;AACA,MAAA;AAAA,IACF;AAAA;AAAA;AAAA,IAIA,KAAK,CAAA;AAAA;AAAA,IACL,KAAK,CAAA,EAAG;AACN,MA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A;AACH,UAAA,gBAAA,CAAiB,IAAA,GAAO,KAAA;AACxB,UAAA,gBAAA,CAAiB,QAAQE,WAAA,CAAM,aAAA;AAAA,YAC7B,SAAS,SAAA;AAAU,YACnB,QAAA,EAAS;AACX,UAAA;AAAA,QAEF;AACE,UAAA,MAAM,IAAI,KAAA,CAAM,CAAA,uBAAA,EAA0B,KAAK,SAAA,CAAU,IAAI,CAAC,CAAA,CAAE,CAAA;AAAA;AAGpE,MAAA,MAAA,CAAO,IAAA,GAAO,gBAAA;AACd,MAAA;AAAA,IACF;AAAA,IAEA;AACE,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,yBAAA,EAA4B,GAAG,MAAA,EAAO,CAAE,KAAK,CAAA,GAAA,EAAM,IAAA,CAAK,SAAA,CAAU,EAAE,CAAC,CAAA;AAAA,OACvE;AAAA;AAGJ,EAAA,MAAA,CAAO,WAAA,GAAc,KAAK,cAAA,EAAe,CAAE,IAAI,CAAC,CAAA,KAAM,mBAAA,CAAoB,CAAC,CAAC,CAAA;AAC5E,EAAA,OAAO,MAAA;AACT;AAYO,SAAS,kBAAA,CACd,MACA,QAAA,EACM;AACN,EAAA,UAAA,CAAW,IAAA,EAAM,GAAG,QAAQ,CAAA;AAC9B;AAEA,SAAS,UAAA,CACP,IAAA,EACA,KAAA,EACA,QAAA,EACA,MAAA,EACM;AACN,EAAA,IAAI,QAAA,CAAS,IAAA,EAAM,KAAA,EAAO,MAAM,MAAM,KAAA,EAA2B;AAC/D,IAAA;AAAA,EACF;AAEA,EAAA,IAAA,CACG,cAAA,EAAe,CACf,OAAA,CAAQ,CAAC,CAAA,KAAM,UAAA,CAAW,CAAA,EAAG,KAAA,GAAQ,CAAA,EAAG,QAAA,EAAU,IAAI,CAAC,CAAA;AAC5D;;;;;"}
1
+ {"version":3,"file":"invocation.js","sources":["../../../src/base/invocation.ts"],"sourcesContent":["import xdr from \"./xdr.js\";\nimport { Asset } from \"./asset.js\";\nimport { Address } from \"./address.js\";\nimport { scValToNative } from \"./scval.js\";\n\nexport interface WasmCreateDetails {\n hash: string;\n address: string;\n salt: string;\n\n constructorArgs?: any[];\n}\n\n/**\n * Details about a contract creation invocation.\n *\n * - `type` indicates if this creation was a custom contract (`'wasm'`) or a\n * wrapping of an existing Digital World asset (`'sac'`)\n * - `asset` is set when `type=='sac'`, containing the canonical {@link Asset}\n * being wrapped by this Digital World Asset Contract\n * - `wasm` is set when `type=='wasm'`, containing additional creation parameters\n */\nexport interface CreateInvocation {\n type: \"sac\" | \"wasm\";\n asset?: string;\n wasm?: WasmCreateDetails;\n}\n\n/**\n * Details about a contract function execution invocation.\n *\n * - `source` is the strkey of the contract (`C...`) being invoked\n * - `function` is the name of the function being invoked\n * - `args` are the natively-represented parameters to the function invocation\n * (see {@link scValToNative} for rules on how they're represented as JS types)\n */\nexport interface ExecuteInvocation {\n source: string;\n function: string;\n\n args: any[];\n}\n\n/**\n * A node in the invocation tree.\n *\n * - `type` is the type of invocation occurring, either contract creation or\n * host function execution\n * - `args` are the parameters to the invocation, depending on the type\n * - `invocations` are any sub-invocations that may occur as a result of this\n * invocation (i.e. a tree of call stacks)\n */\nexport interface InvocationTree {\n type: \"create\" | \"execute\";\n args: CreateInvocation | ExecuteInvocation;\n invocations: InvocationTree[];\n}\n\n/**\n * A callback used when walking an invocation tree.\n *\n * Returning exactly `false` is a hint to stop exploring deeper from this node;\n * other return values are ignored.\n *\n * @param node - the currently explored node\n * @param depth - the depth of the tree this node is occurring at (the\n * root starts at a depth of 1)\n * @param parent - this node's parent node, if any (i.e. this doesn't\n * exist at the root)\n */\nexport type InvocationWalker = (\n node: xdr.SorobanAuthorizedInvocation,\n depth: number,\n parent?: xdr.SorobanAuthorizedInvocation,\n) => boolean | null | void;\n\n/**\n * Turns a raw invocation tree into a human-readable format.\n *\n * This is designed to make the invocation tree easier to understand in order to\n * inform users about the side-effects of their contract calls. This will help\n * make informed decisions about whether or not a particular invocation will\n * result in what you expect it to.\n *\n * @param root - the raw XDR of the invocation,\n * likely acquired from transaction simulation. this is either from the\n * {@link Operation.invokeHostFunction} itself (the `func` field), or from\n * the authorization entries ({@link xdr.SorobanAuthorizationEntry}, the\n * `rootInvocation` field)\n *\n * @example\n * Here, we show a browser modal after simulating an arbitrary transaction,\n * `tx`, which we assume has an `Operation.invokeHostFunction` inside of it:\n *\n * ```ts\n * import { Server, buildInvocationTree } from '@stellar/stellar-sdk';\n *\n * const s = new Server(\"fill in accordingly\");\n *\n * s.simulateTransaction(tx).then(\n * (resp: SorobanRpc.SimulateTransactionResponse) => {\n * if (SorobanRpc.isSuccessfulSim(resp) && resp.result) {\n * // bold assumption: there's a valid result with an auth entry\n * const auth = resp.result.auth;\n * if (auth && auth.length > 0) {\n * alert(\n * \"You are authorizing the following invocation:\\n\" +\n * JSON.stringify(\n * buildInvocationTree(auth[0].rootInvocation()),\n * null,\n * 2\n * )\n * );\n * }\n * }\n * }\n * );\n * ```\n */\nexport function buildInvocationTree(\n root: xdr.SorobanAuthorizedInvocation,\n): InvocationTree {\n const fn = root.function();\n\n const output: Partial<InvocationTree> = {};\n const inner = fn.value();\n\n switch (fn.switch().value) {\n // sorobanAuthorizedFunctionTypeContractFn\n case 0: {\n const invokeArgs = fn.contractFn();\n output.type = \"execute\";\n output.args = {\n source: Address.fromScAddress(invokeArgs.contractAddress()).toString(),\n function: invokeArgs.functionName().toString(),\n\n args: invokeArgs.args().map((arg) => scValToNative(arg)),\n };\n break;\n }\n\n // sorobanAuthorizedFunctionTypeCreateContractHostFn\n // sorobanAuthorizedFunctionTypeCreateContractV2HostFn\n case 1: // fallthrough: just no ctor args in V1\n case 2: {\n const createArgs = inner as\n | xdr.CreateContractArgs\n | xdr.CreateContractArgsV2;\n const createV2 = fn.switch().value === 2;\n output.type = \"create\";\n const createInvocation: Partial<CreateInvocation> = {};\n\n // If the executable is a WASM, the preimage MUST be an address. If it's a\n // token, the preimage MUST be an asset. This is a cheeky way to check\n // that, because wasm=0, token=1 and address=0, asset=1 in the XDR switch\n // values.\n //\n // The first part may not be true in V2, but we'd need to update this code\n // anyway so it can still be an error.\n const [exec, preimage] = [\n createArgs.executable(),\n createArgs.contractIdPreimage(),\n ];\n if (!!exec.switch().value !== !!preimage.switch().value) {\n throw new Error(\n `creation function appears invalid: ${JSON.stringify(\n inner,\n )} (should be wasm+address or token+asset)`,\n );\n }\n\n switch (exec.switch().value) {\n // contractExecutableWasm\n case 0: {\n const details = preimage.fromAddress();\n\n createInvocation.type = \"wasm\";\n createInvocation.wasm = {\n salt: Buffer.from(details.salt()).toString(\"hex\"),\n hash: exec.wasmHash().toString(\"hex\"),\n address: Address.fromScAddress(details.address()).toString(),\n // only apply constructor args for WASM+CreateV2 scenario\n ...(createV2 && {\n constructorArgs: (inner as xdr.CreateContractArgsV2)\n .constructorArgs()\n\n .map((arg) => scValToNative(arg)),\n }), // empty indicates V2 and no ctor, undefined indicates V1\n };\n break;\n }\n\n // contractExecutableStellarAsset\n case 1:\n createInvocation.type = \"sac\";\n createInvocation.asset = Asset.fromOperation(\n preimage.fromAsset(),\n ).toString();\n break;\n\n default:\n throw new Error(`unknown creation type: ${JSON.stringify(exec)}`);\n }\n\n output.args = createInvocation as CreateInvocation;\n break;\n }\n\n default:\n throw new Error(\n `unknown invocation type (${fn.switch().value}): ${JSON.stringify(fn)}`,\n );\n }\n\n output.invocations = root.subInvocations().map((i) => buildInvocationTree(i));\n return output as InvocationTree;\n}\n\n/**\n * Executes a callback function on each node in the tree until stopped.\n *\n * Nodes are walked in a depth-first order. Returning `false` from the callback\n * stops further depth exploration at that node, but it does not stop the walk\n * in a \"global\" view.\n *\n * @param root - the tree to explore\n * @param callback - the callback to execute for each node\n */\nexport function walkInvocationTree(\n root: xdr.SorobanAuthorizedInvocation,\n callback: InvocationWalker,\n): void {\n walkHelper(root, 1, callback);\n}\n\nfunction walkHelper(\n node: xdr.SorobanAuthorizedInvocation,\n depth: number,\n callback: InvocationWalker,\n parent?: xdr.SorobanAuthorizedInvocation,\n): void {\n if (callback(node, depth, parent) === false /* allow void rv */) {\n return;\n }\n\n node\n .subInvocations()\n .forEach((i) => walkHelper(i, depth + 1, callback, node));\n}\n"],"names":["Address","scValToNative","Buffer","Asset"],"mappings":";;;;;;;AAuHO,SAAS,oBACd,IAAA,EACgB;AAChB,EAAA,MAAM,EAAA,GAAK,KAAK,QAAA,EAAS;AAEzB,EAAA,MAAM,SAAkC,EAAC;AACzC,EAAA,MAAM,KAAA,GAAQ,GAAG,KAAA,EAAM;AAEvB,EAAA,QAAQ,EAAA,CAAG,MAAA,EAAO,CAAE,KAAA;AAAO;AAAA,IAEzB,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,UAAA,GAAa,GAAG,UAAA,EAAW;AACjC,MAAA,MAAA,CAAO,IAAA,GAAO,SAAA;AACd,MAAA,MAAA,CAAO,IAAA,GAAO;AAAA,QACZ,QAAQA,eAAA,CAAQ,aAAA,CAAc,WAAW,eAAA,EAAiB,EAAE,QAAA,EAAS;AAAA,QACrE,QAAA,EAAU,UAAA,CAAW,YAAA,EAAa,CAAE,QAAA,EAAS;AAAA,QAE7C,IAAA,EAAM,WAAW,IAAA,EAAK,CAAE,IAAI,CAAC,GAAA,KAAQC,mBAAA,CAAc,GAAG,CAAC;AAAA,OACzD;AACA,MAAA;AAAA,IACF;AAAA;AAAA;AAAA,IAIA,KAAK,CAAA;AAAA;AAAA,IACL,KAAK,CAAA,EAAG;AACN,MAAA,MAAM,UAAA,GAAa,KAAA;AAGnB,MAAA,MAAM,QAAA,GAAW,EAAA,CAAG,MAAA,EAAO,CAAE,KAAA,KAAU,CAAA;AACvC,MAAA,MAAA,CAAO,IAAA,GAAO,QAAA;AACd,MAAA,MAAM,mBAA8C,EAAC;AASrD,MAAA,MAAM,CAAC,IAAA,EAAM,QAAQ,CAAA,GAAI;AAAA,QACvB,WAAW,UAAA,EAAW;AAAA,QACtB,WAAW,kBAAA;AAAmB,OAChC;AACA,MAAA,IAAI,CAAC,CAAC,IAAA,CAAK,MAAA,EAAO,CAA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,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,yBAAA,EAA4B,GAAG,MAAA,EAAO,CAAE,KAAK,CAAA,GAAA,EAAM,IAAA,CAAK,SAAA,CAAU,EAAE,CAAC,CAAA;AAAA,OACvE;AAAA;AAGJ,EAAA,MAAA,CAAO,WAAA,GAAc,KAAK,cAAA,EAAe,CAAE,IAAI,CAAC,CAAA,KAAM,mBAAA,CAAoB,CAAC,CAAC,CAAA;AAC5E,EAAA,OAAO,MAAA;AACT;AAYO,SAAS,kBAAA,CACd,MACA,QAAA,EACM;AACN,EAAA,UAAA,CAAW,IAAA,EAAM,GAAG,QAAQ,CAAA;AAC9B;AAEA,SAAS,UAAA,CACP,IAAA,EACA,KAAA,EACA,QAAA,EACA,MAAA,EACM;AACN,EAAA,IAAI,QAAA,CAAS,IAAA,EAAM,KAAA,EAAO,MAAM,MAAM,KAAA,EAA2B;AAC/D,IAAA;AAAA,EACF;AAEA,EAAA,IAAA,CACG,cAAA,EAAe,CACf,OAAA,CAAQ,CAAC,CAAA,KAAM,UAAA,CAAW,CAAA,EAAG,KAAA,GAAQ,CAAA,EAAG,QAAA,EAAU,IAAI,CAAC,CAAA;AAC5D;;;;;"}
@@ -5,7 +5,7 @@ var xdr_large_int = require('./xdr_large_int.js');
5
5
  class ScInt extends xdr_large_int.XdrLargeInt {
6
6
  /**
7
7
  * @param value - a single, integer-like value which will
8
- * be interpreted in the smallest appropriate XDR type supported by Stellar
8
+ * be interpreted in the smallest appropriate XDR type supported by Digital World
9
9
  * (64, 128, or 256 bit integer values). signed values are supported, though
10
10
  * they are sanity-checked against `opts.type`. if you need 32-bit values,
11
11
  * you can construct them directly without needing this wrapper, e.g.
@@ -1 +1 @@
1
- {"version":3,"file":"sc_int.js","sources":["../../../../src/base/numbers/sc_int.ts"],"sourcesContent":["import { XdrLargeInt, type ScIntType } from \"./xdr_large_int.js\";\n\n/**\n * Provides an easier way to manipulate large numbers for Stellar operations.\n *\n * You can instantiate this \"**s**mart **c**ontract integer\" value either from\n * bigints, strings, or numbers (whole numbers, or this will throw).\n *\n * If you need to create a native BigInt from a list of integer \"parts\" (for\n * example, you have a series of encoded 32-bit integers that represent a larger\n * value), you can use the lower level abstraction {@link XdrLargeInt}. For\n * example, you could do `new XdrLargeInt('u128', bytes...).toBigInt()`.\n *\n * @example\n * ```ts\n * import { xdr, ScInt, scValToBigInt } from \"@stellar/stellar-base\";\n *\n * // You have an ScVal from a contract and want to parse it into JS native.\n * const value = xdr.ScVal.fromXDR(someXdr, \"base64\");\n * const bigi = scValToBigInt(value); // grab it as a BigInt\n * let sci = new ScInt(bigi);\n *\n * sci.toNumber(); // gives native JS type (w/ size check)\n * sci.toBigInt(); // gives the native BigInt value\n * sci.toU64(); // gives ScValType-specific XDR constructs (with size checks)\n *\n * // You have a number and want to shove it into a contract.\n * sci = new ScInt(0xdeadcafebabe);\n * sci.toBigInt() // returns 244838016400062n\n * sci.toNumber() // throws: too large\n *\n * // Pass any to e.g. a Contract.call(), conversion happens automatically\n * // regardless of the initial type.\n * const scValU128 = sci.toU128();\n * const scValI256 = sci.toI256();\n * const scValU64 = sci.toU64();\n *\n * // Lots of ways to initialize:\n * new ScInt(\"123456789123456789\")\n * new ScInt(123456789123456789n);\n * new ScInt(1n << 140n);\n * new ScInt(-42);\n * new ScInt(scValToBigInt(scValU128)); // from above\n *\n * // If you know the type ahead of time (accessing `.raw` is faster than\n * // conversions), you can specify the type directly (otherwise, it's\n * // interpreted from the numbers you pass in):\n * const i = new ScInt(123456789n, { type: \"u256\" });\n *\n * // For example, you can use the underlying `sdk.U256` and convert it to an\n * // `xdr.ScVal` directly like so:\n * const scv = new xdr.ScVal.scvU256(i.raw);\n *\n * // Or reinterpret it as a different type (size permitting):\n * const scv = i.toI64();\n * ```\n *\n * @throws if the `value` is invalid (e.g. floating point), too\n * large (i.e. exceeds a 256-bit value), doesn't fit in the `opts.type`,\n * the signedness of `opts.type` doesn't match the input `value`, or a\n * string `value` can't be parsed as a big integer\n */\nexport class ScInt extends XdrLargeInt {\n /**\n * @param value - a single, integer-like value which will\n * be interpreted in the smallest appropriate XDR type supported by Stellar\n * (64, 128, or 256 bit integer values). signed values are supported, though\n * they are sanity-checked against `opts.type`. if you need 32-bit values,\n * you can construct them directly without needing this wrapper, e.g.\n * `xdr.ScVal.scvU32(1234)`.\n * @param opts - an optional object controlling optional parameters\n * - `type`: specify a type ('i64', 'u64', 'i128', 'u128', 'i256',\n * or 'u256') to override the default type selection. If not specified, the\n * smallest type that fits the value is used.\n */\n constructor(\n value: bigint | number | string,\n opts?: { type?: ScIntType; [key: string]: unknown },\n ) {\n const bigValue = BigInt(value);\n const signed = bigValue < 0n;\n\n let type = opts?.type ?? \"\";\n if (type.startsWith(\"u\") && signed) {\n throw TypeError(`specified type ${opts?.type} yet negative (${value})`);\n }\n\n // If unspecified, we make a best guess at the type based on the bit length\n // of the value, treating 64 as a minimum and 256 as a maximum.\n if (type === \"\") {\n type = signed ? \"i\" : \"u\";\n const bitlen = nearestBigIntSize(bigValue);\n\n switch (bitlen) {\n case 64:\n case 128:\n case 256:\n type += bitlen.toString();\n break;\n\n default:\n throw RangeError(\n `expected 64/128/256 bits for input (${value}), got ${bitlen}`,\n );\n }\n }\n\n super(type as ScIntType, bigValue);\n }\n}\n\nfunction nearestBigIntSize(bigI: bigint): number {\n if (bigI < 0n) {\n // Two's complement: N bits represent -(2^(N-1)) to 2^(N-1)-1.\n // For negative values, compute the signed bit width as\n // (bitlen of abs-1) + 1 to account for the sign bit. This correctly\n // classifies -(2^63) as 64 bits (fits i64) and -(2^63)-1 as 65 bits\n // (needs i128).\n const abs = -bigI;\n const bitlen = (abs - 1n).toString(2).length + 1;\n return [64, 128, 256].find((len) => bitlen <= len) ?? bitlen;\n }\n\n const bitlen = bigI.toString(2).length;\n return [64, 128, 256].find((len) => bitlen <= len) ?? bitlen;\n}\n"],"names":["XdrLargeInt","bitlen"],"mappings":";;;;AA8DO,MAAM,cAAcA,yBAAA,CAAY;AAAA;A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AG,CAAA,IAAKA,OAAAA;AAAA,EACxD;AAEA,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,CAAS,CAAC,CAAA,CAAE,MAAA;AAChC,EAAA,OAAO,CAAC,EAAA,EAAI,GAAA,EAAK,GAAG,CAAA,CAAE,KAAK,CAAC,GAAA,KAAQ,MAAA,IAAU,GAAG,CAAA,IAAK,MAAA;AACxD;;;;"}
1
+ {"version":3,"file":"sc_int.js","sources":["../../../../src/base/numbers/sc_int.ts"],"sourcesContent":["import { XdrLargeInt, type ScIntType } from \"./xdr_large_int.js\";\n\n/**\n * Provides an easier way to manipulate large numbers for Digital World operations.\n *\n * You can instantiate this \"**s**mart **c**ontract integer\" value either from\n * bigints, strings, or numbers (whole numbers, or this will throw).\n *\n * If you need to create a native BigInt from a list of integer \"parts\" (for\n * example, you have a series of encoded 32-bit integers that represent a larger\n * value), you can use the lower level abstraction {@link XdrLargeInt}. For\n * example, you could do `new XdrLargeInt('u128', bytes...).toBigInt()`.\n *\n * @example\n * ```ts\n * import { xdr, ScInt, scValToBigInt } from \"@stellar/stellar-base\";\n *\n * // You have an ScVal from a contract and want to parse it into JS native.\n * const value = xdr.ScVal.fromXDR(someXdr, \"base64\");\n * const bigi = scValToBigInt(value); // grab it as a BigInt\n * let sci = new ScInt(bigi);\n *\n * sci.toNumber(); // gives native JS type (w/ size check)\n * sci.toBigInt(); // gives the native BigInt value\n * sci.toU64(); // gives ScValType-specific XDR constructs (with size checks)\n *\n * // You have a number and want to shove it into a contract.\n * sci = new ScInt(0xdeadcafebabe);\n * sci.toBigInt() // returns 244838016400062n\n * sci.toNumber() // throws: too large\n *\n * // Pass any to e.g. a Contract.call(), conversion happens automatically\n * // regardless of the initial type.\n * const scValU128 = sci.toU128();\n * const scValI256 = sci.toI256();\n * const scValU64 = sci.toU64();\n *\n * // Lots of ways to initialize:\n * new ScInt(\"123456789123456789\")\n * new ScInt(123456789123456789n);\n * new ScInt(1n << 140n);\n * new ScInt(-42);\n * new ScInt(scValToBigInt(scValU128)); // from above\n *\n * // If you know the type ahead of time (accessing `.raw` is faster than\n * // conversions), you can specify the type directly (otherwise, it's\n * // interpreted from the numbers you pass in):\n * const i = new ScInt(123456789n, { type: \"u256\" });\n *\n * // For example, you can use the underlying `sdk.U256` and convert it to an\n * // `xdr.ScVal` directly like so:\n * const scv = new xdr.ScVal.scvU256(i.raw);\n *\n * // Or reinterpret it as a different type (size permitting):\n * const scv = i.toI64();\n * ```\n *\n * @throws if the `value` is invalid (e.g. floating point), too\n * large (i.e. exceeds a 256-bit value), doesn't fit in the `opts.type`,\n * the signedness of `opts.type` doesn't match the input `value`, or a\n * string `value` can't be parsed as a big integer\n */\nexport class ScInt extends XdrLargeInt {\n /**\n * @param value - a single, integer-like value which will\n * be interpreted in the smallest appropriate XDR type supported by Digital World\n * (64, 128, or 256 bit integer values). signed values are supported, though\n * they are sanity-checked against `opts.type`. if you need 32-bit values,\n * you can construct them directly without needing this wrapper, e.g.\n * `xdr.ScVal.scvU32(1234)`.\n * @param opts - an optional object controlling optional parameters\n * - `type`: specify a type ('i64', 'u64', 'i128', 'u128', 'i256',\n * or 'u256') to override the default type selection. If not specified, the\n * smallest type that fits the value is used.\n */\n constructor(\n value: bigint | number | string,\n opts?: { type?: ScIntType; [key: string]: unknown },\n ) {\n const bigValue = BigInt(value);\n const signed = bigValue < 0n;\n\n let type = opts?.type ?? \"\";\n if (type.startsWith(\"u\") && signed) {\n throw TypeError(`specified type ${opts?.type} yet negative (${value})`);\n }\n\n // If unspecified, we make a best guess at the type based on the bit length\n // of the value, treating 64 as a minimum and 256 as a maximum.\n if (type === \"\") {\n type = signed ? \"i\" : \"u\";\n const bitlen = nearestBigIntSize(bigValue);\n\n switch (bitlen) {\n case 64:\n case 128:\n case 256:\n type += bitlen.toString();\n break;\n\n default:\n throw RangeError(\n `expected 64/128/256 bits for input (${value}), got ${bitlen}`,\n );\n }\n }\n\n super(type as ScIntType, bigValue);\n }\n}\n\nfunction nearestBigIntSize(bigI: bigint): number {\n if (bigI < 0n) {\n // Two's complement: N bits represent -(2^(N-1)) to 2^(N-1)-1.\n // For negative values, compute the signed bit width as\n // (bitlen of abs-1) + 1 to account for the sign bit. This correctly\n // classifies -(2^63) as 64 bits (fits i64) and -(2^63)-1 as 65 bits\n // (needs i128).\n const abs = -bigI;\n const bitlen = (abs - 1n).toString(2).length + 1;\n return [64, 128, 256].find((len) => bitlen <= len) ?? bitlen;\n }\n\n const bitlen = bigI.toString(2).length;\n return [64, 128, 256].find((len) => bitlen <= len) ?? bitlen;\n}\n"],"names":["XdrLargeInt","bitlen"],"mappings":";;;;AA8DO,MAAM,cAAcA,yBAAA,CAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAarC,WAAA,CACE,OACA,IAAA,EACA;AACA,IAAA,MAAM,QAAA,GAAW,OAAO,KAAK,CAAA;AAC7B,IAAA,MAAM,SAAS,QAAA,GAAW,EAAA;AAE1B,IAAA,IAAI,IAAA,GAAO,MAAM,IAAA,IAAQ,EAAA;AACzB,IAAA,IAAI,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,IAAK,MAAA,EAAQ;AAClC,MAAA,MAAM,UAAU,CAAA,eAAA,EAAkB,IAAA,EAAM,IAAI,CAAA,eAAA,EAAkB,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,IACxE;AAIA,IAAA,IAAI,SAAS,EAAA,EAAI;AACf,MAAA,IAAA,GAAO,SAAS,GAAA,GAAM,GAAA;AACtB,MAAA,MAAM,MAAA,GAAS,kBAAkB,QAAQ,CAAA;AAEzC,MAAA,QAAQ,MAAA;AAAQ,QACd,KAAK,EAAA;AAAA,QACL,KAAK,GAAA;AAAA,QACL,KAAK,GAAA;AACH,UAAA,IAAA,IAAQ,OAAO,QAAA,EAAS;AACxB,UAAA;AAAA,QAEF;AACE,UAAA,MAAM,UAAA;AAAA,YACJ,CAAA,oCAAA,EAAuC,KAAK,CAAA,OAAA,EAAU,MAAM,CAAA;AAAA,WAC9D;AAAA;AACJ,IACF;AAEA,IAAA,KAAA,CAAM,MAAmB,QAAQ,CAAA;AAAA,EACnC;AACF;AAEA,SAAS,kBAAkB,IAAA,EAAsB;AAC/C,EAAA,IAAI,OAAO,EAAA,EAAI;AAMb,IAAA,MAAM,MAAM,CAAC,IAAA;AACb,IAAA,MAAMC,WAAU,GAAA,GAAM,EAAA,EAAI,QAAA,CAAS,CAAC,EAAE,MAAA,GAAS,CAAA;AAC/C,IAAA,OAAO,CAAC,EAAA,EAAI,GAAA,EAAK,GAAG,CAAA,CAAE,KAAK,CAAC,GAAA,KAAQA,OAAAA,IAAU,GAAG,CAAA,IAAKA,OAAAA;AAAA,EACxD;AAEA,EAAA,MAAM,MAAA,GAAS,IAAA,CAAK,QAAA,CAAS,CAAC,CAAA,CAAE,MAAA;AAChC,EAAA,OAAO,CAAC,EAAA,EAAI,GAAA,EAAK,GAAG,CAAA,CAAE,KAAK,CAAC,GAAA,KAAQ,MAAA,IAAU,GAAG,CAAA,IAAK,MAAA;AACxD;;;;"}
@@ -343,7 +343,7 @@ class Operation {
343
343
  static restoreFootprint = restore_footprint.restoreFootprint;
344
344
  // These are not `xdr.Operation`s directly, but proxies for common
345
345
  // versions of `Operation.invokeHostFunction`
346
- static createStellarAssetContract = invoke_host_function.createStellarAssetContract;
346
+ static createDigitalWorldAssetContract = invoke_host_function.createDigitalWorldAssetContract;
347
347
  static invokeContractFunction = invoke_host_function.invokeContractFunction;
348
348
  static createCustomContract = invoke_host_function.createCustomContract;
349
349
  static uploadContractWasm = invoke_host_function.uploadContractWasm;