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
383cc05c
Commit
383cc05c
authored
Jan 10, 2019
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Readme
parent
fdcacfc2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
24 deletions
+20
-24
README.md
remix-resolve/README.md
+20
-24
No files found.
remix-resolve/README.md
View file @
383cc05c
## Remix
resolve
engine
## Remix
URL resolver
engine
**Input**
`resolve(url, urlHandler)`
```
json
[
'greeter.sol'
:
{
content
:
'pragma
solidity
^
0.5
.
0
;\nimport
"./mortal.sol"
;\n\ncontract
Greeter
is
Mortal
{
\n
/*
Define
variable
greeting
of
the
type
string
*/\n
string
greeting;\n\n
/*
This
runs
when
the
contract
is
executed
*/\n
constructor(string
memory
_greeting)
public
{
\n
greeting
=
_greeting;\n
}
\n\n
/*
Main
function
*/\n
function
greet()
public
view
returns
(string
memory)
{
\n
return
greeting;\n
}
\n
}
\n'
}
]
```
**Output**
```
json
{
'mortal.sol'
:
{
content
:
'pragma
solidity
^
0.5
.
0
;\n\ncontract
Mortal
{
\n
/*
Define
variable
owner
of
the
type
address
*/\n
address
payable
owner;\n\n
/*
This
function
is
executed
at
initialization
and
sets
the
owner
of
the
contract
*/\n
function
mortal()
public
{
owner
=
msg.sender;
}
\n\n
/*
Function
to
recover
the
funds
on
the
contract
*/\n
function
kill()
public
{
if
(msg.sender
==
owner)
selfdestruct(owner);
}
\n
}
\n'
},
'greeter.sol'
:
{
content
:
'pragma
solidity
^
0.5
.
0
;\nimport
\'mortal.sol\';\n\ncontract
Greeter
is
Mortal
{
\n
/*
Define
variable
greeting
of
the
type
string
*/\n
string
greeting;\n\n
/*
This
runs
when
the
contract
is
executed
*/\n
constructor(string
memory
_greeting)
public
{
\n
greeting
=
_greeting;\n
}
\n\n
/*
Main
function
*/\n
function
greet()
public
view
returns
(string
memory)
{
\n
return
greeting;\n
}
\n
}
\n'
}
}
```
#### API
`combineSource(sources)`
Returns
`json`
object with exact same path as
`import`
statement.
Returns
`json`
object with exact same path as
`import`
statement.
**Output**
**Output**
```
json
```
json
{
{
'./mortal.sol'
:
{
content
:
'...'
},
content
:
'pragma
solidity
^
0.5
.
0
;\nimport
"./mortal.sol"
;\n\ncontract
Greeter
is
Mortal
{
\n
/*
Define
variable
greeting
of
the
type
string
*/\n
string
greeting;\n\n
/*
This
runs
when
the
contract
is
executed
*/\n
constructor(string
memory
_greeting)
public
{
\n
greeting
=
_greeting;\n
}
\n\n
/*
Main
function
*/\n
function
greet()
public
view
returns
(string
memory)
{
\n
return
greeting;\n
}
\n
}
\n'
,
'greeter.sol'
:
{
content
:
'...'
}
cleanURL
:
'../greeter.sol'
,
type
:
'local'
}
}
```
```
`resolve(path, combinedSources)`
function should be called from within
`handleImportCb`
function of
`solc.compile(input, handleImportCb)`
.
#### Usage
```
javascript
`resolve(url, urlHandler)`
function should be called from within
`handleImportCb`
function of
`solc.compile(input, handleImportCb)`
.
const
rr
=
require
(
'remix-resolve'
)
function
handleImportCb
(
path
)
{
```
ts
return
rr
.
resolve
(
path
,
combinedSources
)
import
{
RemixResolve
}
from
'remix-url-resolver'
}
const
remixResolve
=
new
RemixResolve
()
const
fileName
:
string
=
'../greeter.sol'
remixResolve
.
resolve
(
fileName
,
urlHandler
)
.
then
((
sources
:
object
)
=>
{
console
.
log
(
sources
)
})
.
catch
((
e
:
Error
)
=>
{
throw
e
})
```
```
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