Skip to content

Commit

Permalink
rename code word function
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Dec 2, 2024
1 parent 4f3c420 commit aecc974
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions contracts/LinearCodeAddressGenerator.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract LinearCodeAddressGenerator {
}

access(self)
fun codeWord(forChain chain: Chain): UInt64 {
fun invalidCodeWord(forChain chain: Chain): UInt64 {
switch chain {
case Chain.Mainnet:
return 0
Expand Down Expand Up @@ -92,15 +92,15 @@ contract LinearCodeAddressGenerator {
/// Returns the address at the given index, for the given chain.
access(all)
fun address(at index: UInt64, chain: Chain): Address {
return Address(self.encodeWord(index) ^ self.codeWord(forChain: chain))
return Address(self.encodeWord(index) ^ self.invalidCodeWord(forChain: chain))
}

/// Returns true if the given address is valid, for the given chain code word.
access(all)
fun isValidAddress(_ address: Address, chain: Chain): Bool {

let address = UInt64.fromBigEndianBytes(address.toBytes())!
var codeWord = self.codeWord(forChain: chain) ^ address
var codeWord = self.invalidCodeWord(forChain: chain) ^ address

if codeWord == 0 {
return false
Expand Down

0 comments on commit aecc974

Please sign in to comment.