@stellar/stellar-sdk 16.0.0-rc.2 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/stellar-sdk-axios.js +25 -27
  2. package/dist/stellar-sdk-axios.js.map +1 -1
  3. package/dist/stellar-sdk-axios.min.js +1 -1
  4. package/dist/stellar-sdk-axios.min.js.map +1 -1
  5. package/dist/stellar-sdk.js +26 -28
  6. package/dist/stellar-sdk.js.map +1 -1
  7. package/dist/stellar-sdk.min.js +2 -2
  8. package/dist/stellar-sdk.min.js.map +1 -1
  9. package/lib/axios/cjs/base/transaction_builder.js +13 -1
  10. package/lib/axios/cjs/base/transaction_builder.js.map +1 -1
  11. package/lib/axios/cjs/bindings/config.js +1 -1
  12. package/lib/axios/cjs/bindings/config.js.map +1 -1
  13. package/lib/axios/cjs/bindings/wasm_fetcher.js +1 -1
  14. package/lib/axios/cjs/bindings/wasm_fetcher.js.map +1 -1
  15. package/lib/axios/cjs/contract/assembled_transaction.js +1 -6
  16. package/lib/axios/cjs/contract/assembled_transaction.js.map +1 -1
  17. package/lib/axios/cjs/contract/client.js.map +1 -1
  18. package/lib/axios/cjs/contract/spec.js.map +1 -1
  19. package/lib/axios/cjs/contract/types.js.map +1 -1
  20. package/lib/axios/cjs/contract/utils.js.map +1 -1
  21. package/lib/axios/cjs/contract/wasm_spec_parser.js +1 -1
  22. package/lib/axios/cjs/contract/wasm_spec_parser.js.map +1 -1
  23. package/lib/axios/cjs/horizon/call_builder.js.map +1 -1
  24. package/lib/axios/cjs/horizon/horizon_api.js.map +1 -1
  25. package/lib/axios/cjs/horizon/horizon_axios_client.js +1 -1
  26. package/lib/axios/cjs/horizon/horizon_axios_client.js.map +1 -1
  27. package/lib/axios/cjs/http-client/fetch-client.js +1 -1
  28. package/lib/axios/cjs/http-client/fetch-client.js.map +1 -1
  29. package/lib/axios/cjs/http-client/types.js.map +1 -1
  30. package/lib/axios/cjs/rpc/axios.js +1 -1
  31. package/lib/axios/cjs/rpc/axios.js.map +1 -1
  32. package/lib/axios/cjs/rpc/jsonrpc.js.map +1 -1
  33. package/lib/axios/cjs/rpc/server.js +6 -15
  34. package/lib/axios/cjs/rpc/server.js.map +1 -1
  35. package/lib/axios/cjs/webauth/challenge_transaction.js.map +1 -1
  36. package/lib/axios/esm/base/transaction_builder.js +13 -1
  37. package/lib/axios/esm/base/transaction_builder.js.map +1 -1
  38. package/lib/axios/esm/bindings/config.js +1 -1
  39. package/lib/axios/esm/bindings/config.js.map +1 -1
  40. package/lib/axios/esm/bindings/wasm_fetcher.js +1 -1
  41. package/lib/axios/esm/bindings/wasm_fetcher.js.map +1 -1
  42. package/lib/axios/esm/contract/assembled_transaction.js +1 -6
  43. package/lib/axios/esm/contract/assembled_transaction.js.map +1 -1
  44. package/lib/axios/esm/contract/client.js.map +1 -1
  45. package/lib/axios/esm/contract/spec.js.map +1 -1
  46. package/lib/axios/esm/contract/types.d.ts +0 -9
  47. package/lib/axios/esm/contract/types.js.map +1 -1
  48. package/lib/axios/esm/contract/utils.js.map +1 -1
  49. package/lib/axios/esm/contract/wasm_spec_parser.js +1 -1
  50. package/lib/axios/esm/contract/wasm_spec_parser.js.map +1 -1
  51. package/lib/axios/esm/horizon/call_builder.js.map +1 -1
  52. package/lib/axios/esm/horizon/horizon_api.js.map +1 -1
  53. package/lib/axios/esm/horizon/horizon_axios_client.js +1 -1
  54. package/lib/axios/esm/horizon/horizon_axios_client.js.map +1 -1
  55. package/lib/axios/esm/http-client/fetch-client.js +1 -1
  56. package/lib/axios/esm/http-client/fetch-client.js.map +1 -1
  57. package/lib/axios/esm/http-client/types.js.map +1 -1
  58. package/lib/axios/esm/rpc/axios.js +1 -1
  59. package/lib/axios/esm/rpc/axios.js.map +1 -1
  60. package/lib/axios/esm/rpc/jsonrpc.js.map +1 -1
  61. package/lib/axios/esm/rpc/server.d.ts +2 -7
  62. package/lib/axios/esm/rpc/server.js +6 -15
  63. package/lib/axios/esm/rpc/server.js.map +1 -1
  64. package/lib/axios/esm/webauth/challenge_transaction.js.map +1 -1
  65. package/lib/cjs/base/transaction_builder.js +13 -1
  66. package/lib/cjs/base/transaction_builder.js.map +1 -1
  67. package/lib/cjs/bindings/config.js +1 -1
  68. package/lib/cjs/bindings/config.js.map +1 -1
  69. package/lib/cjs/bindings/wasm_fetcher.js +1 -1
  70. package/lib/cjs/bindings/wasm_fetcher.js.map +1 -1
  71. package/lib/cjs/contract/assembled_transaction.js +1 -6
  72. package/lib/cjs/contract/assembled_transaction.js.map +1 -1
  73. package/lib/cjs/contract/client.js.map +1 -1
  74. package/lib/cjs/contract/spec.js.map +1 -1
  75. package/lib/cjs/contract/types.js.map +1 -1
  76. package/lib/cjs/contract/utils.js.map +1 -1
  77. package/lib/cjs/contract/wasm_spec_parser.js +1 -1
  78. package/lib/cjs/contract/wasm_spec_parser.js.map +1 -1
  79. package/lib/cjs/horizon/call_builder.js.map +1 -1
  80. package/lib/cjs/horizon/horizon_api.js.map +1 -1
  81. package/lib/cjs/horizon/horizon_axios_client.js +1 -1
  82. package/lib/cjs/horizon/horizon_axios_client.js.map +1 -1
  83. package/lib/cjs/http-client/fetch-client.js +1 -1
  84. package/lib/cjs/http-client/fetch-client.js.map +1 -1
  85. package/lib/cjs/http-client/types.js.map +1 -1
  86. package/lib/cjs/rpc/axios.js +1 -1
  87. package/lib/cjs/rpc/axios.js.map +1 -1
  88. package/lib/cjs/rpc/jsonrpc.js.map +1 -1
  89. package/lib/cjs/rpc/server.js +6 -15
  90. package/lib/cjs/rpc/server.js.map +1 -1
  91. package/lib/cjs/webauth/challenge_transaction.js.map +1 -1
  92. package/lib/esm/base/transaction_builder.js +13 -1
  93. package/lib/esm/base/transaction_builder.js.map +1 -1
  94. package/lib/esm/bindings/config.js +1 -1
  95. package/lib/esm/bindings/config.js.map +1 -1
  96. package/lib/esm/bindings/wasm_fetcher.js +1 -1
  97. package/lib/esm/bindings/wasm_fetcher.js.map +1 -1
  98. package/lib/esm/contract/assembled_transaction.js +1 -6
  99. package/lib/esm/contract/assembled_transaction.js.map +1 -1
  100. package/lib/esm/contract/client.js.map +1 -1
  101. package/lib/esm/contract/spec.js.map +1 -1
  102. package/lib/esm/contract/types.d.ts +0 -9
  103. package/lib/esm/contract/types.js.map +1 -1
  104. package/lib/esm/contract/utils.js.map +1 -1
  105. package/lib/esm/contract/wasm_spec_parser.js +1 -1
  106. package/lib/esm/contract/wasm_spec_parser.js.map +1 -1
  107. package/lib/esm/horizon/call_builder.js.map +1 -1
  108. package/lib/esm/horizon/horizon_api.js.map +1 -1
  109. package/lib/esm/horizon/horizon_axios_client.js +1 -1
  110. package/lib/esm/horizon/horizon_axios_client.js.map +1 -1
  111. package/lib/esm/http-client/fetch-client.js +1 -1
  112. package/lib/esm/http-client/fetch-client.js.map +1 -1
  113. package/lib/esm/http-client/types.js.map +1 -1
  114. package/lib/esm/rpc/axios.js +1 -1
  115. package/lib/esm/rpc/axios.js.map +1 -1
  116. package/lib/esm/rpc/jsonrpc.js.map +1 -1
  117. package/lib/esm/rpc/server.d.ts +2 -7
  118. package/lib/esm/rpc/server.js +6 -15
  119. package/lib/esm/rpc/server.js.map +1 -1
  120. package/lib/esm/webauth/challenge_transaction.js.map +1 -1
  121. package/package.json +2 -5
@@ -1 +1 @@
1
- {"version":3,"file":"assembled_transaction.js","sources":["../../../src/contract/assembled_transaction.ts"],"sourcesContent":["/* disable max-classes rule, because extending error shouldn't count! */\n/* eslint max-classes-per-file: 0 */\nimport {\n Account,\n Address,\n BASE_FEE,\n Contract,\n Operation,\n SorobanDataBuilder,\n TransactionBuilder,\n authorizeEntry as stellarBaseAuthorizeEntry,\n xdr,\n} from \"../base/index.js\";\n// internal helper (not part of the public API), imported directly from auth.js\nimport { getAddressCredentials } from \"../base/auth.js\";\nimport type {\n AssembledTransactionOptions,\n ClientOptions,\n MethodOptions,\n Tx,\n WalletError,\n XDR_BASE64,\n} from \"./types.js\";\nimport { Server } from \"../rpc/index.js\";\nimport { Api } from \"../rpc/api.js\";\nimport { assembleTransaction } from \"../rpc/transaction.js\";\nimport type { Client } from \"./client.js\";\nimport { Err } from \"./rust_result.js\";\nimport {\n contractErrorPattern,\n implementsToString,\n getAccount,\n} from \"./utils.js\";\nimport { DEFAULT_TIMEOUT } from \"./types.js\";\nimport { SentTransaction, Watcher } from \"./sent_transaction.js\";\nimport { Spec } from \"./spec.js\";\nimport {\n ExpiredStateError,\n ExternalServiceError,\n FakeAccountError,\n InternalWalletError,\n InvalidClientRequestError,\n NeedsMoreSignaturesError,\n NoSignatureNeededError,\n NoSignerError,\n NotYetSimulatedError,\n NoUnsignedNonInvokerAuthEntriesError,\n RestoreFailureError,\n SimulationFailedError,\n UserRejectedError,\n} from \"./errors.js\";\n\n/**\n * The main workhorse of {@link Client}. This class is used to wrap a\n * transaction-under-construction and provide high-level interfaces to the most\n * common workflows, while still providing access to low-level stellar-sdk\n * transaction manipulation.\n *\n * Most of the time, you will not construct an `AssembledTransaction` directly,\n * but instead receive one as the return value of a `Client` method. If\n * you're familiar with the libraries generated by soroban-cli's\n * `contract bindings typescript` command, these also wraps `Client` and return\n * `AssembledTransaction` instances.\n *\n * Let's look at examples of how to use `AssembledTransaction` for a variety of\n * use-cases:\n *\n * #### 1. Simple read call\n *\n * Since these only require simulation, you can get the `result` of the call\n * right after constructing your `AssembledTransaction`:\n *\n * ```ts\n * const { result } = await AssembledTransaction.build({\n * method: 'myReadMethod',\n * args: spec.funcArgsToScVals('myReadMethod', {\n * args: 'for',\n * my: 'method',\n * ...\n * }),\n * contractId: 'C123…',\n * networkPassphrase: '…',\n * rpcUrl: 'https://…',\n * publicKey: undefined, // irrelevant, for simulation-only read calls\n * parseResultXdr: (result: xdr.ScVal) =>\n * spec.funcResToNative('myReadMethod', result),\n * })\n * ```\n *\n * While that looks pretty complicated, most of the time you will use this in\n * conjunction with {@link Client}, which simplifies it to:\n *\n * ```ts\n * const { result } = await client.myReadMethod({\n * args: 'for',\n * my: 'method',\n * ...\n * })\n * ```\n *\n * #### 2. Simple write call\n *\n * For write calls that will be simulated and then sent to the network without\n * further manipulation, only one more step is needed:\n *\n * ```ts\n * const assembledTx = await client.myWriteMethod({\n * args: 'for',\n * my: 'method',\n * ...\n * })\n * const sentTx = await assembledTx.signAndSend()\n * ```\n *\n * Here we're assuming that you're using a {@link Client}, rather than\n * constructing `AssembledTransaction`'s directly.\n *\n * Note that `sentTx`, the return value of `signAndSend`, is a\n * {@link SentTransaction}. `SentTransaction` is similar to\n * `AssembledTransaction`, but is missing many of the methods and fields that\n * are only relevant while assembling a transaction. It also has a few extra\n * methods and fields that are only relevant after the transaction has been\n * sent to the network.\n *\n * Like `AssembledTransaction`, `SentTransaction` also has a `result` getter,\n * which contains the parsed final return value of the contract call. Most of\n * the time, you may only be interested in this, so rather than getting the\n * whole `sentTx` you may just want to:\n *\n * ```ts\n * const tx = await client.myWriteMethod({ args: 'for', my: 'method', ... })\n * const { result } = await tx.signAndSend()\n * ```\n *\n * #### 3. More fine-grained control over transaction construction\n *\n * If you need more control over the transaction before simulating it, you can\n * set various {@link MethodOptions} when constructing your\n * `AssembledTransaction`. With a {@link Client}, this is passed as a\n * second object after the arguments (or the only object, if the method takes\n * no arguments):\n *\n * ```ts\n * const tx = await client.myWriteMethod(\n * {\n * args: 'for',\n * my: 'method',\n * ...\n * }, {\n * fee: '10000', // default: {@link BASE_FEE}\n * simulate: false,\n * timeoutInSeconds: 20, // default: {@link DEFAULT_TIMEOUT}\n * }\n * )\n * ```\n *\n * Since we've skipped simulation, we can now edit the `raw` transaction and\n * then manually call `simulate`:\n *\n * ```ts\n * tx.raw.addMemo(Memo.text('Nice memo, friend!'))\n * await tx.simulate()\n * ```\n *\n * If you need to inspect the simulation later, you can access it with\n * `tx.simulation`.\n *\n * #### 4. Multi-auth workflows\n *\n * Soroban, and Stellar in general, allows multiple parties to sign a\n * transaction.\n *\n * Let's consider an Atomic Swap contract. Alice wants to give 10 of her Token\n * A tokens to Bob for 5 of his Token B tokens.\n *\n * ```ts\n * const ALICE = 'G123...'\n * const BOB = 'G456...'\n * const TOKEN_A = 'C123…'\n * const TOKEN_B = 'C456…'\n * const AMOUNT_A = 10n\n * const AMOUNT_B = 5n\n * ```\n *\n * Let's say Alice is also going to be the one signing the final transaction\n * envelope, meaning she is the invoker. So your app, from Alice's browser,\n * simulates the `swap` call:\n *\n * ```ts\n * const tx = await swapClient.swap({\n * a: ALICE,\n * b: BOB,\n * token_a: TOKEN_A,\n * token_b: TOKEN_B,\n * amount_a: AMOUNT_A,\n * amount_b: AMOUNT_B,\n * })\n * ```\n *\n * But your app can't `signAndSend` this right away, because Bob needs to sign\n * it first. You can check this:\n *\n * ```ts\n * const whoElseNeedsToSign = tx.needsNonInvokerSigningBy()\n * ```\n *\n * You can verify that `whoElseNeedsToSign` is an array of length `1`,\n * containing only Bob's public key.\n *\n * Then, still on Alice's machine, you can serialize the\n * transaction-under-assembly:\n *\n * ```ts\n * const json = tx.toJSON()\n * ```\n *\n * And now you need to send it to Bob's browser. How you do this depends on\n * your app. Maybe you send it to a server first, maybe you use WebSockets, or\n * maybe you have Alice text the JSON blob to Bob and have him paste it into\n * your app in his browser (note: this option might be error-prone 😄).\n *\n * Once you get the JSON blob into your app on Bob's machine, you can\n * deserialize it:\n *\n * ```ts\n * const tx = swapClient.txFromJSON(json)\n * ```\n *\n * Or, if you're using a client generated with\n * `soroban contract bindings typescript`, this deserialization will look like:\n *\n * ```ts\n * const tx = swapClient.fromJSON.swap(json)\n * ```\n *\n * Then you can have Bob sign it. What Bob will actually need to sign is some\n * _auth entries_ within the transaction, not the transaction itself or the\n * transaction envelope. Your app can verify that Bob has the correct wallet\n * selected, then:\n *\n * ```ts\n * await tx.signAuthEntries()\n * ```\n *\n * Under the hood, this uses `signAuthEntry`, which you either need to inject\n * during initial construction of the `Client`/`AssembledTransaction`,\n * or which you can pass directly to `signAuthEntries`.\n *\n * Now Bob can again serialize the transaction and send back to Alice, where\n * she can finally call `signAndSend()`.\n *\n * To see an even more complicated example, where Alice swaps with Bob but the\n * transaction is invoked by yet another party, check out\n * [test-swap.js](https://github.com/stellar/js-stellar-sdk/blob/master/test/e2e/src/test-swap.js).\n *\n */\nexport class AssembledTransaction<T> {\n /**\n * The TransactionBuilder as constructed in\n * {@link AssembledTransaction}.build. Feel free set `simulate: false` to modify\n * this object before calling `tx.simulate()` manually. Example:\n *\n * ```ts\n * const tx = await myContract.myMethod(\n * { args: 'for', my: 'method', ... },\n * { simulate: false }\n * );\n * tx.raw.addMemo(Memo.text('Nice memo, friend!'))\n * await tx.simulate();\n * ```\n */\n public raw?: TransactionBuilder;\n\n /**\n * Stores the original operation from `buildWithOp` for reuse during\n * automatic state restoration rebuilds.\n */\n private originalOp?: xdr.Operation;\n\n /**\n * The Transaction as it was built with `raw.build()` right before\n * simulation. Once this is set, modifying `raw` will have no effect unless\n * you call `tx.simulate()` again.\n */\n public built?: Tx;\n\n /**\n * The result of the transaction simulation. This is set after the first call\n * to `simulate`. It is difficult to serialize and deserialize, so it is not\n * included in the `toJSON` and `fromJSON` methods. See `simulationData`\n * cached, serializable access to the data needed by AssembledTransaction\n * logic.\n */\n public simulation?: Api.SimulateTransactionResponse;\n\n /**\n * Cached simulation result. This is set after the first call to\n * {@link AssembledTransaction.simulationData}, and is used to facilitate\n * serialization and deserialization of the AssembledTransaction.\n *\n * Most of the time, if you need this data, you can call\n * `tx.simulation.result`.\n *\n * If you need access to this data after a transaction has been serialized\n * and then deserialized, you can call `simulationData.result`.\n */\n private simulationResult?: Api.SimulateHostFunctionResult;\n\n /**\n * Cached simulation transaction data. This is set after the first call to\n * {@link AssembledTransaction.simulationData}, and is used to facilitate\n * serialization and deserialization of the AssembledTransaction.\n *\n * Most of the time, if you need this data, you can call\n * `simulation.transactionData`.\n *\n * If you need access to this data after a transaction has been serialized\n * and then deserialized, you can call `simulationData.transactionData`.\n */\n private simulationTransactionData?: xdr.SorobanTransactionData;\n\n /**\n * The Soroban server to use for all RPC calls. This is constructed from the\n * `rpcUrl` in the options.\n */\n private server: Server;\n\n /**\n * The signed transaction.\n */\n public signed?: Tx;\n\n /**\n * A list of the most important errors that various AssembledTransaction\n * methods can throw. Feel free to catch specific errors in your application\n * logic.\n */\n static Errors = {\n ExpiredState: ExpiredStateError,\n RestorationFailure: RestoreFailureError,\n NeedsMoreSignatures: NeedsMoreSignaturesError,\n NoSignatureNeeded: NoSignatureNeededError,\n NoUnsignedNonInvokerAuthEntries: NoUnsignedNonInvokerAuthEntriesError,\n NoSigner: NoSignerError,\n NotYetSimulated: NotYetSimulatedError,\n FakeAccount: FakeAccountError,\n SimulationFailed: SimulationFailedError,\n InternalWalletError,\n ExternalServiceError,\n InvalidClientRequest: InvalidClientRequestError,\n UserRejected: UserRejectedError,\n };\n\n /**\n * Serialize the AssembledTransaction to a JSON string. This is useful for\n * saving the transaction to a database or sending it over the wire for\n * multi-auth workflows. `fromJSON` can be used to deserialize the\n * transaction. This only works with transactions that have been simulated.\n */\n toJSON() {\n return JSON.stringify({\n method: this.options.method,\n tx: this.built?.toXDR(),\n simulationResult: {\n auth: this.simulationData.result.auth.map((a) => a.toXDR(\"base64\")),\n retval: this.simulationData.result.retval.toXDR(\"base64\"),\n },\n simulationTransactionData:\n this.simulationData.transactionData.toXDR(\"base64\"),\n });\n }\n\n /**\n * Validate that a built transaction is a single invokeContract operation\n * targeting the expected contract, and return the parsed InvokeContractArgs.\n */\n private static validateInvokeContractOp(\n built: Tx,\n expectedContractId: string,\n ): xdr.InvokeContractArgs {\n if (built.operations.length !== 1) {\n throw new Error(\n \"Transaction envelope must contain exactly one operation.\",\n );\n }\n\n const operation = built.operations[0];\n\n if (operation.type !== \"invokeHostFunction\") {\n throw new Error(\n \"Transaction envelope does not contain an invokeHostFunction operation.\",\n );\n }\n\n const invokeOp = operation as Operation.InvokeHostFunction;\n\n if (invokeOp.func.switch().name !== \"hostFunctionTypeInvokeContract\") {\n throw new Error(\n \"Transaction envelope does not contain an invokeContract host function.\",\n );\n }\n\n const invokeContractArgs = invokeOp.func.value() as xdr.InvokeContractArgs;\n\n let contractAddress: xdr.ScAddress;\n let functionName: string;\n\n try {\n contractAddress = invokeContractArgs.contractAddress();\n functionName = invokeContractArgs.functionName().toString(\"utf-8\");\n } catch {\n throw new Error(\n \"Could not extract contract address or method name from the transaction envelope.\",\n );\n }\n\n if (!contractAddress || !functionName) {\n throw new Error(\n \"Could not extract contract address or method name from the transaction envelope.\",\n );\n }\n\n const xdrContractId = Address.fromScAddress(contractAddress).toString();\n if (xdrContractId !== expectedContractId) {\n throw new Error(\n `Transaction envelope targets contract ${xdrContractId}, but this Client is configured for ${expectedContractId}.`,\n );\n }\n\n return invokeContractArgs;\n }\n\n static fromJSON<T>(\n options: Omit<AssembledTransactionOptions<T>, \"args\">,\n {\n tx,\n simulationResult,\n simulationTransactionData,\n }: {\n tx: XDR_BASE64;\n simulationResult: {\n auth: XDR_BASE64[];\n retval: XDR_BASE64;\n };\n simulationTransactionData: XDR_BASE64;\n },\n ): AssembledTransaction<T> {\n const txn = new AssembledTransaction(options);\n txn.built = TransactionBuilder.fromXDR(tx, options.networkPassphrase) as Tx;\n\n const invokeContractArgs = AssembledTransaction.validateInvokeContractOp(\n txn.built,\n options.contractId,\n );\n\n const xdrMethod = invokeContractArgs.functionName().toString(\"utf-8\");\n\n if (xdrMethod !== options.method) {\n throw new Error(\n `Transaction envelope calls method '${xdrMethod}', but the provided method is '${options.method}'.`,\n );\n }\n\n txn.simulationResult = {\n auth: simulationResult.auth.map((a) =>\n xdr.SorobanAuthorizationEntry.fromXDR(a, \"base64\"),\n ),\n retval: xdr.ScVal.fromXDR(simulationResult.retval, \"base64\"),\n };\n txn.simulationTransactionData = xdr.SorobanTransactionData.fromXDR(\n simulationTransactionData,\n \"base64\",\n );\n return txn;\n }\n\n /**\n * Serialize the AssembledTransaction to a base64-encoded XDR string.\n */\n toXDR(): string {\n if (!this.built)\n throw new Error(\n \"Transaction has not yet been simulated; \" +\n \"call `AssembledTransaction.simulate` first.\",\n );\n return this.built?.toEnvelope().toXDR(\"base64\");\n }\n\n /**\n * Deserialize the AssembledTransaction from a base64-encoded XDR string.\n */\n static fromXDR<T>(\n options: Omit<\n AssembledTransactionOptions<T>,\n \"args\" | \"method\" | \"parseResultXdr\"\n >,\n encodedXDR: string,\n spec: Spec,\n ): AssembledTransaction<T> {\n const envelope = xdr.TransactionEnvelope.fromXDR(encodedXDR, \"base64\");\n const built = TransactionBuilder.fromXDR(\n envelope,\n options.networkPassphrase,\n ) as Tx;\n\n const invokeContractArgs = AssembledTransaction.validateInvokeContractOp(\n built,\n options.contractId,\n );\n\n const method = invokeContractArgs.functionName().toString(\"utf-8\");\n const txn = new AssembledTransaction({\n ...options,\n method,\n parseResultXdr: (result: xdr.ScVal) =>\n spec.funcResToNative(method, result),\n });\n txn.built = built;\n return txn;\n }\n\n private handleWalletError(error?: WalletError): void {\n if (!error) return;\n\n const { message, code } = error;\n const fullMessage = `${message}${error.ext ? ` (${error.ext.join(\", \")})` : \"\"}`;\n\n switch (code) {\n case -1:\n throw new AssembledTransaction.Errors.InternalWalletError(fullMessage);\n case -2:\n throw new AssembledTransaction.Errors.ExternalServiceError(fullMessage);\n case -3:\n throw new AssembledTransaction.Errors.InvalidClientRequest(fullMessage);\n case -4:\n throw new AssembledTransaction.Errors.UserRejected(fullMessage);\n default:\n throw new Error(`Unhandled error: ${fullMessage}`);\n }\n }\n\n private constructor(public options: AssembledTransactionOptions<T>) {\n this.options.simulate = this.options.simulate ?? true;\n const { server, allowHttp, headers, rpcUrl } = this.options;\n this.server = server ?? new Server(rpcUrl, { allowHttp, headers });\n }\n\n /**\n * Construct a new AssembledTransaction. This is the main way to create a new\n * AssembledTransaction; the constructor is private.\n *\n * This is an asynchronous constructor for two reasons:\n *\n * 1. It needs to fetch the account from the network to get the current\n * sequence number.\n * 2. It needs to simulate the transaction to get the expected fee.\n *\n * If you don't want to simulate the transaction, you can set `simulate` to\n * `false` in the options.\n *\n * If you need to create an operation other than `invokeHostFunction`, you\n * can use {@link AssembledTransaction.buildWithOp} instead.\n *\n * @example\n * ```ts\n * const tx = await AssembledTransaction.build({\n * ...,\n * simulate: false,\n * })\n * ```\n */\n static build<T>(\n options: AssembledTransactionOptions<T>,\n ): Promise<AssembledTransaction<T>> {\n const contract = new Contract(options.contractId);\n return AssembledTransaction.buildWithOp(\n contract.call(options.method, ...(options.args ?? [])),\n options,\n );\n }\n\n /**\n * Construct a new AssembledTransaction, specifying an Operation other than\n * `invokeHostFunction` (the default used by {@link AssembledTransaction.build}).\n *\n * Note: `AssembledTransaction` currently assumes these operations can be\n * simulated. This is not true for classic operations; only for those used by\n * Soroban Smart Contracts like `invokeHostFunction` and `createCustomContract`.\n *\n * @example\n * ```ts\n * const tx = await AssembledTransaction.buildWithOp(\n * Operation.createCustomContract({ ... });\n * {\n * ...,\n * simulate: false,\n * }\n * )\n * ```\n */\n static async buildWithOp<T>(\n operation: xdr.Operation,\n options: AssembledTransactionOptions<T>,\n ): Promise<AssembledTransaction<T>> {\n const tx = new AssembledTransaction(options);\n tx.originalOp = operation;\n const account = await getAccount(options, tx.server);\n tx.raw = new TransactionBuilder(account, {\n fee: options.fee ?? BASE_FEE,\n networkPassphrase: options.networkPassphrase,\n })\n .setTimeout(options.timeoutInSeconds ?? DEFAULT_TIMEOUT)\n .addOperation(operation);\n\n if (options.simulate) await tx.simulate();\n\n return tx;\n }\n\n private static async buildFootprintRestoreTransaction<T>(\n options: AssembledTransactionOptions<T>,\n sorobanData: SorobanDataBuilder | xdr.SorobanTransactionData,\n account: Account,\n fee: string,\n ): Promise<AssembledTransaction<T>> {\n const tx = new AssembledTransaction(options);\n tx.raw = new TransactionBuilder(account, {\n fee,\n networkPassphrase: options.networkPassphrase,\n })\n .setSorobanData(\n sorobanData instanceof SorobanDataBuilder\n ? sorobanData.build()\n : sorobanData,\n )\n .addOperation(Operation.restoreFootprint({}))\n .setTimeout(options.timeoutInSeconds ?? DEFAULT_TIMEOUT);\n await tx.simulate({ restore: false });\n return tx;\n }\n\n simulate = async ({ restore }: { restore?: boolean } = {}): Promise<this> => {\n if (!this.built) {\n if (!this.raw) {\n throw new Error(\n \"Transaction has not yet been assembled; \" +\n \"call `AssembledTransaction.build` first.\",\n );\n }\n this.built = this.raw.build();\n }\n restore = restore ?? this.options.restore;\n\n // need to force re-calculation of simulationData for new simulation\n delete this.simulationResult;\n delete this.simulationTransactionData;\n this.simulation = await this.server.simulateTransaction(\n this.built,\n undefined,\n undefined,\n this.options.authV2,\n );\n\n if (restore && Api.isSimulationRestore(this.simulation)) {\n const account = await getAccount(this.options, this.server);\n const result = await this.restoreFootprint(\n this.simulation.restorePreamble,\n account,\n );\n if (result.status === Api.GetTransactionStatus.SUCCESS) {\n // need to rebuild the transaction with bumped account sequence number\n const op = this.originalOp\n ? this.originalOp\n : new Contract(this.options.contractId).call(\n this.options.method,\n ...(this.options.args ?? []),\n );\n this.raw = new TransactionBuilder(account, {\n fee: this.options.fee ?? BASE_FEE,\n networkPassphrase: this.options.networkPassphrase,\n })\n .addOperation(op)\n .setTimeout(this.options.timeoutInSeconds ?? DEFAULT_TIMEOUT);\n delete this.built;\n await this.simulate();\n return this;\n }\n throw new AssembledTransaction.Errors.RestorationFailure(\n `Automatic restore failed! You set 'restore: true' but the attempted restore did not work. Result:\\n${JSON.stringify(result)}`,\n );\n }\n\n if (Api.isSimulationSuccess(this.simulation)) {\n this.built = assembleTransaction(this.built, this.simulation).build();\n }\n\n return this;\n };\n\n get simulationData(): {\n result: Api.SimulateHostFunctionResult;\n transactionData: xdr.SorobanTransactionData;\n } {\n if (this.simulationResult && this.simulationTransactionData) {\n return {\n result: this.simulationResult,\n transactionData: this.simulationTransactionData,\n };\n }\n const simulation = this.simulation!;\n if (!simulation) {\n throw new AssembledTransaction.Errors.NotYetSimulated(\n \"Transaction has not yet been simulated\",\n );\n }\n if (Api.isSimulationError(simulation)) {\n throw new AssembledTransaction.Errors.SimulationFailed(\n `Transaction simulation failed: \"${simulation.error}\"`,\n );\n }\n\n if (Api.isSimulationRestore(simulation)) {\n throw new AssembledTransaction.Errors.ExpiredState(\n `You need to restore some contract state before you can invoke this method.\\n` +\n \"You can set `restore` to true in the method options in order to \" +\n \"automatically restore the contract state when needed.\",\n );\n }\n\n // add to object for serialization & deserialization\n this.simulationResult = simulation.result ?? {\n auth: [],\n retval: xdr.ScVal.scvVoid(),\n };\n this.simulationTransactionData = simulation.transactionData.build();\n\n return {\n result: this.simulationResult,\n transactionData: this.simulationTransactionData!,\n };\n }\n\n get result(): T {\n try {\n if (!this.simulationData.result) {\n throw new Error(\"No simulation result!\");\n }\n return this.options.parseResultXdr(this.simulationData.result.retval);\n } catch (e) {\n if (!implementsToString(e)) throw e;\n const err = this.parseError(e.toString());\n if (err) return err as T;\n throw e;\n }\n }\n\n private parseError(errorMessage: string) {\n if (!this.options.errorTypes) return undefined;\n const match = errorMessage.match(contractErrorPattern);\n if (!match) return undefined;\n const i = parseInt(match[1], 10);\n const err = this.options.errorTypes[i];\n if (!err) return undefined;\n return new Err(err);\n }\n\n /**\n * Sign the transaction with the signTransaction function included previously.\n * If you did not previously include one, you need to include one now.\n */\n sign = async ({\n force = false,\n signTransaction = this.options.signTransaction,\n }: {\n /**\n * If `true`, sign and send the transaction even if it is a read call\n */\n force?: boolean;\n /**\n * You must provide this here if you did not provide one before\n */\n signTransaction?: ClientOptions[\"signTransaction\"];\n } = {}): Promise<void> => {\n if (!this.built) {\n throw new Error(\"Transaction has not yet been simulated\");\n }\n\n if (!force && this.isReadCall) {\n throw new AssembledTransaction.Errors.NoSignatureNeeded(\n \"This is a read call. It requires no signature or sending. \" +\n \"Use `force: true` to sign and send anyway.\",\n );\n }\n\n if (!signTransaction) {\n throw new AssembledTransaction.Errors.NoSigner(\n \"You must provide a signTransaction function, either when calling \" +\n \"`signAndSend` or when initializing your Client\",\n );\n }\n\n if (!this.options.publicKey) {\n throw new AssembledTransaction.Errors.FakeAccount(\n \"This transaction was constructed using a default account. Provide a valid publicKey in the AssembledTransactionOptions.\",\n );\n }\n\n // filter out contracts, as these are dealt with via cross contract calls\n const sigsNeeded = this.needsNonInvokerSigningBy().filter(\n (id) => !id.startsWith(\"C\"),\n );\n if (sigsNeeded.length) {\n throw new AssembledTransaction.Errors.NeedsMoreSignatures(\n `Transaction requires signatures from ${sigsNeeded}. ` +\n \"See `needsNonInvokerSigningBy` for details.\",\n );\n }\n\n const timeoutInSeconds = this.options.timeoutInSeconds ?? DEFAULT_TIMEOUT;\n this.built = TransactionBuilder.cloneFrom(this.built!, {\n fee: this.built!.fee,\n timebounds: undefined,\n sorobanData: this.simulationData.transactionData,\n })\n .setTimeout(timeoutInSeconds)\n .build();\n\n const signOpts: Parameters<\n NonNullable<ClientOptions[\"signTransaction\"]>\n >[1] = {\n networkPassphrase: this.options.networkPassphrase,\n };\n\n if (this.options.address) signOpts.address = this.options.address;\n if (this.options.submit !== undefined)\n signOpts.submit = this.options.submit;\n if (this.options.submitUrl) signOpts.submitUrl = this.options.submitUrl;\n\n const { signedTxXdr: signature, error } = await signTransaction(\n this.built.toXDR(),\n signOpts,\n );\n\n this.handleWalletError(error);\n\n this.signed = TransactionBuilder.fromXDR(\n signature,\n this.options.networkPassphrase,\n ) as Tx;\n };\n\n /**\n * Sends the transaction to the network to return a `SentTransaction` that\n * keeps track of all the attempts to fetch the transaction. Optionally pass\n * a {@link Watcher} that allows you to keep track of the progress as the\n * transaction is sent and processed.\n */\n async send(watcher?: Watcher) {\n if (!this.signed) {\n throw new Error(\n \"The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.\",\n );\n }\n const sent = await SentTransaction.init(this, watcher);\n return sent;\n }\n\n /**\n * Sign the transaction with the `signTransaction` function included previously.\n * If you did not previously include one, you need to include one now.\n * After signing, this method will send the transaction to the network and\n * return a `SentTransaction` that keeps track of all the attempts to fetch\n * the transaction. You may pass a {@link Watcher} to keep\n * track of this progress.\n */\n signAndSend = async ({\n force = false,\n signTransaction = this.options.signTransaction,\n watcher,\n }: {\n /**\n * If `true`, sign and send the transaction even if it is a read call\n */\n force?: boolean;\n /**\n * You must provide this here if you did not provide one before\n */\n signTransaction?: ClientOptions[\"signTransaction\"];\n /**\n * A {@link Watcher} to notify after the transaction is successfully\n * submitted to the network (`onSubmitted`) and as the transaction is\n * processed (`onProgress`).\n */\n watcher?: Watcher;\n } = {}): Promise<SentTransaction<T>> => {\n if (!this.signed) {\n // Wrap signTransaction to disable submit and prevent double submission,\n // without mutating the shared this.options object\n const signer = signTransaction || this.options.signTransaction;\n const wrappedSignTransaction: typeof signTransaction =\n this.options.submit && signer\n ? (tx, opts) => signer(tx, { ...opts, submit: false })\n : signTransaction;\n\n await this.sign({ force, signTransaction: wrappedSignTransaction });\n }\n return this.send(watcher);\n };\n\n /**\n * Get a list of accounts, other than the invoker of the simulation, that\n * need to sign auth entries in this transaction.\n *\n * Soroban allows multiple people to sign a transaction. Someone needs to\n * sign the final transaction envelope; this person/account is called the\n * _invoker_, or _source_. Other accounts might need to sign individual auth\n * entries in the transaction, if they're not also the invoker.\n *\n * This function returns a list of accounts that need to sign auth entries,\n * assuming that the same invoker/source account will sign the final\n * transaction envelope as signed the initial simulation.\n *\n * One at a time, for each public key in this array, you will need to\n * serialize this transaction with `toJSON`, send to the owner of that key,\n * deserialize the transaction with `txFromJson`, and call\n * {@link AssembledTransaction.signAuthEntries}. Then re-serialize and send to\n * the next account in this list.\n */\n needsNonInvokerSigningBy = ({\n includeAlreadySigned = false,\n }: {\n /**\n * Whether or not to include auth entries that have already been signed.\n * Default: false\n */\n includeAlreadySigned?: boolean;\n } = {}): string[] => {\n if (!this.built) {\n throw new Error(\"Transaction has not yet been simulated\");\n }\n\n // We expect that any transaction constructed by these libraries has a\n // single operation, which is an InvokeHostFunction operation. The host\n // function being invoked is the contract method call.\n if (!(\"operations\" in this.built)) {\n throw new Error(\n `Unexpected Transaction type; no operations: ${JSON.stringify(\n this.built,\n )}`,\n );\n }\n const rawInvokeHostFunctionOp = this.built\n .operations[0] as Operation.InvokeHostFunction;\n\n return [\n ...new Set(\n (rawInvokeHostFunctionOp.auth ?? [])\n .map((entry) => getAddressCredentials(entry.credentials()))\n .filter(\n (addrAuth): addrAuth is xdr.SorobanAddressCredentials =>\n // skip source-account credentials (no address payload), which\n // are covered by the envelope signature on the source account\n addrAuth !== null &&\n (includeAlreadySigned ||\n addrAuth.signature().switch().name === \"scvVoid\"),\n )\n .map((addrAuth) =>\n Address.fromScAddress(addrAuth.address()).toString(),\n ),\n ),\n ];\n };\n\n /**\n * If {@link AssembledTransaction.needsNonInvokerSigningBy} returns a\n * non-empty list, you can serialize the transaction with `toJSON`, send it to\n * the owner of one of the public keys in the map, deserialize with\n * `txFromJSON`, and call this method on their machine. Internally, this will\n * use `signAuthEntry` function from connected `wallet` for each.\n *\n * Then, re-serialize the transaction and either send to the next\n * `needsNonInvokerSigningBy` owner, or send it back to the original account\n * who simulated the transaction so they can {@link AssembledTransaction.sign}\n * the transaction envelope and {@link AssembledTransaction.send} it to the\n * network.\n *\n * Sending to all `needsNonInvokerSigningBy` owners in parallel is not\n * currently supported!\n */\n signAuthEntries = async ({\n expiration = (async () =>\n (await this.server.getLatestLedger()).sequence + 100)(),\n signAuthEntry = this.options.signAuthEntry,\n address = this.options.publicKey,\n authorizeEntry = stellarBaseAuthorizeEntry,\n }: {\n /**\n * When to set each auth entry to expire. Could be any number of blocks in\n * the future. Can be supplied as a promise or a raw number. Default:\n * about 8.3 minutes from now.\n */\n expiration?: number | Promise<number>;\n /**\n * Sign all auth entries for this account. Default: the account that\n * constructed the transaction\n */\n address?: string;\n /**\n * You must provide this here if you did not provide one before and you are not passing `authorizeEntry`. Default: the `signAuthEntry` function from the `Client` options. Must sign things as the given `publicKey`.\n */\n signAuthEntry?: ClientOptions[\"signAuthEntry\"];\n\n /**\n * If you have a pro use-case and need to override the default `authorizeEntry` function, rather than using the one in `@stellar/stellar-base`, you can do that! Your function needs to take at least the first argument, `entry: xdr.SorobanAuthorizationEntry`, and return a `Promise<xdr.SorobanAuthorizationEntry>`.\n *\n * Note that you if you pass this, then `signAuthEntry` will be ignored.\n */\n authorizeEntry?: typeof stellarBaseAuthorizeEntry;\n } = {}): Promise<void> => {\n if (!this.built)\n throw new Error(\"Transaction has not yet been assembled or simulated\");\n\n // Likely if we're using a custom authorizeEntry then we know better than the `needsNonInvokerSigningBy` logic.\n if (authorizeEntry === stellarBaseAuthorizeEntry) {\n const needsNonInvokerSigningBy = this.needsNonInvokerSigningBy();\n if (needsNonInvokerSigningBy.length === 0) {\n throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries(\n \"No unsigned non-invoker auth entries; maybe you already signed?\",\n );\n }\n if (needsNonInvokerSigningBy.indexOf(address ?? \"\") === -1) {\n throw new AssembledTransaction.Errors.NoSignatureNeeded(\n `No auth entries for public key \"${address}\"`,\n );\n }\n if (!signAuthEntry) {\n throw new AssembledTransaction.Errors.NoSigner(\n \"You must provide `signAuthEntry` or a custom `authorizeEntry`\",\n );\n }\n }\n\n const rawInvokeHostFunctionOp = this.built\n .operations[0] as Operation.InvokeHostFunction;\n\n const authEntries = rawInvokeHostFunctionOp.auth ?? [];\n\n for (const [i, entry] of authEntries.entries()) {\n // workaround for https://github.com/stellar/js-stellar-sdk/issues/1070\n const credentials = xdr.SorobanCredentials.fromXDR(\n entry.credentials().toXDR(),\n );\n const addrAuth = getAddressCredentials(credentials);\n if (addrAuth === null) {\n // if the invoker/source account, then the entry doesn't need explicit\n // signature, since the tx envelope is already signed by the source\n // account, so only address-based credentials need signing here\n continue;\n }\n const authEntryAddress = Address.fromScAddress(\n addrAuth.address(),\n ).toString();\n\n // this auth entry needs to be signed by a different account\n // (or maybe already was!)\n if (authEntryAddress !== address) continue;\n\n const sign: typeof signAuthEntry = signAuthEntry ?? Promise.resolve;\n\n authEntries[i] = await authorizeEntry(\n entry,\n async (preimage) => {\n const { signedAuthEntry, error } = await sign(\n preimage.toXDR(\"base64\"),\n {\n address,\n },\n );\n this.handleWalletError(error);\n return Buffer.from(signedAuthEntry, \"base64\");\n },\n await expiration,\n this.options.networkPassphrase,\n );\n }\n };\n\n /**\n * Whether this transaction is a read call. This is determined by the\n * simulation result and the transaction data. If the transaction is a read\n * call, it will not need to be signed and sent to the network. If this\n * returns `false`, then you need to call `signAndSend` on this transaction.\n */\n get isReadCall(): boolean {\n const authsCount = this.simulationData.result.auth.length;\n const writeLength = this.simulationData.transactionData\n .resources()\n .footprint()\n .readWrite().length;\n return authsCount === 0 && writeLength === 0;\n }\n\n /**\n * Restores the footprint (resource ledger entries that can be read or written)\n * of an expired transaction.\n *\n * The method will:\n * 1. Build a new transaction aimed at restoring the necessary resources.\n * 2. Sign this new transaction if a `signTransaction` handler is provided.\n * 3. Send the signed transaction to the network.\n * 4. Await and return the response from the network.\n *\n * Preconditions:\n * - A `signTransaction` function must be provided during the Client initialization.\n * - The provided `restorePreamble` should include a minimum resource fee and valid\n * transaction data.\n *\n * @throws - Throws an error if no `signTransaction` function is provided during\n * Client initialization.\n * @throws - Throws a custom error if the\n * restore transaction fails, providing the details of the failure.\n */\n async restoreFootprint(\n /**\n * The preamble object containing data required to\n * build the restore transaction.\n */\n restorePreamble: {\n minResourceFee: string;\n transactionData: SorobanDataBuilder;\n },\n /** The account that is executing the footprint restore operation. If omitted, will use the account from the AssembledTransaction. */\n account?: Account,\n ): Promise<Api.GetTransactionResponse> {\n if (!this.options.signTransaction) {\n throw new Error(\n \"For automatic restore to work you must provide a signTransaction function when initializing your Client\",\n );\n }\n account = account ?? (await getAccount(this.options, this.server));\n // first try restoring the contract\n const restoreTx =\n await AssembledTransaction.buildFootprintRestoreTransaction(\n { ...this.options },\n restorePreamble.transactionData,\n account,\n restorePreamble.minResourceFee,\n );\n const sentTransaction = await restoreTx.signAndSend();\n if (!sentTransaction.getTransactionResponse) {\n throw new AssembledTransaction.Errors.RestorationFailure(\n `The attempt at automatic restore failed. \\n${JSON.stringify(sentTransaction)}`,\n );\n }\n return sentTransaction.getTransactionResponse;\n }\n}\n"],"names":["Server","xdr","authorizeEntry","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AAgB,CAAA;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,MAAM,gBAAA,CAKJ,eAAA,EAKA,OAAA,EACqC;AACrC,IAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,eAAA,EAAiB;AACjC,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAA,GAAU,WAAY,MAAM,UAAA,CAAW,IAAA,CAAK,OAAA,EAAS,KAAK,MAAM,CAAA;AAEhE,IAAA,MAAM,SAAA,GACJ,MAAM,oBAAA,CAAqB,gCAAA;AAAA,MACzB,EAAE,GAAG,IAAA,CAAK,OAAA,EAAQ;AAAA,MAClB,eAAA,CAAgB,eAAA;AAAA,MAChB,OAAA;AAAA,MACA,eAAA,CAAgB;AAAA,KAClB;AACF,IAAA,MAAM,eAAA,GAAkB,MAAM,SAAA,CAAU,WAAA,EAAY;AACpD,IAAA,IAAI,CAAC,gBAAgB,sBAAA,EAAwB;AAC3C,MAAA,MAAM,IAAI,qBAAqB,MAAA,CAAO,kBAAA;AAAA,QACpC,CAAA;AAAA,EAA8C,IAAA,CAAK,SAAA,CAAU,eAAe,CAAC,CAAA;AAAA,OAC/E;AAAA,IACF;AACA,IAAA,OAAO,eAAA,CAAgB,sBAAA;AAAA,EACzB;AACF;;;;"}
1
+ {"version":3,"file":"assembled_transaction.js","sources":["../../../src/contract/assembled_transaction.ts"],"sourcesContent":["/* disable max-classes rule, because extending error shouldn't count! */\n/* eslint max-classes-per-file: 0 */\nimport {\n Account,\n Address,\n BASE_FEE,\n Contract,\n Operation,\n SorobanDataBuilder,\n TransactionBuilder,\n authorizeEntry as stellarBaseAuthorizeEntry,\n xdr,\n} from \"../base/index.js\";\n// internal helper (not part of the public API), imported directly from auth.js\nimport { getAddressCredentials } from \"../base/auth.js\";\nimport type {\n AssembledTransactionOptions,\n ClientOptions,\n MethodOptions,\n Tx,\n WalletError,\n XDR_BASE64,\n} from \"./types.js\";\nimport { Server } from \"../rpc/index.js\";\nimport { Api } from \"../rpc/api.js\";\nimport { assembleTransaction } from \"../rpc/transaction.js\";\nimport type { Client } from \"./client.js\";\nimport { Err } from \"./rust_result.js\";\nimport {\n contractErrorPattern,\n implementsToString,\n getAccount,\n} from \"./utils.js\";\nimport { DEFAULT_TIMEOUT } from \"./types.js\";\nimport { SentTransaction, Watcher } from \"./sent_transaction.js\";\nimport { Spec } from \"./spec.js\";\nimport {\n ExpiredStateError,\n ExternalServiceError,\n FakeAccountError,\n InternalWalletError,\n InvalidClientRequestError,\n NeedsMoreSignaturesError,\n NoSignatureNeededError,\n NoSignerError,\n NotYetSimulatedError,\n NoUnsignedNonInvokerAuthEntriesError,\n RestoreFailureError,\n SimulationFailedError,\n UserRejectedError,\n} from \"./errors.js\";\n\n/**\n * The main workhorse of {@link Client}. This class is used to wrap a\n * transaction-under-construction and provide high-level interfaces to the most\n * common workflows, while still providing access to low-level stellar-sdk\n * transaction manipulation.\n *\n * Most of the time, you will not construct an `AssembledTransaction` directly,\n * but instead receive one as the return value of a `Client` method. If\n * you're familiar with the libraries generated by soroban-cli's\n * `contract bindings typescript` command, these also wraps `Client` and return\n * `AssembledTransaction` instances.\n *\n * Let's look at examples of how to use `AssembledTransaction` for a variety of\n * use-cases:\n *\n * #### 1. Simple read call\n *\n * Since these only require simulation, you can get the `result` of the call\n * right after constructing your `AssembledTransaction`:\n *\n * ```ts\n * const { result } = await AssembledTransaction.build({\n * method: 'myReadMethod',\n * args: spec.funcArgsToScVals('myReadMethod', {\n * args: 'for',\n * my: 'method',\n * ...\n * }),\n * contractId: 'C123…',\n * networkPassphrase: '…',\n * rpcUrl: 'https://…',\n * publicKey: undefined, // irrelevant, for simulation-only read calls\n * parseResultXdr: (result: xdr.ScVal) =>\n * spec.funcResToNative('myReadMethod', result),\n * })\n * ```\n *\n * While that looks pretty complicated, most of the time you will use this in\n * conjunction with {@link Client}, which simplifies it to:\n *\n * ```ts\n * const { result } = await client.myReadMethod({\n * args: 'for',\n * my: 'method',\n * ...\n * })\n * ```\n *\n * #### 2. Simple write call\n *\n * For write calls that will be simulated and then sent to the network without\n * further manipulation, only one more step is needed:\n *\n * ```ts\n * const assembledTx = await client.myWriteMethod({\n * args: 'for',\n * my: 'method',\n * ...\n * })\n * const sentTx = await assembledTx.signAndSend()\n * ```\n *\n * Here we're assuming that you're using a {@link Client}, rather than\n * constructing `AssembledTransaction`'s directly.\n *\n * Note that `sentTx`, the return value of `signAndSend`, is a\n * {@link SentTransaction}. `SentTransaction` is similar to\n * `AssembledTransaction`, but is missing many of the methods and fields that\n * are only relevant while assembling a transaction. It also has a few extra\n * methods and fields that are only relevant after the transaction has been\n * sent to the network.\n *\n * Like `AssembledTransaction`, `SentTransaction` also has a `result` getter,\n * which contains the parsed final return value of the contract call. Most of\n * the time, you may only be interested in this, so rather than getting the\n * whole `sentTx` you may just want to:\n *\n * ```ts\n * const tx = await client.myWriteMethod({ args: 'for', my: 'method', ... })\n * const { result } = await tx.signAndSend()\n * ```\n *\n * #### 3. More fine-grained control over transaction construction\n *\n * If you need more control over the transaction before simulating it, you can\n * set various {@link MethodOptions} when constructing your\n * `AssembledTransaction`. With a {@link Client}, this is passed as a\n * second object after the arguments (or the only object, if the method takes\n * no arguments):\n *\n * ```ts\n * const tx = await client.myWriteMethod(\n * {\n * args: 'for',\n * my: 'method',\n * ...\n * }, {\n * fee: '10000', // default: {@link BASE_FEE}\n * simulate: false,\n * timeoutInSeconds: 20, // default: {@link DEFAULT_TIMEOUT}\n * }\n * )\n * ```\n *\n * Since we've skipped simulation, we can now edit the `raw` transaction and\n * then manually call `simulate`:\n *\n * ```ts\n * tx.raw.addMemo(Memo.text('Nice memo, friend!'))\n * await tx.simulate()\n * ```\n *\n * If you need to inspect the simulation later, you can access it with\n * `tx.simulation`.\n *\n * #### 4. Multi-auth workflows\n *\n * Soroban, and Stellar in general, allows multiple parties to sign a\n * transaction.\n *\n * Let's consider an Atomic Swap contract. Alice wants to give 10 of her Token\n * A tokens to Bob for 5 of his Token B tokens.\n *\n * ```ts\n * const ALICE = 'G123...'\n * const BOB = 'G456...'\n * const TOKEN_A = 'C123…'\n * const TOKEN_B = 'C456…'\n * const AMOUNT_A = 10n\n * const AMOUNT_B = 5n\n * ```\n *\n * Let's say Alice is also going to be the one signing the final transaction\n * envelope, meaning she is the invoker. So your app, from Alice's browser,\n * simulates the `swap` call:\n *\n * ```ts\n * const tx = await swapClient.swap({\n * a: ALICE,\n * b: BOB,\n * token_a: TOKEN_A,\n * token_b: TOKEN_B,\n * amount_a: AMOUNT_A,\n * amount_b: AMOUNT_B,\n * })\n * ```\n *\n * But your app can't `signAndSend` this right away, because Bob needs to sign\n * it first. You can check this:\n *\n * ```ts\n * const whoElseNeedsToSign = tx.needsNonInvokerSigningBy()\n * ```\n *\n * You can verify that `whoElseNeedsToSign` is an array of length `1`,\n * containing only Bob's public key.\n *\n * Then, still on Alice's machine, you can serialize the\n * transaction-under-assembly:\n *\n * ```ts\n * const json = tx.toJSON()\n * ```\n *\n * And now you need to send it to Bob's browser. How you do this depends on\n * your app. Maybe you send it to a server first, maybe you use WebSockets, or\n * maybe you have Alice text the JSON blob to Bob and have him paste it into\n * your app in his browser (note: this option might be error-prone 😄).\n *\n * Once you get the JSON blob into your app on Bob's machine, you can\n * deserialize it:\n *\n * ```ts\n * const tx = swapClient.txFromJSON(json)\n * ```\n *\n * Or, if you're using a client generated with\n * `soroban contract bindings typescript`, this deserialization will look like:\n *\n * ```ts\n * const tx = swapClient.fromJSON.swap(json)\n * ```\n *\n * Then you can have Bob sign it. What Bob will actually need to sign is some\n * _auth entries_ within the transaction, not the transaction itself or the\n * transaction envelope. Your app can verify that Bob has the correct wallet\n * selected, then:\n *\n * ```ts\n * await tx.signAuthEntries()\n * ```\n *\n * Under the hood, this uses `signAuthEntry`, which you either need to inject\n * during initial construction of the `Client`/`AssembledTransaction`,\n * or which you can pass directly to `signAuthEntries`.\n *\n * Now Bob can again serialize the transaction and send back to Alice, where\n * she can finally call `signAndSend()`.\n *\n * To see an even more complicated example, where Alice swaps with Bob but the\n * transaction is invoked by yet another party, check out\n * [test-swap.js](https://github.com/stellar/js-stellar-sdk/blob/master/test/e2e/src/test-swap.js).\n *\n */\nexport class AssembledTransaction<T> {\n /**\n * The TransactionBuilder as constructed in\n * {@link AssembledTransaction}.build. Feel free set `simulate: false` to modify\n * this object before calling `tx.simulate()` manually. Example:\n *\n * ```ts\n * const tx = await myContract.myMethod(\n * { args: 'for', my: 'method', ... },\n * { simulate: false }\n * );\n * tx.raw.addMemo(Memo.text('Nice memo, friend!'))\n * await tx.simulate();\n * ```\n */\n public raw?: TransactionBuilder;\n\n /**\n * Stores the original operation from `buildWithOp` for reuse during\n * automatic state restoration rebuilds.\n */\n private originalOp?: xdr.Operation;\n\n /**\n * The Transaction as it was built with `raw.build()` right before\n * simulation. Once this is set, modifying `raw` will have no effect unless\n * you call `tx.simulate()` again.\n */\n public built?: Tx;\n\n /**\n * The result of the transaction simulation. This is set after the first call\n * to `simulate`. It is difficult to serialize and deserialize, so it is not\n * included in the `toJSON` and `fromJSON` methods. See `simulationData`\n * cached, serializable access to the data needed by AssembledTransaction\n * logic.\n */\n public simulation?: Api.SimulateTransactionResponse;\n\n /**\n * Cached simulation result. This is set after the first call to\n * {@link AssembledTransaction.simulationData}, and is used to facilitate\n * serialization and deserialization of the AssembledTransaction.\n *\n * Most of the time, if you need this data, you can call\n * `tx.simulation.result`.\n *\n * If you need access to this data after a transaction has been serialized\n * and then deserialized, you can call `simulationData.result`.\n */\n private simulationResult?: Api.SimulateHostFunctionResult;\n\n /**\n * Cached simulation transaction data. This is set after the first call to\n * {@link AssembledTransaction.simulationData}, and is used to facilitate\n * serialization and deserialization of the AssembledTransaction.\n *\n * Most of the time, if you need this data, you can call\n * `simulation.transactionData`.\n *\n * If you need access to this data after a transaction has been serialized\n * and then deserialized, you can call `simulationData.transactionData`.\n */\n private simulationTransactionData?: xdr.SorobanTransactionData;\n\n /**\n * The Soroban server to use for all RPC calls. This is constructed from the\n * `rpcUrl` in the options.\n */\n private server: Server;\n\n /**\n * The signed transaction.\n */\n public signed?: Tx;\n\n /**\n * A list of the most important errors that various AssembledTransaction\n * methods can throw. Feel free to catch specific errors in your application\n * logic.\n */\n static Errors = {\n ExpiredState: ExpiredStateError,\n RestorationFailure: RestoreFailureError,\n NeedsMoreSignatures: NeedsMoreSignaturesError,\n NoSignatureNeeded: NoSignatureNeededError,\n NoUnsignedNonInvokerAuthEntries: NoUnsignedNonInvokerAuthEntriesError,\n NoSigner: NoSignerError,\n NotYetSimulated: NotYetSimulatedError,\n FakeAccount: FakeAccountError,\n SimulationFailed: SimulationFailedError,\n InternalWalletError,\n ExternalServiceError,\n InvalidClientRequest: InvalidClientRequestError,\n UserRejected: UserRejectedError,\n };\n\n /**\n * Serialize the AssembledTransaction to a JSON string. This is useful for\n * saving the transaction to a database or sending it over the wire for\n * multi-auth workflows. `fromJSON` can be used to deserialize the\n * transaction. This only works with transactions that have been simulated.\n */\n toJSON() {\n return JSON.stringify({\n method: this.options.method,\n tx: this.built?.toXDR(),\n simulationResult: {\n auth: this.simulationData.result.auth.map((a) => a.toXDR(\"base64\")),\n retval: this.simulationData.result.retval.toXDR(\"base64\"),\n },\n simulationTransactionData:\n this.simulationData.transactionData.toXDR(\"base64\"),\n });\n }\n\n /**\n * Validate that a built transaction is a single invokeContract operation\n * targeting the expected contract, and return the parsed InvokeContractArgs.\n */\n private static validateInvokeContractOp(\n built: Tx,\n expectedContractId: string,\n ): xdr.InvokeContractArgs {\n if (built.operations.length !== 1) {\n throw new Error(\n \"Transaction envelope must contain exactly one operation.\",\n );\n }\n\n const operation = built.operations[0];\n\n if (operation.type !== \"invokeHostFunction\") {\n throw new Error(\n \"Transaction envelope does not contain an invokeHostFunction operation.\",\n );\n }\n\n const invokeOp = operation as Operation.InvokeHostFunction;\n\n if (invokeOp.func.switch().name !== \"hostFunctionTypeInvokeContract\") {\n throw new Error(\n \"Transaction envelope does not contain an invokeContract host function.\",\n );\n }\n\n const invokeContractArgs = invokeOp.func.value() as xdr.InvokeContractArgs;\n\n let contractAddress: xdr.ScAddress;\n let functionName: string;\n\n try {\n contractAddress = invokeContractArgs.contractAddress();\n functionName = invokeContractArgs.functionName().toString(\"utf-8\");\n } catch {\n throw new Error(\n \"Could not extract contract address or method name from the transaction envelope.\",\n );\n }\n\n if (!contractAddress || !functionName) {\n throw new Error(\n \"Could not extract contract address or method name from the transaction envelope.\",\n );\n }\n\n const xdrContractId = Address.fromScAddress(contractAddress).toString();\n if (xdrContractId !== expectedContractId) {\n throw new Error(\n `Transaction envelope targets contract ${xdrContractId}, but this Client is configured for ${expectedContractId}.`,\n );\n }\n\n return invokeContractArgs;\n }\n\n static fromJSON<T>(\n options: Omit<AssembledTransactionOptions<T>, \"args\">,\n {\n tx,\n simulationResult,\n simulationTransactionData,\n }: {\n tx: XDR_BASE64;\n simulationResult: {\n auth: XDR_BASE64[];\n retval: XDR_BASE64;\n };\n simulationTransactionData: XDR_BASE64;\n },\n ): AssembledTransaction<T> {\n const txn = new AssembledTransaction(options);\n txn.built = TransactionBuilder.fromXDR(tx, options.networkPassphrase) as Tx;\n\n const invokeContractArgs = AssembledTransaction.validateInvokeContractOp(\n txn.built,\n options.contractId,\n );\n\n const xdrMethod = invokeContractArgs.functionName().toString(\"utf-8\");\n\n if (xdrMethod !== options.method) {\n throw new Error(\n `Transaction envelope calls method '${xdrMethod}', but the provided method is '${options.method}'.`,\n );\n }\n\n txn.simulationResult = {\n auth: simulationResult.auth.map((a) =>\n xdr.SorobanAuthorizationEntry.fromXDR(a, \"base64\"),\n ),\n retval: xdr.ScVal.fromXDR(simulationResult.retval, \"base64\"),\n };\n txn.simulationTransactionData = xdr.SorobanTransactionData.fromXDR(\n simulationTransactionData,\n \"base64\",\n );\n return txn;\n }\n\n /**\n * Serialize the AssembledTransaction to a base64-encoded XDR string.\n */\n toXDR(): string {\n if (!this.built)\n throw new Error(\n \"Transaction has not yet been simulated; \" +\n \"call `AssembledTransaction.simulate` first.\",\n );\n return this.built?.toEnvelope().toXDR(\"base64\");\n }\n\n /**\n * Deserialize the AssembledTransaction from a base64-encoded XDR string.\n */\n static fromXDR<T>(\n options: Omit<\n AssembledTransactionOptions<T>,\n \"args\" | \"method\" | \"parseResultXdr\"\n >,\n encodedXDR: string,\n spec: Spec,\n ): AssembledTransaction<T> {\n const envelope = xdr.TransactionEnvelope.fromXDR(encodedXDR, \"base64\");\n const built = TransactionBuilder.fromXDR(\n envelope,\n options.networkPassphrase,\n ) as Tx;\n\n const invokeContractArgs = AssembledTransaction.validateInvokeContractOp(\n built,\n options.contractId,\n );\n\n const method = invokeContractArgs.functionName().toString(\"utf-8\");\n const txn = new AssembledTransaction({\n ...options,\n method,\n parseResultXdr: (result: xdr.ScVal) =>\n spec.funcResToNative(method, result),\n });\n txn.built = built;\n return txn;\n }\n\n private handleWalletError(error?: WalletError): void {\n if (!error) return;\n\n const { message, code } = error;\n const fullMessage = `${message}${error.ext ? ` (${error.ext.join(\", \")})` : \"\"}`;\n\n switch (code) {\n case -1:\n throw new AssembledTransaction.Errors.InternalWalletError(fullMessage);\n case -2:\n throw new AssembledTransaction.Errors.ExternalServiceError(fullMessage);\n case -3:\n throw new AssembledTransaction.Errors.InvalidClientRequest(fullMessage);\n case -4:\n throw new AssembledTransaction.Errors.UserRejected(fullMessage);\n default:\n throw new Error(`Unhandled error: ${fullMessage}`);\n }\n }\n\n private constructor(public options: AssembledTransactionOptions<T>) {\n this.options.simulate = this.options.simulate ?? true;\n const { server, allowHttp, headers, rpcUrl } = this.options;\n this.server = server ?? new Server(rpcUrl, { allowHttp, headers });\n }\n\n /**\n * Construct a new AssembledTransaction. This is the main way to create a new\n * AssembledTransaction; the constructor is private.\n *\n * This is an asynchronous constructor for two reasons:\n *\n * 1. It needs to fetch the account from the network to get the current\n * sequence number.\n * 2. It needs to simulate the transaction to get the expected fee.\n *\n * If you don't want to simulate the transaction, you can set `simulate` to\n * `false` in the options.\n *\n * If you need to create an operation other than `invokeHostFunction`, you\n * can use {@link AssembledTransaction.buildWithOp} instead.\n *\n * @example\n * ```ts\n * const tx = await AssembledTransaction.build({\n * ...,\n * simulate: false,\n * })\n * ```\n */\n static build<T>(\n options: AssembledTransactionOptions<T>,\n ): Promise<AssembledTransaction<T>> {\n const contract = new Contract(options.contractId);\n return AssembledTransaction.buildWithOp(\n contract.call(options.method, ...(options.args ?? [])),\n options,\n );\n }\n\n /**\n * Construct a new AssembledTransaction, specifying an Operation other than\n * `invokeHostFunction` (the default used by {@link AssembledTransaction.build}).\n *\n * Note: `AssembledTransaction` currently assumes these operations can be\n * simulated. This is not true for classic operations; only for those used by\n * Soroban Smart Contracts like `invokeHostFunction` and `createCustomContract`.\n *\n * @example\n * ```ts\n * const tx = await AssembledTransaction.buildWithOp(\n * Operation.createCustomContract({ ... });\n * {\n * ...,\n * simulate: false,\n * }\n * )\n * ```\n */\n static async buildWithOp<T>(\n operation: xdr.Operation,\n options: AssembledTransactionOptions<T>,\n ): Promise<AssembledTransaction<T>> {\n const tx = new AssembledTransaction(options);\n tx.originalOp = operation;\n const account = await getAccount(options, tx.server);\n tx.raw = new TransactionBuilder(account, {\n fee: options.fee ?? BASE_FEE,\n networkPassphrase: options.networkPassphrase,\n })\n .setTimeout(options.timeoutInSeconds ?? DEFAULT_TIMEOUT)\n .addOperation(operation);\n\n if (options.simulate) await tx.simulate();\n\n return tx;\n }\n\n private static async buildFootprintRestoreTransaction<T>(\n options: AssembledTransactionOptions<T>,\n sorobanData: SorobanDataBuilder | xdr.SorobanTransactionData,\n account: Account,\n fee: string,\n ): Promise<AssembledTransaction<T>> {\n const tx = new AssembledTransaction(options);\n tx.raw = new TransactionBuilder(account, {\n fee,\n networkPassphrase: options.networkPassphrase,\n })\n .setSorobanData(\n sorobanData instanceof SorobanDataBuilder\n ? sorobanData.build()\n : sorobanData,\n )\n .addOperation(Operation.restoreFootprint({}))\n .setTimeout(options.timeoutInSeconds ?? DEFAULT_TIMEOUT);\n await tx.simulate({ restore: false });\n return tx;\n }\n\n simulate = async ({ restore }: { restore?: boolean } = {}): Promise<this> => {\n if (!this.built) {\n if (!this.raw) {\n throw new Error(\n \"Transaction has not yet been assembled; \" +\n \"call `AssembledTransaction.build` first.\",\n );\n }\n this.built = this.raw.build();\n }\n restore = restore ?? this.options.restore;\n\n // need to force re-calculation of simulationData for new simulation\n delete this.simulationResult;\n delete this.simulationTransactionData;\n this.simulation = await this.server.simulateTransaction(this.built);\n\n if (restore && Api.isSimulationRestore(this.simulation)) {\n const account = await getAccount(this.options, this.server);\n const result = await this.restoreFootprint(\n this.simulation.restorePreamble,\n account,\n );\n if (result.status === Api.GetTransactionStatus.SUCCESS) {\n // need to rebuild the transaction with bumped account sequence number\n const op = this.originalOp\n ? this.originalOp\n : new Contract(this.options.contractId).call(\n this.options.method,\n ...(this.options.args ?? []),\n );\n this.raw = new TransactionBuilder(account, {\n fee: this.options.fee ?? BASE_FEE,\n networkPassphrase: this.options.networkPassphrase,\n })\n .addOperation(op)\n .setTimeout(this.options.timeoutInSeconds ?? DEFAULT_TIMEOUT);\n delete this.built;\n await this.simulate();\n return this;\n }\n throw new AssembledTransaction.Errors.RestorationFailure(\n `Automatic restore failed! You set 'restore: true' but the attempted restore did not work. Result:\\n${JSON.stringify(result)}`,\n );\n }\n\n if (Api.isSimulationSuccess(this.simulation)) {\n this.built = assembleTransaction(this.built, this.simulation).build();\n }\n\n return this;\n };\n\n get simulationData(): {\n result: Api.SimulateHostFunctionResult;\n transactionData: xdr.SorobanTransactionData;\n } {\n if (this.simulationResult && this.simulationTransactionData) {\n return {\n result: this.simulationResult,\n transactionData: this.simulationTransactionData,\n };\n }\n const simulation = this.simulation!;\n if (!simulation) {\n throw new AssembledTransaction.Errors.NotYetSimulated(\n \"Transaction has not yet been simulated\",\n );\n }\n if (Api.isSimulationError(simulation)) {\n throw new AssembledTransaction.Errors.SimulationFailed(\n `Transaction simulation failed: \"${simulation.error}\"`,\n );\n }\n\n if (Api.isSimulationRestore(simulation)) {\n throw new AssembledTransaction.Errors.ExpiredState(\n `You need to restore some contract state before you can invoke this method.\\n` +\n \"You can set `restore` to true in the method options in order to \" +\n \"automatically restore the contract state when needed.\",\n );\n }\n\n // add to object for serialization & deserialization\n this.simulationResult = simulation.result ?? {\n auth: [],\n retval: xdr.ScVal.scvVoid(),\n };\n this.simulationTransactionData = simulation.transactionData.build();\n\n return {\n result: this.simulationResult,\n transactionData: this.simulationTransactionData!,\n };\n }\n\n get result(): T {\n try {\n if (!this.simulationData.result) {\n throw new Error(\"No simulation result!\");\n }\n return this.options.parseResultXdr(this.simulationData.result.retval);\n } catch (e) {\n if (!implementsToString(e)) throw e;\n const err = this.parseError(e.toString());\n if (err) return err as T;\n throw e;\n }\n }\n\n private parseError(errorMessage: string) {\n if (!this.options.errorTypes) return undefined;\n const match = errorMessage.match(contractErrorPattern);\n if (!match) return undefined;\n const i = parseInt(match[1], 10);\n const err = this.options.errorTypes[i];\n if (!err) return undefined;\n return new Err(err);\n }\n\n /**\n * Sign the transaction with the signTransaction function included previously.\n * If you did not previously include one, you need to include one now.\n */\n sign = async ({\n force = false,\n signTransaction = this.options.signTransaction,\n }: {\n /**\n * If `true`, sign and send the transaction even if it is a read call\n */\n force?: boolean;\n /**\n * You must provide this here if you did not provide one before\n */\n signTransaction?: ClientOptions[\"signTransaction\"];\n } = {}): Promise<void> => {\n if (!this.built) {\n throw new Error(\"Transaction has not yet been simulated\");\n }\n\n if (!force && this.isReadCall) {\n throw new AssembledTransaction.Errors.NoSignatureNeeded(\n \"This is a read call. It requires no signature or sending. \" +\n \"Use `force: true` to sign and send anyway.\",\n );\n }\n\n if (!signTransaction) {\n throw new AssembledTransaction.Errors.NoSigner(\n \"You must provide a signTransaction function, either when calling \" +\n \"`signAndSend` or when initializing your Client\",\n );\n }\n\n if (!this.options.publicKey) {\n throw new AssembledTransaction.Errors.FakeAccount(\n \"This transaction was constructed using a default account. Provide a valid publicKey in the AssembledTransactionOptions.\",\n );\n }\n\n // filter out contracts, as these are dealt with via cross contract calls\n const sigsNeeded = this.needsNonInvokerSigningBy().filter(\n (id) => !id.startsWith(\"C\"),\n );\n if (sigsNeeded.length) {\n throw new AssembledTransaction.Errors.NeedsMoreSignatures(\n `Transaction requires signatures from ${sigsNeeded}. ` +\n \"See `needsNonInvokerSigningBy` for details.\",\n );\n }\n\n const timeoutInSeconds = this.options.timeoutInSeconds ?? DEFAULT_TIMEOUT;\n this.built = TransactionBuilder.cloneFrom(this.built!, {\n fee: this.built!.fee,\n timebounds: undefined,\n sorobanData: this.simulationData.transactionData,\n })\n .setTimeout(timeoutInSeconds)\n .build();\n\n const signOpts: Parameters<\n NonNullable<ClientOptions[\"signTransaction\"]>\n >[1] = {\n networkPassphrase: this.options.networkPassphrase,\n };\n\n if (this.options.address) signOpts.address = this.options.address;\n if (this.options.submit !== undefined)\n signOpts.submit = this.options.submit;\n if (this.options.submitUrl) signOpts.submitUrl = this.options.submitUrl;\n\n const { signedTxXdr: signature, error } = await signTransaction(\n this.built.toXDR(),\n signOpts,\n );\n\n this.handleWalletError(error);\n\n this.signed = TransactionBuilder.fromXDR(\n signature,\n this.options.networkPassphrase,\n ) as Tx;\n };\n\n /**\n * Sends the transaction to the network to return a `SentTransaction` that\n * keeps track of all the attempts to fetch the transaction. Optionally pass\n * a {@link Watcher} that allows you to keep track of the progress as the\n * transaction is sent and processed.\n */\n async send(watcher?: Watcher) {\n if (!this.signed) {\n throw new Error(\n \"The transaction has not yet been signed. Run `sign` first, or use `signAndSend` instead.\",\n );\n }\n const sent = await SentTransaction.init(this, watcher);\n return sent;\n }\n\n /**\n * Sign the transaction with the `signTransaction` function included previously.\n * If you did not previously include one, you need to include one now.\n * After signing, this method will send the transaction to the network and\n * return a `SentTransaction` that keeps track of all the attempts to fetch\n * the transaction. You may pass a {@link Watcher} to keep\n * track of this progress.\n */\n signAndSend = async ({\n force = false,\n signTransaction = this.options.signTransaction,\n watcher,\n }: {\n /**\n * If `true`, sign and send the transaction even if it is a read call\n */\n force?: boolean;\n /**\n * You must provide this here if you did not provide one before\n */\n signTransaction?: ClientOptions[\"signTransaction\"];\n /**\n * A {@link Watcher} to notify after the transaction is successfully\n * submitted to the network (`onSubmitted`) and as the transaction is\n * processed (`onProgress`).\n */\n watcher?: Watcher;\n } = {}): Promise<SentTransaction<T>> => {\n if (!this.signed) {\n // Wrap signTransaction to disable submit and prevent double submission,\n // without mutating the shared this.options object\n const signer = signTransaction || this.options.signTransaction;\n const wrappedSignTransaction: typeof signTransaction =\n this.options.submit && signer\n ? (tx, opts) => signer(tx, { ...opts, submit: false })\n : signTransaction;\n\n await this.sign({ force, signTransaction: wrappedSignTransaction });\n }\n return this.send(watcher);\n };\n\n /**\n * Get a list of accounts, other than the invoker of the simulation, that\n * need to sign auth entries in this transaction.\n *\n * Soroban allows multiple people to sign a transaction. Someone needs to\n * sign the final transaction envelope; this person/account is called the\n * _invoker_, or _source_. Other accounts might need to sign individual auth\n * entries in the transaction, if they're not also the invoker.\n *\n * This function returns a list of accounts that need to sign auth entries,\n * assuming that the same invoker/source account will sign the final\n * transaction envelope as signed the initial simulation.\n *\n * One at a time, for each public key in this array, you will need to\n * serialize this transaction with `toJSON`, send to the owner of that key,\n * deserialize the transaction with `txFromJson`, and call\n * {@link AssembledTransaction.signAuthEntries}. Then re-serialize and send to\n * the next account in this list.\n */\n needsNonInvokerSigningBy = ({\n includeAlreadySigned = false,\n }: {\n /**\n * Whether or not to include auth entries that have already been signed.\n * Default: false\n */\n includeAlreadySigned?: boolean;\n } = {}): string[] => {\n if (!this.built) {\n throw new Error(\"Transaction has not yet been simulated\");\n }\n\n // We expect that any transaction constructed by these libraries has a\n // single operation, which is an InvokeHostFunction operation. The host\n // function being invoked is the contract method call.\n if (!(\"operations\" in this.built)) {\n throw new Error(\n `Unexpected Transaction type; no operations: ${JSON.stringify(\n this.built,\n )}`,\n );\n }\n const rawInvokeHostFunctionOp = this.built\n .operations[0] as Operation.InvokeHostFunction;\n\n return [\n ...new Set(\n (rawInvokeHostFunctionOp.auth ?? [])\n .map((entry) => getAddressCredentials(entry.credentials()))\n .filter(\n (addrAuth): addrAuth is xdr.SorobanAddressCredentials =>\n // skip source-account credentials (no address payload), which\n // are covered by the envelope signature on the source account\n addrAuth !== null &&\n (includeAlreadySigned ||\n addrAuth.signature().switch().name === \"scvVoid\"),\n )\n .map((addrAuth) =>\n Address.fromScAddress(addrAuth.address()).toString(),\n ),\n ),\n ];\n };\n\n /**\n * If {@link AssembledTransaction.needsNonInvokerSigningBy} returns a\n * non-empty list, you can serialize the transaction with `toJSON`, send it to\n * the owner of one of the public keys in the map, deserialize with\n * `txFromJSON`, and call this method on their machine. Internally, this will\n * use `signAuthEntry` function from connected `wallet` for each.\n *\n * Then, re-serialize the transaction and either send to the next\n * `needsNonInvokerSigningBy` owner, or send it back to the original account\n * who simulated the transaction so they can {@link AssembledTransaction.sign}\n * the transaction envelope and {@link AssembledTransaction.send} it to the\n * network.\n *\n * Sending to all `needsNonInvokerSigningBy` owners in parallel is not\n * currently supported!\n */\n signAuthEntries = async ({\n expiration = (async () =>\n (await this.server.getLatestLedger()).sequence + 100)(),\n signAuthEntry = this.options.signAuthEntry,\n address = this.options.publicKey,\n authorizeEntry = stellarBaseAuthorizeEntry,\n }: {\n /**\n * When to set each auth entry to expire. Could be any number of blocks in\n * the future. Can be supplied as a promise or a raw number. Default:\n * about 8.3 minutes from now.\n */\n expiration?: number | Promise<number>;\n /**\n * Sign all auth entries for this account. Default: the account that\n * constructed the transaction\n */\n address?: string;\n /**\n * You must provide this here if you did not provide one before and you are not passing `authorizeEntry`. Default: the `signAuthEntry` function from the `Client` options. Must sign things as the given `publicKey`.\n */\n signAuthEntry?: ClientOptions[\"signAuthEntry\"];\n\n /**\n * If you have a pro use-case and need to override the default `authorizeEntry` function, rather than using the one in `@stellar/stellar-base`, you can do that! Your function needs to take at least the first argument, `entry: xdr.SorobanAuthorizationEntry`, and return a `Promise<xdr.SorobanAuthorizationEntry>`.\n *\n * Note that you if you pass this, then `signAuthEntry` will be ignored.\n */\n authorizeEntry?: typeof stellarBaseAuthorizeEntry;\n } = {}): Promise<void> => {\n if (!this.built)\n throw new Error(\"Transaction has not yet been assembled or simulated\");\n\n // Likely if we're using a custom authorizeEntry then we know better than the `needsNonInvokerSigningBy` logic.\n if (authorizeEntry === stellarBaseAuthorizeEntry) {\n const needsNonInvokerSigningBy = this.needsNonInvokerSigningBy();\n if (needsNonInvokerSigningBy.length === 0) {\n throw new AssembledTransaction.Errors.NoUnsignedNonInvokerAuthEntries(\n \"No unsigned non-invoker auth entries; maybe you already signed?\",\n );\n }\n if (needsNonInvokerSigningBy.indexOf(address ?? \"\") === -1) {\n throw new AssembledTransaction.Errors.NoSignatureNeeded(\n `No auth entries for public key \"${address}\"`,\n );\n }\n if (!signAuthEntry) {\n throw new AssembledTransaction.Errors.NoSigner(\n \"You must provide `signAuthEntry` or a custom `authorizeEntry`\",\n );\n }\n }\n\n const rawInvokeHostFunctionOp = this.built\n .operations[0] as Operation.InvokeHostFunction;\n\n const authEntries = rawInvokeHostFunctionOp.auth ?? [];\n\n for (const [i, entry] of authEntries.entries()) {\n // workaround for https://github.com/stellar/js-stellar-sdk/issues/1070\n const credentials = xdr.SorobanCredentials.fromXDR(\n entry.credentials().toXDR(),\n );\n const addrAuth = getAddressCredentials(credentials);\n if (addrAuth === null) {\n // if the invoker/source account, then the entry doesn't need explicit\n // signature, since the tx envelope is already signed by the source\n // account, so only address-based credentials need signing here\n continue;\n }\n const authEntryAddress = Address.fromScAddress(\n addrAuth.address(),\n ).toString();\n\n // this auth entry needs to be signed by a different account\n // (or maybe already was!)\n if (authEntryAddress !== address) continue;\n\n const sign: typeof signAuthEntry = signAuthEntry ?? Promise.resolve;\n\n authEntries[i] = await authorizeEntry(\n entry,\n async (preimage) => {\n const { signedAuthEntry, error } = await sign(\n preimage.toXDR(\"base64\"),\n {\n address,\n },\n );\n this.handleWalletError(error);\n return Buffer.from(signedAuthEntry, \"base64\");\n },\n await expiration,\n this.options.networkPassphrase,\n );\n }\n };\n\n /**\n * Whether this transaction is a read call. This is determined by the\n * simulation result and the transaction data. If the transaction is a read\n * call, it will not need to be signed and sent to the network. If this\n * returns `false`, then you need to call `signAndSend` on this transaction.\n */\n get isReadCall(): boolean {\n const authsCount = this.simulationData.result.auth.length;\n const writeLength = this.simulationData.transactionData\n .resources()\n .footprint()\n .readWrite().length;\n return authsCount === 0 && writeLength === 0;\n }\n\n /**\n * Restores the footprint (resource ledger entries that can be read or written)\n * of an expired transaction.\n *\n * The method will:\n * 1. Build a new transaction aimed at restoring the necessary resources.\n * 2. Sign this new transaction if a `signTransaction` handler is provided.\n * 3. Send the signed transaction to the network.\n * 4. Await and return the response from the network.\n *\n * Preconditions:\n * - A `signTransaction` function must be provided during the Client initialization.\n * - The provided `restorePreamble` should include a minimum resource fee and valid\n * transaction data.\n *\n * @throws - Throws an error if no `signTransaction` function is provided during\n * Client initialization.\n * @throws - Throws a custom error if the\n * restore transaction fails, providing the details of the failure.\n */\n async restoreFootprint(\n /**\n * The preamble object containing data required to\n * build the restore transaction.\n */\n restorePreamble: {\n minResourceFee: string;\n transactionData: SorobanDataBuilder;\n },\n /** The account that is executing the footprint restore operation. If omitted, will use the account from the AssembledTransaction. */\n account?: Account,\n ): Promise<Api.GetTransactionResponse> {\n if (!this.options.signTransaction) {\n throw new Error(\n \"For automatic restore to work you must provide a signTransaction function when initializing your Client\",\n );\n }\n account = account ?? (await getAccount(this.options, this.server));\n // first try restoring the contract\n const restoreTx =\n await AssembledTransaction.buildFootprintRestoreTransaction(\n { ...this.options },\n restorePreamble.transactionData,\n account,\n restorePreamble.minResourceFee,\n );\n const sentTransaction = await restoreTx.signAndSend();\n if (!sentTransaction.getTransactionResponse) {\n throw new AssembledTransaction.Errors.RestorationFailure(\n `The attempt at automatic restore failed. \\n${JSON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gB,CAAA;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAsBA,MAAM,gBAAA,CAKJ,eAAA,EAKA,OAAA,EACqC;AACrC,IAAA,IAAI,CAAC,IAAA,CAAK,OAAA,CAAQ,eAAA,EAAiB;AACjC,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AACA,IAAA,OAAA,GAAU,WAAY,MAAM,UAAA,CAAW,IAAA,CAAK,OAAA,EAAS,KAAK,MAAM,CAAA;AAEhE,IAAA,MAAM,SAAA,GACJ,MAAM,oBAAA,CAAqB,gCAAA;AAAA,MACzB,EAAE,GAAG,IAAA,CAAK,OAAA,EAAQ;AAAA,MAClB,eAAA,CAAgB,eAAA;AAAA,MAChB,OAAA;AAAA,MACA,eAAA,CAAgB;AAAA,KAClB;AACF,IAAA,MAAM,eAAA,GAAkB,MAAM,SAAA,CAAU,WAAA,EAAY;AACpD,IAAA,IAAI,CAAC,gBAAgB,sBAAA,EAAwB;AAC3C,MAAA,MAAM,IAAI,qBAAqB,MAAA,CAAO,kBAAA;AAAA,QACpC,CAAA;AAAA,EAA8C,IAAA,CAAK,SAAA,CAAU,eAAe,CAAC,CAAA;AAAA,OAC/E;AAAA,IACF;AACA,IAAA,OAAO,eAAA,CAAgB,sBAAA;AAAA,EACzB;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../../../src/contract/client.ts"],"sourcesContent":["import { Operation, xdr, Address } from \"../base/index.js\";\nimport { Spec } from \"./spec.js\";\nimport { Server } from \"../rpc/index.js\";\nimport { AssembledTransaction } from \"./assembled_transaction.js\";\nimport type { ClientOptions, MethodOptions } from \"./types.js\";\nimport { sanitizeIdentifier } from \"../bindings/utils.js\";\n\nconst CONSTRUCTOR_FUNC = \"__constructor\";\n\nasync function specFromWasmHash(\n wasmHash: Buffer | string,\n options: Server.Options & { rpcUrl: string },\n format: \"hex\" | \"base64\" = \"hex\",\n): Promise<Spec> {\n if (!options || !options.rpcUrl) {\n throw new TypeError(\"options must contain rpcUrl\");\n }\n const { rpcUrl, allowHttp, headers } = options;\n const serverOpts: Server.Options = { allowHttp, headers };\n const server = new Server(rpcUrl, serverOpts);\n const wasm = await server.getContractWasmByHash(wasmHash, format);\n return Spec.fromWasm(wasm);\n}\n\n/**\n * Generate a class from the contract spec that where each contract method\n * gets included with an identical name.\n *\n * Each method returns an {@link contract.AssembledTransaction | AssembledTransaction} that can\n * be used to modify, simulate, decode results, and possibly sign, & submit the\n * transaction.\n *\n *\n * @param spec - {@link Spec} to construct a Client for\n * @param options - see {@link ClientOptions}\n */\nexport class Client {\n static async deploy<T = Client>(\n /** Constructor/Initialization Args for the contract's `__constructor` method */\n args: Record<string, any> | null,\n /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */\n options: MethodOptions &\n Omit<ClientOptions, \"contractId\"> & {\n /** The hash of the Wasm blob, which must already be installed on-chain. */\n wasmHash: Buffer | string;\n /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */\n salt?: Buffer | Uint8Array;\n /** The format used to decode `wasmHash`, if it's provided as a string. */\n format?: \"hex\" | \"base64\";\n /** The address to use to deploy the custom contract */\n address?: string;\n },\n ): Promise<AssembledTransaction<T>> {\n const {\n wasmHash,\n salt,\n format,\n fee,\n timeoutInSeconds,\n simulate,\n ...clientOptions\n } = options;\n const spec = await specFromWasmHash(wasmHash, clientOptions, format);\n\n const operation = Operation.createCustomContract({\n address: new Address(options.address || options.publicKey!),\n wasmHash:\n typeof wasmHash === \"string\"\n ? Buffer.from(wasmHash, format ?? \"hex\")\n : (wasmHash as Buffer),\n salt,\n constructorArgs: args\n ? spec.funcArgsToScVals(CONSTRUCTOR_FUNC, args)\n : [],\n });\n\n return AssembledTransaction.buildWithOp(operation, {\n fee,\n timeoutInSeconds,\n simulate,\n ...clientOptions,\n contractId: \"ignored\",\n method: CONSTRUCTOR_FUNC,\n parseResultXdr: (result) =>\n new Client(spec, {\n ...clientOptions,\n contractId: Address.fromScVal(result).toString(),\n }),\n }) as unknown as AssembledTransaction<T>;\n }\n\n constructor(\n public readonly spec: Spec,\n public readonly options: ClientOptions,\n ) {\n // Ensure we have a server to reuse for all AssembledTransactions\n if (options.server === undefined) {\n const { allowHttp, headers } = options;\n options.server = new Server(options.rpcUrl, {\n allowHttp,\n headers,\n });\n }\n\n this.spec.funcs().forEach((xdrFn) => {\n const method = xdrFn.name().toString();\n if (method === CONSTRUCTOR_FUNC) {\n return;\n }\n const assembleTransaction = (\n args?: Record<string, any>,\n methodOptions?: MethodOptions,\n ) =>\n AssembledTransaction.build({\n method,\n args: args && spec.funcArgsToScVals(method, args),\n ...options,\n ...methodOptions,\n errorTypes: spec.errorCases().reduce(\n (acc, curr) => ({\n ...acc,\n [curr.value()]: { message: curr.doc().toString() },\n }),\n {} as Pick<ClientOptions, \"errorTypes\">,\n ),\n parseResultXdr: (result: xdr.ScVal) =>\n spec.funcResToNative(method, result),\n });\n\n // @ts-ignore error TS7053: Element implicitly has an 'any' type\n this[sanitizeIdentifier(method)] =\n spec.getFunc(method).inputs().length === 0\n ? (opts?: MethodOptions) => assembleTransaction(undefined, opts)\n : assembleTransaction;\n });\n }\n\n /**\n * Generates a Client instance from the provided ClientOptions and the contract's wasm hash.\n * The wasmHash can be provided in either hex or base64 format.\n *\n * @param wasmHash - The hash of the contract's wasm binary, in either hex or base64 format.\n * @param options - The ClientOptions object containing the necessary configuration, including the rpcUrl.\n * @param format - (optional) The format of the provided wasmHash, either \"hex\" or \"base64\". Defaults to \"hex\".\n * @returns A Promise that resolves to a Client instance.\n * @throws If the provided options object does not contain an rpcUrl.\n */\n static async fromWasmHash(\n wasmHash: Buffer | string,\n options: ClientOptions,\n format: \"hex\" | \"base64\" = \"hex\",\n ): Promise<Client> {\n if (!options || !options.rpcUrl) {\n throw new TypeError(\"options must contain rpcUrl\");\n }\n const { rpcUrl, allowHttp, headers } = options;\n const server =\n options.server ??\n new Server(rpcUrl, {\n allowHttp,\n headers,\n });\n const wasm = await server.getContractWasmByHash(wasmHash, format);\n\n return Client.fromWasm(wasm, options);\n }\n\n /**\n * Generates a Client instance from the provided ClientOptions and the contract's wasm binary.\n *\n * @param wasm - The contract's wasm binary as a Buffer.\n * @param options - The ClientOptions object containing the necessary configuration.\n * @returns A Promise that resolves to a Client instance.\n * @throws If the contract spec cannot be obtained from the provided wasm binary.\n */\n static async fromWasm(wasm: Buffer, options: ClientOptions): Promise<Client> {\n const spec = await Spec.fromWasm(wasm);\n return new Client(spec, options);\n }\n\n /**\n * Generates a Client instance from the provided ClientOptions, which must include the contractId and rpcUrl.\n *\n * @param options - The ClientOptions object containing the necessary configuration, including the contractId and rpcUrl.\n * @returns A Promise that resolves to a Client instance.\n * @throws If the provided options object does not contain both rpcUrl and contractId.\n */\n static async from(options: ClientOptions): Promise<Client> {\n if (!options || !options.rpcUrl || !options.contractId) {\n throw new TypeError(\"options must contain rpcUrl and contractId\");\n }\n const { rpcUrl, contractId, allowHttp, headers } = options;\n const server = new Server(rpcUrl, {\n allowHttp,\n headers,\n });\n const wasm = await server.getContractWasmByContractId(contractId);\n return Client.fromWasm(wasm, options);\n }\n\n txFromJSON = <T>(json: string): AssembledTransaction<T> => {\n const { method, ...tx } = JSON.parse(json);\n return AssembledTransaction.fromJSON(\n {\n ...this.options,\n method,\n parseResultXdr: (result: xdr.ScVal) =>\n this.spec.funcResToNative(method, result),\n },\n tx,\n );\n };\n\n txFromXDR = <T>(xdrBase64: string): AssembledTransaction<T> =>\n AssembledTransaction.fromXDR(this.options, xdrBase64, this.spec);\n}\n"],"names":["Server"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,gBAAA,GAAmB,eAAA;AAEzB,eAAe,gBAAA,CACb,QAAA,EACA,OAAA,EACA,MAAA,GAA2B,KAAA,EACZ;AACf,EA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":3,"file":"client.js","sources":["../../../src/contract/client.ts"],"sourcesContent":["import { Operation, xdr, Address } from \"../base/index.js\";\nimport { Spec } from \"./spec.js\";\nimport { Server } from \"../rpc/index.js\";\nimport { AssembledTransaction } from \"./assembled_transaction.js\";\nimport type { ClientOptions, MethodOptions } from \"./types.js\";\nimport { sanitizeIdentifier } from \"../bindings/utils.js\";\n\nconst CONSTRUCTOR_FUNC = \"__constructor\";\n\nasync function specFromWasmHash(\n wasmHash: Buffer | string,\n options: Server.Options & { rpcUrl: string },\n format: \"hex\" | \"base64\" = \"hex\",\n): Promise<Spec> {\n if (!options || !options.rpcUrl) {\n throw new TypeError(\"options must contain rpcUrl\");\n }\n const { rpcUrl, allowHttp, headers } = options;\n const serverOpts: Server.Options = { allowHttp, headers };\n const server = new Server(rpcUrl, serverOpts);\n const wasm = await server.getContractWasmByHash(wasmHash, format);\n return Spec.fromWasm(wasm);\n}\n\n/**\n * Generate a class from the contract spec that where each contract method\n * gets included with an identical name.\n *\n * Each method returns an {@link contract.AssembledTransaction | AssembledTransaction} that can\n * be used to modify, simulate, decode results, and possibly sign, & submit the\n * transaction.\n *\n *\n * @param spec - {@link Spec} to construct a Client for\n * @param options - see {@link ClientOptions}\n */\nexport class Client {\n static async deploy<T = Client>(\n /** Constructor/Initialization Args for the contract's `__constructor` method */\n args: Record<string, any> | null,\n /** Options for initializing a Client as well as for calling a method, with extras specific to deploying. */\n options: MethodOptions &\n Omit<ClientOptions, \"contractId\"> & {\n /** The hash of the Wasm blob, which must already be installed on-chain. */\n wasmHash: Buffer | string;\n /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */\n salt?: Buffer | Uint8Array;\n /** The format used to decode `wasmHash`, if it's provided as a string. */\n format?: \"hex\" | \"base64\";\n /** The address to use to deploy the custom contract */\n address?: string;\n },\n ): Promise<AssembledTransaction<T>> {\n const {\n wasmHash,\n salt,\n format,\n fee,\n timeoutInSeconds,\n simulate,\n ...clientOptions\n } = options;\n const spec = await specFromWasmHash(wasmHash, clientOptions, format);\n\n const operation = Operation.createCustomContract({\n address: new Address(options.address || options.publicKey!),\n wasmHash:\n typeof wasmHash === \"string\"\n ? Buffer.from(wasmHash, format ?? \"hex\")\n : (wasmHash as Buffer),\n salt,\n constructorArgs: args\n ? spec.funcArgsToScVals(CONSTRUCTOR_FUNC, args)\n : [],\n });\n\n return AssembledTransaction.buildWithOp(operation, {\n fee,\n timeoutInSeconds,\n simulate,\n ...clientOptions,\n contractId: \"ignored\",\n method: CONSTRUCTOR_FUNC,\n parseResultXdr: (result) =>\n new Client(spec, {\n ...clientOptions,\n contractId: Address.fromScVal(result).toString(),\n }),\n }) as unknown as AssembledTransaction<T>;\n }\n\n constructor(\n public readonly spec: Spec,\n public readonly options: ClientOptions,\n ) {\n // Ensure we have a server to reuse for all AssembledTransactions\n if (options.server === undefined) {\n const { allowHttp, headers } = options;\n options.server = new Server(options.rpcUrl, {\n allowHttp,\n headers,\n });\n }\n\n this.spec.funcs().forEach((xdrFn) => {\n const method = xdrFn.name().toString();\n if (method === CONSTRUCTOR_FUNC) {\n return;\n }\n const assembleTransaction = (\n args?: Record<string, any>,\n methodOptions?: MethodOptions,\n ) =>\n AssembledTransaction.build({\n method,\n args: args && spec.funcArgsToScVals(method, args),\n ...options,\n ...methodOptions,\n errorTypes: spec.errorCases().reduce(\n (acc, curr) => ({\n ...acc,\n [curr.value()]: { message: curr.doc().toString() },\n }),\n {} as Pick<ClientOptions, \"errorTypes\">,\n ),\n parseResultXdr: (result: xdr.ScVal) =>\n spec.funcResToNative(method, result),\n });\n\n // @ts-expect-error error TS7053: Element implicitly has an 'any' type\n this[sanitizeIdentifier(method)] =\n spec.getFunc(method).inputs().length === 0\n ? (opts?: MethodOptions) => assembleTransaction(undefined, opts)\n : assembleTransaction;\n });\n }\n\n /**\n * Generates a Client instance from the provided ClientOptions and the contract's wasm hash.\n * The wasmHash can be provided in either hex or base64 format.\n *\n * @param wasmHash - The hash of the contract's wasm binary, in either hex or base64 format.\n * @param options - The ClientOptions object containing the necessary configuration, including the rpcUrl.\n * @param format - (optional) The format of the provided wasmHash, either \"hex\" or \"base64\". Defaults to \"hex\".\n * @returns A Promise that resolves to a Client instance.\n * @throws If the provided options object does not contain an rpcUrl.\n */\n static async fromWasmHash(\n wasmHash: Buffer | string,\n options: ClientOptions,\n format: \"hex\" | \"base64\" = \"hex\",\n ): Promise<Client> {\n if (!options || !options.rpcUrl) {\n throw new TypeError(\"options must contain rpcUrl\");\n }\n const { rpcUrl, allowHttp, headers } = options;\n const server =\n options.server ??\n new Server(rpcUrl, {\n allowHttp,\n headers,\n });\n const wasm = await server.getContractWasmByHash(wasmHash, format);\n\n return Client.fromWasm(wasm, options);\n }\n\n /**\n * Generates a Client instance from the provided ClientOptions and the contract's wasm binary.\n *\n * @param wasm - The contract's wasm binary as a Buffer.\n * @param options - The ClientOptions object containing the necessary configuration.\n * @returns A Promise that resolves to a Client instance.\n * @throws If the contract spec cannot be obtained from the provided wasm binary.\n */\n static async fromWasm(wasm: Buffer, options: ClientOptions): Promise<Client> {\n const spec = await Spec.fromWasm(wasm);\n return new Client(spec, options);\n }\n\n /**\n * Generates a Client instance from the provided ClientOptions, which must include the contractId and rpcUrl.\n *\n * @param options - The ClientOptions object containing the necessary configuration, including the contractId and rpcUrl.\n * @returns A Promise that resolves to a Client instance.\n * @throws If the provided options object does not contain both rpcUrl and contractId.\n */\n static async from(options: ClientOptions): Promise<Client> {\n if (!options || !options.rpcUrl || !options.contractId) {\n throw new TypeError(\"options must contain rpcUrl and contractId\");\n }\n const { rpcUrl, contractId, allowHttp, headers } = options;\n const server = new Server(rpcUrl, {\n allowHttp,\n headers,\n });\n const wasm = await server.getContractWasmByContractId(contractId);\n return Client.fromWasm(wasm, options);\n }\n\n txFromJSON = <T>(json: string): AssembledTransaction<T> => {\n const { method, ...tx } = JSON.parse(json);\n return AssembledTransaction.fromJSON(\n {\n ...this.options,\n method,\n parseResultXdr: (result: xdr.ScVal) =>\n this.spec.funcResToNative(method, result),\n },\n tx,\n );\n };\n\n txFromXDR = <T>(xdrBase64: string): AssembledTransaction<T> =>\n AssembledTransaction.fromXDR(this.options, xdrBase64, this.spec);\n}\n"],"names":["Server"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,gBAAA,GAAmB,eAAA;AAEzB,eAAe,gBAAA,CACb,QAAA,EACA,OAAA,EACA,MAAA,GAA2B,KAAA,EACZ;AACf,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,OAAA,CAAQ,MAAA,EAAQ;AAC/B,IAAA,MAAM,IAAI,UAAU,6BAA6B,CAAA;AAAA,EACnD;AACA,EAAA,MAAM,EAAE,MAAA,EAAQ,SAAA,EAAW,OAAA,EAAQ,GAAI,OAAA;AACvC,EAAA,MAAM,UAAA,GAA6B,EAAE,SAAA,EAAW,OAAA,EAAQ;AACxD,EAAA,MAAM,MAAA,GAAS,IAAIA,SAAA,CAAO,MAAA,EAAQ,UAAU,CAAA;AAC5C,EAAA,MAAM,IAAA,GAAO,MAAM,MAAA,CAAO,qBAAA,CAAsB,UAAU,MAAM,CAAA;AAChE,EAAA,OAAO,IAAA,CAAK,SAAS,IAAI,CAAA;AAC3B;AAcO,MAAM,MAAA,CAAO;AAAA,EAuDlB,WAAA,CACkB,MACA,OAAA,EAChB;AAFgB,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGhB,IAAA,IAAI,OAAA,CAAQ,WAAW,MAAA,EAAW;AAChC,MAAA,MAAM,EAAE,SAAA,EAAW,OAAA,EAAQ,GAAI,OAAA;AAC/B,MAAA,OAAA,CAAQ,MAAA,GAAS,IAAIA,SAAA,CAAO,OAAA,CAAQ,MAAA,EAAQ;AAAA,QAC1C,SAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH;AAEA,IAAA,IAAA,CAAK,IAAA,CAAK,KAAA,EAAM,CAAE,OAAA,CAAQ,CAAC,KAA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