-
Notifications
You must be signed in to change notification settings - Fork 34
/
init.ts
220 lines (207 loc) · 7.97 KB
/
init.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import { Command } from "commander"
import inquirer from "inquirer"
import chalk from "chalk"
import fs from "fs"
import slugify from "slugify"
export const command_init = async (root: Command, initProject: Command) => {
root
.command("chain-config")
.description("Initialize access to the SEI blockchain.")
.action(async () => {
let answers = await inquirer.prompt([
{
type: "input",
name: "private_key",
message: "What is the private key of your wallet?"
},
{
type: "input",
name: "rpc_wasm",
message: "What is the rpc address you wanna use in cosmwasm?"
},
{
type: "input",
name: "rpc_evm",
message: "What is the rpc address you wanna use in evm? (seiv2)"
},
{
type: "input",
name: "network",
message: "What is the network you wanna use? (pacific-1, atlantic-2, arctic-1)"
},
])
if (fs.existsSync("./chain-config.json")) {
//ask for overwrite
let overwrite = await inquirer.prompt([
{
type: "confirm",
name: "overwrite",
message: "chain-config.json already exists. Do you want to overwrite it?"
}
])
if (!overwrite.overwrite) return;
}
fs.writeFileSync("./chain-config.json", JSON.stringify(answers, null, 4))
})
initProject
.command("721")
.description("Initialize a new ERC/CW 721 (nft) collection.")
.argument("<name>", "The name of the collection.")
.argument("<chain>", "The chain to deploy the contract to. (wasm, evm)")
.action(async (name, chain) => {
let slug = slugify(name, { lower: true })
let config = {
chain: chain,
collection_type: "721",
name: name,
symbol: slug.toUpperCase(),
supply: "4444",
token_uri: "",
uri_suffix: "",
fixed_uri: false,
royalty_percent: "5",
royalty_wallet: "",
is_immutable: false,
start_order: "1",
frozen: false,
unfreeze_time: null,
hidden_metadata: false,
placeholder_token_uri: "",
groups: [
{
name: "public",
merkle_root: null,
max_mints_per_wallet: "0",
reserved_supply: "0",
payments: [
{
type: "native",
amount: "1000000",
destination: ""
}
],
start_time: new Date().toISOString().split(".")[0] + "Z",
end_time: null
}
]
}
//save config
if (fs.existsSync(`./${slug}.json`)) {
//ask for overwrite
let overwrite = await inquirer.prompt([
{
type: "confirm",
name: "overwrite",
message: `${slug}.json already exists. Do you want to overwrite it?`
}
])
if (!overwrite.overwrite) return;
}
fs.writeFileSync(`./${slug}.json`, JSON.stringify(config, null, 4))
console.log(chalk.green(`Config file ${slug}.json created.`))
})
initProject
.command("404")
.description("Initialize a new CW404 collection.")
.argument("<name>", "The name of the collection.")
.action(async (name) => {
let slug = slugify(name, { lower: true })
let config = {
chain: "wasm",
collection_type: "404",
name: name,
symbol: slug.toUpperCase(),
supply: "1000000000000000",
max_supply: "1000000000000000",
decimals: "6",
max_edition: "10",
tokens_per_nft: "50000000000",
token_uri: "",
uri_suffix: "",
royalty_percent: "5",
royalty_wallet: "",
is_immutable: false,
frozen: false,
unfreeze_time: null,
frozen_whitelist: [],
groups: [
{
name: "public",
merkle_root: null,
max_mints_per_wallet: "0",
reserved_supply_in_batch: "0",
batch_size: "50000000000",
payments: [
{
type: "native",
amount: "1000000",
destination: ""
}
],
start_time: new Date().toISOString().split(".")[0] + "Z",
end_time: null
}
]
}
//save config
if (fs.existsSync(`./${slug}.json`)) {
//ask for overwrite
let overwrite = await inquirer.prompt([
{
type: "confirm",
name: "overwrite",
message: `${slug}.json already exists. Do you want to overwrite it?`
}
])
if (!overwrite.overwrite) return;
}
fs.writeFileSync(`./${slug}.json`, JSON.stringify(config, null, 4))
console.log(chalk.green(`Config file ${slug}.json created.`))
})
initProject
.command("cw20")
.description("Initialize a new CW20 token contract.")
.argument("<name>", "The name of the token.")
.action(async (name) => {
let slug = slugify(name, { lower: true })
let config = {
chain: "wasm",
collection_type: "cw20",
name: name,
symbol: slug.toUpperCase(),
decimals: "6",
initial_balances: [
{
address: "",
amount: "1000000000000000"
}
],
mint: {
minter: "",
cap: "1000000000000000"
},
marketing: {
project: name,
description: "",
marketing: "",
logo: {
url: "",
}
}
}
//save config
if (fs.existsSync(`./${slug}.json`)) {
//ask for overwrite
let overwrite = await inquirer.prompt([
{
type: "confirm",
name: "overwrite",
message: `${slug}.json already exists. Do you want to overwrite it?`
}
])
if (!overwrite.overwrite) return;
}
fs.writeFileSync(`./${slug}.json`, JSON.stringify(config, null, 4))
console.log(chalk.green(`Config file ${slug}.json created.`))
})
}