Function: accountDeposit(AccountTypes.AccountDeposit data)
The function is called as a result of cross-chain communication after a user deposits funds in another chain. The input data is an AccountDeposit object and contains the fields shown below:
bytes32 accountId— controlled by user, but there is a check that thisaccountIdis related to theuserAddressandbrokerHash.bytes32 brokerHash— controlled by user but can only be allowed broker.address userAddress— is the receiver of funds. There is no check that the address is not zero here.bytes32 tokenHash— controlled by user but can only be an allowed token from trustedsrcChainId.uint256 srcChainId;— source chain id.uint128 tokenAmount— controlled by user, but the user should transfer this amount of tokens to Vault.uint64 srcChainDepositNonce— calculated during deposit call. But it is not validated here.
Branches and code coverage
Intended branches
Check that
accountIdis calculated using thesebrokerHashanduserAddressvalues.Validate that
srcChainDepositNonceis incremented since the previous deposit.brokerHashis allowed.tokenHashandsrcChainIdis allowed.
Negative behavior
userAddressis zero address.tokenAmountis zero.
Function call analysis
vaultManager.getAllowedBrokerExternal/Internal? External.
Argument control?
data.brokerHash.Impact: Return true if
brokerHashis allowed broker.
vaultManager.getAllowedChainToken(data.tokenHash, data.srcChainId)External/Internal? External.
Argument control? All arguments are controlled by caller.
Impact: Return true if
tokenHashfromsrcChainIdis allowed.
Utils.validateAccountId(data.accountId, data.brokerHash, data.userAddress)External/Internal? External.
Argument control? All arguments are controlled by caller.
Impact: Check that
_userAddressand_brokerHashis related to the_accountId. Return true ifkeccak256(abi.encode(_userAddress, _brokerHash)) == _accountId
account.addBalance(data.tokenHash, data.tokenAmount);External/Internal? Internal.
Argument control? All arguments are controlled by caller.
Impact: Increase the balance of
tokenHashbytokenAmountforaccountrelated touserAddress.
vaultManager.addBalance(data.tokenHash, data.srcChainId, data.tokenAmount);External/Internal? External.
Argument control? All arguments are controlled by caller.
Impact: Increase the balance of
tokenHashfromsrcChainIdbytokenAmount.