GithubHelp home page GithubHelp logo

pannu5788 / widget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from access-labs-inc/widget

1.0 0.0 0.0 1.21 MB

Web widget for ability to stake/unstake on creator's pool

License: MIT License

JavaScript 3.52% TypeScript 88.80% CSS 5.69% HTML 1.98%

widget's Introduction

ACS Web Widget

This is a web widget to help you integrate with ACS protocol.

Usage

In order to embed the widget add the following snippet at any location on the hosting page:

<head>
  <!-- Import the styles from us or provide your own -->
  <link rel="stylesheet" href="https://d3bgshfwq8wmv6.cloudfront.net/acs-widget-staging/main.css" /> 
</head>
<body>
  ...
  <div id="acs"></div> <!-- <= Place where the ACS button will show -->
  ...
  <script>
    (function (w, d, s, o, f, js, fjs) {
        w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
        js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
        js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs);
    }(window, document, 'script', '_acs', 'https://d3bgshfwq8wmv6.cloudfront.net/acs-widget-staging/widget.js'));
    _acs('init', {
      element: document.getElementById('acs'),
      poolId: 'Fxh4hDFHJuTfD3Eq4en36dTk8QvbsSMoTE5Y2hVX3qVt',
      poolName: "The Block",
    });
    // Here's how you listen for connected wallet and you'll receive:
    // { address: string; locked: number, airdrop: number }
    // address - user's wallet address
    // locked - amount of ACS (with decimals) locked against your pool
    // airdrop - amount of ACS (with decimals) airdroped against your pool
    // ----------------------------------------------------------------
    // NOTE: To get ACS withtout decimals divide the numbers by 10 ** 6
    document.querySelector("#acs").addEventListener("connected", (event) => {
      console.log("Connected to the wallet: " + JSON.stringify(event.detail));
    });
    document.querySelector("#acs").addEventListener("lock", (event) => {
      console.log("Connected to the wallet with address: " + JSON.stringify(event.detail));
    });
    document.querySelector("#acs").addEventListener("claim", (event) => {
      console.log("Connected to the wallet with address: " + JSON.stringify(event.detail));
    });
  </script>
</body>

You can find a full list of configurations in AppConfigurations interface. To make it work for you own pool, make sure you're change the poolId and poolName. You can optionally change CSS class prefix classPrefix to provide your CSS styling for the app and prevent collision with your names. (By default our classPrefix is set to "acs__" which should be enough to not colide with anyone).

Production builds

For production use these URLs:

  • https://d3bgshfwq8wmv6.cloudfront.net/acs-widget/widget.js
  • https://d3bgshfwq8wmv6.cloudfront.net/acs-widget/main.css

Develop

The widget dev setup is similar to regular client application. To get started:

yarn install
cp .env.example .env.development
vim .env.development # Fill in the right contract program ID
yarn dev

This will open browser with "demo" page which hosts the widget.

Release new version to staging

git push origin main
git tag vX.X.X-beta && git push origin vX.X.X-beta

After this wait for the Github Actions to finish the deploy to S3 and Cloudfront. The demo app will be avail at: https://d3bgshfwq8wmv6.cloudfront.net/acs-widget-staging/index.html

Release new version to production

git push origin main
git tag vX.X.X && git push origin vX.X.X

After this wait for the Github Actions to finish the deploy to S3 and Cloudfront. The demo app will be avail at: https://d3bgshfwq8wmv6.cloudfront.net/acs-widget/index.html

License

The source and documentation in this project are released under the MIT License

widget's People

Contributors

martincik avatar vl-dev avatar dependabot[bot] avatar

Stargazers

Eighty4Crew avatar

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.