contractDeployMultiSig method

Future<ContractDeployResponse> contractDeployMultiSig(
  1. String nodeAddress,
  2. int maxVotes,
  3. int minVotes,
  4. double amount,
  5. double maxFee,
)

Implementation

Future<ContractDeployResponse> contractDeployMultiSig(String nodeAddress,
    int maxVotes, int minVotes, 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": "0x05",
        "amount": amount,
        "maxFee": maxFee,
        "args": [
          {"index": 0, "format": "byte", "value": maxVotes.toString()},
          {"index": 1, "format": "byte", "value": minVotes.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 {
      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;
}