From 40e8972c6f4c28b401496084ee005c79e7070fba Mon Sep 17 00:00:00 2001 From: Jawad Tariq Date: Thu, 15 Feb 2024 16:55:18 -0500 Subject: [PATCH] feat: add unique id for `sendToken` tx Signed-off-by: Jawad Tariq --- contracts/interfaces/IToposCore.sol | 2 +- contracts/topos-core/ToposCore.sol | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/contracts/interfaces/IToposCore.sol b/contracts/interfaces/IToposCore.sol index 90b2b5f..0114d5d 100644 --- a/contracts/interfaces/IToposCore.sol +++ b/contracts/interfaces/IToposCore.sol @@ -25,7 +25,7 @@ interface IToposCore { event CertStored(CertificateId certId, bytes32 receiptRoot); - event CrossSubnetMessageSent(SubnetId indexed targetSubnetId); + event CrossSubnetMessageSent(SubnetId indexed targetSubnetId, SubnetId sourceSubnetId, uint256 nonce); event Upgraded(address indexed implementation); diff --git a/contracts/topos-core/ToposCore.sol b/contracts/topos-core/ToposCore.sol index 65acb8a..6e6798b 100644 --- a/contracts/topos-core/ToposCore.sol +++ b/contracts/topos-core/ToposCore.sol @@ -18,6 +18,10 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable { /// @notice The subnet ID of the subnet this contract is to be deployed on SubnetId public networkSubnetId; + /// @notice Nonce for cross subnet message, meant to be used in combination with `sourceSubnetId` + /// so that the message can be uniquely identified per subnet + uint256 private nonce; + /// @notice Set of certificate IDs Bytes32SetsLib.Set certificateSet; @@ -113,7 +117,8 @@ contract ToposCore is IToposCore, AdminMultisigBase, Initializable { /// @notice Emits an event to signal a cross subnet message has been sent /// @param targetSubnetId The subnet ID of the target subnet function emitCrossSubnetMessage(SubnetId targetSubnetId) external { - emit CrossSubnetMessageSent(targetSubnetId); + nonce += 1; + emit CrossSubnetMessageSent(targetSubnetId, networkSubnetId, nonce); } /// @notice Returns the admin epoch