pha-deploy 0.4.1 → 0.5.0

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 CHANGED
@@ -12,15 +12,16 @@ Current surface area:
12
12
  - `contract compile`
13
13
  - `contract deploy`
14
14
  - `contract upgrade`
15
+ - `contract attach`
15
16
  - `--version` prints both the `pha-deploy` version and the resolved `pha-tomb` version/path.
16
17
  - Dry-run mode is available for token and contract transactions.
17
18
 
18
19
  ## Requirements
19
20
 
20
21
  - Node.js `>=16`
21
- - `pha-tomb >= 2.0.0` must be installed in `PATH` for `contract compile`
22
+ - `pha-tomb >= 2.1.0` must be available for `contract compile`, either in `PATH` or through `--compiler` / `PHA_TOMB_PATH`
22
23
 
23
- `contract deploy` and `contract upgrade` do not invoke the compiler directly. They work from a compiled artifact bundle or explicit `--script` / `--abi` inputs.
24
+ `contract deploy`, `contract upgrade`, and `contract attach` do not invoke the compiler directly. They work from a compiled artifact bundle or explicit `--script` / `--abi` inputs.
24
25
 
25
26
  ## Installation
26
27
 
@@ -40,15 +41,15 @@ node dist/cli.js --help
40
41
  Example version output:
41
42
 
42
43
  ```text
43
- pha-deploy 0.3.0
44
- pha-tomb version 2.0.0
44
+ pha-deploy 0.5.0
45
+ pha-tomb version 2.1.0
45
46
  pha-tomb path /usr/local/bin/pha-tomb
46
47
  ```
47
48
 
48
49
  ## Usage
49
50
 
50
51
  ```bash
51
- pha-deploy contract <compile|deploy|upgrade> [options]
52
+ pha-deploy contract <compile|deploy|upgrade|attach> [options]
52
53
  pha-deploy --create-token [options]
53
54
  pha-deploy --create-series [options]
54
55
  pha-deploy --mint-fungible [options]
@@ -120,11 +121,12 @@ Required token inputs by action:
120
121
 
121
122
  ### 1. Compile
122
123
 
123
- Compile a `.tomb` source file through the system-installed `pha-tomb`.
124
+ Compile a `.tomb` source file through `pha-tomb` from `PATH`, or pin an exact local compiler with `--compiler` / `PHA_TOMB_PATH`.
124
125
 
125
126
  ```bash
126
127
  pha-deploy contract compile \
127
128
  --source ./contracts/demo.tomb \
129
+ --compiler /path/to/pha-tomb \
128
130
  --out ./dist/contracts/demo \
129
131
  --debug \
130
132
  --protocol 16 \
@@ -134,6 +136,7 @@ pha-deploy contract compile \
134
136
  Supported compile flags:
135
137
 
136
138
  - `--source <path>`: required `.tomb` source file
139
+ - `--compiler <path>`: optional explicit `pha-tomb` executable path; takes precedence over `PHA_TOMB_PATH` and `PATH`
137
140
  - `--out <dir>`: final artifact bundle directory
138
141
  - `--contract-name <name>`: required when the compiler emits multiple modules and you need to pick one
139
142
  - `--protocol <number>`: passed through to `pha-tomb`
@@ -141,6 +144,8 @@ Supported compile flags:
141
144
  - `--nativecheck <off|warn|error>`
142
145
  - `--libpath <path>`: repeatable additional library search path
143
146
 
147
+ `PHA_TOMB_PATH=/path/to/pha-tomb` is also supported when `--compiler` is omitted and you want to avoid whichever `pha-tomb` happens to be first in `PATH`.
148
+
144
149
  Compile output:
145
150
 
146
151
  - prints the exact compiler command and cwd
@@ -155,7 +160,7 @@ Compile output:
155
160
  - optional `<contract>.pvm.hex`
156
161
  - optional `<contract>.abi.hex`
157
162
 
158
- `manifest.json` is the preferred handoff format for later deploy/upgrade commands.
163
+ `manifest.json` is the preferred handoff format for later deploy/upgrade/attach commands.
159
164
 
160
165
  ### 2. Deploy
161
166
 
@@ -199,7 +204,24 @@ pha-deploy contract upgrade \
199
204
  --dry-run
