From a396615ed454f99cbd8289e832c6e61e8f8c4156 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 15 Nov 2021 15:01:39 +0000 Subject: [PATCH] move over datatokens utils from ocean.js --- src/@utils/datatokens/index.ts | 38 ++++++ src/@utils/datatokens/words.json | 204 +++++++++++++++++++++++++++++++ 2 files changed, 242 insertions(+) create mode 100644 src/@utils/datatokens/index.ts create mode 100644 src/@utils/datatokens/words.json diff --git a/src/@utils/datatokens/index.ts b/src/@utils/datatokens/index.ts new file mode 100644 index 000000000..b4fb74590 --- /dev/null +++ b/src/@utils/datatokens/index.ts @@ -0,0 +1,38 @@ +import wordListDefault from './words.json' + +export interface DataTokenOptions { + cap?: string + name?: string + symbol?: string +} + +/** + * Generate new datatoken name & symbol from a word list + * @return {<{ name: String; symbol: String }>} datatoken name & symbol. Produces e.g. "Endemic Jellyfish Token" & "ENDJEL-45" + */ +export function generateDatatokenName(wordList?: { + nouns: string[] + adjectives: string[] +}): { + name: string + symbol: string +} { + const list = wordList || wordListDefault + const random1 = Math.floor(Math.random() * list.adjectives.length) + const random2 = Math.floor(Math.random() * list.nouns.length) + const indexNumber = Math.floor(Math.random() * 100) + + // Capitalized adjective & noun + const adjective = list.adjectives[random1].replace(/^\w/, (c) => + c.toUpperCase() + ) + const noun = list.nouns[random2].replace(/^\w/, (c) => c.toUpperCase()) + + const name = `${adjective} ${noun} Token` + // use first 3 letters of name, uppercase it, and add random number + const symbol = `${( + adjective.substring(0, 3) + noun.substring(0, 3) + ).toUpperCase()}-${indexNumber}` + + return { name, symbol } +} diff --git a/src/@utils/datatokens/words.json b/src/@utils/datatokens/words.json new file mode 100644 index 000000000..7f5dbe205 --- /dev/null +++ b/src/@utils/datatokens/words.json @@ -0,0 +1,204 @@ +{ + "nouns": [ + "Crab", + "Fish", + "Seal", + "Octopus", + "Shark", + "Seahorse", + "Walrus", + "Starfish", + "Whale", + "Orca", + "Penguin", + "Jellyfish", + "Squid", + "Lobster", + "Pelican", + "Shrimp", + "Oyster", + "Clam", + "Seagull", + "Dolphin", + "Shell", + "Cormorant", + "Otter", + "Anemone", + "Turtle", + "Coral", + "Ray", + "Barracuda", + "Krill", + "Anchovy", + "Angelfish", + "Barnacle", + "Clownfish", + "Cod", + "Cuttlefish", + "Eel", + "Fugu", + "Herring", + "Haddock", + "Ling", + "Mackerel", + "Manatee", + "Narwhal", + "Nautilus", + "Plankton", + "Porpoise", + "Prawn", + "Pufferfish", + "Swordfish", + "Tuna" + ], + "adjectives": [ + "adamant", + "adroit", + "amatory", + "ambitious", + "amused", + "animistic", + "antic", + "arcadian", + "artistic", + "astonishing", + "astounding", + "baleful", + "bellicose", + "bilious", + "blissful", + "boorish", + "brave", + "breathtaking", + "brilliant", + "calamitous", + "caustic", + "cerulean", + "clever", + "charming", + "comely", + "competent", + "concomitant", + "confident", + "contumacious", + "corpulent", + "crapulous", + "creative", + "dazzling", + "dedicated", + "defamatory", + "delighted", + "delightful", + "determined", + "didactic", + "dilatory", + "dowdy", + "efficacious", + "effulgent", + "egregious", + "empowered", + "endemic", + "enthusiastic", + "equanimous", + "exceptional", + "execrable", + "fabulous", + "fantastic", + "fastidious", + "feckless", + "fecund", + "friable", + "fulsome", + "garrulous", + "generous", + "gentle", + "guileless", + "gustatory", + "heuristic", + "histrionic", + "hubristic", + "incendiary", + "incredible", + "insidious", + "insolent", + "inspired", + "intransigent", + "inveterate", + "invidious", + "invigorated", + "irksome", + "jejune", + "juicy", + "jocular", + "joyful", + "judicious", + "kind", + "lachrymose", + "limpid", + "loquacious", + "lovely", + "luminous", + "mannered", + "marvelous", + "mendacious", + "meretricious", + "minatory", + "mordant", + "motivated", + "munificent", + "nefarious", + "noxious", + "obtuse", + "optimistic", + "parsimonious", + "pendulous", + "pernicious", + "pervasive", + "petulant", + "passionate", + "phenomenal", + "platitudinous", + "pleasant", + "powerful", + "precipitate", + "propitious", + "puckish", + "querulous", + "quiescent", + "rebarbative", + "recalcitant", + "redolent", + "rhadamanthine", + "risible", + "ruminative", + "sagacious", + "salubrious", + "sartorial", + "sclerotic", + "serpentine", + "smart", + "spasmodic", + "strident", + "stunning", + "stupendous", + "taciturn", + "tactful", + "tasty", + "tenacious", + "tremendous", + "tremulous", + "trenchant", + "turbulent", + "turgid", + "ubiquitous", + "uxorious", + "verdant", + "vibrant", + "voluble", + "voracious", + "wheedling", + "withering", + "wonderful", + "zealous" + ] +}