Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

chore: use multiformats sha3 impl #3772

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions examples/traverse-ipld-graphs/eth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,20 @@
const createNode = require('./create-node')
const path = require('path')
const { CID } = require('multiformats/cid')
const MultihashDigest = require('multiformats/hashes/digest')
const fs = require('fs').promises
const uint8ArrayToString = require('uint8arrays/to-string')
const { convert } = require('ipld-format-to-blockcodec')
const sha3 = require('js-sha3')
const { keccak256 } = require('@multiformats/sha3')

async function main () {
const ipfs = await createNode({
ipld: {
codecs: [
...Object.values(require('ipld-ethereum')).map(format => convert(format))
],
hashers: [{
name: 'keccak-256',
code: 0x1b,
digest: async (buf) => {
return MultihashDigest.create(
0x1b,
new Uint8Array(sha3.keccak256.arrayBuffer(buf))
)
}
}]
hashers: [
keccak256
]
}
})

Expand Down
4 changes: 2 additions & 2 deletions examples/traverse-ipld-graphs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"test-ipfs-example": "^3.0.0"
},
"dependencies": {
"@multiformats/sha3": "^2.0.0",
"ipfs": "^0.56.0",
"ipld-ethereum": "^6.0.0",
"ipld-format-to-blockcodec": "0.0.1",
"ipld-git": "^0.6.1",
"js-sha3": "^0.8.0"
"ipld-git": "^0.6.1"
}
}