200
205
  ```
201
206
 
202
- Shared deploy/upgrade flags:
207
+ ### 4. Attach
208
+
209
+ Attach a compiled VM contract bundle to an already existing token symbol:
210
+
211
+ ```bash
212
+ pha-deploy contract attach \
213
+ --rpc https://testnet.phantasma.info/rpc \
214
+ --nexus testnet \
215
+ --chain main \
216
+ --wif <WIF> \
217
+ --manifest ./dist/contracts/demo/manifest.json \
218
+ --symbol DEMO \
219
+ --dry-run
220
+ ```
221
+
222
+ When `--symbol` is omitted, `contract attach` defaults to the bundle contract name from the manifest or direct artifact inputs.
223
+
224
+ Shared deploy/upgrade/attach flags:
203
225
 
204
226
  - `--rpc <url>`: required
205
227
  - `--nexus <name>`: required
@@ -216,6 +238,10 @@ Shared deploy/upgrade flags:
216
238
  - `--payload-hex <hex>`
217
239
  - `--dry-run`
218
240
 
241
+ Attach-only flag:
242
+
243
+ - `--symbol <symbol>`: existing token symbol to attach to; defaults to the bundle contract name when omitted
244
+
219
245
  Deploy/upgrade output always includes:
220
246
 
221
247
  - operation
@@ -226,6 +252,8 @@ Deploy/upgrade output always includes:
226
252
  - generated VM script hex
227
253
  - signed transaction hex
228
254
 
255
+ Attach output also prints the resolved token symbol used for the interop call.
256
+
229
257
  When `--dry-run` is omitted, the CLI also broadcasts the transaction, waits for the tx result, and prints the tx hash.
230
258
 
231
259
  ## Quick Examples
@@ -1 +1 @@
1
- {"version":3,"file":"cli-contract.d.ts","sourceRoot":"","sources":["../src/cli-contract.ts"],"names":[],"mappings":"AA6LA,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoIrE"}
1
+ {"version":3,"file":"cli-contract.d.ts","sourceRoot":"","sources":["../src/cli-contract.ts"],"names":[],"mappings":"AAuMA,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoLrE"}
@@ -41,7 +41,7 @@ function parseOptionalInteger(value, flagName) {
41
41
  return parsed;
42
42
  }
43
43
  async function handleContractCompile(argv) {
44
- const compiler = await (0, compiler_1.resolveSupportedCompiler)(compiler_1.MIN_SUPPORTED_PHA_TOMB_VERSION);
44
+ const compiler = await (0, compiler_1.resolveSupportedCompiler)(compiler_1.MIN_SUPPORTED_PHA_TOMB_VERSION, process.env.PATH ?? "", argv.compiler ?? process.env.PHA_TOMB_PATH);
45
45
  const sourcePath = node_path_1.default.resolve(argv.source);
46
46
  const preferredContractName = argv.contractName?.trim() || node_path_1.default.basename(sourcePath, node_path_1.default.extname(sourcePath));
47
47
  const outputDir = node_path_1.default.resolve(argv.out ?? node_path_1.default.join(process.cwd(), "dist", "contracts", preferredContractName));
@@ -112,10 +112,14 @@ async function handleContractBroadcast(operation, argv) {
112
112
  proofOfWork: parseOptionalInteger(argv.pow, "--pow"),
113
113
  payloadHex: argv.payloadHex,
114
114
  dryRun: argv.dryRun,
115
+ attachSymbol: argv.symbol,
115
116
  });
116
117
  console.log("Transaction:");
117
118
  console.log(` operation: ${result.prepared.operation}`);
118
119
  console.log(` contract: ${result.prepared.contractName}`);
120
+ if (result.prepared.attachSymbol) {
121
+ console.log(` symbol: ${result.prepared.attachSymbol}`);
122
+ }
119
123
  console.log(` from: ${result.prepared.fromAddress}`);
120
124
  console.log(` script bytes: ${result.prepared.scriptBytes}`);
121
125
  console.log(` abi bytes: ${result.prepared.abiBytes}`);
@@ -136,11 +140,15 @@ async function handleContractBroadcast(operation, argv) {
136
140
  async function runContractCli(rawArgv) {
137
141
  const parser = (0, yargs_1.default)(rawArgv)
138
142
  .scriptName("pha-deploy contract")
139
- .command("compile", "Compile a contract through the system-installed pha-tomb", (cmd) => cmd
143
+ .command("compile", "Compile a contract through pha-tomb from PATH or an explicit override", (cmd) => cmd
140
144
  .option("source", {
141
145
  type: "string",
142
146
  demandOption: true,
143
147
  describe: "Path to the .tomb source file",
148
+ })
149
+ .option("compiler", {
150
+ type: "string",
151
+ describe: "Explicit pha-tomb executable path (overrides PHA_TOMB_PATH and PATH)",
144
152
  })
145
153
  .option("out", {
146
154
  type: "string",
@@ -172,6 +180,7 @@ async function runContractCli(rawArgv) {
172
180
  source: argv.source,
173
181
  out: argv.out,
174
182
  contractName: argv["contract-name"],
183
+ compiler: argv.compiler,
175
184
  protocol: argv.protocol,
176
185
  debug: argv.debug,
177
186
  nativeCheck: argv.nativecheck,
@@ -241,6 +250,43 @@ async function runContractCli(rawArgv) {
241
250
  payloadHex: argv["payload-hex"],
242
251
  dryRun: argv["dry-run"],
243
252
  });
253
+ })
254
+ .command("attach", "Attach a compiled contract bundle to an existing token symbol", (cmd) => cmd
255
+ .option("rpc", { type: "string", demandOption: true, describe: "RPC endpoint" })
256
+ .option("nexus", { type: "string", demandOption: true, describe: "Nexus name" })
257
+ .option("chain", { type: "string", default: "main", describe: "Target chain" })
258
+ .option("wif", { type: "string", demandOption: true, describe: "WIF used to sign the transaction" })
259
+ .option("symbol", {
260
+ type: "string",
261
+ describe: "Existing token symbol to attach to (defaults to the bundle contract name)",
262
+ })
263
+ .option("manifest", { type: "string", describe: "Path to manifest.json produced by contract compile" })
264
+ .option("contract-name", { type: "string", describe: "Contract name when using direct --script/--abi inputs" })
265
+ .option("script", { type: "string", describe: "Path to compiled .pvm file when not using --manifest" })
266
+ .option("abi", { type: "string", describe: "Path to compiled .abi file when not using --manifest" })
267
+ .option("debug", { type: "string", describe: "Optional path to .debug file when not using --manifest" })
268
+ .option("gas-price", { type: "number", describe: "Gas price passed to AllowGas" })
269
+ .option("gas-limit", { type: "number", describe: "Gas limit passed to AllowGas" })
270
+ .option("pow", { type: "number", describe: "Proof-of-work difficulty for the legacy VM transaction" })
271
+ .option("payload-hex", { type: "string", describe: "Optional transaction payload as raw hex" })
272
+ .option("dry-run", { type: "boolean", describe: "Build and sign the transaction without broadcasting" }), async (argv) => {
273
+ await handleContractBroadcast("attach", {
274
+ rpc: argv.rpc,
275
+ nexus: argv.nexus,
276
+ chain: argv.chain,
277
+ wif: argv.wif,
278
+ symbol: argv.symbol,
279
+ manifest: argv.manifest,
280
+ contractName: argv["contract-name"],
281
+ script: argv.script,
282
+ abi: argv.abi,
283
+ debug: argv.debug,
284
+ gasPrice: argv["gas-price"],
285
+ gasLimit: argv["gas-limit"],
286
+ pow: argv.pow,
287
+ payloadHex: argv["payload-hex"],
288
+ dryRun: argv["dry-run"],
289
+ });
244
290
  })
245
291
  .demandCommand(1)
246
292
  .strict()
@@ -1 +1 @@
1
- {"version":3,"file":"cli-contract.js","sourceRoot":"","sources":["../src/cli-contract.ts"],"names":[],"mappings":";;;;;AA6LA,wCAoIC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;SACrG,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,yCAAyC,EAAE,CAAC;SAC9F,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,qDAAqD,EAAE,CAAC,EAC5G,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,uBAAuB,CAAC,SAAS,EAAE;YACvC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC;YACnC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;YAC3B,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;YAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;YAC/B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;IACL,CAAC,CACF;SACA,aAAa,CAAC,CAAC,CAAC;SAChB,MAAM,EAAE;SACR,IAAI,EAAE,CAAC;IAEV,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport yargs from \"yargs/yargs\";\nimport {\n CONTRACT_COMPILER_NAME,\n MIN_SUPPORTED_PHA_TOMB_VERSION,\n buildCompileArgs,\n resolveSupportedCompiler,\n runCompiler,\n selectCompiledContractArtifacts,\n type CompileProcessResult,\n type NativeCheckMode,\n} from \"./contract/compiler\";\nimport {\n loadContractArtifactsFromManifest,\n loadContractArtifactsFromPaths,\n materializeCompiledArtifacts,\n} from \"./contract/artifacts\";\nimport { executeContractTransaction, type ContractOperation } from \"./contract/deploy\";\n\nfunction printIndentedBlock(title: string, content: string): void {\n console.log(`${title}:`);\n const trimmed = content.trimEnd();\n if (!trimmed) {\n console.log(\" (empty)\");\n return;\n }\n\n for (const line of trimmed.split(/\\r?\\n/)) {\n console.log(` ${line}`);\n }\n}\n\nfunction printCompileTranscript(result: CompileProcessResult): void {\n console.log(\"Compiler command:\");\n console.log(` ${result.command} ${result.args.join(\" \")}`);\n console.log(`Compiler cwd:`);\n console.log(` ${result.cwd}`);\n printIndentedBlock(`${CONTRACT_COMPILER_NAME} stdout`, result.stdout);\n printIndentedBlock(`${CONTRACT_COMPILER_NAME} stderr`, result.stderr);\n}\n\nfunction parseOptionalInteger(value: unknown, flagName: string): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n const parsed = Number(value);\n if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n throw new Error(`${flagName} must be a positive integer`);\n }\n return parsed;\n}\n\nasync function handleContractCompile(argv: {\n source: string;\n out?: string;\n contractName?: string;\n protocol?: number;\n debug?: boolean;\n nativeCheck?: NativeCheckMode;\n libpath?: string[];\n}): Promise<void> {\n const compiler = await resolveSupportedCompiler(MIN_SUPPORTED_PHA_TOMB_VERSION);\n const sourcePath = path.resolve(argv.source);\n const preferredContractName = argv.contractName?.trim() || path.basename(sourcePath, path.extname(sourcePath));\n const outputDir = path.resolve(\n argv.out ?? path.join(process.cwd(), \"dist\", \"contracts\", preferredContractName),\n );\n const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), \"pha-deploy-compile-\"));\n\n try {\n const compileArgs = buildCompileArgs({\n sourcePath,\n outputRoot: tempRoot,\n libPaths: argv.libpath,\n protocol: argv.protocol,\n debug: argv.debug,\n nativeCheck: argv.nativeCheck,\n });\n const result = await runCompiler(compiler.executablePath, compileArgs, process.cwd());\n printCompileTranscript(result);\n\n if (result.exitCode !== 0) {\n throw new Error(`${CONTRACT_COMPILER_NAME} exited with code ${result.exitCode}`);\n }\n\n const compiled = selectCompiledContractArtifacts(\n path.join(tempRoot, \"Output\"),\n preferredContractName,\n );\n const materialized = materializeCompiledArtifacts({\n compiled,\n outputDir,\n compilerName: compiler.executableName,\n compilerVersion: compiler.version,\n sourceFileName: sourcePath,\n });\n\n console.log(\"Artifacts:\");\n console.log(` contract: ${materialized.bundle.contractName}`);\n console.log(` output: ${materialized.outputDir}`);\n console.log(` manifest: ${materialized.manifestPath}`);\n console.log(` script: ${materialized.scriptPath}`);\n console.log(` abi: ${materialized.abiPath}`);\n if (materialized.debugPath) {\n console.log(` debug: ${materialized.debugPath}`);\n }\n if (materialized.asmPath) {\n console.log(` asm: ${materialized.asmPath}`);\n }\n if (materialized.scriptHexPath) {\n console.log(` script hex: ${materialized.scriptHexPath}`);\n }\n if (materialized.abiHexPath) {\n console.log(` abi hex: ${materialized.abiHexPath}`);\n }\n } finally {\n await fs.rm(tempRoot, { recursive: true, force: true });\n }\n}\n\nasync function handleContractBroadcast(\n operation: ContractOperation,\n argv: {\n rpc: string;\n nexus: string;\n chain?: string;\n wif: string;\n manifest?: string;\n contractName?: string;\n script?: string;\n abi?: string;\n debug?: string;\n gasPrice?: unknown;\n gasLimit?: unknown;\n pow?: unknown;\n payloadHex?: string;\n dryRun?: boolean;\n },\n): Promise<void> {\n const artifacts = argv.manifest\n ? loadContractArtifactsFromManifest(argv.manifest)\n : loadContractArtifactsFromPaths({\n contractName: argv.contractName ?? \"\",\n scriptPath: argv.script ?? \"\",\n abiPath: argv.abi ?? \"\",\n ...(argv.debug ? { debugPath: argv.debug } : {}),\n });\n\n const result = await executeContractTransaction({\n operation,\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n bundle: artifacts.bundle,\n gasPrice: parseOptionalInteger(argv.gasPrice, \"--gas-price\"),\n gasLimit: parseOptionalInteger(argv.gasLimit, \"--gas-limit\"),\n proofOfWork: parseOptionalInteger(argv.pow, \"--pow\"),\n payloadHex: argv.payloadHex,\n dryRun: argv.dryRun,\n });\n\n console.log(\"Transaction:\");\n console.log(` operation: ${result.prepared.operation}`);\n console.log(` contract: ${result.prepared.contractName}`);\n console.log(` from: ${result.prepared.fromAddress}`);\n console.log(` script bytes: ${result.prepared.scriptBytes}`);\n console.log(` abi bytes: ${result.prepared.abiBytes}`);\n console.log(` vm script: ${result.prepared.scriptHex}`);\n console.log(` signed tx: ${result.prepared.txHex}`);\n\n if (result.dryRun) {\n console.log(\"Dry-run complete: transaction was not broadcast.\");\n return;\n }\n\n console.log(` tx hash: ${result.txHash ?? \"\"}`);\n if (result.broadcastError) {\n throw new Error(result.broadcastError);\n }\n if (!result.success) {\n throw new Error(\n `${operation} transaction failed${result.txHash ? ` (txHash: ${result.txHash})` : \"\"}`,\n );\n }\n}\n\nexport async function runContractCli(rawArgv: string[]): Promise<void> {\n const parser = yargs(rawArgv)\n .scriptName(\"pha-deploy contract\")\n .command(\n \"compile\",\n \"Compile a contract through the system-installed pha-tomb\",\n (cmd) =>\n cmd\n .option(\"source\", {\n type: \"string\",\n demandOption: true,\n describe: \"Path to the .tomb source file\",\n })\n .option(\"out\", {\n type: \"string\",\n describe: \"Output directory for the final artifact bundle\",\n })\n .option(\"contract-name\", {\n type: \"string\",\n describe: \"Expected contract artifact name when the compiler emits multiple modules\",\n })\n .option(\"protocol\", {\n type: \"number\",\n describe: \"Target protocol version passed to pha-tomb\",\n })\n .option(\"debug\", {\n type: \"boolean\",\n describe: \"Request debug artifacts from pha-tomb\",\n })\n .option(\"nativecheck\", {\n type: \"string\",\n choices: [\"off\", \"warn\", \"error\"],\n describe: \"Native/foundational interop diagnostics mode\",\n })\n .option(\"libpath\", {\n type: \"string\",\n array: true,\n describe: \"Additional library search path(s) passed to pha-tomb\",\n }),\n async (argv) => {\n await handleContractCompile({\n source: argv.source,\n out: argv.out,\n contractName: argv[\"contract-name\"],\n protocol: argv.protocol,\n debug: argv.debug,\n nativeCheck: argv.nativecheck as NativeCheckMode | undefined,\n libpath: argv.libpath,\n });\n },\n )\n .command(\n \"deploy\",\n \"Deploy a compiled contract artifact bundle\",\n (cmd) =>\n cmd\n .option(\"rpc\", { type: \"string\", demandOption: true, describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", demandOption: true, describe: \"Nexus name\" })\n .option(\"chain\", { type: \"string\", default: \"main\", describe: \"Target chain\" })\n .option(\"wif\", { type: \"string\", demandOption: true, describe: \"WIF used to sign the transaction\" })\n .option(\"manifest\", { type: \"string\", describe: \"Path to manifest.json produced by contract compile\" })\n .option(\"contract-name\", { type: \"string\", describe: \"Contract name when using direct --script/--abi inputs\" })\n .option(\"script\", { type: \"string\", describe: \"Path to compiled .pvm file when not using --manifest\" })\n .option(\"abi\", { type: \"string\", describe: \"Path to compiled .abi file when not using --manifest\" })\n .option(\"debug\", { type: \"string\", describe: \"Optional path to .debug file when not using --manifest\" })\n .option(\"gas-price\", { type: \"number\", describe: \"Gas price passed to AllowGas\" })\n .option(\"gas-limit\", { type: \"number\", describe: \"Gas limit passed to AllowGas\" })\n .option(\"pow\", { type: \"number\", describe: \"Proof-of-work difficulty for the legacy VM transaction\" })\n .option(\"payload-hex\", { type: \"string\", describe: \"Optional transaction payload as raw hex\" })\n .option(\"dry-run\", { type: \"boolean\", describe: \"Build and sign the transaction without broadcasting\" }),\n async (argv) => {\n await handleContractBroadcast(\"deploy\", {\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n manifest: argv.manifest,\n contractName: argv[\"contract-name\"],\n script: argv.script,\n abi: argv.abi,\n debug: argv.debug,\n gasPrice: argv[\"gas-price\"],\n gasLimit: argv[\"gas-limit\"],\n pow: argv.pow,\n payloadHex: argv[\"payload-hex\"],\n dryRun: argv[\"dry-run\"],\n });\n },\n )\n .command(\n \"upgrade\",\n \"Upgrade an already deployed contract artifact bundle\",\n (cmd) =>\n cmd\n .option(\"rpc\", { type: \"string\", demandOption: true, describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", demandOption: true, describe: \"Nexus name\" })\n .option(\"chain\", { type: \"string\", default: \"main\", describe: \"Target chain\" })\n .option(\"wif\", { type: \"string\", demandOption: true, describe: \"WIF used to sign the transaction\" })\n .option(\"manifest\", { type: \"string\", describe: \"Path to manifest.json produced by contract compile\" })\n .option(\"contract-name\", { type: \"string\", describe: \"Contract name when using direct --script/--abi inputs\" })\n .option(\"script\", { type: \"string\", describe: \"Path to compiled .pvm file when not using --manifest\" })\n .option(\"abi\", { type: \"string\", describe: \"Path to compiled .abi file when not using --manifest\" })\n .option(\"debug\", { type: \"string\", describe: \"Optional path to .debug file when not using --manifest\" })\n .option(\"gas-price\", { type: \"number\", describe: \"Gas price passed to AllowGas\" })\n .option(\"gas-limit\", { type: \"number\", describe: \"Gas limit passed to AllowGas\" })\n .option(\"pow\", { type: \"number\", describe: \"Proof-of-work difficulty for the legacy VM transaction\" })\n .option(\"payload-hex\", { type: \"string\", describe: \"Optional transaction payload as raw hex\" })\n .option(\"dry-run\", { type: \"boolean\", describe: \"Build and sign the transaction without broadcasting\" }),\n async (argv) => {\n await handleContractBroadcast(\"upgrade\", {\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n manifest: argv.manifest,\n contractName: argv[\"contract-name\"],\n script: argv.script,\n abi: argv.abi,\n debug: argv.debug,\n gasPrice: argv[\"gas-price\"],\n gasLimit: argv[\"gas-limit\"],\n pow: argv.pow,\n payloadHex: argv[\"payload-hex\"],\n dryRun: argv[\"dry-run\"],\n });\n },\n )\n .demandCommand(1)\n .strict()\n .help();\n\n await parser.parseAsync();\n}\n"]}
1
+ {"version":3,"file":"cli-contract.js","sourceRoot":"","sources":["../src/cli-contract.ts"],"names":[],"mappings":";;;;;AAuMA,wCAoLC;AA3XD,gEAAkC;AAClC,sDAAyB;AACzB,0DAA6B;AAC7B,wDAAgC;AAChC,kDAS6B;AAC7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AE,QAAQ,EAAE,8BAA8B,EAAE,CAAC;SACjF,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,wDAAwD,EAAE,CAAC;SACrG,MAAM,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,yCAAyC,EAAE,CAAC;SAC9F,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,qDAAqD,EAAE,CAAC,EAC5G,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,uBAAuB,CAAC,QAAQ,EAAE;YACtC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC;YACnC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;YAC3B,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC;YAC3B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;YAC/B,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;IACL,CAAC,CACF;SACA,aAAa,CAAC,CAAC,CAAC;SAChB,MAAM,EAAE;SACR,IAAI,EAAE,CAAC;IAEV,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport yargs from \"yargs/yargs\";\nimport {\n CONTRACT_COMPILER_NAME,\n MIN_SUPPORTED_PHA_TOMB_VERSION,\n buildCompileArgs,\n resolveSupportedCompiler,\n runCompiler,\n selectCompiledContractArtifacts,\n type CompileProcessResult,\n type NativeCheckMode,\n} from \"./contract/compiler\";\nimport {\n loadContractArtifactsFromManifest,\n loadContractArtifactsFromPaths,\n materializeCompiledArtifacts,\n} from \"./contract/artifacts\";\nimport { executeContractTransaction, type ContractOperation } from \"./contract/deploy\";\n\nfunction printIndentedBlock(title: string, content: string): void {\n console.log(`${title}:`);\n const trimmed = content.trimEnd();\n if (!trimmed) {\n console.log(\" (empty)\");\n return;\n }\n\n for (const line of trimmed.split(/\\r?\\n/)) {\n console.log(` ${line}`);\n }\n}\n\nfunction printCompileTranscript(result: CompileProcessResult): void {\n console.log(\"Compiler command:\");\n console.log(` ${result.command} ${result.args.join(\" \")}`);\n console.log(`Compiler cwd:`);\n console.log(` ${result.cwd}`);\n printIndentedBlock(`${CONTRACT_COMPILER_NAME} stdout`, result.stdout);\n printIndentedBlock(`${CONTRACT_COMPILER_NAME} stderr`, result.stderr);\n}\n\nfunction parseOptionalInteger(value: unknown, flagName: string): number | undefined {\n if (value === undefined) {\n return undefined;\n }\n const parsed = Number(value);\n if (!Number.isSafeInteger(parsed) || parsed <= 0) {\n throw new Error(`${flagName} must be a positive integer`);\n }\n return parsed;\n}\n\nasync function handleContractCompile(argv: {\n source: string;\n out?: string;\n contractName?: string;\n compiler?: string;\n protocol?: number;\n debug?: boolean;\n nativeCheck?: NativeCheckMode;\n libpath?: string[];\n}): Promise<void> {\n const compiler = await resolveSupportedCompiler(\n MIN_SUPPORTED_PHA_TOMB_VERSION,\n process.env.PATH ?? \"\",\n argv.compiler ?? process.env.PHA_TOMB_PATH,\n );\n const sourcePath = path.resolve(argv.source);\n const preferredContractName = argv.contractName?.trim() || path.basename(sourcePath, path.extname(sourcePath));\n const outputDir = path.resolve(\n argv.out ?? path.join(process.cwd(), \"dist\", \"contracts\", preferredContractName),\n );\n const tempRoot = await fs.mkdtemp(path.join(os.tmpdir(), \"pha-deploy-compile-\"));\n\n try {\n const compileArgs = buildCompileArgs({\n sourcePath,\n outputRoot: tempRoot,\n libPaths: argv.libpath,\n protocol: argv.protocol,\n debug: argv.debug,\n nativeCheck: argv.nativeCheck,\n });\n const result = await runCompiler(compiler.executablePath, compileArgs, process.cwd());\n printCompileTranscript(result);\n\n if (result.exitCode !== 0) {\n throw new Error(`${CONTRACT_COMPILER_NAME} exited with code ${result.exitCode}`);\n }\n\n const compiled = selectCompiledContractArtifacts(\n path.join(tempRoot, \"Output\"),\n preferredContractName,\n );\n const materialized = materializeCompiledArtifacts({\n compiled,\n outputDir,\n compilerName: compiler.executableName,\n compilerVersion: compiler.version,\n sourceFileName: sourcePath,\n });\n\n console.log(\"Artifacts:\");\n console.log(` contract: ${materialized.bundle.contractName}`);\n console.log(` output: ${materialized.outputDir}`);\n console.log(` manifest: ${materialized.manifestPath}`);\n console.log(` script: ${materialized.scriptPath}`);\n console.log(` abi: ${materialized.abiPath}`);\n if (materialized.debugPath) {\n console.log(` debug: ${materialized.debugPath}`);\n }\n if (materialized.asmPath) {\n console.log(` asm: ${materialized.asmPath}`);\n }\n if (materialized.scriptHexPath) {\n console.log(` script hex: ${materialized.scriptHexPath}`);\n }\n if (materialized.abiHexPath) {\n console.log(` abi hex: ${materialized.abiHexPath}`);\n }\n } finally {\n await fs.rm(tempRoot, { recursive: true, force: true });\n }\n}\n\nasync function handleContractBroadcast(\n operation: ContractOperation,\n argv: {\n rpc: string;\n nexus: string;\n chain?: string;\n wif: string;\n symbol?: string;\n manifest?: string;\n contractName?: string;\n script?: string;\n abi?: string;\n debug?: string;\n gasPrice?: unknown;\n gasLimit?: unknown;\n pow?: unknown;\n payloadHex?: string;\n dryRun?: boolean;\n },\n): Promise<void> {\n const artifacts = argv.manifest\n ? loadContractArtifactsFromManifest(argv.manifest)\n : loadContractArtifactsFromPaths({\n contractName: argv.contractName ?? \"\",\n scriptPath: argv.script ?? \"\",\n abiPath: argv.abi ?? \"\",\n ...(argv.debug ? { debugPath: argv.debug } : {}),\n });\n\n const result = await executeContractTransaction({\n operation,\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n bundle: artifacts.bundle,\n gasPrice: parseOptionalInteger(argv.gasPrice, \"--gas-price\"),\n gasLimit: parseOptionalInteger(argv.gasLimit, \"--gas-limit\"),\n proofOfWork: parseOptionalInteger(argv.pow, \"--pow\"),\n payloadHex: argv.payloadHex,\n dryRun: argv.dryRun,\n attachSymbol: argv.symbol,\n });\n\n console.log(\"Transaction:\");\n console.log(` operation: ${result.prepared.operation}`);\n console.log(` contract: ${result.prepared.contractName}`);\n if (result.prepared.attachSymbol) {\n console.log(` symbol: ${result.prepared.attachSymbol}`);\n }\n console.log(` from: ${result.prepared.fromAddress}`);\n console.log(` script bytes: ${result.prepared.scriptBytes}`);\n console.log(` abi bytes: ${result.prepared.abiBytes}`);\n console.log(` vm script: ${result.prepared.scriptHex}`);\n console.log(` signed tx: ${result.prepared.txHex}`);\n\n if (result.dryRun) {\n console.log(\"Dry-run complete: transaction was not broadcast.\");\n return;\n }\n\n console.log(` tx hash: ${result.txHash ?? \"\"}`);\n if (result.broadcastError) {\n throw new Error(result.broadcastError);\n }\n if (!result.success) {\n throw new Error(\n `${operation} transaction failed${result.txHash ? ` (txHash: ${result.txHash})` : \"\"}`,\n );\n }\n}\n\nexport async function runContractCli(rawArgv: string[]): Promise<void> {\n const parser = yargs(rawArgv)\n .scriptName(\"pha-deploy contract\")\n .command(\n \"compile\",\n \"Compile a contract through pha-tomb from PATH or an explicit override\",\n (cmd) =>\n cmd\n .option(\"source\", {\n type: \"string\",\n demandOption: true,\n describe: \"Path to the .tomb source file\",\n })\n .option(\"compiler\", {\n type: \"string\",\n describe: \"Explicit pha-tomb executable path (overrides PHA_TOMB_PATH and PATH)\",\n })\n .option(\"out\", {\n type: \"string\",\n describe: \"Output directory for the final artifact bundle\",\n })\n .option(\"contract-name\", {\n type: \"string\",\n describe: \"Expected contract artifact name when the compiler emits multiple modules\",\n })\n .option(\"protocol\", {\n type: \"number\",\n describe: \"Target protocol version passed to pha-tomb\",\n })\n .option(\"debug\", {\n type: \"boolean\",\n describe: \"Request debug artifacts from pha-tomb\",\n })\n .option(\"nativecheck\", {\n type: \"string\",\n choices: [\"off\", \"warn\", \"error\"],\n describe: \"Native/foundational interop diagnostics mode\",\n })\n .option(\"libpath\", {\n type: \"string\",\n array: true,\n describe: \"Additional library search path(s) passed to pha-tomb\",\n }),\n async (argv) => {\n await handleContractCompile({\n source: argv.source,\n out: argv.out,\n contractName: argv[\"contract-name\"],\n compiler: argv.compiler,\n protocol: argv.protocol,\n debug: argv.debug,\n nativeCheck: argv.nativecheck as NativeCheckMode | undefined,\n libpath: argv.libpath,\n });\n },\n )\n .command(\n \"deploy\",\n \"Deploy a compiled contract artifact bundle\",\n (cmd) =>\n cmd\n .option(\"rpc\", { type: \"string\", demandOption: true, describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", demandOption: true, describe: \"Nexus name\" })\n .option(\"chain\", { type: \"string\", default: \"main\", describe: \"Target chain\" })\n .option(\"wif\", { type: \"string\", demandOption: true, describe: \"WIF used to sign the transaction\" })\n .option(\"manifest\", { type: \"string\", describe: \"Path to manifest.json produced by contract compile\" })\n .option(\"contract-name\", { type: \"string\", describe: \"Contract name when using direct --script/--abi inputs\" })\n .option(\"script\", { type: \"string\", describe: \"Path to compiled .pvm file when not using --manifest\" })\n .option(\"abi\", { type: \"string\", describe: \"Path to compiled .abi file when not using --manifest\" })\n .option(\"debug\", { type: \"string\", describe: \"Optional path to .debug file when not using --manifest\" })\n .option(\"gas-price\", { type: \"number\", describe: \"Gas price passed to AllowGas\" })\n .option(\"gas-limit\", { type: \"number\", describe: \"Gas limit passed to AllowGas\" })\n .option(\"pow\", { type: \"number\", describe: \"Proof-of-work difficulty for the legacy VM transaction\" })\n .option(\"payload-hex\", { type: \"string\", describe: \"Optional transaction payload as raw hex\" })\n .option(\"dry-run\", { type: \"boolean\", describe: \"Build and sign the transaction without broadcasting\" }),\n async (argv) => {\n await handleContractBroadcast(\"deploy\", {\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n manifest: argv.manifest,\n contractName: argv[\"contract-name\"],\n script: argv.script,\n abi: argv.abi,\n debug: argv.debug,\n gasPrice: argv[\"gas-price\"],\n gasLimit: argv[\"gas-limit\"],\n pow: argv.pow,\n payloadHex: argv[\"payload-hex\"],\n dryRun: argv[\"dry-run\"],\n });\n },\n )\n .command(\n \"upgrade\",\n \"Upgrade an already deployed contract artifact bundle\",\n (cmd) =>\n cmd\n .option(\"rpc\", { type: \"string\", demandOption: true, describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", demandOption: true, describe: \"Nexus name\" })\n .option(\"chain\", { type: \"string\", default: \"main\", describe: \"Target chain\" })\n .option(\"wif\", { type: \"string\", demandOption: true, describe: \"WIF used to sign the transaction\" })\n .option(\"manifest\", { type: \"string\", describe: \"Path to manifest.json produced by contract compile\" })\n .option(\"contract-name\", { type: \"string\", describe: \"Contract name when using direct --script/--abi inputs\" })\n .option(\"script\", { type: \"string\", describe: \"Path to compiled .pvm file when not using --manifest\" })\n .option(\"abi\", { type: \"string\", describe: \"Path to compiled .abi file when not using --manifest\" })\n .option(\"debug\", { type: \"string\", describe: \"Optional path to .debug file when not using --manifest\" })\n .option(\"gas-price\", { type: \"number\", describe: \"Gas price passed to AllowGas\" })\n .option(\"gas-limit\", { type: \"number\", describe: \"Gas limit passed to AllowGas\" })\n .option(\"pow\", { type: \"number\", describe: \"Proof-of-work difficulty for the legacy VM transaction\" })\n .option(\"payload-hex\", { type: \"string\", describe: \"Optional transaction payload as raw hex\" })\n .option(\"dry-run\", { type: \"boolean\", describe: \"Build and sign the transaction without broadcasting\" }),\n async (argv) => {\n await handleContractBroadcast(\"upgrade\", {\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n manifest: argv.manifest,\n contractName: argv[\"contract-name\"],\n script: argv.script,\n abi: argv.abi,\n debug: argv.debug,\n gasPrice: argv[\"gas-price\"],\n gasLimit: argv[\"gas-limit\"],\n pow: argv.pow,\n payloadHex: argv[\"payload-hex\"],\n dryRun: argv[\"dry-run\"],\n });\n },\n )\n .command(\n \"attach\",\n \"Attach a compiled contract bundle to an existing token symbol\",\n (cmd) =>\n cmd\n .option(\"rpc\", { type: \"string\", demandOption: true, describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", demandOption: true, describe: \"Nexus name\" })\n .option(\"chain\", { type: \"string\", default: \"main\", describe: \"Target chain\" })\n .option(\"wif\", { type: \"string\", demandOption: true, describe: \"WIF used to sign the transaction\" })\n .option(\"symbol\", {\n type: \"string\",\n describe: \"Existing token symbol to attach to (defaults to the bundle contract name)\",\n })\n .option(\"manifest\", { type: \"string\", describe: \"Path to manifest.json produced by contract compile\" })\n .option(\"contract-name\", { type: \"string\", describe: \"Contract name when using direct --script/--abi inputs\" })\n .option(\"script\", { type: \"string\", describe: \"Path to compiled .pvm file when not using --manifest\" })\n .option(\"abi\", { type: \"string\", describe: \"Path to compiled .abi file when not using --manifest\" })\n .option(\"debug\", { type: \"string\", describe: \"Optional path to .debug file when not using --manifest\" })\n .option(\"gas-price\", { type: \"number\", describe: \"Gas price passed to AllowGas\" })\n .option(\"gas-limit\", { type: \"number\", describe: \"Gas limit passed to AllowGas\" })\n .option(\"pow\", { type: \"number\", describe: \"Proof-of-work difficulty for the legacy VM transaction\" })\n .option(\"payload-hex\", { type: \"string\", describe: \"Optional transaction payload as raw hex\" })\n .option(\"dry-run\", { type: \"boolean\", describe: \"Build and sign the transaction without broadcasting\" }),\n async (argv) => {\n await handleContractBroadcast(\"attach\", {\n rpc: argv.rpc,\n nexus: argv.nexus,\n chain: argv.chain,\n wif: argv.wif,\n symbol: argv.symbol,\n manifest: argv.manifest,\n contractName: argv[\"contract-name\"],\n script: argv.script,\n abi: argv.abi,\n debug: argv.debug,\n gasPrice: argv[\"gas-price\"],\n gasLimit: argv[\"gas-limit\"],\n pow: argv.pow,\n payloadHex: argv[\"payload-hex\"],\n dryRun: argv[\"dry-run\"],\n });\n },\n )\n .demandCommand(1)\n .strict()\n .help();\n\n await parser.parseAsync();\n}\n"]}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAqPA,iBAAe,IAAI,kBA+JlB;AAcD,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAsPA,iBAAe,IAAI,kBA+JlB;AAcD,eAAe,IAAI,CAAC"}
package/dist/cli.js CHANGED
@@ -30,16 +30,17 @@ const version_1 = require("./version");
30
30
  */
