Skip to content

Commit

Permalink
perf: query TX meta from web3infura.dev gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
charmful0x authored Mar 23, 2023
1 parent 2b36f4d commit 2b96d6c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/molecules/ar/atoms/mime.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getArTxObject } from "./tx-gql.js";
import axios from "axios";

export async function getTxsMimeType(txs) {
try {
Expand All @@ -7,11 +7,10 @@ export async function getTxsMimeType(txs) {
for (const tx of txsArray) {
res[tx] = {};

const metadata = await getArTxObject(tx);
const metadata = await getArseedTxMeta(tx);
res[tx].mime = metadata?.tags.find(
(tag) => tag.name.toLowerCase() === "content-type"
)?.value;
res[tx]["size"] = metadata?.data?.size;
}

return res;
Expand All @@ -20,3 +19,15 @@ export async function getTxsMimeType(txs) {
return {};
}
}

async function getArseedTxMeta(txid) {
try {
const metadata = (
await axios.get(`https://arseed.web3infra.dev/bundle/tx/${txid}`)
)?.data;
return metadata;
} catch (error) {
console.log(error);
return {};
}
}

0 comments on commit 2b96d6c

Please sign in to comment.