From d025170ea6471b3579470e170eb3a9598a98b40d Mon Sep 17 00:00:00 2001 From: pizzaman1337 Date: Mon, 21 Oct 2024 10:37:05 -0400 Subject: [PATCH] Update transmit in facet to accept bytes array for asset flexibility --- .../beanstalk/ForkSystem/TransmitInFacet.sol | 16 +++++++++------- .../beanstalk/ForkSystem/TransmitOutFacet.sol | 15 +++++++-------- .../contracts/interfaces/ITransmitInFacet.sol | 6 ++---- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/protocol/contracts/beanstalk/ForkSystem/TransmitInFacet.sol b/protocol/contracts/beanstalk/ForkSystem/TransmitInFacet.sol index bdeea15423..02dad8960e 100644 --- a/protocol/contracts/beanstalk/ForkSystem/TransmitInFacet.sol +++ b/protocol/contracts/beanstalk/ForkSystem/TransmitInFacet.sol @@ -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 } } diff --git a/protocol/contracts/beanstalk/ForkSystem/TransmitOutFacet.sol b/protocol/contracts/beanstalk/ForkSystem/TransmitOutFacet.sol index 6bbd465117..924b9ab75d 100644 --- a/protocol/contracts/beanstalk/ForkSystem/TransmitOutFacet.sol +++ b/protocol/contracts/beanstalk/ForkSystem/TransmitOutFacet.sol @@ -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(), @@ -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); } } diff --git a/protocol/contracts/interfaces/ITransmitInFacet.sol b/protocol/contracts/interfaces/ITransmitInFacet.sol index 525bb37aa3..9ab38d79f8 100644 --- a/protocol/contracts/interfaces/ITransmitInFacet.sol +++ b/protocol/contracts/interfaces/ITransmitInFacet.sol @@ -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; }