Giter Club home page Giter Club logo

drive's Introduction

Fission logo

Powering Microservices for Web3

FISSION is a set of useful status codes and translated messages to connect smart contracts of all kinds 🔌

Build Status Maintainability Coverage Status
ERC-1066 ERC-1444 ECIP-1050 Built with ❤ by SPADE Co

Quickstart

npm install --save fission-codes
// Solidity
pragma solidity ^0.5.0;
import { FISSION } from "/fission-codes/contracts/FISSION.sol";
// JavaScript
const fission = require("fission-codes");

Table of Contents

TL;DR

FISSION helps developers understand and build interoperable smart contracts. It establishes a common vocabulary for smart contracts to interact with a rich set of messages to tag data and common situations. It has applications in state transfer, development tooling, instrumentation, and user messaging.

  1. Improved feedback for humans (end users and developers alike)
  2. Helping developers understand their code at runtime
  3. Enhanced smart contract interoperability and autonomy

Motivation

The very essence and power of having a shared platform like a programmable blockchain is how it facilitates the flow of information. We pay for this abstraction with a speed penalty, but at the application layer there is no need to worry about the common issues in distributed systems: availability, stale state, locked data, and so on. This is an oft-overlooked advantage of this technology, so let’s make the most of it!

Not to be confused with a fluent interface, FISSION can be seen as a fluid interface — an common interface flowing between nodes. This stands in contrast to the concrete interfaces that we commonly see today on Ethereum: method signatures. These are not mutually exclusive concepts, but rather two halves of a very powerful whole!

The core of the FISSION is status codes. These provide the common interface to build messages, flows, and protocols from. This strategy isn’t limited projects under the FISSION umbrella; everyone is encouraged to build robust protocols from these building blocks!

The idea is very simple: 256 codes organized as a 16x16 table. The columns are categories (ex. permissions, time, off-chain, etc), and the rows are reasons (ex. failure, success, informational, required action). They are passed around as the first value in a multi-value return, or as an argument to a function.

This library makes it easy to construct codes, inspect them for conditions, automatically revert on failures, retrieve human-readable localizations, and so on.

Contract Autonomy

Smart contracts are largely intended to be autonomous. While each contract may define a specific interface, having a common set of semantic codes can help developers write code that can react appropriately to various situations.

In the above diagram, the dotted arrows are requests (or calls). The rest are responses (or returns) that contain FISSION codes: green arrows are success responses, and orange arrows are neither successes nor errors. By convention, the code is the first value in a request or multiple return.

Semantically Rich

HTTP status codes are widely used for this purpose. BEAM languages use atoms and tagged tuples to signify much the same information. Both provide a lot of information both to the programmer (debugging for instance), and to the program that needs to decide what to do next.

FISSIONs convey a much richer set of information than booleans, and are able to be reacted to autonomously unlike arbitrary strings.

User Feedback

Since status codes are finite and known in advance, we can provide global, human-readable sets of status messages. These may also be translated into any language, differing levels of technical detail, added as revert messages, natspecs, and so on.

We also see a desire for this in transactions, and there's no reason that FISSIONs couldn't be used by the EVM itself.

Web3 Microservices

Shared multi-user systems like Ethereum should lend themselves to easily sharing data. Data is decentralized in the sense that we don’t have one giant database with open access. Unlike how we can use on-chain libraries to share functionality (rather than redeploying the same classes over and over), the true value of most applications is the data that they contain. Unfortunately, the majority of bespoke architectures silo data behind access control and programmatic interfaces with only brittle and limited options for requesting this data. We need a way to help data flow between these silos.

Smart contracts decompose into two parts that may be of interest to others: behaviour and data. Behaviour on its own may be deployed to the network as a library. They are very flexible chunks of code that may be verified by the community as safe to use. In fact, this is arguably safer than even redeploying it from your own contract, since you have certainty about that exact bytecode.

Unlike behaviour, data is owned by particular contracts, and depends on a program to get and set values. The data itself may be valuable to other contracts (ex. a token balance or authorization). Rather than duplicating this data, a single home is both efficient and convenient. For any stateful data, this is obviously something that must live on chain rather than being redeployed.

