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
2fd155ed
Commit
2fd155ed
authored
Dec 08, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to implement resolve function in TS
parent
7ba69b1a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
110 additions
and
24 deletions
+110
-24
package.json
remix-resolve/package.json
+1
-0
getFile.js
remix-resolve/src/getFile.js
+0
-5
getFile.ts
remix-resolve/src/getFile.ts
+9
-0
index.js
remix-resolve/src/index.js
+0
-14
index.ts
remix-resolve/src/index.ts
+2
-2
resolve.ts
remix-resolve/src/resolve.ts
+95
-0
test.js
remix-resolve/tests/test.js
+1
-1
tsconfig.json
remix-resolve/tsconfig.json
+2
-2
No files found.
remix-resolve/package.json
View file @
2fd155ed
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"axios"
:
"^0.18.0"
,
"axios"
:
"^0.18.0"
,
"request"
:
"^2.88.0"
,
"solc"
:
"^0.5.0"
,
"solc"
:
"^0.5.0"
,
"url"
:
"^0.11.0"
,
"url"
:
"^0.11.0"
,
"valid-url"
:
"^1.0.9"
"valid-url"
:
"^1.0.9"
...
...
remix-resolve/src/getFile.js
deleted
100644 → 0
View file @
7ba69b1a
const
getFile
=
function
(
path
,
sources
)
{
return
sources
[
path
].
content
}
module
.
exports
=
getFile
remix-resolve/src/getFile.ts
0 → 100644
View file @
2fd155ed
export
interface
Sources
{
[
contractPath
:
string
]:
{
content
:
string
}
}
export
function
getFile
(
path
:
string
,
sources
:
Sources
)
{
return
sources
[
path
].
content
}
remix-resolve/src/index.js
deleted
100644 → 0
View file @
7ba69b1a
/*
const rr = require('remix-resolve')
const fileContent = rr.resolve('https://github.com/ethereum/greeter.sol')
const input = rr.combineSource({ 'greeter.sol': content })
*/
const
resolve
=
require
(
'./resolve.js'
)
const
combineSource
=
require
(
'./combineSource.js'
)
const
getFile
=
require
(
'./getFile.js'
)
module
.
exports
=
{
resolve
:
resolve
,
combineSource
:
combineSource
,
getFile
:
getFile
}
remix-resolve/src/index.ts
View file @
2fd155ed
...
@@ -3,6 +3,6 @@ const rr = require('remix-resolve')
...
@@ -3,6 +3,6 @@ const rr = require('remix-resolve')
const fileContent = rr.resolve('https://github.com/ethereum/greeter.sol')
const fileContent = rr.resolve('https://github.com/ethereum/greeter.sol')
const input = rr.combineSource({ 'greeter.sol': content })
const input = rr.combineSource({ 'greeter.sol': content })
*/
*/
export
*
from
'./resolve
.js
'
export
*
from
'./resolve'
export
*
from
'./combineSource.js'
export
*
from
'./combineSource.js'
export
*
from
'./getFile
.js
'
export
*
from
'./getFile'
remix-resolve/src/resolve.ts
0 → 100644
View file @
2fd155ed
interface
Imported
{
content
:
string
;
cleanURL
:
string
;
type
:
string
;
}
interface
PrvHandld
{
[
filePath
:
string
]:
Imported
}
interface
Handler
{
type
:
string
;
match
(
url
:
string
):
any
;
handle
(
match
:
any
):
any
;
}
export
class
ImportResolver
{
previouslyHandled
:
PrvHandld
[]
constructor
()
{
this
.
previouslyHandled
=
[]
}
handleGithubCall
(
root
:
string
,
filePath
:
string
)
{
return
}
handleHttp
(
url
:
string
,
cleanURL
:
string
)
{
return
}
handleHttps
(
url
:
string
,
cleanURL
:
string
)
{
return
}
handleSwarm
(
url
:
string
,
cleanURL
:
string
)
{
return
}
handleIPFS
(
url
:
string
)
{
return
}
handleLocal
(
root
:
string
,
filePath
:
string
)
{
return
}
getHandlers
():
Handler
[]
{
return
[
{
type
:
'github'
,
match
:
(
url
)
=>
{
return
/^
(
https
?
:
\/\/)?(
www.
)?
github.com
\/([^/]
*
\/[^/]
*
)\/(
.*
)
/
.
exec
(
url
)
},
handle
:
(
match
)
=>
{
this
.
handleGithubCall
(
match
[
3
],
match
[
4
])
}
},
{
type
:
'http'
,
match
:
(
url
)
=>
{
return
/^
(
http
?
:
\/\/?(
.*
))
$/
.
exec
(
url
)
},
handle
:
(
match
)
=>
{
this
.
handleHttp
(
match
[
1
],
match
[
2
])
}
},
{
type
:
'https'
,
match
:
(
url
)
=>
{
return
/^
(
https
?
:
\/\/?(
.*
))
$/
.
exec
(
url
)
},
handle
:
(
match
)
=>
{
this
.
handleHttps
(
match
[
1
],
match
[
2
])
}
},
{
type
:
'swarm'
,
match
:
(
url
)
=>
{
return
/^
(
bzz-raw
?
:
\/\/?(
.*
))
$/
.
exec
(
url
)
},
handle
:
(
match
)
=>
{
this
.
handleSwarm
(
match
[
1
],
match
[
2
])
}
},
{
type
:
'ipfs'
,
match
:
(
url
)
=>
{
return
/^
(
ipfs:
\/\/?
.+
)
/
.
exec
(
url
)
},
handle
:
(
match
)
=>
{
this
.
handleIPFS
(
match
[
1
])
}
},
{
type
:
'local'
,
match
:
(
url
)
=>
{
return
/
(
^
(?!(?:
http:
\/\/)
|
(?:
https:
\/\/)?(?:
www.
)?(?:
github.com
)))(
^
\/
*
[\w
+-_
/]
*
\/)
*
?(\w
+
\.
sol
)
/g
.
exec
(
url
)
},
handle
:
(
match
)
=>
{
this
.
handleLocal
(
match
[
2
],
match
[
3
])
}
}
]
}
resolve
(
filePath
:
string
,
customHandlers
:
Handler
[])
{
var
imported
:
Imported
=
this
.
previouslyHandled
[
filePath
]
if
(
imported
)
{
return
imported
}
const
builtinHandlers
:
Handler
[]
=
this
.
getHandlers
()
const
handlers
:
Handler
[]
=
[...
builtinHandlers
,
...
customHandlers
]
handlers
.
forEach
(
handler
=>
{
const
match
=
handler
.
match
(
filePath
)
if
(
match
)
{
const
content
:
any
=
handler
.
handle
(
match
)
imported
=
{
content
,
cleanURL
:
filePath
,
type
:
handler
.
type
}
this
.
previouslyHandled
[
filePath
]
=
imported
}
})
return
imported
}
}
remix-resolve/tests/test.js
View file @
2fd155ed
const
rr
=
require
(
'../
src
/index.js'
)
const
rr
=
require
(
'../
dist
/index.js'
)
const
assert
=
require
(
'assert'
)
const
assert
=
require
(
'assert'
)
const
fs
=
require
(
'fs'
)
const
fs
=
require
(
'fs'
)
const
solc
=
require
(
'solc'
)
const
solc
=
require
(
'solc'
)
...
...
remix-resolve/tsconfig.json
View file @
2fd155ed
{
{
"compileOnSave"
:
false
,
"compileOnSave"
:
false
,
"include"
:
[
"./src"
],
"include"
:
[
"./src"
],
"compileOptions"
:
{
"compile
r
Options"
:
{
"baseUrl"
:
"./src"
,
"baseUrl"
:
"./src"
,
"outDir"
:
"./dist"
,
"outDir"
:
"./dist"
,
"sourceMap"
:
fals
e
,
"sourceMap"
:
tru
e
,
"declaration"
:
false
,
"declaration"
:
false
,
"module"
:
"commonjs"
,
"module"
:
"commonjs"
,
"strict"
:
true
,
"strict"
:
true
,
...
...
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