Coder Social home page Coder Social logo

digitalsloth / syrius-extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dexterlabz/syrius-extension

0.0 0.0 0.0 17.8 MB

Syrius extension provides a non-custodial wallet solution for Zenon - Network of Momentum that can run in the browser.

License: MIT License

JavaScript 85.56% TypeScript 0.19% HTML 0.36% SCSS 13.90%

syrius-extension's Introduction

Syrius Extension

Please open up an issue to nudge me to keep the npm packages up-to-date. FYI, it takes time to make different packages with different versions work together nicely.

Installing and Running

Procedures:

  1. Check if your Node.js version is >= 14.
  2. Clone this repository.
  3. Run npm install to install the dependencies.
  4. Run npm run build
  5. Load your extension on Chrome following:
    1. Access chrome://extensions/
    2. Check Developer mode
    3. Click on Load unpacked extension
    4. Select the build folder.

How to integrate site with extension

const listenToExtension = function() {
  window.addEventListener("message", (event) => {
    console.log("Message received on site ", event);
    try{
      const parsedData = event.data;
      if(parsedData.method){
        switch(parsedData.method){
          case "znn.grantedWalletRead":{
            const result = JSON.stringify(parsedData.data);
            break;
          }
          case "znn.signedTransaction": {
            const result = JSON.stringify(parsedData.data);
            break;
          }
          case "znn.accountBlockSent": {
            const result = JSON.stringify(parsedData.data);
            break;
          }
        }
      }
    }
    catch(err){
      console.error(err);
    }
  });
}

const connectExtensionWallet = function() {
  window.postMessage({
    method: "znn.requestWalletAccess",
    params: {}
  }, "*");
}

const sendTransactionToSigning = function() {
  window.postMessage({
    method: "znn.sendTransactionToSigning",
    params: {
      from: 'z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7', 
      to: 'z1qqjnwjjpnue8xmmpanz6csze6tcmtzzdtfsww7', 
      amount: '330000000', // 1 ZNN = 100000000
      tokenStandard:
        'zts1znnxxxxxxxxxxxxx9z4ulx', 
      chainId: '3',   
    }
  }, "*");
}

const sendAccountBlockToSend = function() {
  window.postMessage({
    method: "znn.sendAccountBlockToSend",
    params: accountBlockTransactionExample.toJson()
  }, "*");
}

Webpack auto-reload and HRM

To make your workflow much more efficient this project uses the webpack server to development (started with npm start) with auto reload feature that reloads the browser automatically every time that you save some file in your editor.

You can run the dev mode on other port if you want. Just specify the env var port like this:

$ PORT=6002 npm start

Packing

$ NODE_ENV=production npm run build

Now, the content of build folder will be the extension ready to be submitted to the Chrome Web Store. Just take a look at the official guide to more infos about publishing.

syrius-extension's People

Contributors

ulucthulhu avatar 0x3639 avatar dexter703 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.