mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
prototype auto-generating data token name
This commit is contained in:
parent
9873076e4b
commit
0290f57bf4
133
src/data/words.json
Normal file
133
src/data/words.json
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
"nouns": [
|
||||||
|
"Crab",
|
||||||
|
"Fish",
|
||||||
|
"Seal",
|
||||||
|
"Octopus",
|
||||||
|
"Shark",
|
||||||
|
"Seahorse",
|
||||||
|
"Walrus",
|
||||||
|
"Starfish",
|
||||||
|
"Whale",
|
||||||
|
"Orca",
|
||||||
|
"Penguin",
|
||||||
|
"Jellyfish",
|
||||||
|
"Squid",
|
||||||
|
"Lobster",
|
||||||
|
"Pelican",
|
||||||
|
"Shrimp",
|
||||||
|
"Oyster",
|
||||||
|
"Clam",
|
||||||
|
"Seagull",
|
||||||
|
"Dolphin",
|
||||||
|
"Shell",
|
||||||
|
"Cormorant",
|
||||||
|
"Otter",
|
||||||
|
"Pelican",
|
||||||
|
"Anemone",
|
||||||
|
"Turtle",
|
||||||
|
"Coral"
|
||||||
|
],
|
||||||
|
"adjectives": [
|
||||||
|
"adamant",
|
||||||
|
"adroit",
|
||||||
|
"amatory",
|
||||||
|
"animistic",
|
||||||
|
"antic",
|
||||||
|
"arcadian",
|
||||||
|
"baleful",
|
||||||
|
"bellicose",
|
||||||
|
"bilious",
|
||||||
|
"boorish",
|
||||||
|
"calamitous",
|
||||||
|
"caustic",
|
||||||
|
"cerulean",
|
||||||
|
"comely",
|
||||||
|
"concomitant",
|
||||||
|
"contumacious",
|
||||||
|
"corpulent",
|
||||||
|
"crapulous",
|
||||||
|
"defamatory",
|
||||||
|
"didactic",
|
||||||
|
"dilatory",
|
||||||
|
"dowdy",
|
||||||
|
"efficacious",
|
||||||
|
"effulgent",
|
||||||
|
"egregious",
|
||||||
|
"endemic",
|
||||||
|
"equanimous",
|
||||||
|
"execrable",
|
||||||
|
"fastidious",
|
||||||
|
"feckless",
|
||||||
|
"fecund",
|
||||||
|
"friable",
|
||||||
|
"fulsome",
|
||||||
|
"garrulous",
|
||||||
|
"guileless",
|
||||||
|
"gustatory",
|
||||||
|
"heuristic",
|
||||||
|
"histrionic",
|
||||||
|
"hubristic",
|
||||||
|
"incendiary",
|
||||||
|
"insidious",
|
||||||
|
"insolent",
|
||||||
|
"intransigent",
|
||||||
|
"inveterate",
|
||||||
|
"invidious",
|
||||||
|
"irksome",
|
||||||
|
"jejune",
|
||||||
|
"jocular",
|
||||||
|
"judicious",
|
||||||
|
"lachrymose",
|
||||||
|
"limpid",
|
||||||
|
"loquacious",
|
||||||
|
"luminous",
|
||||||
|
"mannered",
|
||||||
|
"mendacious",
|
||||||
|
"meretricious",
|
||||||
|
"minatory",
|
||||||
|
"mordant",
|
||||||
|
"munificent",
|
||||||
|
"nefarious",
|
||||||
|
"noxious",
|
||||||
|
"obtuse",
|
||||||
|
"parsimonious",
|
||||||
|
"pendulous",
|
||||||
|
"pernicious",
|
||||||
|
"pervasive",
|
||||||
|
"petulant",
|
||||||
|
"platitudinous",
|
||||||
|
"precipitate",
|
||||||
|
"propitious",
|
||||||
|
"puckish",
|
||||||
|
"querulous",
|
||||||
|
"quiescent",
|
||||||
|
"rebarbative",
|
||||||
|
"recalcitant",
|
||||||
|
"redolent",
|
||||||
|
"rhadamanthine",
|
||||||
|
"risible",
|
||||||
|
"ruminative",
|
||||||
|
"sagacious",
|
||||||
|
"salubrious",
|
||||||
|
"sartorial",
|
||||||
|
"sclerotic",
|
||||||
|
"serpentine",
|
||||||
|
"spasmodic",
|
||||||
|
"strident",
|
||||||
|
"taciturn",
|
||||||
|
"tenacious",
|
||||||
|
"tremulous",
|
||||||
|
"trenchant",
|
||||||
|
"turbulent",
|
||||||
|
"turgid",
|
||||||
|
"ubiquitous",
|
||||||
|
"uxorious",
|
||||||
|
"verdant",
|
||||||
|
"voluble",
|
||||||
|
"voracious",
|
||||||
|
"wheedling",
|
||||||
|
"withering",
|
||||||
|
"zealous"
|
||||||
|
]
|
||||||
|
}
|
@ -4,6 +4,8 @@ import { AbiItem } from 'web3-utils/types'
|
|||||||
import defaultFactoryABI from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
import defaultFactoryABI from '@oceanprotocol/contracts/artifacts/DTFactory.json'
|
||||||
import defaultDatatokensABI from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
import defaultDatatokensABI from '@oceanprotocol/contracts/artifacts/DataTokenTemplate.json'
|
||||||
|
|
||||||
|
import wordListDefault from '../data/words.json'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a interface to DataTokens
|
* Provides a interface to DataTokens
|
||||||
*/
|
*/
|
||||||
@ -32,6 +34,32 @@ export class DataTokens {
|
|||||||
this.web3 = web3
|
this.web3 = web3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate new datatoken name & symbol from a word list
|
||||||
|
* @return {<{ name: String; symbol: String }>} datatoken name & symbol. Produces e.g. "Endemic Jellyfish Token" & "ENDJEL-145"
|
||||||
|
*/
|
||||||
|
public generateDtName(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 }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new datatoken
|
* Create new datatoken
|
||||||
* @param {String} metaDataStoreURI
|
* @param {String} metaDataStoreURI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user