Code Monkey home page Code Monkey logo

metamask-snap-polkadot's Introduction

Polkadot Wallet Snap for MetaMask

This project uses the MetaMask Snaps framework to extend MetaMask capabilities to include support for Polkadot, Kusama, and other Substrate- and FRAME-based blockchains in the Polkadot ecosystem.

Documentation

Polkadot Wallet snap architecture, integration steps and detailed API documentation for dApp developers is covered in the project wiki, which also includes a usage guide for the example dApp.

Local Development

Developers who wish to use the snap locally must use MetaMask Flask; run the following commands from the project root to launch the Polkadot Wallet Snap Example dApp.

  • yarn install
  • yarn build
  • yarn run demo

License

Copyright [2020] [ChainSafe Systems]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

metamask-snap-polkadot's People

Contributors

beroburny avatar danforbes avatar dependabot[bot] avatar github-actions[bot] avatar irubido avatar lykhoyda avatar mpetrunic 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metamask-snap-polkadot's Issues

Connect transactions

  • fetch and display account transactions
  • set interval and refresh them every 3s

Expose method to configure snap

  • name: configure
  • configuration:
{
   rpcUrl: string;
   explorerUrl?: string  //empty tx list if this is not provided;
   unit: {
      symbol: string;
     decimals: number;
   };
  addressPrefix: number;
}

- save configuration to plugin state
- either throw rpc error if missing or use default configuration(westend?!)
- refactor code to use configuration

Stacktrace logging

If context argument of log methods is exception, we should log exception stacktraces.
I would suggest we have flag to enable/disable stacktraces or to log them at verbose level

Create example page wireframes

Things to display:

  • connect button - it's suppose to install metamask snap
    • if metamask is not present display overlay to hide data until metamask is available
    • after connect, replace with public address
  • account balance
  • account transactions
  • button to export private key
  • section to sign custom message
    • text area and button sign
  • section to transfer
    • to address
    • amount
    • send button

You can use this page to create some wireframe: https://wireframe.cc/

Balance not loading - Unable to initialize the API

Doesn't seem to be working at all as balance is not displaying. Noted error in the console.

FATAL: Unable to initialize the API: createType(Metadata):: Unable to create Enum via index 12, in V0, V1, V2, V3, V4, V5, V6, V7, V8, V9, V10, V11

MetamaskInpageProvider - lost connection to MetaMask RpcProvider

MetamaskInpageProvider - lost connection to MetaMask RpcProvider
Error: StreamMiddleware - Unknown response id 2951923128
at chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:276079
at h.write [as _write] (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:276195)
at v (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:371323)
at chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:374439
at h.g.write (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:374466)
at a.b (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:363746)
at d (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:95984)
at a.o.emit (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:98970)
at _ (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:358585)
at w (chrome-extension://dlemoigadagaakbfkaflkknjpidifbji/inpage.js:1:358400)

[Bug] Snap Confirmation Doesn't Load

In order to get the Snap confirmation to load, I had to uninstall the Snap and reinstall it. Edit: I am using v10.16.2-flask.0 of MetaMask Flask.

Snap not working because of chain upgrades

  • try to update polkadot libraries
  • make sure everything works as expected

Hopefully, you won't encounter ses issues, otherwise we will have to deal with that ๐Ÿฅ 

Subscribe to transaction status

  • given tx hash it should listen if tx is executed and deliver receipt
  • integrate in example page
    • display loading (disable tx sending component)
    • display receipt in dialog

Fix unsubscribing

It's currently commented out, but should work without throwing bunch of errors (maybe because of disconnect.

Expose getPublicKey rpc api

  • expose getPublicKey rpc api (without params)
  • method should returned public key of generated account
  • display that public key after connect in index.html

Investigate Updating to Latest Snap API

In January of 2021, MetaMask made a number of breaking changes to the Snap provider API. The largest change was to remove the injected window.web3 instance. Additionally, the following breaking changes were made

  • Stop 0-padding eth_chainId return values for some chains
  • Stop emitting chainIdChanged, and instead emit chainChanged
  • Removing ethereum.publicConfigStore
  • Removing the ethereum._metamask.isEnabled experimental method
  • Removing the ethereum._metamask.isApproved experimental method

This ticket is for tracking an investigation into how these API changes will affect the project in this repository. See MetaMask's migration guide for more details.

Implement api handler

  • all rpc method should be available in api handler
  • refactor example to use api handler

Use adapter lib inside example

const allInjected = await web3Enable('my cool dapp');
allInjected["metamask-js"].getMetamaskApi().configure(...)

Note: this isn't exact code, you will have to investigate and debug stuff (probably do some casting and custom types)

Dcoument snap

Documentation should be in readme.md and include:

  • arhitecture (dapp->adapter->snap-> provider) graph
  • InjectedExtension additional api
  • document available methods and event listening
  • example how to add to own dapp (using injectedExtension)

Connect account details example

  • fetch and display polkadot address using snap api
  • fetch and display polkadot public key using snap api
  • fetch and display latest block details
    • subscribe and refetch block every
  • fetch and display address balance
    • set interval and fetch falance every 3s
  • display latest block slot

Add snap methods to injected

  • extend Injected interface with method getMetamaskSnapApi in which you will create and return following object:
interface MetamaskSnapApi {
   addAsset(): Promise<void>
  ...rest of snap methods
}

Hardware wallet support

MetaMask has some limited support for hardware wallets (Ledger and Trezor at time of writing).

Will this Polkadot snap interoperate with that layer of MetaMask, effectively producing hardware wallet support for signing Polkadot transactions, etc?

There does seem to be an emerging Polkadot app for Ledger: https://wiki.polkadot.network/docs/en/learn-ledger

Thank you.

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.