Skip to content
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

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

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo changes to lines that are not needed for your PR.

store.doFetchIpnsKeys()
},

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo changes to lines that are not needed for your PR.

store.doFetchIpnsKeys()
},

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

doImportIpnsKey: (file) => async ({ getIpfs, store }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're missing an implementation of this function now

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)
},



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
Comment on lines -67 to -68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remove comments

const oldExpectedTime = store.selectExpectedPublishTime()
const avg = Math.floor((time * 1.5 + oldExpectedTime) / 2)
await writeSetting('expectedPublishTime', avg)