@iexec-nox/nox-protocol-contracts 0.1.0-beta.3 → 0.1.0-beta.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.
- package/contracts/sdk/Nox.sol +177 -89
- package/package.json +1 -1
package/contracts/sdk/Nox.sol
CHANGED
|
@@ -13,6 +13,10 @@ import "encrypted-types/EncryptedTypes.sol";
|
|
|
13
13
|
* the transaction will revert as it will not be recognized by the ACL.
|
|
14
14
|
*/
|
|
15
15
|
library Nox {
|
|
16
|
+
// ============ Errors ============
|
|
17
|
+
|
|
18
|
+
error UninitializedHandle();
|
|
19
|
+
|
|
16
20
|
// ============ Internal address resolution ============
|
|
17
21
|
|
|
18
22
|
/**
|
|
@@ -235,124 +239,106 @@ library Nox {
|
|
|
235
239
|
// ============ Arithmetic primitives ============
|
|
236
240
|
|
|
237
241
|
function add(euint16 a, euint16 b) internal returns (euint16) {
|
|
238
|
-
return euint16.wrap(
|
|
242
|
+
return euint16.wrap(_add(euint16.unwrap(a), euint16.unwrap(b)));
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
function add(euint256 a, euint256 b) internal returns (euint256) {
|
|
242
|
-
return euint256.wrap(
|
|
246
|
+
return euint256.wrap(_add(euint256.unwrap(a), euint256.unwrap(b)));
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
function add(eint16 a, eint16 b) internal returns (eint16) {
|
|
246
|
-
return eint16.wrap(
|
|
250
|
+
return eint16.wrap(_add(eint16.unwrap(a), eint16.unwrap(b)));
|
|
247
251
|
}
|
|
248
252
|
|
|
249
253
|
function add(eint256 a, eint256 b) internal returns (eint256) {
|
|
250
|
-
return eint256.wrap(
|
|
254
|
+
return eint256.wrap(_add(eint256.unwrap(a), eint256.unwrap(b)));
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
function sub(euint16 a, euint16 b) internal returns (euint16) {
|
|
254
|
-
return euint16.wrap(
|
|
258
|
+
return euint16.wrap(_sub(euint16.unwrap(a), euint16.unwrap(b)));
|
|
255
259
|
}
|
|
256
260
|
|
|
257
261
|
function sub(euint256 a, euint256 b) internal returns (euint256) {
|
|
258
|
-
return euint256.wrap(
|
|
262
|
+
return euint256.wrap(_sub(euint256.unwrap(a), euint256.unwrap(b)));
|
|
259
263
|
}
|
|
260
264
|
|
|
261
265
|
function sub(eint16 a, eint16 b) internal returns (eint16) {
|
|
262
|
-
return eint16.wrap(
|
|
266
|
+
return eint16.wrap(_sub(eint16.unwrap(a), eint16.unwrap(b)));
|
|
263
267
|
}
|
|
264
268
|
|
|
265
269
|
function sub(eint256 a, eint256 b) internal returns (eint256) {
|
|
266
|
-
return eint256.wrap(
|
|
270
|
+
return eint256.wrap(_sub(eint256.unwrap(a), eint256.unwrap(b)));
|
|
267
271
|
}
|
|
268
272
|
|
|
269
273
|
function mul(euint16 a, euint16 b) internal returns (euint16) {
|
|
270
|
-
return euint16.wrap(
|
|
274
|
+
return euint16.wrap(_mul(euint16.unwrap(a), euint16.unwrap(b)));
|
|
271
275
|
}
|
|
272
276
|
|
|
273
277
|
function mul(euint256 a, euint256 b) internal returns (euint256) {
|
|
274
|
-
return euint256.wrap(
|
|
278
|
+
return euint256.wrap(_mul(euint256.unwrap(a), euint256.unwrap(b)));
|
|
275
279
|
}
|
|
276
280
|
|
|
277
281
|
function mul(eint16 a, eint16 b) internal returns (eint16) {
|
|
278
|
-
return eint16.wrap(
|
|
282
|
+
return eint16.wrap(_mul(eint16.unwrap(a), eint16.unwrap(b)));
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
function mul(eint256 a, eint256 b) internal returns (eint256) {
|
|
282
|
-
return eint256.wrap(
|
|
286
|
+
return eint256.wrap(_mul(eint256.unwrap(a), eint256.unwrap(b)));
|
|
283
287
|
}
|
|
284
288
|
|
|
285
289
|
function div(euint16 a, euint16 b) internal returns (euint16) {
|
|
286
|
-
return euint16.wrap(
|
|
290
|
+
return euint16.wrap(_div(euint16.unwrap(a), euint16.unwrap(b)));
|
|
287
291
|
}
|
|
288
292
|
|
|
289
293
|
function div(euint256 a, euint256 b) internal returns (euint256) {
|
|
290
|
-
return euint256.wrap(
|
|
294
|
+
return euint256.wrap(_div(euint256.unwrap(a), euint256.unwrap(b)));
|
|
291
295
|
}
|
|
292
296
|
|
|
293
297
|
function div(eint16 a, eint16 b) internal returns (eint16) {
|
|
294
|
-
return eint16.wrap(
|
|
298
|
+
return eint16.wrap(_div(eint16.unwrap(a), eint16.unwrap(b)));
|
|
295
299
|
}
|
|
296
300
|
|
|
297
301
|
function div(eint256 a, eint256 b) internal returns (eint256) {
|
|
298
|
-
return eint256.wrap(
|
|
302
|
+
return eint256.wrap(_div(eint256.unwrap(a), eint256.unwrap(b)));
|
|
299
303
|
}
|
|
300
304
|
|
|
301
305
|
function safeAdd(euint16 a, euint16 b) internal returns (ebool, euint16) {
|
|
302
|
-
(bytes32 success, bytes32 result) =
|
|
303
|
-
euint16.unwrap(a),
|
|
304
|
-
euint16.unwrap(b)
|
|
305
|
-
);
|
|
306
|
+
(bytes32 success, bytes32 result) = _safeAdd(euint16.unwrap(a), euint16.unwrap(b));
|
|
306
307
|
return (ebool.wrap(success), euint16.wrap(result));
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
function safeAdd(euint256 a, euint256 b) internal returns (ebool, euint256) {
|
|
310
|
-
(bytes32 success, bytes32 result) =
|
|
311
|
-
euint256.unwrap(a),
|
|
312
|
-
euint256.unwrap(b)
|
|
313
|
-
);
|
|
311
|
+
(bytes32 success, bytes32 result) = _safeAdd(euint256.unwrap(a), euint256.unwrap(b));
|
|
314
312
|
return (ebool.wrap(success), euint256.wrap(result));
|
|
315
313
|
}
|
|
316
314
|
|
|
317
315
|
function safeAdd(eint16 a, eint16 b) internal returns (ebool, eint16) {
|
|
318
|
-
(bytes32 success, bytes32 result) =
|
|
316
|
+
(bytes32 success, bytes32 result) = _safeAdd(eint16.unwrap(a), eint16.unwrap(b));
|
|
319
317
|
return (ebool.wrap(success), eint16.wrap(result));
|
|
320
318
|
}
|
|
321
319
|
|
|
322
320
|
function safeAdd(eint256 a, eint256 b) internal returns (ebool, eint256) {
|
|
323
|
-
(bytes32 success, bytes32 result) =
|
|
324
|
-
eint256.unwrap(a),
|
|
325
|
-
eint256.unwrap(b)
|
|
326
|
-
);
|
|
321
|
+
(bytes32 success, bytes32 result) = _safeAdd(eint256.unwrap(a), eint256.unwrap(b));
|
|
327
322
|
return (ebool.wrap(success), eint256.wrap(result));
|
|
328
323
|
}
|
|
329
324
|
|
|
330
325
|
function safeSub(euint16 a, euint16 b) internal returns (ebool, euint16) {
|
|
331
|
-
(bytes32 success, bytes32 result) =
|
|
332
|
-
euint16.unwrap(a),
|
|
333
|
-
euint16.unwrap(b)
|
|
334
|
-
);
|
|
326
|
+
(bytes32 success, bytes32 result) = _safeSub(euint16.unwrap(a), euint16.unwrap(b));
|
|
335
327
|
return (ebool.wrap(success), euint16.wrap(result));
|
|
336
328
|
}
|
|
337
329
|
|
|
338
330
|
function safeSub(euint256 a, euint256 b) internal returns (ebool, euint256) {
|
|
339
|
-
(bytes32 success, bytes32 result) =
|
|
340
|
-
euint256.unwrap(a),
|
|
341
|
-
euint256.unwrap(b)
|
|
342
|
-
);
|
|
331
|
+
(bytes32 success, bytes32 result) = _safeSub(euint256.unwrap(a), euint256.unwrap(b));
|
|
343
332
|
return (ebool.wrap(success), euint256.wrap(result));
|
|
344
333
|
}
|
|
345
334
|
|
|
346
335
|
function safeSub(eint16 a, eint16 b) internal returns (ebool, eint16) {
|
|
347
|
-
(bytes32 success, bytes32 result) =
|
|
336
|
+
(bytes32 success, bytes32 result) = _safeSub(eint16.unwrap(a), eint16.unwrap(b));
|
|
348
337
|
return (ebool.wrap(success), eint16.wrap(result));
|
|
349
338
|
}
|
|
350
339
|
|
|
351
340
|
function safeSub(eint256 a, eint256 b) internal returns (ebool, eint256) {
|
|
352
|
-
(bytes32 success, bytes32 result) =
|
|
353
|
-
eint256.unwrap(a),
|
|
354
|
-
eint256.unwrap(b)
|
|
355
|
-
);
|
|
341
|
+
(bytes32 success, bytes32 result) = _safeSub(eint256.unwrap(a), eint256.unwrap(b));
|
|
356
342
|
return (ebool.wrap(success), eint256.wrap(result));
|
|
357
343
|
}
|
|
358
344
|
|
|
@@ -361,11 +347,7 @@ library Nox {
|
|
|
361
347
|
function select(ebool condition, euint16 ifTrue, euint16 ifFalse) internal returns (euint16) {
|
|
362
348
|
return
|
|
363
349
|
euint16.wrap(
|
|
364
|
-
|
|
365
|
-
ebool.unwrap(condition),
|
|
366
|
-
euint16.unwrap(ifTrue),
|
|
367
|
-
euint16.unwrap(ifFalse)
|
|
368
|
-
)
|
|
350
|
+
_select(ebool.unwrap(condition), euint16.unwrap(ifTrue), euint16.unwrap(ifFalse))
|
|
369
351
|
);
|
|
370
352
|
}
|
|
371
353
|
|
|
@@ -376,130 +358,118 @@ library Nox {
|
|
|
376
358
|
) internal returns (euint256) {
|
|
377
359
|
return
|
|
378
360
|
euint256.wrap(
|
|
379
|
-
|
|
380
|
-
ebool.unwrap(condition),
|
|
381
|
-
euint256.unwrap(ifTrue),
|
|
382
|
-
euint256.unwrap(ifFalse)
|
|
383
|
-
)
|
|
361
|
+
_select(ebool.unwrap(condition), euint256.unwrap(ifTrue), euint256.unwrap(ifFalse))
|
|
384
362
|
);
|
|
385
363
|
}
|
|
386
364
|
|
|
387
365
|
function select(ebool condition, eint16 ifTrue, eint16 ifFalse) internal returns (eint16) {
|
|
388
366
|
return
|
|
389
367
|
eint16.wrap(
|
|
390
|
-
|
|
391
|
-
ebool.unwrap(condition),
|
|
392
|
-
eint16.unwrap(ifTrue),
|
|
393
|
-
eint16.unwrap(ifFalse)
|
|
394
|
-
)
|
|
368
|
+
_select(ebool.unwrap(condition), eint16.unwrap(ifTrue), eint16.unwrap(ifFalse))
|
|
395
369
|
);
|
|
396
370
|
}
|
|
397
371
|
|
|
398
372
|
function select(ebool condition, eint256 ifTrue, eint256 ifFalse) internal returns (eint256) {
|
|
399
373
|
return
|
|
400
374
|
eint256.wrap(
|
|
401
|
-
|
|
402
|
-
ebool.unwrap(condition),
|
|
403
|
-
eint256.unwrap(ifTrue),
|
|
404
|
-
eint256.unwrap(ifFalse)
|
|
405
|
-
)
|
|
375
|
+
_select(ebool.unwrap(condition), eint256.unwrap(ifTrue), eint256.unwrap(ifFalse))
|
|
406
376
|
);
|
|
407
377
|
}
|
|
408
378
|
|
|
409
379
|
function eq(euint16 a, euint16 b) internal returns (ebool) {
|
|
410
|
-
return ebool.wrap(
|
|
380
|
+
return ebool.wrap(_eq(euint16.unwrap(a), euint16.unwrap(b)));
|
|
411
381
|
}
|
|
412
382
|
|
|
413
383
|
function eq(euint256 a, euint256 b) internal returns (ebool) {
|
|
414
|
-
return ebool.wrap(
|
|
384
|
+
return ebool.wrap(_eq(euint256.unwrap(a), euint256.unwrap(b)));
|
|
415
385
|
}
|
|
416
386
|
|
|
417
387
|
function eq(eint16 a, eint16 b) internal returns (ebool) {
|
|
418
|
-
return ebool.wrap(
|
|
388
|
+
return ebool.wrap(_eq(eint16.unwrap(a), eint16.unwrap(b)));
|
|
419
389
|
}
|
|
420
390
|
|
|
421
391
|
function eq(eint256 a, eint256 b) internal returns (ebool) {
|
|
422
|
-
return ebool.wrap(
|
|
392
|
+
return ebool.wrap(_eq(eint256.unwrap(a), eint256.unwrap(b)));
|
|
423
393
|
}
|
|
424
394
|
|
|
425
395
|
function ne(euint16 a, euint16 b) internal returns (ebool) {
|
|
426
|
-
return ebool.wrap(
|
|
396
|
+
return ebool.wrap(_ne(euint16.unwrap(a), euint16.unwrap(b)));
|
|
427
397
|
}
|
|
428
398
|
|
|
429
399
|
function ne(euint256 a, euint256 b) internal returns (ebool) {
|
|
430
|
-
return ebool.wrap(
|
|
400
|
+
return ebool.wrap(_ne(euint256.unwrap(a), euint256.unwrap(b)));
|
|
431
401
|
}
|
|
432
402
|
|
|
433
403
|
function ne(eint16 a, eint16 b) internal returns (ebool) {
|
|
434
|
-
return ebool.wrap(
|
|
404
|
+
return ebool.wrap(_ne(eint16.unwrap(a), eint16.unwrap(b)));
|
|
435
405
|
}
|
|
436
406
|
|
|
437
407
|
function ne(eint256 a, eint256 b) internal returns (ebool) {
|
|
438
|
-
return ebool.wrap(
|
|
408
|
+
return ebool.wrap(_ne(eint256.unwrap(a), eint256.unwrap(b)));
|
|
439
409
|
}
|
|
440
410
|
|
|
441
411
|
function lt(euint16 a, euint16 b) internal returns (ebool) {
|
|
442
|
-
return ebool.wrap(
|
|
412
|
+
return ebool.wrap(_lt(euint16.unwrap(a), euint16.unwrap(b)));
|
|
443
413
|
}
|
|
444
414
|
|
|
445
415
|
function lt(euint256 a, euint256 b) internal returns (ebool) {
|
|
446
|
-
return ebool.wrap(
|
|
416
|
+
return ebool.wrap(_lt(euint256.unwrap(a), euint256.unwrap(b)));
|
|
447
417
|
}
|
|
448
418
|
|
|
449
419
|
function lt(eint16 a, eint16 b) internal returns (ebool) {
|
|
450
|
-
return ebool.wrap(
|
|
420
|
+
return ebool.wrap(_lt(eint16.unwrap(a), eint16.unwrap(b)));
|
|
451
421
|
}
|
|
452
422
|
|
|
453
423
|
function lt(eint256 a, eint256 b) internal returns (ebool) {
|
|
454
|
-
return ebool.wrap(
|
|
424
|
+
return ebool.wrap(_lt(eint256.unwrap(a), eint256.unwrap(b)));
|
|
455
425
|
}
|
|
456
426
|
|
|
457
427
|
function le(euint16 a, euint16 b) internal returns (ebool) {
|
|
458
|
-
return ebool.wrap(
|
|
428
|
+
return ebool.wrap(_le(euint16.unwrap(a), euint16.unwrap(b)));
|
|
459
429
|
}
|
|
460
430
|
|
|
461
431
|
function le(euint256 a, euint256 b) internal returns (ebool) {
|
|
462
|
-
return ebool.wrap(
|
|
432
|
+
return ebool.wrap(_le(euint256.unwrap(a), euint256.unwrap(b)));
|
|
463
433
|
}
|
|
464
434
|
|
|
465
435
|
function le(eint16 a, eint16 b) internal returns (ebool) {
|
|
466
|
-
return ebool.wrap(
|
|
436
|
+
return ebool.wrap(_le(eint16.unwrap(a), eint16.unwrap(b)));
|
|
467
437
|
}
|
|
468
438
|
|
|
469
439
|
function le(eint256 a, eint256 b) internal returns (ebool) {
|
|
470
|
-
return ebool.wrap(
|
|
440
|
+
return ebool.wrap(_le(eint256.unwrap(a), eint256.unwrap(b)));
|
|
471
441
|
}
|
|
472
442
|
|
|
473
443
|
function gt(euint16 a, euint16 b) internal returns (ebool) {
|
|
474
|
-
return ebool.wrap(
|
|
444
|
+
return ebool.wrap(_gt(euint16.unwrap(a), euint16.unwrap(b)));
|
|
475
445
|
}
|
|
476
446
|
|
|
477
447
|
function gt(euint256 a, euint256 b) internal returns (ebool) {
|
|
478
|
-
return ebool.wrap(
|
|
448
|
+
return ebool.wrap(_gt(euint256.unwrap(a), euint256.unwrap(b)));
|
|
479
449
|
}
|
|
480
450
|
|
|
481
451
|
function gt(eint16 a, eint16 b) internal returns (ebool) {
|
|
482
|
-
return ebool.wrap(
|
|
452
|
+
return ebool.wrap(_gt(eint16.unwrap(a), eint16.unwrap(b)));
|
|
483
453
|
}
|
|
484
454
|
|
|
485
455
|
function gt(eint256 a, eint256 b) internal returns (ebool) {
|
|
486
|
-
return ebool.wrap(
|
|
456
|
+
return ebool.wrap(_gt(eint256.unwrap(a), eint256.unwrap(b)));
|
|
487
457
|
}
|
|
488
458
|
|
|
489
459
|
function ge(euint16 a, euint16 b) internal returns (ebool) {
|
|
490
|
-
return ebool.wrap(
|
|
460
|
+
return ebool.wrap(_ge(euint16.unwrap(a), euint16.unwrap(b)));
|
|
491
461
|
}
|
|
492
462
|
|
|
493
463
|
function ge(euint256 a, euint256 b) internal returns (ebool) {
|
|
494
|
-
return ebool.wrap(
|
|
464
|
+
return ebool.wrap(_ge(euint256.unwrap(a), euint256.unwrap(b)));
|
|
495
465
|
}
|
|
496
466
|
|
|
497
467
|
function ge(eint16 a, eint16 b) internal returns (ebool) {
|
|
498
|
-
return ebool.wrap(
|
|
468
|
+
return ebool.wrap(_ge(eint16.unwrap(a), eint16.unwrap(b)));
|
|
499
469
|
}
|
|
500
470
|
|
|
501
471
|
function ge(eint256 a, eint256 b) internal returns (ebool) {
|
|
502
|
-
return ebool.wrap(
|
|
472
|
+
return ebool.wrap(_ge(eint256.unwrap(a), eint256.unwrap(b)));
|
|
503
473
|
}
|
|
504
474
|
|
|
505
475
|
// ============ ADVANCED FUNCTIONS ============
|
|
@@ -514,7 +484,7 @@ library Nox {
|
|
|
514
484
|
euint256 balanceTo,
|
|
515
485
|
euint256 amount
|
|
516
486
|
) internal returns (ebool success, euint256 newBalanceFrom, euint256 newBalanceTo) {
|
|
517
|
-
(bytes32 _success, bytes32 _newBalanceFrom, bytes32 _newBalanceTo) =
|
|
487
|
+
(bytes32 _success, bytes32 _newBalanceFrom, bytes32 _newBalanceTo) = _transfer(
|
|
518
488
|
euint256.unwrap(balanceFrom),
|
|
519
489
|
euint256.unwrap(balanceTo),
|
|
520
490
|
euint256.unwrap(amount)
|
|
@@ -534,7 +504,7 @@ library Nox {
|
|
|
534
504
|
euint256 amount,
|
|
535
505
|
euint256 totalSupply
|
|
536
506
|
) internal returns (ebool success, euint256 newBalanceTo, euint256 newTotalSupply) {
|
|
537
|
-
(bytes32 _success, bytes32 _newBalanceTo, bytes32 _newTotalSupply) =
|
|
507
|
+
(bytes32 _success, bytes32 _newBalanceTo, bytes32 _newTotalSupply) = _mint(
|
|
538
508
|
euint256.unwrap(balanceTo),
|
|
539
509
|
euint256.unwrap(amount),
|
|
540
510
|
euint256.unwrap(totalSupply)
|
|
@@ -554,7 +524,7 @@ library Nox {
|
|
|
554
524
|
euint256 amount,
|
|
555
525
|
euint256 totalSupply
|
|
556
526
|
) internal returns (ebool success, euint256 newBalanceFrom, euint256 newTotalSupply) {
|
|
557
|
-
(bytes32 _success, bytes32 _newBalanceFrom, bytes32 _newTotalSupply) =
|
|
527
|
+
(bytes32 _success, bytes32 _newBalanceFrom, bytes32 _newTotalSupply) = _burn(
|
|
558
528
|
euint256.unwrap(balanceFrom),
|
|
559
529
|
euint256.unwrap(amount),
|
|
560
530
|
euint256.unwrap(totalSupply)
|
|
@@ -905,4 +875,122 @@ library Nox {
|
|
|
905
875
|
function isPubliclyDecryptable(eint256 handle) internal view returns (bool) {
|
|
906
876
|
return _acl().isPubliclyDecryptable(eint256.unwrap(handle));
|
|
907
877
|
}
|
|
878
|
+
|
|
879
|
+
// ============ Private helpers ============
|
|
880
|
+
|
|
881
|
+
function _assertInitialized(bytes32 handle) private pure {
|
|
882
|
+
require(handle != bytes32(0), UninitializedHandle());
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
function _add(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
886
|
+
_assertInitialized(a);
|
|
887
|
+
_assertInitialized(b);
|
|
888
|
+
return _compute().add(a, b);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
function _sub(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
892
|
+
_assertInitialized(a);
|
|
893
|
+
_assertInitialized(b);
|
|
894
|
+
return _compute().sub(a, b);
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
function _mul(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
898
|
+
_assertInitialized(a);
|
|
899
|
+
_assertInitialized(b);
|
|
900
|
+
return _compute().mul(a, b);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function _div(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
904
|
+
_assertInitialized(a);
|
|
905
|
+
_assertInitialized(b);
|
|
906
|
+
return _compute().div(a, b);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
function _safeAdd(bytes32 a, bytes32 b) private returns (bytes32, bytes32) {
|
|
910
|
+
_assertInitialized(a);
|
|
911
|
+
_assertInitialized(b);
|
|
912
|
+
return _compute().safeAdd(a, b);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
function _safeSub(bytes32 a, bytes32 b) private returns (bytes32, bytes32) {
|
|
916
|
+
_assertInitialized(a);
|
|
917
|
+
_assertInitialized(b);
|
|
918
|
+
return _compute().safeSub(a, b);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
function _select(bytes32 condition, bytes32 ifTrue, bytes32 ifFalse) private returns (bytes32) {
|
|
922
|
+
_assertInitialized(condition);
|
|
923
|
+
_assertInitialized(ifTrue);
|
|
924
|
+
_assertInitialized(ifFalse);
|
|
925
|
+
return _compute().select(condition, ifTrue, ifFalse);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function _eq(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
929
|
+
_assertInitialized(a);
|
|
930
|
+
_assertInitialized(b);
|
|
931
|
+
return _compute().eq(a, b);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
function _ne(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
935
|
+
_assertInitialized(a);
|
|
936
|
+
_assertInitialized(b);
|
|
937
|
+
return _compute().ne(a, b);
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
function _lt(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
941
|
+
_assertInitialized(a);
|
|
942
|
+
_assertInitialized(b);
|
|
943
|
+
return _compute().lt(a, b);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
function _le(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
947
|
+
_assertInitialized(a);
|
|
948
|
+
_assertInitialized(b);
|
|
949
|
+
return _compute().le(a, b);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
function _gt(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
953
|
+
_assertInitialized(a);
|
|
954
|
+
_assertInitialized(b);
|
|
955
|
+
return _compute().gt(a, b);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function _ge(bytes32 a, bytes32 b) private returns (bytes32) {
|
|
959
|
+
_assertInitialized(a);
|
|
960
|
+
_assertInitialized(b);
|
|
961
|
+
return _compute().ge(a, b);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
function _transfer(
|
|
965
|
+
bytes32 balanceFrom,
|
|
966
|
+
bytes32 balanceTo,
|
|
967
|
+
bytes32 amount
|
|
968
|
+
) private returns (bytes32, bytes32, bytes32) {
|
|
969
|
+
_assertInitialized(balanceFrom);
|
|
970
|
+
_assertInitialized(balanceTo);
|
|
971
|
+
_assertInitialized(amount);
|
|
972
|
+
return _compute().transfer(balanceFrom, balanceTo, amount);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function _mint(
|
|
976
|
+
bytes32 balanceTo,
|
|
977
|
+
bytes32 amount,
|
|
978
|
+
bytes32 totalSupply
|
|
979
|
+
) private returns (bytes32, bytes32, bytes32) {
|
|
980
|
+
_assertInitialized(balanceTo);
|
|
981
|
+
_assertInitialized(amount);
|
|
982
|
+
_assertInitialized(totalSupply);
|
|
983
|
+
return _compute().mint(balanceTo, amount, totalSupply);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
function _burn(
|
|
987
|
+
bytes32 balanceFrom,
|
|
988
|
+
bytes32 amount,
|
|
989
|
+
bytes32 totalSupply
|
|
990
|
+
) private returns (bytes32, bytes32, bytes32) {
|
|
991
|
+
_assertInitialized(balanceFrom);
|
|
992
|
+
_assertInitialized(amount);
|
|
993
|
+
_assertInitialized(totalSupply);
|
|
994
|
+
return _compute().burn(balanceFrom, amount, totalSupply);
|
|
995
|
+
}
|
|
908
996
|
}
|