( parameters: PrepareEncodeFunctionDataParameters<abi, functionName>, )
| 82 | | ErrorType |
| 83 | |
| 84 | export function prepareEncodeFunctionData< |
| 85 | const abi extends Abi | readonly unknown[], |
| 86 | functionName extends ContractFunctionName<abi> | undefined = undefined, |
| 87 | >( |
| 88 | parameters: PrepareEncodeFunctionDataParameters<abi, functionName>, |
| 89 | ): PrepareEncodeFunctionDataReturnType<abi, functionName> { |
| 90 | const { abi, args, functionName } = |
| 91 | parameters as PrepareEncodeFunctionDataParameters |
| 92 | |
| 93 | let abiItem = abi[0] |
| 94 | if (functionName) { |
| 95 | const item = getAbiItem({ |
| 96 | abi, |
| 97 | args, |
| 98 | name: functionName, |
| 99 | }) |
| 100 | if (!item) throw new AbiFunctionNotFoundError(functionName, { docsPath }) |
| 101 | abiItem = item |
| 102 | } |
| 103 | |
| 104 | if (abiItem.type !== 'function') |
| 105 | throw new AbiFunctionNotFoundError(undefined, { docsPath }) |
| 106 | |
| 107 | return { |
| 108 | abi: [abiItem], |
| 109 | functionName: toFunctionSelector(formatAbiItem(abiItem)), |
| 110 | } as unknown as PrepareEncodeFunctionDataReturnType<abi, functionName> |
| 111 | } |
no test coverage detected