Skip to content

Commit 1a07484

Browse files
committed
fix: standardize variable naming from txId to txID across multiple contracts
1 parent 58aced5 commit 1a07484

13 files changed

+84
-84
lines changed

src/core/CrossModule.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ abstract contract CrossModule is
3434
_grantRole(IBC_ROLE, address(ibcHandler_));
3535
}
3636

37-
function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, IERC165) returns (bool) {
38-
return interfaceId == type(IIBCModule).interfaceId || interfaceId == type(IIBCModuleInitializer).interfaceId
39-
|| super.supportsInterface(interfaceId);
37+
function supportsInterface(bytes4 interfaceID) public view virtual override(AccessControl, IERC165) returns (bool) {
38+
return interfaceID == type(IIBCModule).interfaceId || interfaceID == type(IIBCModuleInitializer).interfaceId
39+
|| super.supportsInterface(interfaceID);
4040
}
4141

4242
// function initiateTx() external {}

src/core/IAuthenticator.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import {
1212
} from "../proto/cross/core/auth/Auth.sol";
1313

1414
interface IAuthenticator {
15-
error AuthStateAlreadyInitialized(bytes32 txId);
16-
error IdNotFound(bytes32 txId);
17-
error AuthAlreadyCompleted(bytes32 txId);
15+
error AuthStateAlreadyInitialized(bytes32 txID);
16+
error IDNotFound(bytes32 txID);
17+
error AuthAlreadyCompleted(bytes32 txID);
1818

19-
event TxSigned(address indexed signer, bytes32 indexed txId, AuthType.AuthMode method);
19+
event TxSigned(address indexed signer, bytes32 indexed txID, AuthType.AuthMode method);
2020

2121
function signTx(MsgSignTx.Data calldata msg_) external returns (MsgSignTxResponse.Data memory);
2222

src/core/IContractModule.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface IContractModule {
2222

2323
// CrossContext is a context in cross-chain transaction
2424
struct CrossContext {
25-
bytes txId;
25+
bytes txID;
2626
uint8 txIndex;
2727
Account.Data[] signers;
2828
}

src/core/ICoordinator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "src/proto/cross/core/atomic/simple/AtomicSimple.sol";
88

99
interface ICoordinator {
10-
error CoordinatorStateNotFound(bytes32 txId);
10+
error CoordinatorStateNotFound(bytes32 txID);
1111

1212
function coordinatorState(QueryCoordinatorStateRequest.Data calldata req)
1313
external

src/core/IInitiator.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ pragma solidity ^0.8.20;
44
import {MsgInitiateTx, MsgInitiateTxResponse, QuerySelfXCCResponse} from "../proto/cross/core/initiator/Initiator.sol";
55

66
interface IInitiator {
7-
error UnexpectedChainId(bytes32 expectedHash, bytes32 gotHash);
7+
error UnexpectedChainID(bytes32 expectedHash, bytes32 gotHash);
88
error MessageTimeoutHeight(uint256 blockNumber, uint64 timeoutVersionHeight);
99
error MessageTimeoutTimestamp(uint256 blockTimestamp, uint64 timeoutTimestamp);
10-
error TxIdAlreadyExists(bytes32 txIdHash);
10+
error TxIDAlreadyExists(bytes32 txIDHash);
1111
error SelfXCCNotImplemented();
1212

13-
event TxInitiated(bytes txId, address indexed proposer);
13+
event TxInitiated(bytes txID, address indexed proposer);
1414

1515
function initiateTx(MsgInitiateTx.Data calldata msg_) external returns (MsgInitiateTxResponse.Data memory resp);
1616

src/core/Initiator.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract contract Initiator is IInitiator, TxAuthManagerBase, TxManagerBase {
2323
{
2424
// chain_id check
2525
bytes32 got = keccak256(bytes(msg_.chain_id));
26-
if (got != CHAIN_ID_HASH) revert IInitiator.UnexpectedChainId(CHAIN_ID_HASH, got);
26+
if (got != CHAIN_ID_HASH) revert IInitiator.UnexpectedChainID(CHAIN_ID_HASH, got);
2727

2828
// timeouts
2929
uint64 rh = msg_.timeout_height.revision_height;
@@ -35,29 +35,29 @@ abstract contract Initiator is IInitiator, TxAuthManagerBase, TxManagerBase {
3535
revert IInitiator.MessageTimeoutTimestamp(block.timestamp, msg_.timeout_timestamp);
3636
}
3737

38-
// generate txId
39-
bytes32 txIdHash = sha256(MsgInitiateTx.encode(msg_));
40-
bytes memory txId = abi.encodePacked(txIdHash);
41-
if (isTxRecorded(txIdHash)) revert IInitiator.TxIdAlreadyExists(txIdHash);
38+
// generate txID
39+
bytes32 txIDHash = sha256(MsgInitiateTx.encode(msg_));
40+
bytes memory txID = abi.encodePacked(txIDHash);
41+
if (isTxRecorded(txIDHash)) revert IInitiator.TxIDAlreadyExists(txIDHash);
4242

4343
// persist as PENDING
44-
createTx(txIdHash, msg_);
44+
createTx(txIDHash, msg_);
4545

4646
// auth init & sign
4747
Account.Data[] memory required = _getRequiredAccounts(msg_);
48-
initAuthState(txIdHash, required);
49-
bool completed = sign(txIdHash, msg_.signers);
48+
initAuthState(txIDHash, required);
49+
bool completed = sign(txIDHash, msg_.signers);
5050

51-
emit TxInitiated(txId, msg.sender);
51+
emit TxInitiated(txID, msg.sender);
5252

5353
if (completed) {
54-
runTxIfCompleted(txIdHash);
54+
runTxIfCompleted(txIDHash);
5555
return MsgInitiateTxResponse.Data({
56-
txID: txId, status: MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED
56+
txID: txID, status: MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED
5757
});
5858
}
5959
return MsgInitiateTxResponse.Data({
60-
txID: txId, status: MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_PENDING
60+
txID: txID, status: MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_PENDING
6161
});
6262
}
6363

src/core/TxAtomicSimple.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract contract TxAtomicSimple is IBCKeeper, PacketHandler, ContractRegistry {
2020
error UnexpectedTypeURL();
2121
error NotImplemented();
2222

23-
event OnContractCall(bytes indexed txId, uint8 indexed txIndex, bool indexed success, bytes ret);
23+
event OnContractCall(bytes indexed txID, uint8 indexed txIndex, bool indexed success, bytes ret);
2424

2525
function handlePacket(Packet memory packet) internal virtual override returns (bytes memory acknowledgement) {
2626
IContractModule module = getModule(packet);

src/core/TxAuthManager.sol

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,70 @@ import {CrossStore} from "./CrossStore.sol";
66
import {Account, TxAuthState} from "../proto/cross/core/auth/Auth.sol";
77

88
abstract contract TxAuthManager is TxAuthManagerBase, CrossStore {
9-
function initAuthState(bytes32 txId, Account.Data[] memory signers) internal virtual override {
9+
function initAuthState(bytes32 txID, Account.Data[] memory signers) internal virtual override {
1010
CrossStore.AuthStorage storage s = _getAuthStorage();
11-
if (s.authInitialized[txId]) revert AuthStateAlreadyInitialized(txId);
12-
_setStateFromRemainingList(s, txId, signers);
13-
s.authInitialized[txId] = true;
11+
if (s.authInitialized[txID]) revert AuthStateAlreadyInitialized(txID);
12+
_setStateFromRemainingList(s, txID, signers);
13+
s.authInitialized[txID] = true;
1414
}
1515

16-
function isCompletedAuth(bytes32 txId) internal view virtual override returns (bool) {
16+
function isCompletedAuth(bytes32 txID) internal view virtual override returns (bool) {
1717
CrossStore.AuthStorage storage s = _getAuthStorage();
18-
if (!s.authInitialized[txId]) revert IdNotFound(txId);
19-
return s.remainingCount[txId] == 0;
18+
if (!s.authInitialized[txID]) revert IDNotFound(txID);
19+
return s.remainingCount[txID] == 0;
2020
}
2121

22-
function sign(bytes32 txId, Account.Data[] memory signers) internal virtual override returns (bool) {
22+
function sign(bytes32 txID, Account.Data[] memory signers) internal virtual override returns (bool) {
2323
CrossStore.AuthStorage storage s = _getAuthStorage();
24-
if (!s.authInitialized[txId]) revert IdNotFound(txId);
25-
if (s.remainingCount[txId] == 0) revert AuthAlreadyCompleted(txId);
24+
if (!s.authInitialized[txID]) revert IDNotFound(txID);
25+
if (s.remainingCount[txID] == 0) revert AuthAlreadyCompleted(txID);
2626

2727
for (uint256 i = 0; i < signers.length; ++i) {
2828
bytes32 key = _accountKey(signers[i]);
29-
if (s.remaining[txId][key]) {
30-
s.remaining[txId][key] = false;
31-
--s.remainingCount[txId];
32-
if (s.remainingCount[txId] == 0) return true;
29+
if (s.remaining[txID][key]) {
30+
s.remaining[txID][key] = false;
31+
--s.remainingCount[txID];
32+
if (s.remainingCount[txID] == 0) return true;
3333
}
3434
}
35-
return s.remainingCount[txId] == 0;
35+
return s.remainingCount[txID] == 0;
3636
}
3737

38-
function getAuthState(bytes32 txId) internal view virtual override returns (TxAuthState.Data memory) {
38+
function getAuthState(bytes32 txID) internal view virtual override returns (TxAuthState.Data memory) {
3939
CrossStore.AuthStorage storage s = _getAuthStorage();
40-
if (!s.authInitialized[txId]) revert IdNotFound(txId);
41-
Account.Data[] memory remains = _getRemainingSigners(s, txId);
40+
if (!s.authInitialized[txID]) revert IDNotFound(txID);
41+
Account.Data[] memory remains = _getRemainingSigners(s, txID);
4242
return TxAuthState.Data({remaining_signers: remains});
4343
}
4444

45-
function _getRemainingSigners(CrossStore.AuthStorage storage s, bytes32 txId)
45+
function _getRemainingSigners(CrossStore.AuthStorage storage s, bytes32 txID)
4646
internal
4747
view
4848
returns (Account.Data[] memory out)
4949
{
50-
uint256 total = s.requiredAccounts[txId].length;
51-
uint256 need = s.remainingCount[txId];
50+
uint256 total = s.requiredAccounts[txID].length;
51+
uint256 need = s.remainingCount[txID];
5252
out = new Account.Data[](need);
5353
uint256 p = 0;
5454
for (uint256 i = 0; i < total; ++i) {
55-
Account.Data memory acc = s.requiredAccounts[txId][i];
56-
if (s.remaining[txId][_accountKey(acc)]) {
55+
Account.Data memory acc = s.requiredAccounts[txID][i];
56+
if (s.remaining[txID][_accountKey(acc)]) {
5757
out[p] = acc;
5858
++p;
5959
if (p == need) break;
6060
}
6161
}
6262
}
6363

64-
function _setStateFromRemainingList(CrossStore.AuthStorage storage s, bytes32 txId, Account.Data[] memory list)
64+
function _setStateFromRemainingList(CrossStore.AuthStorage storage s, bytes32 txID, Account.Data[] memory list)
6565
internal
6666
{
6767
for (uint256 i = 0; i < list.length; ++i) {
6868
bytes32 key = _accountKey(list[i]);
69-
if (!s.remaining[txId][key]) {
70-
s.remaining[txId][key] = true;
71-
++s.remainingCount[txId];
72-
s.requiredAccounts[txId].push(list[i]);
69+
if (!s.remaining[txID][key]) {
70+
s.remaining[txID][key] = true;
71+
++s.remainingCount[txID];
72+
s.requiredAccounts[txID].push(list[i]);
7373
}
7474
}
7575
}

src/core/TxAuthManagerBase.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ pragma solidity ^0.8.20;
44
import {Account, TxAuthState} from "../proto/cross/core/auth/Auth.sol";
55

66
abstract contract TxAuthManagerBase {
7-
error AuthStateAlreadyInitialized(bytes32 txId);
8-
error IdNotFound(bytes32 txId);
9-
error AuthAlreadyCompleted(bytes32 txId);
7+
error AuthStateAlreadyInitialized(bytes32 txID);
8+
error IDNotFound(bytes32 txID);
9+
error AuthAlreadyCompleted(bytes32 txID);
1010

11-
function initAuthState(bytes32 txId, Account.Data[] memory signers) internal virtual;
12-
function isCompletedAuth(bytes32 txId) internal view virtual returns (bool);
13-
function sign(bytes32 txId, Account.Data[] memory signers) internal virtual returns (bool);
14-
function getAuthState(bytes32 txId) internal view virtual returns (TxAuthState.Data memory);
11+
function initAuthState(bytes32 txID, Account.Data[] memory signers) internal virtual;
12+
function isCompletedAuth(bytes32 txID) internal view virtual returns (bool);
13+
function sign(bytes32 txID, Account.Data[] memory signers) internal virtual returns (bool);
14+
function getAuthState(bytes32 txID) internal view virtual returns (TxAuthState.Data memory);
1515
}

src/core/TxManager.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ import {MsgInitiateTx, MsgInitiateTxResponse, ContractTransaction} from "../prot
99
import {Account} from "../proto/cross/core/auth/Auth.sol";
1010

1111
abstract contract TxManager is TxManagerBase, TxRunnerBase, CrossStore {
12-
function createTx(bytes32 txId, MsgInitiateTx.Data calldata src) internal virtual override {
12+
function createTx(bytes32 txID, MsgInitiateTx.Data calldata src) internal virtual override {
1313
CrossStore.TxStorage storage t = _getTxStorage();
14-
if (t.txExists[txId]) revert TxAlreadyExists(txId);
15-
_deepStoreMsg(t, txId, src);
16-
t.txStatus[txId] = MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_PENDING;
17-
t.txExists[txId] = true;
14+
if (t.txExists[txID]) revert TxAlreadyExists(txID);
15+
_deepStoreMsg(t, txID, src);
16+
t.txStatus[txID] = MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_PENDING;
17+
t.txExists[txID] = true;
1818
}
1919

20-
function runTxIfCompleted(bytes32 txId) internal virtual override {
20+
function runTxIfCompleted(bytes32 txID) internal virtual override {
2121
CrossStore.TxStorage storage t = _getTxStorage();
22-
if (!t.txExists[txId]) return;
23-
if (t.txStatus[txId] == MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED) return;
24-
t.txStatus[txId] = MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED;
25-
_runTx(txId, t.txMsg[txId]);
22+
if (!t.txExists[txID]) return;
23+
if (t.txStatus[txID] == MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED) return;
24+
t.txStatus[txID] = MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED;
25+
_runTx(txID, t.txMsg[txID]);
2626
}
2727

28-
function isTxRecorded(bytes32 txId) internal view virtual override returns (bool) {
28+
function isTxRecorded(bytes32 txID) internal view virtual override returns (bool) {
2929
CrossStore.TxStorage storage t = _getTxStorage();
30-
return t.txExists[txId];
30+
return t.txExists[txID];
3131
}
3232

33-
function _deepStoreMsg(CrossStore.TxStorage storage t, bytes32 txId, MsgInitiateTx.Data calldata src) private {
34-
MsgInitiateTx.Data storage dst = t.txMsg[txId];
33+
function _deepStoreMsg(CrossStore.TxStorage storage t, bytes32 txID, MsgInitiateTx.Data calldata src) private {
34+
MsgInitiateTx.Data storage dst = t.txMsg[txID];
3535
dst.chain_id = src.chain_id;
3636
dst.nonce = src.nonce;
3737
dst.commit_protocol = src.commit_protocol;

0 commit comments

Comments
 (0)