gun icon indicating copy to clipboard operation
gun copied to clipboard

gun.put(data, cb, opt) should not mutate opt

Open mimiza opened this issue 4 years ago • 1 comments

Hi! In the gun.put function (ie. gun.put(data, cb, opt), gun mutates "opt" object. This makes using SEA.certify difficult. Because instead of injecting certificate object directly in the put like this gun.put(data, null, {opt: { cert }}), people (including me) usually inject a ref to the certificate object, like this gun.put(data, null, cert). The first put is successful, but then gun mutates the "opt" object and that causes the next call to fail because "opt" now has been mutated and become a gun object.

So for now I'm having to use gun put + certificate like this:

const args = [data, null, {opt: { cert }}]
gun.get('~' + alice.pub).get('somewhere').put(...args)

mimiza avatar Feb 02 '21 13:02 mimiza

  • https://github.com/amark/gun/issues/1093

This is a longer discussion, cause its the difference between what gets passed over protocol, versus what is passed from the chaining API up to the root gun.js instance.

Good thing you reminded me about this, cause AXE probably has a bug that breaks this. So I need to rethink how to support both.

amark avatar Dec 16 '21 09:12 amark