I would suggest to remove the overwriting of tradeID variable tradeID = Strings.toString(transactionHash);
the transactionHash is not really unique as a new trade could have the same setup.
You could consider doing a check if the tradeId is already set and only if not then set to a random one. For the random one you could, for example, add the blocknumber to the hash which would provide more uniqueness.
please add a getter function for the mutuallyTerminated variable like:
function isMutuallyTerminated() public view returns (bool) {
return mutuallyTerminated;
}
it will show if a trade was terminated mutually or by an error.
Iβve got a possible improvement in mind in regards of an inheritance issue.
Sometimes you need to know which exact implementation youβre interacting with. They share the same interface and maybe abstract contract functions but they could also provide some more useful functions. When you just receive the contract address you cant be sure which exact implemenation that is, solidity does not provide a getMyContractName (or something like that) function.
Possible solution would be to introduce a function in ISDC.sol like
function iAmImplementation(string memory contractImplementation) external view returns (bool);
in SDC.sol a string variable like
string internal implementation;
and in the SDCPledgedBalance.sol (and all possible other implementations) this:
Another solutions could be ERC165, which checks the other way around and you could be sure that e.g. an SDCPledgedBalance.sol is an ISDC.sol. In this case to be sure that a contract is an exact implementation, every implementation would need its own additional interface like an empty ISDCPledgedBalance.sol and you could check on that.
Interface theObject = getObject();
Class theImplementation = theObject.getClass();
and I thought that this should be possible in Solidity too - but it appears to be not possible yet. But solution to do this is to do type casting
MyContract contract = MyContract(interface)
which gives an error if interface is not MyContract.
But on the other hand: if one needs to rely on the specific implementation, then the interface was maybe poorly defined. Maybe one should consider marker interfaces.