Requesting data comes with its own set of use cases: access control, a missing value, expiration, out of range, and so on. Any smart contract that needs to request data from a collaborator (ie: lots of contracts) can leverage FISSION helpers to make it easy to autonomously handle these use cases without writing reams of code, or demanding human intervention.

This has been described as "microservices for web3". It is complementary to concrete interfaces (like ERC20). method interfaces are primarily mechanical (the “how”), data and status codes are primarily semantic (the “what”).

Example

Scenario

It's common for one group of users to make use of several contracts. It would be useful to register this information once, and share it among many different contracts, rather than duplicating this information across many places (with potential inconsistencies).

For instance, if a teammate is promoted to admin status, this should be reflected across all of the shared contracts. Likewise, if someone is banned, it is much easier to make this change once and rest assured that it covers all of our contracts.

Smart Contracts

Here is a contract that consolidates member rights in one place for this group of users. It returns a common set codes from FISSION as a simple way of communicating with other contracts (primarily about permissions).

pragma solidity ^0.5.0;

import { FISSION } from "fission-codes/contracts/FISSION.sol";

contract SimpleAuth {
    enum Level {
        Banned,
        Unregistered,
        Member,
        Admin
    }

    mapping (address => Level) private auth;

    constructor() public {
        auth[tx.origin] = Level.Admin;
    }

    function min(Level minLevel) public view returns (byte status) {
        if (auth[tx.origin] == Level.Banned) { return FISSION.code(FISSION.Status.Revoked); }
        if (auth[tx.origin] < minLevel) { return FISSION.code(FISSION.Status.Disallowed_Stop); }
        return FISSION.code(FISSION.Status.Allowed_Go);
    }

    function set(address who, Level level) public returns (byte status) {
        require(auth[tx.origin] == Level.Admin, "Must be an admin");
        auth[who] = level;
        return FISSION.code(FISSION.Status.Success);
    }
}

There may be many collaborator contracts. Below is a portfolio controlled by the SimpleAuth members.

pragma solidity ^0.5.0;

import { FISSION } from "fission-codes/contracts/FISSION.sol";
import { SimpleAuth } from "./SimpleAuth.sol";

contract Portfolio {
    SimpleAuth private auth;
    mapping (address => bool) private holdings;

    constructor (SimpleAuth control) public {
        auth = control;
    }

    function isHeld(address token) external view returns (byte status, bool held) {
        byte permission = auth.min(SimpleAuth.Level.Unregistered);
        if (FISSION.isBlocking(permission)) { return (permission, false); }
        return (FISSION.code(FISSION.Status.Found_Equal_InRange), holdings[token]);
    }

    function setTracking(address token, bool track) external returns (byte status) {
        FISSION.requireSuccess(auth.min(SimpleAuth.Level.Member));
        holdings[token] = track;
        return FISSION.code(FISSION.Status.Success);
    }
}

Resources

Documentation

Standards

This library contains implementations of these standards:

Ethereum Improvement Proposals (EIP)

Ethereum Classic Improvement Proposals (ECIP)

Articles

Discussions

Presentations

@expede presenting FISSION at Devcon IV

FAQ

Is this like HTTP status codes?

They're similar! FISSION is more structured and designed for smart contract use cases. Blockchains have different constraints than the web, and the design of FISSION reflects that!

Does this replace revert-with-reason?

Not at all! FISSION fully supports revert and revert-with-reason, and this library has several functions that make it easy to combine the two. Sometimes it makes sense to return a regular status code, and let the caller decide if it should revert. Of course you should immediately revert if there’s an overflow, or find ourselves with nonsensical state.

Is FISSION an acronym? What does "FISSION" stand for?

"FISSION" stands for the Fluid Interface for Scalable Smart Contract Interoperable Networks.

Badge

Feel free to put this badge on your FISSION-compatible projects to let others know that they can interop easily with your contracts!

FISSION compatible

<!-- README.md -->

