@gangfun/cli 0.26.0 → 0.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/README.zh-CN.md +2 -0
- package/package.json +1 -1
- package/src/flags.js +69 -0
- package/src/index.js +6 -5
package/README.md
CHANGED
|
@@ -148,7 +148,9 @@ Website, X link and description (optional): `--website mycoin.xyz --twitter @myc
|
|
|
148
148
|
handle or an x.com / twitter.com link (profile, post, community) and stores it as `https://x.com/…`; `--website` takes an
|
|
149
149
|
http(s) link (`mycoin.xyz` becomes `https://mycoin.xyz/`; no IP address or port). They go into the token's metadata JSON,
|
|
150
150
|
uploaded to gang.fun and fixed on-chain as its `contractURI()` / `metaURI()`; like `logoURI` they can't be changed after
|
|
151
|
-
the launch. The preview shows `metaURI` and the uploaded `metadata`.
|
|
151
|
+
the launch. The preview shows `metaURI` and the uploaded `metadata`. A create refuses any flag it doesn't take (`--x`,
|
|
152
|
+
`--website-url`, `--website=…`) and names the right one, before anything is uploaded or sent: a misspelled link flag is
|
|
153
|
+
never silently dropped.
|
|
152
154
|
|
|
153
155
|
`logoURI` is written on-chain and can't be changed, so the logo must stay online for good. `--logo-uri` with an image hosted
|
|
154
156
|
anywhere other than gang.fun is downloaded and copied to gang.fun first (png / jpeg / webp / gif, ≤512 KB), and the copy goes on-chain
|
package/README.zh-CN.md
CHANGED
|
@@ -138,6 +138,8 @@ gang execute --request-id …
|
|
|
138
138
|
x.com / twitter.com 链接(主页、帖子、社区),统一存成 `https://x.com/…`;`--website` 填 http(s) 链接
|
|
139
139
|
(`mycoin.xyz` 会变成 `https://mycoin.xyz/`,不能用 IP 地址或端口)。它们写进代币的 metadata JSON,上传到 gang.fun,
|
|
140
140
|
地址作为 `contractURI()` / `metaURI()` 固定在链上;和 `logoURI` 一样,发币后不能再改。preview 会显示 `metaURI` 和上传的 `metadata`。
|
|
141
|
+
发币命令遇到不认识的参数(`--x`、`--website-url`、`--website=…`)会直接报错并给出正确写法,不会上传或发送任何东西,
|
|
142
|
+
写错的链接参数不会被悄悄丢掉。
|
|
141
143
|
|
|
142
144
|
`logoURI` 写在链上,发币后改不了,所以 logo 必须长期能打开。`--logo-uri` 填的不是 gang.fun 的图片时,CLI 会先下载这张图,
|
|
143
145
|
转存到 gang.fun(png / jpeg / webp / gif,≤512 KB),上链的是转存后的 `ipfs://<cid>`(已经在 gang.fun 的文件——`ipfs://<cid>` 或 `https://cdn.gang.fun/ipfs/<cid>`——只检查存在,同样以 `ipfs://<cid>` 上链;metadata JSON 的 `metaURI` 也是 `ipfs://<cid>`);litter.catbox.moe 这类临时图床几天内就会删图。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gangfun/cli",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"mcpName": "io.github.gangfun/gang",
|
|
5
5
|
"description": "Gang launchpad CLI for Binance Agentic Wallet agents: create on GangLaunchpad (untaxed or tax tokens), 打新 fair mint, PancakeSwap pool trades, LaunchpadV2 and legacy Soft/U/S trade.",
|
|
6
6
|
"type": "module",
|
package/src/flags.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The flags a create takes (gang create, gang v3 / fair / fly create, a launch in one command). Anything else is refused
|
|
3
|
+
* before any wrap / approve round or upload: a token's links and metadata can never change after the create, and a
|
|
4
|
+
* misspelled --website (--x, --website-url, --website=…) used to be dropped without a word.
|
|
5
|
+
*/
|
|
6
|
+
import { FLY_CREATE_FLAGS } from './fly.js'
|
|
7
|
+
import { LAUNCH_FLAGS } from './launch.js'
|
|
8
|
+
|
|
9
|
+
export const LINK_FLAGS = ['website', 'twitter']
|
|
10
|
+
// gang create: V3 by default, a 打新 sale with --fair; a setting of the other kind is refused, not ignored
|
|
11
|
+
export const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient']
|
|
12
|
+
export const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee', 'shares']
|
|
13
|
+
|
|
14
|
+
export const CREATE_ACCEPTS = new Set([
|
|
15
|
+
'name', 'symbol', 'logo', 'logo-file', 'file-logo', 'logo-uri', 'keep-logo-uri', ...LINK_FLAGS, 'description',
|
|
16
|
+
'quote', 'ref-pool', 'grad', 'testnet', 'calldata', 'from', 'note', 'conf', 'reveal-after',
|
|
17
|
+
'fair', 'fly', ...V3_CREATE_FLAGS, ...FAIR_CREATE_FLAGS, ...FLY_CREATE_FLAGS,
|
|
18
|
+
// a launch in one command: its dev buy reads --slippage like gang buy, its bond --use-wbnb like gang bond post
|
|
19
|
+
...LAUNCH_FLAGS, 'slippage', 'use-wbnb',
|
|
20
|
+
// refused further on, each with its own reason
|
|
21
|
+
'follow', 'cover', 'taxed', 'pair', 'pair-or-quote', 'hours',
|
|
22
|
+
])
|
|
23
|
+
|
|
24
|
+
// what people type for the two link flags
|
|
25
|
+
const LINK_TYPOS = {
|
|
26
|
+
website: ['url', 'site', 'web', 'homepage', 'link', 'website-url', 'web-url', 'site-url', 'websiteurl', 'www'],
|
|
27
|
+
twitter: ['x', 'x-url', 'xurl', 'twitter-url', 'twitter-link', 'twitter-handle', 'tw', 'handle'],
|
|
28
|
+
}
|
|
29
|
+
const LINK_HINT = { website: '--website <URL>', twitter: '--twitter @handle (or an x.com link)' }
|
|
30
|
+
|
|
31
|
+
const distance = (a, b) => {
|
|
32
|
+
let prev = Array.from({ length: b.length + 1 }, (_, j) => j)
|
|
33
|
+
for (let i = 1; i <= a.length; i++) {
|
|
34
|
+
const row = [i]
|
|
35
|
+
for (let j = 1; j <= b.length; j++) row[j] = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1))
|
|
36
|
+
prev = row
|
|
37
|
+
}
|
|
38
|
+
return prev[b.length]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The closest flag `accepts` has to a mistyped `name` (2 edits at most, case ignored), or null. */
|
|
42
|
+
export function suggestFlag(name, accepts) {
|
|
43
|
+
const n = name.toLowerCase()
|
|
44
|
+
for (const [to, typos] of Object.entries(LINK_TYPOS)) if (typos.includes(n)) return to
|
|
45
|
+
let best = null, bestD = 3
|
|
46
|
+
for (const f of accepts) {
|
|
47
|
+
const d = distance(n, f)
|
|
48
|
+
if (d < bestD) { best = f; bestD = d }
|
|
49
|
+
}
|
|
50
|
+
return best
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The error for the first flag in argv (process.argv.slice(2)) that `accepts` lacks, or null when every flag is known.
|
|
55
|
+
* A flag is a word starting with "--" and a letter; values ("--- launch day ---") are left to the flag that reads them.
|
|
56
|
+
*/
|
|
57
|
+
export function unknownFlagError(argv, accepts, label) {
|
|
58
|
+
for (const a of argv) {
|
|
59
|
+
if (!/^--[A-Za-z]/.test(a)) continue
|
|
60
|
+
const raw = a.slice(2)
|
|
61
|
+
const [name, eq] = [raw.split('=')[0], raw.includes('=')]
|
|
62
|
+
if (accepts.has(raw)) continue
|
|
63
|
+
if (eq && accepts.has(name)) return `--${raw}: give the value after a space (--${name} ${raw.slice(name.length + 1) || '<value>'})`
|
|
64
|
+
const to = suggestFlag(name, accepts)
|
|
65
|
+
const hint = !to ? 'see gang help for its flags.' : LINK_HINT[to] ? `did you mean ${LINK_HINT[to]}?` : `did you mean --${to}?`
|
|
66
|
+
return `--${raw} is not a flag of ${label}: ${hint} Nothing was uploaded or sent: unknown flags are refused, since a token's links and metadata can never change after the create`
|
|
67
|
+
}
|
|
68
|
+
return null
|
|
69
|
+
}
|
package/src/index.js
CHANGED
|
@@ -36,6 +36,7 @@ import { portfolio } from './portfolio.js'
|
|
|
36
36
|
import { record } from './telemetry.js'
|
|
37
37
|
import { trending, trendingBlock, TRENDING_NOTE } from './trending.js'
|
|
38
38
|
import { shareFor } from './share.js'
|
|
39
|
+
import { CREATE_ACCEPTS, FAIR_CREATE_FLAGS, LINK_FLAGS, V3_CREATE_FLAGS, unknownFlagError } from './flags.js'
|
|
39
40
|
import { parseAbi } from 'viem'
|
|
40
41
|
|
|
41
42
|
const args = process.argv.slice(2)
|
|
@@ -156,7 +157,6 @@ const parseNote = () => {
|
|
|
156
157
|
try { return makeNote(raw, opt('conf'), opt('reveal-after')) } catch (e) { fail(e.message) }
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
const LINK_FLAGS = ['website', 'twitter']
|
|
160
160
|
/** --website / --twitter (create only) → canonical { website, twitter }, or null when neither is given. */
|
|
161
161
|
const parseLinks = () => {
|
|
162
162
|
for (const name of LINK_FLAGS) {
|
|
@@ -351,7 +351,8 @@ U / S pads) and run that kind's trade. Results of V3 / 打新 / 铸币飞轮 tok
|
|
|
351
351
|
--twitter / --description and the logo go into the token's metadata JSON (uploaded to
|
|
352
352
|
gang.fun; the token's contractURI / metaURI, permanent). --logo-uri images are copied
|
|
353
353
|
to gang.fun first (other hosts expire); --keep-logo-uri puts a permanent URL (e.g.
|
|
354
|
-
ipfs://) on-chain as is; gang.fun files always go on as ipfs://<cid
|
|
354
|
+
ipfs://) on-chain as is; gang.fun files always go on as ipfs://<cid>. A flag no create
|
|
355
|
+
takes (--x, --website-url, --website=…) is refused before any upload, never ignored
|
|
355
356
|
gang create --fly --name <n> --symbol <s> [--preset j|steady] [--raise 3-50] [--quota 5-100] [--invite-bonus 0-3]
|
|
356
357
|
[--max-per-tx 1-10] [--hold 60-90] [--mint-fee 1-3] [--exit-fee 1-2] [--dev-cut 0-10] [--buy-pct 0-50]
|
|
357
358
|
[--sell-tax 1-2] [--launch-delay 0-300] [--window 300-1800] [--cap-mul 1-2] [--post-mint | --no-post-mint]
|
|
@@ -1137,9 +1138,6 @@ function alias(kind, sub) {
|
|
|
1137
1138
|
return { ...io, out: (o) => out(o && typeof o === 'object' ? { ...o, useInstead: `${use} (same flags)` } : o) }
|
|
1138
1139
|
}
|
|
1139
1140
|
|
|
1140
|
-
// gang create: V3 by default, a 打新 sale with --fair; a setting of the other kind is refused, not ignored
|
|
1141
|
-
const V3_CREATE_FLAGS = ['buy-tax', 'sell-tax', 'dividend', 'recipient']
|
|
1142
|
-
const FAIR_CREATE_FLAGS = ['raise', 'cap', 'hold', 'mint-fee', 'exit-fee', 'shares']
|
|
1143
1141
|
// 铸币飞轮 settings beyond those it shares with 打新 (--raise / --hold / --mint-fee / --exit-fee) and V3 (--sell-tax)
|
|
1144
1142
|
const FLY_ONLY_FLAGS = FLY_CREATE_FLAGS.filter((f) => !['raise', 'hold', 'mint-fee', 'exit-fee', 'sell-tax'].includes(f))
|
|
1145
1143
|
const FLY_NO_BOND = '铸币飞轮 tokens take no GangBond, buy-back splitter, split module, LP splitter, combined recipient or --dev-buy (phase 1): the creator mints its shares in the create with --dev-shares <n>'
|
|
@@ -1268,6 +1266,9 @@ async function main() {
|
|
|
1268
1266
|
// `gang create` (= `gang v3 create`) / `gang fair create` write the links into the token metadata
|
|
1269
1267
|
const tokenCreate = cmd === 'create' || ((cmd === 'v3' || cmd === 'fair' || cmd === 'fly') && args[1] === 'create')
|
|
1270
1268
|
const flyCreate = (cmd === 'create' && flag('fly')) || (cmd === 'fly' && args[1] === 'create')
|
|
1269
|
+
// a flag no create reads is refused first, before any check that reads the others (flags.js)
|
|
1270
|
+
const unknown = tokenCreate && unknownFlagError(args, CREATE_ACCEPTS, cmd === 'create' ? 'gang create' : `gang ${cmd} create`)
|
|
1271
|
+
if (unknown) fail(unknown)
|
|
1271
1272
|
if (flyCreate) {
|
|
1272
1273
|
const launch = LAUNCH_FLAGS.find((f) => flag(f))
|
|
1273
1274
|
if (launch) fail(`--${launch}: ${FLY_NO_BOND}`)
|