contractDeployTimeLock method
Implementation
Future<ContractDeployResponse> contractDeployTimeLock(
String nodeAddress, int timestamp, double amount, double maxFee) async {
ContractDeployRequest contractDeployRequest;
ContractDeployResponse contractDeployResponse;
Map<String, dynamic> mapParams;
Completer<ContractDeployResponse> _completer =
new Completer<ContractDeployResponse>();
mapParams = {
'method': ContractDeployRequest.METHOD_NAME,
'params': [
{
"from": nodeAddress,
"codeHash": "0x01",
"amount": amount,
"maxFee": maxFee,
"args": [
{"index": 0, "format": "uint64", "value": timestamp.toString()}
]
}
],
'id': 101,
'key': keyApp
};
try {
if (this.nodeType == NORMAL_VPS_NODE) {
SSHClientStatus sshClientStatus;
sshClientStatus = await VpsUtil().connectVps(this.apiUrl, keyApp);
if (sshClientStatus.sshClientStatus) {
sshClient = sshClientStatus.sshClient;
}
var response = await ssh.HttpClientImpl(
clientFactory: () =>
ssh.SSHTunneledBaseClient(sshClientStatus.sshClient)).request(
this.apiUrl,
method: 'POST',
data: jsonEncode(mapParams),
headers: requestHeaders);
if (response.status == 200) {
contractDeployResponse =
contractDeployResponseFromJson(response.text);
}
} else {
if (this.nodeType == SHARED_NODE) {
contractDeployRequest = ContractDeployRequest.fromJson(mapParams);
AppService().sendTx(
nodeAddress,
amount.toString(),
"",
"",
HEX.encode(new DeployContractAttachment(
"0x01", contractDeployRequest.params.last.args)
.toBytes()));
} else {
contractDeployRequest = ContractDeployRequest.fromJson(mapParams);
body = json.encode(contractDeployRequest.toJson());
responseHttp = await http.post(Uri.parse(this.apiUrl),
body: body, headers: requestHeaders);
if (responseHttp.statusCode == 200) {
contractDeployResponse =
contractDeployResponseFromJson(responseHttp.body);
}
}
}
} catch (e) {
logger.e(e.toString());
contractDeployResponse = new ContractDeployResponse();
contractDeployResponse.error = new ContractDeployResponseError();
contractDeployResponse.error.message = e.toString();
}
_completer.complete(contractDeployResponse);
return _completer.future;
}