From 024eaab74c4316d980668996ac4674fbca219ee6 Mon Sep 17 00:00:00 2001 From: Evgeny Marchenko Date: Sat, 22 Jun 2019 20:33:01 +0300 Subject: [PATCH 1/2] yet another getter --- truffle/contracts/Lazy.sol | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/truffle/contracts/Lazy.sol b/truffle/contracts/Lazy.sol index 404b215..78310ed 100644 --- a/truffle/contracts/Lazy.sol +++ b/truffle/contracts/Lazy.sol @@ -19,6 +19,9 @@ contract Lazy is Structs { } Task[] public tasks; + function tasksNum() external view returns(uint) { + return tasks.length; + } uint256 public stake; IVerifier public verifier; @@ -65,6 +68,21 @@ contract Lazy is Structs { msg.sender.transfer(stake); } + function taskDataById(uint id) external view returns( + uint[5] memory input, + uint[2] memory a, + uint[4] memory b, + uint[2] memory c + ) { + Task memory task = tasks[id]; + input = task.data.input; + a = task.proof.a; + b[0] = task.proof.b[0][0]; + b[1] = task.proof.b[0][1]; + b[2] = task.proof.b[1][0]; + b[3] = task.proof.b[1][1]; + c = task.proof.c; + } function last5Timestamps() view external returns (uint256[5] memory result) { From 470fc06a9d3a87e7f0f3d4fd805e3a84cb80ef9e Mon Sep 17 00:00:00 2001 From: Evgeny Marchenko Date: Sat, 22 Jun 2019 21:28:57 +0300 Subject: [PATCH 2/2] simplify getter even more --- truffle/contracts/Lazy.sol | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/truffle/contracts/Lazy.sol b/truffle/contracts/Lazy.sol index 78310ed..87cf7af 100644 --- a/truffle/contracts/Lazy.sol +++ b/truffle/contracts/Lazy.sol @@ -69,19 +69,26 @@ contract Lazy is Structs { } function taskDataById(uint id) external view returns( - uint[5] memory input, - uint[2] memory a, - uint[4] memory b, - uint[2] memory c + uint[13] memory data ) { Task memory task = tasks[id]; - input = task.data.input; - a = task.proof.a; - b[0] = task.proof.b[0][0]; - b[1] = task.proof.b[0][1]; - b[2] = task.proof.b[1][0]; - b[3] = task.proof.b[1][1]; - c = task.proof.c; + + data[0] = task.data.input[0]; + data[1] = task.data.input[1]; + data[2] = task.data.input[2]; + data[3] = task.data.input[3]; + data[4] = task.data.input[4]; + + data[5] = task.proof.a[0]; + data[6] = task.proof.a[1]; + + data[7] = task.proof.b[0][0]; + data[8] = task.proof.b[0][1]; + data[9] = task.proof.b[1][0]; + data[10] = task.proof.b[1][0]; + + data[11] = task.proof.c[0]; + data[12] = task.proof.c[1]; }