Skip to content

Commit

Permalink
Extract static fn part
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Aug 3, 2023
1 parent dc1da07 commit 7dccfd4
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/components/common/EthHashInfo/AddressEmoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import { useAppSelector } from '@/store'
import { selectSettings } from '@/store/settingsSlice'
import css from './styles.module.css'

// Define the Unicode ranges for animal, fruit, and vegetable emojis
const unicodeRanges = [
[0x1f400, 0x1f43f],
[0x1f980, 0x1f994],
[0x1f345, 0x1f35f],
[0x1f950, 0x1f96b],
]

// Calculate the total number of emojis
let totalEmojis = 0
for (let range of unicodeRanges) {
totalEmojis += range[1] - range[0] + 1
}

function ethereumAddressToEmoji(address: string): string {
// Convert the Ethereum address from hexadecimal to decimal
const decimal = BigInt(address.slice(0, 6))

// Define the Unicode ranges for animal, fruit, and vegetable emojis
const unicodeRanges = [
[0x1f400, 0x1f43f],
[0x1f980, 0x1f994],
[0x1f345, 0x1f35f],
[0x1f950, 0x1f96b],
]

// Calculate the total number of emojis
let totalEmojis = 0
for (let range of unicodeRanges) {
totalEmojis += range[1] - range[0] + 1
}

// Calculate the index by taking the modulo of the decimal by the number of emojis
let index = Number(decimal % BigInt(totalEmojis))

Expand Down

0 comments on commit 7dccfd4

Please sign in to comment.