aboutsummaryrefslogtreecommitdiffstats
path: root/packages/migrations/src/utils/artifact_writer.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-06-28 06:13:57 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-06-30 08:25:56 +0800
commit6e1a549fcb5cc9257ee984a906db78dd2568042b (patch)
tree08432dbc8a2e12c352030ed40f62f3bd44227f97 /packages/migrations/src/utils/artifact_writer.ts
parent5f0a2953c63c31daa975b587f5c5072b6f7e418c (diff)
downloaddexon-0x-contracts-6e1a549fcb5cc9257ee984a906db78dd2568042b.tar.gz
dexon-0x-contracts-6e1a549fcb5cc9257ee984a906db78dd2568042b.tar.zst
dexon-0x-contracts-6e1a549fcb5cc9257ee984a906db78dd2568042b.zip
Use ledger subprovider
Diffstat (limited to 'packages/migrations/src/utils/artifact_writer.ts')
-rw-r--r--packages/migrations/src/utils/artifact_writer.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/migrations/src/utils/artifact_writer.ts b/packages/migrations/src/utils/artifact_writer.ts
new file mode 100644
index 000000000..2da5a09dd
--- /dev/null
+++ b/packages/migrations/src/utils/artifact_writer.ts
@@ -0,0 +1,26 @@
+import { BaseContract } from '@0xproject/base-contract';
+import { ContractArtifact } from '@0xproject/sol-compiler';
+import * as fs from 'fs';
+import * as path from 'path';
+
+export class ArtifactWriter {
+ private _artifactsDir: string;
+ private _networkId: number;
+ constructor(artifactsDir: string, networkId: number) {
+ this._artifactsDir = artifactsDir;
+ this._networkId = networkId;
+ }
+ // This updates the artifact file but does not update the `artifacts` module above. It will not
+ // contain the saved artifact changes.
+ public saveArtifact(contract: BaseContract): void {
+ const contractName = contract.contractName;
+ const artifactFile = path.join(this._artifactsDir, `${contractName}.json`);
+ const artifact: ContractArtifact = JSON.parse(fs.readFileSync(artifactFile).toString());
+ artifact.networks[this._networkId] = {
+ address: contract.address,
+ links: {},
+ constructorArgs: JSON.stringify(contract.constructorArgs),
+ };
+ fs.writeFileSync(artifactFile, JSON.stringify(artifact, null, '\t'));
+ }
+}