swarm import done

yann300-patch-18
aniket-engg 4 years ago committed by Aniket
parent 115193449b
commit 91352d0e30
  1. 9
      libs/remix-url-resolver/src/resolve.ts
  2. 10
      libs/remix-url-resolver/tests/test.ts
  3. 87
      package-lock.json
  4. 1
      package.json

@ -1,5 +1,5 @@
import axios, { AxiosResponse } from 'axios'
var Bzz = require('web3-bzz');
import { BzzNode as Bzz } from '@erebos/bzz-node'
export interface Imported {
content: string;
@ -90,9 +90,10 @@ export class RemixURLResolver {
async handleSwarm(url: string, cleanUrl: string): Promise<HandlerResponse> {
//eslint-disable-next-line no-useless-catch
try {
const bzz = new Bzz(Bzz.givenProvider || 'http://swarm-gateways.net');
const contentInBuffer = await bzz.download(url)
return { content: contentInBuffer.toString(), cleanUrl }
const bzz = new Bzz({url: 'http://swarm-gateways.net'});
const url = bzz.getDownloadURL(cleanUrl, {mode: 'raw'})
const response: AxiosResponse = await axios.get(url)
return { content: response.data, cleanUrl }
} catch(e) {
throw e
}

@ -31,12 +31,6 @@ describe('testRunner', () => {
// handle: (match: Array<string>) => { return handleLocal(match[2], match[3]) }
// }
// ]
// browser/greeter.sol :
// bzz-raw://a728627437140f2b0b46c1bcfb0de2126d18b40e9b61c3e31bd96abebf714619
// browser/mortal.sol :
// bzz-raw://bbd213997d71870470ad72e9b4a74d7898d11bfd3bfc483220f9fd0721607bff
// metadata.json :
// bzz-raw://ce595759fa991e3b165b280c9376f073c1d9d5591edaadf05fe76ddef8909249
// urlResolver.resolve(fileName, localFSHandler)
// .then((sources: object) => {
// results = sources
@ -168,7 +162,7 @@ describe('testRunner', () => {
it('should have 3 items', () => {
assert.equal(Object.keys(results).length, 3)
})
it('should return contract content from raw github url', () => {
it('should return contract content from IPFS url', () => {
const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'})
const expt: object = {
content: content,
@ -199,7 +193,7 @@ describe('testRunner', () => {
it('should have 3 items', () => {
assert.equal(Object.keys(results).length, 3)
})
it('should return contract content from raw github url', () => {
it('should return contract content from SWARM url', () => {
const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'})
const expt: object = {
content: content,

87
package-lock.json generated

@ -2461,6 +2461,60 @@
"kuler": "^2.0.0"
}
},
"@erebos/bzz": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/@erebos/bzz/-/bzz-0.13.0.tgz",
"integrity": "sha512-ETjXxeNzT7wGofz0CcrNEc/dLeLg0DALuxpMymrzK+AvLvP8PZUfiFn+tZoupSMGaLldfSLJXweOfs3BimVaRg==",
"requires": {
"@babel/runtime": "^7.8.3"
}
},
"@erebos/bzz-node": {
"version": "0.13.0",
"resolved": "https://registry.npmjs.org/@erebos/bzz-node/-/bzz-node-0.13.0.tgz",
"integrity": "sha512-Mmo9awJG/Agj6lPqicj8VRdUELoT9pP2xIVniaoUqIMMZkf+lswXFylkyH578ZCNaehyZTTttaXS5WA+T9UVyA==",
"requires": {
"@babel/runtime": "^7.8.3",
"@erebos/bzz": "^0.13.0",
"form-data": "^3.0.0",
"node-fetch": "^2.6.0",
"tar-stream": "^2.1.0"
},
"dependencies": {
"bl": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.0.3.tgz",
"integrity": "sha512-fs4G6/Hu4/EE+F75J8DuN/0IpQqNjAdC7aEQv7Qt8MHGUH7Ckv2MwTEEeN9QehD0pfIDkMI1bkHYkKy7xHyKIg==",
"requires": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",
"readable-stream": "^3.4.0"
}
},
"form-data": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz",
"integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
},
"tar-stream": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.4.tgz",
"integrity": "sha512-o3pS2zlG4gxr67GmFYBLlq+dM8gyRGUOvsrHclSkvtVtQbjV0s/+ZE8OpICbaj8clrX3tjeHngYGP7rweaBnuw==",
"requires": {
"bl": "^4.0.3",
"end-of-stream": "^1.4.1",
"fs-constants": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^3.1.1"
}
}
}
},
"@ethersproject/abi": {
"version": "5.0.7",
"resolved": "https://registry.npmjs.org/@ethersproject/abi/-/abi-5.0.7.tgz",
@ -6882,7 +6936,7 @@
"@remixproject/engine": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@remixproject/engine/-/engine-0.3.3.tgz",
"integrity": "sha1-jEde0zAFQBj8C0s49f1FqbK9gIY=",
"integrity": "sha512-0orGJhxHAFMUMokfDVq04yy0cvFknyrk9PcqvJw3KqChhusgkLw/J/KqJszywD9BmIjLgdc3n8vRtCmHICR3mA==",
"requires": {
"@remixproject/plugin-api": "0.3.3",
"@remixproject/plugin-utils": "0.3.3"
@ -6891,7 +6945,7 @@
"@remixproject/engine-web": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@remixproject/engine-web/-/engine-web-0.3.3.tgz",
"integrity": "sha1-ZQZD7museqljZNPHpuOwG7dgiZU=",
"integrity": "sha512-GF+WHrZyT8OS9ApmAv6ujUfX/lfxbpfTYbYC0To/EznusrBYfm0tmem1xvmI4PJ5C1NOxz9j862S4I4AxWGOng==",
"requires": {
"@remixproject/engine": "0.3.3",
"@remixproject/plugin-api": "0.3.3",
@ -6901,7 +6955,7 @@
"@remixproject/plugin": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@remixproject/plugin/-/plugin-0.3.3.tgz",
"integrity": "sha1-yy+ifasg+IQ5CDJ2jmXRaRc8sAE=",
"integrity": "sha512-gSZdgBjb4y2N2+5kMfbJYjO2zH8b1pFd3xdY4ViL5vtt8l4lup+iOVidrGTv1lPPl7Snk+E8NQhRk8Snr6//mg==",
"requires": {
"@remixproject/plugin-api": "0.3.3",
"@remixproject/plugin-utils": "0.3.3",
@ -6911,7 +6965,7 @@
"events": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.2.0.tgz",
"integrity": "sha1-k7h8GPjvzUICpGGuxN/AVWtjk3k="
"integrity": "sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg=="
}
}
},
@ -6941,7 +6995,7 @@
"@remixproject/plugin-webview": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@remixproject/plugin-webview/-/plugin-webview-0.3.3.tgz",
"integrity": "sha1-3x7RgdkD1ya0JTjfWsIp8cpQOqI=",
"integrity": "sha512-2/O2hUgcTFFmuKYnHl65FW7n591lF1PLAmFUSzoUOezs0iAg8+IP1ydejVXFLWhZByLkiQezHu/kezA5g4cwaQ==",
"requires": {
"@remixproject/plugin": "0.3.3",
"@remixproject/plugin-api": "0.3.3",
@ -6951,7 +7005,7 @@
"@remixproject/plugin-ws": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@remixproject/plugin-ws/-/plugin-ws-0.3.3.tgz",
"integrity": "sha1-qxGVX9ut7uRG0FE+8gOnbyodNr8=",
"integrity": "sha512-QHWv5sjzUIb+rsLyAcOV67tShx8fniJvxYglqURaBc9LXdz0j5QfwnDIGwJwvnkJqAsk3MnXizaIXMU7CvKuzw==",
"requires": {
"@remixproject/plugin": "0.3.3",
"@remixproject/plugin-api": "0.3.3",
@ -8913,8 +8967,7 @@
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"at-least-node": {
"version": "1.0.0",
@ -12586,7 +12639,6 @@
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"requires": {
"delayed-stream": "~1.0.0"
}
@ -14598,8 +14650,7 @@
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"delegates": {
"version": "1.0.0",
@ -16793,7 +16844,7 @@
"express-ws": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/express-ws/-/express-ws-4.0.0.tgz",
"integrity": "sha1-2r2NyXRRZBiQKkH+bjDtlJtNNsQ=",
"integrity": "sha512-KEyUw8AwRET2iFjFsI1EJQrJ/fHeGiJtgpYgEWG3yDv4l/To/m3a2GaYfeGyB3lsWdvbesjF5XCMx+SVBgAAYw==",
"requires": {
"ws": "^5.2.0"
},
@ -16801,7 +16852,7 @@
"ws": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
"integrity": "sha1-3/7xSGa46NyRM1glFNG++vlumA8=",
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
"requires": {
"async-limiter": "~1.0.0"
}
@ -17599,8 +17650,7 @@
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
"dev": true
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
},
"fs-extra": {
"version": "3.0.1",
@ -26085,14 +26135,12 @@
"mime-db": {
"version": "1.44.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
"dev": true
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
},
"mime-types": {
"version": "2.1.27",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
"dev": true,
"requires": {
"mime-db": "1.44.0"
}
@ -27521,8 +27569,7 @@
"node-fetch": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==",
"dev": true
"integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
},
"node-fetch-npm": {
"version": "2.0.4",

@ -127,6 +127,7 @@
]
},
"dependencies": {
"@erebos/bzz-node": "^0.13.0",
"@remixproject/engine": "^0.3.3",
"@remixproject/engine-web": "^0.3.3",
"@remixproject/plugin": "^0.3.3",

Loading…
Cancel
Save