-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Todo.sol
35 lines (29 loc) · 841 Bytes
/
Todo.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: GNU-3.0-or-later
pragma solidity ^0.8.0;
import "hstp/HSTP.sol";
// Stateless Hyper Service Transfer Protocol for on-chain services.
contract Todo is HSTP("Todo") {
struct ITodo {
string todo;
}
function addTodo(ITodo memory request) public payable returns(Response memory response) {
response.body = request.todo;
return response;
}
// Override for HSTP.
function query(bytes memory payload)
public
view
virtual
override
returns (Response memory) {}
function mutation(bytes memory payload)
public
payable
virtual
override
returns (Response memory) {
(ITodo memory request) = abi.decode(payload, (ITodo));
return this.addTodo(request);
}
}