File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ var EmbarkJS =
5757
5858 this . abi = options . abi ;
5959 this . address = options . address ;
60- this . code = options . code ;
60+ this . code = '0x' + options . code ;
6161 this . web3 = options . web3 || web3 ;
6262
6363 var ContractClass = this . web3 . eth . contract ( this . abi ) ;
@@ -278,6 +278,7 @@ var EmbarkJS =
278278 } ;
279279
280280 EmbarkJS . Messages . setProvider = function ( provider , options ) {
281+ var self = this ;
281282 var ipfs ;
282283 if ( provider === 'whisper' ) {
283284 this . currentMessages = EmbarkJS . Messages . Whisper ;
@@ -288,7 +289,13 @@ var EmbarkJS =
288289 web3 = new Web3 ( new Web3 . providers . HttpProvider ( "http://" + options . server + ':' + options . port ) ) ;
289290 }
290291 }
291- this . currentMessages . identity = web3 . shh . newIdentity ( ) ;
292+ web3 . version . getWhisper ( function ( err , res ) {
293+ if ( err ) {
294+ console . log ( "whisper not available" ) ;
295+ } else {
296+ self . currentMessages . identity = web3 . shh . newIdentity ( ) ;
297+ }
298+ } ) ;
292299 } else if ( provider === 'orbit' ) {
293300 this . currentMessages = EmbarkJS . Messages . Orbit ;
294301 if ( options === undefined ) {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ EmbarkJS.Contract = function(options) {
1010
1111 this . abi = options . abi ;
1212 this . address = options . address ;
13- this . code = options . code ;
13+ this . code = '0x' + options . code ;
1414 this . web3 = options . web3 || web3 ;
1515
1616 var ContractClass = this . web3 . eth . contract ( this . abi ) ;
@@ -231,6 +231,7 @@ EmbarkJS.Messages = {
231231} ;
232232
233233EmbarkJS . Messages . setProvider = function ( provider , options ) {
234+ var self = this ;
234235 var ipfs ;
235236 if ( provider === 'whisper' ) {
236237 this . currentMessages = EmbarkJS . Messages . Whisper ;
@@ -241,7 +242,13 @@ EmbarkJS.Messages.setProvider = function(provider, options) {
241242 web3 = new Web3 ( new Web3 . providers . HttpProvider ( "http://" + options . server + ':' + options . port ) ) ;
242243 }
243244 }
244- this . currentMessages . identity = web3 . shh . newIdentity ( ) ;
245+ web3 . version . getWhisper ( function ( err , res ) {
246+ if ( err ) {
247+ console . log ( "whisper not available" ) ;
248+ } else {
249+ self . currentMessages . identity = web3 . shh . newIdentity ( ) ;
250+ }
251+ } ) ;
245252 } else if ( provider === 'orbit' ) {
246253 this . currentMessages = EmbarkJS . Messages . Orbit ;
247254 if ( options === undefined ) {
You can’t perform that action at this time.
0 commit comments