From 9e7bea24310ca96672ff108d6c293842fbea4caf Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Wed, 4 Sep 2024 16:25:24 +0100 Subject: [PATCH] chore: mark ipfs fns as deprecated --- src/api/appDataHexToCid.ts | 12 ++++++++++++ src/api/appDataToCid.ts | 16 ++++++++++++++++ src/api/cidToAppDataHex.ts | 6 ++++++ src/api/fetchDocFromAppData.ts | 4 +++- src/api/fetchDocFromCid.ts | 7 +++++++ src/api/index.ts | 7 ++++--- 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/api/appDataHexToCid.ts b/src/api/appDataHexToCid.ts index 76c9945..ae57a74 100644 --- a/src/api/appDataHexToCid.ts +++ b/src/api/appDataHexToCid.ts @@ -1,5 +1,11 @@ import { MetaDataError } from '../consts' +/** + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * + * @param appDataHex + * @returns + */ export async function appDataHexToCid(appDataHex: string): Promise { const cid = await _appDataHexToCid(appDataHex) _assertCid(cid, appDataHex) @@ -7,6 +13,12 @@ export async function appDataHexToCid(appDataHex: string): Promise { return cid } +/** + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * + * @param appDataHex + * @returns + */ export async function appDataHexToCidLegacy(appDataHex: string): Promise { const cid = await _appDataHexToCidLegacy(appDataHex) _assertCid(cid, appDataHex) diff --git a/src/api/appDataToCid.ts b/src/api/appDataToCid.ts index 3e80d3b..c38e58a 100644 --- a/src/api/appDataToCid.ts +++ b/src/api/appDataToCid.ts @@ -9,6 +9,8 @@ import { validateAppDataDoc } from './validateAppDataDoc' /** * Calculates appDataHex without publishing file to IPFS * + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * * This method is intended to quickly generate the appDataHex independent * of IPFS upload/pinning * @@ -19,6 +21,8 @@ export async function appDataToCid(appData: AnyAppDataDocVersion): Promise +/** + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * + * @param appDataAux + * @returns + */ export async function appDataToCid(appDataAux: AnyAppDataDocVersion | string): Promise { return _appDataToCidAux(appDataAux, _appDataToCid) } @@ -54,6 +64,12 @@ export async function appDataToCidLegacy(appData: AnyAppDataDocVersion): Promise */ export async function appDataToCidLegacy(fullAppData: string): Promise +/** + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * + * @param appDataAux + * @returns + */ export async function appDataToCidLegacy(appDataAux: AnyAppDataDocVersion | string): Promise { // For the legacy-mode we use plain JSON.stringify to mantain backwards compatibility, however this is not a good idea to do since JSON.stringify. Better specify the doc as a fullAppData string or use stringifyDeterministic const fullAppData = JSON.stringify(appDataAux) diff --git a/src/api/cidToAppDataHex.ts b/src/api/cidToAppDataHex.ts index 2202cbc..4e1f0bd 100644 --- a/src/api/cidToAppDataHex.ts +++ b/src/api/cidToAppDataHex.ts @@ -1,5 +1,11 @@ import { extractDigest } from '../utils/ipfs' +/** + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * + * @param cid + * @returns + */ export async function cidToAppDataHex(cid: string): Promise { return extractDigest(cid) } diff --git a/src/api/fetchDocFromAppData.ts b/src/api/fetchDocFromAppData.ts index a5393ce..ed88f57 100644 --- a/src/api/fetchDocFromAppData.ts +++ b/src/api/fetchDocFromAppData.ts @@ -4,6 +4,8 @@ import { appDataHexToCid, appDataHexToCidLegacy } from './appDataHexToCid' import { fetchDocFromCid } from './fetchDocFromCid' /** + * + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes * * @param appDataHex Derives the CID from the appData hex, and fetches and parses the document from IPFS * @param ipfsUri URL of the IPFS gateway to use for the fetch @@ -20,7 +22,7 @@ export async function fetchDocFromAppDataHex( /** * Fetches the document from IPFS using the appData hex * - * @deprecated + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes * * @param appDataHex * @param ipfsUri diff --git a/src/api/fetchDocFromCid.ts b/src/api/fetchDocFromCid.ts index 82311cc..a31281a 100644 --- a/src/api/fetchDocFromCid.ts +++ b/src/api/fetchDocFromCid.ts @@ -1,6 +1,13 @@ import { AnyAppDataDocVersion } from 'generatedTypes' import { DEFAULT_IPFS_READ_URI } from '../consts' +/** + * @deprecated AppData is not longer stored on IPFS nor it's derived from IPFS content hashes + * + * @param cid + * @param ipfsUri + * @returns + */ export async function fetchDocFromCid(cid: string, ipfsUri = DEFAULT_IPFS_READ_URI): Promise { const { default: fetch } = await import('cross-fetch') const response = await fetch(`${ipfsUri}/${cid}`) diff --git a/src/api/index.ts b/src/api/index.ts index 99b0e95..58e05ed 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -15,16 +15,17 @@ export class MetadataApi { generateAppDataDoc = generateAppDataDoc validateAppDataDoc = validateAppDataDoc - // appData / CID conversion + // ---- Deprecated methods ---- + + // appData / CID conversion (deprecated) appDataToCid = appDataToCid // (appData | fullAppData) --> cid appDataHexToCid = appDataHexToCid // appDataHex --> cid cidToAppDataHex = cidToAppDataHex // cid --> appDataHex - // Fetch appData document from IPFS + // Fetch appData document from IPFS (deprecated) fetchDocFromCid = fetchDocFromCid // cid --> document fetchDocFromAppDataHex = fetchDocFromAppDataHex // appDataHex --> appData - // ---- Deprecated methods ---- // Upload to IPFS (deprecated) uploadMetadataDocToIpfsLegacy = uploadMetadataDocToIpfsLegacy // appData --> cid + publish IPFS appDataToCidLegacy = appDataToCidLegacy // (appData | fullAppData) --> cid