Skip to content

Commit

Permalink
🎨 Rename AR functions
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Nov 4, 2021
1 parent d35dc11 commit cf7c78c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/util/arweave.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jwk = require('../../config/arweave-key.json');

const arweave = Arweave.init({ host: 'arweave.net', port: 443, protocol: 'https' });

export async function getArIdFromHashes(ipfsHash) {
export async function getArweaveIdFromHashes(ipfsHash) {
const res = await arweave.arql(
{
op: 'and',
Expand Down Expand Up @@ -77,7 +77,7 @@ function generateManifestFile(files, { stub = false } = {}) {
export async function estimateARPrice(data) {
const { buffer, key } = data;
const ipfsHash = await getFileIPFSHash(data);
const id = await getArIdFromHashes(ipfsHash);
const id = await getArweaveIdFromHashes(ipfsHash);
if (id) {
return {
key,
Expand Down Expand Up @@ -168,7 +168,7 @@ export async function submitToArweave(data, ipfsHash) {

export async function uploadFileToArweave(data) {
const ipfsHash = await getFileIPFSHash(data);
const id = await getArIdFromHashes(ipfsHash);
const id = await getArweaveIdFromHashes(ipfsHash);
if (id) {
return {
arweaveId: id,
Expand All @@ -190,7 +190,7 @@ export async function uploadFileToArweave(data) {
async function uploadManifestFile(filesWithId) {
const manifest = generateManifestFile(filesWithId);
const manifestIPFSHash = await getFileIPFSHash(manifest);
let arweaveId = await getArIdFromHashes(manifestIPFSHash);
let arweaveId = await getArweaveIdFromHashes(manifestIPFSHash);
if (!arweaveId) {
[arweaveId] = await Promise.all([
submitToArweave(manifest, manifestIPFSHash),
Expand All @@ -213,7 +213,7 @@ export async function uploadFilesToArweave(files) {
getFolderIPFSHash(files),
Promise.all(files.map(f => getFileIPFSHash(f))),
]);
const arweaveIds = await Promise.all(ipfsHashes.map(h => getArIdFromHashes(h)));
const arweaveIds = await Promise.all(ipfsHashes.map(h => getArweaveIdFromHashes(h)));
if (!arweaveIds.some(id => !id)) {
const filesWithId = files.map((f, i) => ({ ...f, arweaveId: arweaveIds[i] }));
const { manifest, ipfsHash: manifestIPFSHash } = await uploadManifestFile(filesWithId);
Expand Down

0 comments on commit cf7c78c

Please sign in to comment.