Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
705d5670
Unverified
Commit
705d5670
authored
Nov 19, 2021
by
Mark Tyneway
Committed by
GitHub
Nov 19, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1770 from ethereum-optimism/sc/gen-artifacts-ts
feat: rewrite generate-artifacts in ts
parents
a87e3d0d
8d024666
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
53 deletions
+63
-53
package.json
packages/contracts/package.json
+1
-1
generate-artifacts.js
packages/contracts/scripts/generate-artifacts.js
+0
-52
generate-artifacts.ts
packages/contracts/scripts/generate-artifacts.ts
+62
-0
No files found.
packages/contracts/package.json
View file @
705d5670
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
"build:contracts"
:
"hardhat compile --show-stack-traces"
,
"build:contracts"
:
"hardhat compile --show-stack-traces"
,
"build:dump"
:
"ts-node bin/take-dump.ts"
,
"build:dump"
:
"ts-node bin/take-dump.ts"
,
"autogen:markdown"
:
"node scripts/generate-markdown.js"
,
"autogen:markdown"
:
"node scripts/generate-markdown.js"
,
"autogen:artifacts"
:
"
node scripts/generate-artifacts.j
s && ts-node scripts/generate-deployed-artifacts.ts"
,
"autogen:artifacts"
:
"
ts-node scripts/generate-artifacts.t
s && ts-node scripts/generate-deployed-artifacts.ts"
,
"test"
:
"yarn test:contracts"
,
"test"
:
"yarn test:contracts"
,
"test:contracts"
:
"hardhat test --show-stack-traces"
,
"test:contracts"
:
"hardhat test --show-stack-traces"
,
"test:coverage"
:
"NODE_OPTIONS=--max_old_space_size=8192 hardhat coverage && istanbul check-coverage --statements 88 --branches 76 --functions 84 --lines 88"
,
"test:coverage"
:
"NODE_OPTIONS=--max_old_space_size=8192 hardhat coverage && istanbul check-coverage --statements 88 --branches 76 --functions 84 --lines 88"
,
...
...
packages/contracts/scripts/generate-artifacts.js
deleted
100644 → 0
View file @
a87e3d0d
#!/usr/bin/env node
const
path
=
require
(
'
path
'
)
const
glob
=
require
(
'
glob
'
)
const
fs
=
require
(
'
fs
'
)
;(
async
()
=>
{
console
.
log
(
`writing contract artifacts typescript file`
)
const
getContractJsonFiles
=
(
artifactsFolder
)
=>
{
return
glob
.
sync
(
`
${
artifactsFolder
}
/**/*.json`
).
filter
((
match
)
=>
{
return
!
match
.
endsWith
(
'
.dbg.json
'
)
})
}
const
evmArtifactPaths
=
getContractJsonFiles
(
path
.
resolve
(
__dirname
,
`../artifacts/contracts`
)
)
const
content
=
`
/* eslint-disable @typescript-eslint/no-var-requires, no-empty */
/*
THIS FILE IS AUTOMATICALLY GENERATED.
DO NOT EDIT.
*/
${
evmArtifactPaths
.
map
((
artifactPath
)
=>
{
const
artifact
=
require
(
artifactPath
)
const
relPath
=
path
.
relative
(
__dirname
,
artifactPath
)
return
`
let
${
artifact
.
contractName
}
try {
${
artifact
.
contractName
}
= require('
${
relPath
}
')
} catch {}
`
})
.
join
(
'
\n
'
)}
export const getContractArtifact = (name: string): any => {
return {
${
evmArtifactPaths
.
map
((
artifactPath
)
=>
{
const
artifact
=
require
(
artifactPath
)
return
`
${
artifact
.
contractName
}
:
${
artifact
.
contractName
}
`
})
.
join
(
'
,
\n
'
)}
}[name]
}
`
fs
.
writeFileSync
(
`./src/contract-artifacts.ts`
,
content
)
})().
catch
(
console
.
error
)
packages/contracts/scripts/generate-artifacts.ts
0 → 100644
View file @
705d5670
import
path
from
'
path
'
import
glob
from
'
glob
'
import
fs
from
'
fs
'
/**
* Script for automatically generating a file which has a series of `require` statements for
* importing JSON contract artifacts. We do this to preserve browser compatibility.
*/
const
main
=
async
()
=>
{
const
contractArtifactsFolder
=
path
.
resolve
(
__dirname
,
`../artifacts/contracts`
)
const
artifactPaths
=
glob
.
sync
(
`
${
contractArtifactsFolder
}
/**/*.json`
)
.
filter
((
match
)
=>
{
// Filter out the debug outputs.
return
!
match
.
endsWith
(
'
.dbg.json
'
)
})
const
content
=
`
/* eslint-disable @typescript-eslint/no-var-requires, no-empty */
/*
THIS FILE IS AUTOMATICALLY GENERATED.
DO NOT EDIT.
*/
${
artifactPaths
.
map
((
artifactPath
)
=>
{
// eslint-disable-next-line @typescript-eslint/no-var-requires
const
artifact
=
require
(
artifactPath
)
const
relPath
=
path
.
relative
(
__dirname
,
artifactPath
)
return
`
let
${
artifact
.
contractName
}
try {
${
artifact
.
contractName
}
= require('
${
relPath
}
')
} catch {}
`
})
.
join
(
'
\n
'
)}
export const getContractArtifact = (name: string): any => {
return {
${
artifactPaths
.
map
((
artifactPath
)
=>
{
// eslint-disable-next-line @typescript-eslint/no-var-requires
const
artifact
=
require
(
artifactPath
)
return
`
${
artifact
.
contractName
}
`
})
.
join
(
'
,
\n
'
)}
}[name]
}
`
fs
.
writeFileSync
(
path
.
resolve
(
__dirname
,
`../src/contract-artifacts.ts`
),
content
)
}
main
()
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