-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipechain.tsol
132 lines (112 loc) · 4.5 KB
/
pipechain.tsol
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// SPDX-License-Identifier: UNLICENSED
pragma ever-solidity >= 0.66.0;
pragma AbiHeader expire;
pragma AbiHeader time;
pragma AbiHeader pubkey;
import "https://raw.githubusercontent.com/tonlabs/debots/main/Debot.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Terminal/Terminal.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/ConfirmInput/ConfirmInput.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/Menu/Menu.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/AddressInput/AddressInput.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/AmountInput/AmountInput.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/UserInfo/UserInfo.sol";
import "https://raw.githubusercontent.com/tonlabs/DeBot-IS-consortium/main/SigningBoxInput/SigningBoxInput.sol";
import "ICompleted.tsol";
contract Invoked is Debot {
address m_invoker;
uint64 m_arg1;
string m_arg2;
bool m_arg3;
uint32 m_arg4;
address m_arg5;
uint256 m_arg6;
mapping(uint32 => Data) m_arg7;
/// @notice Returns Metadata about DeBot.
function getDebotInfo() public functionID(0xDEB) override view returns(
string name, string version, string publisher, string caption, string author,
address support, string hello, string language, string dabi, bytes icon
) {
name = "InvokeTest";
version = "1.0.0-alpha.0";
publisher = "Ever Guild";
caption = "For testing pipechain";
author = "Ever Guild";
support = address(0);
hello = "I am support pipechain";
language = "en";
dabi = m_debotAbi.get();
icon = "";
}
function getRequiredInterfaces() public view override returns (uint256[] interfaces) {
return [Terminal.ID, AddressInput.ID, AmountInput.ID, ConfirmInput.ID, Menu.ID, UserInfo.ID];
}
/// @notice Entry point function for DeBot.
function start() public override {
uint256[] empty;
SigningBoxInput.get(tvm.functionId(setSignBoxHandle), "Enter keys", empty);
}
function setSignBoxHandle(uint32 handle) pure public {
require(handle != 0);
this.setDataOnchain{
abiVer: 2, sign: true,
time: 0, expire: 0, pubkey: 0, signBoxHandle: handle,
callbackId: tvm.functionId(onSuccess),
onErrorId: tvm.functionId(onError)
}().extMsg;
}
function onSuccess() public {
}
function onError(uint32 sdkError, uint32 exitCode) pure public {
sdkError;
exitCode;
revert();
}
function setDataOnchain() view public {
require(msg.pubkey() == tvm.pubkey());
tvm.accept();
}
//
// Invoke funcitons
//
function invokeTest(uint64 arg1, string arg2, bool arg3, uint32 arg4, address arg5, uint256 arg6, mapping(uint32 => Data) arg7) public {
m_invoker = msg.sender;
AmountInput.get(tvm.functionId(checkArg1), "Enter arg1 as amount:", 9, 0, 100 ever);
Terminal.input(tvm.functionId(checkArg2), "Enter arg2 as string:", false);
// Terminal.print(0, "Print smthg");
ConfirmInput.get(tvm.functionId(checkArg3), "Enter arg3 as boolean:");
MenuItem[] items;
for(uint32 i = 0; i < arg4 + 1; i++) {
items.push(MenuItem(format("Item {}", i), "", tvm.functionId(checkArg4)) );
}
Menu.select("Enter arg4 as menu index:", "", items);
AddressInput.get(tvm.functionId(checkArg5), "Enter arg5 as address:");
UserInfo.getPublicKey(tvm.functionId(checkArg6));
m_arg1 = arg1;
m_arg2 = arg2;
m_arg3 = arg3;
m_arg4 = arg4;
m_arg5 = arg5;
m_arg6 = arg6;
m_arg7 = arg7;
}
// ----------------------------------------------------
function checkArg1(uint128 value) view public {
require(value == m_arg1, 201);
}
function checkArg2(string value) view public {
require(value == m_arg2, 202);
}
function checkArg3(bool value) view public {
require(value == m_arg3, 203);
}
function checkArg4(uint32 index) view public {
require(index == m_arg4, 204);
}
function checkArg5(address value) view public {
require(value == m_arg5, 205);
}
function checkArg6(uint256 value) view public {
require(value == m_arg6, 206);
IOnInvokeCompleted(m_invoker).OnInvokeCompleted(Status.Passed, m_arg7);
}
}