Skip to content

Commit

Permalink
feat:updated attestBatch in socketBatcher
Browse files Browse the repository at this point in the history
  • Loading branch information
tHeMaskedMan981 committed Oct 4, 2023
1 parent 77d40da commit 5aa6171
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions contracts/socket/SocketBatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ contract SocketBatcher is AccessControl {
* @param signature The signature of the packet data.
*/
struct AttestRequest {
address switchboard;
bytes32 packetId;
uint256 proposalCount;
bytes32 root;
Expand Down Expand Up @@ -325,16 +326,12 @@ contract SocketBatcher is AccessControl {

/**
* @notice attests a batch of Packets
* @param switchboardAddress_ address of switchboard
* @param attestRequests_ the list of requests with packets to be attested by switchboard in sequence
*/
function _attestBatch(
address switchboardAddress_,
AttestRequest[] calldata attestRequests_
) internal {
function _attestBatch(AttestRequest[] calldata attestRequests_) internal {
uint256 attestRequestLength = attestRequests_.length;
for (uint256 index = 0; index < attestRequestLength; ) {
FastSwitchboard(switchboardAddress_).attest(
FastSwitchboard(attestRequests_[index].switchboard).attest(
attestRequests_[index].packetId,
attestRequests_[index].proposalCount,
attestRequests_[index].root,
Expand All @@ -348,35 +345,29 @@ contract SocketBatcher is AccessControl {

/**
* @notice attests a batch of Packets
* @param switchboardAddress_ address of switchboard
* @param attestRequests_ the list of requests with packets to be attested by switchboard in sequence
*/
function attestBatch(
address switchboardAddress_,
AttestRequest[] calldata attestRequests_
) external {
_attestBatch(switchboardAddress_, attestRequests_);
function attestBatch(AttestRequest[] calldata attestRequests_) external {
_attestBatch(attestRequests_);
}

/**
* @notice send a batch of propose, attest and execute transactions
* @param socketAddress_ address of socket
* @param switchboardAddress_ address of switchboard
* @param proposeRequests_ the list of requests with packets to be proposed
* @param attestRequests_ the list of requests with packets to be attested by switchboard
* @param executeRequests_ the list of requests with messages to be executed
*/
function sendBatch(
address socketAddress_,
address switchboardAddress_,
SealRequest[] calldata sealRequests_,
ProposeRequest[] calldata proposeRequests_,
AttestRequest[] calldata attestRequests_,
ExecuteRequest[] calldata executeRequests_
) external payable {
_sealBatch(socketAddress_, sealRequests_);
_proposeBatch(socketAddress_, proposeRequests_);
_attestBatch(switchboardAddress_, attestRequests_);
_attestBatch(attestRequests_);
_executeBatch(socketAddress_, executeRequests_);
}

Expand Down
2 changes: 1 addition & 1 deletion test/socket/SocketBatcher.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ contract SocketBatcherTest is Setup {

SocketBatcher.AttestRequest memory attestRequest = SocketBatcher
.AttestRequest({
switchboard: address(_b.configs__[0].switchboard__),
packetId: packetId,
proposalCount: 0,
root: root,
Expand All @@ -141,7 +142,6 @@ contract SocketBatcherTest is Setup {

batcher__.sendBatch(
address(_b.socket__),
address(_b.configs__[0].switchboard__),
sealRequests,
proposeRequests,
attestRequests,
Expand Down

0 comments on commit 5aa6171

Please sign in to comment.