TransactionContract.fromJson constructor

TransactionContract.fromJson(
  1. Map<String, dynamic> json
)

Create a new TransactionContract instance by parsing a JSON map.

Implementation

factory TransactionContract.fromJson(Map<String, dynamic> json) {
  final type = TransactionContractType.findByName(
      OnChainUtils.parseString(value: json["type"], name: "type"));
  final any = Any.fromJson(OnChainUtils.parseMap(
      value: json["parameter"], name: "parameter", throwOnNull: true)!);
  final int? permissionId = OnChainUtils.parseInt(
      value: json["permission_id"] ?? json["Permission_id"],
      name: "permission_id");

  return TransactionContract(
    type: type,
    parameter: any,
    permissionId: permissionId,
    provider:
        OnChainUtils.parseBytes(value: json["provider"], name: "provider"),
    contractName: OnChainUtils.parseBytes(
        value: json["contract_name"], name: "contract_name"),
  );
}