Skip to content

Commit

Permalink
chore: fmt code
Browse files Browse the repository at this point in the history
  • Loading branch information
Atlasoin committed Oct 20, 2024
1 parent 0fcc721 commit caa518d
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions src/Pi.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {OVMClient} from "@webisopen/ovm-contracts/src/OVMClient.sol";
import {ExecMode, Requirement, Specification} from "@webisopen/ovm-contracts/src/libraries/DataTypes.sol";

Expand All @@ -15,30 +16,20 @@ contract Pi is OVMClient {
* @param OVMTaskAddress The address of the OVMTask contract.
* @param admin The address of the admin.
*/
constructor(
address OVMTaskAddress,
address admin
) OVMClient(OVMTaskAddress, admin) {
constructor(address OVMTaskAddress, address admin) OVMClient(OVMTaskAddress, admin) {
// set specification
Specification memory spec;
spec.name = "kallypi";
spec.version = "1.0.0";
spec.description = "Calculate PI";
spec.environment = "python:3.7";
spec.repository = "https://github.com/kallydev/kallypi";
spec
.repoTag = "0xb6a6502fa480fd1fb5bf95c1fb1366bcbc335a08356c2a97daf6bc44e9cc0253";
spec.repoTag = "0xb6a6502fa480fd1fb5bf95c1fb1366bcbc335a08356c2a97daf6bc44e9cc0253";
spec.license = "WTFPL";
spec.entrypoint = "src/main.py";
spec.requirement = Requirement({
ram: "256mb",
disk: "5mb",
timeout: 600,
cpu: 1,
gpu: false
});
spec
.apiABIs = '[{"request":{"type":"function","name":"getResponse","inputs":[{"name":"requestId","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},"getResponse":{"type":"function","name":"getResponse","inputs":[{"name":"requestId","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"}}]';
spec.requirement = Requirement({ram: "256mb", disk: "5mb", timeout: 600, cpu: 1, gpu: false});
spec.apiABIs =
'[{"request":{"type":"function","name":"getResponse","inputs":[{"name":"requestId","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},"getResponse":{"type":"function","name":"getResponse","inputs":[{"name":"requestId","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"}}]';
spec.royalty = 5;
spec.execMode = ExecMode.JIT;

Expand All @@ -50,17 +41,10 @@ contract Pi is OVMClient {
* @param numDigits The number of digits to calculate for PI.
* @return requestId The ID of the request returned by the OVMTasks contract.
*/
function sendRequest(
uint256 numDigits
) external payable returns (bytes32 requestId) {
function sendRequest(uint256 numDigits) external payable returns (bytes32 requestId) {
// encode the data
bytes memory data = abi.encode(numDigits);
requestId = _sendRequest(
msg.sender,
msg.value,
REQ_DETERMINISTIC,
data
);
requestId = _sendRequest(msg.sender, msg.value, REQ_DETERMINISTIC, data);
}

/**
Expand All @@ -69,10 +53,12 @@ contract Pi is OVMClient {
* @param requestId The ID of the request.
* @param data The response data to be set.
*/
function setResponse(
bytes32 requestId,
bytes calldata data
) external override recordResponse(requestId) onlyOVMTask {
function setResponse(bytes32 requestId, bytes calldata data)
external
override
recordResponse(requestId)
onlyOVMTask
{
// parse and save the data fulfilled by the OVMTasks contract
(bool success, string memory strPI) = _parseData(data);
if (success) {
Expand All @@ -87,9 +73,7 @@ contract Pi is OVMClient {
* @param requestId The ID of the request.
* @return The response data as a string in our pi calculation case.
*/
function getResponse(
bytes32 requestId
) external view returns (string memory) {
function getResponse(bytes32 requestId) external view returns (string memory) {
return _responseData[requestId];
}

Expand All @@ -99,9 +83,7 @@ contract Pi is OVMClient {
* @return A tuple containing a boolean value indicating the success of the task execution
* and a string representing the parsed data.
*/
function _parseData(
bytes calldata data
) internal pure returns (bool, string memory) {
function _parseData(bytes calldata data) internal pure returns (bool, string memory) {
return abi.decode(data, (bool, string));
}
}

0 comments on commit caa518d

Please sign in to comment.