Skip to content

Commit

Permalink
JsmnSolLib.sol in NunyaBusiness;
Browse files Browse the repository at this point in the history
msg.vaue check
  • Loading branch information
morkeltry committed Oct 16, 2024
1 parent 6ef059e commit faa29f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions DEV_DEEPDIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ It should not be a usecase requirement that the receipt is encrypted if the user
##### checkBalance function pair
Future work! We did not see how useful from either testing or UX perspectives `checkBalance` would be, so we will certainly be implementing this once we are ast the hackathon deadline!


#### `Gateway.sol`
4 changes: 2 additions & 2 deletions packages/hardhat/contracts/Gateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ contract Gateway is Initializable, OwnableUpgradeable {

/// @notice Creates a new task with provided execution info
/// @param _payloadHash Hash of the payload
/// @param _userAddress Address of the user
/// @param _userAddress Address of the user .. WARNING - does not perform same purpose in this modified version
/// @param _routingInfo Routing information
/// @param _info Execution information

Expand Down Expand Up @@ -825,7 +825,7 @@ contract Gateway is Initializable, OwnableUpgradeable {
emit logNewTask(
_taskId,
getChainId(chain_id_1, chain_id_2, chain_id_3, chain_id_length),
_userAddress,
msg.sender,
_routingInfo,
_payloadHash,
_info
Expand Down
9 changes: 8 additions & 1 deletion packages/hardhat/contracts/NunyaBusiness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import "hardhat/console.sol";
// import "@openzeppelin/contracts/access/Ownable.sol";
import "./ISecretContract.sol";

import "./JsmnSolLib.sol";

/**
* @author
*/
Expand Down Expand Up @@ -129,10 +131,15 @@ contract NunyaBusiness {

// TODO: use ref encrypted with (user pubkey+salt)
// TODO: `string calldata secret` or `uint256 secret`
function pay(string calldata _secret, string calldata _ref, uint256 _value, string calldata _denomination) public payable returns (uint256) {
function pay(string calldata _valueJson, string calldata _ref, uint256 _value, string calldata _denomination) public payable returns (uint256) {
// >= because we need gas for fees
uint256 gasPaid = fundGateway(50000); // TODO 50000 is the minimum, need to adjust to a good estimate
require(msg.value >= _value + gasPaid, "Not enough value sent to pay for gas.");

// fix pseudocode!
// Token claimedPayment = parse(_valueJson);
// require (msg.value === claimedPayment, "incorrect payment value - ensure _valueJson is in the format {amount: paymentAmount, ... } and that msg.value == paymentAmount exactly.");

uint256 requestId = secretContract.pay(_secret, _ref, msg.value - gasPaid, _denomination);
expectedResult[requestId] = FunctionCallType.PAY;
return(requestId);
Expand Down

0 comments on commit faa29f0

Please sign in to comment.