@@ -6,26 +6,35 @@ function showTruebitScrypt(hash) {
6
6
return "<div>Scrypt Hash from TrueBit solver:</div> <div>" + hash + "</div>"
7
7
}
8
8
9
- var incentiveLayer , fileSystem
10
-
11
- const taskInfo = {
12
- "ipfshash" :"QmZGf6QCViGi7VPZSp97EkvDX9NuNyspZvgpXs1Wq73u4L" ,
13
- "codehash" :"0xcb1f3611566c137482d4a5b560896d2142a13450915d8e17e7dd9c24736a164c" ,
14
- "memsize" :20
15
- }
9
+ var fileSystem , scryptSubmitter
16
10
17
11
function getTruebitScrypt ( data ) {
18
12
19
- //handle file system work
13
+ let hash = "default"
20
14
15
+ scryptSubmitter . methods . submitData ( data ) . send ( { gas : 200000 } , function ( error , txHash ) {
16
+ scryptSubmitter . once ( 'GotFiles' , function ( error , event ) {
17
+ if ( event ) {
18
+ let fileID = event . args . files [ 0 ]
19
+
20
+ fileSystem . methods . getData ( fileID ) . call ( function ( error , result ) {
21
+ hash = result [ 0 ]
22
+ } )
23
+ }
24
+ } )
25
+ } )
26
+
27
+ return hash
21
28
}
22
29
23
30
function runScrypt ( ) {
24
31
data = document . getElementById ( 'input-data' ) . value
25
32
hash = s . crypto_scrypt ( data , "foo" , 1024 , 1 , 1 , 256 )
26
33
document . getElementById ( 'js-scrypt' ) . innerHTML = showJSScrypt ( s . to_hex ( hash ) )
27
34
28
- document . getElementById ( 'tb-scrypt' ) . innerHTML = showTruebitScrypt ( "foobar" )
35
+ truHash = getTruebitScrypt ( data )
36
+
37
+ document . getElementById ( 'tb-scrypt' ) . innerHTML = showTruebitScrypt ( truHash )
29
38
}
30
39
31
40
function getArtifacts ( networkName ) {
@@ -34,6 +43,10 @@ function getArtifacts(networkName) {
34
43
httpRequest . onreadystatechange = function ( ) {
35
44
if ( httpRequest . readyState === XMLHttpRequest . DONE ) {
36
45
//get scrypt submitter artifact
46
+ const artifacts = JSON . parse ( httpRequest . responseText )
47
+
48
+ fileSystem = window . web3 . eth . contract ( artifacts . fileSystem . abi , artifacts . fileSystem . address )
49
+ scryptSubmitter = window . web3 . eth . contract ( artifacts . scrypt . abi , artifacts . scrypt . address )
37
50
}
38
51
}
39
52
0 commit comments