1import * as _ from 'lodash-es' 8export const testApiConn = async ({apiUrl, gatewayUrl}: {apiUrl: string, gatewayUrl: string}) => { 10 vitalikblog: `bafybeian5iywb7rfkoam2xctdqr7gotavvp5alcsclrdowdyywq5u4b7bu/general/2025/09/21/low_risk_defi.html`, 11 samplepng: `bafybeihkoviema7g3gxyt6la7vd5ho32ictqbilu3wnlo3rs7ewhnp7lly` 13 betLog(_.chain(ipfsSampleH).map((urlPath, key) => { 14 return [key, gatewayUrl + `/${urlPath}`] 15 }).fromPairs().value()) 17 const response = await fetch(`${apiUrl}/api/v0/version`, { 20 const data = await response.json() 24export const getNodeInfo = async (apiHost: string) => { 25 const url = `${apiHost}/api/v0/id` 26 const idResponse = await fetch(url, { method: 'POST' }) 27 const nodeData = await idResponse.json() 30 const nodeFilePath = pathJoin(tmpPath, 'savedNode.json') 38export const setPinFromIpns = async (apiHost: string) => { 39 betLog('Resolving IPNS name:', ipnsPinName) 41 const resolveUrl = `${apiHost}/api/v0/name/resolve?arg=/ipns/${ipnsPinName}` 42 const resolveResponse = await fetch(resolveUrl, { method: 'POST' }) 43 const resolveData = await resolveResponse.json() 45 if (!resolveData.Path) { 46 throw new Error(`Failed to resolve IPNS name: ${JSON.stringify(resolveData)}`) 49 const ipfsHash = resolveData.Path.replace('/ipfs/', '') 50 betLog('Resolved to IPFS hash:', ipfsHash) 52 const pinUrl = `${apiHost}/api/v0/pin/add?arg=${ipfsHash}` 53 const pinResponse = await fetch(pinUrl, { method: 'POST' }) 54 const pinData = await pinResponse.json() 57 return {ipfsHash, pinData}