Commit 8416811b authored by kf's avatar kf

feat: convert generate-deployed-artifacts to ts

parent b882d8c1
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,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.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": "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",
......
#!/usr/bin/env node import path from 'path'
const path = require('path') import glob from 'glob'
const glob = require('glob') import fs from 'fs'
const fs = require('fs')
/**
;(async () => { * Script for automatically generating a TypeScript file for retrieving deploy artifact JSON files.
console.log(`writing deployed contract artifacts typescript file`) * We do this to make sure that this package remains browser compatible.
*/
const main = async () => {
let content = ` let content = `
/* eslint-disable */ /* eslint-disable */
/* /*
...@@ -51,14 +52,12 @@ const fs = require('fs') ...@@ -51,14 +52,12 @@ const fs = require('fs')
content += ` content += `
export const getDeployedContractArtifact = (name: string, network: string): any => { export const getDeployedContractArtifact = (name: string, network: string): any => {
return { return {
${artifactNames ${artifactNames.join(',\n')}
.map((artifactName) => {
return `${artifactName}: ${artifactName}`
})
.join(',\n')}
}[(network + '__' + name).replace(/-/g, '_')] }[(network + '__' + name).replace(/-/g, '_')]
} }
` `
fs.writeFileSync(`./src/contract-deployed-artifacts.ts`, content) 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