MCPcopy Create free account
hub / github.com/wevm/viem / constructor

Method constructor

src/errors/contract.ts:101–164  ·  view source on GitHub ↗
(
    cause: BaseError,
    {
      abi,
      args,
      contractAddress,
      docsPath,
      functionName,
      sender,
    }: {
      abi: Abi
      args?: any | undefined
      contractAddress?: Address | undefined
      docsPath?: string | undefined
      functionName: string
      sender?: Address | undefined
    },
  )

Source from the content-addressed store, hash-verified

99 sender?: Address | undefined
100
101 constructor(
102 cause: BaseError,
103 {
104 abi,
105 args,
106 contractAddress,
107 docsPath,
108 functionName,
109 sender,
110 }: {
111 abi: Abi
112 args?: any | undefined
113 contractAddress?: Address | undefined
114 docsPath?: string | undefined
115 functionName: string
116 sender?: Address | undefined
117 },
118 ) {
119 const abiItem = getAbiItem({ abi, args, name: functionName })
120 const formattedArgs = abiItem
121 ? formatAbiItemWithArgs({
122 abiItem,
123 args,
124 includeFunctionName: false,
125 includeName: false,
126 })
127 : undefined
128 const functionWithParams = abiItem
129 ? formatAbiItem(abiItem, { includeName: true })
130 : undefined
131
132 const prettyArgs = prettyPrint({
133 address: contractAddress && getContractAddress(contractAddress),
134 function: functionWithParams,
135 args:
136 formattedArgs &&
137 formattedArgs !== '()' &&
138 `${[...Array(functionName?.length ?? 0).keys()]
139 .map(() => ' ')
140 .join('')}${formattedArgs}`,
141 sender,
142 })
143
144 super(
145 cause.shortMessage ||
146 `An unknown error occurred while executing the contract function "${functionName}".`,
147 {
148 cause,
149 docsPath,
150 metaMessages: [
151 ...(cause.metaMessages ? [...cause.metaMessages, ' '] : []),
152 prettyArgs && 'Contract Call:',
153 prettyArgs,
154 ].filter(Boolean) as string[],
155 name: 'ContractFunctionExecutionError',
156 },
157 )
158 this.abi = abi

Callers

nothing calls this directly

Calls 5

getAbiItemFunction · 0.85
formatAbiItemWithArgsFunction · 0.85
formatAbiItemFunction · 0.85
prettyPrintFunction · 0.85
getContractAddressFunction · 0.70

Tested by

no test coverage detected