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

ipfs.dag.put should be happy if i don't give it options #1395

Closed
whyrusleeping opened this issue Jun 12, 2018 · 5 comments
Closed

ipfs.dag.put should be happy if i don't give it options #1395

whyrusleeping opened this issue Jun 12, 2018 · 5 comments
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up

Comments

@whyrusleeping
Copy link
Member

simply running:

ipfs.dag.put(thing, (e, v) => {
  console.log(e,v)
})

Doesnt work right now, because it wants the put options struct.

@alanshaw alanshaw added kind/bug A bug in existing code (including security flaws) exp/novice Someone with a little familiarity can pick up status/ready Ready to be worked P2 Medium: Good to have, but can wait until someone steps up labels Jun 18, 2018
@fsdiogo
Copy link
Contributor

fsdiogo commented Jun 19, 2018

According to the dag.put spec the options are required. We could have some defaults to make it optional though.

@alanshaw
Copy link
Member

An options object should always be optional IMHO. This needs to be fixed.

@0x-r4bbit
Copy link
Contributor

@alanshaw I'd like to give this a spin in case nobody is working on this yet.

While looking into this, some questions came up regarding the testing environment:

  • Tests for this API are written in interface-ipfs-core, so I assume, this would be the place to a have spec that makes options optional (and introduces decent defaults)
  • However, tests are executed within the jsipfs repo, so to have this fixed and tested, we need to touch two repositories. What's your way to go about this? Shall I first send a PR to the interface repo and once landed and published have jsipfs depend on the newer version so it can fulfill the new spec?
  • As I'm new to this field, I can't say what those decent defaults would be. So any pointers on what the defaults should look like would be great.

Last but not least I noticed from the documentation that a subset of tests can be run using e.g.

test.dag(common, { only: true })

This doesn't seem to work, as npm run test:node:core still executes the entire core testsuite and basically ignores the only option.

I guess this is either a bug or I'm using the API wrong and probably this should be discussed in the interface repo. Hope you have some insights on that! :)

Thanks!

@alanshaw
Copy link
Member

@PascalPrecht that would be awesome if you had a go.

You can write your tests in interface-ipfs-core, and use npm link to enable you to run your tests against your code in js-ipfs.

At the moment I've not been able to merge the PRs that enable the only skip so for the time being if you branch off of #1389 then you should be able to rebase when it's merged (hopefully very soon).

Let me know if any of that is unclear!

@0x-r4bbit
Copy link
Contributor

@alanshaw thanks for the super quick feedback!

Everything's crystal clear 👌

PR in the making...

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jun 29, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jun 29, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jun 30, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jun 30, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 2, 2018
The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes ipfs#1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@ghost ghost removed the status/ready Ready to be worked label Jul 3, 2018
alanshaw pushed a commit that referenced this issue Jul 3, 2018
* fix(core/components/dag): make options in `put` API optional

The [dag.put](https://github.com/ipfs/interface-ipfs-core/blob/master/SPEC/DAG.md#dagput) interface
takes an options object which is required, but should be optional with
decent defaults.

See dedicated test here: ipfs-inactive/interface-js-ipfs-core#316

This commit implements this behaviour.

**Before**:

```js
ipfs.dag.put(obj, options, (err, cid) => {...});
```

^ Prior to this commit, without passing `options`, this call resulted in an error.

**After**:

```js
ipfs.dag.put(obj, (err, cid) => {...});
```

^ This is now perfectly fine.

Fixes #1395

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>

* chore: update interface-ipfs-core dependency

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
Development

No branches or pull requests

4 participants