@inco/lightning 0.8.0-devnet-2 → 0.8.0-devnet-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,10 @@ import {IOwnerManager} from "safe-smart-account/interfaces/IOwnerManager.sol";
9
9
  import {IncoTest} from "./IncoTest.sol";
10
10
  import {inco} from "../Lib.sol";
11
11
  import {IncoLightning} from "../IncoLightning.sol";
12
+ import {IncoVerifier} from "../IncoVerifier.sol";
13
+ import {SessionVerifier, Session} from "../periphery/SessionVerifier.sol";
14
+ import {ALLOWANCE_GRANTED_MAGIC_VALUE} from "../Types.sol";
15
+ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
12
16
  import {IVersion} from "../version/interfaces/IVersion.sol";
13
17
  import {Version} from "../version/Version.sol";
14
18
  import {IIncoVerifier} from "../interfaces/IIncoVerifier.sol";
@@ -196,6 +200,116 @@ contract TestUpgrade is IncoTest {
196
200
  inco.upgradeToAndCall(address(v2Impl), "");
197
201
  }
198
202
 
203
+ // ============ IncoVerifier Tests ============
204
+
205
+ function test_IncoVerifier_GetEIP712Name() public view {
206
+ IncoVerifier verifier = IncoVerifier(address(inco.incoVerifier()));
207
+ string memory name = verifier.getEIP712Name();
208
+ // Name should not be empty
209
+ assertGt(bytes(name).length, 0, "EIP712 name should not be empty");
210
+ }
211
+
212
+ function test_IncoVerifier_GetEIP712Version() public view {
213
+ IncoVerifier verifier = IncoVerifier(address(inco.incoVerifier()));
214
+ string memory version = verifier.getEIP712Version();
215
+ // Version should not be empty
216
+ assertGt(bytes(version).length, 0, "EIP712 version should not be empty");
217
+ }
218
+
219
+ function test_IncoVerifier_Upgrade_ByOwner_Succeeds() public {
220
+ IncoVerifier verifier = IncoVerifier(address(inco.incoVerifier()));
221
+
222
+ // Deploy a new IncoVerifier implementation
223
+ IncoVerifier newImpl = new IncoVerifier(address(inco));
224
+
225
+ // Upgrade by owner should succeed
226
+ vm.prank(owner);
227
+ verifier.upgradeToAndCall(address(newImpl), "");
228
+ }
229
+
230
+ function test_IncoVerifier_Upgrade_ByNonOwner_Fails() public {
231
+ IncoVerifier verifier = IncoVerifier(address(inco.incoVerifier()));
232
+
233
+ // Deploy a new IncoVerifier implementation
234
+ IncoVerifier newImpl = new IncoVerifier(address(inco));
235
+
236
+ // Upgrade by non-owner should fail
237
+ vm.prank(alice);
238
+ vm.expectRevert();
239
+ verifier.upgradeToAndCall(address(newImpl), "");
240
+ }
241
+
242
+ // ============ SessionVerifier Tests ============
243
+
244
+ function test_SessionVerifier_ValidSession_ReturnsAllowanceGranted() public {
245
+ SessionVerifier verifier = new SessionVerifier("");
246
+
247
+ bytes memory sharerArgData = abi.encode(Session({decrypter: bob, expiresAt: block.timestamp + 1 days}));
248
+
249
+ bytes32 result = verifier.canUseSession(bytes32(0), bob, sharerArgData, "");
250
+ assertEq(result, ALLOWANCE_GRANTED_MAGIC_VALUE, "Valid session should return ALLOWANCE_GRANTED_MAGIC_VALUE");
251
+ }
252
+
253
+ function test_SessionVerifier_ExpiredSession_ReturnsZero() public {
254
+ SessionVerifier verifier = new SessionVerifier("");
255
+
256
+ // Create session that expired 1 second ago
257
+ bytes memory sharerArgData = abi.encode(Session({decrypter: bob, expiresAt: block.timestamp - 1}));
258
+
259
+ bytes32 result = verifier.canUseSession(bytes32(0), bob, sharerArgData, "");
260
+ assertEq(result, bytes32(0), "Expired session should return bytes32(0)");
261
+ }
262
+
263
+ function test_SessionVerifier_WrongDecrypter_ReturnsZero() public {
264
+ SessionVerifier verifier = new SessionVerifier("");
265
+
266
+ // Session is valid but decrypter doesn't match caller
267
+ bytes memory sharerArgData = abi.encode(Session({decrypter: alice, expiresAt: block.timestamp + 1 days}));
268
+
269
+ bytes32 result = verifier.canUseSession(bytes32(0), bob, sharerArgData, "");
270
+ assertEq(result, bytes32(0), "Wrong decrypter should return bytes32(0)");
271
+ }
272
+
273
+ function test_SessionVerifier_Initialize() public {
274
+ SessionVerifier impl = new SessionVerifier("");
275
+ ERC1967Proxy proxy = new ERC1967Proxy(address(impl), "");
276
+ SessionVerifier verifier = SessionVerifier(address(proxy));
277
+
278
+ verifier.initialize(alice);
279
+ assertEq(verifier.owner(), alice, "Owner should be alice after initialize");
280
+ }
281
+
282
+ function test_SessionVerifier_Upgrade_ByOwner_Succeeds() public {
283
+ SessionVerifier impl = new SessionVerifier("");
284
+ ERC1967Proxy proxy = new ERC1967Proxy(address(impl), "");
285
+ SessionVerifier verifier = SessionVerifier(address(proxy));
286
+
287
+ verifier.initialize(alice);
288
+
289
+ // Deploy new implementation
290
+ SessionVerifier newImpl = new SessionVerifier("");
291
+
292
+ // Upgrade by owner should succeed
293
+ vm.prank(alice);
294
+ verifier.upgradeToAndCall(address(newImpl), "");
295
+ }
296
+
297
+ function test_SessionVerifier_Upgrade_ByNonOwner_Fails() public {
298
+ SessionVerifier impl = new SessionVerifier("");
299
+ ERC1967Proxy proxy = new ERC1967Proxy(address(impl), "");
300
+ SessionVerifier verifier = SessionVerifier(address(proxy));
301
+
302
+ verifier.initialize(alice);
303
+
304
+ // Deploy new implementation
305
+ SessionVerifier newImpl = new SessionVerifier("");
306
+
307
+ // Upgrade by non-owner should fail
308
+ vm.prank(bob);
309
+ vm.expectRevert();
310
+ verifier.upgradeToAndCall(address(newImpl), "");
311
+ }
312
+
199
313
  // Helpers
