-
Notifications
You must be signed in to change notification settings - Fork 8
Add NewAddress public function #9
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,8 @@ package core | |||||
|
|
||||||
| import ( | ||||||
| "bytes" | ||||||
| "encoding/binary" | ||||||
| "github.com/ElrondNetwork/elrond-go-core/hashing/keccak" | ||||||
| ) | ||||||
|
|
||||||
| // SystemAccountAddress is the hard-coded address in which we save global settings on all shards | ||||||
|
|
@@ -85,3 +87,46 @@ func IsSmartContractOnMetachain(identifier []byte, rcvAddress []byte) bool { | |||||
| make([]byte, numInitCharactersForOnMetachainSC)) | ||||||
| return isOnMetaChainSCAddress | ||||||
| } | ||||||
|
|
||||||
| // NewAddress creates a new smart contract address from the creators address and nonce | ||||||
| // The address is created by applied keccak256 on the appended value off creator address and nonce | ||||||
|
||||||
| // The address is created by applied keccak256 on the appended value off creator address and nonce | |
| // The address is created by applying keccak256 on the appended value of creator address and nonce |
Copilot
AI
Aug 28, 2025
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.
The comment has grammatical errors. It should read: 'Prefix mask is applied for the first 8 bytes as 0, and for bytes 9-10 as VM type'
| // Prefix mask is applied for first 8 bytes 0, and for bytes 9-10 - VM type | |
| // Prefix mask is applied for the first 8 bytes as 0, and for bytes 9-10 as VM type |
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.
Missing unit tests.
Copilot
AI
Aug 28, 2025
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.
Converting byte slice to string and back to bytes is inefficient. The keccak.Compute method likely accepts []byte directly, or you should use a method that accepts byte slices to avoid unnecessary conversion.
| scAddress := keccak.NewKeccak().Compute(string(adrAndNonce)) | |
| scAddress := keccak.NewKeccak().Compute(adrAndNonce) |
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.
There's a grammatical error in the comment. It should be 'from the creator's address' (with an apostrophe) instead of 'from the creators address'