Skip to content

Add Uint256 variable support to DVM and SCEXISTS(), SCLOAD(), TOLOWER(), TOUPPER(), SUBFIELD() functions#71

Open
deroholic wants to merge 13 commits intoderoproject:mainfrom
deroholic:main
Open

Add Uint256 variable support to DVM and SCEXISTS(), SCLOAD(), TOLOWER(), TOUPPER(), SUBFIELD() functions#71
deroholic wants to merge 13 commits intoderoproject:mainfrom
deroholic:main

Conversation

@deroholic
Copy link

New DVM functions, please review

@ghost
Copy link

ghost commented Jun 22, 2022

neat!

@deroholic deroholic changed the title Add SCEXISTS(), SCLOAD(), TOLOWER(), TOUPPER(), SUBFIELD() functions Add Uint256 variable support to DVM and SCEXISTS(), SCLOAD(), TOLOWER(), TOUPPER(), SUBFIELD() functions Jul 20, 2022
DeroHolic added 6 commits July 22, 2022 11:21
…will give an indication of reason for failure.

Also allow SC entrypoint functions to return String so that a descriptive error is available.  An empty string indicates no error.

Ex:
100 RETURN "asset ratio invalid"

Produces:
DERO.GetGasEstimate error: [-32098] Discarded knowingly [asset ratio invalid]
LIBRARY CONTRACT (8916824bb9a392841213b152cc0f7c4809ed4df9bfec7f8071b4524a12e62b99):

Function Add(a Uint64, b Uint64) Uint64
	10 RETURN a + b
End Function

CLIENT CONTRACT:

Function Test(x, Uint64, y Uin64) Uint64
	10 IMPORT lib FROM HEXDECODE("8916824bb9a392841213b152cc0f7c4809ed4df9bfec7f8071b4524a12e62b99")
	20 DIM v1, v2 AS Uint64

	30 LET v1 = lib.Add(x, y)
	40 LET v2 = x + y

	50 IF v1 != v2 THEN GOTO 90

	// success
	60 RETURN 0

	// failure
	90 RETURN 1
End Function
@Slixe
Copy link
Contributor

Slixe commented Aug 23, 2023

Looks good to me, more tests would be great and also to limit functions call from a SC to another to "exported functions" only (those who start with a upper case), that would let private functions for Smart Contract and reduce security risks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants