I'm trying to pass an instance of the Storage
structure from StorageController.sol to Publisher.sol. No matter what I do, I get VM Exception while processing transaction: revert
in my Truffle test.
Both contracts have pragma experimental ABIEncoderV2;
at the top. StorageController.sol is imported by Publisher.
Here's what I tried so far: 1. Using a mapping: StorageController:
mapping(uint256 => Storage) public storages;
Publisher:
Storage memory _storage = _storages.storages(storage_id);
This won't even compile, it says, TypeError: Different number of components on the left hand side (1) than on the right hand side (6).
- Using a function
StorageController:
function getStorage(uint256 i) external view returns(Storage memory) {
return storages[i];
}
Publisher
StorageController.Storage memory _storage = _storages.getStorage(storage_id);
Output: VM Exception while processing transaction: revert
- Passing a tuple
StorageController:
function getStorageData(uint256 i) external view
returns(bytes32 name, uint256 maxLength, uint256 rank, uint256 writingFee, uint256 sellPrice, bool nonpublic) {
return ("", 1,1,1,1,false);
}
(I hardcoded the output values just in case)
Publisher:
(bytes32 name,,,,,) = _storages.getStorageData(storage_id);
Output: same as above.