UNPKG

@lighthouse-web3/sdk

Version:

NPM package and CLI tool to interact with lighthouse protocol

23 lines (22 loc) 811 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lighthouse_config_1 = require("../../lighthouse.config"); exports.default = async (cid) => { try { const response = await fetch(lighthouse_config_1.defaultConfig.lighthouseAPI + `/api/lighthouse/get_proof?cid=${cid}`); if (!response.ok) { if (response.status === 400) { throw new Error("Proof Doesn't exist yet"); } throw new Error(`Request failed with status code ${response.status}`); } const data = (await response.json()); return { data }; } catch (error) { if (error?.response?.status === 400) { throw new Error("Proof Doesn't exist yet"); } throw new Error(error.message); } };