-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add solc/download and do not include the soljson file in source
- Loading branch information
v1rtl
committed
Sep 26, 2021
1 parent
edacc52
commit 3e4eaae
Showing
9 changed files
with
70 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
.solc-cache | ||
soljson.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ export { createRequire } from 'https://deno.land/[email protected]/node/module.ts' | |
export { existsSync } from 'https://deno.land/[email protected]/node/fs.ts' | ||
export { default as semver } from 'https://esm.sh/semver?no-check' | ||
export { keccak256 } from 'https://esm.sh/js-sha3' | ||
export { readerFromStreamReader, copy } from 'https://deno.land/[email protected]/io/mod.ts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { readerFromStreamReader, copy } from './deps.ts' | ||
|
||
export const download = async (version?: string) => { | ||
console.log(`Fetching releases...`) | ||
const { releases, latestRelease } = await fetch('https://solc-bin.ethereum.org/bin/list.json').then((res) => | ||
res.json() | ||
) | ||
|
||
const jsFile = releases[version || latestRelease] | ||
|
||
console.log(`Downloading soljson from https://solc-bin.ethereum.org/bin/${jsFile}...`) | ||
|
||
const res = await fetch(`https://solc-bin.ethereum.org/bin/${jsFile}`) | ||
|
||
const rdr = res.body?.getReader() | ||
|
||
if (rdr) { | ||
const r = readerFromStreamReader(rdr) | ||
const f = await Deno.open('./soljson.js', { create: true, write: true }) | ||
await copy(r, f) | ||
f.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
import { setupMethods } from './wrapper.ts' | ||
import { soljson } from './module.ts' | ||
import { createRequire } from './deps.ts' | ||
import { download } from './download.ts' | ||
import process from 'https://esm.sh/process/browser.js' | ||
import { exists } from './utils.ts' | ||
|
||
export const solc = setupMethods(soljson) | ||
const require = createRequire(import.meta.url) | ||
|
||
const __filename = new URL('', import.meta.url).pathname | ||
const __dirname = new URL('.', import.meta.url).pathname | ||
|
||
// @ts-ignore Node.js | ||
globalThis.__dirname = __dirname | ||
// @ts-ignore Node.js | ||
globalThis.__filename = __filename | ||
|
||
process.versions = { node: '12.4.0' } | ||
|
||
// @ts-ignore Node.js | ||
globalThis.process = process | ||
|
||
if (!(await exists('./soljson.js'))) await download() | ||
|
||
export const solc = setupMethods(require('./soljson.js')) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
import * as _assert from 'https://deno.land/x/[email protected]/node/assert.ts' | ||
|
||
export const assert = (actual: unknown, message: string) => { | ||
return _assert.strict(actual, message) | ||
export const assert = (actual: unknown, message: string) => _assert.strict(actual, message) | ||
|
||
export const exists = async (filename: string): Promise<boolean> => { | ||
try { | ||
await Deno.stat(filename) | ||
// successful, file or directory must exist | ||
return true | ||
} catch (error) { | ||
if (error instanceof Deno.errors.NotFound) { | ||
// file or directory does not exist | ||
return false | ||
} else { | ||
// unexpected error, maybe permissions, pass it along | ||
throw error | ||
} | ||
} | ||
} |