[![FISSION compatible](https://github.com/fission-suite/fission-codes/raw/master/static/FISSION-badge.svg?sanitize=true)](https://fission.codes)
<!-- website.html -->
<a href="https://docs.fission.codes/fission-codes/"
  ><img
    alt="FISSION compatible"
    src="https://github.com/fission-suite/fission-codes/raw/master/static/FISSION-badge.svg?sanitize=true"
/></a>

Featured On

Sponsors

drive's People

Contributors

agentofuser avatar bgins avatar bmann avatar dependabot[bot] avatar dholms avatar expede avatar icidasset avatar matheus23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

drive's Issues

File Operations

Implement all the basic file system interactions:

  • Add file
  • Drop files
  • Create directory
  • Remove file
  • Remove directory
  • Rename file
  • Rename directory
  • Select a single file
  • Select a single directory using arrow keys
  • Select a single directory using shift key + left mouse click
  • Select multiple items using shift key + left mouse click (range select)
  • Select multiple items using cmd/meta key + left mouse click (individual select)
  • Move selected items (files & directories) using drag & drop
  • Duplicate (and show rename modal?)

Lookup By DNS

NB: Feature requests will only be considered if they solve a pain

Summary

Lookup a hash by a DNS record root. For example: searching boris.fission.name would lookup the CID, and use it.

Bonus points for adding this to the URL: drive.fission.name/#/boris.fission.name/foo/bar/baz

Keep path on a single line

Problem

If a path is too long, it'll be broken up over multiple lines.
That doesn't look too good.

Screenshot_2020-03-27 Fission Drive

Solution

Ideally, if the path doesn't fit on the screen (on one line), we'd switch to the "mobile version" where only the last part of the path is shown.

Not sure how we can easily achieve that though. Maybe some formula consisting of the width of the container, the amount of characters in the path, ...

Selecting "link to file" from a "link to Drive" page duplicates the file in the path

I'm on this page, which I got from picking "link to drive page":

https://drive.fission.codes/#/events.fission.name/2020/04-16-dweb-lunchnlearn-joel-ceramic-network/index.html

Then I select "link to file", and get this incorrect link:

https://ipfs.runfission.com/ipfs/QmSGGeGZXK9Ayx5wgG883gQeU39tdoUM8vt6Uzdh3uMJDc/2020/04-16-dweb-lunchnlearn-joel-ceramic-network/index.html/index.html

Seems to double up the file for any file so SOMEFILE.jpg/SOMEFILE.jpg, tried it for images and a js file.

Initial file-system setup

The issue with the initial setup is that the DNSLink address is not available yet. So when we create the initial file system and update the data root using the api, we should probably wait with the data-root update until the dnslink is available?

No Action Cancellation

Summary

Problem

While waiting for a load (Item A), I click something else (Item B). Item B displays. When the Item A finishes loading, I'm directed to Item A.

Impact

Unexpected / surprising behaviour

Solution

Cancel the first action when a second action is requested

Web-based Signup

Implement web-based signup with private keys

  • username / email
  • WebAuthN support -- need a biometric; on (eg) Chromebook, will need a Yubikey
  • non-WebAuthN, generate a key in storage using ZeroWallet

Need to use ZeroWallet approach (ask for passphrase), because IndexDB for example -- is scoped PER DOMAIN. @dholms will help complete ZW for this epic.

For ZW, needs a passphrase.

@expede mentions key stretching.

Account is in unverified state (Pre-Acquisition phase). Send email to verify email.

Once email is verified, we mark that user as "Acquired".

SendInBlue has Transactional Email that we could use to power the email verification. Probably we will also do the ask permission for product updates email. In any case, we will message that we DO need to send email for account updates on our service.

Add pop up help / support / chat

Was using Roam Research, and they have a little built in help that slides up when you click a floating question mark in the bottom left hand corner of the screen:

Screenshot 2020-04-05 21 10 53

When it slides up, it also reveals an Intercom chat icon. I like this approach, when a user is looking for help (by clicking on the question mark), they can transition into seeing a quick preview of commands, or move into chatting / sending email for more support.

I'd like to see us implement this, using Missive Chat.

I'd still like to use Missive in the support page, too fission-codes/landing-page#19

Private Folder

Problem

All of a User's files are exposed to the public

Solution

Add a "Private" section to drive that is only available after authorization with auth.fission.codes

Reliant on:

URI escape file names

When you get "Link to file", the file includes characters like spaces, for example:

https://ipfs.runfission.com/ipfs/QmcPq2kUHvVfouFb2BJz8xxuDHe4KJtuiNKwSZenDso6Vf/public/Screenshots2/Screen Shot 2020-05-04 at 1.07.58 PM.png

Browsers mostly do the right thing and automatically convert the spaces to %20, but probably we want to URI escape this ourselves when generating the links.

Implement service worker support for IPFS

I'll start with the big part. IPFS Companion is a browser extension. Extensions run in the main web UI thread. Service / web workers run in their own thread.

To improve performance of Drive, we could implement a service worker version of IPFS running in the browser.

This would not be compatible with IPFS Companion, so this means dropping support for IPFS Companion. It has about 20K installs and lets users run a local IPFS node.

Since we focus on making our services work web native in all browsers, even if they use some cutting edge tech, relying on extensions isn't in line with our goals.

The problem is that we need a separate ipfs daemon in every webpage. So, performance when running multiple apps / across multiple domains may be an issue.

Relevant discussions from IPFS land:

Social share previews for drive through metatags

Summary

Problem

drive.fission.codes has minimal social share info displayed when pasted into Twitter, Facebook, Slack, Discord, etc.

For now, this issue should just be about the home page. OEmbed server side support for rich unfurls in Slack of directories or files and embedding is a larger issue.

Impact

The gloriousness of Drive isn't shared on social.

Solution

Add OG and twitter card details to metatags.

Decrease ipfs-js size

Right now ipfs.js is 5.6MB. get-ipfs isn't much better (2.22MB since we're getting the minified version).

After talking with Hugo at Diffusion, the vast majority of that is different IPLD formats, nearly all of which we aren't using.

I believe ipfs-provider is more flexible in regards to which IPLD formats you import.

I mostly wanted to flag this since at some point we'll want to do one of the following:

  • make a custom smaller ipfs.js
  • update get-ipfs to be flexible around IPLD formats
  • fork ipfs-provider, add features that we need (such as es6 syntax)

Add a flag for a personal-domain mode

Problem

We'll add the Drive app by default to a user's personal domain (eg. bob.fission.name) with the file-system DNSLink at files.bob.fission.name). Currently drive puts the DNSLink in the hash of the url, but for this to work we need to construct it based on the host/domain.

_dnslink.files.bob.name  -> TXT /ipfs/ffs-hash
_dnslink.bob.name        -> TXT /ipns/drive.fission.codes
_dnslink.my.app          -> TXT /ipfs/some-hash

Solution

Add a flag, or some other indicator, that puts Drive in this mode. Essentially transforming the url parsing part to that described above.

Add a simple share widget

Or use the Web Share API when available (only iOS atm).

A simple widget could be a textfield with the url in it,
and a small button that would copy that to the clipboard.

Session restore doesn't include route

Summary

Problem

When I reload drive.fission.codes after previously looking at it, I'm on the last directory I looked at, but the URL has no route

Solution

Update the /# to include the route that you're at

Support .webloc files

.webloc files are Apple created "bookmarks" that are mostly created from dragging and dropping from the address bar of a browser.

I'd like a way to store bookmarks / links in Drive, and I think Apple's format is the most simple.

In this case, "supporting" .webloc files might mean:

  • instead of "download" in the preview, have it say "open this website" and link to the link
  • displaying an iframe with preview of the link?

Load IPFS script async

Have the app load first, then load js-ipfs (or whatever ipfs thing) and when js-ipfs is loaded, start setting up the ipfs-related things.

User themes

Users would like to customize the look of their drive app.

Current Solution

