From fbb25d99ff5ea524f58fb9dabcfa6fca9c87722f Mon Sep 17 00:00:00 2001 From: emizzle Date: Wed, 26 Jun 2019 12:44:20 +1000 Subject: [PATCH] Pass PK in to the constructor Instead of passing the PK of the embark-configured accounts in to `EmbarkJS.Plasma.init()`, pass it in to the constructor of `Embark.Plasma` instead. This makes the PK available in other functions of `Embark.Plasma` (ie `.transfer()`. Bump version --- package.json | 2 +- src/index.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 57e590b..302dcf8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "embark-plasma", - "version": "1.0.4", + "version": "1.0.5", "description": "OmiseGO Plasma plugin for Embark", "main": "dist/index.js", "files": [ diff --git a/src/index.js b/src/index.js index 0de30b3..c7ee3ca 100644 --- a/src/index.js +++ b/src/index.js @@ -20,14 +20,16 @@ class EmbarkPlasma extends EmbarkJSPlasma { // gets hydrated blockchain config from embark, use it to init // this.events.once("config:load:contracts", this.addCodeToEmbarkJs.bind(this)); - this.addCodeToEmbarkJs(); + this.registerServiceCheck(); this.registerConsoleCommands(); this.events.request("blockchain:get", (web3) => { this.events.request("blockchain:ready", () => { this.events.request("blockchain:provider:contract:accounts:getAll", (_err, accounts) => { - this.init(web3, true, accounts); + this.accounts = accounts; + this.addCodeToEmbarkJs(); + this.init(web3, true); }); }); }); @@ -77,13 +79,14 @@ class EmbarkPlasma extends EmbarkJSPlasma { error: console.error, trace: console.trace }, - pluginConfig: ${JSON.stringify(this.pluginConfig)} + pluginConfig: ${JSON.stringify(this.pluginConfig)}, + accounts: ${JSON.stringify(this.accounts)} };`; code += "\nEmbarkJS.onReady(() => {"; 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, ${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 if (global.embarkjsOmg) EmbarkJS.Plasma.init(embarkJsWeb3Provider.web3, true).catch((err) => console.error(err));`; code += "\n});"; this.embark.addCodeToEmbarkJS(code);