ipfs / js-ipns

Utilities for creating, parsing, and validating IPNS records

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't create new ipns record

darkrain opened this issue · comments

I try this code but my callback is not executed.

Why? may be i generate keys incorrectly?

const ipns = require('ipns');
const crypto = require('libp2p-crypto');


async function async(){
	const keys = await crypto.keys.generateKeyPair('RSA', 2048)

	ipns.create(keys, '/ipfs/QmNjRHSsT4Tj2nrvjaaGC1DmkQaV7Ec6gxZ34Qsrvqc2Zf', 0,'10000', (err, entryData) => {
		console.log(err)
		console.log(ipnsEntry);
	})

	
};

async()

Hey @darkrain

Can you confirm me that you are using libp2p-crypto@0.17.0?

Hey @darkrain

Can you confirm me that you are using libp2p-crypto@0.17.0?

Yep

So, the problem is that libp2p-crypto@0.17.0 uses the newest async API:

https://github.com/libp2p/js-libp2p-crypto/blob/master/CHANGELOG.md#features

In this context, when you do generateKeyPair, the resulting keys will have the sign function, which uses the new API. This way, js-ipns tries to sign using the oldest libp2p-crypto API, that is, using a callback. If you check the package.json in this repo, you can see that we have libp2p-crypto@0.16.0, which still works on a callback way.

TLDR: we are on a process of refactoring all our codebase to use an async API and get rid of callbacks.
Apparently, all the blocking dependencies to get this module refactored are already merged and released, so we will move with ipfs/js-ipns#19, which will fix this issue for you

@vasco-santos Thank you form Russia and our team)

@darkrain just released the new version of js-ipns@0.6.0.

Will close the issue now, but let me know if this did not solve your problem