pha-deploy 0.2.3 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"createSeries.js","sourceRoot":"","sources":["../../src/actions/createSeries.ts"],"names":[],"mappings":";;;AAyDA,oCA6DC;AAtHD,uDAa0B;AAC1B,2CAAwC;AACxC,uCAAmE;AAEnE,MAAa,eAAe;IAEjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVT,YACS,GAAW,EACX,KAAa,EACb,GAAW,EACX,aAAqB,EACrB,UAAkB,EAClB,uBAA+B,EAC/B,gBAAwB,EACxB,mBAA2B,EAC3B,YAA4B,EAC5B,cAA+B;QAT/B,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAQ;QACX,kBAAa,GAAb,aAAa,CAAQ;QACrB,eAAU,GAAV,UAAU,CAAQ;QAClB,4BAAuB,GAAvB,uBAAuB,CAAQ;QAC/B,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,wBAAmB,GAAnB,mBAAmB,CAAQ;QAC3B,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,mBAAc,GAAd,cAAc,CAAiB;QAEtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QACvD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc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V,GAAG,CAAC,mBAAmB,CACxB,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,IAAA,sBAAY,EAAC,6BAAU,CAAC,YAAY,CAAC,8BAAW,EAAE,IAAA,6BAAU,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAE3C,MAAM,GAAG,GAAG,IAAI,+BAAY,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAEvD,IAAI,MAAM,GAAG,MAAM,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEhC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAS,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEzD,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,QAAQ,GAAG,4CAAyB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import {\n Bytes32,\n CarbonBlob,\n CreateSeriesFeeOptions,\n CreateTokenSeriesTxHelper,\n MetadataField,\n PhantasmaAPI,\n PhantasmaKeys,\n SeriesInfoBuilder,\n SignedTxMsg,\n VmStructSchema,\n getRandomPhantasmaId,\n hexToBytes,\n} from \"phantasma-sdk-ts\";\nimport { waitForTx } from \"./waitForTx\";\nimport { bigintReplacer, Metadata, formatForLog } from \"./helpers\";\n\nexport class createSeriesCfg {\n constructor(\n public rpc: string,\n public nexus: string,\n public wif: string,\n public carbonTokenId: bigint,\n public gasFeeBase: bigint,\n public gasFeeCreateTokenSeries: bigint,\n public gasFeeMultiplier: bigint,\n public createSeriesMaxData: bigint,\n public seriesSchema: VmStructSchema,\n public seriesMetadata: MetadataField[]\n ) {\n this.rpc = rpc;\n this.nexus = nexus;\n this.wif = wif;\n this.carbonTokenId = carbonTokenId;\n this.gasFeeBase = gasFeeBase;\n this.gasFeeCreateTokenSeries = gasFeeCreateTokenSeries;\n this.gasFeeMultiplier = gasFeeMultiplier;\n this.createSeriesMaxData = createSeriesMaxData;\n this.seriesSchema = seriesSchema;\n this.seriesMetadata = seriesMetadata;\n }\n\n toPrintable() {\n // Do not leak WIF; derive owner\n const { wif: _omit, seriesMetadata: seriesMetadata, ...rest } = this; // rest has all public fields except wif/sharedRom\n const owner = PhantasmaKeys.fromWIF(this.wif).Address.toString();\n\n return {\n ...rest,\n owner,\n seriesMetadata\n };\n }\n}\n\n\n\nexport async function createSeries(\n cfg: createSeriesCfg,\n dryRun: boolean,\n logSettings: boolean = false,\n) {\n const txSender = PhantasmaKeys.fromWIF(cfg.wif);\n const senderPubKey = new Bytes32(txSender.PublicKey);\n\n const newPhantasmaSeriesId = await getRandomPhantasmaId();\n\n if (logSettings) {\n console.log(\n `Creating new series '${newPhantasmaSeriesId}' using these settings:`,\n JSON.stringify(cfg.toPrintable(), bigintReplacer, 2),\n );\n }\n\n const info = SeriesInfoBuilder.build(\n cfg.seriesSchema,\n newPhantasmaSeriesId,\n 0,\n 0,\n senderPubKey,\n cfg.seriesMetadata\n );\n\n const feeOptions = new CreateSeriesFeeOptions(\n cfg.gasFeeBase,\n cfg.gasFeeCreateTokenSeries,\n cfg.gasFeeMultiplier,\n );\n\n const tx = CreateTokenSeriesTxHelper.buildTxAndSignHex(\n cfg.carbonTokenId,\n info,\n txSender,\n feeOptions,\n cfg.createSeriesMaxData,\n );\n\n if (dryRun) {\n console.log(`[dry-run] Prepared tx (not sent): ${tx}`);\n console.log(formatForLog(CarbonBlob.NewFromBytes(SignedTxMsg, hexToBytes(tx), 0)));\n return;\n }\n\n console.log(\"Broadcasting transaction...\");\n\n const rpc = new PhantasmaAPI(cfg.rpc, null, cfg.nexus);\n\n let txHash = await rpc.sendCarbonTransaction(tx);\n console.log(\"txHash: \", txHash);\n\n const { success, result } = await waitForTx(rpc, txHash);\n\n if (success) {\n var seriesId = CreateTokenSeriesTxHelper.parseResult(result);\n console.log(\"Deployed carbon series ID:\", seriesId);\n } else {\n console.log(\"Could not deploy series\");\n }\n}\n"]}
1
+ {"version":3,"file":"createSeries.js","sourceRoot":"","sources":["../../src/actions/createSeries.ts"],"names":[],"mappings":";;;AAyDA,oCA+DC;AAxHD,uDAa0B;AAC1B,2CAAwC;AACxC,uCAAmE;AAEnE,MAAa,eAAe;IAEjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVT,YACS,GAAW,EACX,KAAa,EACb,GAAW,EACX,aAAqB,EACrB,UAAkB,EAClB,uBAA+B,EAC/B,gBAAwB,EACxB,mBAA2B,EAC3B,YAA4B,EAC5B,cAA+B;QAT/B,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAQ;QACX,kBAAa,GAAb,aAAa,CAAQ;QACrB,eAAU,GAAV,UAAU,CAAQ;QAClB,4BAAuB,GAAvB,uBAAuB,CAAQ;QAC/B,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,wBAAmB,GAAnB,mBAAmB,CAAQ;QAC3B,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,mBAAc,GAAd,cAAc,CAAiB;QAEtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,aAAa,GAAG,aAAa,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yB,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import {\n Bytes32,\n CarbonBlob,\n CreateSeriesFeeOptions,\n CreateTokenSeriesTxHelper,\n MetadataField,\n PhantasmaAPI,\n PhantasmaKeys,\n SeriesInfoBuilder,\n SignedTxMsg,\n VmStructSchema,\n getRandomPhantasmaId,\n hexToBytes,\n} from \"phantasma-sdk-ts\";\nimport { waitForTx } from \"./waitForTx\";\nimport { bigintReplacer, Metadata, formatForLog } from \"./helpers\";\n\nexport class createSeriesCfg {\n constructor(\n public rpc: string,\n public nexus: string,\n public wif: string,\n public carbonTokenId: bigint,\n public gasFeeBase: bigint,\n public gasFeeCreateTokenSeries: bigint,\n public gasFeeMultiplier: bigint,\n public createSeriesMaxData: bigint,\n public seriesSchema: VmStructSchema,\n public seriesMetadata: MetadataField[]\n ) {\n this.rpc = rpc;\n this.nexus = nexus;\n this.wif = wif;\n this.carbonTokenId = carbonTokenId;\n this.gasFeeBase = gasFeeBase;\n this.gasFeeCreateTokenSeries = gasFeeCreateTokenSeries;\n this.gasFeeMultiplier = gasFeeMultiplier;\n this.createSeriesMaxData = createSeriesMaxData;\n this.seriesSchema = seriesSchema;\n this.seriesMetadata = seriesMetadata;\n }\n\n toPrintable() {\n // Do not leak WIF; derive owner\n const { wif: _omit, seriesMetadata: seriesMetadata, ...rest } = this; // rest has all public fields except wif/sharedRom\n const owner = PhantasmaKeys.fromWIF(this.wif).Address.toString();\n\n return {\n ...rest,\n owner,\n seriesMetadata\n };\n }\n}\n\n\n\nexport async function createSeries(\n cfg: createSeriesCfg,\n dryRun: boolean,\n logSettings: boolean = false,\n) {\n const txSender = PhantasmaKeys.fromWIF(cfg.wif);\n const senderPubKey = new Bytes32(txSender.PublicKey);\n\n const newPhantasmaSeriesId = await getRandomPhantasmaId();\n\n if (logSettings) {\n console.log(\n `Creating new series '${newPhantasmaSeriesId}' using these settings:`,\n JSON.stringify(cfg.toPrintable(), bigintReplacer, 2),\n );\n }\n\n const info = SeriesInfoBuilder.build(\n cfg.seriesSchema,\n newPhantasmaSeriesId,\n 0,\n 0,\n senderPubKey,\n cfg.seriesMetadata\n );\n\n const feeOptions = new CreateSeriesFeeOptions(\n cfg.gasFeeBase,\n cfg.gasFeeCreateTokenSeries,\n cfg.gasFeeMultiplier,\n );\n\n const tx = CreateTokenSeriesTxHelper.buildTxAndSignHex(\n cfg.carbonTokenId,\n info,\n txSender,\n feeOptions,\n cfg.createSeriesMaxData,\n );\n\n if (dryRun) {\n console.log(`[dry-run] Prepared tx (not sent): ${tx}`);\n console.log(formatForLog(CarbonBlob.NewFromBytes(SignedTxMsg, hexToBytes(tx), 0)));\n return;\n }\n\n console.log(\"Broadcasting transaction...\");\n\n const rpc = new PhantasmaAPI(cfg.rpc, null, cfg.nexus);\n\n let txHash = await rpc.sendCarbonTransaction(tx);\n console.log(\"txHash: \", txHash);\n\n const { success, result } = await waitForTx(rpc, txHash);\n\n if (success) {\n var seriesId = CreateTokenSeriesTxHelper.parseResult(result);\n console.log(\n `Deployed series with phantasma ID ${newPhantasmaSeriesId.toString()} and carbon series ID ${seriesId}`,\n );\n } else {\n console.log(\"Could not deploy series\");\n }\n}\n"]}
@@ -4,13 +4,13 @@ export declare class mintNftTokenCfg {
4
4
  nexus: string;
5
5
  wif: string;
6
6
  carbonTokenId: bigint;
7
- carbonSeriesId: number;
7
+ phantasmaSeriesId: bigint;
8
8
  nftRomSchema: VmStructSchema;
9
9
  nftMetadata: MetadataField[];
10
10
  gasFeeBase: bigint;
11
11
  gasFeeMultiplier: bigint;
12
12
  mintTokenMaxData: bigint;
13
- constructor(rpc: string, nexus: string, wif: string, carbonTokenId: bigint, carbonSeriesId: number, nftRomSchema: VmStructSchema, nftMetadata: MetadataField[], gasFeeBase: bigint, gasFeeMultiplier: bigint, mintTokenMaxData: bigint);
13
+ constructor(rpc: string, nexus: string, wif: string, carbonTokenId: bigint, phantasmaSeriesId: bigint, nftRomSchema: VmStructSchema, nftMetadata: MetadataField[], gasFeeBase: bigint, gasFeeMultiplier: bigint, mintTokenMaxData: bigint);
14
14
  toPrintable(): Omit<this, "wif" | "toPrintable" | "nftMetadata"> & {
15
15
  owner: string;
16
16
  nftMetadata: MetadataField[];
@@ -1 +1 @@
1
- {"version":3,"file":"mintNftToken.d.ts","sourceRoot":"","sources":["../../src/actions/mintNftToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,cAAc,EACd,aAAa,EACd,MAAM,kBAAkB,CAAC;AAI1B,qBAAa,eAAe;IAEjB,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,aAAa,EAAE,MAAM;IACrB,cAAc,EAAE,MAAM;IACtB,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa,EAAE;IAC5B,UAAU,EAAE,MAAM;IAClB,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,MAAM;gBATxB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,cAAc,EAC5B,WAAW,EAAE,aAAa,EAAE,EAC5B,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM;IAcjC,WAAW;;;;CAYZ;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,OAAO,EACf,WAAW,GAAE,OAAe,iBA8D7B"}
1
+ {"version":3,"file":"mintNftToken.d.ts","sourceRoot":"","sources":["../../src/actions/mintNftToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,cAAc,EACd,aAAa,EACd,MAAM,kBAAkB,CAAC;AAkB1B,qBAAa,eAAe;IAEjB,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,MAAM;IACX,aAAa,EAAE,MAAM;IACrB,iBAAiB,EAAE,MAAM;IACzB,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa,EAAE;IAC5B,UAAU,EAAE,MAAM;IAClB,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,MAAM;gBATxB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,cAAc,EAC5B,WAAW,EAAE,aAAa,EAAE,EAC5B,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM;IAcjC,WAAW;;;;CAYZ;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,OAAO,EACf,WAAW,GAAE,OAAe,iBAkE7B"}
@@ -5,23 +5,34 @@ exports.mintNftToken = mintNftToken;
5
5
  const phantasma_sdk_ts_1 = require("phantasma-sdk-ts");
6
6
  const waitForTx_1 = require("./waitForTx");
7
7
  const helpers_1 = require("./helpers");
8
+ function bytes32HexToRpcDecimal(hex) {
9
+ if (hex.length === 0) {
10
+ return "0";
11
+ }
12
+ // RPC/public read paths interpret the raw Bytes32 `_i` word as an unsigned little-endian integer.
13
+ const littleEndianHex = Array.from((0, phantasma_sdk_ts_1.hexToBytes)(hex))
14
+ .reverse()
15
+ .map((b) => b.toString(16).padStart(2, "0"))
16
+ .join("");
17
+ return BigInt(`0x${littleEndianHex}`).toString();
18
+ }
8
19
  class mintNftTokenCfg {
9
20
  rpc;
10
21
  nexus;
11
22
  wif;
12
23
  carbonTokenId;
13
- carbonSeriesId;
24
+ phantasmaSeriesId;
14
25
  nftRomSchema;
15
26
  nftMetadata;
16
27
  gasFeeBase;
17
28
  gasFeeMultiplier;
18
29
  mintTokenMaxData;
19
- constructor(rpc, nexus, wif, carbonTokenId, carbonSeriesId, nftRomSchema, nftMetadata, gasFeeBase, gasFeeMultiplier, mintTokenMaxData) {
30
+ constructor(rpc, nexus, wif, carbonTokenId, phantasmaSeriesId, nftRomSchema, nftMetadata, gasFeeBase, gasFeeMultiplier, mintTokenMaxData) {
20
31
  this.rpc = rpc;
21
32
  this.nexus = nexus;
22
33
  this.wif = wif;
23
34
  this.carbonTokenId = carbonTokenId;
24
- this.carbonSeriesId = carbonSeriesId;
35
+ this.phantasmaSeriesId = phantasmaSeriesId;
25
36
  this.nftRomSchema = nftRomSchema;
26
37
  this.nftMetadata = nftMetadata;
27
38
  this.gasFeeBase = gasFeeBase;
@@ -31,7 +42,7 @@ class mintNftTokenCfg {
31
42
  this.nexus = nexus;
32
43
  this.wif = wif;
33
44
  this.carbonTokenId = carbonTokenId;
34
- this.carbonSeriesId = carbonSeriesId;
45
+ this.phantasmaSeriesId = phantasmaSeriesId;
35
46
  this.nftRomSchema = nftRomSchema;
36
47
  this.nftMetadata = nftMetadata;
37
48
  this.gasFeeBase = gasFeeBase;
@@ -53,13 +64,12 @@ exports.mintNftTokenCfg = mintNftTokenCfg;
53
64
  async function mintNftToken(cfg, dryRun, logSettings = false) {
54
65
  const txSender = phantasma_sdk_ts_1.PhantasmaKeys.fromWIF(cfg.wif);
55
66
  const senderPubKey = new phantasma_sdk_ts_1.Bytes32(txSender.PublicKey);
56
- const newPhantasmaNftId = await (0, phantasma_sdk_ts_1.getRandomPhantasmaId)();
57
67
  if (logSettings) {
58
- console.log(`Minting new token '${newPhantasmaNftId}' using these settings:`, JSON.stringify(cfg.toPrintable(), helpers_1.bigintReplacer, 2));
68
+ console.log("Minting NFT through deterministic chain-generated id flow using these settings:", JSON.stringify(cfg.toPrintable(), helpers_1.bigintReplacer, 2));
59
69
  }
60
- const rom = phantasma_sdk_ts_1.NftRomBuilder.buildAndSerialize(cfg.nftRomSchema, newPhantasmaNftId, cfg.nftMetadata);
70
+ const rom = phantasma_sdk_ts_1.PhantasmaNftRomBuilder.buildAndSerialize(cfg.nftRomSchema, cfg.nftMetadata);
61
71
  const feeOptions = new phantasma_sdk_ts_1.MintNftFeeOptions(cfg.gasFeeBase, cfg.gasFeeMultiplier);
62
- const tx = phantasma_sdk_ts_1.MintNonFungibleTxHelper.buildTxAndSignHex(cfg.carbonTokenId, cfg.carbonSeriesId, txSender, senderPubKey, rom, new Uint8Array(), feeOptions, cfg.mintTokenMaxData);
72
+ const tx = phantasma_sdk_ts_1.MintPhantasmaNonFungibleTxHelper.buildTxAndSignHex(cfg.carbonTokenId, cfg.phantasmaSeriesId, txSender, senderPubKey, rom, new Uint8Array(), feeOptions, cfg.mintTokenMaxData);
63
73
  if (dryRun) {
64
74
  console.log(`[dry-run] Prepared tx (not sent): ${tx}`);
65
75
  console.log((0, helpers_1.formatForLog)(phantasma_sdk_ts_1.CarbonBlob.NewFromBytes(phantasma_sdk_ts_1.SignedTxMsg, (0, phantasma_sdk_ts_1.hexToBytes)(tx), 0)));
@@ -71,8 +81,14 @@ async function mintNftToken(cfg, dryRun, logSettings = false) {
71
81
  console.log("txHash: ", txHash);
72
82
  const { success, result } = await (0, waitForTx_1.waitForTx)(rpc, txHash);
73
83
  if (success) {
74
- const carbonNftAddresses = phantasma_sdk_ts_1.MintNonFungibleTxHelper.parseResult(cfg.carbonTokenId, result);
75
- console.log(`Deployed NFT with phantasma ID ${newPhantasmaNftId} and carbon NFT address ${carbonNftAddresses[0].ToHex()}`);
84
+ const mintResults = phantasma_sdk_ts_1.MintPhantasmaNonFungibleTxHelper.parseResult(result);
85
+ if (mintResults.length === 0) {
86
+ throw new Error("Deterministic mint result is empty");
87
+ }
88
+ const carbonNftAddress = phantasma_sdk_ts_1.TokenHelper.getNftAddress(cfg.carbonTokenId, mintResults[0].carbonInstanceId);
89
+ const mintedPhantasmaNftIdHex = mintResults[0].phantasmaNftId.ToHex();
90
+ const mintedPhantasmaNftId = bytes32HexToRpcDecimal(mintedPhantasmaNftIdHex);
91
+ console.log(`Minted NFT with phantasma ID ${mintedPhantasmaNftId} (0x${mintedPhantasmaNftIdHex}) and carbon NFT address ${carbonNftAddress.ToHex()}`);
76
92
  }
77
93
  else {
78
94
  console.log("Could not mint NFT");
@@ -1 +1 @@
1
- {"version":3,"file":"mintNftToken.js","sourceRoot":"","sources":["../../src/actions/mintNftToken.ts"],"names":[],"mappings":";;;AAwDA,oCAiEC;AAzHD,uDAa0B;AAC1B,2CAAwC;AACxC,uCAAyD;AAEzD,MAAa,eAAe;IAEjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVT,YACS,GAAW,EACX,KAAa,EACb,GAAW,EACX,aAAqB,EACrB,cAAsB,EACtB,YAA4B,EAC5B,WAA4B,EAC5B,UAAkB,EAClB,gBAAwB,EACxB,gBAAwB;QATxB,QAAG,GAAH,GAAG,CAAQ;QACX,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAQ;QACX,kBAAa,GAAb,aAAa,CAAQ;QACrB,mBAAc,GAAd,cAAc,CAAQ;QACtB,iBAAY,GAAZ,YAAY,CAAgB;QAC5B,gBAAW,GAAX,WAAW,CAAiB;QAC5B,eAAU,GAAV,UAAU,CAAQ;QAClB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAE/B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAED,WAAW;QACT,gCAAgC;QAChC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE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AqC,EAAE,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,IAAA,sBAAY,EAAC,6BAAU,CAAC,YAAY,CAAC,8BAAW,EAAE,IAAA,6BAAU,EAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,OAAO;IACT,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAE3C,MAAM,GAAG,GAAG,IAAI,+BAAY,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAEvD,IAAI,MAAM,GAAG,MAAM,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEhC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAS,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEzD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,kBAAkB,GAAG,0CAAuB,CAAC,WAAW,CAC5D,GAAG,CAAC,aAAa,EACjB,MAAM,CACP,CAAC;QACF,OAAO,CAAC,GAAG,CACT,kCAAkC,iBAAiB,2BAA2B,kBAAkB,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAC9G,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["import {\n Bytes32,\n CarbonBlob,\n hexToBytes,\n getRandomPhantasmaId,\n MintNftFeeOptions,\n MintNonFungibleTxHelper,\n NftRomBuilder,\n PhantasmaAPI,\n PhantasmaKeys,\n SignedTxMsg,\n VmStructSchema,\n MetadataField,\n} from \"phantasma-sdk-ts\";\nimport { waitForTx } from \"./waitForTx\";\nimport { bigintReplacer, formatForLog } from \"./helpers\";\n\nexport class mintNftTokenCfg {\n constructor(\n public rpc: string,\n public nexus: string,\n public wif: string,\n public carbonTokenId: bigint,\n public carbonSeriesId: number,\n public nftRomSchema: VmStructSchema,\n public nftMetadata: MetadataField[],\n public gasFeeBase: bigint,\n public gasFeeMultiplier: bigint,\n public mintTokenMaxData: bigint,\n ) {\n this.rpc = rpc;\n this.nexus = nexus;\n this.wif = wif;\n this.carbonTokenId = carbonTokenId;\n this.carbonSeriesId = carbonSeriesId;\n this.nftRomSchema = nftRomSchema;\n this.nftMetadata = nftMetadata;\n this.gasFeeBase = gasFeeBase;\n this.gasFeeMultiplier = gasFeeMultiplier;\n this.mintTokenMaxData = mintTokenMaxData;\n }\n\n toPrintable() {\n // Do not leak WIF; derive owner\n const { wif: _omit, nftMetadata, ...rest } =\n this; // rest has all public fields except wif/metadata strings\n const owner = PhantasmaKeys.fromWIF(this.wif).Address.toString();\n\n return {\n ...rest,\n owner,\n nftMetadata\n };\n }\n}\n\nexport async function mintNftToken(\n cfg: mintNftTokenCfg,\n dryRun: boolean,\n logSettings: boolean = false,\n) {\n const txSender = PhantasmaKeys.fromWIF(cfg.wif);\n const senderPubKey = new Bytes32(txSender.PublicKey);\n\n const newPhantasmaNftId = await getRandomPhantasmaId();\n\n if (logSettings) {\n console.log(\n `Minting new token '${newPhantasmaNftId}' using these settings:`,\n JSON.stringify(cfg.toPrintable(), bigintReplacer, 2),\n );\n }\n\n const rom = NftRomBuilder.buildAndSerialize(\n cfg.nftRomSchema,\n newPhantasmaNftId,\n cfg.nftMetadata\n );\n\n const feeOptions = new MintNftFeeOptions(\n cfg.gasFeeBase,\n cfg.gasFeeMultiplier,\n );\n\n const tx = MintNonFungibleTxHelper.buildTxAndSignHex(\n cfg.carbonTokenId,\n cfg.carbonSeriesId,\n txSender,\n senderPubKey,\n rom,\n new Uint8Array(),\n feeOptions,\n cfg.mintTokenMaxData,\n );\n\n if (dryRun) {\n console.log(`[dry-run] Prepared tx (not sent): ${tx}`);\n console.log(formatForLog(CarbonBlob.NewFromBytes(SignedTxMsg, hexToBytes(tx), 0)));\n return;\n }\n\n console.log(\"Broadcasting transaction...\");\n\n const rpc = new PhantasmaAPI(cfg.rpc, null, cfg.nexus);\n\n let txHash = await rpc.sendCarbonTransaction(tx);\n console.log(\"txHash: \", txHash);\n\n const { success, result } = await waitForTx(rpc, txHash);\n\n if (success) {\n const carbonNftAddresses = MintNonFungibleTxHelper.parseResult(\n cfg.carbonTokenId,\n result,\n );\n console.log(\n `Deployed NFT with phantasma ID ${newPhantasmaNftId} and carbon NFT address ${carbonNftAddresses[0].ToHex()}`,\n );\n } else {\n console.log(\"Could not mint NFT\");\n }\n}\n"]}
1
+ {"version":3,"file":"mintNftToken.js","sourceRoot":"","sources":["../../src/actions/mintNftToken.ts"],"names":[],"mappings":";;;AAsEA,oCAqEC;AA3ID,uDAa0B;AAC1B,2CAAwC;AACxC,uCAAyD;AAEzD,SAAS,sBAAsB,CAAC,GAAW;IACzC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,kGAAkG;IAClG,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,IAAA,6BAAU,EAAC,GAAG,CAAC,CAAC;SAChD,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SAC3C,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,OAAO,MAAM,CAAC,KAAK,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AACnD,CAAC;AAED,MAAa,eAAe;IAEjB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAVT,YACS,GAAW,EACX,KAAa,EACb,GAAW,EACX,aAAqB,EACrB,iBAAyB,EACzB,YAA4B,EAC5B,WAA4B,EAC5B,UAAkB,EAClB,gBAAwB,EACxB,gBAAwB;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AAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEhC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAS,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEzD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,mDAAgC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,gBAAgB,GAAG,8BAAW,CAAC,aAAa,CAChD,GAAG,CAAC,aAAa,EACjB,WAAW,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAChC,CAAC;QACF,MAAM,uBAAuB,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QACtE,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,uBAAuB,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,CACT,gCAAgC,oBAAoB,OAAO,uBAAuB,4BAA4B,gBAAgB,CAAC,KAAK,EAAE,EAAE,CACzI,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACpC,CAAC;AACH,CAAC","sourcesContent":["import {\n Bytes32,\n CarbonBlob,\n hexToBytes,\n MintNftFeeOptions,\n MintPhantasmaNonFungibleTxHelper,\n PhantasmaAPI,\n PhantasmaNftRomBuilder,\n PhantasmaKeys,\n SignedTxMsg,\n TokenHelper,\n VmStructSchema,\n MetadataField,\n} from \"phantasma-sdk-ts\";\nimport { waitForTx } from \"./waitForTx\";\nimport { bigintReplacer, formatForLog } from \"./helpers\";\n\nfunction bytes32HexToRpcDecimal(hex: string): string {\n if (hex.length === 0) {\n return \"0\";\n }\n\n // RPC/public read paths interpret the raw Bytes32 `_i` word as an unsigned little-endian integer.\n const littleEndianHex = Array.from(hexToBytes(hex))\n .reverse()\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n\n return BigInt(`0x${littleEndianHex}`).toString();\n}\n\nexport class mintNftTokenCfg {\n constructor(\n public rpc: string,\n public nexus: string,\n public wif: string,\n public carbonTokenId: bigint,\n public phantasmaSeriesId: bigint,\n public nftRomSchema: VmStructSchema,\n public nftMetadata: MetadataField[],\n public gasFeeBase: bigint,\n public gasFeeMultiplier: bigint,\n public mintTokenMaxData: bigint,\n ) {\n this.rpc = rpc;\n this.nexus = nexus;\n this.wif = wif;\n this.carbonTokenId = carbonTokenId;\n this.phantasmaSeriesId = phantasmaSeriesId;\n this.nftRomSchema = nftRomSchema;\n this.nftMetadata = nftMetadata;\n this.gasFeeBase = gasFeeBase;\n this.gasFeeMultiplier = gasFeeMultiplier;\n this.mintTokenMaxData = mintTokenMaxData;\n }\n\n toPrintable() {\n // Do not leak WIF; derive owner\n const { wif: _omit, nftMetadata, ...rest } =\n this; // rest has all public fields except wif/metadata strings\n const owner = PhantasmaKeys.fromWIF(this.wif).Address.toString();\n\n return {\n ...rest,\n owner,\n nftMetadata\n };\n }\n}\n\nexport async function mintNftToken(\n cfg: mintNftTokenCfg,\n dryRun: boolean,\n logSettings: boolean = false,\n) {\n const txSender = PhantasmaKeys.fromWIF(cfg.wif);\n const senderPubKey = new Bytes32(txSender.PublicKey);\n\n if (logSettings) {\n console.log(\n \"Minting NFT through deterministic chain-generated id flow using these settings:\",\n JSON.stringify(cfg.toPrintable(), bigintReplacer, 2),\n );\n }\n\n const rom = PhantasmaNftRomBuilder.buildAndSerialize(\n cfg.nftRomSchema,\n cfg.nftMetadata\n );\n\n const feeOptions = new MintNftFeeOptions(\n cfg.gasFeeBase,\n cfg.gasFeeMultiplier,\n );\n\n const tx = MintPhantasmaNonFungibleTxHelper.buildTxAndSignHex(\n cfg.carbonTokenId,\n cfg.phantasmaSeriesId,\n txSender,\n senderPubKey,\n rom,\n new Uint8Array(),\n feeOptions,\n cfg.mintTokenMaxData,\n );\n\n if (dryRun) {\n console.log(`[dry-run] Prepared tx (not sent): ${tx}`);\n console.log(formatForLog(CarbonBlob.NewFromBytes(SignedTxMsg, hexToBytes(tx), 0)));\n return;\n }\n\n console.log(\"Broadcasting transaction...\");\n\n const rpc = new PhantasmaAPI(cfg.rpc, null, cfg.nexus);\n\n let txHash = await rpc.sendCarbonTransaction(tx);\n console.log(\"txHash: \", txHash);\n\n const { success, result } = await waitForTx(rpc, txHash);\n\n if (success) {\n const mintResults = MintPhantasmaNonFungibleTxHelper.parseResult(result);\n if (mintResults.length === 0) {\n throw new Error(\"Deterministic mint result is empty\");\n }\n\n const carbonNftAddress = TokenHelper.getNftAddress(\n cfg.carbonTokenId,\n mintResults[0].carbonInstanceId,\n );\n const mintedPhantasmaNftIdHex = mintResults[0].phantasmaNftId.ToHex();\n const mintedPhantasmaNftId = bytes32HexToRpcDecimal(mintedPhantasmaNftIdHex);\n console.log(\n `Minted NFT with phantasma ID ${mintedPhantasmaNftId} (0x${mintedPhantasmaNftIdHex}) and carbon NFT address ${carbonNftAddress.ToHex()}`,\n );\n } else {\n console.log(\"Could not mint NFT\");\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function runContractCli(rawArgv: string[]): Promise<void>;
2
+ //# sourceMappingURL=cli-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-contract.d.ts","sourceRoot":"","sources":["../src/cli-contract.ts"],"names":[],"mappings":"AA0LA,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoIrE"}
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runContractCli = runContractCli;
7
+ const promises_1 = __importDefault(require("node:fs/promises"));
8
+ const node_os_1 = __importDefault(require("node:os"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const yargs_1 = __importDefault(require("yargs/yargs"));
11
+ const compiler_1 = require("./contract/compiler");
12
+ const artifacts_1 = require("./contract/artifacts");
13
+ const deploy_1 = require("./contract/deploy");
14
+ function printIndentedBlock(title, content) {
15
+ console.log(`${title}:`);
16
+ const trimmed = content.trimEnd();
17
+ if (!trimmed) {
18
+ console.log(" (empty)");
19
+ return;
20
+ }
21
+ for (const line of trimmed.split(/\r?\n/)) {
22
+ console.log(` ${line}`);
23
+ }
24
+ }
25
+ function printCompileTranscript(result) {
26
+ console.log("Compiler command:");
27
+ console.log(` ${result.command} ${result.args.join(" ")}`);
28
+ console.log(`Compiler cwd:`);
29
+ console.log(` ${result.cwd}`);
30
+ printIndentedBlock(`${compiler_1.CONTRACT_COMPILER_NAME} stdout`, result.stdout);
31
+ printIndentedBlock(`${compiler_1.CONTRACT_COMPILER_NAME} stderr`, result.stderr);
32
+ }
33
+ function parseOptionalInteger(value, flagName) {
34
+ if (value === undefined) {
35
+ return undefined;
36
+ }
37
+ const parsed = Number(value);
38
+ if (!Number.isSafeInteger(parsed) || parsed <= 0) {
39
+ throw new Error(`${flagName} must be a positive integer`);
40
+ }
41
+ return parsed;
42
+ }
43
+ async function handleContractCompile(argv) {
44
+ const compiler = await (0, compiler_1.resolveSupportedCompiler)(compiler_1.MIN_SUPPORTED_PHA_TOMB_VERSION);
45
+ const sourcePath = node_path_1.default.resolve(argv.source);
46
+ const preferredContractName = argv.contractName?.trim() || node_path_1.default.basename(sourcePath, node_path_1.default.extname(sourcePath));
47
+ const outputDir = node_path_1.default.resolve(argv.out ?? node_path_1.default.join(process.cwd(), "dist", "contracts", preferredContractName));
48
+ const tempRoot = await promises_1.default.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), "pha-deploy-compile-"));
49
+ try {
50
+ const compileArgs = (0, compiler_1.buildCompileArgs)({
51
+ sourcePath,
52
+ outputRoot: tempRoot,
53
+ libPaths: argv.libpath,
54
+ protocol: argv.protocol,
55
+ debug: argv.debug,
56
+ nativeCheck: argv.nativeCheck,
57
+ });
58
+ const result = await (0, compiler_1.runCompiler)(compiler.executablePath, compileArgs, process.cwd());
59
+ printCompileTranscript(result);
60
+ if (result.exitCode !== 0) {
61
+ throw new Error(`${compiler_1.CONTRACT_COMPILER_NAME} exited with code ${result.exitCode}`);
62
+ }
63
+ const compiled = (0, compiler_1.selectCompiledContractArtifacts)(node_path_1.default.join(tempRoot, "Output"), preferredContractName);
64
+ const materialized = (0, artifacts_1.materializeCompiledArtifacts)({
65
+ compiled,
66
+ outputDir,
67
+ compilerName: compiler.executableName,
68
+ compilerVersion: compiler.version,
69
+ sourceFileName: sourcePath,
70
+ });
71
+ console.log("Artifacts:");
72
+ console.log(` contract: ${materialized.bundle.contractName}`);
73
+ console.log(` output: ${materialized.outputDir}`);
74
+ console.log(` manifest: ${materialized.manifestPath}`);
75
+ console.log(` script: ${materialized.scriptPath}`);
76
+ console.log(` abi: ${materialized.abiPath}`);
77
+ if (materialized.debugPath) {
78
+ console.log(` debug: ${materialized.debugPath}`);
79
+ }
80
+ if (materialized.asmPath) {
81
+ console.log(` asm: ${materialized.asmPath}`);
82
+ }
83
+ if (materialized.scriptHexPath) {
84
+ console.log(` script hex: ${materialized.scriptHexPath}`);
85
+ }
86
+ if (materialized.abiHexPath) {
87
+ console.log(` abi hex: ${materialized.abiHexPath}`);
88
+ }
89
+ }
90
+ finally {
91
+ await promises_1.default.rm(tempRoot, { recursive: true, force: true });
92
+ }
93
+ }
94
+ async function handleContractBroadcast(operation, argv) {
95
+ const artifacts = argv.manifest
96
+ ? (0, artifacts_1.loadContractArtifactsFromManifest)(argv.manifest)
97
+ : (0, artifacts_1.loadContractArtifactsFromPaths)({
98
+ contractName: argv.contractName ?? "",
99
+ scriptPath: argv.script ?? "",
100
+ abiPath: argv.abi ?? "",
101
+ ...(argv.debug ? { debugPath: argv.debug } : {}),
102
+ });
103
+ const result = await (0, deploy_1.executeContractTransaction)({
104
+ operation,
105
+ rpc: argv.rpc,
106
+ nexus: argv.nexus,
107
+ chain: argv.chain,
108
+ wif: argv.wif,
109
+ bundle: artifacts.bundle,
110
+ gasPrice: parseOptionalInteger(argv.gasPrice, "--gas-price"),
111
+ gasLimit: parseOptionalInteger(argv.gasLimit, "--gas-limit"),
112
+ proofOfWork: parseOptionalInteger(argv.pow, "--pow"),
113
+ payloadHex: argv.payloadHex,
114
+ dryRun: argv.dryRun,
115
+ });
116
+ console.log("Transaction:");
117
+ console.log(` operation: ${result.prepared.operation}`);
118
+ console.log(` contract: ${result.prepared.contractName}`);
119
+ console.log(` from: ${result.prepared.fromAddress}`);
120
+ console.log(` script bytes: ${result.prepared.scriptBytes}`);
121
+ console.log(` abi bytes: ${result.prepared.abiBytes}`);
122
+ console.log(` vm script: ${result.prepared.scriptHex}`);
123
+ console.log(` signed tx: ${result.prepared.txHex}`);
124
+ if (result.dryRun) {
125
+ console.log("Dry-run complete: transaction was not broadcast.");
126
+ return;
127
+ }
128
+ console.log(` tx hash: ${result.txHash ?? ""}`);
129
+ if (!result.success) {
130
+ throw new Error(`${operation} transaction failed${result.txHash ? ` (txHash: ${result.txHash})` : ""}`);
131
+ }
132
+ }
133
+ async function runContractCli(rawArgv) {
134
+ const parser = (0, yargs_1.default)(rawArgv)
135
+ .scriptName("pha-deploy contract")
136
+ .command("compile", "Compile a contract through the system-installed pha-tomb", (cmd) => cmd
137
+ .option("source", {
138
+ type: "string",
139
+ demandOption: true,
140
+ describe: "Path to the .tomb source file",
141
+ })
142
+ .option("out", {
143
+ type: "string",
144
+ describe: "Output directory for the final artifact bundle",
145
+ })
146
+ .option("contract-name", {
147
+ type: "string",
148
+ describe: "Expected contract artifact name when the compiler emits multiple modules",
149
+ })
150
+ .option("protocol", {
151
+ type: "number",
152
+ describe: "Target protocol version passed to pha-tomb",
153
+ })
154
+ .option("debug", {
155
+ type: "boolean",
156
+ describe: "Request debug artifacts from pha-tomb",
157
+ })
158
+ .option("nativecheck", {
159
+ type: "string",
160
+ choices: ["off", "warn", "error"],
161
+ describe: "Native/foundational interop diagnostics mode",
162
+ })
163
+ .option("libpath", {
164
+ type: "string",
165
+ array: true,
166
+ describe: "Additional library search path(s) passed to pha-tomb",
167
+ }), async (argv) => {
168
+ await handleContractCompile({
169
+ source: argv.source,
170
+ out: argv.out,
171
+ contractName: argv["contract-name"],
172
+ protocol: argv.protocol,
173
+ debug: argv.debug,
174
+ nativeCheck: argv.nativecheck,
175
+ libpath: argv.libpath,
176
+ });
177
+ })
178
+ .command("deploy", "Deploy a compiled contract artifact bundle", (cmd) => cmd
179
+ .option("rpc", { type: "string", demandOption: true, describe: "RPC endpoint" })
180
+ .option("nexus", { type: "string", demandOption: true, describe: "Nexus name" })
181
+ .option("chain", { type: "string", default: "main", describe: "Target chain" })
182
+ .option("wif", { type: "string", demandOption: true, describe: "WIF used to sign the transaction" })
183
+ .option("manifest", { type: "string", describe: "Path to manifest.json produced by contract compile" })
184
+ .option("contract-name", { type: "string", describe: "Contract name when using direct --script/--abi inputs" })
185
+ .option("script", { type: "string", describe: "Path to compiled .pvm file when not using --manifest" })
186
+ .option("abi", { type: "string", describe: "Path to compiled .abi file when not using --manifest" })
187
+ .option("debug", { type: "string", describe: "Optional path to .debug file when not using --manifest" })
188
+ .option("gas-price", { type: "number", describe: "Gas price passed to AllowGas" })
189
+ .option("gas-limit", { type: "number", describe: "Gas limit passed to AllowGas" })
190
+ .option("pow", { type: "number", describe: "Proof-of-work difficulty for the legacy VM transaction" })
191
+ .option("payload-hex", { type: "string", describe: "Optional transaction payload as raw hex" })
192
+ .option("dry-run", { type: "boolean", describe: "Build and sign the transaction without broadcasting" }), async (argv) => {
193
+ await handleContractBroadcast("deploy", {
194
+ rpc: argv.rpc,
195
+ nexus: argv.nexus,
196
+ chain: argv.chain,
197
+ wif: argv.wif,
198
+ manifest: argv.manifest,
199
+ contractName: argv["contract-name"],
200
+ script: argv.script,
201
+ abi: argv.abi,
202
+ debug: argv.debug,
203
+ gasPrice: argv["gas-price"],
204
+ gasLimit: argv["gas-limit"],
205
+ pow: argv.pow,
206
+ payloadHex: argv["payload-hex"],
207
+ dryRun: argv["dry-run"],
208
+ });
209
+ })
210
+ .command("upgrade", "Upgrade an already deployed contract artifact bundle", (cmd) => cmd
211
+ .option("rpc", { type: "string", demandOption: true, describe: "RPC endpoint" })
212
+ .option("nexus", { type: "string", demandOption: true, describe: "Nexus name" })
213
+ .option("chain", { type: "string", default: "main", describe: "Target chain" })
214
+ .option("wif", { type: "string", demandOption: true, describe: "WIF used to sign the transaction" })
215
+ .option("manifest", { type: "string", describe: "Path to manifest.json produced by contract compile" })
216
+ .option("contract-name", { type: "string", describe: "Contract name when using direct --script/--abi inputs" })
217
+ .option("script", { type: "string", describe: "Path to compiled .pvm file when not using --manifest" })
218
+ .option("abi", { type: "string", describe: "Path to compiled .abi file when not using --manifest" })
219
+ .option("debug", { type: "string", describe: "Optional path to .debug file when not using --manifest" })
220
+ .option("gas-price", { type: "number", describe: "Gas price passed to AllowGas" })
221
+ .option("gas-limit", { type: "number", describe: "Gas limit passed to AllowGas" })
222
+ .option("pow", { type: "number", describe: "Proof-of-work difficulty for the legacy VM transaction" })
223
+ .option("payload-hex", { type: "string", describe: "Optional transaction payload as raw hex" })
224
+ .option("dry-run", { type: "boolean", describe: "Build and sign the transaction without broadcasting" }), async (argv) => {
225
+ await handleContractBroadcast("upgrade", {
226
+ rpc: argv.rpc,
227
+ nexus: argv.nexus,
228
+ chain: argv.chain,
229
+ wif: argv.wif,
230
+ manifest: argv.manifest,
231
+ contractName: argv["contract-name"],
232
+ script: argv.script,
233
+ abi: argv.abi,
234
+ debug: argv.debug,
235
+ gasPrice: argv["gas-price"],
236
+ gasLimit: argv["gas-limit"],
237
+ pow: argv.pow,
238
+ payloadHex: argv["payload-hex"],
239
+ dryRun: argv["dry-run"],
240
+ });
241
+ })
242
+ .demandCommand(1)
243
+ .strict()
244
+ .help();
245
+ await parser.parseAsync();
246
+ }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AAE,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,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.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"]}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA+OA,iBAAe,IAAI,kBAqJlB;AAcD,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAqPA,iBAAe,IAAI,kBA+JlB;AAcD,eAAe,IAAI,CAAC"}
package/dist/cli.js CHANGED
@@ -13,6 +13,8 @@ const createSeries_1 = require("./actions/createSeries");
13
13
  const mintFungibleToken_1 = require("./actions/mintFungibleToken");
14
14
  const mintNftToken_1 = require("./actions/mintNftToken");
15
15
  const phantasma_sdk_ts_1 = require("phantasma-sdk-ts");
16
+ const cli_contract_1 = require("./cli-contract");
17
+ const version_1 = require("./version");
16
18
  /**
17
19
  * CLI for pha-deploy.
18
20
  *
@@ -28,12 +30,16 @@ const phantasma_sdk_ts_1 = require("phantasma-sdk-ts");
28
30
  */
29
31
  function printHelp() {
30
32
  const text = `Usage:
33
+ pha-deploy contract <compile|deploy|upgrade> [options]
31
34
  pha-deploy --create-token [options]
32
35
  pha-deploy --create-series [options]
33
36
  pha-deploy --mint-fungible [options]
34
37
  pha-deploy --mint-nft [options]
35
38
 
36
39
  Actions:
40
+ contract compile Compile a contract through the system-installed pha-tomb
41
+ contract deploy Deploy a compiled contract bundle
42
+ contract upgrade Upgrade a compiled contract bundle
37
43
  --create-token Create a token
38
44
  --create-series Create a token series
39
45
  --mint-fungible Mint fungible tokens
@@ -57,7 +63,7 @@ Overrides (replace values from config.toml when provided):
57
63
  --fungible-max-supply <int> Alias for --token-max-supply
58
64
  --fungible-decimals <0..255> Decimal places; required when token-type=fungible
59
65
  --carbon-token-id <int> Existing carbon token ID (for series or mint)
60
- --carbon-token-series-id <int> Existing series ID (for mint)
66
+ --phantasma-series-id <int> Existing Phantasma series ID (required for deterministic mint)
61
67
  --mint-fungible-to <address> Recipient address for fungible mint (default: WIF owner)
62
68
  --mint-fungible-amount <int> Amount to mint (integer atomic units)
63
69
  --rom <hex> Token ROM hex (optional; for token creation)
@@ -122,13 +128,13 @@ async function actionMintNft(cfg, dryRun, logSettings) {
122
128
  requireArg(cfg.nexus, "nexus");
123
129
  requireArg(cfg.wif, "wif");
124
130
  requireArg(cfg.carbonTokenId, "carbon_token_id");
125
- requireArg(cfg.carbonTokenSeriesId, "carbon_token_series_id");
131
+ requireArg(cfg.phantasmaSeriesId, "phantasma_series_id");
126
132
  requireArg(cfg.tokenSchemas, "token_schemas");
127
133
  requireArg(cfg.nftMetadata, "nft_metadata");
128
134
  requireArg(cfg.gasFeeBase, "gas_fee_base");
129
135
  requireArg(cfg.gasFeeMultiplier, "gas_fee_multiplier");
130
136
  requireArg(cfg.mintTokenMaxData, "mint_token_max_data");
131
- await (0, mintNftToken_1.mintNftToken)(new mintNftToken_1.mintNftTokenCfg(cfg.rpc, cfg.nexus, cfg.wif, cfg.carbonTokenId, cfg.carbonTokenSeriesId, cfg.tokenSchemas.rom, cfg.nftMetadata, cfg.gasFeeBase, cfg.gasFeeMultiplier, cfg.mintTokenMaxData), dryRun, logSettings);
137
+ await (0, mintNftToken_1.mintNftToken)(new mintNftToken_1.mintNftTokenCfg(cfg.rpc, cfg.nexus, cfg.wif, cfg.carbonTokenId, cfg.phantasmaSeriesId, cfg.tokenSchemas.rom, cfg.nftMetadata, cfg.gasFeeBase, cfg.gasFeeMultiplier, cfg.mintTokenMaxData), dryRun, logSettings);
132
138
  }
133
139
  async function actionMintFungible(cfg, dryRun, logSettings) {
134
140
  requireArg(cfg.rpc, "rpc");
@@ -145,6 +151,14 @@ async function actionMintFungible(cfg, dryRun, logSettings) {
145
151
  /* ------------------------------- Main ------------------------------- */
146
152
  async function main() {
147
153
  const rawArgv = (0, helpers_1.hideBin)(process.argv);
154
+ if (rawArgv.length === 1 && (rawArgv[0] === "--version" || rawArgv[0] === "-v")) {
155
+ console.log((0, version_1.renderVersionReport)(await (0, version_1.buildVersionReport)()));
156
+ return;
157
+ }
158
+ if (rawArgv[0] === "contract") {
159
+ await (0, cli_contract_1.runContractCli)(rawArgv.slice(1));
160
+ return;
161
+ }
148
162
  // Pre-parse --config and --help early so the TOML file can be loaded before the main yargs parsing.
149
163
  const pre = (0, yargs_1.default)(rawArgv)
150
164
  .option("config", {
@@ -220,7 +234,7 @@ async function main() {
220
234
  type: "string",
221
235
  describe: "Amount to mint (integer atomic units)",
222
236
  })
223
- .version()
237
+ .version(false)
224
238
  .epilog("pha-deploy - Phantasma token deployment and minting CLI");
225
239
  const argv = await parser.parseAsync();
226
240
  if (argv.help) {