Skip to content

Commit 69e7d92

Browse files
committed
CID type selection improvements
1 parent 4226b75 commit 69e7d92

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

bin/chel

-1
This file was deleted.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/deploy.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import { path } from './deps.ts'
66
import { upload } from './upload.ts'
77

8+
// Prefixes to use to select the correct CID to use
9+
const CONTRACT_TEXT_PREFIX = `t|`
10+
const CONTRACT_MANIFEST_PREFIX = `m|`
11+
812
export async function deploy (args: string[]) {
913
const [urlOrDirOrSqliteFile, ...manifests] = args
1014
if (manifests.length === 0) throw new Error('missing url or manifests!')
@@ -13,11 +17,11 @@ export async function deploy (args: string[]) {
1317
const json = JSON.parse(Deno.readTextFileSync(manifestPath))
1418
const body = JSON.parse(json.body)
1519
const dirname = path.dirname(manifestPath)
16-
toUpload.push('t|' + path.join(dirname, body.contract.file))
20+
toUpload.push(CONTRACT_TEXT_PREFIX + path.join(dirname, body.contract.file))
1721
if (body.contractSlim) {
18-
toUpload.push('t|' + path.join(dirname, body.contractSlim.file))
22+
toUpload.push(CONTRACT_TEXT_PREFIX + path.join(dirname, body.contractSlim.file))
1923
}
20-
toUpload.push('m|' + manifestPath)
24+
toUpload.push(CONTRACT_MANIFEST_PREFIX + manifestPath)
2125
}
2226
await upload([urlOrDirOrSqliteFile, ...toUpload], true)
2327
}

src/upload.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export async function upload (args: string[], internal = false) {
1717
for (const filepath_ of files) {
1818
let type = multicodes.RAW
1919
let filepath = filepath_
20-
if (filepath_[1] === '|') {
20+
if (internal) {
21+
// The `{type}|` prefix is used to determine which kind of CID is needed
22+
if (filepath_[1] !== '|') throw new Error('Invalid path format')
2123
switch (filepath_[0]) {
2224
case 'r':
2325
// raw file type

0 commit comments

Comments
 (0)