Coder Social home page Coder Social logo

unlock-protocol / unlock Goto Github PK

View Code? Open in Web Editor NEW
821.0 34.0 238.0 708.48 MB

Ʉnlock is a protocol for memberships built on a blockchain.

Home Page: https://unlock-protocol.com

License: MIT License

JavaScript 16.70% Shell 0.57% Dockerfile 0.05% TypeScript 44.00% HTML 0.03% CSS 0.02% Solidity 38.62%
ethereum solidity javascript unlock blockchain protocol memberships nft infrastructure

unlock's Introduction

Unlock Unlock


This repository includes all the code deployed by Unlock, including smart contracts and the web app running at unlock-protocol.com.

Unlock is a membership protocol, built on a blockchain. It enables creators to monetize their content or software without relying on a middleman. It lets consumers manage all of their subscriptions in a consistent way, as well as earn discounts when they share the best content and applications they use.

Read more about why we're building Unlock.

License: MIT

Demo

You can try Unlock using the Ethereum blockchain on our homepage.

We are building this in the open, which means you can also run the code locally (see instructions below). You can try out the staging version - which runs the latest, in-progress code, but against the Goerli test network.

Contributing

Thanks for your interest in contributing to Unlock! We're excited you're here. There are a variety of ways to contribute to the project. Please read more about contributing in our contributor guide. Please also check our code of conduct for all participants in our community.

Getting started

The code

Unlock uses a monorepo which includes all the services and applications we develop.


# get the code
git clone https://github.com/unlock-protocol/unlock
cd unlock

You'll need yarn installed globally.

yarn
# install all dependencies (...may take a while)

Build all packages:

yarn build

To execute commands inside the repo, we use the pattern yarn workspace <workspace name> <command>

# build the contracts
yarn workspace @unlock-protocol/smart-contracts build

# validate lint for paywall
yarn workspace @unlock-protocol/paywall lint

# etc.

The protocol

You can run a local version of the protocol using Docker.

cd docker && docker-compose up --build

This will create the required infrastructure (database, local ethereum test network, subgraph...) and start core services such as the Locksmith API and a Wedlocks mailing service for debug purposes.

NB: config is defined in both docker-compose.yml and docker-compose.override.yml.

Deploy and provision the contracts

The following script will deploy the contracts, create some dummy locks and send you some local tokens for development.

cd docker
docker-compose exec eth-node yarn provision

Run one of the app

The main dashboard lives in the unlock-app folder of this repo.

To launch it locally:

# install deps
yarn

# start Unlock main app
yarn workspace @unlock-protocol/unlock-app start

This will start

  • http://localhost:3000 to start using the application and deploy locks locally.
  • http://localhost:3002 our static landing page site.

Secrets

Secrets are stored in the Unlock Labs 1Password account in the API & Services Vault. They can be loaded in our Github Actions through the use of dedicated actions.

Here is an example:

steps:
  - name: Load secrets from 1Password
    uses: 1Password/[email protected]
    with:
      export-env: true
    env:
      OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
      USERNAME: op://secrets/test-api/username
      CREDENTIAL: op://secrets/test-api/credential
  ... more steps that require USERNAME and CREDENTIAL to be set

These reference URIs have the following syntax: op://<vault>/<item>[/<section>]/<field> So for example, the reference URI op://app-cicd/aws/secret-access-key would be interpreted as: Vault: app-cicd Item: aws Field: secret-access-key

Thank you

BrowserStack Logo

Thanks to BrowserStack for providing the infrastructure that allows us to test in real browsers.

