Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
deb1a4f3
Commit
deb1a4f3
authored
Jan 30, 2018
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move compiler code from browser-solidity including txHelper
parent
7eb8cc31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
280 additions
and
0 deletions
+280
-0
compiler-imports.js
remix-solidity/src/compiler/compiler-imports.js
+85
-0
compiler-input.js
remix-solidity/src/compiler/compiler-input.js
+21
-0
compiler-worker.js
remix-solidity/src/compiler/compiler-worker.js
+45
-0
compiler.js
remix-solidity/src/compiler/compiler.js
+0
-0
txHelper.js
remix-solidity/src/compiler/txHelper.js
+129
-0
No files found.
remix-solidity/src/compiler/compiler-imports.js
0 → 100644
View file @
deb1a4f3
'use strict'
// TODO: can just use request or fetch instead
var
$
=
require
(
'jquery'
)
var
base64
=
require
(
'js-base64'
).
Base64
var
swarmgw
=
require
(
'swarmgw'
)
module
.
exports
=
{
handleGithubCall
:
function
(
root
,
path
,
cb
)
{
return
$
.
getJSON
(
'https://api.github.com/repos/'
+
root
+
'/contents/'
+
path
)
.
done
(
function
(
data
)
{
if
(
'content'
in
data
)
{
cb
(
null
,
base64
.
decode
(
data
.
content
),
root
+
'/'
+
path
)
}
else
{
cb
(
'Content not received'
)
}
})
.
fail
(
function
(
xhr
,
text
,
err
)
{
// NOTE: on some browsers, err equals to '' for certain errors (such as offline browser)
cb
(
err
||
'Unknown transport error'
)
})
},
handleSwarmImport
:
function
(
url
,
cb
)
{
swarmgw
.
get
(
url
,
function
(
err
,
content
)
{
cb
(
err
,
content
,
url
)
})
},
handleIPFS
:
function
(
url
,
cb
)
{
// replace ipfs:// with /ipfs/
url
=
url
.
replace
(
/^ipfs:
\/\/?
/
,
'ipfs/'
)
return
$
.
ajax
({
type
:
'GET'
,
url
:
'https://gateway.ipfs.io/'
+
url
})
.
done
(
function
(
data
)
{
cb
(
null
,
data
,
url
)
})
.
fail
(
function
(
xhr
,
text
,
err
)
{
// NOTE: on some browsers, err equals to '' for certain errors (such as offline browser)
cb
(
err
||
'Unknown transport error'
)
})
},
handlers
:
function
()
{
return
[
{
type
:
'github'
,
match
:
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleGithubCall
(
match
[
3
],
match
[
4
],
cb
)
}
},
{
type
:
'swarm'
,
match
:
/^
(
bzz
[
ri
]?
:
\/\/?
.*
)
$/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleSwarmImport
(
match
[
1
],
cb
)
}
},
{
type
:
'ipfs'
,
match
:
/^
(
ipfs:
\/\/?
.+
)
/
,
handler
:
(
match
,
cb
)
=>
{
this
.
handleIPFS
(
match
[
1
],
cb
)
}
}
]
},
import
:
function
(
url
,
cb
)
{
var
handlers
=
this
.
handlers
()
var
found
=
false
handlers
.
forEach
(
function
(
handler
)
{
if
(
found
)
{
return
}
var
match
=
handler
.
match
.
exec
(
url
)
if
(
match
)
{
found
=
true
// TODO: this needs to be moved to the caller
$
(
'#output'
).
append
(
$
(
'<div/>'
).
append
(
$
(
'<pre/>'
).
text
(
'Loading '
+
url
+
' ...'
)))
handler
.
handler
(
match
,
function
(
err
,
content
,
cleanUrl
)
{
if
(
err
)
{
cb
(
'Unable to import "'
+
cleanUrl
+
'": '
+
err
)
return
}
cb
(
null
,
content
,
cleanUrl
,
handler
.
type
,
url
)
})
}
})
if
(
found
)
{
return
}
else
if
(
/^
[^
:
]
*:
\/\/
/
.
exec
(
url
))
{
cb
(
'Unable to import "'
+
url
+
'": Unsupported URL schema'
)
}
else
{
cb
(
'Unable to import "'
+
url
+
'": File not found'
)
}
}
}
remix-solidity/src/compiler/compiler-input.js
0 → 100644
View file @
deb1a4f3
'use strict'
module
.
exports
=
(
sources
,
opts
)
=>
{
return
JSON
.
stringify
({
language
:
'Solidity'
,
sources
:
sources
,
settings
:
{
optimizer
:
{
enabled
:
opts
.
optimize
===
true
||
opts
.
optimize
===
1
,
runs
:
200
},
libraries
:
opts
.
libraries
,
outputSelection
:
{
'*'
:
{
''
:
[
'legacyAST'
],
'*'
:
[
'abi'
,
'metadata'
,
'evm.legacyAssembly'
,
'evm.bytecode'
,
'evm.deployedBytecode'
,
'evm.methodIdentifiers'
,
'evm.gasEstimates'
]
}
}
}
})
}
remix-solidity/src/compiler/compiler-worker.js
0 → 100644
View file @
deb1a4f3
'use strict'
var
solc
=
require
(
'solc/wrapper'
)
var
compileJSON
=
function
()
{
return
''
}
var
missingInputs
=
[]
module
.
exports
=
function
(
self
)
{
self
.
addEventListener
(
'message'
,
function
(
e
)
{
var
data
=
e
.
data
switch
(
data
.
cmd
)
{
case
'loadVersion'
:
delete
self
.
Module
// NOTE: workaround some browsers?
self
.
Module
=
undefined
compileJSON
=
null
self
.
importScripts
(
data
.
data
)
var
compiler
=
solc
(
self
.
Module
)
compileJSON
=
function
(
input
)
{
try
{
return
compiler
.
compileStandardWrapper
(
input
,
function
(
path
)
{
missingInputs
.
push
(
path
)
return
{
'error'
:
'Deferred import'
}
})
}
catch
(
exception
)
{
return
JSON
.
stringify
({
error
:
'Uncaught JavaScript exception:
\
n'
+
exception
})
}
}
self
.
postMessage
({
cmd
:
'versionLoaded'
,
data
:
compiler
.
version
()
})
break
case
'compile'
:
missingInputs
.
length
=
0
self
.
postMessage
({
cmd
:
'compiled'
,
job
:
data
.
job
,
data
:
compileJSON
(
data
.
input
),
missingInputs
:
missingInputs
})
break
}
},
false
)
}
remix-solidity/src/compiler/compiler.js
0 → 100644
View file @
deb1a4f3
This diff is collapsed.
Click to expand it.
remix-solidity/src/compiler/txHelper.js
0 → 100644
View file @
deb1a4f3
'use strict'
var
ethJSABI
=
require
(
'ethereumjs-abi'
)
var
$
=
require
(
'jquery'
)
module
.
exports
=
{
encodeParams
:
function
(
funABI
,
args
)
{
var
types
=
[]
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
for
(
var
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
var
type
=
funABI
.
inputs
[
i
].
type
types
.
push
(
type
)
if
(
args
.
length
<
types
.
length
)
{
args
.
push
(
''
)
}
}
}
// NOTE: the caller will concatenate the bytecode and this
// it could be done here too for consistency
return
ethJSABI
.
rawEncode
(
types
,
args
)
},
encodeFunctionId
:
function
(
funABI
)
{
var
types
=
[]
if
(
funABI
.
inputs
&&
funABI
.
inputs
.
length
)
{
for
(
var
i
=
0
;
i
<
funABI
.
inputs
.
length
;
i
++
)
{
types
.
push
(
funABI
.
inputs
[
i
].
type
)
}
}
return
ethJSABI
.
methodID
(
funABI
.
name
,
types
)
},
sortAbiFunction
:
function
(
contractabi
)
{
var
abi
=
contractabi
.
sort
(
function
(
a
,
b
)
{
if
(
a
.
name
>
b
.
name
)
{
return
-
1
}
else
{
return
1
}
}).
sort
(
function
(
a
,
b
)
{
if
(
a
.
constant
===
true
)
{
return
-
1
}
else
{
return
1
}
})
return
abi
},
getConstructorInterface
:
function
(
abi
)
{
var
funABI
=
{
'name'
:
''
,
'inputs'
:
[],
'type'
:
'constructor'
,
'outputs'
:
[]
}
if
(
typeof
abi
===
'string'
)
{
try
{
abi
=
JSON
.
parse
(
abi
)
}
catch
(
e
)
{
console
.
log
(
'exception retrieving ctor abi '
+
abi
)
return
funABI
}
}
for
(
var
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
if
(
abi
[
i
].
type
===
'constructor'
)
{
funABI
.
inputs
=
abi
[
i
].
inputs
||
[]
break
}
}
return
funABI
},
getFunction
:
function
(
abi
,
fnName
)
{
for
(
var
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
if
(
abi
[
i
].
name
===
fnName
)
{
return
abi
[
i
]
}
}
return
null
},
getFallbackInterface
:
function
(
abi
)
{
for
(
var
i
=
0
;
i
<
abi
.
length
;
i
++
)
{
if
(
abi
[
i
].
type
===
'fallback'
)
{
return
abi
[
i
]
}
}
},
/**
* return the contract obj of the given @arg name. Uses last compilation result.
* return null if not found
* @param {String} name - contract name
* @returns contract obj and associated file: { contract, file } or null
*/
getContract
:
(
contractName
,
contracts
)
=>
{
for
(
var
file
in
contracts
)
{
if
(
contracts
[
file
][
contractName
])
{
return
{
object
:
contracts
[
file
][
contractName
],
file
:
file
}
}
}
return
null
},
/**
* call the given @arg cb (function) for all the contracts. Uses last compilation result
* stop visiting when cb return true
* @param {Function} cb - callback
*/
visitContracts
:
(
contracts
,
cb
)
=>
{
for
(
var
file
in
contracts
)
{
for
(
var
name
in
contracts
[
file
])
{
if
(
cb
({
name
:
name
,
object
:
contracts
[
file
][
name
],
file
:
file
}))
return
}
}
},
inputParametersDeclarationToString
:
function
(
abiinputs
)
{
var
inputs
=
''
if
(
abiinputs
)
{
$
.
each
(
abiinputs
,
function
(
i
,
inp
)
{
if
(
inputs
!==
''
)
{
inputs
+=
', '
}
inputs
+=
inp
.
type
+
' '
+
inp
.
name
})
}
return
inputs
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment