diff --git a/README.md b/README.md
index b364c77e..76d926bb 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Lighthouse
+# Lighthouse
Lighthouse is a permanent decentralized file storage protocol that allows the ability to pay once and store forever. While traditionally, users need to repeatedly keep track and pay for their storage after every fixed amount of time, Lighthouse manages this for them and makes sure that user files are stored forever. The aim is to move users from a rent-based cost model where they are renting their own files on cloud storage to a permanent ownership model. It is built on top of IPFS, Filecoin, and Polygon. It uses the existing miner network and storage capacity of the filecoin network.
diff --git a/package-lock.json b/package-lock.json
index 188c6ac8..937823e4 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@lighthouse-web3/sdk",
- "version": "0.4.6",
+ "version": "0.4.7",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lighthouse-web3/sdk",
- "version": "0.4.6",
+ "version": "0.4.7",
"license": "MIT",
"dependencies": {
"@lighthouse-web3/kavach": "^0.1.9",
diff --git a/package.json b/package.json
index 3e9e1037..bba1417f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@lighthouse-web3/sdk",
- "version": "0.4.6",
+ "version": "0.4.7",
"description": "NPM package and CLI tool to interact with lighthouse protocol",
"main": "./dist/Lighthouse/index.js",
"types": "./dist/Lighthouse/index.d.ts",
diff --git a/src/Commands/index.ts b/src/Commands/index.ts
index 68c89dcc..490e02a1 100644
--- a/src/Commands/index.ts
+++ b/src/Commands/index.ts
@@ -11,6 +11,7 @@ import shareFile from './share-file'
import getUploads from './get-uploads'
import deleteFile from './delete-file'
import dealStatus from './deal-status'
+import walrusBlobs from './walrus-blobs'
import decryptFile from './decrypt-file'
import createWallet from './create-wallet'
import walletForget from './wallet-forget'
@@ -72,7 +73,7 @@ Command.prototype.helpInformation = function (context: any) {
}
widgets.addHelpText('before', 'Welcome to lighthouse-web3')
-widgets.version('0.4.6')
+widgets.version('0.4.7')
widgets
.command('wallet')
@@ -160,6 +161,12 @@ widgets
.description('Get filecoin deal status of a CID')
.action(dealStatus)
+widgets
+ .command('walrus-blobs')
+ .argument('', 'File Cid')
+ .description('Get walrus blob IDs for a CID')
+ .action(walrusBlobs)
+
widgets
.command('get-uploads')
.description('Get details of file uploaded')
diff --git a/src/Commands/walrus-blobs.ts b/src/Commands/walrus-blobs.ts
new file mode 100644
index 00000000..1943a14b
--- /dev/null
+++ b/src/Commands/walrus-blobs.ts
@@ -0,0 +1,36 @@
+import { yellow, red } from 'kleur'
+import lighthouse from '../Lighthouse'
+
+export default async function (cid: string) {
+ try {
+ if (!cid) {
+ throw new Error('Please provide a CID.')
+ }
+
+ const { blobIds } = await lighthouse.walrusBlobs(cid)
+
+ console.log(
+ yellow('\r\nCID:') + Array(9).fill('\xa0').join('') + cid
+ )
+
+ if (blobIds.length === 0) {
+ console.log(yellow('\r\nNo walrus blobs found for this CID'))
+ return
+ }
+
+ console.log(
+ '\r\n' +
+ Array(4).fill('\xa0').join('') +
+ yellow('Blob ID')
+ )
+
+ for (let i = 0; i < blobIds.length; i++) {
+ console.log(
+ Array(4).fill('\xa0').join('') + blobIds[i] + '\r\n'
+ )
+ }
+ } catch (error: any) {
+ console.log(red(error.message))
+ process.exit(0)
+ }
+}
diff --git a/src/Lighthouse/deleteFileWalrus/index.ts b/src/Lighthouse/deleteFileWalrus/index.ts
new file mode 100644
index 00000000..a54e4300
--- /dev/null
+++ b/src/Lighthouse/deleteFileWalrus/index.ts
@@ -0,0 +1,40 @@
+import { lighthouseConfig } from '../../lighthouse.config'
+
+export type deleteFileResponseType = {
+ data: {
+ message: string
+ }
+}
+
+export default async (
+ authToken: string,
+ fileId: string
+): Promise => {
+ try {
+ const response = await fetch(
+ `${lighthouseConfig.lighthouseAPI}/api/user/delete_file_walrus?id=${fileId}`,
+ {
+ method: 'DELETE',
+ headers: {
+ Authorization: `Bearer ${authToken}`,
+ 'Content-Type': 'application/json',
+ },
+ }
+ )
+
+ if (!response.ok) {
+ throw new Error(`Request failed with status code ${response.status}`)
+ }
+
+ const result = (await response.json()) as any
+ /*
+ Example response:
+ {
+ "message": "File deleted successfully."
+ }
+ */
+ return { data: result }
+ } catch (error: any) {
+ throw new Error(error.message)
+ }
+}
diff --git a/src/Lighthouse/getUploads/index.ts b/src/Lighthouse/getUploads/index.ts
index 60cc8036..03039d15 100644
--- a/src/Lighthouse/getUploads/index.ts
+++ b/src/Lighthouse/getUploads/index.ts
@@ -23,12 +23,13 @@ export type uploadsResponseType = {
export default async (
authToken: string,
- lastKey: string | null = null
+ lastKey: string | null = null,
+ fileType: string = 'all'
): Promise => {
try {
const response = await fetch(
lighthouseConfig.lighthouseAPI +
- `/api/user/files_uploaded?lastKey=${lastKey}`,
+ `/api/user/files_uploaded?lastKey=${lastKey}&fileType=${fileType}`,
{
headers: {
Authorization: `Bearer ${authToken}`,
diff --git a/src/Lighthouse/index.ts b/src/Lighthouse/index.ts
index 1e2e1b8c..840401dc 100644
--- a/src/Lighthouse/index.ts
+++ b/src/Lighthouse/index.ts
@@ -6,7 +6,8 @@ import getUploads from './getUploads'
import getFileInfo from './getFileInfo'
import createWallet from './createWallet'
import deleteFile from './deleteFile'
-
+import walrusBlobs from './walrusBlobs'
+import deleteFileWalrus from './deleteFileWalrus'
import shareFile from './encryption/shareFile'
import getAuthMessage from './encryption/getAuthMessage'
import revokeFileAccess from './encryption/revokeFileAccess'
@@ -53,6 +54,8 @@ export {
getAllKeys,
removeKey,
deleteFile,
+ walrusBlobs,
+ deleteFileWalrus,
}
export default {
@@ -81,4 +84,6 @@ export default {
getAllKeys,
removeKey,
deleteFile,
+ walrusBlobs,
+ deleteFileWalrus,
}
diff --git a/src/Lighthouse/walrusBlobs/index.ts b/src/Lighthouse/walrusBlobs/index.ts
new file mode 100644
index 00000000..01481ade
--- /dev/null
+++ b/src/Lighthouse/walrusBlobs/index.ts
@@ -0,0 +1,21 @@
+import { lighthouseConfig } from '../../lighthouse.config'
+
+export type walrusBlobsResponse = {
+ blobIds: string[]
+}
+
+export default async (cid: string): Promise => {
+ try {
+ const response = await fetch(
+ `${lighthouseConfig.lighthouseAPI}/api/lighthouse/walrus_blobs?cid=${cid}`
+ )
+ if (!response.ok) {
+ throw new Error(`Request failed with status code ${response.status}`)
+ }
+ const walrusBlobs: walrusBlobsResponse = (await response.json()) as walrusBlobsResponse
+
+ return { blobIds: walrusBlobs.blobIds }
+ } catch (error: any) {
+ throw new Error(error.message)
+ }
+}