Get private key from mnemonic and use to sign tx
For plasma txfers, we need to sign the child chain tx using the private key of the account configured with the mnemonic. This is a temporary solution until we can support `eth_signTypeData_v3` in embark to do the signing for us.
This commit is contained in:
parent
f99fba9452
commit
c86b37e823
13
src/index.js
13
src/index.js
|
@ -1,6 +1,6 @@
|
|||
import EmbarkJSPlasma from "embarkjs-plasma";
|
||||
import { dappPath } from "embark-utils";
|
||||
import { formatDate } from "./utils";
|
||||
import {dappPath} from "embark-utils";
|
||||
import {formatDate} from "./utils";
|
||||
|
||||
// Service check constants
|
||||
const SERVICE_CHECK_ON = "on";
|
||||
|
@ -17,7 +17,6 @@ class EmbarkPlasma extends EmbarkJSPlasma {
|
|||
this.embark = embark;
|
||||
this.events = embark.events;
|
||||
this.pluginConfig = embark.pluginConfig;
|
||||
this.accounts = [];
|
||||
|
||||
// gets hydrated blockchain config from embark, use it to init
|
||||
// this.events.once("config:load:contracts", this.addCodeToEmbarkJs.bind(this));
|
||||
|
@ -27,7 +26,9 @@ class EmbarkPlasma extends EmbarkJSPlasma {
|
|||
|
||||
this.events.request("blockchain:get", (web3) => {
|
||||
this.events.request("blockchain:ready", () => {
|
||||
this.init(web3, true);
|
||||
this.events.request("blockchain:provider:contract:accounts:getAll", (_err, accounts) => {
|
||||
this.init(web3, true, accounts);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -82,7 +83,7 @@ class EmbarkPlasma extends EmbarkJSPlasma {
|
|||
code += "\n EmbarkJS.Plasma = new __embarkPlasma(opts);";
|
||||
code += `\n const embarkJsWeb3Provider = EmbarkJS.Blockchain.Providers["web3"]`;
|
||||
code += `\n if (!embarkJsWeb3Provider) { throw new Error("web3 cannot be found. Please ensure you have the 'embarkjs-connector-web3' plugin installed in your DApp."); }`;
|
||||
code += `\n if (global.embarkjsOmg) EmbarkJS.Plasma.init(embarkJsWeb3Provider.web3, true).catch((err) => console.error(err));`; // global.embarkjsOmg ? "${web3SymlinkPath}" : null);`; // pass the symlink path ONLY when we are in the node (VM) context
|
||||
code += `\n if (global.embarkjsOmg) EmbarkJS.Plasma.init(embarkJsWeb3Provider.web3, true, ${JSON.stringify(this.accounts)}).catch((err) => console.error(err));`; // global.embarkjsOmg ? "${web3SymlinkPath}" : null);`; // pass the symlink path ONLY when we are in the node (VM) context
|
||||
code += "\n});";
|
||||
|
||||
this.embark.addCodeToEmbarkJS(code);
|
||||
|
@ -229,7 +230,7 @@ class EmbarkPlasma extends EmbarkJSPlasma {
|
|||
name,
|
||||
cb => {
|
||||
if (!this.inited) {
|
||||
return cb({ name: "Loading...", status: SERVICE_CHECK_OFF });
|
||||
return cb({name: "Loading...", status: SERVICE_CHECK_OFF});
|
||||
}
|
||||
this.childChain.status()
|
||||
.then(status => {
|
||||
|
|
Loading…
Reference in New Issue