From 44d1f28606dea517c86bdb8512f7732139876ba5 Mon Sep 17 00:00:00 2001 From: mingda Date: Sat, 27 Jun 2020 18:01:18 +0800 Subject: [PATCH] contract interaction scripts --- .gitignore | 1 + test/utils/Contracts.ts | 10 +++++----- tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 28e453c..38880f7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ docs/src node_modules/ coverage/ lint/ +script/ # VIM *.swo diff --git a/test/utils/Contracts.ts b/test/utils/Contracts.ts index 7901049..31a936c 100644 --- a/test/utils/Contracts.ts +++ b/test/utils/Contracts.ts @@ -35,7 +35,7 @@ interface ContractJson { byteCode: string; } -function _getContractJSON(contractName: string): ContractJson { +export function getContractJSON(contractName: string): ContractJson { switch (contractName) { case DODO_CONTRACT_NAME: return { @@ -85,22 +85,22 @@ function _getContractJSON(contractName: string): ContractJson { } export function getContractWithAddress(contractName: string, address: string) { - var Json = _getContractJSON(contractName) + var Json = getContractJSON(contractName) var web3 = getDefaultWeb3() return new web3.eth.Contract(Json.abi, address) } export function getDepolyedContract(contractName: string): Contract { - var Json = _getContractJSON(contractName) + var Json = getContractJSON(contractName) var networkId = process.env.NETWORK_ID - var deployedAddress = _getContractJSON(contractName).networks[networkId].address + var deployedAddress = getContractJSON(contractName).networks[networkId].address var web3 = getDefaultWeb3() return new web3.eth.Contract(Json.abi, deployedAddress) } export async function newContract(contractName: string, args: any[] = []): Promise { var web3 = getDefaultWeb3() - var Json = _getContractJSON(contractName) + var Json = getContractJSON(contractName) var contract = new web3.eth.Contract(Json.abi) var adminAccount = (await web3.eth.getAccounts())[0] let parameter = { diff --git a/tsconfig.json b/tsconfig.json index 5ecfa5e..3e1de7f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "typeRoots": ["node_modules/@types"], "types": ["node", "mocha", "chai"] }, - "include": ["src", "test"], + "include": ["src", "test", "script"], "exclude": ["scripts/**/*", "build/**/*", "migrations/**/*"], "compileOnSave": true }