Giter Club home page Giter Club logo

webextensionwallet's Introduction

WebExtensionWallet

1. Install

This extension is now published on Chrome web store. Wellcome to install and take a try!

We will keep improving this extension, and any suggestions are welcome!

Note: If you need to test local html files, you need to turn on the "Allow access to file URLs" option at extension management page:

2. Brief introduction of using our ExtensionWallet

(1) In tab `New-Wallet`, you can create your own wallet, and download the keystore files.
(2) In tab `Send-TX`, you can import your keystore file, and then your account will be stored within the extension.
(3) After your account keyfile is imported, you can send NAS to other account address.
(4) After a transaction is sent, you got the transaction hash shown at the bottom of extension page.
(5) Click the transaction hash in tab `Send-TX` to check transaction status
(6) Another way to check your transaction status is to copy your transaction hash to `check-TX` to view the result.

3. Instructions on how to use NasExtWallet in your webapp

Now NasExtWallet supports two different ways to communicate with Dapp page.

3.1 Using NebPay SDK

Please refer to Dapp Example SuperDictionary to learn how to use this extension.

When developing your Dapp page, you can use NebPay SDK to communicate with ExtensionWallet. Just as the example below.

To call a SmartContract through extensionWallet, you should use nebpay.call or nebpay.simulateCall to send a transaction as below:

nebPay.call(to, value, callFunction, callArgs, {
    qrcode: {
        showQRCode: true
    },
    listener: cbCallDapp //specify a listener to handle the transaction result
});

function cbCallDapp(resp){
    console.log("response: " + JSON.stringify(resp))
}
    

3.2 Using postMessage

When developing your Dapp page, you can use postMessage API to communicate with ExtensionWallet, and use window.addEventListener to listen the message answer. Just as the example below.

To call a smart contract function with extensionWallet, you should use postMessage to send a message as below:

window.postMessage({
    "target": "contentscript",
    "data":{
        "to": to,
        "value": "0",
        "contract":{  //"contract" is a parameter used to deploy a contract or call a smart contract function
            "function": func,
            "args": para
        }
    },
    "method": "neb_sendTransaction",
}, "*");

And then you need to add an eventlistener to listen the returned message.

window.addEventListener('message', function(e) {
     console.log("message received, msg.data: " + JSON.stringify(e.data));
     if(!!e.data.data.txhash){
         console.log("Transaction hash:\n" + JSON.stringify(e.data.data.txhash, null, '\t'));
     }
})

4 how to get account address

It is useful for Dapp to get the current account address in the extension. Here is the explanation on how to achieve this.

Method 1:

var userAddress;

function getUserAddress() {
    console.log("********* get account ************")
    window.postMessage({
        "target": "contentscript",
        "data":{
        },
        "method": "getAccount",
    }, "*");
}
// listen message from contentscript
window.addEventListener('message', function(e) {
    // e.detail contains the transferred data (can
    console.log("received by page:" + e + ", e.data:" + JSON.stringify(e.data));
    if (!!e.data.data && !!e.data.data.account) {
        userAddrerss = e.data.data.account;
    }
})

Method 2:

A module NasExtWallet is injected to your page if NasExtWallet is installed, then you can use the code below to get user account:

var userAddress;

NasExtWallet.getUserAddress(function(addr){
    userAddress = addr;
    console.log("user address is : " + addr)
})

example page

And you can use example/TestPage.html to take a test.

webextensionwallet's People

Contributors

chengorangeju avatar creategithub avatar imerkle avatar includeleec avatar jaymansfield avatar old2 avatar pingneb avatar qywang2012 avatar the8thbit avatar yupnano avatar zoowii 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

webextensionwallet's Issues

Unload current wallet when clicking "change another wallet"

Currently, when you click "change another wallet", a wallet that's currently loaded will stay loaded until another wallet file is selected. Sometimes I just want to unload the current wallet so that it's not unlocked. Clicking change wallet should immediately lock and clear an existing unlocked wallet.

