Skip to content

Commit

Permalink
simplifying the generateUID function
Browse files Browse the repository at this point in the history
  • Loading branch information
magj2006 committed Oct 29, 2024
1 parent cd0eb2a commit b992561
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/core/ExocoreGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ contract ExocoreGateway is
}
emit LSTTransfer(isDeposit, success, bytes32(token), bytes32(staker), amount);

if (srcChainId == SOLANA_DEVNET_CHAIN_ID || srcChainId == SOLANA_MAINNET_CHAIN_ID) {
if (_isSolana(srcChainId)) {
response = isDeposit ? bytes("") : abi.encodePacked(lzNonce, success, bytes32(token), bytes32(staker));
} else {
response = isDeposit ? bytes("") : abi.encodePacked(lzNonce, success);
Expand Down Expand Up @@ -423,7 +423,7 @@ contract ExocoreGateway is
}
emit RewardOperation(isSubmitReward, success, bytes32(token), bytes32(avsOrWithdrawer), amount);

if (srcChainId == SOLANA_DEVNET_CHAIN_ID || srcChainId == SOLANA_MAINNET_CHAIN_ID) {
if (_isSolana(srcChainId)) {
response = isSubmitReward
? bytes("")
: abi.encodePacked(lzNonce, success, bytes32(token), bytes32(avsOrWithdrawer));
Expand Down
18 changes: 5 additions & 13 deletions test/foundry/unit/ExocoreGateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,11 @@ contract SetUp is Test {
nonce, clientChainId, address(clientGateway), exocoreChainId, address(exocoreGateway).toBytes32()
);
} else {
if (isSolanaClient) {
uid = GUID.generate(
nonce,
exocoreChainId,
address(exocoreGateway),
solanaClientChainId,
address(solanaClientGateway).toBytes32()
);
} else {
uid = GUID.generate(
nonce, exocoreChainId, address(exocoreGateway), clientChainId, address(clientGateway).toBytes32()
);
}
uint16 targetChainId = isSolanaClient ? solanaClientChainId : clientChainId;
bytes32 targetGateway =
isSolanaClient ? address(solanaClientGateway).toBytes32() : address(clientGateway).toBytes32();

return GUID.generate(nonce, exocoreChainId, address(exocoreGateway), targetChainId, targetGateway);
}
}

Expand Down

0 comments on commit b992561

Please sign in to comment.