Files
FrenoCorp/node_modules/viem/utils/hash/toSignature.ts
Michael Freno 7c684a42cc FRE-600: Fix code review blockers
- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 00:08:01 -04:00

35 lines
932 B
TypeScript

import { type AbiEvent, type AbiFunction, formatAbiItem } from 'abitype'
import type { ErrorType } from '../../errors/utils.js'
import {
type NormalizeSignatureErrorType,
normalizeSignature,
} from './normalizeSignature.js'
export type ToSignatureErrorType = NormalizeSignatureErrorType | ErrorType
/**
* Returns the signature for a given function or event definition.
*
* @example
* const signature = toSignature('function ownerOf(uint256 tokenId)')
* // 'ownerOf(uint256)'
*
* @example
* const signature_3 = toSignature({
* name: 'ownerOf',
* type: 'function',
* inputs: [{ name: 'tokenId', type: 'uint256' }],
* outputs: [],
* stateMutability: 'view',
* })
* // 'ownerOf(uint256)'
*/
export const toSignature = (def: string | AbiFunction | AbiEvent) => {
const def_ = (() => {
if (typeof def === 'string') return def
return formatAbiItem(def)
})()
return normalizeSignature(def_)
}