Retrofit new 4bytes fetcher function into legacy use4Bytes
This commit is contained in:
parent
cbab64cd99
commit
379c695083
|
@ -110,34 +110,12 @@ export const use4Bytes = (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const signatureURL = fourBytesURL(assetsURLPrefix, fourBytes);
|
const loadSig = async () => {
|
||||||
fetch(signatureURL)
|
const entry = await fetch4Bytes(assetsURLPrefix, fourBytes);
|
||||||
.then(async (res) => {
|
fullCache.set(fourBytes, entry);
|
||||||
if (!res.ok) {
|
setEntry(entry);
|
||||||
console.error(`Signature does not exist in 4bytes DB: ${fourBytes}`);
|
};
|
||||||
fullCache.set(fourBytes, null);
|
loadSig();
|
||||||
setEntry(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get only the first occurrence, for now ignore alternative param names
|
|
||||||
const sigs = await res.text();
|
|
||||||
const sig = sigs.split(";")[0];
|
|
||||||
const cut = sig.indexOf("(");
|
|
||||||
const method = sig.slice(0, cut);
|
|
||||||
|
|
||||||
const entry: FourBytesEntry = {
|
|
||||||
name: method,
|
|
||||||
signature: sig,
|
|
||||||
};
|
|
||||||
setEntry(entry);
|
|
||||||
fullCache.set(fourBytes, entry);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(`Couldn't fetch signature URL ${signatureURL}`, err);
|
|
||||||
setEntry(null);
|
|
||||||
fullCache.set(fourBytes, null);
|
|
||||||
});
|
|
||||||
}, [fourBytes, assetsURLPrefix]);
|
}, [fourBytes, assetsURLPrefix]);
|
||||||
|
|
||||||
if (rawFourBytes === "0x") {
|
if (rawFourBytes === "0x") {
|
||||||
|
|
Loading…
Reference in New Issue