PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm
Просмотр файла: chunk-ELXJ5A4B.mjs.map
{"version":3,"sources":["../../src/account/Account.ts"],"sourcesContent":["import type { AccountAuthenticator } from \"../transactions/authenticator/account\";\nimport { HexInput, SigningScheme, SigningSchemeInput } from \"../types\";\nimport type { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { AuthenticationKey } from \"../core/authenticationKey\";\nimport { AccountPublicKey, Ed25519PrivateKey, PrivateKey, Signature, VerifySignatureArgs } from \"../core/crypto\";\nimport { Ed25519Account } from \"./Ed25519Account\";\nimport { SingleKeyAccount } from \"./SingleKeyAccount\";\nimport { AnyRawTransaction } from \"../transactions/types\";\n\n/**\n * Arguments for creating an `Ed25519Account` from an `Ed25519PrivateKey`.\n * To use the SingleKey authentication scheme, set `legacy` to false.\n *\n * @param privateKey - The private key used to create the account.\n * @param address - Optional address for the account.\n * @param legacy - Indicates whether to use legacy authentication (default is true).\n */\nexport interface CreateEd25519AccountFromPrivateKeyArgs {\n privateKey: Ed25519PrivateKey;\n address?: AccountAddressInput;\n legacy?: true;\n}\n\n/**\n * Arguments for creating a `SingleKeyAccount` using an `Ed25519PrivateKey`.\n * The `legacy` property must be set to false to utilize the `SingleKey` authentication scheme.\n *\n * @param privateKey - The Ed25519 private key used for account creation.\n * @param address - Optional account address input.\n * @param legacy - Must be false to enable the `SingleKey` authentication scheme.\n */\nexport interface CreateEd25519SingleKeyAccountFromPrivateKeyArgs {\n privateKey: Ed25519PrivateKey;\n address?: AccountAddressInput;\n legacy: false;\n}\n\n/**\n * Arguments for creating a `SingleKeyAccount` from a supported private key, excluding `Ed25519PrivateKey`.\n * The `legacy` argument is always false and cannot be set to true.\n *\n * @param privateKey - The private key used to create the account.\n * @param address - Optional address input for the account.\n * @param legacy - Always false; cannot be explicitly set to true.\n */\nexport interface CreateSingleKeyAccountFromPrivateKeyArgs {\n privateKey: Exclude<PrivateKey, Ed25519PrivateKey>;\n address?: AccountAddressInput;\n legacy?: false;\n}\n\n/**\n * Arguments for creating an `Account` from a private key when the key type is unknown at compile time.\n *\n * @param privateKey - The private key used to create the account.\n * @param address - Optional address for the account.\n * @param legacy - Optional flag indicating if the account is a legacy account.\n */\nexport interface CreateAccountFromPrivateKeyArgs {\n privateKey: PrivateKey;\n address?: AccountAddressInput;\n legacy?: boolean;\n}\n\n/**\n * Arguments for generating an Ed25519 account, specifying the signing scheme and legacy option.\n *\n * @param scheme - The signing scheme to use for the account.\n * @param legacy - Indicates if the account should be created in legacy mode.\n */\nexport interface GenerateEd25519AccountArgs {\n scheme?: SigningSchemeInput.Ed25519;\n legacy?: true;\n}\n\n/**\n * Arguments for generating a `SingleKeyAccount` with an underlying `Ed25519PrivateKey`.\n * The `legacy` argument must be set to false to ensure an `Ed25519SingleKeyAccount` is returned.\n *\n * @param scheme - Optional signing scheme input for the account.\n * @param legacy - Indicates whether to use legacy account generation.\n */\nexport interface GenerateEd25519SingleKeyAccountArgs {\n scheme?: SigningSchemeInput.Ed25519;\n legacy: false;\n}\n\n/**\n * Arguments for generating a `SingleKeyAccount` using a supported private key other than `Ed25519PrivateKey`.\n * The `legacy` argument is optional and defaults to false, and cannot be set to true.\n *\n * @param scheme - The signing scheme to use for the account.\n * @param legacy - Indicates whether to use legacy account generation (defaults to false).\n */\nexport interface GenerateSingleKeyAccountArgs {\n scheme: Exclude<SigningSchemeInput, SigningSchemeInput.Ed25519>;\n legacy?: false;\n}\n\n/**\n * Arguments for generating an opaque `Account` when the input signature scheme is unknown at compile time.\n *\n * @param scheme - The signing scheme to use for account generation.\n * @param legacy - Indicates whether to use legacy account generation methods.\n */\nexport interface GenerateAccountArgs {\n scheme?: SigningSchemeInput;\n legacy?: boolean;\n}\n\n/**\n * Arguments for deriving a private key using a mnemonic phrase and a specified BIP44 path.\n *\n * @param path - The BIP44 derivation path for the key.\n * @param mnemonic - The mnemonic phrase used for key generation.\n */\nexport interface PrivateKeyFromDerivationPathArgs {\n path: string;\n mnemonic: string;\n}\n\n/**\n * Abstract class representing a generic Aptos account.\n *\n * This class serves as a single entry point for account generation, allowing accounts to be created\n * either through `Account.generate()` or `Account.fromDerivationPath`. Although it is defined as an\n * abstract class, it should be treated as an interface and enforced using the `implements` keyword.\n *\n * Note: Generating an account instance does not create the account on-chain.\n */\nexport abstract class Account {\n /**\n * Public key associated with the account\n */\n abstract readonly publicKey: AccountPublicKey;\n\n /**\n * Account address associated with the account\n */\n abstract readonly accountAddress: AccountAddress;\n\n /**\n * Signing scheme used to sign transactions\n */\n abstract signingScheme: SigningScheme;\n\n /**\n * Generates a new account based on the specified signing scheme and legacy option.\n * This function allows you to create an account with either the Ed25519 signing scheme or a different scheme as specified.\n *\n * @param args - The arguments for generating the account.\n * @param args.scheme - The signing scheme to use for account generation. Defaults to Ed25519.\n * @param args.legacy - Indicates whether to use the legacy account generation method. Defaults to true.\n */\n static generate(args?: GenerateEd25519AccountArgs): Ed25519Account;\n static generate(args: GenerateEd25519SingleKeyAccountArgs): SingleKeyAccount;\n static generate(args: GenerateSingleKeyAccountArgs): SingleKeyAccount;\n static generate(args: GenerateAccountArgs): Account;\n static generate(args: GenerateAccountArgs = {}) {\n const { scheme = SigningSchemeInput.Ed25519, legacy = true } = args;\n if (scheme === SigningSchemeInput.Ed25519 && legacy) {\n return Ed25519Account.generate();\n }\n return SingleKeyAccount.generate({ scheme });\n }\n\n /**\n * Creates an account from a given private key and address.\n * This function allows you to instantiate an account based on the provided private key,\n * and it can differentiate between legacy and non-legacy accounts.\n *\n * @param args - The arguments for creating the account.\n * @param args.privateKey - The private key used to create the account.\n * @param args.address - The address associated with the account.\n * @param args.legacy - A boolean indicating whether to create a legacy account (default is true).\n * @returns An instance of either Ed25519Account or SingleKeyAccount based on the provided private key.\n */\n static fromPrivateKey(args: CreateEd25519AccountFromPrivateKeyArgs): Ed25519Account;\n static fromPrivateKey(args: CreateEd25519SingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;\n static fromPrivateKey(args: CreateSingleKeyAccountFromPrivateKeyArgs): SingleKeyAccount;\n static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs): Account;\n static fromPrivateKey(args: CreateAccountFromPrivateKeyArgs) {\n const { privateKey, address, legacy = true } = args;\n if (privateKey instanceof Ed25519PrivateKey && legacy) {\n return new Ed25519Account({\n privateKey,\n address,\n });\n }\n return new SingleKeyAccount({ privateKey, address });\n }\n\n /**\n * @deprecated use `fromPrivateKey` instead.\n * Instantiates an account using a private key and a specified account address. This is primarily used to instantiate an\n * `Account` that has had its authentication key rotated.\n *\n * @param args - The arguments required to create an account from a private key.\n * @param args.privateKey - The underlying private key for the account.\n * @param args.address - The account address the `Account` will sign for.\n * @param args.legacy - Optional. If set to false, the keypair generated is a Unified keypair. Defaults to generating a Legacy\n * Ed25519 keypair.\n *\n * @returns Account\n */\n static fromPrivateKeyAndAddress(args: CreateAccountFromPrivateKeyArgs) {\n return this.fromPrivateKey(args);\n }\n\n /**\n * Generates an account from a specified derivation path and mnemonic.\n * This function allows you to create an account using different signing schemes based on the provided arguments.\n *\n * @param args - The arguments for generating the account.\n * @param args.scheme - The signing scheme to use for account generation. Defaults to Ed25519.\n * @param args.mnemonic - The mnemonic phrase used to derive the account.\n * @param args.path - The derivation path used to generate the account.\n * @param args.legacy - A boolean indicating whether to use the legacy account generation method. Defaults to true.\n */\n static fromDerivationPath(args: GenerateEd25519AccountArgs & PrivateKeyFromDerivationPathArgs): Ed25519Account;\n static fromDerivationPath(\n args: GenerateEd25519SingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs,\n ): SingleKeyAccount;\n static fromDerivationPath(args: GenerateSingleKeyAccountArgs & PrivateKeyFromDerivationPathArgs): SingleKeyAccount;\n static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs): Account;\n static fromDerivationPath(args: GenerateAccountArgs & PrivateKeyFromDerivationPathArgs) {\n const { scheme = SigningSchemeInput.Ed25519, mnemonic, path, legacy = true } = args;\n if (scheme === SigningSchemeInput.Ed25519 && legacy) {\n return Ed25519Account.fromDerivationPath({ mnemonic, path });\n }\n return SingleKeyAccount.fromDerivationPath({ scheme, mnemonic, path });\n }\n\n /**\n * Retrieve the authentication key for the associated account using the provided public key.\n * This key enables account owners to rotate their private key(s) associated with the account without changing the address that\n * hosts their account.\n * See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}\n *\n * @param args - The arguments for retrieving the authentication key.\n * @param args.publicKey - The public key of the account.\n * @returns The authentication key for the associated account.\n */\n static authKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Sign a message using the available signing capabilities.\n * @param message the signing message, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n */\n abstract signWithAuthenticator(message: HexInput): AccountAuthenticator;\n\n /**\n * Sign a transaction using the available signing capabilities.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n */\n abstract signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticator;\n\n /**\n * Sign the given message using the available signing capabilities.\n * @param message in HexInput format\n * @returns Signature\n */\n abstract sign(message: HexInput): Signature;\n\n /**\n * Sign the given transaction using the available signing capabilities.\n * @param transaction the transaction to be signed\n * @returns Signature\n */\n abstract signTransaction(transaction: AnyRawTransaction): Signature;\n\n /**\n * Verify the given message and signature with the public key.\n * This function helps ensure the integrity and authenticity of a message by validating its signature.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The raw message data in HexInput format.\n * @param args.signature - The signed message signature.\n * @returns A boolean indicating whether the signature is valid.\n */\n verifySignature(args: VerifySignatureArgs): boolean {\n return this.publicKey.verifySignature(args);\n }\n}\n"],"mappings":"2HAkIO,IAAeA,EAAf,KAAuB,CA4B5B,OAAO,SAASC,EAA4B,CAAC,EAAG,CAC9C,GAAM,CAAE,OAAAC,IAAqC,OAAAC,EAAS,EAAK,EAAIF,EAC/D,OAAIC,IAAW,GAA8BC,EACpCC,EAAe,SAAS,EAE1BC,EAAiB,SAAS,CAAE,OAAAH,CAAO,CAAC,CAC7C,CAiBA,OAAO,eAAeD,EAAuC,CAC3D,GAAM,CAAE,WAAAK,EAAY,QAAAC,EAAS,OAAAJ,EAAS,EAAK,EAAIF,EAC/C,OAAIK,aAAsBE,GAAqBL,EACtC,IAAIC,EAAe,CACxB,WAAAE,EACA,QAAAC,CACF,CAAC,EAEI,IAAIF,EAAiB,CAAE,WAAAC,EAAY,QAAAC,CAAQ,CAAC,CACrD,CAeA,OAAO,yBAAyBN,EAAuC,CACrE,OAAO,KAAK,eAAeA,CAAI,CACjC,CAkBA,OAAO,mBAAmBA,EAA8D,CACtF,GAAM,CAAE,OAAAC,IAAqC,SAAAO,EAAU,KAAAC,EAAM,OAAAP,EAAS,EAAK,EAAIF,EAC/E,OAAIC,IAAW,GAA8BC,EACpCC,EAAe,mBAAmB,CAAE,SAAAK,EAAU,KAAAC,CAAK,CAAC,EAEtDL,EAAiB,mBAAmB,CAAE,OAAAH,EAAQ,SAAAO,EAAU,KAAAC,CAAK,CAAC,CACvE,CAYA,OAAO,QAAQT,EAA0D,CACvE,GAAM,CAAE,UAAAU,CAAU,EAAIV,EACtB,OAAOU,EAAU,QAAQ,CAC3B,CAuCA,gBAAgBV,EAAoC,CAClD,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CACF","names":["Account","args","scheme","legacy","Ed25519Account","SingleKeyAccount","privateKey","address","Ed25519PrivateKey","mnemonic","path","publicKey"]}Выполнить команду
Для локальной разработки. Не используйте в интернете!