Skip to content

Commit

Permalink
Revert "feat(gql): use wallet for owner_address when available for …
Browse files Browse the repository at this point in the history
…public list commands PE-6232"

This reverts commit bd21f97.
  • Loading branch information
fedellen committed Jun 6, 2024
1 parent 3a8bdd0 commit a7b8e8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
16 changes: 6 additions & 10 deletions src/commands/list_drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,22 @@ new CLICommand({
const rootFolderId = drive.rootFolderId;
const withKeys = await parameters.getParameterValue(WithKeysParameter, (value) => !!value);

// We have the drive id from deriving a key, we can derive the owner
const driveOwner = await arDrive.getOwnerForDriveId(driveId);

children = await arDrive.listPrivateFolder({
folderId: rootFolderId,
driveKey,
maxDepth,
includeRoot: true,
owner: await wallet.getAddress(),
owner: driveOwner,
withKeys
});
} else {
const arDrive = cliArDriveAnonymousFactory({ arweave });

// Use wallet for owner if available to improve GQL query performance
const owner = (await (await parameters.getOptionalWallet())?.getAddress()) ?? undefined;

const drive = await arDrive.getPublicDrive({
driveId,
owner
});
const drive = await arDrive.getPublicDrive({ driveId });
const rootFolderId = drive.rootFolderId;
children = await arDrive.listPublicFolder({ folderId: rootFolderId, maxDepth, includeRoot: true, owner });
children = await arDrive.listPublicFolder({ folderId: rootFolderId, maxDepth, includeRoot: true });
}

const sortedChildren = children.sort((a, b) => alphabeticalOrder(a.path, b.path)) as (
Expand Down
18 changes: 5 additions & 13 deletions src/commands/list_folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,13 @@ new CLICommand({
const driveKey = await parameters.getDriveKey({ driveId });
const withKeys = await parameters.getParameterValue(WithKeysParameter, (value) => !!value);

children = await arDrive.listPrivateFolder({
folderId,
driveKey,
maxDepth,
owner: await wallet.getAddress(),
withKeys
});
// We have the drive id from deriving a key, we can derive the owner
const driveOwner = await arDrive.getOwnerForDriveId(driveId);

children = await arDrive.listPrivateFolder({ folderId, driveKey, maxDepth, owner: driveOwner, withKeys });
} else {
const arDrive = cliArDriveAnonymousFactory({ arweave });
children = await arDrive.listPublicFolder({
folderId,
maxDepth,
// Use wallet for owner if available to improve GQL query performance
owner: await (await parameters.getOptionalWallet())?.getAddress()
});
children = await arDrive.listPublicFolder({ folderId, maxDepth });
}

const sortedChildren = children.sort((a, b) => alphabeticalOrder(a.path, b.path)) as (
Expand Down

0 comments on commit a7b8e8d

Please sign in to comment.