Thank you to all the Members of our lock as well! You can easily join this list by clicking on the ❤️ Sponsor button (it's free!) at the top of this page too.

Members

unlock's People

Contributors

0xtxbi avatar adeelhasan avatar akeem avatar benwerd avatar ccarfi avatar cellog avatar chialit avatar chrisvanpatten avatar clemsos avatar cnasc avatar easyrun42 avatar greenkeeper[bot] avatar hardlydifficult avatar imac7 avatar jordang7 avatar julien51 avatar kalidiagne avatar m00n620 avatar nfurfaro avatar omahs avatar philmod avatar renovate[bot] avatar searchableguy avatar smombartz avatar sudheerdev avatar svell avatar teawaterwire avatar unlock-deployer avatar vikaskyadav avatar wonderwomancode 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unlock's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Stricter Lint rules

The current lint rules are fairly limited. We need a set of much stricter rules.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Allowing Lock owners to update the price of keys

The keyPrice for each Lock is set upon creation of the Lock smart contract.
We expect most creators to actually "price" the keys to their lock based on a fiat value ($ or else). As such we should allow creators to update the price of the keys (keyPrice) on the locks easily at any point. This will require additions to the Lock smart contract but also changes in the web app.

Show truncated balances

The balance on accounts is showing too many numbers. We need to only show relevant decimals.
If the user has more than 1Eth, let's show only 2 decimals.
If the user has less than 0.0001 Eth let's show < 0.0001 (about 2cts at current prices).
For anything in between, let's show at most 2 non zero values.

Smart Contracts Improvements

The current smart contracts are extremely basic and present a large number of challenges.

  1. Unlock smart contract needs to be upgradeable, without losing the "link" from the Locks
  2. Most of the Lock "code" should actually be shared between all deployed locks so we can save on gas
  3. Locks themselves do not need to be upgradeable but we should assume that newer versions of the Lock smart contract will be deployed over time
  4. Gas fees: we should ensure that gas fees are minimal for all Lock actions

Show name of network on interface...

When a user visits an unlock-protocol.com page they should instantly see which Ethereum network is being used (Main net, Rinkeby, Ropsten...)

Ideally this would take the form of a small persistent label at the bottom or top of the screen.

Unlock dashboard doesn't release local storage cache

Describe the bug
The web dashboard doesn't update based on completed transactions. The values for balance, outstanding tokens, and amount to withdraw stay static unless action is taken to force the dashboard to release the cache.

To Reproduce
Steps to reproduce the behavior:

  1. Visit the dashboard.
  2. Perform a balance-changing action such as purchasing a key - or simply change your network in Metamask.
  3. Reload the page.
  4. Note that the values have not updated as expected.

Expected behavior
On each reload, the Unlock dashboard should reflect current confirmed transactions on the current network.

Desktop (please complete the following information):

  • Chrome on OSX

Infinite number of keys!

Locks have the ability to have an infinite number of keys.
We should implement that feature both in the UI and the smart contract.

Hover state on icon is broken

On the layout icons, the over state should not be solid blue but should also show the actual icon for the button.
screen shot 2018-10-11 at 11 51 21

Is there a way to test hover states with storybook?

Documentation site

As an open source project, we should have a well-described documentation site, as well as in-line code documentation.

I recommend using Read the Docs to establish a documentation site at docs.unlock-protocol.com, which would be configured to automatically rebuild from markdown files stored in the Unlock repository itself. New commits to master would automatically rebuild the documentation site.

For in-line documentation, I think we should use JSDoc-style syntax, which can then be automatically compiled into a reference site.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Ether Symbol & Monaco Font

@benwerd I looked into why the design specified the Manaco font (which it shouldn't). The Eth symbol isnt available in Plex (the font we're using) and hence it reverted to Monaco. I've created an SVG which you call pull from Zeplin or from here

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Rename Provider

The Provider component has a name that could easily be confused with Redux's own <Provider> tag, which is a bit confusing now but could lead to larger issues down the road. Already it's forcing us to use import { Provider as ReduxProvider } or a similar alias in cases where both could be used.

I suggest giving it a more descriptive name - eg Web3Provider.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Upgradability for the Unlock Smart Contract

Some characteristics of the smart contract (variables such as max available discount %... etc) will need to be modifiable by the smart contract owner.

However, we may also need to upgrade the logic in the smart contract. In that context, it may be useful to have a way to upgrade it.

In that context, we should explore the proxy patterns exposed by Zeppelin.

One of the key challenges though is that this needs to ensure that all deployed Locks are also pointing to the current version of the Unlock smart contract.

Enforce rinkeby on staging.unlock-protocol.com

In order to avoid mistakes we should enforce networks on different versions of Unlock.
In dev, enforce the use of a local testnet, on staging, enforce Rinkeby... and on the main site, enforce the use of the main net.

Server side rendering

Multiple "pages" from the application need to be rendered on the server. This will allow for better SEO but also for tools to extract data. For example the home page, about page and jobs page should be rendered on the server side.

It is important though that we let react "rehydrate" these pages once loaded so that the regular react app takes over and resumes once the pages have been loaded by a web browser.

Customize position of circles

In order to get more unique lock icons we should also position (x, y and z) the inner circles


* @todo Customize position of circles
* @body In order to get more unique lock icons we should also position (x, y and z) the inner circles
* more uniquely based on the lock address... the challenge is to not have any white space.
* @param {lock} lock
*/
const Icon = ({ lock }) => {


This issue was generated by todo based on a @todo comment in b31941a when #216 was merged. cc @unlock-protocol.

"Refreshing" data from localStorage

Since we do not have a server side component for now, we use the blockchain as the source of truth and store (cache!) data using localStorage.
We use a redux middleware to make sure that our redux store is always 'synced' to localStorage.

The challenge is that data might have changed in the blockchain while the app is not running on the front end, and we need a mechanism to "sync" the redux store again after the web application has loaded.

Tests coverage

We need a way to run full test coverage across all code and include coverage on the main README page.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

A better CI setup

We are using Travis-CI to run our tests on Pull Requests.
The current setup involves using docker-compose to build an setup in which we can do tests. This setup has 2 services:

  1. ganache-cli which runs an instance of ganache
  2. a container with all the Unlock code with a single command to run all the tests from tests.sh.

When adding new test suites (we currently only test smart-contracts and unlock-app) you need to update tests.sh.

The travis-ci config is "strange":

before_install:
- docker-compose -f docker/docker-compose.ci.yml build
- docker-compose -f docker/docker-compose.ci.yml up --abort-on-container-exit

We first build the cluster: so far so good, but then we also run it and ask it to terminate when a container exits. That second instruction should probably not in before_install. Also we should probably terminate properly.

This setup is probably what is causing #194? (the error does happen but for some reason test.sh continues it execution...

Finally, running CI already takes about 5 minutes while this is a very early project. There are ways to optimize that building process.

Documentation and use cases.

Great project, just wondering if you have some early docs you can share and maybe a document showing some possible alternative use cases apart from a publishing paywall.

Thanks!

ERC721 compatibility

The current implementation of the Lock smart contract is not fully compatible with the ERC721 spec.
The main reason for this is that we use the owner's address as the tokenId which means that when ownership is changed, the tokenId itself is changed, which is not how the spec works.

One approach would be to actually have unique tokenId for each key, but that would incure more gas fees. Is there any other option to achieve this?

Enable "consistent" mining

When developing locally with ganache-cli, we currently have a setting which only mines transactions "on demand". This means that transactions are immediately mined and that they are also immediately confirmed.

This is not consistent with the deployments on both rinkeby and the main network. We should then change that setting so that blocks are mined consistently, even when they're empty.

A good default would be one every 3 seconds for example.

Detect when Metamask is locked

Metamask is "locked" by default, we should be able to detect that and show an error to the user asking them to unlock it.

default account

There should always be a default account which the user can switch away from to another one.
It should be set when the network connects (if none is previously set)

Multiple Lock types/smart contracts

At this point we have only a single Lock smart contract which covers multiple use cases (Public, Private, Restricted...).

A better approach would be to have a single Lock interface which implements the "core" behavior of the Unlock protocol and then have multple contracts PublicLock, PrivateLock, RestrictedLock which would have different characteristics.
This would allow for lower deployment costs and maybe easier maintainability.

save name to the redux store

handleSubmit () { // TODO save name to the redux store
const lockParams = {
keyReleaseMechanism: this.state.keyReleaseMechanism,
expirationDuration: this.state.expirationDuration * this.state.expirationDurationUnit,
keyPrice: Web3Utils.toWei(this.state.keyPrice.toString(10), this.state.keyPriceCurrency),
maxNumberOfKeys: this.state.maxNumberOfKeys,


This issue was generated by todo based on a TODO comment in 42fa9d7 when #319 was merged. cc @unlock-protocol.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Upgradable Unlock Smart Contract

The Unlock smart contract needs to be upgradable, without changing its address and its data (balances of Unlock points or deployed Locks).

The Unlock.sol smart contract has 3 main purposes:

  • Deploy locks and keep track of them
  • Keep track of the the Discount Token supply: grant them upon referrals.
  • Grant corresponding discounts on key purchases

A lot of the logic will be implemented later and will be adjusted as we make progress in understanding how the Unlock network is functioning. For that reason, it is important that we use an Upgradeable approach so that we can incrementally add and update the functionality of that smart contract.

For this we want to use the "Unstructured Storage Proxy" described by @leanthebean in this article

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.