Function: deposit(VaultTypes.VaultDepositFE data)
This allows any caller to deposit the funds to the Vault. All data about the deposit action will be transferred to the Ledger contract in main chain.
Inputs
dataControl: Caller has full control.
Constraints:
brokerHashandtokenHashshould be allowed, user should have enough amount of tokens to deposit them.Impact: The caller of this function will deposit the funds to contract.
Branches and code coverage
Intended branches
Check if the branch has test coverage.
Include function calls.
End sentences with periods.
Negative behavior
Caller is a service admin.
Negative behavior should be what the function requires.
Function Call Analysis
allowedTokenSet.contains(data.tokenHash)External/Internal? Internal.
Argument control?
data.tokenHash.Impact: Return true if
tokenHashis allowed. The result of this function should synchronize with the state of allowed tokens in the Ledger contact in main chain.
allowedBrokerSet.contains(data.brokerHash)External/Internal? Internal.
Argument control?
data.brokerHash.Impact: Return true if
brokerHashis allowed. The result of this function should synchronize with the state of allowed brokers in the Ledger contact in main chain.
Utils.validateAccountId(data.accountId, data.brokerHash, msg.sender)External/Internal? Internal.
Argument control?
data.accountIdanddata.brokerHash.Impact: Calculate that
accountIdis equal to hash fromdata.brokerHashandmsg.sender.
tokenAddress.safeTransferFrom(msg.sender, address(this), data.tokenAmount)External/Internal? External.
Argument control?
data.tokenAmount.Impact: Transfer the amount of tokens that will be deposited. Will revert if
msg.senderdoes not have enough tokens.
IVaultCrossChainManager(crossChainManagerAddress).deposit(depositData)External/Internal? External.
Argument control?
depositData.Impact: Initiate the cross-chain message to keep track of the deposited funds in the Ledger contract in main chain.