contract interaction scripts
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@ docs/src
|
||||
node_modules/
|
||||
coverage/
|
||||
lint/
|
||||
script/
|
||||
|
||||
# VIM
|
||||
*.swo
|
||||
|
||||
@@ -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<Contract> {
|
||||
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 = {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user