Skip to content

Commit

Permalink
Update transmit in facet to accept bytes array for asset flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaman1337 committed Oct 21, 2024
1 parent be07d9d commit d025170
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
16 changes: 9 additions & 7 deletions protocol/contracts/beanstalk/ForkSystem/TransmitInFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ contract TransmitInFacet is Invariable {
*/
function transmitIn(
address user,
bytes[] calldata deposits,
bytes[] calldata plots,
bytes[] calldata fertilizer,
bytes calldata // data
bytes[][] calldata assets,
bytes calldata //data
) external fundsSafu {
require(s.sys.supportedSourceForks[msg.sender], "Unsupported source");
require(assets.length >= 2, "Insufficient data provided");

LibTransmitIn.transmitInDeposits(user, deposits);
LibTransmitIn.transmitInPlots(user, plots);
LibTransmitIn.transmitInFertilizer(user, fertilizer);
LibTransmitIn.transmitInDeposits(user, assets[0]);
LibTransmitIn.transmitInPlots(user, assets[1]);
if (assets.length > 2) {
LibTransmitIn.transmitInFertilizer(user, assets[2]);
}
// additional assets can be processed here in the future
}
}
15 changes: 7 additions & 8 deletions protocol/contracts/beanstalk/ForkSystem/TransmitOutFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract TransmitOutFacet is Invariable {
LibTransmitOut.SourceDeposit[] calldata sourceDeposits,
LibTransmitOut.SourcePlot[] calldata sourcePlots,
LibTransmitOut.SourceFertilizer[] calldata sourceFertilizer,
bytes calldata // data
bytes calldata data
) external fundsSafu {
bytes[] memory deposits = LibTransmitOut.transmitOutDeposits(
LibTractor._user(),
Expand All @@ -38,13 +38,12 @@ contract TransmitOutFacet is Invariable {
sourceFertilizer
);

bytes[][] memory assets = new bytes[][](3);
assets[0] = deposits;
assets[1] = plots;
assets[2] = fertilizer;

// Reverts if Destination fails to handle transmitted assets.
ITransmitInFacet(destination).transmitIn(
LibTractor._user(),
deposits,
plots,
fertilizer,
abi.encode("")
);
ITransmitInFacet(destination).transmitIn(LibTractor._user(), assets, data);
}
}
6 changes: 2 additions & 4 deletions protocol/contracts/interfaces/ITransmitInFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ pragma solidity ^0.8.20;
interface ITransmitInFacet {
function transmitIn(
address user,
bytes[] calldata deposits,
bytes[] calldata plots,
bytes[] calldata fertilizer,
bytes calldata data
bytes[][] calldata assets,
bytes calldata //data
) external;
}

0 comments on commit d025170

Please sign in to comment.