PageSourceSearch

https://blockhead.info/_app/immutable/chunks/encodeFunctionData.C3yK8hut.js

js blockhead.info collected 2026-10-04 12:41:38 UTC 4,206 bytes, 1 lines download raw bytes

1import{X as A,W as v,B as w,ag as S,V as T,ab as a,c0 as F}from"./preferences.C7NlrpXN.js";import{l as k,g as d,m as E,e as N}from"./encodeAbiParameters.DXBuOtCW.js";function M(t,e){const s=t.exec(e);return s==null?void 0:s.groups}const _=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,q=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,C=/^\(.+?\).*?$/,g=/^tuple(?<array>(\[(\d*)\])*)$/;function l(t){let e=t.type;if(g.test(t.type)&&"components"in t){e="(";const s=t.components.length;for(let r=0;r<s;r++){const o=t.components[r];e+=l(o),r<s-1&&(e+=", ")}const n=M(g,t.type);return e+=`)${(n==null?void 0:n.array)??""}`,l({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function f(t){let e="";const s=t.length;for(let n=0;n<s;n++){const r=t[n];e+=l(r),n!==s-1&&(e+=", ")}return e}function R(t){return t.type==="function"?`function ${t.name}(${f(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs.length?` returns (${f(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${f(t.inputs)})`:t.type==="error"?`error ${t.name}(${f(t.inputs)})`:t.type==="constructor"?`constructor(${f(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?"fallback()":"receive() external payable"}const z=t=>A(v(t));function B(t){return z(t)}function D(t){let e=!0,s="",n=0,r="",o=!1;for(let u=0;u<t.length;u++){const i=t[u];if(["(",")",","].includes(i)&&(e=!0),i==="("&&n++,i===")"&&n--,!!e){if(n===0){if(i===" "&&["event","function",""].includes(r))r="";else if(r+=i,i===")"){o=!0;break}continue}if(i===" "){t[u-1]!==","&&s!==","&&s!==",("&&(s="",e=!1);continue}r+=i,s+=i}}if(!o)throw new w("Unable to normalize signature.");return r}const H=t=>{const e=typeof t=="string"?t:R(t);return D(e)};function $(t){return B(H(t))}const O=$,m=t=>S($(t),0,4);function j(t){const{abi:e,args:s=[],name:n}=t,r=T(n,{strict:!1}),o=e.filter(i=>r?i.type==="function"?m(i)===n:i.type==="event"?O(i)===n:!1:"name"in i&&i.name===n);if(o.length===0)return;if(o.length===1)return o[0];let u;for(const i of o){if(!("inputs"in i))continue;if(!s||s.length===0){if(!i.inputs||i.inputs.length===0)return i;continue}if(!i.inputs||i.inputs.length===0||i.inputs.length!==s.length)continue;if(s.every((c,x)=>{const y="inputs"in i&&i.inputs[x];return y?p(c,y):!1})){if(u&&"inputs"in u&&u.inputs){const c=b(i.inputs,u.inputs,s);if(c)throw new k({abiItem:i,type:c[0]},{abiItem:u,type:c[1]})}u=i}}return u||o[0]}function p(t,e){const s=typeof t,n=e.type;switch(n){case"address":return a(t,{strict:!1});case"bool":return s==="boolean";case"function":return s==="string";case"string":return s==="string";default:return n==="tuple"&&"components"in e?Object.values(e.components).every((r,o)=>p(Object.values(t)[o],r)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(n)?s==="number"||s==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n)?s==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n)?Array.isArray(t)&&t.every(r=>p(r,{...e,type:n.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function b(t,e,s){for(const n in t){const r=t[n],o=e[n];if(r.type==="tuple"&&o.type==="tuple"&&"components"in r&&"components"in o)return b(r.components,o.components,s[n]);const u=[r.type,o.type];if(u.includes("address")&&u.includes("bytes20")?!0:u.includes("address")&&u.includes("string")?a(s[n],{strict:!1}):u.includes("address")&&u.includes("bytes")?a(s[n],{strict:!1}):!1)return u}}const h="/docs/contract/encodeFunctionData";function U(t){const{abi:e,args:s,functionName:n}=t;let r=e[0];if(n){const o=j({abi:e,args:s,name:n});if(!o)throw new d(n,{docsPath:h});r=o}if(r.type!=="function")throw new d(void 0,{docsPath:h});return{abi:[r],functionName:m(E(r))}}function G(t){const{args:e}=t,{abi:s,functionName:n}=(()=>{var i;return t.abi.length===1&&((i=t.functionName)!=null&&i.startsWith("0x"))?t:U(t)})(),r=s[0],o=n,u="inputs"in r&&r.inputs?N(r.inputs,e??[]):void 0;return F([o,u??"0x"])}export{M as a,_ as b,C as c,m as d,G as e,H as f,j as g,$ as h,q as i,U as p,O as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.