Skip to content

Commit a796cb1

Browse files
committed
updated
1 parent 7d60fdb commit a796cb1

File tree

9 files changed

+31
-54
lines changed

9 files changed

+31
-54
lines changed

src/Commands/balance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function (data: any, options: any) {
1515
spinner.start()
1616

1717
const response = await lighthouse.getBalance(
18-
config.get('LIGHTHOUSE_GLOBAL_PUBLICKEY') as string
18+
config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string
1919
)
2020

2121
spinner.stop()

src/Commands/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import revokeAccess from './revoke-access'
1818
import resetPassword from './reset-password'
1919
import uploadEncrypted from './upload-encrypted'
2020
import podsi from './podsi'
21+
import { version } from '../../package.json'
2122

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

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

7475
widgets.addHelpText('before', 'Welcome to lighthouse-web3')
75-
widgets.version('0.3.0')
76+
widgets.version(version)
7677

7778
widgets
7879
.command('wallet')

src/Commands/podsi.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,29 @@ export default async function (cid: any, options: any) {
1313
const { data } = await getPodsi(cid)
1414
console.log(bold().cyan('Piece Info:'))
1515
console.log(green('Piece CID:'), data.pieceCID)
16-
console.log(green('Piece Size:'), data.pieceSize)
17-
console.log(green('Car File Size:'), data.carFileSize)
1816

1917
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-
)
2618

2719
console.log('\n' + bold().cyan('Inclusion Proof:'))
2820
console.log(
2921
green('Proof Index:'),
30-
data.proof.fileProof.inclusionProof.proofIndex.index
22+
data.dealInfo[0].proof.inclusionProof.proofIndex.index
3123
)
3224
console.log(green('Proof Paths:'))
33-
data.proof.fileProof.inclusionProof.proofIndex.path.forEach((path) => {
25+
data.dealInfo[0].proof.inclusionProof.proofIndex.path.forEach((path) => {
3426
console.log(yellow(' -'), path)
3527
})
3628

3729
console.log('\n' + bold().cyan('Proof Subtree:'))
3830
console.log(
3931
green('Index:'),
40-
data.proof.fileProof.inclusionProof.proofSubtree.index
32+
data.dealInfo[0].proof.inclusionProof.proofSubtree.index
4133
)
4234
console.log(green('Paths:'))
43-
data.proof.fileProof.inclusionProof.proofSubtree.path.forEach((path) => {
35+
data.dealInfo[0].proof.inclusionProof.proofSubtree.path.forEach((path) => {
4436
console.log(yellow(' -'), path)
4537
})
4638

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-
6339
console.log('\n' + bold().cyan('Deal Info:'))
6440
data.dealInfo.forEach((deal) => {
6541
console.log(green('Deal ID:'), deal.dealId)

src/Commands/upload-encrypted.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import bytesToSize from './utils/byteToSize'
88
import { config } from './utils/getNetwork'
99
import lighthouse from '../Lighthouse'
1010

11-
const getQuote = async (path: string, publicKey: string, Spinner: any) => {
11+
const getQuote = async (path: string, apiKey: string, Spinner: any) => {
1212
const spinner = new Spinner('Getting Quote...')
1313
spinner.start()
1414

15-
const quoteResponse: any = (await lighthouse.getQuote(path, publicKey)).data
15+
const quoteResponse: any = (await lighthouse.getQuote(path, apiKey)).data
1616
spinner.stop()
1717
process.stdout.clearLine(-1)
1818
process.stdout.cursorTo(0)
@@ -149,7 +149,7 @@ export default async function (_path: string) {
149149
// Display Quote
150150
const quoteResponse = await getQuote(
151151
path,
152-
config.get('LIGHTHOUSE_GLOBAL_PUBLICKEY') as string,
152+
config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string,
153153
Spinner
154154
)
155155

src/Commands/upload.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import lighthouse from '../Lighthouse'
77
import bytesToSize from './utils/byteToSize'
88
import { config } from './utils/getNetwork'
99

10-
const getQuote = async (path: string, publicKey: string, Spinner: any) => {
10+
const getQuote = async (path: string, apiKey: string, Spinner: any) => {
1111
const spinner = new Spinner('Getting Quote...')
1212
spinner.start()
1313

14-
const quoteResponse: any = (await lighthouse.getQuote(path, publicKey)).data
14+
const quoteResponse: any = (await lighthouse.getQuote(path, apiKey)).data
1515
spinner.stop()
1616
process.stdout.clearLine(-1)
1717
process.stdout.cursorTo(0)
@@ -139,7 +139,7 @@ export default async function (_path: string) {
139139
// Display Quote
140140
const quoteResponse = await getQuote(
141141
path,
142-
config.get('LIGHTHOUSE_GLOBAL_PUBLICKEY') as string,
142+
config.get('LIGHTHOUSE_GLOBAL_API_KEY') as string,
143143
Spinner
144144
)
145145

src/Lighthouse/tests/getBalance.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'dotenv/config'
33

44
describe('getBalance', () => {
55
it('should retrieve balance when lighthouse-package generated public key provided', async () => {
6-
const publicKey = process.env.TEST_PUBLIC_KEY as string
7-
const balance = (await lighthouse.getBalance(publicKey)).data
6+
const apiKey = process.env.TEST_API_KEY as string
7+
const balance = (await lighthouse.getBalance(apiKey)).data
88

99
expect(typeof balance.dataLimit).toBe('number')
1010
expect(typeof balance.dataUsed).toBe('number')
@@ -13,19 +13,19 @@ describe('getBalance', () => {
1313

1414
it('should throw error when random public key is provided', async () => {
1515
try {
16-
const randomPublicKey = '0xD794EC627684D6Be2667413e8FF1DeDc0eef363f'
17-
const balance = (await lighthouse.getBalance(randomPublicKey)).data
16+
const randomAPIKey = '0xD794EC627684D6Be2667413e8FF1DeDc0eef363f'
17+
const balance = (await lighthouse.getBalance(randomAPIKey)).data
1818
} catch (error) {
19-
expect(error.message).toBe('Request failed with status code 404')
19+
expect(error.message).toBe('Request failed with status code 401')
2020
}
2121
}, 20000)
2222

2323
it('should throw error when invalid public key is provided', async () => {
2424
try {
25-
const invalidPublicKey = 'invalidPublicKey'
26-
const balance = (await lighthouse.getBalance(invalidPublicKey)).data
25+
const invalidAPIKey = 'invalidPublicKey'
26+
const balance = (await lighthouse.getBalance(invalidAPIKey)).data
2727
} catch (error) {
28-
expect(error.message).toBe('Request failed with status code 400')
28+
expect(error.message).toBe('Request failed with status code 401')
2929
}
3030
}, 20000)
3131
})

src/Lighthouse/tests/getQuote.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,39 @@ import lighthouse from '..'
33
import 'dotenv/config'
44

55
describe('getQuote', () => {
6-
const publicKey = process.env.TEST_PUBLIC_KEY as string
6+
const apiKey = process.env.TEST_API_KEY as string
77
const filePath = resolve(
88
process.cwd(),
99
'src/Lighthouse/tests/testImages/testImage1.svg'
1010
)
1111
const folderPath = resolve(process.cwd(), 'src/Lighthouse/tests/testImages')
1212

1313
it('should get quote for file when correct path and public key is provided', async () => {
14-
const response = (await lighthouse.getQuote(filePath, publicKey)).data
14+
const response = (await lighthouse.getQuote(filePath, apiKey)).data
1515
expect(response).toHaveProperty('metaData')
1616
expect(response).toHaveProperty('dataLimit')
1717
expect(response).toHaveProperty('dataUsed')
1818
})
1919

2020
it('should get quote for folder when correct path and public key is provided', async () => {
21-
const response = (await lighthouse.getQuote(folderPath, publicKey)).data
21+
const response = (await lighthouse.getQuote(folderPath, apiKey)).data
2222
expect(response).toHaveProperty('metaData')
2323
expect(response).toHaveProperty('dataLimit')
2424
expect(response).toHaveProperty('dataUsed')
2525
})
2626

27-
it('should throw error when invalid public key is provided', async () => {
27+
it('should throw error when invalid api key is provided', async () => {
2828
try {
29-
const response = (await lighthouse.getQuote(filePath, 'invalidPublicKey'))
29+
const response = (await lighthouse.getQuote(filePath, 'invalidAPIKey'))
3030
.data
3131
} catch (error) {
32-
expect(error.message).toBe('Request failed with status code 400')
32+
expect(error.message).toBe('Request failed with status code 401')
3333
}
3434
})
3535

3636
it('should throw error when wrong file/folder path is provided', async () => {
3737
try {
38-
const response = (await lighthouse.getQuote('wrong/file/path', publicKey))
38+
const response = (await lighthouse.getQuote('wrong/file/path', apiKey))
3939
.data
4040
} catch (error) {
4141
expect(error.message).toMatch('ENOENT: no such file or directory')

src/Lighthouse/tests/ipns.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('ipns', () => {
4949
it('should retrieve list of all keys from apiKey', async () => {
5050
const keyList = (await lighthouse.getAllKeys(apiKey)).data
5151
const len = keyList.length
52-
expect(keyList[len - 1].ipnsName).toEqual(ipnsName)
52+
expect(typeof keyList[len - 1].ipnsName).toBe('string')
5353
}, 20000)
5454
})
5555

src/Lighthouse/tests/podsi.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('podsi', () => {
77
).data
88

99
expect(response).toHaveProperty('pieceCID')
10-
expect(response).toHaveProperty('proof')
10+
expect(typeof response.dealInfo[0].dealId).toBe('number')
1111
expect(response).toHaveProperty('dealInfo')
1212
}, 20000)
1313

@@ -17,7 +17,7 @@ describe('podsi', () => {
1717
await lighthouse.posdi('QmbnJh4KMARvXcSqNCaz3gv6KuJ8v19RYi55YVqPg4zZV8')
1818
).data
1919
} catch (error) {
20-
expect(error.message).toBe("Proof Doesn't exist yet")
20+
expect(error.message).toBe("Request failed with status code 404")
2121
}
2222
}, 20000)
2323
})

0 commit comments

Comments
 (0)