My calls to uploadManifiest in MutationService keep failing with the error: info: Egg upgrade failed with error: TypeError: (0 , ipfs_1.uploadIpfsManifest) is not a function.
I'm not sure what the cause of this is, below my set up of the file causing the issue:
mutation.ts
import { uploadManifest } from '../utils/ipfs';
export class MutationService {
public async eggUpgrade(nftAddress: string) {
try {
const updatedManifest = this.addExchangeAttributes(manifest);
const mediaUri = await this.uploadManifest(updatedManifest);
logger.info(`mediaUri: ${JSON.stringify(mediaUri)}`);
} catch (e) {
logger.info(`Egg upgrade failed with error: ${e}`);
return { success: false, tx_id: null };
}
}
async uploadManifest(manifest: any) {
const manifestBuffer = Buffer.from(JSON.stringify(manifest));
return await uploadManifest(
{
projectId: process.env.IPFS_INFURA_PROJECT_ID as string,
secretKey: process.env.IPFS_INFURA_SECRET as string,
},
manifestBuffer,
);
}
}
ipfs.ts
export async function uploadManifest(
ipfsCredentials: IIpfsCredentials,
manifestBuffer: Buffer,
) {
const tokenIpfs = `${ipfsCredentials.projectId}:${ipfsCredentials.secretKey}`;
const ipfs = create(INFURA_IPFS_URI as Options);
const authIpfs = Buffer.from(tokenIpfs).toString('base64');
const manifestJson = JSON.parse(manifestBuffer.toString('utf8'));
const manifestHash = await uploadToIpfs(
ipfs,
Buffer.from(JSON.stringify(manifestJson)),
);
await fetch(`${INFURA_IPFS_API_URI}/pin/add?arg=${manifestHash}`, {
headers: {
Authorization: `Basic ${authIpfs}`,
},
method: 'POST',
});
await sleep(500);
const link = `https://ipfs.io/ipfs/${manifestHash}`;
logger.debug(`uploaded manifest: ${link}`);
return link;
}