Skip to content

Commit 63ec485

Browse files
committed
refactor: replace CoreStore with CrossStore in transaction management contracts
1 parent 10743ca commit 63ec485

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {MsgInitiateTx, MsgInitiateTxResponse} from "../proto/cross/core/initiato
55
import {Account} from "../proto/cross/core/auth/Auth.sol";
66
import {CoordinatorState} from "src/proto/cross/core/atomic/simple/AtomicSimple.sol";
77

8-
abstract contract CoreStore {
8+
abstract contract CrossStore {
99
// keccak256(abi.encode(uint256(keccak256("cross.core.auth")) - 1)) & ~bytes32(uint256(0xff))
1010
bytes32 internal constant AUTH_STORAGE_LOCATION =
1111
hex"93e3b8eb4220ad7cd6d04c9032dc8d35824a37bf01220f3aeab27e9ece04f300";

src/core/TxAuthManager.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
pragma solidity ^0.8.20;
33

44
import {TxAuthManagerBase} from "./TxAuthManagerBase.sol";
5-
import {CoreStore} from "./CoreStore.sol";
5+
import {CrossStore} from "./CrossStore.sol";
66
import {Account, TxAuthState} from "../proto/cross/core/auth/Auth.sol";
77

8-
abstract contract TxAuthManager is TxAuthManagerBase, CoreStore {
8+
abstract contract TxAuthManager is TxAuthManagerBase, CrossStore {
99
function initAuthState(bytes32 txId, Account.Data[] memory signers) internal virtual override {
10-
CoreStore.AuthStorage storage s = _getAuthStorage();
10+
CrossStore.AuthStorage storage s = _getAuthStorage();
1111
if (s.authInitialized[txId]) revert AuthStateAlreadyInitialized(txId);
1212
_setStateFromRemainingList(s, txId, signers);
1313
s.authInitialized[txId] = true;
1414
}
1515

1616
function isCompletedAuth(bytes32 txId) internal view virtual override returns (bool) {
17-
CoreStore.AuthStorage storage s = _getAuthStorage();
17+
CrossStore.AuthStorage storage s = _getAuthStorage();
1818
if (!s.authInitialized[txId]) revert IDNotFound(txId);
1919
return s.remainingCount[txId] == 0;
2020
}
2121

2222
function sign(bytes32 txId, Account.Data[] memory signers) internal virtual override returns (bool) {
23-
CoreStore.AuthStorage storage s = _getAuthStorage();
23+
CrossStore.AuthStorage storage s = _getAuthStorage();
2424
if (!s.authInitialized[txId]) revert IDNotFound(txId);
2525
if (s.remainingCount[txId] == 0) revert AuthAlreadyCompleted(txId);
2626

@@ -36,13 +36,13 @@ abstract contract TxAuthManager is TxAuthManagerBase, CoreStore {
3636
}
3737

3838
function getAuthState(bytes32 txId) internal view virtual override returns (TxAuthState.Data memory) {
39-
CoreStore.AuthStorage storage s = _getAuthStorage();
39+
CrossStore.AuthStorage storage s = _getAuthStorage();
4040
if (!s.authInitialized[txId]) revert IDNotFound(txId);
4141
Account.Data[] memory remains = _getRemainingSigners(s, txId);
4242
return TxAuthState.Data({remaining_signers: remains});
4343
}
4444

45-
function _getRemainingSigners(CoreStore.AuthStorage storage s, bytes32 txId)
45+
function _getRemainingSigners(CrossStore.AuthStorage storage s, bytes32 txId)
4646
internal
4747
view
4848
returns (Account.Data[] memory out)
@@ -61,7 +61,7 @@ abstract contract TxAuthManager is TxAuthManagerBase, CoreStore {
6161
}
6262
}
6363

64-
function _setStateFromRemainingList(CoreStore.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) {

src/core/TxManager.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ pragma solidity ^0.8.20;
33

44
import {TxManagerBase} from "./TxManagerBase.sol";
55
import {TxRunnerBase} from "./TxRunnerBase.sol";
6-
import {CoreStore} from "./CoreStore.sol";
6+
import {CrossStore} from "./CrossStore.sol";
77

88
import {MsgInitiateTx, MsgInitiateTxResponse, ContractTransaction} from "../proto/cross/core/initiator/Initiator.sol";
99
import {Account} from "../proto/cross/core/auth/Auth.sol";
1010

11-
abstract contract TxManager is TxManagerBase, TxRunnerBase, CoreStore {
11+
abstract contract TxManager is TxManagerBase, TxRunnerBase, CrossStore {
1212
function createTx(bytes32 txId, MsgInitiateTx.Data calldata src) internal virtual override {
13-
CoreStore.TxStorage storage t = _getTxStorage();
13+
CrossStore.TxStorage storage t = _getTxStorage();
1414
if (t.txExists[txId]) revert TxAlreadyExists(txId);
1515
_deepStoreMsg(t, txId, src);
1616
t.txStatus[txId] = MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_PENDING;
1717
t.txExists[txId] = true;
1818
}
1919

2020
function runTxIfCompleted(bytes32 txId) internal virtual override {
21-
CoreStore.TxStorage storage t = _getTxStorage();
21+
CrossStore.TxStorage storage t = _getTxStorage();
2222
if (!t.txExists[txId]) return;
2323
if (t.txStatus[txId] == MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED) return;
2424
_runTx(txId, t.txMsg[txId]);
2525
t.txStatus[txId] = MsgInitiateTxResponse.InitiateTxStatus.INITIATE_TX_STATUS_VERIFIED;
2626
}
2727

2828
function isTxRecorded(bytes32 txId) internal view virtual override returns (bool) {
29-
CoreStore.TxStorage storage t = _getTxStorage();
29+
CrossStore.TxStorage storage t = _getTxStorage();
3030
return t.txExists[txId];
3131
}
3232

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

0 commit comments

Comments
 (0)