200
314
  function _txHash(Safe _safe, address to, uint256 value, bytes memory data) internal view returns (bytes32) {
201
315
  return _safe.getTransactionHash(
@@ -25,6 +25,7 @@ contract TestVersion is Test {
25
25
  assertEq(someContract.getName(), "SomeContract");
26
26
  assertEq(someContract.getVersion(), "1_2_3");
27
27
  assertEq(someContract.getVersionedName(), "SomeContract_1_2_3__12345678");
28
+ assertEq(someContract.salt(), bytes32(uint256(12345678)));
28
29
  }
29
30
 
30
31
  }
@@ -1,453 +0,0 @@
1
- // AUTOGENERATED FILE. DO NOT EDIT.
2
- // This file was generated by the IncoLightning library generator.
3
- // The original template is located at Lib.template.sol
4
-
5
- /// SPDX-License-Identifier: No License
6
- pragma solidity ^0.8;
7
-
8
- import {IncoLightning} from "../IncoLightning.sol";
9
- import {ebool, euint256, eaddress, ETypes} from "../Types.sol";
10
-
11
- IncoLightning constant inco = IncoLightning(0x7b98b0482099611B0ebEA0F98f81FF555406794A);
12
- address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
-
14
- function typeOf(bytes32 handle) pure returns (ETypes) {
15
- return ETypes(uint8(uint256(handle) >> 8));
16
- }
17
-
18
- library e {
19
-
20
- function sanitize(euint256 a) internal returns (euint256) {
21
- if (euint256.unwrap(a) == bytes32(0)) {
22
- return asEuint256(0);
23
- }
24
- return a;
25
- }
26
-
27
- function sanitize(ebool a) internal returns (ebool) {
28
- if (ebool.unwrap(a) == bytes32(0)) {
29
- return asEbool(false);
30
- }
31
- return a;
32
- }
33
-
34
- function sanitize(eaddress a) internal returns (eaddress) {
35
- if (eaddress.unwrap(a) == bytes32(0)) {
36
- return asEaddress(address(0));
37
- }
38
- return a;
39
- }
40
-
41
- function s(euint256 a) internal returns (euint256) {
42
- return sanitize(a);
43
- }
44
-
45
- function s(ebool a) internal returns (ebool) {
46
- return sanitize(a);
47
- }
48
-
49
- function s(eaddress a) internal returns (eaddress) {
50
- return sanitize(a);
51
- }
52
-
53
- function add(euint256 a, euint256 b) internal returns (euint256) {
54
- return inco.eAdd(s(a), s(b));
55
- }
56
-
57
- function add(euint256 a, uint256 b) internal returns (euint256) {
58
- return inco.eAdd(s(a), asEuint256(b));
59
- }
60
-
61
- function add(uint256 a, euint256 b) internal returns (euint256) {
62
- return inco.eAdd(asEuint256(a), s(b));
63
- }
64
-
65
- function sub(euint256 a, euint256 b) internal returns (euint256) {
66
- return inco.eSub(s(a), s(b));
67
- }
68
-
69
- function sub(euint256 a, uint256 b) internal returns (euint256) {
70
- return inco.eSub(s(a), asEuint256(b));
71
- }
72
-
73
- function sub(uint256 a, euint256 b) internal returns (euint256) {
74
- return inco.eSub(asEuint256(a), s(b));
75
- }
76
-
77
- function mul(euint256 a, euint256 b) internal returns (euint256) {
78
- return inco.eMul(s(a), s(b));
79
- }
80
-
81
- function mul(euint256 a, uint256 b) internal returns (euint256) {
82
- return inco.eMul(s(a), asEuint256(b));
83
- }
84
-
85
- function mul(uint256 a, euint256 b) internal returns (euint256) {
86
- return inco.eMul(asEuint256(a), s(b));
87
- }
88
-
89
- function div(euint256 a, euint256 b) internal returns (euint256) {
90
- return inco.eDiv(s(a), s(b));
91
- }
92
-
93
- function div(euint256 a, uint256 b) internal returns (euint256) {
94
- return inco.eDiv(s(a), asEuint256(b));
95
- }
96
-
97
- function div(uint256 a, euint256 b) internal returns (euint256) {
98
- return inco.eDiv(asEuint256(a), s(b));
99
- }
100
-
101
- function rem(euint256 a, euint256 b) internal returns (euint256) {
102
- return inco.eRem(s(a), s(b));
103
- }
104
-
105
- function rem(euint256 a, uint256 b) internal returns (euint256) {
106
- return inco.eRem(s(a), asEuint256(b));
107
- }
108
-
109
- function rem(uint256 a, euint256 b) internal returns (euint256) {
110
- return inco.eRem(asEuint256(a), s(b));
111
- }
112
-
113
- function and(euint256 a, euint256 b) internal returns (euint256) {
114
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
115
- }
116
-
117
- function and(euint256 a, uint256 b) internal returns (euint256) {
118
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
119
- }
120
-
121
- function and(uint256 a, euint256 b) internal returns (euint256) {
122
- return euint256.wrap(inco.eBitAnd(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
123
- }
124
-
125
- function and(ebool a, ebool b) internal returns (ebool) {
126
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
127
- }
128
-
129
- function and(ebool a, bool b) internal returns (ebool) {
130
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
131
- }
132
-
133
- function and(bool a, ebool b) internal returns (ebool) {
134
- return ebool.wrap(inco.eBitAnd(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
135
- }
136
-
137
- function or(euint256 a, euint256 b) internal returns (euint256) {
138
- return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
139
- }
140
-
141
- function or(euint256 a, uint256 b) internal returns (euint256) {
142
- return euint256.wrap(inco.eBitOr(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
143
- }
144
-
145
- function or(uint256 a, euint256 b) internal returns (euint256) {
146
- return euint256.wrap(inco.eBitOr(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
147
- }
148
-
149
- function or(ebool a, ebool b) internal returns (ebool) {
150
- return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
151
- }
152
-
153
- function or(ebool a, bool b) internal returns (ebool) {
154
- return ebool.wrap(inco.eBitOr(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
155
- }
156
-
157
- function or(bool a, ebool b) internal returns (ebool) {
158
- return ebool.wrap(inco.eBitOr(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
159
- }
160
-
161
- function xor(euint256 a, euint256 b) internal returns (euint256) {
162
- return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(s(b))));
163
- }
164
-
165
- function xor(euint256 a, uint256 b) internal returns (euint256) {
166
- return euint256.wrap(inco.eBitXor(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b))));
167
- }
168
-
169
- function xor(uint256 a, euint256 b) internal returns (euint256) {
170
- return euint256.wrap(inco.eBitXor(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b))));
171
- }
172
-
173
- function xor(ebool a, ebool b) internal returns (ebool) {
174
- return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(s(b))));
175
- }
176
-
177
- function xor(ebool a, bool b) internal returns (ebool) {
178
- return ebool.wrap(inco.eBitXor(ebool.unwrap(s(a)), ebool.unwrap(asEbool(b))));
179
- }
180
-
181
- function xor(bool a, ebool b) internal returns (ebool) {
182
- return ebool.wrap(inco.eBitXor(ebool.unwrap(asEbool(a)), ebool.unwrap(s(b))));
183
- }
184
-
185
- function shl(euint256 a, euint256 b) internal returns (euint256) {
186
- return inco.eShl(s(a), s(b));
187
- }
188
-
189
- function shl(euint256 a, uint256 b) internal returns (euint256) {
190
- return inco.eShl(s(a), asEuint256(b));
191
- }
192
-
193
- function shl(uint256 a, euint256 b) internal returns (euint256) {
194
- return inco.eShl(asEuint256(a), s(b));
195
- }
196
-
197
- function shr(euint256 a, euint256 b) internal returns (euint256) {
198
- return inco.eShr(s(a), s(b));
199
- }
200
-
201
- function shr(euint256 a, uint256 b) internal returns (euint256) {
202
- return inco.eShr(s(a), asEuint256(b));
203
- }
204
-
205
- function shr(uint256 a, euint256 b) internal returns (euint256) {
206
- return inco.eShr(asEuint256(a), s(b));
207
- }
208
-
209
- function rotl(euint256 a, euint256 b) internal returns (euint256) {
210
- return inco.eRotl(s(a), s(b));
211
- }
212
-
213
- function rotl(euint256 a, uint256 b) internal returns (euint256) {
214
- return inco.eRotl(s(a), asEuint256(b));
215
- }
216
-
217
- function rotl(uint256 a, euint256 b) internal returns (euint256) {
218
- return inco.eRotl(asEuint256(a), s(b));
219
- }
220
-
221
- function rotr(euint256 a, euint256 b) internal returns (euint256) {
222
- return inco.eRotr(s(a), s(b));
223
- }
224
-
225
- function rotr(euint256 a, uint256 b) internal returns (euint256) {
226
- return inco.eRotr(s(a), asEuint256(b));
227
- }
228
-
229
- function rotr(uint256 a, euint256 b) internal returns (euint256) {
230
- return inco.eRotr(asEuint256(a), s(b));
231
- }
232
-
233
- function eq(euint256 a, euint256 b) internal returns (ebool) {
234
- return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
235
- }
236
-
237
- function eq(euint256 a, uint256 b) internal returns (ebool) {
238
- return inco.eEq(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
239
- }
240
-
241
- function eq(uint256 a, euint256 b) internal returns (ebool) {
242
- return inco.eEq(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
243
- }
244
-
245
- function eq(eaddress a, address b) internal returns (ebool) {
246
- return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
247
- }
248
-
249
- function eq(eaddress a, eaddress b) internal returns (ebool) {
250
- return inco.eEq(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
251
- }
252
-
253
- function eq(address a, eaddress b) internal returns (ebool) {
254
- return inco.eEq(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
255
- }
256
-
257
- function ne(euint256 a, euint256 b) internal returns (ebool) {
258
- return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(s(b)));
259
- }
260
-
261
- function ne(euint256 a, uint256 b) internal returns (ebool) {
262
- return inco.eNe(euint256.unwrap(s(a)), euint256.unwrap(asEuint256(b)));
263
- }
264
-
265
- function ne(uint256 a, euint256 b) internal returns (ebool) {
266
- return inco.eNe(euint256.unwrap(asEuint256(a)), euint256.unwrap(s(b)));
267
- }
268
-
269
- function ne(eaddress a, eaddress b) internal returns (ebool) {
270
- return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(s(b)));
271
- }
272
-
273
- function ne(eaddress a, address b) internal returns (ebool) {
274
- return inco.eNe(eaddress.unwrap(s(a)), eaddress.unwrap(asEaddress(b)));
275
- }
276
-
277
- function ne(address a, eaddress b) internal returns (ebool) {
278
- return inco.eNe(eaddress.unwrap(asEaddress(a)), eaddress.unwrap(s(b)));
279
- }
280
-
281
- function ge(euint256 a, euint256 b) internal returns (ebool) {
282
- return inco.eGe(s(a), s(b));
283
- }
284
-
285
- function ge(euint256 a, uint256 b) internal returns (ebool) {
286
- return inco.eGe(s(a), asEuint256(b));
287
- }
288
-
289
- function ge(uint256 a, euint256 b) internal returns (ebool) {
290
- return inco.eGe(asEuint256(a), s(b));
291
- }
292
-
293
- function gt(euint256 a, euint256 b) internal returns (ebool) {
294
- return inco.eGt(s(a), s(b));
295
- }
296
-
297
- function gt(euint256 a, uint256 b) internal returns (ebool) {
298
- return inco.eGt(s(a), asEuint256(b));
299
- }
300
-
301
- function gt(uint256 a, euint256 b) internal returns (ebool) {
302
- return inco.eGt(asEuint256(a), s(b));
303
- }
304
-
305
- function le(euint256 a, euint256 b) internal returns (ebool) {
306
- return inco.eLe(s(a), s(b));
307
- }
308
-
309
- function le(euint256 a, uint256 b) internal returns (ebool) {
310
- return inco.eLe(s(a), asEuint256(b));
311
- }
312
-
313
- function le(uint256 a, euint256 b) internal returns (ebool) {
314
- return inco.eLe(asEuint256(a), s(b));
315
- }
316
-
317
- function lt(euint256 a, euint256 b) internal returns (ebool) {
318
- return inco.eLt(s(a), s(b));
319
- }
320
-
321
- function lt(euint256 a, uint256 b) internal returns (ebool) {
322
- return inco.eLt(s(a), asEuint256(b));
323
- }
324
-
325
- function lt(uint256 a, euint256 b) internal returns (ebool) {
326
- return inco.eLt(asEuint256(a), s(b));
327
- }
328
-
329
- function min(euint256 a, euint256 b) internal returns (euint256) {
330
- return inco.eMin(s(a), s(b));
331
- }
332
-
333
- function min(euint256 a, uint256 b) internal returns (euint256) {
334
- return inco.eMin(s(a), asEuint256(b));
335
- }
336
-
337
- function min(uint256 a, euint256 b) internal returns (euint256) {
338
- return inco.eMin(asEuint256(a), s(b));
339
- }
340
-
341
- function max(euint256 a, euint256 b) internal returns (euint256) {
342
- return inco.eMax(s(a), s(b));
343
- }
344
-
345
- function max(euint256 a, uint256 b) internal returns (euint256) {
346
- return inco.eMax(s(a), asEuint256(b));
347
- }
348
-
349
- function max(uint256 a, euint256 b) internal returns (euint256) {
350
- return inco.eMax(asEuint256(a), s(b));
351
- }
352
-
353
- function not(ebool a) internal returns (ebool) {
354
- return inco.eNot(s(a));
355
- }
356
-
357
- function rand() internal returns (euint256) {
358
- return euint256.wrap(inco.eRand(ETypes.Uint256));
359
- }
360
-
361
- function randBounded(uint256 upperBound) internal returns (euint256) {
362
- return euint256.wrap(inco.eRandBounded(euint256.unwrap(asEuint256(upperBound)), ETypes.Uint256));
363
- }
364
-
365
- function randBounded(euint256 upperBound) internal returns (euint256) {
366
- return euint256.wrap(inco.eRandBounded(euint256.unwrap(s(upperBound)), ETypes.Uint256));
367
- }
368
-
369
- function asEuint256(uint256 a) internal returns (euint256) {
370
- return inco.asEuint256(a);
371
- }
372
-
373
- function asEbool(bool a) internal returns (ebool) {
374
- return inco.asEbool(a);
375
- }
376
-
377
- function asEaddress(address a) internal returns (eaddress) {
378
- return inco.asEaddress(a);
379
- }
380
-
381
- function asEbool(euint256 a) internal returns (ebool) {
382
- return ebool.wrap(inco.eCast(euint256.unwrap(a), ETypes.Bool));
383
- }
384
-
385
- function asEuint256(ebool a) internal returns (euint256) {
386
- return euint256.wrap(inco.eCast(ebool.unwrap(a), ETypes.Uint256));
387
- }
388
-
389
- function newEuint256(bytes memory ciphertext, address user) internal returns (euint256) {
390
- return inco.newEuint256(ciphertext, user);
391
- }
392
-
393
- function newEbool(bytes memory ciphertext, address user) internal returns (ebool) {
394
- return inco.newEbool(ciphertext, user);
395
- }
396
-
397
- function newEaddress(bytes memory ciphertext, address user) internal returns (eaddress) {
398
- return inco.newEaddress(ciphertext, user);
399
- }
400
-
401
- function allow(euint256 a, address to) internal {
402
- inco.allow(euint256.unwrap(a), to);
403
- }
404
-
405
- function allow(ebool a, address to) internal {
406
- inco.allow(ebool.unwrap(a), to);
407
- }
408
-
409
- function allow(eaddress a, address to) internal {
410
- inco.allow(eaddress.unwrap(a), to);
411
- }
412
-
413
- function reveal(euint256 a) internal {
414
- inco.reveal(euint256.unwrap(a));
415
- }
416
-
417
- function reveal(ebool a) internal {
418
- inco.reveal(ebool.unwrap(a));
419
- }
420
-
421
- function reveal(eaddress a) internal {
422
- inco.reveal(eaddress.unwrap(a));
423
- }
424
-
425
- function allowThis(euint256 a) internal {
426
- allow(a, address(this));
427
- }
428
-
429
- function allowThis(ebool a) internal {
430
- allow(a, address(this));
431
- }
432
-
433
- function allowThis(eaddress a) internal {
434
- allow(a, address(this));
435
- }
436
-
437
- function isAllowed(address user, euint256 a) internal view returns (bool) {
438
- return inco.isAllowed(euint256.unwrap(a), user);
439
- }
440
-
441
- function select(ebool control, euint256 ifTrue, euint256 ifFalse) internal returns (euint256) {
442
- return euint256.wrap(inco.eIfThenElse(s(control), euint256.unwrap(s(ifTrue)), euint256.unwrap(s(ifFalse))));
443
- }
444
-
445
- function select(ebool control, ebool ifTrue, ebool ifFalse) internal returns (ebool) {
446
- return ebool.wrap(inco.eIfThenElse(s(control), ebool.unwrap(s(ifTrue)), ebool.unwrap(s(ifFalse))));
447
- }
448
-
449
- function select(ebool control, eaddress ifTrue, eaddress ifFalse) internal returns (eaddress) {
450
- return eaddress.wrap(inco.eIfThenElse(s(control), eaddress.unwrap(s(ifTrue)), eaddress.unwrap(s(ifFalse))));
451
- }
452
-
453
- }