Currently we have a light and dark theme that changes based on the user's system preferences.

Preferred Solution

Not sure how to approach this. Where do we draw the line?
If they define a theme, is it a fixed light or dark theme?
Does a theme have to define both?

Maybe something like this ...?

accent: ...
accent_background: ...
body_background: ...
body_text: ...
subtle_text: ...

And finally, how would these themes be applied?

Should be able to get shareable url for videos

I removed the on-hover overlay for videos, because otherwise you wouldn't be able to start the playback. So we need another solution here. Example, add a right-click menu to the list which has an option to get a shareable link.

For directories with large numbers of files, figure out interface

For directories with large numbers of files, it takes a long time to load all of the files, and then it's not very useful.

Here's an example: https://drive.fission.codes/#/QmYGs1ksGX3eMiGvxNuvRT6PD7zPKZpHyiUDXKGQoL4R7S

This is a folder containing HLS encoded video files. If you scroll to the bottom, you get 410 Files (349.39 MB) as the summary.

We might want to only show XX files, and then implementing paging or lazy loading or search to filter down the total.

The summary of total files / size -- maybe even average / median file size could be interesting -- would be good at the top / in view.

File Explorer

Just for public files, before we do all of the crypt-tree stuff. Essentially a prettier version of the IPFS gateway on directories.

Feel free to use existing JS/TS/Elm file explorer templates

  • Display files such as images
  • Download files
  • List files in directories
  • Show metadata (e.g. file size) Maybe toggle-able
  • Navigate to child directories
  • Navigate to parent directories

Create Folder

Problem

No way to create folders in Drive UI

Solution

  • Add a "New Folder" button or similar
  • Use the soon to be added helper functions from ts-sdk (oddsdk/ts-odd#5)

Upload Files

Problem

Users should be able to add files to their Drive from the Drive UI

Solution

To do

Minor stuff that can be done/fixed later:

  • Loading animation looks weird on iOS Firefox (sometimes)
  • On mobile resolution, you should be able to click away the details overlay
  • Using the path in the header doesn’t show a loading animation, so if the loading takes a while the user doesn’t know
  • Add a better app icon
  • Add shadows on the top and bottom of the list (so you can see the list continues in that direction)
  • Put file-extension tag at the end of the row or underneath the icon
  • Sticky directory stats? So you see the stats at all times.

Embed directories

Summary

I want to show the contents of a directory in a blog post, so people can get a sense of what the contents are.

Today, I screenshot the folder and then link the image to the live view in Drive.

See https://drive.fission.codes/#/QmYGs1ksGX3eMiGvxNuvRT6PD7zPKZpHyiUDXKGQoL4R7S and https://blog.fission.codes/experimenting-with-hls-video-streaming-and-ipfs/ for examples of this.

I'm specifically calling this embed directories, as I think that embedding individual files is a different problem space.

Directories of images become mini-galleries, directories of audio files become mini-playlists, depending on further options to display content differently.

Drive Widget

One way to solve this would be to write a small chunk of javascript.

As an example, here is the documentation for the Tito ticketing widget https://ti.to/docs/widget

For Drive, a Share option would have an Embed option, and then display a chunk of code that can be cut/paste.

Downside of this is that this would only work for platforms that allow for HTML/JS widgets.

OEmbed Support

A general solution that would make this work in anything that supports OEmbed -- and would extend to individual files -- would be to add OEmbed support for Drive. That needs to be written up and researched in detail, as it may mean needing to run a proxy at drive.fission.codes alongside the go-ipfs gateway.

This has a fair amount of operational complexity in needing to write new code and run an OEmbed server.

The upside is that any application that supports OEmbed will "just work" when Drive links are pasted in, and show a rich preview for different directory and file types.

Medium being one big publishing example that is widely used.

Further Thoughts

How could this be implemented in such a way that any Fission app could easily do embedding, in a way that Fission services provide central support?

Keyboard shortcuts

Easy to add.

Some ideas:

  • Arrows to navigate between items in the menu
  • Escape key to close preview
  • Backspace to go up a directory

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.