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
e07f3b90
Commit
e07f3b90
authored
Dec 09, 2018
by
0mkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try async ipfs request
parent
a98c8ac3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
7 deletions
+52
-7
package.json
remix-resolve/package.json
+0
-1
resolve.ts
remix-resolve/src/resolve.ts
+27
-4
test.js
remix-resolve/tests/test.js
+25
-2
No files found.
remix-resolve/package.json
View file @
e07f3b90
...
...
@@ -30,7 +30,6 @@
},
"dependencies"
:
{
"axios"
:
"^0.18.0"
,
"request"
:
"^2.88.0"
,
"solc"
:
"^0.5.0"
,
"url"
:
"^0.11.0"
,
"valid-url"
:
"^1.0.9"
...
...
remix-resolve/src/resolve.ts
View file @
e07f3b90
import
axios
from
'axios'
interface
Imported
{
content
:
string
;
cleanURL
:
string
;
...
...
@@ -31,8 +32,30 @@ export class ImportResolver {
handleSwarm
(
url
:
string
,
cleanURL
:
string
)
{
return
}
handleIPFS
(
url
:
string
)
{
return
async
handleIPFS
(
url
:
string
)
{
// replace ipfs:// with /ipfs/
url
=
url
.
replace
(
/^ipfs:
\/\/?
/
,
'ipfs/'
)
console
.
log
(
url
)
try
{
const
response
=
await
axios
.
get
(
'http://localhost:8080/'
+
url
)
return
response
.
data
}
catch
(
e
)
{
throw
e
}
/*axios.get('http://localhost:8080/' + url)
.then(function (response) {
// handle success
console.log(response);
return response.data
})
.catch(function (error) {
// handle error
console.log(error);
})
.then(function () {
// always executed
});
*/
}
handleLocal
(
root
:
string
,
filePath
:
string
)
{
return
...
...
@@ -66,13 +89,13 @@ export class ImportResolver {
}
]
}
async
resolve
(
filePath
:
string
,
customHandlers
:
Handler
[])
{
async
resolve
(
filePath
:
string
,
customHandlers
?
:
Handler
[])
{
var
imported
:
Imported
=
this
.
previouslyHandled
[
filePath
]
if
(
imported
)
{
return
imported
}
const
builtinHandlers
:
Handler
[]
=
this
.
getHandlers
()
const
handlers
:
Handler
[]
=
[...
builtinHandlers
,
...
custom
Handlers
]
const
handlers
:
Handler
[]
=
customHandlers
?
[...
builtinHandlers
,
...
customHandlers
]
:
[...
builtin
Handlers
]
handlers
.
forEach
(
handler
=>
{
const
match
=
handler
.
match
(
filePath
)
if
(
match
)
{
...
...
remix-resolve/tests/test.js
View file @
e07f3b90
...
...
@@ -6,7 +6,7 @@ const path = require('path')
describe
(
'testRunner'
,
function
()
{
describe
(
'#resolve'
,
function
()
{
describe
(
'test example_1 [local imports]]'
,
function
()
{
let
filen
ame
=
'../remix-resolve/tests/example_1/greeter.sol'
const
fileN
ame
=
'../remix-resolve/tests/example_1/greeter.sol'
let
results
=
{}
before
(
function
(
done
)
{
...
...
@@ -30,7 +30,7 @@ describe('testRunner', function () {
handle
:
(
match
)
=>
{
return
handleLocal
(
match
[
2
],
match
[
3
])
}
}
]
resolver
.
resolve
(
file
n
ame
,
localFSHandler
)
resolver
.
resolve
(
file
N
ame
,
localFSHandler
)
.
then
(
sources
=>
{
results
=
sources
done
()
...
...
@@ -53,5 +53,28 @@ describe('testRunner', function () {
assert
.
deepEqual
(
results
,
expt
)
})
})
// test IPFShandle
describe
(
'test getting IPFS files'
,
function
()
{
const
fileName
=
'ipfs://'
+
'QmeKtwMBqz5Ac7oL8SyTD96mccEzw9X9d39jLb2kgnBYbn'
let
results
=
[]
before
(
function
(
done
)
{
const
resolver
=
new
rr
.
ImportResolver
()
var
sources
=
[]
resolver
.
resolve
(
fileName
)
.
then
(
sources
=>
{
console
.
log
(
sources
)
results
=
sources
done
()
})
.
catch
(
e
=>
{
throw
e
})
})
it
(
'should have 3 items'
,
function
()
{
assert
.
equal
(
Object
.
keys
(
results
).
length
,
3
)
})
})
})
})
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