PHP WebShell

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

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

{"version":3,"sources":["../../src/api/transactionSubmission/management.ts"],"sourcesContent":["import EventEmitter from \"eventemitter3\";\nimport { TransactionWorkerEvents, TransactionWorker, TransactionWorkerEventsEnum } from \"../../transactions/management\";\nimport { InputGenerateTransactionPayloadData, InputGenerateTransactionOptions } from \"../../transactions\";\nimport { AptosConfig } from \"../aptosConfig\";\nimport { Account } from \"../../account\";\n\nexport class TransactionManagement extends EventEmitter<TransactionWorkerEvents> {\n  account!: Account;\n\n  transactionWorker!: TransactionWorker;\n\n  readonly config: AptosConfig;\n\n  /**\n   * Initializes a new instance of the Aptos client with the provided configuration settings.\n   * This allows you to interact with the Aptos blockchain using the specified network and options.\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   * @param config.account - Optional account settings for authentication.\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({\n   *         network: Network.TESTNET, // specify the network to use\n   *         nodeUrl: \"https://testnet.aptos.dev\" // replace with your node URL\n   *     });\n   *\n   *     // Initialize the Aptos client with the configuration\n   *     const aptos = new Aptos(config);\n   *\n   *     console.log(\"Aptos client initialized successfully.\");\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  constructor(config: AptosConfig) {\n    super();\n    this.config = config;\n  }\n\n  /**\n   * Initializes the transaction worker using the provided sender account and begins listening for events.\n   * This function is essential for setting up the transaction processing environment.\n   *\n   * @param args - The arguments for starting the transaction worker.\n   * @param args.sender - The sender account to sign and submit the transaction.\n   *\n   * @example\n   * ```typescript\n   * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n   *\n   * const config = new AptosConfig({ network: Network.TESTNET });\n   * const aptos = new Aptos(config);\n   *\n   * async function runExample() {\n   *     const sender = Account.generate(); // Generate a new account for sending transactions\n   *\n   *     // Start the transaction worker with the sender account\n   *     aptos.start({ sender });\n   *\n   *     console.log(\"Transaction worker started with sender:\", sender.accountAddress);\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  private start(args: { sender: Account }): void {\n    const { sender } = args;\n    this.account = sender;\n    this.transactionWorker = new TransactionWorker(this.config, sender);\n\n    this.transactionWorker.start();\n    this.registerToEvents();\n  }\n\n  /**\n   * Pushes transaction data to the transaction worker for processing.\n   *\n   * @param args.data An array of transaction payloads to be processed.\n   * @param args.options Optional. Transaction generation configurations (excluding accountSequenceNumber).\n   *\n   * @example\n   * ```typescript\n   * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n   *\n   * const config = new AptosConfig({ network: Network.TESTNET });\n   * const aptos = new Aptos(config);\n   *\n   * async function runExample() {\n   *   // Prepare transaction payloads\n   *   const payloads = [\n   *      {}, // Build your first transaction payload\n   *      {}, // Build your second transaction payload\n   *   ];\n   *\n   *   // Push transaction data to the worker\n   *   aptos.push({\n   *     data: payloads,\n   *     {}, // Specify options as needed\n   *   });\n   *\n   *   console.log(\"Transaction data pushed successfully.\");\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  private push(args: {\n    data: InputGenerateTransactionPayloadData[];\n    options?: Omit<InputGenerateTransactionOptions, \"accountSequenceNumber\">;\n  }): void {\n    const { data, options } = args;\n\n    for (const d of data) {\n      this.transactionWorker.push(d, options);\n    }\n  }\n\n  /**\n   * Starts listening to transaction worker events, allowing the application to respond to transaction status changes.\n   * This function enables the application to handle events such as transaction sent, execution success, or failure.\n   *\n   * @example\n   * ```typescript\n   * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n   *\n   * const config = new AptosConfig({ network: Network.TESTNET });\n   * const aptos = new Aptos(config);\n   *\n   * async function runExample() {\n   *   // Register to listen for transaction events\n   *   aptos.registerToEvents();\n   *\n   *   // You can send a transaction here to see the events in action\n   *   const sender = Account.generate(); // replace with a real account\n   *   const destination = Account.generate(); // replace with a real account\n   *\n   *   const transaction = await aptos.transaction.build.simple({\n   *     sender: sender.accountAddress,\n   *     data: {\n   *       function: \"0x1::aptos_account::transfer\",\n   *       functionArguments: [destination.accountAddress, 100],\n   *     },\n   *   });\n   *\n   *   await aptos.transaction.send(transaction);\n   *\n   *   console.log(\"Transaction sent and events registered.\");\n   * }\n   * runExample().catch(console.error);\n   * ```\n   */\n  private registerToEvents() {\n    // TODO - Should we ask events to listen to this as an input?\n    this.transactionWorker.on(TransactionWorkerEventsEnum.TransactionSent, async (data) => {\n      this.emit(TransactionWorkerEventsEnum.TransactionSent, data);\n    });\n    this.transactionWorker.on(TransactionWorkerEventsEnum.TransactionSendFailed, async (data) => {\n      this.emit(TransactionWorkerEventsEnum.TransactionSendFailed, data);\n    });\n    this.transactionWorker.on(TransactionWorkerEventsEnum.TransactionExecuted, async (data) => {\n      this.emit(TransactionWorkerEventsEnum.TransactionExecuted, data);\n    });\n    this.transactionWorker.on(TransactionWorkerEventsEnum.TransactionExecutionFailed, async (data) => {\n      this.emit(TransactionWorkerEventsEnum.TransactionExecutionFailed, data);\n    });\n    this.transactionWorker.on(TransactionWorkerEventsEnum.ExecutionFinish, async (data) => {\n      this.emit(TransactionWorkerEventsEnum.ExecutionFinish, data);\n    });\n  }\n\n  /**\n   * Send batch transactions for a single account.\n   *\n   * This function uses a transaction worker that receives payloads to be processed\n   * and submitted to chain.\n   * Note that this process is best for submitting multiple transactions that\n   * don't rely on each other, i.e. batch funds, batch token mints, etc.\n   *\n   * If any worker failure, the functions throws an error.\n   *\n   * @param args.sender The sender account to sign and submit the transaction\n   * @param args.data An array of transaction payloads\n   * @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)\n   *\n   * @return void. Throws if any error\n   */\n  forSingleAccount(args: {\n    sender: Account;\n    data: InputGenerateTransactionPayloadData[];\n    options?: Omit<InputGenerateTransactionOptions, \"accountSequenceNumber\">;\n  }): void {\n    try {\n      const { sender, data, options } = args;\n      this.start({ sender });\n\n      this.push({ data, options });\n    } catch (error: any) {\n      throw new Error(`failed to submit transactions with error: ${error}`);\n    }\n  }\n}\n"],"mappings":"yCAAA,OAAOA,MAAkB,gBAMlB,IAAMC,EAAN,cAAoCC,CAAsC,CAmC/E,YAAYC,EAAqB,CAC/B,MAAM,EACN,KAAK,OAASA,CAChB,CA2BQ,MAAMC,EAAiC,CAC7C,GAAM,CAAE,OAAAC,CAAO,EAAID,EACnB,KAAK,QAAUC,EACf,KAAK,kBAAoB,IAAIC,EAAkB,KAAK,OAAQD,CAAM,EAElE,KAAK,kBAAkB,MAAM,EAC7B,KAAK,iBAAiB,CACxB,CAiCQ,KAAKD,EAGJ,CACP,GAAM,CAAE,KAAAG,EAAM,QAAAC,CAAQ,EAAIJ,EAE1B,QAAWK,KAAKF,EACd,KAAK,kBAAkB,KAAKE,EAAGD,CAAO,CAE1C,CAoCQ,kBAAmB,CAEzB,KAAK,kBAAkB,qBAAgD,MAAOD,GAAS,CACrF,KAAK,uBAAkDA,CAAI,CAC7D,CAAC,EACD,KAAK,kBAAkB,2BAAsD,MAAOA,GAAS,CAC3F,KAAK,6BAAwDA,CAAI,CACnE,CAAC,EACD,KAAK,kBAAkB,yBAAoD,MAAOA,GAAS,CACzF,KAAK,2BAAsDA,CAAI,CACjE,CAAC,EACD,KAAK,kBAAkB,gCAA2D,MAAOA,GAAS,CAChG,KAAK,kCAA6DA,CAAI,CACxE,CAAC,EACD,KAAK,kBAAkB,qBAAgD,MAAOA,GAAS,CACrF,KAAK,uBAAkDA,CAAI,CAC7D,CAAC,CACH,CAkBA,iBAAiBH,EAIR,CACP,GAAI,CACF,GAAM,CAAE,OAAAC,EAAQ,KAAAE,EAAM,QAAAC,CAAQ,EAAIJ,EAClC,KAAK,MAAM,CAAE,OAAAC,CAAO,CAAC,EAErB,KAAK,KAAK,CAAE,KAAAE,EAAM,QAAAC,CAAQ,CAAC,CAC7B,OAASE,EAAY,CACnB,MAAM,IAAI,MAAM,6CAA6CA,CAAK,EAAE,CACtE,CACF,CACF","names":["EventEmitter","TransactionManagement","EventEmitter","config","args","sender","TransactionWorker","data","options","d","error"]}

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


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