`NasExtWallet.getUserAddress()` 在单个通信周期内只能承载一个回调

我只是在测试中发现了一个现象,暂时没有深入阅读钱包扩展的源码。

在每个交互周期内(页面 → 钱包扩展 → 页面),NasExtWallet.getUserAddress() 方法只能承载一个回调。也就是说,连续多次调用 NasExtWallet.getUserAddress(callback),最后一次注册的 callback 会覆盖之前的所有 callback。

比如有以下代码:

NasExtWallet.getUserAddress(function () {
	console.log(1)
})
NasExtWallet.getUserAddress(function () {
	console.log(2)
})
NasExtWallet.getUserAddress(function () {
	console.log(3)
})
NasExtWallet.getUserAddress(function () {
	console.log(4)
})

会在控制台得到 4 4 4 4,而不是 1 2 3 4


Original issue: NasaTeam/Nasa.js#31

选择钱包文件选择不上

点击web钱包插件,发送星云币->选择钱包->选择完钱包后,web钱包插件界面自动没了,打开又要选择钱包,周而复始.请问是什么问题?

how to call pay page by chrome extension

我正在开发一个Chrome Extension。我在background.js中使用如下代码调用nebPay的方法。
image
background.js的控制台输出为:
image
但是无法弹出网页钱包的支付弹窗。

"Amount to Send" unit is wrong

image

To reproduce:

const nebPay = new NebPay()
const value = "1000000"
const callFunction = "anyFunction"
const callArgs = JSON.stringify([idx])
const opts = {
}

nebPay.call(
  CONTRACT_ADDRESS,
  value,
  callFunction,
  callArgs,
  opts
)

The first time extension popup is open, the unit for value is wrong.

Ubuntu closes popup on file prompt

Problem:

I want to import a wallet in the Send-TX tab. This is what I initially see when I have the extension opened.
screenshot from 2018-05-21 00-19-03

When I click on the 'SELECT WALLET FILE' button, a file dialog shows up, but the extension popup goes away.
screenshot from 2018-05-21 00-19-44
Selecting a file doesn't do anything. I believe it's because Chrome has closed the extension app already so there's nothing for the call to return to.

This is a bug with Ubuntu Chrome. This affects MetaMask too, and right now they use a hack around it.
MetaMask/metamask-extension#1136

Versions:

  • Ubuntu 16.04
  • Chrome Version 66.0.3359.181 (Official Build) (64-bit)
  • WebExtensionWallet 0.1.0

自定义数据签名功能

请问钱包插件现在是否有能够对自定义数据进行签名的功能?类似于MetaMask中那种不只是对交易签名,还能对其它数据签名,如果没有请问多久能提供支持?

Error: Not a V3 walle

after select my Wallet File, i enter the password and click the unLock button ,but show me :"Wallet File".how I save it?

thanks

插件在PC端调用支付功能时除了钱包支付页面外,总会另新建一个浏览器窗口

系统:Ubuntu
使用浏览器:Chrome、Vivaldi
描述:插件工作正常,但每次支付操作时,除弹出正常支付页面外,还会调用新建浏览器进程来尝试打开移动端的钱包,因PC端无移动端钱包APP,导致每次会弹出一个无效的空白浏览器窗口,影响体验。
查询空白浏览器进程可发现调用为移动APP链接:openapp.nasnano://virtual?params=......,望查实。

Feature request: 提供一个接口,用于返回钱包扩展当前的环境信息

钱包扩展增加了 NasExtWallet 这个全局命名空间,这个势头非常好。期待它暴露更多的实用功能出来 👍

我提个需求:提供一个接口,用于返回钱包扩展当前的环境信息(主网 / 测试网 / 本地)。

另外,希望 NasExtWallet 提供的接口能做成同步的。现在的 .getUserAddress() 是异步的,但似乎是可以做成同步的?比如当钱包状态发生变化时主动注入(或发消息)到页面中?

因此,如果提供一个 NasExtWallet.getEnv() 接口,希望它是同步的。

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.