There is currently a published contract on the main chain (contract A for short), I must use another contract .somefunction (contract B for short) to call A.somefunction(), but A.somefunction() already uses msg.sender to bring in to use. The following are examples
Contract Acoin is ERC20{
struct Staking {
uint256 Coin;
uint256 ArriveCoin;
uint256 ArriveTime;
uint256 Time;
uint256 State;
}
mapping(address => Staking[]) public All_Staking;
constructor(string memory name, string memory symbol) ERC20(name,symbol){}
function SearchStaking() public view returns (Staking[] memory) {
require(All_Staking[msg.sender].length > 0,"Sorry, This account does not have any Token staking");
return All_Staking[msg.sender];
}
}
So I need to write B contract to use msg.sender(caller not B contract) to call SearchStaking of A contract and get the array of AContract.Staking[], if I use All_Staking to call, I can get a single result but no array length.
import "./ACoin.sol";
Contract B is ERC20{
Acoin public ACoin;
Acoin.Staking[] private Staking;
constructor(string memory name, string memory symbol,address _A) ERC20(name,symbol){
ACoin = Acoin(_A);
}
function GetUserAllStaking() public view returns(Acoin.Staking[] memory){
return ACoin.SearchStaking(); ---->Here should using msg.sender not Contract B address
}
}