from static method

TronContractData from(
  1. Transaction_Contract_ContractType type,
  2. Any parameter
)

Implementation

static TronContractData from(
    tron.Transaction_Contract_ContractType type, Any parameter) {
  return switch (type) {
    tron.Transaction_Contract_ContractType.TransferContract =>
      TronTransferContractData.fromPB(
        parameter.unpackInto<TransferContract>(TransferContract()),
      ),
    tron.Transaction_Contract_ContractType.TriggerSmartContract =>
      TronTriggerSmartContractData.from(
        parameter.unpackInto<TriggerSmartContract>(TriggerSmartContract()),
      ),
    tron.Transaction_Contract_ContractType.TransferAssetContract =>
      TronTransferAssetContractData.fromPB(
        parameter.unpackInto<TransferAssetContract>(TransferAssetContract()),
      ),
    _ => throw UnsupportedError(
        "Unsupported Contract Type: $type with $parameter",
      ),
  };
}