-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enable context? * Update README * Remove comment * Remove dead code
- Loading branch information
Showing
7 changed files
with
111 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: Unlicense | ||
pragma solidity ^0.8.13; | ||
|
||
import "./suavelib/Suave.sol"; | ||
|
||
library Context { | ||
function confidentialInputs() internal returns (bytes memory) { | ||
return Suave.contextGet("confidentialInputs"); | ||
} | ||
|
||
function kettleAddress() internal returns (address) { | ||
bytes memory addr = Suave.contextGet("kettleAddress"); | ||
return abi.decode(addr, (address)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.8; | ||
|
||
contract ContextConnector { | ||
bytes confidentialInputs; | ||
address kettleAddress; | ||
|
||
function setConfidentialInputs(bytes memory _confidentialInputs) public { | ||
confidentialInputs = _confidentialInputs; | ||
} | ||
|
||
function resetConfidentialInputs() public { | ||
confidentialInputs = ""; | ||
} | ||
|
||
function setKettleAddress(address _kettleAddress) public { | ||
kettleAddress = _kettleAddress; | ||
} | ||
|
||
function resetKettleAddress() public { | ||
setKettleAddress(address(0)); | ||
} | ||
|
||
fallback() external { | ||
(string memory key) = abi.decode(msg.data, (string)); | ||
bytes32 keyHash = keccak256(abi.encodePacked(key)); | ||
|
||
bytes memory msgContent; | ||
if (keyHash == keccak256(abi.encodePacked("confidentialInputs"))) { | ||
msgContent = confidentialInputs; | ||
} else if (keyHash == keccak256(abi.encodePacked("kettleAddress"))) { | ||
msgContent = abi.encode(kettleAddress); | ||
} else { | ||
revert("Invalid context key"); | ||
} | ||
|
||
bytes memory msgdata = abi.encode(msgContent); | ||
assembly { | ||
let location := msgdata | ||
let length := mload(msgdata) | ||
return(add(location, 0x20), length) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters