-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokens.ts
86 lines (82 loc) · 2.05 KB
/
tokens.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { token } from '@roll-network/api'
import { printTable } from 'console-table-printer'
import { InteractionType } from '@roll-network/auth-sdk'
import inquirer from 'inquirer'
import config from './config.js'
import logger from './logger.js'
import { generateClientPool } from './utils.js'
export const getTokenList = async () => {
try {
const { clientPool } = await generateClientPool(config)
const answers = await inquirer.prompt([
{
type: 'input',
name: 'limit',
message: 'Limit',
default: 10,
},
{
type: 'input',
name: 'offset',
message: 'Offset',
default: 0,
},
{
type: 'input',
name: 'symbol',
message: 'Symbol',
default: '',
},
{
type: 'input',
name: 'contractAddress',
message: 'Contract address',
default: '',
},
])
const response = await token.getTokens(
clientPool.getClient(InteractionType.ClientCredentials).call,
answers,
)
if (response.rows.length === 0) {
logger.info('No tokens found')
} else {
printTable(
response.rows.map((row) => ({
id: row.uuid,
symbol: row.symbol,
contractAddress: row.contractAddress,
})),
)
}
logger.info(`Total rows: ${response.totalRows}`)
} catch (error) {
logger.fatal(JSON.stringify(error as Error))
}
}
export const getTokenCreator = async () => {
try {
const { clientPool } = await generateClientPool(config)
const answers = await inquirer.prompt([
{
type: 'input',
name: 'tokenId',
message: 'Token ID',
},
])
const creator = await token.getTokenCreator(
clientPool.getClient(InteractionType.ClientCredentials).call,
answers,
)
printTable([
{
id: creator.userID,
name: creator.name,
username: creator.username,
profilePic: creator.profilePic,
},
])
} catch (error) {
logger.fatal(JSON.stringify(error as Error))
}
}