Skip to content

Commit

Permalink
Add support for generating random account names
Browse files Browse the repository at this point in the history
This is (potentially) useful for debugging.

By default, this feature is disabled.
  • Loading branch information
csillag committed Feb 11, 2024
1 parent a0d37ad commit 2adef43
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/hooks/useAccountName.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SearchScope } from '../../types/searchScope'
import Chance from 'chance'

const NO_MATCH = '__no_match__'

Expand All @@ -7,14 +8,20 @@ type AccountNameInfo = {
loading: boolean
}

/**
* Do we want to see some random names?
*/
const DEBUG_MODE = false

/**
* Look up the name of an account.
*/
const lookupName = (scope: SearchScope, _address: string): string | undefined => {
switch (scope.layer) {
// TODO: look up the data
default:
return undefined
// If debug mode is on, return mock names in ~50% of the cases, no nome otherwise
return DEBUG_MODE && Math.random() < 0.5 ? new Chance().name() : undefined
}
}

Expand Down

0 comments on commit 2adef43

Please sign in to comment.