@iexec/iexec-oracle-factory-wrapper
Version:
A wrapper for creating API based oracles for ethereum on the top of iExec
15 lines • 574 B
JavaScript
import { Buffer } from 'buffer';
import fetch from 'cross-fetch';
import { DEFAULT_IPFS_GATEWAY } from '../../config/config.js';
const get = async (cid, { ipfsGateway = DEFAULT_IPFS_GATEWAY } = {}) => {
const multiaddr = `/ipfs/${cid.toString()}`;
const publicUrl = `${ipfsGateway}${multiaddr}`;
const res = await fetch(publicUrl);
if (!res.ok) {
throw Error(`Failed to load content from ${publicUrl}`);
}
const arrayBuffer = await res.arrayBuffer();
return Buffer.from(arrayBuffer);
};
export default get;
//# sourceMappingURL=get.js.map