31
31
  function printHelp() {
32
32
  const text = `Usage:
33
- pha-deploy contract <compile|deploy|upgrade> [options]
33
+ pha-deploy contract <compile|deploy|upgrade|attach> [options]
34
34
  pha-deploy --create-token [options]
35
35
  pha-deploy --create-series [options]
36
36
  pha-deploy --mint-fungible [options]
37
37
  pha-deploy --mint-nft [options]
38
38
 
39
39
  Actions:
40
- contract compile Compile a contract through the system-installed pha-tomb
40
+ contract compile Compile a contract through pha-tomb from PATH or an explicit override
41
41
  contract deploy Deploy a compiled contract bundle
42
42
  contract upgrade Upgrade a compiled contract bundle
43
+ contract attach Attach a compiled contract bundle to an existing token
43
44
  --create-token Create a token
44
45
  --create-series Create a token series
45
46
  --mint-fungible Mint fungible tokens
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AACA,2CAAwC;AACxC,kDAA0B;AAC1B,sDAAyD;AACzD,yCAAoC;AACpC,uDAAoE;AACpE,yDAAuE;AACvE,mEAAsF;AACtF,yDAAuE;AACvE,uDAA4D;AAC5D,iDAAg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AAC;QACH,CAAC;IACH,CAAC;IAED,mCAAmC;IACnC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,SAAS,EAAE,CAAC;IACd,CAAC;AACH,CAAC;AAED,2EAA2E;AAE3E,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACnB,OAAO,CAAC,KAAK,CACX,yBAAyB,EACzB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CACnC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,IAAI,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs\";\nimport loadConfig, { Config, TokenType } from \"./config\";\nimport { inspect } from \"node:util\";\nimport { createToken, createTokenCfg } from \"./actions/createToken\";\nimport { createSeries, createSeriesCfg } from \"./actions/createSeries\";\nimport { mintFungibleToken, mintFungibleTokenCfg } from \"./actions/mintFungibleToken\";\nimport { mintNftToken, mintNftTokenCfg } from \"./actions/mintNftToken\";\nimport { PhantasmaKeys, setLogger } from \"phantasma-sdk-ts\";\nimport { runContractCli } from \"./cli-contract\";\nimport { buildVersionReport, renderVersionReport } from \"./version\";\n\n/**\n * CLI for pha-deploy.\n *\n * Modes:\n * - CLI one-shot: use flags to perform actions immediately\n * - TOML-driven: use `--config` or default `config.toml` for config values\n *\n * Actions:\n * - create-token\n * - create-series\n * - mint-fungible\n * - mint-nft\n */\n\nfunction printHelp(): void {\n const text = `Usage:\n pha-deploy contract <compile|deploy|upgrade> [options]\n pha-deploy --create-token [options]\n pha-deploy --create-series [options]\n pha-deploy --mint-fungible [options]\n pha-deploy --mint-nft [options]\n\nActions:\n contract compile Compile a contract through the system-installed pha-tomb\n contract deploy Deploy a compiled contract bundle\n contract upgrade Upgrade a compiled contract bundle\n --create-token Create a token\n --create-series Create a token series\n --mint-fungible Mint fungible tokens\n --mint-nft Mint tokens\n\nCommon flags:\n --config <path> Path to TOML config file (default: config.toml)\n --dry-run Do not broadcast transactions; just show payloads\n --rpc-log Enable SDK JSON-RPC logging (full response payloads)\n --settings-log Print resolved configuration before executing an action\n --help Show this help\n --version Show version number\n\nOverrides (replace values from config.toml when provided):\n --rpc <url> RPC endpoint (fallback: https://testnet.phantasma.info/rpc)\n --nexus <name> Chain nexus (example: mainnet or testnet)\n --wif <wif> WIF for signing\n --symbol <symbol> Token symbol\n --token-type <nft|fungible> Token type to create (default: nft)\n --token-max-supply <int> Non-negative integer; required when token-type=fungible\n --fungible-max-supply <int> Alias for --token-max-supply\n --fungible-decimals <0..255> Decimal places; required when token-type=fungible\n --carbon-token-id <int> Existing carbon token ID (for series or mint)\n --phantasma-series-id <int> Existing Phantasma series ID (required for deterministic mint)\n --mint-fungible-to <address> Recipient address for fungible mint (default: WIF owner)\n --mint-fungible-amount <int> Amount to mint (integer atomic units)\n --rom <hex> Token ROM hex (optional; for token creation)\n --token-schemas <json> JSON string with schemas (seriesMetadata, rom, ram)\n --token-metadata <json> JSON string of token metadata fields\n --series-metadata <json> JSON object or array of series metadata fields\n --nft-metadata <json> JSON object or array of NFT metadata fields\n --create-token-max-data <int> Max data for create-token tx\n --create-token-series-max-data <int> Max data for create-series tx\n --mint-token-max-data <int> Max data for mint-nft tx\n --gas-fee-base <int> Gas fee base\n --gas-fee-create-token-base <int> Gas fee base for create-token\n --gas-fee-create-token-symbol <int> Gas fee per symbol\n --gas-fee-create-token-series <int> Gas fee for create-series\n --gas-fee-multiplier <int> Gas fee multiplier\n\npha-deploy - Phantasma token deployment and minting CLI\n`;\n console.log(text);\n}\n\nfunction requireArg<T>(\n value: T,\n name: string,\n): asserts value is NonNullable<T> {\n if (value === undefined || value === null) {\n throw new Error(`${name} is required`);\n }\n}\n\n/* ----------------------------- Actions ----------------------------- */\nasync function actionCreateToken(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.symbol, \"symbol\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeCreateTokenBase, \"gas_fee_create_token_base\");\n requireArg(cfg.gasFeeCreateTokenSymbol, \"gas_fee_create_token_symbol\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.createTokenMaxData, \"create_token_max_data\");\n\n const tokenType: TokenType =\n (cfg.tokenType ?? \"nft\") === \"fungible\" ? \"fungible\" : \"nft\";\n\n if (tokenType === \"fungible\") {\n requireArg(cfg.tokenMaxSupply, \"token_max_supply\");\n requireArg(cfg.fungibleDecimals, \"fungible_decimals\");\n } else {\n requireArg(cfg.tokenSchemas, \"token_schemas\");\n }\n\n await createToken(\n new createTokenCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.symbol,\n cfg.gasFeeBase,\n cfg.gasFeeCreateTokenBase,\n cfg.gasFeeCreateTokenSymbol,\n cfg.gasFeeMultiplier,\n cfg.createTokenMaxData,\n cfg.tokenSchemas,\n cfg.tokenMetadata,\n tokenType,\n cfg.tokenMaxSupply,\n cfg.fungibleDecimals,\n ),\n dryRun,\n logSettings,\n );\n}\n\nasync function actionCreateSeries(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.carbonTokenId, \"carbon_token_id\");\n requireArg(cfg.tokenSchemas, \"token_schemas\");\n requireArg(cfg.seriesMetadata, \"series_metadata\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeCreateTokenSeries, \"gas_fee_create_token_series\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.createTokenSeriesMaxData, \"create_token_series_max_data\");\n\n await createSeries(\n new createSeriesCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.carbonTokenId,\n cfg.gasFeeBase,\n cfg.gasFeeCreateTokenSeries,\n cfg.gasFeeMultiplier,\n cfg.createTokenSeriesMaxData,\n cfg.tokenSchemas?.seriesMetadata,\n cfg.seriesMetadata\n ),\n dryRun,\n logSettings,\n );\n}\n\nasync function actionMintNft(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.carbonTokenId, \"carbon_token_id\");\n requireArg(cfg.phantasmaSeriesId, \"phantasma_series_id\");\n requireArg(cfg.tokenSchemas, \"token_schemas\");\n requireArg(cfg.nftMetadata, \"nft_metadata\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.mintTokenMaxData, \"mint_token_max_data\");\n\n await mintNftToken(\n new mintNftTokenCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.carbonTokenId,\n cfg.phantasmaSeriesId,\n cfg.tokenSchemas.rom,\n cfg.nftMetadata,\n cfg.gasFeeBase,\n cfg.gasFeeMultiplier,\n cfg.mintTokenMaxData,\n ),\n dryRun,\n logSettings,\n );\n}\n\nasync function actionMintFungible(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.carbonTokenId, \"carbon_token_id\");\n requireArg(cfg.mintFungibleAmount, \"mint_fungible_amount\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.mintTokenMaxData, \"mint_token_max_data\");\n\n const to =\n cfg.mintFungibleTo ?? PhantasmaKeys.fromWIF(cfg.wif).Address.toString();\n\n await mintFungibleToken(\n new mintFungibleTokenCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.carbonTokenId,\n to,\n cfg.mintFungibleAmount,\n cfg.gasFeeBase,\n cfg.gasFeeMultiplier,\n cfg.mintTokenMaxData,\n ),\n dryRun,\n logSettings,\n );\n}\n\n/* ------------------------------- Main ------------------------------- */\n\nasync function main() {\n const rawArgv = hideBin(process.argv);\n\n if (rawArgv.length === 1 && (rawArgv[0] === \"--version\" || rawArgv[0] === \"-v\")) {\n console.log(renderVersionReport(await buildVersionReport()));\n return;\n }\n\n if (rawArgv[0] === \"contract\") {\n await runContractCli(rawArgv.slice(1));\n return;\n }\n\n // Pre-parse --config and --help early so the TOML file can be loaded before the main yargs parsing.\n const pre = yargs(rawArgv)\n .option(\"config\", {\n type: \"string\",\n alias: \"c\",\n description: \"Path to TOML config file (default: config.toml)\",\n })\n .option(\"help\", {\n type: \"boolean\",\n })\n .alias(\"h\", \"help\")\n .help(false)\n .version(false)\n .parseSync();\n\n if ((pre as any).help) {\n printHelp();\n return;\n }\n\n // Minimal yargs parsing for the top-level CLI behavior\n const parser = yargs(rawArgv)\n .scriptName(\"pha-deploy\")\n .usage(\"Usage: $0 [options] [--create-token|--create-series|--mint-fungible|--mint-nft]\")\n .option(\"rpc\", { type: \"string\", describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", describe: \"Chain nexus\" })\n .option(\"wif\", { type: \"string\", describe: \"WIF for signing\" })\n .option(\"symbol\", { type: \"string\", describe: \"Token symbol\" })\n .option(\"token-type\", {\n type: \"string\",\n choices: [\"nft\", \"fungible\"],\n describe: \"Token type to create (default: nft)\",\n })\n .option(\"token-max-supply\", {\n type: \"string\",\n describe:\n \"Token max supply (optional for NFT; required when --token-type fungible)\",\n })\n .option(\"fungible-decimals\", {\n type: \"number\",\n describe:\n \"Decimal places for fungible token (required when --token-type fungible)\",\n })\n .option(\"dry-run\", {\n type: \"boolean\",\n describe: \"Do not broadcast transactions; just show payloads\",\n })\n .option(\"rpc-log\", {\n type: \"boolean\",\n describe:\n \"Enable SDK RPC logging (prints full JSON-RPC responses for debugging)\",\n })\n .option(\"settings-log\", {\n type: \"boolean\",\n describe: \"Print resolved configuration before executing an action\",\n })\n .option(\"help\", {\n type: \"boolean\",\n describe: \"Show help\",\n })\n .alias(\"h\", \"help\")\n .option(\"config\", {\n type: \"string\",\n describe:\n \"Path to TOML config file (default: config.toml). Takes precedence as the file used for defaults.\",\n })\n .option(\"create-token\", { type: \"boolean\", describe: \"Create a token\" })\n .option(\"create-series\", {\n type: \"boolean\",\n describe: \"Create a token series\",\n })\n .option(\"mint-fungible\", { type: \"boolean\", describe: \"Mint fungible tokens\" })\n .option(\"mint-nft\", { type: \"boolean\", describe: \"Mint tokens\" })\n .option(\"mint-fungible-to\", {\n type: \"string\",\n describe: \"Recipient address for fungible mint (default: WIF owner)\",\n })\n .option(\"mint-fungible-amount\", {\n type: \"string\",\n describe: \"Amount to mint (integer atomic units)\",\n })\n .version(false)\n .epilog(\"pha-deploy - Phantasma token deployment and minting CLI\");\n\n const argv = await parser.parseAsync();\n if ((argv as any).help) {\n printHelp();\n return;\n }\n\n // Load TOML configuration (if present) before doing full parsing\n const cfg = loadConfig({ configPath: pre.config ?? null });\n\n const rpcLogEnabled = Boolean((argv as any)[\"rpc-log\"]);\n const settingsLogEnabled = Boolean((argv as any)[\"settings-log\"]);\n if (rpcLogEnabled) {\n // SDK logs JSON-RPC responses as raw objects; inspect avoids [Object] output.\n setLogger({\n log: (...args: unknown[]) => {\n const formatted = args.map((arg) =>\n typeof arg === \"string\"\n ? arg\n : inspect(arg, { depth: null, colors: false }),\n );\n console.log(...formatted);\n },\n });\n } else {\n // Enforce silent SDK logs unless explicitly enabled.\n setLogger();\n }\n\n // Determine dry-run (CLI flag overrides config)\n const dryRun = Boolean((argv as any)[\"dry-run\"]) || cfg.dryRun || false;\n\n // One-shot actions: pick the first matching action\n const actions = [\"create-token\", \"create-series\", \"mint-fungible\", \"mint-nft\"];\n let foundAction = false;\n for (const action of actions) {\n if ((argv as any)[action]) {\n foundAction = true;\n switch (action) {\n case \"create-token\": {\n await actionCreateToken(cfg, dryRun, settingsLogEnabled);\n return;\n }\n case \"create-series\": {\n await actionCreateSeries(cfg, dryRun, settingsLogEnabled);\n return;\n }\n case \"mint-fungible\": {\n await actionMintFungible(cfg, dryRun, settingsLogEnabled);\n return;\n }\n case \"mint-nft\": {\n await actionMintNft(cfg, dryRun, settingsLogEnabled);\n return;\n }\n }\n }\n }\n\n // No action requested -> show help\n if (!foundAction) {\n printHelp();\n }\n}\n\n/* ----------------------------- Run Script ---------------------------- */\n\nif (require.main === module) {\n main().catch((err) => {\n console.error(\n \"Unhandled error in CLI:\",\n err && err.stack ? err.stack : err,\n );\n process.exit(2);\n });\n}\n\nexport default main;\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AACA,2CAAwC;AACxC,kDAA0B;AAC1B,sDAAyD;AACzD,yCAAoC;AACpC,uDAAoE;AACpE,yDAAuE;AACvE,mEAAsF;AACtF,yDAAuE;AACvE,uDAA4D;AAC5D,iDAAgD;AAChD,uCAAoE;AAEpE;;;;;;;;;;;;GAYG;AAEH,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDd,CAAC;IACA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,UAAU,CACjB,KAAQ,EACR,IAAY;IAEZ,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,cAAc,CAAC,CAAC;IACzC,CAAC;A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OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,IAAI,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { hideBin } from \"yargs/helpers\";\nimport yargs from \"yargs\";\nimport loadConfig, { Config, TokenType } from \"./config\";\nimport { inspect } from \"node:util\";\nimport { createToken, createTokenCfg } from \"./actions/createToken\";\nimport { createSeries, createSeriesCfg } from \"./actions/createSeries\";\nimport { mintFungibleToken, mintFungibleTokenCfg } from \"./actions/mintFungibleToken\";\nimport { mintNftToken, mintNftTokenCfg } from \"./actions/mintNftToken\";\nimport { PhantasmaKeys, setLogger } from \"phantasma-sdk-ts\";\nimport { runContractCli } from \"./cli-contract\";\nimport { buildVersionReport, renderVersionReport } from \"./version\";\n\n/**\n * CLI for pha-deploy.\n *\n * Modes:\n * - CLI one-shot: use flags to perform actions immediately\n * - TOML-driven: use `--config` or default `config.toml` for config values\n *\n * Actions:\n * - create-token\n * - create-series\n * - mint-fungible\n * - mint-nft\n */\n\nfunction printHelp(): void {\n const text = `Usage:\n pha-deploy contract <compile|deploy|upgrade|attach> [options]\n pha-deploy --create-token [options]\n pha-deploy --create-series [options]\n pha-deploy --mint-fungible [options]\n pha-deploy --mint-nft [options]\n\nActions:\n contract compile Compile a contract through pha-tomb from PATH or an explicit override\n contract deploy Deploy a compiled contract bundle\n contract upgrade Upgrade a compiled contract bundle\n contract attach Attach a compiled contract bundle to an existing token\n --create-token Create a token\n --create-series Create a token series\n --mint-fungible Mint fungible tokens\n --mint-nft Mint tokens\n\nCommon flags:\n --config <path> Path to TOML config file (default: config.toml)\n --dry-run Do not broadcast transactions; just show payloads\n --rpc-log Enable SDK JSON-RPC logging (full response payloads)\n --settings-log Print resolved configuration before executing an action\n --help Show this help\n --version Show version number\n\nOverrides (replace values from config.toml when provided):\n --rpc <url> RPC endpoint (fallback: https://testnet.phantasma.info/rpc)\n --nexus <name> Chain nexus (example: mainnet or testnet)\n --wif <wif> WIF for signing\n --symbol <symbol> Token symbol\n --token-type <nft|fungible> Token type to create (default: nft)\n --token-max-supply <int> Non-negative integer; required when token-type=fungible\n --fungible-max-supply <int> Alias for --token-max-supply\n --fungible-decimals <0..255> Decimal places; required when token-type=fungible\n --carbon-token-id <int> Existing carbon token ID (for series or mint)\n --phantasma-series-id <int> Existing Phantasma series ID (required for deterministic mint)\n --mint-fungible-to <address> Recipient address for fungible mint (default: WIF owner)\n --mint-fungible-amount <int> Amount to mint (integer atomic units)\n --rom <hex> Token ROM hex (optional; for token creation)\n --token-schemas <json> JSON string with schemas (seriesMetadata, rom, ram)\n --token-metadata <json> JSON string of token metadata fields\n --series-metadata <json> JSON object or array of series metadata fields\n --nft-metadata <json> JSON object or array of NFT metadata fields\n --create-token-max-data <int> Max data for create-token tx\n --create-token-series-max-data <int> Max data for create-series tx\n --mint-token-max-data <int> Max data for mint-nft tx\n --gas-fee-base <int> Gas fee base\n --gas-fee-create-token-base <int> Gas fee base for create-token\n --gas-fee-create-token-symbol <int> Gas fee per symbol\n --gas-fee-create-token-series <int> Gas fee for create-series\n --gas-fee-multiplier <int> Gas fee multiplier\n\npha-deploy - Phantasma token deployment and minting CLI\n`;\n console.log(text);\n}\n\nfunction requireArg<T>(\n value: T,\n name: string,\n): asserts value is NonNullable<T> {\n if (value === undefined || value === null) {\n throw new Error(`${name} is required`);\n }\n}\n\n/* ----------------------------- Actions ----------------------------- */\nasync function actionCreateToken(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.symbol, \"symbol\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeCreateTokenBase, \"gas_fee_create_token_base\");\n requireArg(cfg.gasFeeCreateTokenSymbol, \"gas_fee_create_token_symbol\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.createTokenMaxData, \"create_token_max_data\");\n\n const tokenType: TokenType =\n (cfg.tokenType ?? \"nft\") === \"fungible\" ? \"fungible\" : \"nft\";\n\n if (tokenType === \"fungible\") {\n requireArg(cfg.tokenMaxSupply, \"token_max_supply\");\n requireArg(cfg.fungibleDecimals, \"fungible_decimals\");\n } else {\n requireArg(cfg.tokenSchemas, \"token_schemas\");\n }\n\n await createToken(\n new createTokenCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.symbol,\n cfg.gasFeeBase,\n cfg.gasFeeCreateTokenBase,\n cfg.gasFeeCreateTokenSymbol,\n cfg.gasFeeMultiplier,\n cfg.createTokenMaxData,\n cfg.tokenSchemas,\n cfg.tokenMetadata,\n tokenType,\n cfg.tokenMaxSupply,\n cfg.fungibleDecimals,\n ),\n dryRun,\n logSettings,\n );\n}\n\nasync function actionCreateSeries(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.carbonTokenId, \"carbon_token_id\");\n requireArg(cfg.tokenSchemas, \"token_schemas\");\n requireArg(cfg.seriesMetadata, \"series_metadata\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeCreateTokenSeries, \"gas_fee_create_token_series\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.createTokenSeriesMaxData, \"create_token_series_max_data\");\n\n await createSeries(\n new createSeriesCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.carbonTokenId,\n cfg.gasFeeBase,\n cfg.gasFeeCreateTokenSeries,\n cfg.gasFeeMultiplier,\n cfg.createTokenSeriesMaxData,\n cfg.tokenSchemas?.seriesMetadata,\n cfg.seriesMetadata\n ),\n dryRun,\n logSettings,\n );\n}\n\nasync function actionMintNft(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.carbonTokenId, \"carbon_token_id\");\n requireArg(cfg.phantasmaSeriesId, \"phantasma_series_id\");\n requireArg(cfg.tokenSchemas, \"token_schemas\");\n requireArg(cfg.nftMetadata, \"nft_metadata\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.mintTokenMaxData, \"mint_token_max_data\");\n\n await mintNftToken(\n new mintNftTokenCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.carbonTokenId,\n cfg.phantasmaSeriesId,\n cfg.tokenSchemas.rom,\n cfg.nftMetadata,\n cfg.gasFeeBase,\n cfg.gasFeeMultiplier,\n cfg.mintTokenMaxData,\n ),\n dryRun,\n logSettings,\n );\n}\n\nasync function actionMintFungible(\n cfg: Config,\n dryRun: boolean,\n logSettings: boolean,\n) {\n requireArg(cfg.rpc, \"rpc\");\n requireArg(cfg.nexus, \"nexus\");\n requireArg(cfg.wif, \"wif\");\n requireArg(cfg.carbonTokenId, \"carbon_token_id\");\n requireArg(cfg.mintFungibleAmount, \"mint_fungible_amount\");\n requireArg(cfg.gasFeeBase, \"gas_fee_base\");\n requireArg(cfg.gasFeeMultiplier, \"gas_fee_multiplier\");\n requireArg(cfg.mintTokenMaxData, \"mint_token_max_data\");\n\n const to =\n cfg.mintFungibleTo ?? PhantasmaKeys.fromWIF(cfg.wif).Address.toString();\n\n await mintFungibleToken(\n new mintFungibleTokenCfg(\n cfg.rpc,\n cfg.nexus,\n cfg.wif,\n cfg.carbonTokenId,\n to,\n cfg.mintFungibleAmount,\n cfg.gasFeeBase,\n cfg.gasFeeMultiplier,\n cfg.mintTokenMaxData,\n ),\n dryRun,\n logSettings,\n );\n}\n\n/* ------------------------------- Main ------------------------------- */\n\nasync function main() {\n const rawArgv = hideBin(process.argv);\n\n if (rawArgv.length === 1 && (rawArgv[0] === \"--version\" || rawArgv[0] === \"-v\")) {\n console.log(renderVersionReport(await buildVersionReport()));\n return;\n }\n\n if (rawArgv[0] === \"contract\") {\n await runContractCli(rawArgv.slice(1));\n return;\n }\n\n // Pre-parse --config and --help early so the TOML file can be loaded before the main yargs parsing.\n const pre = yargs(rawArgv)\n .option(\"config\", {\n type: \"string\",\n alias: \"c\",\n description: \"Path to TOML config file (default: config.toml)\",\n })\n .option(\"help\", {\n type: \"boolean\",\n })\n .alias(\"h\", \"help\")\n .help(false)\n .version(false)\n .parseSync();\n\n if ((pre as any).help) {\n printHelp();\n return;\n }\n\n // Minimal yargs parsing for the top-level CLI behavior\n const parser = yargs(rawArgv)\n .scriptName(\"pha-deploy\")\n .usage(\"Usage: $0 [options] [--create-token|--create-series|--mint-fungible|--mint-nft]\")\n .option(\"rpc\", { type: \"string\", describe: \"RPC endpoint\" })\n .option(\"nexus\", { type: \"string\", describe: \"Chain nexus\" })\n .option(\"wif\", { type: \"string\", describe: \"WIF for signing\" })\n .option(\"symbol\", { type: \"string\", describe: \"Token symbol\" })\n .option(\"token-type\", {\n type: \"string\",\n choices: [\"nft\", \"fungible\"],\n describe: \"Token type to create (default: nft)\",\n })\n .option(\"token-max-supply\", {\n type: \"string\",\n describe:\n \"Token max supply (optional for NFT; required when --token-type fungible)\",\n })\n .option(\"fungible-decimals\", {\n type: \"number\",\n describe:\n \"Decimal places for fungible token (required when --token-type fungible)\",\n })\n .option(\"dry-run\", {\n type: \"boolean\",\n describe: \"Do not broadcast transactions; just show payloads\",\n })\n .option(\"rpc-log\", {\n type: \"boolean\",\n describe:\n \"Enable SDK RPC logging (prints full JSON-RPC responses for debugging)\",\n })\n .option(\"settings-log\", {\n type: \"boolean\",\n describe: \"Print resolved configuration before executing an action\",\n })\n .option(\"help\", {\n type: \"boolean\",\n describe: \"Show help\",\n })\n .alias(\"h\", \"help\")\n .option(\"config\", {\n type: \"string\",\n describe:\n \"Path to TOML config file (default: config.toml). Takes precedence as the file used for defaults.\",\n })\n .option(\"create-token\", { type: \"boolean\", describe: \"Create a token\" })\n .option(\"create-series\", {\n type: \"boolean\",\n describe: \"Create a token series\",\n })\n .option(\"mint-fungible\", { type: \"boolean\", describe: \"Mint fungible tokens\" })\n .option(\"mint-nft\", { type: \"boolean\", describe: \"Mint tokens\" })\n .option(\"mint-fungible-to\", {\n type: \"string\",\n describe: \"Recipient address for fungible mint (default: WIF owner)\",\n })\n .option(\"mint-fungible-amount\", {\n type: \"string\",\n describe: \"Amount to mint (integer atomic units)\",\n })\n .version(false)\n .epilog(\"pha-deploy - Phantasma token deployment and minting CLI\");\n\n const argv = await parser.parseAsync();\n if ((argv as any).help) {\n printHelp();\n return;\n }\n\n // Load TOML configuration (if present) before doing full parsing\n const cfg = loadConfig({ configPath: pre.config ?? null });\n\n const rpcLogEnabled = Boolean((argv as any)[\"rpc-log\"]);\n const settingsLogEnabled = Boolean((argv as any)[\"settings-log\"]);\n if (rpcLogEnabled) {\n // SDK logs JSON-RPC responses as raw objects; inspect avoids [Object] output.\n setLogger({\n log: (...args: unknown[]) => {\n const formatted = args.map((arg) =>\n typeof arg === \"string\"\n ? arg\n : inspect(arg, { depth: null, colors: false }),\n );\n console.log(...formatted);\n },\n });\n } else {\n // Enforce silent SDK logs unless explicitly enabled.\n setLogger();\n }\n\n // Determine dry-run (CLI flag overrides config)\n const dryRun = Boolean((argv as any)[\"dry-run\"]) || cfg.dryRun || false;\n\n // One-shot actions: pick the first matching action\n const actions = [\"create-token\", \"create-series\", \"mint-fungible\", \"mint-nft\"];\n let foundAction = false;\n for (const action of actions) {\n if ((argv as any)[action]) {\n foundAction = true;\n switch (action) {\n case \"create-token\": {\n await actionCreateToken(cfg, dryRun, settingsLogEnabled);\n return;\n }\n case \"create-series\": {\n await actionCreateSeries(cfg, dryRun, settingsLogEnabled);\n return;\n }\n case \"mint-fungible\": {\n await actionMintFungible(cfg, dryRun, settingsLogEnabled);\n return;\n }\n case \"mint-nft\": {\n await actionMintNft(cfg, dryRun, settingsLogEnabled);\n return;\n }\n }\n }\n }\n\n // No action requested -> show help\n if (!foundAction) {\n printHelp();\n }\n}\n\n/* ----------------------------- Run Script ---------------------------- */\n\nif (require.main === module) {\n main().catch((err) => {\n console.error(\n \"Unhandled error in CLI:\",\n err && err.stack ? err.stack : err,\n );\n process.exit(2);\n });\n}\n\nexport default main;\n"]}
@@ -1,5 +1,5 @@
1
1
  export declare const CONTRACT_COMPILER_NAME = "pha-tomb";
2
- export declare const MIN_SUPPORTED_PHA_TOMB_VERSION = "2.0.0";
2
+ export declare const MIN_SUPPORTED_PHA_TOMB_VERSION = "2.1.0";
3
3
  export type NativeCheckMode = "off" | "warn" | "error";
4
4
  export interface InstalledCompiler {
5
5
  executableName: string;
@@ -36,7 +36,7 @@ export declare function isSemverGte(actual: string, minimum: string): boolean;
36
36
  export declare function findExecutableInPath(executableName: string, envPath?: string, platform?: NodeJS.Platform): string | null;
37
37
  export declare function queryCompilerVersion(executablePath: string): Promise<string>;
38
38
  export declare function findInstalledCompiler(envPath?: string): Promise<InstalledCompiler | null>;
39
- export declare function resolveSupportedCompiler(minimumVersion?: string, envPath?: string): Promise<InstalledCompiler>;
39
+ export declare function resolveSupportedCompiler(minimumVersion?: string, envPath?: string, explicitPath?: string): Promise<InstalledCompiler>;
40
40
  export declare function buildCompileArgs(options: CompileArgsOptions): string[];
41
41
  export declare function runCompiler(executablePath: string, args: string[], cwd: string): Promise<CompileProcessResult>;
42
42
  export declare function selectCompiledContractArtifacts(compilerOutputDir: string, requestedContractName?: string): CompiledContractArtifacts;
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/contract/compiler.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,aAAa,CAAC;AACjD,eAAO,MAAM,8BAA8B,UAAU,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD,MA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,CA8D3B"}
@@ -16,7 +16,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
16
16
  const node_path_1 = __importDefault(require("node:path"));
17
17
  const node_child_process_1 = require("node:child_process");
18
18
  exports.CONTRACT_COMPILER_NAME = "pha-tomb";
19
- exports.MIN_SUPPORTED_PHA_TOMB_VERSION = "2.0.0";
19
+ exports.MIN_SUPPORTED_PHA_TOMB_VERSION = "2.1.0";
20
20
  function parseSemver(version) {
21
21
  const match = version.trim().match(/^(\d+)\.(\d+)\.(\d+)/);
22
22
  if (!match) {
@@ -116,8 +116,25 @@ async function findInstalledCompiler(envPath = process.env.PATH ?? "") {
116
116
  version: await queryCompilerVersion(executablePath),
117
117
  };
118
118
  }
119
- async function resolveSupportedCompiler(minimumVersion = exports.MIN_SUPPORTED_PHA_TOMB_VERSION, envPath = process.env.PATH ?? "") {
120
- const compiler = await findInstalledCompiler(envPath);
119
+ async function resolveExplicitCompiler(executablePath) {
120
+ const normalizedPath = node_path_1.default.resolve(executablePath.trim());
121
+ try {
122
+ node_fs_1.default.accessSync(normalizedPath, node_fs_1.default.constants.X_OK);
123
+ }
124
+ catch {
125
+ throw new Error(`${exports.CONTRACT_COMPILER_NAME} is not executable: ${normalizedPath}`);
126
+ }
127
+ return {
128
+ executableName: node_path_1.default.basename(normalizedPath),
129
+ executablePath: normalizedPath,
130
+ version: await queryCompilerVersion(normalizedPath),
131
+ };
132
+ }
133
+ async function resolveSupportedCompiler(minimumVersion = exports.MIN_SUPPORTED_PHA_TOMB_VERSION, envPath = process.env.PATH ?? "", explicitPath) {
134
+ const requestedPath = explicitPath?.trim();
135
+ const compiler = requestedPath
136
+ ? await resolveExplicitCompiler(requestedPath)
137
+ : await findInstalledCompiler(envPath);
121
138
  if (!compiler) {
122
139
  throw new Error(`${exports.CONTRACT_COMPILER_NAME} was not found in PATH`);
123
140
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/contract/compiler.ts"],"names":[],"mappings":";;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UAAU,EAAE,CACjG,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,gBAAgB,MAAM,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,gBAAgB,MAAM,CAAC,CAAC;IAC1E,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,yCAAyC,gBAAgB,MAAM,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,MAAc,EAAsB,EAAE;QAC1D,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,gBAAgB,GAAG,MAAM,EAAE,CAAC,CAAC;QACjF,OAAO,iBAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE,gBAAgB;QAC9B,iBAAiB,EAAE,mBAAmB;QACtC,UAAU;QACV,OAAO;QACP,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC;QAC7B,aAAa,EAAE,YAAY,CAAC,UAAU,CAAC;QACvC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { spawn } from \"node:child_process\";\n\nexport const CONTRACT_COMPILER_NAME = \"pha-tomb\";\nexport const MIN_SUPPORTED_PHA_TOMB_VERSION = \"2.0.0\";\n\nexport type NativeCheckMode = \"off\" | \"warn\" | \"error\";\n\nexport interface InstalledCompiler {\n executableName: string;\n executablePath: string;\n version: string;\n}\n\nexport interface CompileProcessResult {\n command: string;\n args: string[];\n cwd: string;\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport interface CompileArgsOptions {\n sourcePath: string;\n outputRoot: string;\n libPaths?: string[];\n protocol?: number;\n debug?: boolean;\n nativeCheck?: NativeCheckMode;\n}\n\nexport interface CompiledContractArtifacts {\n contractName: string;\n compilerOutputDir: string;\n scriptPath: string;\n abiPath: string;\n debugPath?: string;\n asmPath?: string;\n scriptHexPath?: string;\n abiHexPath?: string;\n}\n\nfunction parseSemver(version: string): [number, number, number] {\n const match = version.trim().match(/^(\\d+)\\.(\\d+)\\.(\\d+)/);\n if (!match) {\n throw new Error(`Unsupported semantic version: ${version}`);\n }\n\n return [\n Number(match[1]),\n Number(match[2]),\n Number(match[3]),\n ];\n}\n\nexport function isSemverGte(actual: string, minimum: string): boolean {\n const actualParts = parseSemver(actual);\n const minimumParts = parseSemver(minimum);\n\n for (let i = 0; i < actualParts.length; i += 1) {\n const a = actualParts[i] ?? 0;\n const b = minimumParts[i] ?? 0;\n if (a > b) {\n return true;\n }\n if (a < b) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function findExecutableInPath(\n executableName: string,\n envPath: string = process.env.PATH ?? \"\",\n platform: NodeJS.Platform = process.platform,\n): string | null {\n const pathEntries = envPath.split(path.delimiter).filter(Boolean);\n const candidateNames =\n platform === \"win32\"\n ? [executableName, `${executableName}.exe`, `${executableName}.cmd`, `${executableName}.bat`]\n : [executableName];\n\n for (const entry of pathEntries) {\n for (const candidateName of candidateNames) {\n const candidatePath = path.join(entry, candidateName);\n try {\n fs.accessSync(candidatePath, fs.constants.X_OK);\n return candidatePath;\n } catch {\n continue;\n }\n }\n }\n\n return null;\n}\n\nasync function runCommandCapture(\n command: string,\n args: string[],\n cwd: string,\n): Promise<CompileProcessResult> {\n return await new Promise<CompileProcessResult>((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n child.stdout.setEncoding(\"utf8\");\n child.stderr.setEncoding(\"utf8\");\n child.stdout.on(\"data\", (chunk: string) => {\n stdout += chunk;\n });\n child.stderr.on(\"data\", (chunk: string) => {\n stderr += chunk;\n });\n child.on(\"error\", reject);\n child.on(\"close\", (code) => {\n resolve({\n command,\n args,\n cwd,\n stdout,\n stderr,\n exitCode: code ?? -1,\n });\n });\n });\n}\n\nexport async function queryCompilerVersion(executablePath: string): Promise<string> {\n const result = await runCommandCapture(executablePath, [\"--version\"], process.cwd());\n if (result.exitCode !== 0) {\n throw new Error(\n `${CONTRACT_COMPILER_NAME} --version exited with code ${result.exitCode}: ${result.stderr.trim() || result.stdout.trim() || \"no diagnostics\"}`,\n );\n }\n\n const versionLine = result.stdout\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .find((line) => line.length > 0);\n\n if (!versionLine) {\n throw new Error(`${CONTRACT_COMPILER_NAME} --version returned no output`);\n }\n\n return versionLine;\n}\n\nexport async function findInstalledCompiler(\n envPath: string = process.env.PATH ?? \"\",\n): Promise<InstalledCompiler | null> {\n const executablePath = findExecutableInPath(CONTRACT_COMPILER_NAME, envPath);\n if (!executablePath) {\n return null;\n }\n\n return {\n executableName: CONTRACT_COMPILER_NAME,\n executablePath,\n version: await queryCompilerVersion(executablePath),\n };\n}\n\nexport async function resolveSupportedCompiler(\n minimumVersion: string = MIN_SUPPORTED_PHA_TOMB_VERSION,\n envPath: string = process.env.PATH ?? \"\",\n): Promise<InstalledCompiler> {\n const compiler = await findInstalledCompiler(envPath);\n if (!compiler) {\n throw new Error(`${CONTRACT_COMPILER_NAME} was not found in PATH`);\n }\n\n if (!isSemverGte(compiler.version, minimumVersion)) {\n throw new Error(\n `${CONTRACT_COMPILER_NAME} ${compiler.version} is below the minimum supported version ${minimumVersion}`,\n );\n }\n\n return compiler;\n}\n\nexport function buildCompileArgs(options: CompileArgsOptions): string[] {\n const args: string[] = [\n `output:${path.resolve(options.outputRoot)}`,\n ];\n\n if (options.protocol !== undefined) {\n args.push(`protocol:${options.protocol}`);\n }\n for (const libPath of options.libPaths ?? []) {\n args.push(`libpath:${path.resolve(libPath)}`);\n }\n if (options.debug) {\n args.push(\"debug\");\n }\n if (options.nativeCheck) {\n args.push(`nativecheck:${options.nativeCheck}`);\n }\n\n args.push(path.resolve(options.sourcePath));\n return args;\n}\n\nexport async function runCompiler(\n executablePath: string,\n args: string[],\n cwd: string,\n): Promise<CompileProcessResult> {\n return await runCommandCapture(executablePath, args, cwd);\n}\n\nexport function selectCompiledContractArtifacts(\n compilerOutputDir: string,\n requestedContractName?: string,\n): CompiledContractArtifacts {\n const normalizedOutputDir = path.resolve(compilerOutputDir);\n if (!fs.existsSync(normalizedOutputDir)) {\n throw new Error(`Compiler output directory does not exist: ${normalizedOutputDir}`);\n }\n\n const entries = fs.readdirSync(normalizedOutputDir, { withFileTypes: true });\n const pvmFiles = entries\n .filter((entry) => entry.isFile() && entry.name.endsWith(\".pvm\"))\n .map((entry) => entry.name)\n .sort();\n\n if (pvmFiles.length === 0) {\n throw new Error(`No .pvm artifacts were produced in ${normalizedOutputDir}`);\n }\n\n const requestedName = requestedContractName?.trim();\n let selectedBaseName: string | null = null;\n if (requestedName) {\n const requestedFile = `${requestedName}.pvm`;\n if (pvmFiles.includes(requestedFile)) {\n selectedBaseName = requestedName;\n }\n }\n\n if (!selectedBaseName && pvmFiles.length === 1) {\n selectedBaseName = path.basename(pvmFiles[0], \".pvm\");\n }\n\n if (!selectedBaseName) {\n const candidates = pvmFiles.map((file) => path.basename(file, \".pvm\")).join(\", \");\n if (requestedName) {\n throw new Error(\n `Requested contract '${requestedName}' was not found in compiler output. Available artifacts: ${candidates}`,\n );\n }\n throw new Error(\n `Compiler produced multiple .pvm artifacts. Use --contract-name to select one of: ${candidates}`,\n );\n }\n\n const scriptPath = path.join(normalizedOutputDir, `${selectedBaseName}.pvm`);\n const abiPath = path.join(normalizedOutputDir, `${selectedBaseName}.abi`);\n if (!fs.existsSync(abiPath)) {\n throw new Error(`ABI artifact is missing for contract '${selectedBaseName}': ${abiPath}`);\n }\n\n const optionalFile = (suffix: string): string | undefined => {\n const candidate = path.join(normalizedOutputDir, `${selectedBaseName}${suffix}`);\n return fs.existsSync(candidate) ? candidate : undefined;\n };\n\n return {\n contractName: selectedBaseName,\n compilerOutputDir: normalizedOutputDir,\n scriptPath,\n abiPath,\n debugPath: optionalFile(\".debug\"),\n asmPath: optionalFile(\".asm\"),\n scriptHexPath: optionalFile(\".pvm.hex\"),\n abiHexPath: optionalFile(\".abi.hex\"),\n };\n}\n"]}
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/contract/compiler.ts"],"names":[],"mappings":";;;;;;AAyDA,kCAgBC;AAED,oDAwBC;AAsCD,oDAkBC;AAED,sDAaC;AAiBD,4DAoBC;AAED,4CAoBC;AAED,kCAMC;AAED,0EAiEC;AAhTD,sDAAyB;AACzB,0DAA6B;AAC7B,2DAA2C;AAE9B,QAAA,sBAAsB,GAAG,UAAU,CAAC;AACpC,QAAA,8BAA8B,GAAG,OAAO,CAAC;AAuCtD,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAChB,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACjB,CAAC;AACJ,CAAC;AAED,SAAgB,WAAW,CAAC,MAAc,EAAE,OAAe;IACzD,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAE1C,KAAK,IAAI,CAAC,G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,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,gBAAgB,MAAM,CAAC,CAAC;IAC1E,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,yCAAyC,gBAAgB,MAAM,OAAO,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED,MAAM,YAAY,GAAG,CAAC,MAAc,EAAsB,EAAE;QAC1D,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,gBAAgB,GAAG,MAAM,EAAE,CAAC,CAAC;QACjF,OAAO,iBAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE,gBAAgB;QAC9B,iBAAiB,EAAE,mBAAmB;QACtC,UAAU;QACV,OAAO;QACP,SAAS,EAAE,YAAY,CAAC,QAAQ,CAAC;QACjC,OAAO,EAAE,YAAY,CAAC,MAAM,CAAC;QAC7B,aAAa,EAAE,YAAY,CAAC,UAAU,CAAC;QACvC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;KACrC,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { spawn } from \"node:child_process\";\n\nexport const CONTRACT_COMPILER_NAME = \"pha-tomb\";\nexport const MIN_SUPPORTED_PHA_TOMB_VERSION = \"2.1.0\";\n\nexport type NativeCheckMode = \"off\" | \"warn\" | \"error\";\n\nexport interface InstalledCompiler {\n executableName: string;\n executablePath: string;\n version: string;\n}\n\nexport interface CompileProcessResult {\n command: string;\n args: string[];\n cwd: string;\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\nexport interface CompileArgsOptions {\n sourcePath: string;\n outputRoot: string;\n libPaths?: string[];\n protocol?: number;\n debug?: boolean;\n nativeCheck?: NativeCheckMode;\n}\n\nexport interface CompiledContractArtifacts {\n contractName: string;\n compilerOutputDir: string;\n scriptPath: string;\n abiPath: string;\n debugPath?: string;\n asmPath?: string;\n scriptHexPath?: string;\n abiHexPath?: string;\n}\n\nfunction parseSemver(version: string): [number, number, number] {\n const match = version.trim().match(/^(\\d+)\\.(\\d+)\\.(\\d+)/);\n if (!match) {\n throw new Error(`Unsupported semantic version: ${version}`);\n }\n\n return [\n Number(match[1]),\n Number(match[2]),\n Number(match[3]),\n ];\n}\n\nexport function isSemverGte(actual: string, minimum: string): boolean {\n const actualParts = parseSemver(actual);\n const minimumParts = parseSemver(minimum);\n\n for (let i = 0; i < actualParts.length; i += 1) {\n const a = actualParts[i] ?? 0;\n const b = minimumParts[i] ?? 0;\n if (a > b) {\n return true;\n }\n if (a < b) {\n return false;\n }\n }\n\n return true;\n}\n\nexport function findExecutableInPath(\n executableName: string,\n envPath: string = process.env.PATH ?? \"\",\n platform: NodeJS.Platform = process.platform,\n): string | null {\n const pathEntries = envPath.split(path.delimiter).filter(Boolean);\n const candidateNames =\n platform === \"win32\"\n ? [executableName, `${executableName}.exe`, `${executableName}.cmd`, `${executableName}.bat`]\n : [executableName];\n\n for (const entry of pathEntries) {\n for (const candidateName of candidateNames) {\n const candidatePath = path.join(entry, candidateName);\n try {\n fs.accessSync(candidatePath, fs.constants.X_OK);\n return candidatePath;\n } catch {\n continue;\n }\n }\n }\n\n return null;\n}\n\nasync function runCommandCapture(\n command: string,\n args: string[],\n cwd: string,\n): Promise<CompileProcessResult> {\n return await new Promise<CompileProcessResult>((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n\n let stdout = \"\";\n let stderr = \"\";\n\n child.stdout.setEncoding(\"utf8\");\n child.stderr.setEncoding(\"utf8\");\n child.stdout.on(\"data\", (chunk: string) => {\n stdout += chunk;\n });\n child.stderr.on(\"data\", (chunk: string) => {\n stderr += chunk;\n });\n child.on(\"error\", reject);\n child.on(\"close\", (code) => {\n resolve({\n command,\n args,\n cwd,\n stdout,\n stderr,\n exitCode: code ?? -1,\n });\n });\n });\n}\n\nexport async function queryCompilerVersion(executablePath: string): Promise<string> {\n const result = await runCommandCapture(executablePath, [\"--version\"], process.cwd());\n if (result.exitCode !== 0) {\n throw new Error(\n `${CONTRACT_COMPILER_NAME} --version exited with code ${result.exitCode}: ${result.stderr.trim() || result.stdout.trim() || \"no diagnostics\"}`,\n );\n }\n\n const versionLine = result.stdout\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .find((line) => line.length > 0);\n\n if (!versionLine) {\n throw new Error(`${CONTRACT_COMPILER_NAME} --version returned no output`);\n }\n\n return versionLine;\n}\n\nexport async function findInstalledCompiler(\n envPath: string = process.env.PATH ?? \"\",\n): Promise<InstalledCompiler | null> {\n const executablePath = findExecutableInPath(CONTRACT_COMPILER_NAME, envPath);\n if (!executablePath) {\n return null;\n }\n\n return {\n executableName: CONTRACT_COMPILER_NAME,\n executablePath,\n version: await queryCompilerVersion(executablePath),\n };\n}\n\nasync function resolveExplicitCompiler(executablePath: string): Promise<InstalledCompiler> {\n const normalizedPath = path.resolve(executablePath.trim());\n try {\n fs.accessSync(normalizedPath, fs.constants.X_OK);\n } catch {\n throw new Error(`${CONTRACT_COMPILER_NAME} is not executable: ${normalizedPath}`);\n }\n\n return {\n executableName: path.basename(normalizedPath),\n executablePath: normalizedPath,\n version: await queryCompilerVersion(normalizedPath),\n };\n}\n\nexport async function resolveSupportedCompiler(\n minimumVersion: string = MIN_SUPPORTED_PHA_TOMB_VERSION,\n envPath: string = process.env.PATH ?? \"\",\n explicitPath?: string,\n): Promise<InstalledCompiler> {\n const requestedPath = explicitPath?.trim();\n const compiler = requestedPath\n ? await resolveExplicitCompiler(requestedPath)\n : await findInstalledCompiler(envPath);\n if (!compiler) {\n throw new Error(`${CONTRACT_COMPILER_NAME} was not found in PATH`);\n }\n\n if (!isSemverGte(compiler.version, minimumVersion)) {\n throw new Error(\n `${CONTRACT_COMPILER_NAME} ${compiler.version} is below the minimum supported version ${minimumVersion}`,\n );\n }\n\n return compiler;\n}\n\nexport function buildCompileArgs(options: CompileArgsOptions): string[] {\n const args: string[] = [\n `output:${path.resolve(options.outputRoot)}`,\n ];\n\n if (options.protocol !== undefined) {\n args.push(`protocol:${options.protocol}`);\n }\n for (const libPath of options.libPaths ?? []) {\n args.push(`libpath:${path.resolve(libPath)}`);\n }\n if (options.debug) {\n args.push(\"debug\");\n }\n if (options.nativeCheck) {\n args.push(`nativecheck:${options.nativeCheck}`);\n }\n\n args.push(path.resolve(options.sourcePath));\n return args;\n}\n\nexport async function runCompiler(\n executablePath: string,\n args: string[],\n cwd: string,\n): Promise<CompileProcessResult> {\n return await runCommandCapture(executablePath, args, cwd);\n}\n\nexport function selectCompiledContractArtifacts(\n compilerOutputDir: string,\n requestedContractName?: string,\n): CompiledContractArtifacts {\n const normalizedOutputDir = path.resolve(compilerOutputDir);\n if (!fs.existsSync(normalizedOutputDir)) {\n throw new Error(`Compiler output directory does not exist: ${normalizedOutputDir}`);\n }\n\n const entries = fs.readdirSync(normalizedOutputDir, { withFileTypes: true });\n const pvmFiles = entries\n .filter((entry) => entry.isFile() && entry.name.endsWith(\".pvm\"))\n .map((entry) => entry.name)\n .sort();\n\n if (pvmFiles.length === 0) {\n throw new Error(`No .pvm artifacts were produced in ${normalizedOutputDir}`);\n }\n\n const requestedName = requestedContractName?.trim();\n let selectedBaseName: string | null = null;\n if (requestedName) {\n const requestedFile = `${requestedName}.pvm`;\n if (pvmFiles.includes(requestedFile)) {\n selectedBaseName = requestedName;\n }\n }\n\n if (!selectedBaseName && pvmFiles.length === 1) {\n selectedBaseName = path.basename(pvmFiles[0], \".pvm\");\n }\n\n if (!selectedBaseName) {\n const candidates = pvmFiles.map((file) => path.basename(file, \".pvm\")).join(\", \");\n if (requestedName) {\n throw new Error(\n `Requested contract '${requestedName}' was not found in compiler output. Available artifacts: ${candidates}`,\n );\n }\n throw new Error(\n `Compiler produced multiple .pvm artifacts. Use --contract-name to select one of: ${candidates}`,\n );\n }\n\n const scriptPath = path.join(normalizedOutputDir, `${selectedBaseName}.pvm`);\n const abiPath = path.join(normalizedOutputDir, `${selectedBaseName}.abi`);\n if (!fs.existsSync(abiPath)) {\n throw new Error(`ABI artifact is missing for contract '${selectedBaseName}': ${abiPath}`);\n }\n\n const optionalFile = (suffix: string): string | undefined => {\n const candidate = path.join(normalizedOutputDir, `${selectedBaseName}${suffix}`);\n return fs.existsSync(candidate) ? candidate : undefined;\n };\n\n return {\n contractName: selectedBaseName,\n compilerOutputDir: normalizedOutputDir,\n scriptPath,\n abiPath,\n debugPath: optionalFile(\".debug\"),\n asmPath: optionalFile(\".asm\"),\n scriptHexPath: optionalFile(\".pvm.hex\"),\n abiHexPath: optionalFile(\".abi.hex\"),\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ContractArtifactBundle } from "phantasma-sdk-ts";
2
- export type ContractOperation = "deploy" | "upgrade";
2
+ export type ContractOperation = "deploy" | "upgrade" | "attach";
3
3
  export interface PreparedContractTransaction {
4
4
  operation: ContractOperation;
5
5
  contractName: string;
@@ -8,6 +8,7 @@ export interface PreparedContractTransaction {
8
8
  txHex: string;
9
9
  scriptBytes: number;
10
10
  abiBytes: number;
11
+ attachSymbol?: string;
11
12
  }
12
13
  export interface ExecuteContractTransactionOptions {
13
14
  operation: ContractOperation;
@@ -21,6 +22,7 @@ export interface ExecuteContractTransactionOptions {
21
22
  proofOfWork?: number;
22
23
  payloadHex?: string;
23
24
  dryRun?: boolean;
25
+ attachSymbol?: string;
24
26
  }
25
27
  export interface ExecuteContractTransactionResult {
26
28
  prepared: PreparedContractTransaction;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/contract/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAIvB,MAAM,kBAAkB,CAAC;AAI1B,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErD,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sdk-ts");
6
6
  const waitForTx_1 = require("../actions/waitForTx");
7
7
  const txHash_1 = require("../rpc/txHash");
8
+ function normalizeAttachSymbol(requestedSymbol, bundle) {
9
+ const attachSymbol = (requestedSymbol ?? bundle.contractName).trim();
10
+ if (!attachSymbol) {
11
+ throw new Error("attach symbol cannot be empty");
12
+ }
13
+ return attachSymbol;
14
+ }
15
+ function normalizeLifecycleGas(value, fallback, label) {
16
+ const numeric = value ?? fallback;
17
+ if (!Number.isSafeInteger(numeric) || numeric <= 0) {
18
+ throw new Error(`${label} must be a positive safe integer`);
19
+ }
20
+ return numeric;
21
+ }
22
+ function buildAttachScript(bundle, fromAddress, attachSymbol, gasPrice, gasLimit) {
23
+ // Attach must go through Nexus interop because it binds an already-created native token to a VM
24
+ // bundle. Runtime.DeployContract/UpgradeContract target a different lifecycle.
25
+ const resolvedGasPrice = normalizeLifecycleGas(gasPrice, phantasma_sdk_ts_1.ContractTxHelper.DefaultGasPrice, "gasPrice");
26
+ const resolvedGasLimit = normalizeLifecycleGas(gasLimit, phantasma_sdk_ts_1.ContractTxHelper.DefaultGasLimit, "gasLimit");
27
+ const nullAddress = new phantasma_sdk_ts_1.ScriptBuilder().NullAddress;
28
+ return new phantasma_sdk_ts_1.ScriptBuilder()
29
+ .BeginScript()
30
+ .AllowGas(fromAddress, nullAddress, resolvedGasPrice, resolvedGasLimit)
31
+ .CallInterop("Nexus.AttachTokenContract", [
32
+ fromAddress,
33
+ attachSymbol,
34
+ bundle.script,
35
+ bundle.abi,
36
+ ])
37
+ .SpendGas(fromAddress)
38
+ .EndScript();
39
+ }
40
+ function buildAndSignTransaction(options, keys, scriptHex) {
41
+ const nexus = options.nexus.trim();
42
+ const chain = (options.chain ?? "main").trim();
43
+ if (!nexus) {
44
+ throw new Error("nexus cannot be empty");
45
+ }
46
+ if (!chain) {
47
+ throw new Error("chain cannot be empty");
48
+ }
49
+ const payloadHex = options.payloadHex?.trim() ?? "";
50
+ const tx = new phantasma_sdk_ts_1.Transaction(nexus, chain, scriptHex, new Date(Date.now() + 5 * 60 * 1000), payloadHex);
51
+ const proofOfWork = options.proofOfWork ?? phantasma_sdk_ts_1.ProofOfWork.Minimal;
52
+ if (proofOfWork > 0) {
53
+ tx.mineTransaction(proofOfWork);
54
+ }
55
+ tx.signWithKeys(keys);
56
+ return tx.ToStringEncoded(true).toUpperCase();
57
+ }
8
58
  function prepareContractTransaction(options) {
9
59
  const keys = phantasma_sdk_ts_1.PhantasmaKeys.fromWIF(options.wif);
10
60
  const fromAddress = keys.Address.Text;
11
- const scriptHex = options.operation === "deploy"
12
- ? phantasma_sdk_ts_1.ContractTxHelper.buildDeployScriptFromBundle(options.bundle, fromAddress, options.gasPrice, options.gasLimit)
13
- : phantasma_sdk_ts_1.ContractTxHelper.buildUpgradeScriptFromBundle(options.bundle, fromAddress, options.gasPrice, options.gasLimit);
14
- const txHex = options.operation === "deploy"
15
- ? phantasma_sdk_ts_1.ContractTxHelper.buildDeployTransactionAndEncode({
16
- nexus: options.nexus,
17
- chain: options.chain,
18
- signer: keys,
19
- from: fromAddress,
20
- contractName: options.bundle.contractName,
21
- script: options.bundle.script,
22
- abi: options.bundle.abi,
23
- gasPrice: options.gasPrice,
24
- gasLimit: options.gasLimit,
25
- proofOfWork: options.proofOfWork,
26
- payloadHex: options.payloadHex,
27
- })
28
- : phantasma_sdk_ts_1.ContractTxHelper.buildUpgradeTransactionAndEncode({
29
- nexus: options.nexus,
30
- chain: options.chain,
31
- signer: keys,
32
- from: fromAddress,
33
- contractName: options.bundle.contractName,
34
- script: options.bundle.script,
35
- abi: options.bundle.abi,
36
- gasPrice: options.gasPrice,
37
- gasLimit: options.gasLimit,
38
- proofOfWork: options.proofOfWork,
39
- payloadHex: options.payloadHex,
40
- });
61
+ const attachSymbol = options.operation === "attach"
62
+ ? normalizeAttachSymbol(options.attachSymbol, options.bundle)
63
+ : undefined;
64
+ const scriptHex = options.operation === "attach"
65
+ ? buildAttachScript(options.bundle, fromAddress, attachSymbol, options.gasPrice, options.gasLimit)
66
+ : options.operation === "deploy"
67
+ ? phantasma_sdk_ts_1.ContractTxHelper.buildDeployScriptFromBundle(options.bundle, fromAddress, options.gasPrice, options.gasLimit)
68
+ : phantasma_sdk_ts_1.ContractTxHelper.buildUpgradeScriptFromBundle(options.bundle, fromAddress, options.gasPrice, options.gasLimit);
69
+ const txHex = options.operation === "attach"
70
+ ? buildAndSignTransaction(options, keys, scriptHex)
71
+ : options.operation === "deploy"
72
+ ? phantasma_sdk_ts_1.ContractTxHelper.buildDeployTransactionAndEncode({
73
+ nexus: options.nexus,
74
+ chain: options.chain,
75
+ signer: keys,
76
+ from: fromAddress,
77
+ contractName: options.bundle.contractName,
78
+ script: options.bundle.script,
79
+ abi: options.bundle.abi,
80
+ gasPrice: options.gasPrice,
81
+ gasLimit: options.gasLimit,
82
+ proofOfWork: options.proofOfWork,
83
+ payloadHex: options.payloadHex,
84
+ })
85
+ : phantasma_sdk_ts_1.ContractTxHelper.buildUpgradeTransactionAndEncode({
86
+ nexus: options.nexus,
87
+ chain: options.chain,
88
+ signer: keys,
89
+ from: fromAddress,
90
+ contractName: options.bundle.contractName,
91
+ script: options.bundle.script,
92
+ abi: options.bundle.abi,
93
+ gasPrice: options.gasPrice,
94
+ gasLimit: options.gasLimit,
95
+ proofOfWork: options.proofOfWork,
96
+ payloadHex: options.payloadHex,
97
+ });
41
98
  return {
42
99
  operation: options.operation,
43
100
  contractName: options.bundle.contractName,
@@ -46,6 +103,7 @@ function prepareContractTransaction(options) {
46
103
  txHex,
47
104
  scriptBytes: options.bundle.script.length,
48
105
  abiBytes: options.bundle.abi.length,
106
+ ...(attachSymbol ? { attachSymbol } : {}),
49
107
  };
50
108
  }
51
109
  async function executeContractTransaction(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/contract/deploy.ts"],"names":[],"mappings":";;AA4CA,gEA2DC;AAED,gEAoCC;AA7ID,uDAK0B;AAC1B,oDAAiD;AACjD,0C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YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACjE,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAS,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,KAAK;QACb,MAAM;QACN,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n ContractArtifactBundle,\n ContractTxHelper,\n PhantasmaAPI,\n PhantasmaKeys,\n} from \"phantasma-sdk-ts\";\nimport { waitForTx } from \"../actions/waitForTx\";\nimport { requireRpcTxHash } from \"../rpc/txHash\";\n\nexport type ContractOperation = \"deploy\" | \"upgrade\";\n\nexport interface PreparedContractTransaction {\n operation: ContractOperation;\n contractName: string;\n fromAddress: string;\n scriptHex: string;\n txHex: string;\n scriptBytes: number;\n abiBytes: number;\n}\n\nexport interface ExecuteContractTransactionOptions {\n operation: ContractOperation;\n rpc: string;\n nexus: string;\n chain?: string;\n wif: string;\n bundle: ContractArtifactBundle;\n gasPrice?: number;\n gasLimit?: number;\n proofOfWork?: number;\n payloadHex?: string;\n dryRun?: boolean;\n}\n\nexport interface ExecuteContractTransactionResult {\n prepared: PreparedContractTransaction;\n dryRun: boolean;\n txHash?: string;\n success?: boolean;\n result?: string;\n broadcastError?: string;\n}\n\nexport function prepareContractTransaction(\n options: ExecuteContractTransactionOptions,\n): PreparedContractTransaction {\n const keys = PhantasmaKeys.fromWIF(options.wif);\n const fromAddress = keys.Address.Text;\n\n const scriptHex =\n options.operation === \"deploy\"\n ? ContractTxHelper.buildDeployScriptFromBundle(\n options.bundle,\n fromAddress,\n options.gasPrice,\n options.gasLimit,\n )\n : ContractTxHelper.buildUpgradeScriptFromBundle(\n options.bundle,\n fromAddress,\n options.gasPrice,\n options.gasLimit,\n );\n\n const txHex =\n options.operation === \"deploy\"\n ? ContractTxHelper.buildDeployTransactionAndEncode({\n nexus: options.nexus,\n chain: options.chain,\n signer: keys,\n from: fromAddress,\n contractName: options.bundle.contractName,\n script: options.bundle.script,\n abi: options.bundle.abi,\n gasPrice: options.gasPrice,\n gasLimit: options.gasLimit,\n proofOfWork: options.proofOfWork,\n payloadHex: options.payloadHex,\n })\n : ContractTxHelper.buildUpgradeTransactionAndEncode({\n nexus: options.nexus,\n chain: options.chain,\n signer: keys,\n from: fromAddress,\n contractName: options.bundle.contractName,\n script: options.bundle.script,\n abi: options.bundle.abi,\n gasPrice: options.gasPrice,\n gasLimit: options.gasLimit,\n proofOfWork: options.proofOfWork,\n payloadHex: options.payloadHex,\n });\n\n return {\n operation: options.operation,\n contractName: options.bundle.contractName,\n fromAddress,\n scriptHex,\n txHex,\n scriptBytes: options.bundle.script.length,\n abiBytes: options.bundle.abi.length,\n };\n}\n\nexport async function executeContractTransaction(\n options: ExecuteContractTransactionOptions,\n): Promise<ExecuteContractTransactionResult> {\n const prepared = prepareContractTransaction(options);\n if (options.dryRun) {\n return {\n prepared,\n dryRun: true,\n };\n }\n\n const rpc = new PhantasmaAPI(options.rpc, null, options.nexus);\n let txHash: string;\n try {\n txHash = requireRpcTxHash(\n await rpc.sendRawTransaction(prepared.txHex),\n `${options.operation} transaction`,\n );\n } catch (err) {\n return {\n prepared,\n dryRun: false,\n success: false,\n result: \"\",\n broadcastError: err instanceof Error ? err.message : String(err),\n };\n }\n const waitResult = await waitForTx(rpc, txHash);\n\n return {\n prepared,\n dryRun: false,\n txHash,\n success: waitResult.success,\n result: waitResult.result,\n };\n}\n"]}
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/contract/deploy.ts"],"names":[],"mappings":";;AA0IA,gEA0EC;AAED,gEAoCC;AA1PD,uDAQ0B;AAC1B,oDAAiD;AACjD,0CAAiD;AAuCjD,SAAS,qBAAqB,CAC5B,eAAmC,EACnC,MAA8B;IA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,MAAM,GAAG,IAAA,yBAAgB,EACvB,MAAM,GAAG,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAC5C,GAAG,OAAO,CAAC,SAAS,cAAc,CACnC,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,KAAK;YACb,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,EAAE;YACV,cAAc,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACjE,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAS,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,QAAQ;QACR,MAAM,EAAE,KAAK;QACb,MAAM;QACN,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,MAAM,EAAE,UAAU,CAAC,MAAM;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import {\n ContractArtifactBundle,\n ContractTxHelper,\n ProofOfWork,\n PhantasmaAPI,\n PhantasmaKeys,\n ScriptBuilder,\n Transaction,\n} from \"phantasma-sdk-ts\";\nimport { waitForTx } from \"../actions/waitForTx\";\nimport { requireRpcTxHash } from \"../rpc/txHash\";\n\nexport type ContractOperation = \"deploy\" | \"upgrade\" | \"attach\";\n\nexport interface PreparedContractTransaction {\n operation: ContractOperation;\n contractName: string;\n fromAddress: string;\n scriptHex: string;\n txHex: string;\n scriptBytes: number;\n abiBytes: number;\n attachSymbol?: string;\n}\n\nexport interface ExecuteContractTransactionOptions {\n operation: ContractOperation;\n rpc: string;\n nexus: string;\n chain?: string;\n wif: string;\n bundle: ContractArtifactBundle;\n gasPrice?: number;\n gasLimit?: number;\n proofOfWork?: number;\n payloadHex?: string;\n dryRun?: boolean;\n attachSymbol?: string;\n}\n\nexport interface ExecuteContractTransactionResult {\n prepared: PreparedContractTransaction;\n dryRun: boolean;\n txHash?: string;\n success?: boolean;\n result?: string;\n broadcastError?: string;\n}\n\nfunction normalizeAttachSymbol(\n requestedSymbol: string | undefined,\n bundle: ContractArtifactBundle,\n): string {\n const attachSymbol = (requestedSymbol ?? bundle.contractName).trim();\n if (!attachSymbol) {\n throw new Error(\"attach symbol cannot be empty\");\n }\n\n return attachSymbol;\n}\n\nfunction normalizeLifecycleGas(\n value: number | undefined,\n fallback: number,\n label: string,\n): number {\n const numeric = value ?? fallback;\n if (!Number.isSafeInteger(numeric) || numeric <= 0) {\n throw new Error(`${label} must be a positive safe integer`);\n }\n\n return numeric;\n}\n\nfunction buildAttachScript(\n bundle: ContractArtifactBundle,\n fromAddress: string,\n attachSymbol: string,\n gasPrice?: number,\n gasLimit?: number,\n): string {\n // Attach must go through Nexus interop because it binds an already-created native token to a VM\n // bundle. Runtime.DeployContract/UpgradeContract target a different lifecycle.\n const resolvedGasPrice = normalizeLifecycleGas(\n gasPrice,\n ContractTxHelper.DefaultGasPrice,\n \"gasPrice\",\n );\n const resolvedGasLimit = normalizeLifecycleGas(\n gasLimit,\n ContractTxHelper.DefaultGasLimit,\n \"gasLimit\",\n );\n const nullAddress = new ScriptBuilder().NullAddress;\n\n return new ScriptBuilder()\n .BeginScript()\n .AllowGas(fromAddress, nullAddress, resolvedGasPrice, resolvedGasLimit)\n .CallInterop(\"Nexus.AttachTokenContract\", [\n fromAddress,\n attachSymbol,\n bundle.script,\n bundle.abi,\n ])\n .SpendGas(fromAddress)\n .EndScript();\n}\n\nfunction buildAndSignTransaction(\n options: ExecuteContractTransactionOptions,\n keys: PhantasmaKeys,\n scriptHex: string,\n): string {\n const nexus = options.nexus.trim();\n const chain = (options.chain ?? \"main\").trim();\n if (!nexus) {\n throw new Error(\"nexus cannot be empty\");\n }\n if (!chain) {\n throw new Error(\"chain cannot be empty\");\n }\n\n const payloadHex = options.payloadHex?.trim() ?? \"\";\n const tx = new Transaction(\n nexus,\n chain,\n scriptHex,\n new Date(Date.now() + 5 * 60 * 1000),\n payloadHex,\n );\n const proofOfWork = options.proofOfWork ?? ProofOfWork.Minimal;\n if (proofOfWork > 0) {\n tx.mineTransaction(proofOfWork);\n }\n tx.signWithKeys(keys);\n return tx.ToStringEncoded(true).toUpperCase();\n}\n\nexport function prepareContractTransaction(\n options: ExecuteContractTransactionOptions,\n): PreparedContractTransaction {\n const keys = PhantasmaKeys.fromWIF(options.wif);\n const fromAddress = keys.Address.Text;\n const attachSymbol =\n options.operation === \"attach\"\n ? normalizeAttachSymbol(options.attachSymbol, options.bundle)\n : undefined;\n\n const scriptHex =\n options.operation === \"attach\"\n ? buildAttachScript(\n options.bundle,\n fromAddress,\n attachSymbol as string,\n options.gasPrice,\n options.gasLimit,\n )\n : options.operation === \"deploy\"\n ? ContractTxHelper.buildDeployScriptFromBundle(\n options.bundle,\n fromAddress,\n options.gasPrice,\n options.gasLimit,\n )\n : ContractTxHelper.buildUpgradeScriptFromBundle(\n options.bundle,\n fromAddress,\n options.gasPrice,\n options.gasLimit,\n );\n\n const txHex =\n options.operation === \"attach\"\n ? buildAndSignTransaction(options, keys, scriptHex)\n : options.operation === \"deploy\"\n ? ContractTxHelper.buildDeployTransactionAndEncode({\n nexus: options.nexus,\n chain: options.chain,\n signer: keys,\n from: fromAddress,\n contractName: options.bundle.contractName,\n script: options.bundle.script,\n abi: options.bundle.abi,\n gasPrice: options.gasPrice,\n gasLimit: options.gasLimit,\n proofOfWork: options.proofOfWork,\n payloadHex: options.payloadHex,\n })\n : ContractTxHelper.buildUpgradeTransactionAndEncode({\n nexus: options.nexus,\n chain: options.chain,\n signer: keys,\n from: fromAddress,\n contractName: options.bundle.contractName,\n script: options.bundle.script,\n abi: options.bundle.abi,\n gasPrice: options.gasPrice,\n gasLimit: options.gasLimit,\n proofOfWork: options.proofOfWork,\n payloadHex: options.payloadHex,\n });\n\n return {\n operation: options.operation,\n contractName: options.bundle.contractName,\n fromAddress,\n scriptHex,\n txHex,\n scriptBytes: options.bundle.script.length,\n abiBytes: options.bundle.abi.length,\n ...(attachSymbol ? { attachSymbol } : {}),\n };\n}\n\nexport async function executeContractTransaction(\n options: ExecuteContractTransactionOptions,\n): Promise<ExecuteContractTransactionResult> {\n const prepared = prepareContractTransaction(options);\n if (options.dryRun) {\n return {\n prepared,\n dryRun: true,\n };\n }\n\n const rpc = new PhantasmaAPI(options.rpc, null, options.nexus);\n let txHash: string;\n try {\n txHash = requireRpcTxHash(\n await rpc.sendRawTransaction(prepared.txHex),\n `${options.operation} transaction`,\n );\n } catch (err) {\n return {\n prepared,\n dryRun: false,\n success: false,\n result: \"\",\n broadcastError: err instanceof Error ? err.message : String(err),\n };\n }\n const waitResult = await waitForTx(rpc, txHash);\n\n return {\n prepared,\n dryRun: false,\n txHash,\n success: waitResult.success,\n result: waitResult.result,\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pha-deploy",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "CLI for Phantasma token and contract lifecycle workflows",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",