@@ -179,9 +179,7 @@ export class ArDrive extends ArDriveAnonymous {
179
179
public async movePublicFile ( { fileId, newParentFolderId } : MovePublicFileParams ) : Promise < ArFSResult > {
180
180
const destFolderDriveId = await this . arFsDao . getDriveIdForFolderId ( newParentFolderId ) ;
181
181
182
- const owner = await this . getOwnerForDriveId ( destFolderDriveId ) ;
183
- await this . assertOwnerAddress ( owner ) ;
184
-
182
+ const owner = await this . wallet . getAddress ( ) ;
185
183
const originalFileMetaData = await this . getPublicFile ( { fileId } ) ;
186
184
187
185
if ( ! destFolderDriveId . equals ( originalFileMetaData . driveId ) ) {
@@ -256,9 +254,7 @@ export class ArDrive extends ArDriveAnonymous {
256
254
public async movePrivateFile ( { fileId, newParentFolderId, driveKey } : MovePrivateFileParams ) : Promise < ArFSResult > {
257
255
const destFolderDriveId = await this . arFsDao . getDriveIdForFolderId ( newParentFolderId ) ;
258
256
259
- const owner = await this . getOwnerForDriveId ( destFolderDriveId ) ;
260
- await this . assertOwnerAddress ( owner ) ;
261
-
257
+ const owner = await this . wallet . getAddress ( ) ;
262
258
const originalFileMetaData = await this . getPrivateFile ( { fileId, driveKey } ) ;
263
259
264
260
if ( ! destFolderDriveId . equals ( originalFileMetaData . driveId ) ) {
@@ -345,9 +341,7 @@ export class ArDrive extends ArDriveAnonymous {
345
341
346
342
const destFolderDriveId = await this . arFsDao . getDriveIdForFolderId ( newParentFolderId ) ;
347
343
348
- const owner = await this . getOwnerForDriveId ( destFolderDriveId ) ;
349
- await this . assertOwnerAddress ( owner ) ;
350
-
344
+ const owner = await this . wallet . getAddress ( ) ;
351
345
const originalFolderMetaData = await this . getPublicFolder ( { folderId } ) ;
352
346
353
347
if ( ! destFolderDriveId . equals ( originalFolderMetaData . driveId ) ) {
@@ -430,9 +424,7 @@ export class ArDrive extends ArDriveAnonymous {
430
424
431
425
const destFolderDriveId = await this . arFsDao . getDriveIdForFolderId ( newParentFolderId ) ;
432
426
433
- const owner = await this . getOwnerForDriveId ( destFolderDriveId ) ;
434
- await this . assertOwnerAddress ( owner ) ;
435
-
427
+ const owner = await this . wallet . getAddress ( ) ;
436
428
const originalFolderMetaData = await this . getPrivateFolder ( { folderId, driveKey } ) ;
437
429
438
430
if ( ! destFolderDriveId . equals ( originalFolderMetaData . driveId ) ) {
@@ -594,13 +586,10 @@ export class ArDrive extends ArDriveAnonymous {
594
586
const preparedEntities : UploadStats [ ] = [ ] ;
595
587
596
588
for ( const entity of entitiesToUpload ) {
597
- const { destFolderId, driveKey } = entity ;
589
+ const { destFolderId } = entity ;
598
590
const destDriveId = await this . arFsDao . getDriveIdForFolderId ( destFolderId ) ;
599
591
600
- // Assert drive privacy and owner of the drive
601
- const owner = await this . arFsDao . getOwnerAndAssertDrive ( destDriveId , driveKey ) ;
602
- await this . assertOwnerAddress ( owner ) ;
603
-
592
+ const owner = await this . wallet . getAddress ( ) ;
604
593
preparedEntities . push ( { ...entity , destDriveId, owner } ) ;
605
594
}
606
595
@@ -822,7 +811,7 @@ export class ArDrive extends ArDriveAnonymous {
822
811
}
823
812
824
813
private async deriveMetaDataTxIdForFileId ( fileId : FileID , dataTxId : TransactionID ) : Promise < TransactionID > {
825
- const owner = await this . arFsDao . getDriveOwnerForFileId ( fileId ) ;
814
+ const owner = await this . wallet . getAddress ( ) ;
826
815
const fileMetaData = await this . arFsDao . getPublicFile ( fileId , owner ) ;
827
816
828
817
if ( fileMetaData . dataTxId . equals ( dataTxId ) ) {
@@ -837,7 +826,7 @@ export class ArDrive extends ArDriveAnonymous {
837
826
destinationFolderId : FolderID ,
838
827
dataTxId : TransactionID
839
828
) : Promise < ArFSPublicFile | undefined > {
840
- const owner = await this . arFsDao . getDriveOwnerForFolderId ( destinationFolderId ) ;
829
+ const owner = await this . wallet . getAddress ( ) ;
841
830
await this . assertFolderExists ( destinationFolderId , owner ) ;
842
831
843
832
const allFileMetaDataTxInFolder = await this . arFsDao . getPublicFilesWithParentFolderIds (
@@ -870,10 +859,7 @@ export class ArDrive extends ArDriveAnonymous {
870
859
destinationFolderId : FolderID ;
871
860
conflictResolution : FileNameConflictResolution ;
872
861
} ) : Promise < boolean > {
873
- const destDriveId = await this . arFsDao . getDriveIdForFolderId ( destinationFolderId ) ;
874
- const owner = await this . arFsDao . getOwnerAndAssertDrive ( destDriveId ) ;
875
- await this . assertOwnerAddress ( owner ) ;
876
-
862
+ const owner = await this . wallet . getAddress ( ) ;
877
863
await resolveFileNameConflicts ( {
878
864
wrappedFile,
879
865
conflictResolution,
@@ -989,12 +975,8 @@ export class ArDrive extends ArDriveAnonymous {
989
975
conflictResolution = upsertOnConflicts ,
990
976
prompts
991
977
} : UploadPublicManifestParams ) : Promise < ArFSManifestResult > {
992
- const driveId = await this . arFsDao . getDriveIdForFolderId ( folderId ) ;
993
-
994
978
// Assert that the owner of this drive is consistent with the provided wallet
995
- const owner = await this . getOwnerForDriveId ( driveId ) ;
996
- await this . assertOwnerAddress ( owner ) ;
997
-
979
+ const owner = await this . wallet . getAddress ( ) ;
998
980
const children = await this . listPublicFolder ( {
999
981
folderId,
1000
982
maxDepth,
@@ -1034,8 +1016,7 @@ export class ArDrive extends ArDriveAnonymous {
1034
1016
assertValidArFSFolderName ( folderName ) ;
1035
1017
1036
1018
const driveId = await this . arFsDao . getDriveIdForFolderId ( parentFolderId ) ;
1037
- const owner = await this . arFsDao . getOwnerAndAssertDrive ( driveId ) ;
1038
- await this . assertOwnerAddress ( owner ) ;
1019
+ const owner = await this . wallet . getAddress ( ) ;
1039
1020
1040
1021
// Assert that there are no duplicate names in the destination folder
1041
1022
const entityNamesInParentFolder = await this . arFsDao . getPublicEntityNamesInFolder ( parentFolderId , owner ) ;
@@ -1096,8 +1077,7 @@ export class ArDrive extends ArDriveAnonymous {
1096
1077
assertValidArFSFolderName ( folderName ) ;
1097
1078
1098
1079
const driveId = await this . arFsDao . getDriveIdForFolderId ( parentFolderId ) ;
1099
- const owner = await this . arFsDao . getOwnerAndAssertDrive ( driveId , driveKey ) ;
1100
- await this . assertOwnerAddress ( owner ) ;
1080
+ const owner = await this . wallet . getAddress ( ) ;
1101
1081
1102
1082
// Assert that there are no duplicate names in the destination folder
1103
1083
const entityNamesInParentFolder = await this . arFsDao . getPrivateEntityNamesInFolder (
@@ -1286,10 +1266,8 @@ export class ArDrive extends ArDriveAnonymous {
1286
1266
withKeys
1287
1267
} : GetPrivateDriveParams ) : Promise < ArFSPrivateDrive > {
1288
1268
if ( ! owner ) {
1289
- owner = await this . getOwnerForDriveId ( driveId ) ;
1269
+ owner = await this . wallet . getAddress ( ) ;
1290
1270
}
1291
- await this . assertOwnerAddress ( owner ) ;
1292
-
1293
1271
const drive = await this . arFsDao . getPrivateDrive ( driveId , driveKey , owner ) ;
1294
1272
return withKeys
1295
1273
? drive
@@ -1318,9 +1296,8 @@ export class ArDrive extends ArDriveAnonymous {
1318
1296
withKeys
1319
1297
} : GetPrivateFolderParams ) : Promise < ArFSPrivateFolder > {
1320
1298
if ( ! owner ) {
1321
- owner = await this . arFsDao . getDriveOwnerForFolderId ( folderId ) ;
1299
+ owner = await this . wallet . getAddress ( ) ;
1322
1300
}
1323
- await this . assertOwnerAddress ( owner ) ;
1324
1301
1325
1302
const folder = await this . arFsDao . getPrivateFolder ( folderId , driveKey , owner ) ;
1326
1303
return withKeys ? folder : new ArFSPrivateFolderKeyless ( folder ) ;
@@ -1343,7 +1320,7 @@ export class ArDrive extends ArDriveAnonymous {
1343
1320
withKeys = false
1344
1321
} : GetPrivateFileParams ) : Promise < ArFSPrivateFile > {
1345
1322
if ( ! owner ) {
1346
- owner = await this . arFsDao . getDriveOwnerForFileId ( fileId ) ;
1323
+ owner = await this . wallet . getAddress ( ) ;
1347
1324
}
1348
1325
1349
1326
const file = await this . arFsDao . getPrivateFile ( fileId , driveKey , owner ) ;
@@ -1364,9 +1341,8 @@ export class ArDrive extends ArDriveAnonymous {
1364
1341
withKeys = false
1365
1342
} : ListPrivateFolderParams ) : Promise < ( ArFSPrivateFolderWithPaths | ArFSPrivateFileWithPaths ) [ ] > {
1366
1343
if ( ! owner ) {
1367
- owner = await this . arFsDao . getDriveOwnerForFolderId ( folderId ) ;
1344
+ owner = await this . wallet . getAddress ( ) ;
1368
1345
}
1369
- await this . assertOwnerAddress ( owner ) ;
1370
1346
1371
1347
const withPathsFactory = withKeys ? privateEntityWithPathsFactory : privateEntityWithPathsKeylessFactory ;
1372
1348
@@ -1490,8 +1466,8 @@ export class ArDrive extends ArDriveAnonymous {
1490
1466
}
1491
1467
1492
1468
async renamePublicFile ( { fileId, newName } : RenamePublicFileParams ) : Promise < ArFSResult > {
1493
- const owner = await this . arFsDao . getDriveOwnerForFileId ( fileId ) ;
1494
- await this . assertOwnerAddress ( owner ) ;
1469
+ const owner = await this . wallet . getAddress ( ) ;
1470
+
1495
1471
const file = await this . getPublicFile ( { fileId, owner } ) ;
1496
1472
if ( file . name === newName ) {
1497
1473
throw new Error ( `To rename a file, the new name must be different` ) ;
@@ -1549,8 +1525,7 @@ export class ArDrive extends ArDriveAnonymous {
1549
1525
}
1550
1526
1551
1527
async renamePrivateFile ( { fileId, newName, driveKey } : RenamePrivateFileParams ) : Promise < ArFSResult > {
1552
- const owner = await this . arFsDao . getDriveOwnerForFileId ( fileId ) ;
1553
- await this . assertOwnerAddress ( owner ) ;
1528
+ const owner = await this . wallet . getAddress ( ) ;
1554
1529
const file = await this . getPrivateFile ( { fileId, driveKey, owner } ) ;
1555
1530
if ( file . name === newName ) {
1556
1531
throw new Error ( `To rename a file, the new name must be different` ) ;
@@ -1613,8 +1588,7 @@ export class ArDrive extends ArDriveAnonymous {
1613
1588
}
1614
1589
1615
1590
async renamePublicFolder ( { folderId, newName } : RenamePublicFolderParams ) : Promise < ArFSResult > {
1616
- const owner = await this . arFsDao . getDriveOwnerForFolderId ( folderId ) ;
1617
- await this . assertOwnerAddress ( owner ) ;
1591
+ const owner = await this . wallet . getAddress ( ) ;
1618
1592
const folder = await this . getPublicFolder ( { folderId, owner } ) ;
1619
1593
if ( `${ folder . parentFolderId } ` === ROOT_FOLDER_ID_PLACEHOLDER ) {
1620
1594
throw new Error (
@@ -1671,8 +1645,7 @@ export class ArDrive extends ArDriveAnonymous {
1671
1645
}
1672
1646
1673
1647
async renamePrivateFolder ( { folderId, newName, driveKey } : RenamePrivateFolderParams ) : Promise < ArFSResult > {
1674
- const owner = await this . arFsDao . getDriveOwnerForFolderId ( folderId ) ;
1675
- await this . assertOwnerAddress ( owner ) ;
1648
+ const owner = await this . wallet . getAddress ( ) ;
1676
1649
const folder = await this . getPrivateFolder ( { folderId, driveKey, owner } ) ;
1677
1650
if ( `${ folder . parentFolderId } ` === ROOT_FOLDER_ID_PLACEHOLDER ) {
1678
1651
throw new Error (
@@ -1735,8 +1708,7 @@ export class ArDrive extends ArDriveAnonymous {
1735
1708
}
1736
1709
1737
1710
async renamePublicDrive ( { driveId, newName } : RenamePublicDriveParams ) : Promise < ArFSResult > {
1738
- const owner = await this . arFsDao . getOwnerForDriveId ( driveId ) ;
1739
- await this . assertOwnerAddress ( owner ) ;
1711
+ const owner = await this . wallet . getAddress ( ) ;
1740
1712
const drive = await this . getPublicDrive ( { driveId, owner } ) ;
1741
1713
if ( drive . name === newName ) {
1742
1714
throw new Error ( `New drive name '${ newName } ' must be different from the current drive name!` ) ;
@@ -1791,8 +1763,7 @@ export class ArDrive extends ArDriveAnonymous {
1791
1763
}
1792
1764
1793
1765
async renamePrivateDrive ( { driveId, newName, driveKey } : RenamePrivateDriveParams ) : Promise < ArFSResult > {
1794
- const owner = await this . arFsDao . getOwnerForDriveId ( driveId ) ;
1795
- await this . assertOwnerAddress ( owner ) ;
1766
+ const owner = await this . wallet . getAddress ( ) ;
1796
1767
const drive = await this . getPrivateDrive ( { driveId, owner, driveKey } ) ;
1797
1768
if ( drive . name === newName ) {
1798
1769
throw new Error ( `New drive name '${ newName } ' must be different from the current drive name!` ) ;
@@ -1858,7 +1829,7 @@ export class ArDrive extends ArDriveAnonymous {
1858
1829
owner
1859
1830
} : DownloadPrivateFolderParameters ) : Promise < void > {
1860
1831
if ( ! owner ) {
1861
- owner = await this . arFsDao . getDriveOwnerForFolderId ( folderId ) ;
1832
+ owner = await this . wallet . getAddress ( ) ;
1862
1833
}
1863
1834
1864
1835
return this . arFsDao . downloadPrivateFolder ( {
@@ -1880,7 +1851,7 @@ export class ArDrive extends ArDriveAnonymous {
1880
1851
owner
1881
1852
} : DownloadPrivateDriveParameters ) : Promise < void > {
1882
1853
if ( ! owner ) {
1883
- owner = await this . arFsDao . getOwnerForDriveId ( driveId ) ;
1854
+ owner = await this . wallet . getAddress ( ) ;
1884
1855
}
1885
1856
1886
1857
const drive = await this . arFsDao . getPrivateDrive ( driveId , driveKey , owner ) ;
0 commit comments