PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm
Просмотр файла: chunk-BAEIZAP7.mjs.map
{"version":3,"sources":["../../src/transactions/transactionBuilder/helpers.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n EntryFunctionArgumentTypes,\n InputGenerateTransactionPayloadData,\n InputGenerateTransactionPayloadDataWithRemoteABI,\n InputScriptData,\n SimpleEntryFunctionArgumentTypes,\n} from \"../types\";\nimport { Bool, FixedBytes, MoveOption, MoveString, MoveVector, U128, U16, U256, U32, U64, U8 } from \"../../bcs\";\nimport { AccountAddress } from \"../../core\";\nimport { MoveFunction, MoveFunctionId } from \"../../types\";\n\n/**\n * Determines if the provided argument is of type boolean.\n * This can help in validating input types before processing them further.\n *\n * @param arg - The argument to check, which can be of various types.\n * @returns A boolean indicating whether the argument is a boolean.\n */\nexport function isBool(arg: SimpleEntryFunctionArgumentTypes): arg is boolean {\n return typeof arg === \"boolean\";\n}\n\n/**\n * Checks if the provided argument is of type string.\n *\n * @param arg - The value to be checked for string type.\n * @returns A boolean indicating whether the argument is a string.\n */\nexport function isString(arg: any): arg is string {\n return typeof arg === \"string\";\n}\n\n/**\n * Determines if the provided argument is of type number.\n *\n * @param arg - The argument to check, which can be of various types.\n * @returns A boolean indicating whether the argument is a number.\n */\nexport function isNumber(arg: SimpleEntryFunctionArgumentTypes): arg is number {\n return typeof arg === \"number\";\n}\n\n/**\n * Converts a number or a string representation of a number into a number type.\n * This function is useful for ensuring that the input is in a consistent numeric format,\n * which can help prevent type mismatches in further processing.\n *\n * @param arg - The input value to be converted. This can be a number, a string representing a number, or any other type.\n * @returns Returns the converted number if the input is valid; otherwise, it returns undefined.\n */\nexport function convertNumber(arg: SimpleEntryFunctionArgumentTypes): number | undefined {\n if (isNumber(arg)) {\n return arg;\n }\n if (isString(arg) && arg !== \"\") {\n return Number.parseInt(arg, 10);\n }\n\n return undefined;\n}\n\n/**\n * Determines if the provided argument is a large number, which can be a number, bigint, or string representation of a number.\n *\n * @param arg - The argument to check, which can be of type number, bigint, or string.\n */\nexport function isLargeNumber(arg: SimpleEntryFunctionArgumentTypes): arg is number | bigint | string {\n return typeof arg === \"number\" || typeof arg === \"bigint\" || typeof arg === \"string\";\n}\n\n/**\n * Checks if the provided argument is empty, meaning it is either null or undefined.\n *\n * @param arg - The argument to check for emptiness.\n * @returns A boolean indicating whether the argument is empty.\n */\nexport function isEmptyOption(arg: SimpleEntryFunctionArgumentTypes): arg is null | undefined {\n return arg === null || arg === undefined;\n}\n\n/**\n * Determines if the provided argument is a valid encoded entry function argument type.\n * This function helps validate that the argument conforms to the expected types for entry function parameters.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\nexport function isEncodedEntryFunctionArgument(\n arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes,\n): arg is EntryFunctionArgumentTypes {\n return (\n /**\n * Determines if the provided argument is an instance of the Bool class.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsBool(arg) ||\n /**\n * Determines if the provided argument is an instance of U8.\n * This function helps validate the type of the argument passed to ensure it is a U8 type.\n *\n * @param arg - The argument to be checked, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsU8(arg) ||\n /**\n * Determines if the provided argument is an instance of U16.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsU16(arg) ||\n /**\n * Determines if the provided argument is an instance of U32.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n * @returns A boolean indicating whether the argument is a U32 instance.\n */\n isBcsU32(arg) ||\n /**\n * Determine if the provided argument is an instance of U64.\n * This function helps validate that the argument conforms to the expected U64 type.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsU64(arg) ||\n /**\n * Determines if the provided argument is an instance of U128.\n * This function helps validate the type of the argument passed to ensure it is a U128 type.\n *\n * @param arg - The argument to be checked, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsU128(arg) ||\n /**\n * Determines if the provided argument is an instance of U256.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n * @returns A boolean indicating whether the argument is a U256 instance.\n */\n isBcsU256(arg) ||\n /**\n * Determines if the provided argument is an instance of AccountAddress.\n * This function helps validate whether a given input corresponds to a valid BCS address type.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsAddress(arg) ||\n /**\n * Determine if the provided argument is an instance of MoveString.\n *\n * @param arg - The argument to check, which can be of types EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsString(arg) ||\n /**\n * Determine if the provided argument is an instance of FixedBytes.\n * This function helps to validate the type of the argument being passed.\n *\n * @param arg - The argument to check, which can be of type EntryFunctionArgumentTypes or SimpleEntryFunctionArgumentTypes.\n */\n isBcsFixedBytes(arg) ||\n arg instanceof MoveVector ||\n arg instanceof MoveOption\n );\n}\n\nexport function isBcsBool(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is Bool {\n return arg instanceof Bool;\n}\n\nexport function isBcsAddress(\n arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes,\n): arg is AccountAddress {\n return arg instanceof AccountAddress;\n}\n\nexport function isBcsString(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is MoveString {\n return arg instanceof MoveString;\n}\n\nexport function isBcsFixedBytes(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is FixedBytes {\n return arg instanceof FixedBytes;\n}\n\nexport function isBcsU8(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U8 {\n return arg instanceof U8;\n}\n\nexport function isBcsU16(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U16 {\n return arg instanceof U16;\n}\n\nexport function isBcsU32(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U32 {\n return arg instanceof U32;\n}\n\nexport function isBcsU64(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U64 {\n return arg instanceof U64;\n}\n\nexport function isBcsU128(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U128 {\n return arg instanceof U128;\n}\n\nexport function isBcsU256(arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes): arg is U256 {\n return arg instanceof U256;\n}\n\n/**\n * Determines if the provided argument contains script data input by checking for the presence of bytecode.\n *\n * @param arg - The input data to be checked, which can either be a payload with remote ABI or a standard payload.\n * @param arg.bytecode - The bytecode of the script, present if the input is script data.\n * @param arg.function - The function associated with the transaction, which is relevant for standard payloads.\n * @param arg.args - The arguments for the function, applicable in the context of standard payloads.\n */\nexport function isScriptDataInput(\n arg: InputGenerateTransactionPayloadDataWithRemoteABI | InputGenerateTransactionPayloadData,\n): arg is InputScriptData {\n return \"bytecode\" in arg;\n}\n\n/**\n * Throws an error indicating a type mismatch for a specified argument position.\n * This function helps in debugging by providing clear feedback on expected types.\n *\n * @param expectedType - The type that was expected for the argument.\n * @param position - The position of the argument that caused the type mismatch.\n */\nexport function throwTypeMismatch(expectedType: string, position: number) {\n throw new Error(`Type mismatch for argument ${position}, expected '${expectedType}'`);\n}\n\n/**\n * Finds the index of the first non-signer argument in the function ABI parameters.\n *\n * A function is often defined with a `signer` or `&signer` arguments at the start, which are filled in\n * by signatures and not by the caller. This function helps identify the position of the first argument that\n * can be provided by the caller, allowing for easier handling of function parameters.\n *\n * @param functionAbi - The ABI of the function to analyze.\n * @returns The index of the first non-signer argument, or the length of the parameters array if none are found.\n */\nexport function findFirstNonSignerArg(functionAbi: MoveFunction): number {\n const index = functionAbi.params.findIndex((param) => param !== \"signer\" && param !== \"&signer\");\n if (index < 0) {\n return functionAbi.params.length;\n }\n return index;\n}\n\n/**\n * Splits a function identifier into its constituent parts: module address, module name, and function name.\n * This function helps in validating and extracting details from a function identifier string.\n *\n * @param functionArg - The function identifier string in the format \"moduleAddress::moduleName::functionName\".\n * @returns An object containing the module address, module name, and function name.\n * @throws Error if the function identifier does not contain exactly three parts.\n */\nexport function getFunctionParts(functionArg: MoveFunctionId) {\n const funcNameParts = functionArg.split(\"::\");\n if (funcNameParts.length !== 3) {\n throw new Error(`Invalid function ${functionArg}`);\n }\n const moduleAddress = funcNameParts[0];\n const moduleName = funcNameParts[1];\n const functionName = funcNameParts[2];\n return { moduleAddress, moduleName, functionName };\n}\n"],"mappings":"4NAqBO,SAASA,EAAOC,EAAuD,CAC5E,OAAO,OAAOA,GAAQ,SACxB,CAQO,SAASC,EAASD,EAAyB,CAChD,OAAO,OAAOA,GAAQ,QACxB,CAQO,SAASE,EAASF,EAAsD,CAC7E,OAAO,OAAOA,GAAQ,QACxB,CAUO,SAASG,EAAcH,EAA2D,CACvF,GAAIE,EAASF,CAAG,EACd,OAAOA,EAET,GAAIC,EAASD,CAAG,GAAKA,IAAQ,GAC3B,OAAO,OAAO,SAASA,EAAK,EAAE,CAIlC,CAOO,SAASI,EAAcJ,EAAwE,CACpG,OAAO,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,UAAY,OAAOA,GAAQ,QAC9E,CAQO,SAASK,EAAcL,EAAgE,CAC5F,OAAOA,GAAQ,IACjB,CAQO,SAASM,EACdN,EACmC,CACnC,OAMEO,EAAUP,CAAG,GAObQ,EAAQR,CAAG,GAMXS,EAAST,CAAG,GAOZU,EAASV,CAAG,GAOZW,EAASX,CAAG,GAOZY,EAAUZ,CAAG,GAOba,EAAUb,CAAG,GAObc,EAAad,CAAG,GAMhBe,EAAYf,CAAG,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ber","isEmptyOption","isEncodedEntryFunctionArgument","isBcsBool","isBcsU8","isBcsU16","isBcsU32","isBcsU64","isBcsU128","isBcsU256","isBcsAddress","isBcsString","isBcsFixedBytes","MoveVector","MoveOption","Bool","AccountAddress","MoveString","FixedBytes","U8","U16","U32","U64","U128","U256","isScriptDataInput","throwTypeMismatch","expectedType","position","findFirstNonSignerArg","functionAbi","index","param","getFunctionParts","functionArg","funcNameParts","moduleAddress","moduleName","functionName"]}Выполнить команду
Для локальной разработки. Не используйте в интернете!