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
c19eebab
Unverified
Commit
c19eebab
authored
Aug 16, 2021
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: make contracts package browser compatible
parent
3f9941e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
3 deletions
+84
-3
.gitignore
packages/contracts/.gitignore
+1
-0
package.json
packages/contracts/package.json
+3
-2
build.sh
packages/contracts/scripts/build.sh
+2
-1
generate-artifacts.js
packages/contracts/scripts/generate-artifacts.js
+78
-0
No files found.
packages/contracts/.gitignore
0 → 100644
View file @
c19eebab
src/contract-artifacts.ts
packages/contracts/package.json
View file @
c19eebab
...
@@ -39,13 +39,14 @@
...
@@ -39,13 +39,14 @@
"lint:fix"
:
"yarn lint:check --fix"
,
"lint:fix"
:
"yarn lint:check --fix"
,
"lint:contracts"
:
"yarn solhint -f table contracts/optimistic-ethereum/**/*.sol"
,
"lint:contracts"
:
"yarn solhint -f table contracts/optimistic-ethereum/**/*.sol"
,
"clean"
:
"rm -rf ./dist ./artifacts ./artifacts-ovm ./cache ./cache-ovm ./tsconfig.build.tsbuildinfo"
,
"clean"
:
"rm -rf ./dist ./artifacts ./artifacts-ovm ./cache ./cache-ovm ./tsconfig.build.tsbuildinfo"
,
"deploy"
:
"ts-node
\"
./bin/deploy.ts
\"
&& yarn generate
-
markdown"
,
"deploy"
:
"ts-node
\"
./bin/deploy.ts
\"
&& yarn generate
:
markdown"
,
"serve"
:
"./bin/serve_dump.sh"
,
"serve"
:
"./bin/serve_dump.sh"
,
"prepublishOnly"
:
"yarn copyfiles -u 2
\"
contracts/optimistic-ethereum/**/*
\"
./"
,
"prepublishOnly"
:
"yarn copyfiles -u 2
\"
contracts/optimistic-ethereum/**/*
\"
./"
,
"postpublish"
:
"rimraf OVM iOVM libraries mockOVM"
,
"postpublish"
:
"rimraf OVM iOVM libraries mockOVM"
,
"prepack"
:
"yarn prepublishOnly"
,
"prepack"
:
"yarn prepublishOnly"
,
"postpack"
:
"yarn postpublish"
,
"postpack"
:
"yarn postpublish"
,
"generate-markdown"
:
"node
\"
./scripts/generate-markdown.js
\"
"
,
"generate:markdown"
:
"node
\"
./scripts/generate-markdown.js
\"
"
,
"generate:artifacts"
:
"node
\"
./scripts/generate-artifacts.js
\"
"
,
"pre-commit"
:
"lint-staged"
"pre-commit"
:
"lint-staged"
},
},
"dependencies"
:
{
"dependencies"
:
{
...
...
packages/contracts/scripts/build.sh
View file @
c19eebab
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
set
-e
set
-e
yarn build:typescript &
yarn build:contracts
yarn build:contracts
yarn build:contracts:ovm
yarn build:contracts:ovm
yarn generate:artifacts
yarn build:typescript
packages/contracts/scripts/generate-artifacts.js
0 → 100644
View file @
c19eebab
#!/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
ovmArtifactPaths
=
getContractJsonFiles
(
path
.
resolve
(
__dirname
,
`../artifacts-ovm/contracts`
)
)
const
content
=
`
/* eslint-disable @typescript-eslint/no-var-requires, no-empty */
/*
THIS FILE IS AUTOMATICALLY GENERATED.
DO NOT EDIT.
*/
${
ovmArtifactPaths
.
map
((
artifactPath
)
=>
{
const
artifact
=
require
(
artifactPath
)
const
relPath
=
path
.
relative
(
__dirname
,
artifactPath
)
return
`
let ovm__
${
artifact
.
contractName
}
try {
ovm__
${
artifact
.
contractName
}
= require('
${
relPath
}
')
} catch {}
`
})
.
join
(
'
\n
'
)}
${
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, ovm: boolean): any => {
if (ovm) {
return {
${
ovmArtifactPaths
.
map
((
artifactPath
)
=>
{
const
artifact
=
require
(
artifactPath
)
return
`
${
artifact
.
contractName
}
: ovm__
${
artifact
.
contractName
}
`
})
.
join
(
'
,
\n
'
)}
}[name]
} else {
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
)
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