1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

move over datatokens utils from ocean.js

This commit is contained in:
Matthias Kretschmann 2021-11-15 15:01:39 +00:00
parent e79dcf2342
commit a396615ed4
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 242 additions and 0 deletions

View File

@ -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 }
}

View File

@ -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"
]
}