Commit 8416811b authored by kf's avatar kf

feat: convert generate-deployed-artifacts to ts

parent b882d8c1
......@@ -23,7 +23,7 @@
"build:contracts": "hardhat compile --show-stack-traces",
"build:dump": "ts-node bin/take-dump.ts",
"autogen:markdown": "node scripts/generate-markdown.js",
"autogen:artifacts": "node scripts/generate-artifacts.js && node scripts/generate-deployed-artifacts.js",
"autogen:artifacts": "node scripts/generate-artifacts.js && ts-node scripts/generate-deployed-artifacts.ts",
"test": "yarn test:contracts",
"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",
......
#!/usr/bin/env node
const path = require('path')
const glob = require('glob')
const fs = require('fs')
;(async () => {
console.log(`writing deployed contract artifacts typescript file`)
import path from 'path'
import glob from 'glob'
import fs from 'fs'
/**
* Script for automatically generating a TypeScript file for retrieving deploy artifact JSON files.
* We do this to make sure that this package remains browser compatible.
*/
const main = async () => {
let content = `
/* eslint-disable */
/*
......@@ -51,14 +52,12 @@ const fs = require('fs')
content += `
export const getDeployedContractArtifact = (name: string, network: string): any => {
return {
${artifactNames
.map((artifactName) => {
return `${artifactName}: ${artifactName}`
})
.join(',\n')}
${artifactNames.join(',\n')}
}[(network + '__' + name).replace(/-/g, '_')]
}
`
fs.writeFileSync(`./src/contract-deployed-artifacts.ts`, content)
})().catch(console.error)
}
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment