Skip to content

Commit 7e619ac

Browse files
authored
Merge pull request #95 from lighthouse-web3/v0.2.6
Multi-file upload
2 parents 7a5802e + 63012cc commit 7e619ac

File tree

27 files changed

+1877
-7908
lines changed

27 files changed

+1877
-7908
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [16.x]
18+
node-version: [18.x]
1919
steps:
2020
- name: Use Node.js ${{ matrix.node-version }} 🛎️
2121
uses: actions/checkout@v3

.github/workflows/npm-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 16
17+
node-version: 18
1818
- run: npm ci
1919
- run: npm run build
2020
- run: npm test
@@ -26,7 +26,7 @@ jobs:
2626
- uses: actions/checkout@v3
2727
- uses: actions/setup-node@v3
2828
with:
29-
node-version: 16
29+
node-version: 18
3030
registry-url: https://registry.npmjs.org/
3131
- run: npm ci
3232
- run: npm run build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Lighthouse <img src="https://img.shields.io/badge/BETA-v0.2.5-green"/>
1+
# Lighthouse <img src="https://img.shields.io/badge/BETA-v0.2.6-green"/>
22

33
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.
44

package-lock.json

Lines changed: 1338 additions & 7758 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lighthouse-web3/sdk",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "NPM package and CLI tool to interact with lighthouse protocol",
55
"main": "./dist/Lighthouse/index.js",
66
"types": "./dist/Lighthouse/index.d.ts",
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"build": "tsc",
1212
"start": "node index.js",
13-
"test": "jest",
13+
"test": "jest --runInBand",
1414
"format": "prettier --write \"src/**/*.ts\"",
1515
"lint": "eslint . --ext .ts"
1616
},

src/Commands/create-wallet.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default async (_: any, _options: any) => {
3939
} else {
4040
config.set('LIGHTHOUSE_GLOBAL_WALLET', encryptedWallet)
4141
config.set('LIGHTHOUSE_GLOBAL_PUBLICKEY', publicKey)
42-
4342
console.log(
4443
cyan('Public Key: ' + publicKey) + green('\r\nWallet Created!')
4544
)

src/Commands/get-uploads.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import lighthouse from '../Lighthouse'
55

66
export default async function () {
77
try {
8-
if (!config.get('LIGHTHOUSE_GLOBAL_PUBLICKEY')) {
9-
throw new Error('Wallet not created/imported')
8+
if (!config.get('LIGHTHOUSE_GLOBAL_API_KEY')) {
9+
throw new Error('Please create api-key first: use api-key command')
1010
}
1111

1212
const response = (
1313
await lighthouse.getUploads(
14-
config.get('LIGHTHOUSE_GLOBAL_PUBLICKEY') as string
14+
config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string
1515
)
1616
).data
1717

src/Commands/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import revokeAccess from './revoke-access'
1919
import viewCarFiles from './view-car-files'
2020
import resetPassword from './reset-password'
2121
import uploadEncrypted from './upload-encrypted'
22+
import podsi from './podsi'
2223

2324
const widgets = new Command('lighthouse-web3')
2425

@@ -73,7 +74,7 @@ Command.prototype.helpInformation = function (context: any) {
7374
}
7475

7576
widgets.addHelpText('before', 'Welcome to lighthouse-web3')
76-
widgets.version('0.2.5')
77+
widgets.version('0.2.6')
7778

7879
widgets
7980
.command('wallet')
@@ -127,6 +128,12 @@ widgets
127128
.argument('<path>', 'Path to file')
128129
.action(createCar)
129130

131+
widgets
132+
.command('podsi')
133+
.description('Show Proof of data segment inclusion')
134+
.argument('<cid>', 'CID of the file previously uploaded')
135+
.action(podsi)
136+
130137
widgets
131138
.command('upload')
132139
.description('Upload a file')

src/Commands/ipns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default async function (_options: any) {
4141
}
4242

4343
if(_options.remove || _options.r) {
44-
const removeRes = await lighthouse.removeKey(_options.remove, config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string)
44+
await lighthouse.removeKey(_options.remove, config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string)
4545
console.log(
4646
green('Record Removed!!!')
4747
)

src/Commands/podsi.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { green, red, bold, yellow } from 'kleur'
2+
import { isCID } from '../Lighthouse/utils/util'
3+
import getPodsi from '../Lighthouse/podsi'
4+
5+
export default async function (cid: any, options: any) {
6+
if (JSON.stringify(cid) === '{}') {
7+
options.help()
8+
} else {
9+
try {
10+
if (!isCID(cid)) {
11+
throw new Error('Invalid CID')
12+
}
13+
const { data } = await getPodsi(cid)
14+
console.log(bold().cyan('Piece Info:'))
15+
console.log(green('Piece CID:'), data.pieceCID)
16+
console.log(green('Piece Size:'), data.pieceSize)
17+
console.log(green('Car File Size:'), data.carFileSize)
18+
19+
console.log('\n' + bold().cyan('Proof Data:'))
20+
console.log(green('Piece CID:'), data.proof.pieceCID)
21+
console.log(green('ID:'), data.proof.id)
22+
console.log(
23+
green('Last Update:'),
24+
new Date(data.proof.lastUpdate * 1000).toLocaleString()
25+
)
26+
27+
console.log('\n' + bold().cyan('Inclusion Proof:'))
28+
console.log(
29+
green('Proof Index:'),
30+
data.proof.fileProof.inclusionProof.proofIndex.index
31+
)
32+
console.log(green('Proof Paths:'))
33+
data.proof.fileProof.inclusionProof.proofIndex.path.forEach((path) => {
34+
console.log(yellow(' -'), path)
35+
})
36+
37+
console.log('\n' + bold().cyan('Proof Subtree:'))
38+
console.log(
39+
green('Index:'),
40+
data.proof.fileProof.inclusionProof.proofSubtree.index
41+
)
42+
console.log(green('Paths:'))
43+
data.proof.fileProof.inclusionProof.proofSubtree.path.forEach((path) => {
44+
console.log(yellow(' -'), path)
45+
})
46+
47+
console.log('\n' + bold().cyan('Index Record:'))
48+
console.log(green('Checksum:'), data.proof.fileProof.indexRecord.checksum)
49+
console.log(
50+
green('Proof Index:'),
51+
data.proof.fileProof.indexRecord.proofIndex
52+
)
53+
console.log(
54+
green('Proof Subtree:'),
55+
data.proof.fileProof.indexRecord.proofSubtree
56+
)
57+
console.log(green('Size:'), data.proof.fileProof.indexRecord.size)
58+
59+
console.log('\n' + bold().cyan('Verifier Data:'))
60+
console.log(green('Comm Pc:'), data.proof.fileProof.verifierData.commPc)
61+
console.log(green('Size Pc:'), data.proof.fileProof.verifierData.sizePc)
62+
63+
console.log('\n' + bold().cyan('Deal Info:'))
64+
data.dealInfo.forEach((deal) => {
65+
console.log(green('Deal ID:'), deal.dealId)
66+
console.log(green('Storage Provider:'), deal.storageProvider)
67+
})
68+
} catch (error: any) {
69+
console.log(red(error.message))
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)