Skip to main content
Post Undeleted by xcanchal
Post Deleted by xcanchal

I am using a data separation pattern, keeping my data in a contract and the business logic in a separate contract that calls the storage one to add/update/delete records.

In order to send the Data struct as an argument in those CRUD functions, would it be acceptable to create a third "types" contract and inherit the types both from "logic" and "storage" contracts?

// Types.sol

contract Types {
  struct Data {
    ...attributes
  }
}
// Logic.sol

contract Logic is Types {
  function someFunction(Datatype1 dataparam1, type2 param2) {
    Data data = Data(param1, param2);
    storage.someFunction(data);
  }
}

// Storage.sol

contract Storage is Types {
  function someFunction(Data data) onlyLogic { ... }
}

I am using a data separation pattern, keeping my data in a contract and the business logic in a separate contract that calls the storage one to add/update/delete records.

In order to send the Data struct as an argument in those CRUD functions, would it be acceptable to create a third "types" contract and inherit the types both from "logic" and "storage" contracts?

// Types.sol

contract Types {
  struct Data {
    ...attributes
  }
}
// Logic.sol

contract Logic is Types {
  function someFunction(Data data) {
    storage.someFunction(data);
  }
}

// Storage.sol

contract Storage is Types {
  function someFunction(Data data) onlyLogic { ... }
}

I am using a data separation pattern, keeping my data in a contract and the business logic in a separate contract that calls the storage one to add/update/delete records.

In order to send the Data struct as an argument in those CRUD functions, would it be acceptable to create a third "types" contract and inherit the types both from "logic" and "storage" contracts?

// Types.sol

contract Types {
  struct Data {
    ...attributes
  }
}
// Logic.sol

contract Logic is Types {
  function someFunction(type1 param1, type2 param2) {
    Data data = Data(param1, param2);
    storage.someFunction(data);
  }
}

// Storage.sol

contract Storage is Types {
  function someFunction(Data data) onlyLogic { ... }
}
Source Link

Is it acceptable to inherit data types from two different contracts (logic and storage?)

I am using a data separation pattern, keeping my data in a contract and the business logic in a separate contract that calls the storage one to add/update/delete records.

In order to send the Data struct as an argument in those CRUD functions, would it be acceptable to create a third "types" contract and inherit the types both from "logic" and "storage" contracts?

// Types.sol

contract Types {
  struct Data {
    ...attributes
  }
}
// Logic.sol

contract Logic is Types {
  function someFunction(Data data) {
    storage.someFunction(data);
  }
}

// Storage.sol

contract Storage is Types {
  function someFunction(Data data) onlyLogic { ... }
}