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 thisaccountId
is related to theuserAddress
andbrokerHash
.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
accountId
is calculated using thesebrokerHash
anduserAddress
values.Validate that
srcChainDepositNonce
is incremented since the previous deposit.brokerHash
is allowed.tokenHash
andsrcChainId
is allowed.
Negative behavior
userAddress
is zero address.tokenAmount
is zero.
Function call analysis
vaultManager.getAllowedBroker
External/Internal? External.
Argument control?
data.brokerHash
.Impact: Return true if
brokerHash
is allowed broker.
vaultManager.getAllowedChainToken(data.tokenHash, data.srcChainId)
External/Internal? External.
Argument control? All arguments are controlled by caller.
Impact: Return true if
tokenHash
fromsrcChainId
is allowed.
Utils.validateAccountId(data.accountId, data.brokerHash, data.userAddress)
External/Internal? External.
Argument control? All arguments are controlled by caller.
Impact: Check that
_userAddress
and_brokerHash
is 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
tokenHash
bytokenAmount
foraccount
related 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
tokenHash
fromsrcChainId
bytokenAmount
.