-
Notifications
You must be signed in to change notification settings - Fork 34
/
lighthouse.ts
95 lines (78 loc) · 3.8 KB
/
lighthouse.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
import { program } from "commander"
import chalk from "chalk"
import fs from "fs"
import { DirectSecp256k1Wallet } from "@cosmjs/proto-signing"
import { command_init } from "./init"
import { command_collection } from "./collection"
import { command_utils } from "./utils"
import { command_allowlist } from "./allowlist"
import { command_ownership } from "./ownership"
import { command_metadata } from "./arweave"
const LIGHTHOUSE_CONTRACT_ATLANTIC_2 = ["sei1pl24jsr4m7hwpu9qf6uae2h9q4gwf8rrltdht9k0wn7la6qyhd7qetsn3n", "0xdcaae50550e49c63fadb7596cf74fdfee804bb7c"]
const LIGHTHOUSE_CONTRACT_PACIFIC_1 = ["sei1qdlexq6sr2grvx0f6m638xs7e4kswa0jk63cqj0j5z99g2rz7xpq9n7lu8", "0x139a1ecd6d0775f2b6a38049f2a08a542862f182"]
const LIGHTHOUSE_CONTRACT_ARCTIC_1 = ["sei1zqd3qn4ydj4nu592534hvj5g937j0aadlryd0gt8aan8z23lfwhqsv0h66", "0x764a882c7d27f7adf8c8d7a167ef66712a3f4bae"]
export const getChainConfig = async (pkMust: boolean = false) => {
const configFilePath = program.opts().config || "./chain-config.json";
var config: any;
try {
config = JSON.parse(fs.readFileSync(configFilePath).toString())
} catch (error) {
console.log(chalk.red(configFilePath+" not found. Please run 'lighthouse init chain-config' to initialize the chain config file."))
process.exit(1)
}
let pk: string = config.private_key;
if (!pk && pkMust) {
console.log(chalk.red("Private key not found in "+configFilePath))
process.exit(1)
}
let wallet: DirectSecp256k1Wallet;
if (pk) {
if (pk.startsWith("0x")) {
pk = pk.slice(2)
}
wallet = await DirectSecp256k1Wallet.fromKey(Buffer.from(pk, 'hex'), "sei");
}
let lighthouse: string[];
if (config.network === "pacific-1") {
lighthouse = LIGHTHOUSE_CONTRACT_PACIFIC_1
} else if (config.network === "atlantic-2") {
lighthouse = LIGHTHOUSE_CONTRACT_ATLANTIC_2
} else if (config.network === "arctic-1") {
lighthouse = LIGHTHOUSE_CONTRACT_ARCTIC_1
} else {
console.log(chalk.red("Invalid network. available networks: pacific-1, atlantic-2, arctic-1"))
process.exit(1)
}
return { wallet: wallet!, lighthouse: lighthouse[0], lighthouse_evm: lighthouse[1], rpc_wasm: config.rpc_wasm as string, rpc_evm: config.rpc_evm as string, privateKey: pk }
}
const main = () => {
program
.name("lighthouse")
.description(` _^_
|@|
===== __ ___________ __________ ______ __ __________
#:: / / / _/ ___/ // /_ __/ // / __ \\/ / / / __/ __/
#:: / /___/ // (_ / _ / / / / _ / /_/ / /_/ /\\ \\/ _/
#:: /____/___/\\___/_//_/ /_/ /_//_/\\____/\\____/___/___/𝐯𝟐
#::
#::
###::^-..
The tool for creating and managing NFT collections on the SEI blockchain.`)
.version("2.0.0")
.option("-cf, --config <path>", "set config path", "./chain-config.json")
const init = program.command("init").description("Initialization commands")
const initProject = init.command("project").description("Initialize a new project.")
const collection = program.command("collection").description("Collection commands")
const allowlist = program.command("allowlist").description("Allowlist commands (merkle tree)")
const metadata = program.command("metadata").description("Metadata & Arweave commands")
const utils = program.command("utils").description("Utility commands")
command_init(init, initProject)
command_collection(collection)
command_metadata(metadata)
command_allowlist(allowlist)
command_utils(utils)
const ownership = collection.command("ownership").description("Collection ownership commands")
command_ownership(ownership)
program.parse()
}
main()