Skip to content

Commit

Permalink
fix: there can be multiple tranceivers on the same address on differe…
Browse files Browse the repository at this point in the history
…nt chains. (#23)

* fix it so that there can be multiple tranceivers on the same address on different chains.

* fix spelling error

* add token back

* add cast to bytes

* run forge fmt

* update examples-native-token-transfers

* try to revert to older package
  • Loading branch information
Foivos authored Jul 2, 2024
1 parent 01b4ed6 commit 7c47f13
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/axelar/AxelarTransceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract AxelarTransceiver is IAxelarTransceiver, AxelarGMPExecutable, Transceiv
mapping(uint16 => string) idToAxelarChainId;
mapping(string => uint16) axelarChainIdToId;
mapping(uint16 => string) idToTransceiverAddress;
mapping(string => uint16) transceiverAddressToId;
mapping(uint16 => bytes32) idToTransceiverAddressHash;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AxelarTransceiver")) - 1)) & ~bytes32(uint256(0xff))

Expand Down Expand Up @@ -92,7 +92,7 @@ contract AxelarTransceiver is IAxelarTransceiver, AxelarGMPExecutable, Transceiv
slot.idToAxelarChainId[chainId] = chainName;
slot.axelarChainIdToId[chainName] = chainId;
slot.idToTransceiverAddress[chainId] = transceiverAddress;
slot.transceiverAddressToId[transceiverAddress] = chainId;
slot.idToTransceiverAddressHash[chainId] = keccak256(bytes(transceiverAddress));

emit AxelarChainIdSet(chainId, chainName, transceiverAddress);
}
Expand Down Expand Up @@ -185,7 +185,10 @@ contract AxelarTransceiver is IAxelarTransceiver, AxelarGMPExecutable, Transceiv
) internal virtual override {
AxelarTransceiverStorage storage slot = _storage();
uint16 sourceChainId = slot.axelarChainIdToId[sourceChain];
if (sourceChainId == 0 || slot.transceiverAddressToId[sourceAddress] != sourceChainId) {
if (
sourceChainId == 0
|| slot.idToTransceiverAddressHash[sourceChainId] != keccak256(bytes(sourceAddress))
) {
revert InvalidSibling(sourceChainId, sourceChain, sourceAddress);
}

Expand Down

0 comments on commit 7c47f13

Please sign in to comment.