-
Notifications
You must be signed in to change notification settings - Fork 10
Implement simpler hash function #9
Conversation
Braqzen
left a comment
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.
main.sw- Has unused imports
ContractIdINPUT_MESSAGE
MIN_GASconst can probably be moved into the manifest file. The latestforcallows us to load values from the file as a pseudo constructor. I haven't used this myself yet
- Has unused imports
utils.sw- Has unused imports
OUTPUT_CHANGEOUTPUT_CONTRACTOUTPUT_VARIABLEtx_gas_limittx_inputs_counttx_output_typetx_outputs_countsha256
- Similar comment regarding moving constants into manifest
- I would keep all the imports together and then below them declare the constants (if not put in manifest) rather than have some imports at the top and then a
core::numand constants somewhere at the bottom of the file. Keeping things neatly together, at the top, makes it easier to navigate when searching
- Has unused imports
|
If there isn't an issue in the Sway repo to warn on unused imports then please file one. |
adlerjohn
left a comment
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.
New versions of forc and fuels-rs are around the corner. Would it be better to wait a few days and do this properly with the new functions instead of hard-coding things that will have to get changed later?
| // This ensures the coins can only be spent in a call to `TokenContract.finalizeDeposit()` | ||
| // Note: The script must be right-padded to the next full word before hashing, to match with `get_script_bytecode()` | ||
| const SPENDING_SCRIPT_HASH = 0x2d235589506d17993e0b7aca4407a5ac1c325efd9d704ff94696a8f7c012ab9d; | ||
| const SPENDING_SCRIPT_HASH = 0x6856bb03b84d876ee60c890be5b0602d0f7480d375917a660da3115e8e008ddb; |
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 seems like the perfect usecase for configuration-time constants!
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.
Could be deferred to a subsequent PR.
Someone already made an issue for it: FuelLabs/sway#1298 |
Yeah, I think I'm gonna scrap this PR since I've started working with using the new GTF refactor. Merging this minor issue may not be worth the effort |
|
Closing to prioritize new sway and sdk releases |
Moved helper functions from the predicate into their own utils library and added a new helper function
tx_script_bytecode_hashto easily get an unpadded script hash.Note: there is a future issue to tweak this new function to use GTF in the future