PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm

Просмотр файла: chunk-UGIHQFID.mjs.map

{"version":3,"sources":["../../src/api/transactionSubmission/simulate.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PublicKey } from \"../../core\";\nimport { simulateTransaction } from \"../../internal/transactionSubmission\";\nimport { AnyRawTransaction, InputSimulateTransactionOptions } from \"../../transactions\";\nimport { UserTransactionResponse } from \"../../types\";\nimport { AptosConfig } from \"../aptosConfig\";\nimport { ValidateFeePayerDataOnSimulation } from \"./helpers\";\n\n/**\n * A class to handle all `Simulate` transaction operations.\n */\nexport class Simulate {\n  readonly config: AptosConfig;\n\n  /**\n   * Initializes a new instance of the Aptos client with the specified configuration.\n   * This allows you to interact with the Aptos blockchain using the provided settings.\n   *\n   * @param config - The configuration settings for the Aptos client.\n   * @param config.network - The network to connect to (e.g., TESTNET, MAINNET).\n   * @param config.nodeUrl - The URL of the Aptos node to connect to.\n   *\n   * @example\n   * ```typescript\n   * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n   *\n   * async function runExample() {\n   *     // Create a configuration for the Aptos client\n   *     const config = new AptosConfig({ network: Network.TESTNET }); // Specify your desired network\n   *\n   *     // Initialize the Aptos client with the configuration\n   *     const aptos = new Aptos(config);\n   *\n   *     console.log(\"Aptos client initialized:\", aptos);\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  constructor(config: AptosConfig) {\n    this.config = config;\n  }\n\n  /**\n   * Simulates a transaction based on the provided parameters and returns the result.\n   * This function helps you understand the outcome of a transaction before executing it on the blockchain.\n   *\n   * @param args - The parameters for simulating the transaction.\n   * @param args.signerPublicKey - The public key of the signer for the transaction (optional).\n   * @param args.transaction - The raw transaction data to simulate.\n   * @param args.feePayerPublicKey - The public key of the fee payer (optional).\n   * @param args.options - Additional options for simulating the transaction (optional).\n   *\n   * @example\n   * ```typescript\n   * import {\n   *     Account,\n   *     Aptos,\n   *     AptosConfig,\n   *     Network,\n   * } from \"@aptos-labs/ts-sdk\";\n   *\n   * async function example() {\n   *     let sender = Account.generate();\n   *     let receiver = Account.generate();\n   *\n   *     // 0. Set up the client and test accounts\n   *     const config = new AptosConfig({ network: Network.DEVNET });\n   *     const aptos = new Aptos(config);\n   *\n   *     await aptos.fundAccount({\n   *         accountAddress: sender.accountAddress,\n   *         amount: 100_000_000,\n   *     });\n   *\n   *     // 1. Build the transaction to preview the impact of it\n   *     const transaction = await aptos.transaction.build.simple({\n   *         sender: sender.accountAddress,\n   *         data: {\n   *             // All transactions on Aptos are implemented via smart contracts.\n   *             function: \"0x1::aptos_account::transfer\",\n   *             functionArguments: [receiver.accountAddress, 100],\n   *         },\n   *     });\n   *\n   *     // 2. Simulate to see what would happen if we execute this transaction\n   *     const [userTransactionResponse] = await aptos.transaction.simulate.simple({\n   *         signerPublicKey: sender.publicKey,\n   *         transaction,\n   *     });\n   *     console.log(userTransactionResponse);\n   *\n   *     // If the fee looks ok, continue to signing!\n   *     // ...\n   * }\n   *\n   * example();\n   * ```\n   */\n  @ValidateFeePayerDataOnSimulation\n  async simple(args: {\n    signerPublicKey?: PublicKey;\n    transaction: AnyRawTransaction;\n    feePayerPublicKey?: PublicKey;\n    options?: InputSimulateTransactionOptions;\n  }): Promise<Array<UserTransactionResponse>> {\n    return simulateTransaction({ aptosConfig: this.config, ...args });\n  }\n\n  /**\n   * Simulates a multi-agent transaction by generating a signed transaction and posting it to the Aptos full node.\n   * This function helps in understanding the outcome of a transaction involving multiple signers before it is executed.\n   *\n   * @param args - The parameters for simulating the transaction.\n   * @param args.signerPublicKey - The public key of the primary signer (optional).\n   * @param args.transaction - The raw transaction to be simulated.\n   * @param args.secondarySignersPublicKeys - An array of public keys for secondary signers (optional).\n   *        Each element of the array can be optional, allowing the corresponding key check to be skipped.\n   * @param args.feePayerPublicKey - The public key of the fee payer (optional).\n   * @param args.options - Options for simulating the transaction (optional).\n   *\n   * @example\n   * ```typescript\n   * import {\n   *     Account,\n   *     Aptos,\n   *     AptosConfig,\n   *     Network,\n   * } from \"@aptos-labs/ts-sdk\";\n   *\n   * async function example() {\n   *     let sender1 = Account.generate();\n   *     let sender2 = Account.generate();\n   *     let receiver = Account.generate();\n   *\n   *     // 0. Set up the client and test accounts\n   *     const config = new AptosConfig({ network: Network.DEVNET });\n   *     const aptos = new Aptos(config);\n   *\n   *     await aptos.fundAccount({\n   *         accountAddress: sender.accountAddress,\n   *         amount: 100_000_000,\n   *     });\n   *\n   *     // 1. Build\n   *     console.log(\"\\n=== 1. Building the transaction ===\\n\");\n   *     const transaction = await aptos.transaction.build.multiAgent({\n   *     sender: sender1.accountAddress,\n   *     secondarySignerAddresses: [sender2.accountAddress],\n   *     data: {\n   *        // REPLACE WITH YOUR MULTI-AGENT FUNCTION HERE\n   *        function:\n   *          \"<REPLACE WITH YOUR MULTI AGENT MOVE ENTRY FUNCTION> (Syntax {address}::{module}::{function})\",\n   *          functionArguments: [],\n   *        },\n   *      });\n   *      console.log(\"Transaction:\", transaction);\n   *\n   *      // 2. Simulate (Optional)\n   *      console.log(\"\\n === 2. Simulating Response (Optional) === \\n\");\n   *      const [userTransactionResponse] = await aptos.transaction.simulate.multiAgent(\n   *        {\n   *          signerPublicKey: sender1.publicKey,\n   *          secondarySignersPublicKeys: [sender2.publicKey],\n   *          transaction,\n   *        },\n   *      );\n   *      console.log(userTransactionResponse);\n   *\n   *      // If the fee looks ok, continue to signing!\n   *      // ...\n   * }\n   *\n   * example();\n   * ```\n   */\n  @ValidateFeePayerDataOnSimulation\n  async multiAgent(args: {\n    signerPublicKey?: PublicKey;\n    transaction: AnyRawTransaction;\n    secondarySignersPublicKeys?: Array<PublicKey | undefined>;\n    feePayerPublicKey?: PublicKey;\n    options?: InputSimulateTransactionOptions;\n  }): Promise<Array<UserTransactionResponse>> {\n    return simulateTransaction({ aptosConfig: this.config, ...args });\n  }\n}\n"],"mappings":"2HAaO,IAAMA,EAAN,KAAe,CA2BpB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CA2DA,MAAM,OAAOC,EAK+B,CAC1C,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CAsEA,MAAM,WAAWA,EAM2B,CAC1C,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CACF,EAtFQE,EAAA,CADLC,GAvFUL,EAwFL,sBA6EAI,EAAA,CADLC,GApKUL,EAqKL","names":["Simulate","config","args","simulateTransaction","__decorateClass","ValidateFeePayerDataOnSimulation"]}

Выполнить команду


Для локальной разработки. Не используйте в интернете!