-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new functions in stdlib from stdlib.fc
and math.fc
#986
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for reviewing the draft, I just wanted to keep those notes around :)
int get_original_fwd_fee(int workchain, int fwd_fee) asm(fwd_fee workchain) "GETORIGINALFWDFEE"; | ||
int my_storage_due() asm "DUEPAYMENT"; | ||
|
||
tuple get_fee_cofigs() asm "UNPACKEDCONFIGTUPLE"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tuple get_fee_cofigs() asm "UNPACKEDCONFIGTUPLE"; | |
tuple get_fee_configs() asm "UNPACKEDCONFIGTUPLE"; |
@@ -440,7 +440,7 @@ builder store_ref(builder b, cell c) asm(c b) "STREF"; | |||
;;; Stores `slice` [s] into `builder` [b] | |||
builder store_slice(builder b, slice s) asm "STSLICER"; | |||
|
|||
;;; Stores (serializes) an integer [x] in the range `0..2^120 − 1` into `builder` [b]. | |||
;;; Stores (serializes) an integer [x] in the range `0..2^128 − 1` into `builder` [b]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These things keep bubbling up :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, again, haha 😆
it's from the copy-pasting the latest stdlib from Core team projects
@@ -645,3 +645,22 @@ builder store_builder(builder to, builder from) asm "STBR"; | |||
|
|||
;;; Retrieves code of smart-contract from c7 | |||
cell my_code() asm "MYCODE"; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, it would be handy to visually separate the regular stdlib.fc
(from TON monorepo) and the additions you make specifically for Tact's use. Like, ;;; --- Tact-adjusted ---
, or something
asm fun pow2(exp: Int): Int { POW2 } | ||
|
||
asm fun sgn(x: Int): Int { SGN } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, name it sign()
for it to look less cryptic and be simpler to type
asm fun sgn(x: Int): Int { SGN } | |
asm fun sign(x: Int): Int { SGN } |
asm fun computeSliceDataSize(slice: Slice, maxCells: Int): DataSize { SDATASIZE TRIPLE } | ||
|
||
asm fun cellDepth(cell: Cell): Int { CDEPTH } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be an extension function
asm fun cellDepth(cell: Cell): Int { CDEPTH } | |
asm extends fun depth(self: Cell): Int { CDEPTH } |
|
||
asm extends fun sliceLast(self: Slice, len: Int): Slice { SDCUTLAST } | ||
|
||
asm fun sliceDepth(slice: Slice): Int { SDEPTH } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be an extension function
asm fun sliceDepth(slice: Slice): Int { SDEPTH } | |
asm extends fun depth(self: Slice): Int { SDEPTH } |
@@ -48,6 +48,8 @@ asm extends fun refs(self: Builder): Int { BREFS } | |||
|
|||
asm extends fun bits(self: Builder): Int { BBITS } | |||
|
|||
asm fun builderDepth(builder: Builder): Int { BDEPTH } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be an extension function
asm fun builderDepth(builder: Builder): Int { BDEPTH } | |
asm extends fun depth(self: Builder): Int { BDEPTH } |
} | ||
|
||
asm fun stringHash(data: Slice): Int { SHA256U } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one doesn't make much sense, since in Tact String
and Slice
are considered different types, while the Slice
already has the .hash()
method which uses the same TVM instruction. And for both that method and this function, the user would have to do explicit conversion theirString.asSlice()
, so this function stringHash()
is probably redundant and should be removed :)
Issue
Closes #770.
Checklist
docs/
and made the build locally