Commit 410f6a47 authored by coderkentzhang's avatar coderkentzhang
Browse files

fix save address bug

parent 812f7ab4
......@@ -70,7 +70,9 @@ class ContractNote:
if 'address' not in config:
# print("address not in config",config)
config['address'] = {}
print("save new address {} -> {}".format(contractname,newaddress))
config['address'][contractname] = newaddress
config.write()
@staticmethod
def save_history(contractname,newaddress,blocknum=None,txhash=None):
......
......@@ -552,7 +552,7 @@ def main(argv):
ContractNote.save_contract_address(name, address)
print("on block : {},address: {} ".format(blocknum, address))
if needSaveAddress is True:
ContractNote.save_address(name, address, blocknum,txhash)
ContractNote.save_address(name, address)
print("address save to file: ", client_config.contract_info_file)
else:
print(
......
pragma solidity ^0.4.24;
contract HelloEvent{
string name;
event onset(string newname);
string name ;
bool b;
event on_set(string newname);
event on_number(string name,int indexed age);
event on_two_event(string name ,int indexed age, string indexed key);
event on_address(address addr);
......@@ -18,6 +19,7 @@ contract HelloEvent{
{
name = n;
b = i;
}
......@@ -35,10 +37,9 @@ contract HelloEvent{
}
function set(string n) public{
emit onset(n);
emit on_set(n);
emit on_number(n,5);
emit on_address(0xAb3BB3C6111ff74A280B3A560eB204FC9538061E);
name = n;
name = n;
}
}
......@@ -46,8 +46,7 @@ try:
memo = "tx:" + result["transactionHash"]
# 把部署结果存入文件备查
ContractNote.save_address(contract_name,
result["contractAddress"],
int(result["blockNumber"], 16), memo)
result["contractAddress"])
# 发送交易,调用一个改写数据的接口
print("\n>>sendRawTransaction:----------------------------------------------------")
to_address = result['contractAddress'] # use new deploy address
......
......@@ -156,17 +156,24 @@ def main(argv):
event_name = argv[2]
indexed_value = argv[3:]
print("usage input {},{},{},{}".format(contractname, address, event_name, indexed_value))
if address == "last":
cn = ContractNote()
address = cn.get_last(contractname)
print("hex address :", address)
abifile = "contracts/" + contractname + ".abi"
parser = DatatypeParser(abifile)
client = BcosClient()
print(client.getinfo())
register_event_callback([address], event_name, indexed_value)
try:
print("usage input {},{},{},{}".format(contractname, address, event_name, indexed_value))
if address == "last":
cn = ContractNote()
address = cn.get_last(contractname)
print("hex address :", address)
abifile = "contracts/" + contractname + ".abi"
parser = DatatypeParser(abifile)
client = BcosClient()
print(client.getinfo())
register_event_callback([address], event_name, indexed_value)
except Exception as e:
import traceback
traceback.print_exc()
client.finish()
import time
time.sleep(0.5)
sys.exit(-1)
if __name__ == "__main__":
main(sys.argv[1:])
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