Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WookongSolo hardware wallet support #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
"vuex": "^3.0.1",
"web3": "^1.0.0-beta.36",
"web3-provider-engine": "^14.0.6",
"websocket": "^1.0.28"
"websocket": "^1.0.28",
"wookong-solo": "0.1.2"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
Expand Down
7 changes: 5 additions & 2 deletions src/models/ExternalWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import ecc from 'eosjs-ecc'
import {Blockchains} from './Blockchains'
import LedgerWallet from './hardware/LedgerWallet';
import LiquidEOS from './hardware/LiquidEOS';
import WookongSolo from './hardware/WookongSolo';

export const EXT_WALLET_TYPES = {
LEDGER:'Ledger Nano S',
LIQUID_EOS:'Scatter/LiquidEOS DIY Hardware Wallet'
LEDGER: 'Ledger Nano S',
LIQUID_EOS: 'Scatter/LiquidEOS DIY Hardware Wallet',
WOOKONG_SOLO: 'Wookong Solo'
};

export const EXT_WALLET_TYPES_ARR = Object.keys(EXT_WALLET_TYPES).map(x => EXT_WALLET_TYPES[x]);
Expand All @@ -33,6 +35,7 @@ const getInterface = (type, blockchain) => {
switch(type){
case EXT_WALLET_TYPES.LEDGER: return LedgerWallet.typeToInterface(blockchain);
case EXT_WALLET_TYPES.LIQUID_EOS: return LiquidEOS.typeToInterface();
case EXT_WALLET_TYPES.WOOKONG_SOLO: return WookongSolo.typeToInterface();
}
}

Expand Down
47 changes: 47 additions & 0 deletions src/models/hardware/WookongSolo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import PopupService from '../../services/PopupService';
import { Popup } from '../popups/Popup';
import { getPublicKey, signTransaction } from "wookong-solo";

const cache = {};

export default class WookongSolo {
constructor(blockchain){
console.log("wookong constructor");
this.blockchain = blockchain;
this.init();
}

static typeToInterface(blockchain){
console.log("wookong typeToInterface");
if(!cache.hasOwnProperty(blockchain)) cache[blockchain] = new WookongSolo(blockchain);
return cache[blockchain];
};

async init(){
this.canConnect = async () => {
console.log("wookong canConnect");
return true;
};
this.getPublicKey = async () => {
console.log("wookong getPublicKey");
const publicKey = await getPublicKey();

console.log("publicKey: " + publicKey);
return publicKey;
};
this.sign = async (publicKey, rawTxHex, abi) => {
console.log("wookong sign");
console.log('rawTxHex is:', JSON.stringify(rawTxHex));
console.log('rawTxHex.buf is:', JSON.stringify(rawTxHex.buf));
let res = {};
try {
res = await signTransaction(rawTxHex);
} catch (error) {
console.log('sign exception: ', error);
}

console.log("res payload" + res.payload);
return res.payload;
}
}
}