Function: sgReceive(uint16, bytes, uint256, address bridgedToken, uint256 amountLD, bytes payload)
Function that handles receiving via StarGate.
Inputs
srcChainIdControl: Fully controlled by the caller. Currently not used.
Constraints: None. Should check that it is a valid chain ID for the source chain.
Impact: The source chain where the cross-chain transaction originated.
srcAddressControl: Fully controlled by the caller. Currently not used.
Constraints: None. Should check that it corresponds to the WoocrossChainRouterV4 contract on the source chain.
Impact: The address of the originating contract on the source chain.
nonceControl: Fully controlled by the caller. Currently not used.
Constraints: None. Should be used to prevent replay attacks.
Impact: The nonce of the transaction.
bridgedTokenControl: Fully controlled by the caller.
Constraints: None. Assumed to be a token that can be bridged.
Impact: The token that was bridged.
amountLDControl: Fully controlled by the caller.
Constraints: None. Assumed to be the amount of the bridged token. When called by StarGate, StarGate ensures that this amount the token has been transferred to the contract by StarGate as a result of the cross-chain call.
Impact: The amount of the bridged token.
payloadControl: Fully controlled by the caller.
Constraints: None. Assumed to be the payload of the cross-chain transaction.
Impact: The payload of the cross-chain transaction.
Branches and code coverage
Intended branches
Ensure that
srcChainIdis a valid chain ID. Currently not enforced.Ensure that
srcAddresscorresponds to the WoocrossChainRouterV4 contract on the source chain. Currently not enforced.Ensure that
nonceis used to prevent replay attacks. Currently not enforced.If
bridgedTokenisSGETH, handle the native received.If
bridgedTokenis notSGETH, handle the ERC-20 received.
Negative behavior
Should not allow anyone other than the StarGate router to call this function.