Skip to content

feat : adds functionality to import and export IPNS keys in the IPFS WebUI #2348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"save": "Save",
"cancel": "Cancel",
"enable": "Enable",
"disable": "Disable"
"disable": "Disable",
"import": "Import Key"
},
"edit": "Edit",
"visitService": "Visit service",
Expand Down
17 changes: 13 additions & 4 deletions src/bundles/ipns.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ const ipnsBundle = {
doRemoveIpnsKey: (name) => async ({ getIpfs, store }) => {
const ipfs = getIpfs()
await ipfs.key.rm(name)

store.doFetchIpnsKeys()
},

doRenameIpnsKey: (oldName, newName) => async ({ getIpfs, store }) => {
const ipfs = getIpfs()
await ipfs.key.rename(oldName, newName)

store.doFetchIpnsKeys()
},

Expand All @@ -63,9 +61,20 @@ const ipnsBundle = {
await ipfs.name.publish(cid, { key })
},

doImportIpnsKey: (file) => async ({ getIpfs, store }) => {
const ipfs = getIpfs()
const reader = new FileReader()
reader.onload = async (event) => {
const key = event.target.result
await ipfs.key.import(file.name, key)
store.doFetchIpnsKeys()
}
reader.readAsText(file)
},

// moderate expectation: publishing should take no longer than average
// between old expectation and the length of the last publish + some buffer
doUpdateExpectedPublishTime: (time) => async ({ store, dispatch }) => {
// moderate expectation: publishing should take no longer than average
// between old expectation and the length of the last publish + some buffer
const oldExpectedTime = store.selectExpectedPublishTime()
const avg = Math.floor((time * 1.5 + oldExpectedTime) / 2)
await writeSetting('expectedPublishTime', avg)
Expand Down