mirror of
https://github.com/GMGNAI/gmgn-skills.git
synced 2026-08-16 01:28:06 +00:00
Add EVM chains arc and stable everywhere robinhood is supported:
- src/validate.ts: add arc + stable to VALID_CHAINS and EVM address check
- src/commands/{token,market,portfolio,swap,track}.ts: extend --chain
option help and the market-signal chain gate
- src/client/OpenApiClient.ts: HotSearchesParam chain comment
- Sync SKILL.md files, Readme.md, Readme.zh.md, docs/cli-usage.md;
update the default hot-search set wording from 6-chain to 7-chain
Cooking/create_token remains sol/bsc/base/robinhood only (no launchpad
on arc or stable), matching the openapi service.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
const VALID_CHAINS = new Set(["sol", "bsc", "base", "eth", "robinhood", "arc", "stable" /*, "monad" */]);
|
|
const SOL_ADDRESS_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
const EVM_ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
const POSITIVE_INT_RE = /^\d+$/;
|
|
|
|
export function validateChain(chain: string): void {
|
|
if (!VALID_CHAINS.has(chain)) {
|
|
console.error(
|
|
`[gmgn-cli] Invalid chain: "${chain}". Must be one of: ${[...VALID_CHAINS].join(", ")}`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
export function validateAddress(address: string, chain: string, label: string): void {
|
|
const isEvm = chain === "bsc" || chain === "base" || chain === "eth" || chain === "robinhood" || chain === "arc" || chain === "stable" /* || chain === "monad" */;
|
|
const valid = isEvm ? EVM_ADDRESS_RE.test(address) : SOL_ADDRESS_RE.test(address);
|
|
if (!valid) {
|
|
console.error(
|
|
`[gmgn-cli] Invalid ${label} address for chain "${chain}": "${address}"`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
export function validatePositiveInt(value: string, label: string): void {
|
|
if (!POSITIVE_INT_RE.test(value) || BigInt(value) <= 0n) {
|
|
console.error(
|
|
`[gmgn-cli] Invalid ${label}: "${value}". Must be a positive integer.`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
// Chains that do not support condition orders / smart_trade strategies.
|
|
const NO_CONDITION_ORDER_CHAINS = new Set(["arc", "stable"]);
|
|
|
|
export function validateConditionOrdersSupported(chain: string, feature: string): void {
|
|
if (NO_CONDITION_ORDER_CHAINS.has(chain)) {
|
|
console.error(
|
|
`[gmgn-cli] condition orders are not supported on chain "${chain}" (${feature}). Use a plain swap or limit_order instead.`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
export function validatePercent(value: number): void {
|
|
if (value <= 0 || value > 100) {
|
|
console.error(
|
|
`[gmgn-cli] Invalid --percent: ${value}. Must be between 0 (exclusive) and 100 (inclusive).`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
}
|