diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index 247a568842..6ef9410305 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -99,7 +99,7 @@ export class RemixURLResolver { url = url.replace(/^ipfs:\/\/?/, 'ipfs/') //eslint-disable-next-line no-useless-catch try { - const req = 'https://gateway.ipfs.io/' + url + const req = 'https://ipfsgw.komputing.org/' + url // If you don't find greeter.sol on ipfs gateway use local // const req = 'http://localhost:8080/' + url const response: AxiosResponse = await axios.get(req) diff --git a/libs/remix-url-resolver/tests/example_1/greeter.sol b/libs/remix-url-resolver/tests/example_1/greeter.sol index 8425568af9..95e622d176 100644 --- a/libs/remix-url-resolver/tests/example_1/greeter.sol +++ b/libs/remix-url-resolver/tests/example_1/greeter.sol @@ -14,4 +14,4 @@ contract Greeter is Mortal { function greet() public view returns (string memory) { return greeting; } -} +} \ No newline at end of file diff --git a/libs/remix-url-resolver/tests/test.ts b/libs/remix-url-resolver/tests/test.ts index 054a593e1e..c3ee376504 100644 --- a/libs/remix-url-resolver/tests/test.ts +++ b/libs/remix-url-resolver/tests/test.ts @@ -141,6 +141,37 @@ describe('testRunner', () => { assert.deepEqual(results, expt) }) }) + + // Test IPFS imports + describe('test getting IPFS imports', () => { + const urlResolver = new RemixURLResolver() + const fileName = 'ipfs://QmcuCKyokk9Z6f65ADAADNiS2R2xCjfRkv7mYBSWDwtA7M' + let results: object = {} + + before(done => { + urlResolver.resolve(fileName) + .then((sources: object) => { + results = sources + done() + }) + .catch((e: Error) => { + throw e + }) + }) + + it('should have 3 items', () => { + assert.equal(Object.keys(results).length, 3) + }) + it('should return contract content from raw github url', () => { + const content = fs.readFileSync(__dirname + '/example_1/greeter.sol', { encoding: 'utf8'}) + const expt: object = { + content: content, + cleanUrl: 'ipfs/QmcuCKyokk9Z6f65ADAADNiS2R2xCjfRkv7mYBSWDwtA7M', + type: 'ipfs' + } + assert.deepEqual(results, expt) + }) + }) }) }) })