@lighthouse-web3/sdk
Version:
NPM package and CLI tool to interact with lighthouse protocol
36 lines (35 loc) • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lighthouse_config_1 = require("../../lighthouse.config");
exports.default = async (apiKey) => {
try {
const response = await fetch(lighthouse_config_1.lighthouseConfig.lighthouseAPI + `/api/ipns/get_ipns_records`, {
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
});
if (!response.ok) {
throw new Error(`Request failed with status code ${response.status}`);
}
const data = (await response.json());
/*
return:
{
data: [
{
"ipnsName": "6cda213e3a534f8388665dee77a26458",
"ipnsId": "k51qzi5uqu5dm6uvby6428rfpcv1vcba6hxq6vcu52qtfsx3np4536jkr71gnu",
"publicKey": "0xc88c729ef2c18baf1074ea0df537d61a54a8ce7b",
"cid": "Qmd5MBBScDUV3Ly8qahXtZFqyRRfYSmUwEcxpYcV4hzKfW",
"lastUpdate": 1684855771773
}
]
}
*/
return { data: data };
}
catch (error) {
throw new Error(error.message);
}
};