GithubHelp home page GithubHelp logo

oip's People

Contributors

bitspill avatar cchrysostom avatar orpheus avatar ostlerdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oip's Issues

Only support full RFC6902 in OIP042 Edits

As MLG has been using the OIP042 Edit spec for the past month or two, we have occasionally ran into an issue with how Edits use a Squashed version of the RFC6902 Patches.

While squashing the patch works in most instances, there are a couple specific semi-common cases that the squashed patches cannot handle. The main issue occurs when multiple items are being added to an array, as if there are multiple add operations for an Array, and they are “appending” the data, the squashed patch format will only pick up on one of the adds and ignore the second. The additional issues stem from how RFC6902 patches are Sequential, and how the Squashed Patch format removes any ordering.

The main bug logic can be demonstrated as follows using js-oip. Notice how we lose the “add” for “three”.

let rfc6902Patch = edit.createRFC6902Patch({ field: [ 'one', 'two' ] }, { field: [ 'two', 'three', 'four' ] })
// rfc6902Patch = [
//    {"op": "remove", "path": "/field/0"}, 
//    {"op": "add", "path": "/field/-", "value": "three"}, 
//    {"op": "add", "path": "/field/-", "value": "four"}
// ]
let squashedPatch = edit.squashRFC6902Patch(rfc6902Patch)
// squashedPatch = { 
//    "add": { "/field/-": "four" }, 
//    "remove": ["/field/0"] 
// }

We propose that we retroactively remove support for the Squashed Patch format from js-oip and OIPd and only support patches containing a full RFC6902 formatted JSON Patch. MLG would then publish "replacement" edits for records that we have already edited. We at MLG think this way forward would be simplest for the long term support of OIPd, in order to prevent having to maintain the squashed patch format forever.

Currently MLG is the only user of OIP042 Edits, so this should luckily not affect anybody else.

We propose that the format of an OIP042 Edit be defined as the following:

{
  "oip042": {
    "edit": {
      "artifact": {
        "artifactID": "string",
        "timestamp": integer,
        "patch": // RFC6902 JSON Patch https://tools.ietf.org/html/rfc6902
      },
      "signature": "string"
    }
  }
}

An example edit would look like:

{
  "oip042": {
    "edit": {
      "artifact": {
        "artifactID": "a66b77ec997a72b649fd8e2e256f39f698b914c8c35ea87dc6b0ffb7c2fd8c29",
        "timestamp": 1567526939603,
        "patch":[
          {"op": "remove", "path": "/field/0"}, 
          {"op": "add", "path": "/field/-", "value": "three"}, 
          {"op": "add", "path": "/field/-", "value": "four"}
        ]
      },
      "signature": "IPra1n/c8Zd76cTwNMgM6I4SVc/r6MBo+KQdVoWoOxi8JZvGMmjYO/gazJl0llZoiAQ+BBNYrDGYfHnAJYUywMA="
    }
  }
}

Mark Edits as Broken

Currently there is no code that will mark an Edit as broken and prevent it from being processed in the future. This is a feature that still needs to be implemented, but is currently a lower priority.

You can find more discussion about the work that needs to be done, and the reasoning behind it, right here: #13 (comment)

better error code

differentiate between "insufficient funds" and when there is a mismatch between the payer and the signer, in such a case return "payer/signer mismatch"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.