PatrickAlphaC/rwa-creator

Issue with a checker inside `sendMintRequest` function

Closed this issue · 4 comments

if (_getCollateralRatioAdjustedTotalBalance(amountOfTokensToMint) > s_portfolioBalance) {

s_portfolioBalance is updated only in the _mintFulFillRequest function which is called inside fulfillRequest function.
So If I'm not wrong when we initially call sendMintRequest function this s_portfolioBalance will be zero right, then this function call is always gonna revert right?
Correct me If I'm wrong.

You're right! We should initialize calling this func

what would be the better approach for this?
Is it optimal to just initialise the value of s_portfolioBalance by calling a function in the constructor like this?

    function initializePortfolioBalance(bytes memory response) internal {
        s_portfolioBalance = uint256(bytes32(response));
    }
    

Hmm... Yes! Have an initializer with a balance would be great.

yep got it thanks