From 35c0a88fecd1f26f71dc81fc21fb6a9d8dd3bb92 Mon Sep 17 00:00:00 2001 From: Derek Sonnenberg Date: Mon, 3 Jun 2024 10:24:43 -0500 Subject: [PATCH 1/2] feat(gql): utilize drive ID in conflict resolution and list folder queries PE-6232 --- src/ardrive.ts | 75 +++++++++++++++++++++++++---------- src/arfs/arfs_entities.ts | 4 +- src/arfs/arfsdao.ts | 44 +++++++++++++++----- src/arfs/arfsdao_anonymous.ts | 11 ++++- 4 files changed, 98 insertions(+), 36 deletions(-) diff --git a/src/ardrive.ts b/src/ardrive.ts index 15a99608..05f77a54 100644 --- a/src/ardrive.ts +++ b/src/ardrive.ts @@ -191,7 +191,11 @@ export class ArDrive extends ArDriveAnonymous { } // Assert that there are no duplicate names in the destination folder - const entityNamesInParentFolder = await this.arFsDao.getPublicEntityNamesInFolder(newParentFolderId, owner); + const entityNamesInParentFolder = await this.arFsDao.getPublicEntityNamesInFolder( + newParentFolderId, + owner, + destFolderDriveId + ); if (entityNamesInParentFolder.includes(originalFileMetaData.name)) { // TODO: Add optional interactive prompt to resolve name conflicts in ticket PE-599 throw new Error(errorMessage.entityNameExists); @@ -269,7 +273,8 @@ export class ArDrive extends ArDriveAnonymous { const entityNamesInParentFolder = await this.arFsDao.getPrivateEntityNamesInFolder( newParentFolderId, owner, - driveKey + driveKey, + destFolderDriveId ); if (entityNamesInParentFolder.includes(originalFileMetaData.name)) { // TODO: Add optional interactive prompt to resolve name conflicts in ticket PE-599 @@ -353,7 +358,11 @@ export class ArDrive extends ArDriveAnonymous { } // Assert that there are no duplicate names in the destination folder - const entityNamesInParentFolder = await this.arFsDao.getPublicEntityNamesInFolder(newParentFolderId, owner); + const entityNamesInParentFolder = await this.arFsDao.getPublicEntityNamesInFolder( + newParentFolderId, + owner, + destFolderDriveId + ); if (entityNamesInParentFolder.includes(originalFolderMetaData.name)) { // TODO: Add optional interactive prompt to resolve name conflicts in ticket PE-599 throw new Error(errorMessage.entityNameExists); @@ -439,7 +448,8 @@ export class ArDrive extends ArDriveAnonymous { const entityNamesInParentFolder = await this.arFsDao.getPrivateEntityNamesInFolder( newParentFolderId, owner, - driveKey + driveKey, + destFolderDriveId ); if (entityNamesInParentFolder.includes(originalFolderMetaData.name)) { // TODO: Add optional interactive prompt to resolve name conflicts in ticket PE-599 @@ -523,14 +533,14 @@ export class ArDrive extends ArDriveAnonymous { const resolvedEntitiesToUpload: UploadStats[] = []; for (const entity of entitiesToUpload) { - const { destFolderId, wrappedEntity, driveKey, owner, destName } = entity; + const { destFolderId, wrappedEntity, driveKey, owner, destName, destDriveId } = entity; const resolveConflictParams = { conflictResolution, getConflictInfoFn: (folderId: FolderID) => driveKey - ? this.arFsDao.getPrivateNameConflictInfoInFolder(folderId, owner, driveKey) - : this.arFsDao.getPublicNameConflictInfoInFolder(folderId, owner), + ? this.arFsDao.getPrivateNameConflictInfoInFolder(folderId, owner, driveKey, destDriveId) + : this.arFsDao.getPublicNameConflictInfoInFolder(folderId, owner, destDriveId), prompts, destFolderId }; @@ -729,6 +739,7 @@ export class ArDrive extends ArDriveAnonymous { destinationFolderId }: RetryPublicArFSFileByDestFolderIdParams): Promise { const metaDataTx = await this.deriveMetaDataTxFromPublicFolder(destinationFolderId, dataTxId); + const driveId = await this.arFsDao.getDriveIdForFolderId(destinationFolderId); let metaDataTxId: undefined | TransactionID = undefined; let createMetaDataPlan: undefined | ArFSCreateFileMetaDataV2Plan = undefined; @@ -743,7 +754,8 @@ export class ArDrive extends ArDriveAnonymous { const isValidUpload = await this.assertWriteFileMetaData({ wrappedFile, conflictResolution, - destinationFolderId + destinationFolderId, + driveId }); if (!isValidUpload) { @@ -827,11 +839,13 @@ export class ArDrive extends ArDriveAnonymous { dataTxId: TransactionID ): Promise { const owner = await this.wallet.getAddress(); + const driveId = await this.arFsDao.getDriveIdForFolderId(destinationFolderId); await this.assertFolderExists(destinationFolderId, owner); const allFileMetaDataTxInFolder = await this.arFsDao.getPublicFilesWithParentFolderIds( [destinationFolderId], - owner + owner, + driveId ); const metaDataTxsForThisTx = allFileMetaDataTxInFolder.filter((f) => `${f.dataTxId}` === `${dataTxId}`); @@ -853,11 +867,13 @@ export class ArDrive extends ArDriveAnonymous { private async assertWriteFileMetaData({ wrappedFile, destinationFolderId, - conflictResolution + conflictResolution, + driveId }: { wrappedFile: ArFSFileToUpload; destinationFolderId: FolderID; conflictResolution: FileNameConflictResolution; + driveId: DriveID; }): Promise { const owner = await this.wallet.getAddress(); await resolveFileNameConflicts({ @@ -865,7 +881,8 @@ export class ArDrive extends ArDriveAnonymous { conflictResolution, destFolderId: destinationFolderId, destinationFileName: wrappedFile.destinationBaseName, - getConflictInfoFn: (folderId: FolderID) => this.arFsDao.getPublicNameConflictInfoInFolder(folderId, owner) + getConflictInfoFn: (folderId: FolderID) => + this.arFsDao.getPublicNameConflictInfoInFolder(folderId, owner, driveId) }); if (wrappedFile.conflictResolution) { @@ -1019,7 +1036,11 @@ export class ArDrive extends ArDriveAnonymous { const owner = await this.wallet.getAddress(); // Assert that there are no duplicate names in the destination folder - const entityNamesInParentFolder = await this.arFsDao.getPublicEntityNamesInFolder(parentFolderId, owner); + const entityNamesInParentFolder = await this.arFsDao.getPublicEntityNamesInFolder( + parentFolderId, + owner, + driveId + ); if (entityNamesInParentFolder.includes(folderName)) { // TODO: Add optional interactive prompt to resolve name conflicts in ticket PE-599 throw new Error(errorMessage.entityNameExists); @@ -1083,7 +1104,8 @@ export class ArDrive extends ArDriveAnonymous { const entityNamesInParentFolder = await this.arFsDao.getPrivateEntityNamesInFolder( parentFolderId, owner, - driveKey + driveKey, + driveId ); if (entityNamesInParentFolder.includes(folderName)) { // TODO: Add optional interactive prompt to resolve name conflicts in ticket PE-599 @@ -1438,10 +1460,11 @@ export class ArDrive extends ArDriveAnonymous { await fileToDownload.write(); } - async assertUniqueNameWithinPublicFolder(name: string, folderId: FolderID): Promise { + async assertUniqueNameWithinPublicFolder(name: string, folderId: FolderID, driveId: DriveID): Promise { const allSiblingNames = await this.arFsDao.getPublicEntityNamesInFolder( folderId, - await this.wallet.getAddress() + await this.wallet.getAddress(), + driveId ); const collidesWithExistingSiblingName = allSiblingNames.reduce((accumulator, siblingName) => { return accumulator || siblingName === name; @@ -1451,11 +1474,17 @@ export class ArDrive extends ArDriveAnonymous { } } - async assertUniqueNameWithinPrivateFolder(name: string, folderId: FolderID, driveKey: DriveKey): Promise { + async assertUniqueNameWithinPrivateFolder( + name: string, + folderId: FolderID, + driveKey: DriveKey, + driveId: DriveID + ): Promise { const allSiblingNames = await this.arFsDao.getPrivateEntityNamesInFolder( folderId, await this.wallet.getAddress(), - driveKey + driveKey, + driveId ); const collidesWithExistingSiblingName = allSiblingNames.reduce((accumulator, siblingName) => { return accumulator || siblingName === name; @@ -1467,13 +1496,14 @@ export class ArDrive extends ArDriveAnonymous { async renamePublicFile({ fileId, newName }: RenamePublicFileParams): Promise { const owner = await this.wallet.getAddress(); + const driveId = await this.getDriveIdForFileId(fileId); const file = await this.getPublicFile({ fileId, owner }); if (file.name === newName) { throw new Error(`To rename a file, the new name must be different`); } assertValidArFSFileName(newName); - await this.assertUniqueNameWithinPublicFolder(newName, file.parentFolderId); + await this.assertUniqueNameWithinPublicFolder(newName, file.parentFolderId, driveId); const fileMetadataTxDataStub = new ArFSPublicFileMetadataTransactionData( newName, file.size, @@ -1527,11 +1557,12 @@ export class ArDrive extends ArDriveAnonymous { async renamePrivateFile({ fileId, newName, driveKey }: RenamePrivateFileParams): Promise { const owner = await this.wallet.getAddress(); const file = await this.getPrivateFile({ fileId, driveKey, owner }); + const driveId = await this.getDriveIdForFileId(fileId); if (file.name === newName) { throw new Error(`To rename a file, the new name must be different`); } assertValidArFSFileName(newName); - await this.assertUniqueNameWithinPrivateFolder(newName, file.parentFolderId, driveKey); + await this.assertUniqueNameWithinPrivateFolder(newName, file.parentFolderId, driveKey, driveId); const fileMetadataTxDataStub = await ArFSPrivateFileMetadataTransactionData.from( newName, file.size, @@ -1590,6 +1621,7 @@ export class ArDrive extends ArDriveAnonymous { async renamePublicFolder({ folderId, newName }: RenamePublicFolderParams): Promise { const owner = await this.wallet.getAddress(); const folder = await this.getPublicFolder({ folderId, owner }); + const driveId = await this.getDriveIdForFolderId(folderId); if (`${folder.parentFolderId}` === ROOT_FOLDER_ID_PLACEHOLDER) { throw new Error( `The root folder with ID '${folderId}' cannot be renamed as it shares its name with its parent drive. Consider renaming the drive instead.` @@ -1599,7 +1631,7 @@ export class ArDrive extends ArDriveAnonymous { throw new Error(`New folder name '${newName}' must be different from the current folder name!`); } assertValidArFSFolderName(newName); - await this.assertUniqueNameWithinPublicFolder(newName, folder.parentFolderId); + await this.assertUniqueNameWithinPublicFolder(newName, folder.parentFolderId, driveId); const folderMetadataTxDataStub = new ArFSPublicFolderTransactionData(newName, folder.customMetaDataJson); const metadataRewardSettings = this.uploadPlanner.isTurboUpload() @@ -1647,6 +1679,7 @@ export class ArDrive extends ArDriveAnonymous { async renamePrivateFolder({ folderId, newName, driveKey }: RenamePrivateFolderParams): Promise { const owner = await this.wallet.getAddress(); const folder = await this.getPrivateFolder({ folderId, driveKey, owner }); + const driveId = await this.getDriveIdForFolderId(folderId); if (`${folder.parentFolderId}` === ROOT_FOLDER_ID_PLACEHOLDER) { throw new Error( `The root folder with ID '${folderId}' cannot be renamed as it shares its name with its parent drive. Consider renaming the drive instead.` @@ -1656,7 +1689,7 @@ export class ArDrive extends ArDriveAnonymous { throw new Error(`New folder name '${newName}' must be different from the current folder name!`); } assertValidArFSFolderName(newName); - await this.assertUniqueNameWithinPrivateFolder(newName, folder.parentFolderId, driveKey); + await this.assertUniqueNameWithinPrivateFolder(newName, folder.parentFolderId, driveKey, driveId); const folderMetadataTxDataStub = await ArFSPrivateFolderTransactionData.from( newName, driveKey, diff --git a/src/arfs/arfs_entities.ts b/src/arfs/arfs_entities.ts index b6721332..b9f0e7f0 100644 --- a/src/arfs/arfs_entities.ts +++ b/src/arfs/arfs_entities.ts @@ -34,8 +34,8 @@ export class ArFSEntity { readonly contentType: ContentType; // the mime type of the file uploaded. in the case of drives and folders, it is always a JSON file. Public drive/folders must use "application/json" and private drives use "application/octet-stream" since this data is encrypted. readonly driveId: DriveID; // the unique drive identifier, created with uuidv4 https://www.npmjs.com/package/uuidv4 eg. 41800747-a852-4dc9-9078-6c20f85c0f3a readonly entityType: EntityType; // the type of ArFS entity this is. this can only be set to "drive", "folder", "file" - readonly name: string; // user defined entity name, cannot be longer than 64 characters. This is stored in the JSON file that is uploaded along with the drive/folder/file metadata transaction - readonly txId: TransactionID; // the arweave transaction id for this entity. 43 numbers/letters eg. 1xRhN90Mu5mEgyyrmnzKgZP0y3aK8AwSucwlCOAwsaI + readonly name: string; // user defined entity name, cannot be longer than 64 characters. This is stored in the JSON file that is uploaded along with the drive/folder/file metadata transaction cspell:disable + readonly txId: TransactionID; // the arweave transaction id for this entity. 43 numbers/letters eg. 1xRhN90Mu5mEgyyrmnzKgZP0y3aK8AwSucwlCOAwsaI cspell:enable readonly unixTime: UnixTime; // seconds since unix epoch, taken at the time of upload, 10 numbers eg. 1620068042 readonly boost?: FeeMultiple; diff --git a/src/arfs/arfsdao.ts b/src/arfs/arfsdao.ts index b3685020..ab49dcf7 100644 --- a/src/arfs/arfsdao.ts +++ b/src/arfs/arfsdao.ts @@ -1546,6 +1546,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { folderIDs: FolderID[], driveKey: DriveKey, owner: ArweaveAddress, + driveId: DriveID, latestRevisionsOnly = false ): Promise { let cursor = ''; @@ -1555,6 +1556,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { while (hasNextPage) { const gqlQuery = buildQuery({ tags: [ + { name: 'Drive-Id', value: `${driveId}` }, { name: 'Parent-Folder-Id', value: folderIDs.map((fid) => fid.toString()) }, { name: 'Entity-Type', value: 'file' } ], @@ -1593,6 +1595,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { ) => | ArFSFileOrFolderBuilder<'file', ArFSFileOrFolderEntity<'file'>> | ArFSFileOrFolderBuilder<'folder', ArFSFileOrFolderEntity<'folder'>>, + driveId: DriveID, latestRevisionsOnly = true, filterOnOwner = true ): Promise { @@ -1603,6 +1606,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { while (hasNextPage) { const gqlQuery = buildQuery({ tags: [ + { name: 'Drive-Id', value: `${driveId}` }, { name: 'Parent-Folder-Id', value: `${parentFolderId}` }, { name: 'Entity-Type', value: ['file', 'folder'] } ], @@ -1638,6 +1642,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { parentFolderId: FolderID, owner: ArweaveAddress, driveKey: DriveKey, + driveId: DriveID, latestRevisionsOnly = true ): Promise<(ArFSPrivateFile | ArFSPrivateFolder)[]> { return this.getEntitiesInFolder( @@ -1647,6 +1652,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { entityType === 'folder' ? ArFSPrivateFolderBuilder.fromArweaveNode(node, this.gatewayApi, driveKey) : ArFSPrivateFileBuilder.fromArweaveNode(node, this.gatewayApi, driveKey), + driveId, latestRevisionsOnly ); } @@ -1654,6 +1660,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { async getPublicEntitiesInFolder( parentFolderId: FolderID, owner: ArweaveAddress, + driveId: DriveID, latestRevisionsOnly = true ): Promise<(ArFSPublicFile | ArFSPublicFolder)[]> { return this.getEntitiesInFolder( @@ -1663,6 +1670,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { entityType === 'folder' ? ArFSPublicFolderBuilder.fromArweaveNode(node, this.gatewayApi) : ArFSPublicFileBuilder.fromArweaveNode(node, this.gatewayApi), + driveId, latestRevisionsOnly ); } @@ -1678,18 +1686,23 @@ export class ArFSDAO extends ArFSDAOAnonymous { async getPrivateEntityNamesInFolder( folderId: FolderID, owner: ArweaveAddress, - driveKey: DriveKey + driveKey: DriveKey, + driveId: DriveID ): Promise { - const childrenOfFolder = await this.getPrivateEntitiesInFolder(folderId, owner, driveKey, true); + const childrenOfFolder = await this.getPrivateEntitiesInFolder(folderId, owner, driveKey, driveId, true); return childrenOfFolder.map(entityToNameMap); } - async getPublicEntityNamesInFolder(folderId: FolderID, owner: ArweaveAddress): Promise { - const childrenOfFolder = await this.getPublicEntitiesInFolder(folderId, owner, true); + async getPublicEntityNamesInFolder(folderId: FolderID, owner: ArweaveAddress, driveId: DriveID): Promise { + const childrenOfFolder = await this.getPublicEntitiesInFolder(folderId, owner, driveId, true); return childrenOfFolder.map(entityToNameMap); } - async getPublicNameConflictInfoInFolder(folderId: FolderID, owner: ArweaveAddress): Promise { + async getPublicNameConflictInfoInFolder( + folderId: FolderID, + owner: ArweaveAddress, + driveId: DriveID + ): Promise { const cacheKey = { folderId, owner }; const cachedConflictInfo = this.caches.publicConflictCache.get(cacheKey); if (cachedConflictInfo) { @@ -1699,7 +1712,7 @@ export class ArFSDAO extends ArFSDAOAnonymous { return this.caches.publicConflictCache.put( cacheKey, (async () => { - const childrenOfFolder = await this.getPublicEntitiesInFolder(folderId, owner, true); + const childrenOfFolder = await this.getPublicEntitiesInFolder(folderId, owner, driveId, true); return { files: childrenOfFolder.filter(fileFilter).map(fileConflictInfoMap), folders: childrenOfFolder.filter(folderFilter).map(folderToNameAndIdMap) @@ -1711,7 +1724,8 @@ export class ArFSDAO extends ArFSDAOAnonymous { async getPrivateNameConflictInfoInFolder( folderId: FolderID, owner: ArweaveAddress, - driveKey: DriveKey + driveKey: DriveKey, + driveId: DriveID ): Promise { const cacheKey = { folderId, owner, driveKey }; const cachedConflictInfo = this.caches.privateConflictCache.get(cacheKey); @@ -1722,7 +1736,13 @@ export class ArFSDAO extends ArFSDAOAnonymous { return this.caches.privateConflictCache.put( cacheKey, (async () => { - const childrenOfFolder = await this.getPrivateEntitiesInFolder(folderId, owner, driveKey, true); + const childrenOfFolder = await this.getPrivateEntitiesInFolder( + folderId, + owner, + driveKey, + driveId, + true + ); // Hack to deal with potential typescript bug const files = childrenOfFolder.filter(fileFilter) as ArFSPrivateFile[]; const folders = childrenOfFolder.filter(folderFilter) as ArFSPrivateFolder[]; @@ -2282,9 +2302,11 @@ export class ArFSDAO extends ArFSDAOAnonymous { // Fetch all file entities within all Folders of the drive const childFiles: ArFSPrivateFile[] = []; for (const id of searchFolderIDs) { - (await this.getPrivateFilesWithParentFolderIds([id], driveKey, owner, true)).forEach((e) => { - childFiles.push(e); - }); + (await this.getPrivateFilesWithParentFolderIds([id], driveKey, owner, driveIdOfFolder, true)).forEach( + (e) => { + childFiles.push(e); + } + ); } const [, ...subFolderIDs]: FolderID[] = hierarchy.folderIdSubtreeFromFolderId(folder.entityId, maxDepth + 1); diff --git a/src/arfs/arfsdao_anonymous.ts b/src/arfs/arfsdao_anonymous.ts index 3f137454..8e811d53 100644 --- a/src/arfs/arfsdao_anonymous.ts +++ b/src/arfs/arfsdao_anonymous.ts @@ -246,6 +246,7 @@ export class ArFSDAOAnonymous extends ArFSDAOType { async getPublicFilesWithParentFolderIds( folderIDs: FolderID[], owner: ArweaveAddress, + driveId: DriveID, latestRevisionsOnly = false ): Promise { let cursor = ''; @@ -255,6 +256,7 @@ export class ArFSDAOAnonymous extends ArFSDAOType { while (hasNextPage) { const gqlQuery = buildQuery({ tags: [ + { name: 'Drive-Id', value: `${driveId}` }, { name: 'Parent-Folder-Id', value: folderIDs.map((fid) => fid.toString()) }, { name: 'Entity-Type', value: 'file' } ], @@ -359,7 +361,7 @@ export class ArFSDAOAnonymous extends ArFSDAOType { const childrenFileEntities: ArFSPublicFile[] = []; for (const id of searchFolderIDs) { - (await this.getPublicFilesWithParentFolderIds([id], owner, true)).forEach((e) => { + (await this.getPublicFilesWithParentFolderIds([id], owner, driveIdOfFolder, true)).forEach((e) => { childrenFileEntities.push(e); }); } @@ -420,7 +422,12 @@ export class ArFSDAOAnonymous extends ArFSDAOType { ); // Fetch all file entities within all Folders of the drive - const childrenFileEntities = await this.getPublicFilesWithParentFolderIds(searchFolderIDs, owner, true); + const childrenFileEntities = await this.getPublicFilesWithParentFolderIds( + searchFolderIDs, + owner, + driveIdOfFolder, + true + ); const folderWrapper = new ArFSFolderToDownload( publicEntityWithPathsFactory(publicFolder, hierarchy), customFolderName From 7a50cfb1e98672a5a8b3b0a197a3cab2a22d65c8 Mon Sep 17 00:00:00 2001 From: Derek Sonnenberg Date: Mon, 3 Jun 2024 14:14:09 -0500 Subject: [PATCH 2/2] fix(gql): use owner in builder created queries PE-6232 --- src/arfs/arfs_builders/arfs_builders.ts | 4 ++-- src/arfs/arfs_builders/arfs_drive_builders.ts | 14 +++++++------- src/arfs/arfs_builders/arfs_file_builders.ts | 8 ++++---- src/arfs/arfs_builders/arfs_folder_builders.ts | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/arfs/arfs_builders/arfs_builders.ts b/src/arfs/arfs_builders/arfs_builders.ts index ccc58fbe..c4dd9a46 100644 --- a/src/arfs/arfs_builders/arfs_builders.ts +++ b/src/arfs/arfs_builders/arfs_builders.ts @@ -193,9 +193,9 @@ export abstract class ArFSFileOrFolderBuilder< > extends ArFSMetadataEntityBuilder { parentFolderId?: FolderID; - protected async parseFromArweaveNode(node?: GQLNodeInterface): Promise { + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { const unparsedTags: GQLTagInterface[] = []; - const tags = await super.parseFromArweaveNode(node); + const tags = await super.parseFromArweaveNode(node, owner); tags.forEach((tag: GQLTagInterface) => { const key = tag.name; const { value } = tag; diff --git a/src/arfs/arfs_builders/arfs_drive_builders.ts b/src/arfs/arfs_builders/arfs_drive_builders.ts index 21d2f1fe..18acb7d6 100644 --- a/src/arfs/arfs_builders/arfs_drive_builders.ts +++ b/src/arfs/arfs_builders/arfs_drive_builders.ts @@ -20,7 +20,7 @@ import { ArFSMetadataEntityBuilderParams, ArFSPrivateMetadataEntityBuilderParams } from './arfs_builders'; -import { ArFSPrivateDriveKeyless } from '../../exports'; +import { ArFSPrivateDriveKeyless, ArweaveAddress } from '../../exports'; import { GatewayAPI } from '../../utils/gateway_api'; export interface DriveMetaDataTransactionData extends EntityMetaDataTransactionData { @@ -54,9 +54,9 @@ export class ArFSPublicDriveBuilder extends ArFSDriveBuilder { ]; } - protected async parseFromArweaveNode(node?: GQLNodeInterface): Promise { + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { const unparsedTags: GQLTagInterface[] = []; - const tags = await super.parseFromArweaveNode(node); + const tags = await super.parseFromArweaveNode(node, owner); tags.forEach((tag: GQLTagInterface) => { const key = tag.name; const { value } = tag; @@ -155,9 +155,9 @@ export class ArFSPrivateDriveBuilder extends ArFSDriveBuilder return fileBuilder; } - protected async parseFromArweaveNode(node?: GQLNodeInterface): Promise { + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { const unparsedTags: GQLTagInterface[] = []; - const tags = await super.parseFromArweaveNode(node); + const tags = await super.parseFromArweaveNode(node, owner); tags.forEach((tag: GQLTagInterface) => { const key = tag.name; const { value } = tag; @@ -286,9 +286,9 @@ export class SafeArFSDriveBuilder extends ArFSDriveBuilder { return driveBuilder; } - protected async parseFromArweaveNode(node?: GQLNodeInterface): Promise { + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { const unparsedTags: GQLTagInterface[] = []; - const tags = await super.parseFromArweaveNode(node); + const tags = await super.parseFromArweaveNode(node, owner); tags.forEach((tag: GQLTagInterface) => { const key = tag.name; const { value } = tag; diff --git a/src/arfs/arfs_builders/arfs_file_builders.ts b/src/arfs/arfs_builders/arfs_file_builders.ts index 6f7f7bb0..f1f0ecca 100644 --- a/src/arfs/arfs_builders/arfs_file_builders.ts +++ b/src/arfs/arfs_builders/arfs_file_builders.ts @@ -43,8 +43,8 @@ export abstract class ArFSFileBuilder { - const tags = await super.parseFromArweaveNode(node); + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { + const tags = await super.parseFromArweaveNode(node, owner); return tags.filter((tag) => tag.name !== 'File-Id'); } @@ -148,9 +148,9 @@ export class ArFSPrivateFileBuilder extends ArFSFileBuilder { return fileBuilder; } - protected async parseFromArweaveNode(node?: GQLNodeInterface): Promise { + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { const unparsedTags: GQLTagInterface[] = []; - const tags = await super.parseFromArweaveNode(node); + const tags = await super.parseFromArweaveNode(node, owner); tags.forEach((tag: GQLTagInterface) => { const key = tag.name; const { value } = tag; diff --git a/src/arfs/arfs_builders/arfs_folder_builders.ts b/src/arfs/arfs_builders/arfs_folder_builders.ts index 8f2a9988..607d26ce 100644 --- a/src/arfs/arfs_builders/arfs_folder_builders.ts +++ b/src/arfs/arfs_builders/arfs_folder_builders.ts @@ -30,8 +30,8 @@ export abstract class ArFSFolderBuilder { - protected async parseFromArweaveNode(node?: GQLNodeInterface): Promise { - const tags = await super.parseFromArweaveNode(node); + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { + const tags = await super.parseFromArweaveNode(node, owner); return tags.filter((tag) => tag.name !== 'Folder-Id'); } @@ -135,9 +135,9 @@ export class ArFSPrivateFolderBuilder extends ArFSFolderBuilder { + protected async parseFromArweaveNode(node?: GQLNodeInterface, owner?: ArweaveAddress): Promise { const unparsedTags: GQLTagInterface[] = []; - const tags = await super.parseFromArweaveNode(node); + const tags = await super.parseFromArweaveNode(node, owner); tags.forEach((tag: GQLTagInterface) => { const key = tag.name; const { value } = tag;