Skip to content

Commit 47468bd

Browse files
committed
remove duplicate check
1 parent a1e54b9 commit 47468bd

File tree

3 files changed

+15
-26
lines changed

3 files changed

+15
-26
lines changed

cli/src/commands/list.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Command } from '@commander-js/extra-typings'
22

33
import { listFiles } from '../lib/website/read'
44

5-
import { initPublicProvider, validateWebsiteAddress } from './utils'
5+
import { initPublicProvider } from './utils'
66
import {
77
extractWebsiteMetadata,
88
fileHashHex,
@@ -20,13 +20,12 @@ export const listFilesCommand = new Command('list')
2020
.action(async (address, _, command) => {
2121
const globalOptions = loadConfig({ ...command.optsWithGlobals(), address })
2222

23-
const provider = await initPublicProvider(globalOptions)
24-
2523
const webSiteAddress = globalOptions.address
2624
if (!webSiteAddress) {
2725
throw new Error('No address provided')
2826
}
29-
validateWebsiteAddress(webSiteAddress)
27+
28+
const provider = await initPublicProvider(globalOptions)
3029

3130
const metadatas = await getGlobalMetadata(provider, webSiteAddress)
3231
const webSiteDefaultMetadata = extractWebsiteMetadata(metadatas)

cli/src/commands/metadata.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { Command } from '@commander-js/extra-typings'
2-
import {
3-
makeProviderFromNodeURLAndSecret,
4-
validateWebsiteAddress,
5-
} from './utils'
2+
import { makeProviderFromNodeURLAndSecret } from './utils'
63
import {
74
fileHashHex,
85
filterMetadataToUpdate,
@@ -40,13 +37,12 @@ export const metadataCommand = new Command('metadata')
4037
.action(async (address, options, command) => {
4138
const globalOptions = loadConfig({ ...command.optsWithGlobals(), address })
4239

43-
const provider = await makeProviderFromNodeURLAndSecret(globalOptions)
44-
4540
const webSiteAddress = globalOptions.address
4641
if (!webSiteAddress) {
4742
throw new Error('No address provided')
4843
}
49-
validateWebsiteAddress(webSiteAddress)
44+
45+
const provider = await makeProviderFromNodeURLAndSecret(globalOptions)
5046

5147
let metadatas: Metadata[] = []
5248
if (options.delete) {

cli/src/commands/showFile.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,25 @@ import { bytesToStr } from '@massalabs/massa-web3'
33

44
import { getFileFromAddress } from '../lib/website/read'
55

6-
import {
7-
makeProviderFromNodeURLAndSecret,
8-
validateWebsiteAddress,
9-
} from './utils'
6+
import { initPublicProvider } from './utils'
107
import { loadConfig } from './config'
118

129
export const showFileCommand = new Command('show')
1310
.description('Show a file from the given website on Massa blockchain')
1411
.argument('<file_path>', 'Path of the file to show')
1512
.option('-a, --address <address>', 'Address of the website to edit')
1613
.action(async (filePath, options, command) => {
17-
const globalOptions = loadConfig(command.optsWithGlobals())
14+
const globalOptions = loadConfig({
15+
...command.optsWithGlobals(),
16+
address: options.address,
17+
})
1818

19-
const provider = await makeProviderFromNodeURLAndSecret(globalOptions)
20-
21-
if (globalOptions.address) {
22-
validateWebsiteAddress(globalOptions.address)
23-
} else {
24-
console.log(
25-
"No address provided, targeting user's address isn't supported yet"
26-
)
27-
console.log('User address is', provider.address)
28-
process.exit(1)
19+
if (!globalOptions.address) {
20+
throw new Error('No address provided')
2921
}
3022

23+
const provider = await initPublicProvider(globalOptions)
24+
3125
console.log('Targeting website at address', globalOptions.address)
3226

3327
const fileContent = await getFileFromAddress(

0 commit comments

Comments
 (0)