Skip to content

Commit a82a598

Browse files
authored
fix: use wrapped feeds in download command (#633)
1 parent f6e988b commit a82a598

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/command/download.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { MantarayNode } from '@ethersphere/bee-js'
1+
import { Bytes, MantarayNode } from '@ethersphere/bee-js'
22
import fs from 'fs'
33
import { Aggregation, LeafCommand } from 'furious-commander'
4-
import { Bytes } from '@ethersphere/bee-js'
54
import { BzzAddress, makeBzzAddress } from '../utils/bzz-address'
65
import { Download as ManifestDownload } from './manifest/download'
76
import { RootCommand } from './root-command'

src/utils/bzz-address.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Bee, MantarayNode } from '@ethersphere/bee-js'
1+
import { Bee, MantarayNode, MerkleTree } from '@ethersphere/bee-js'
2+
import { Binary } from 'cafe-utility'
23
import { CommandLineError } from './error'
34

45
export class BzzAddress {
@@ -37,8 +38,10 @@ export async function makeBzzAddress(bee: Bee, url: string): Promise<BzzAddress>
3738

3839
const resolvedFeed = await manifest.resolveFeed(bee)
3940

40-
resolvedFeed.ifPresent(feed => {
41-
address.hash = feed.payload.toHex()
41+
await resolvedFeed.ifPresentAsync(async feed => {
42+
const merkleTree = await MerkleTree.root(feed.payload.toUint8Array())
43+
const cacAddress = Binary.uint8ArrayToHex(merkleTree.hash())
44+
address.hash = cacAddress
4245
})
4346

4447
return address

0 commit comments

Comments
 (0)