Skip to content

Commit

Permalink
Deploying SwapIntentController and integrating correctly into test calls
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSparksCode committed Aug 14, 2023
1 parent 4b733e4 commit 257e3c7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/SwapIntent.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {SwapIntentController, SwapIntent} from "src/contracts/intents-example/Sw
// 2. Is the Atlas contract always also the Escrow contract? Would Escrow ever be separate?
// 3. What is staging call and staging lock? How does it work?
// A: Checks protocolCall config for requireStaging, then calls holdStagingLock() on EscrowKey
// 4. What is userSelector (bytes4) in _stagingCall?
// 4. When is SwapIntentController deployed and where is it called or passed as arg
// A: SwapIntentContoller is ProtocolControl, must be deployed and passed into txBuilder

// Refactor Ideas:
// 1. Lots of bitwise operations explicitly coded in contracts - could be a helper lib thats more readable
Expand All @@ -28,14 +29,16 @@ import {SwapIntentController, SwapIntent} from "src/contracts/intents-example/Sw


contract SwapIntentTest is BaseTest {

SwapIntentController public swapIntentController;
TxBuilder public txBuilder;

function setUp() public virtual override {
BaseTest.setUp();

swapIntentController = new SwapIntentController(address(escrow));

txBuilder = new TxBuilder({
protocolControl: address(control),
protocolControl: address(swapIntentController),
escrowAddress: address(escrow),
atlasAddress: address(atlas)
});
Expand Down Expand Up @@ -65,7 +68,6 @@ contract SwapIntentTest is BaseTest {
});
// swap(SwapIntent calldata) selector = 0x98434997
bytes memory userCallData = abi.encodeWithSelector(SwapIntentController.swap.selector, swapIntent);

console.log("userCallData:");
console.logBytes(userCallData);

Expand All @@ -78,13 +80,20 @@ contract SwapIntentTest is BaseTest {
data: userCallData
});

// searcherCallData is similar to userCallData
// decodes to [bytes stagingReturnData, address searcherTo]
// where stagingReturnData decodes to SwapIntent (same as in userCallData)
bytes memory searcherCallData = abi.encode(swapIntent, searcherOneEOA);
console.log("searcherCallData:");
console.logBytes(searcherCallData);

// Builds the SearcherCall
searcherCall = txBuilder.buildSearcherCall({
userCall: userCall,
protocolCall: protocolCall,
searcherCallData: "", // TODO update
searcherCallData: searcherCallData,
searcherEOA: searcherOneEOA,
searcherContract: address(searcherOne),
searcherContract: address(searcherOne), // TODO
bidAmount: 1e18
});

Expand Down

0 comments on commit 257e3c7

Please sign in to comment.