contract A {
struct Product {
uint256 id;
string name;
uint256 quantity;
}
function someFunction(address user) external view returns(Product[] memory _product) {
// do some processing
return _product;
}
}
Another contract B is calling someFunction and needs to return Product struct received (from Contract A). But contract B doesn’t know the Product struct (as it’s defined in Contract A).
contract B {
ContractAInterface internal contractA;
function bFunction() public view returns(/* what return type to specify here? */) {
return contractA.someFunction(msg.sender);
}
}
Would I need to duplicate Product struct definition in Contract B and then use:
function bFunction() public view returns(Product[] memory _Product)
Thanks @abcoathup! But I was wondering if there's a way to do it without importing Contract A. Actually, Contract A is an on-chain Oracle and Contract B is a contract that user interacts with through the client side Dapp.
All user interactions are with Contract B and this contract just calls Contract A (on-chain Oracle) functions as defined by the OracleInterface (ContractAInterface).
Is there a way to import Struct as well in an interface? Also, technically Contract A resides in different repo and Contract B (and ContractAInterface) resides together in same repo.