@hsuite/smart-engines-cli 1.2.1 → 1.4.2

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.
Files changed (109) hide show
  1. package/README.md +272 -58
  2. package/dist/_lib/attestation.d.ts +45 -0
  3. package/dist/_lib/attestation.d.ts.map +1 -0
  4. package/dist/_lib/attestation.js +76 -0
  5. package/dist/_lib/attestation.js.map +1 -0
  6. package/dist/_lib/baas.d.ts +147 -0
  7. package/dist/_lib/baas.d.ts.map +1 -0
  8. package/dist/_lib/baas.js +260 -0
  9. package/dist/_lib/baas.js.map +1 -0
  10. package/dist/_lib/cluster.d.ts +6 -6
  11. package/dist/_lib/cluster.js +6 -6
  12. package/dist/_lib/deploy-manifest.d.ts +69 -0
  13. package/dist/_lib/deploy-manifest.d.ts.map +1 -0
  14. package/dist/_lib/deploy-manifest.js +87 -0
  15. package/dist/_lib/deploy-manifest.js.map +1 -0
  16. package/dist/_lib/docker.d.ts +82 -0
  17. package/dist/_lib/docker.d.ts.map +1 -0
  18. package/dist/_lib/docker.js +164 -0
  19. package/dist/_lib/docker.js.map +1 -0
  20. package/dist/_lib/faucet-client.d.ts +64 -0
  21. package/dist/_lib/faucet-client.d.ts.map +1 -0
  22. package/dist/_lib/faucet-client.js +92 -0
  23. package/dist/_lib/faucet-client.js.map +1 -0
  24. package/dist/_lib/framework.d.ts +59 -0
  25. package/dist/_lib/framework.d.ts.map +1 -0
  26. package/dist/_lib/framework.js +149 -0
  27. package/dist/_lib/framework.js.map +1 -0
  28. package/dist/_lib/frontend-guard.d.ts +13 -0
  29. package/dist/_lib/frontend-guard.d.ts.map +1 -0
  30. package/dist/_lib/frontend-guard.js +41 -0
  31. package/dist/_lib/frontend-guard.js.map +1 -0
  32. package/dist/_lib/registry-fanout.d.ts +178 -0
  33. package/dist/_lib/registry-fanout.d.ts.map +1 -0
  34. package/dist/_lib/registry-fanout.js +545 -0
  35. package/dist/_lib/registry-fanout.js.map +1 -0
  36. package/dist/_lib/runtime-env.d.ts +126 -0
  37. package/dist/_lib/runtime-env.d.ts.map +1 -0
  38. package/dist/_lib/runtime-env.js +172 -0
  39. package/dist/_lib/runtime-env.js.map +1 -0
  40. package/dist/_lib/subscription-client.d.ts +129 -18
  41. package/dist/_lib/subscription-client.d.ts.map +1 -1
  42. package/dist/_lib/subscription-client.js +268 -40
  43. package/dist/_lib/subscription-client.js.map +1 -1
  44. package/dist/_lib/subscription-env.d.ts +35 -0
  45. package/dist/_lib/subscription-env.d.ts.map +1 -1
  46. package/dist/_lib/subscription-env.js +46 -2
  47. package/dist/_lib/subscription-env.js.map +1 -1
  48. package/dist/commands/app-lifecycle.d.ts +36 -0
  49. package/dist/commands/app-lifecycle.d.ts.map +1 -0
  50. package/dist/commands/app-lifecycle.js +145 -0
  51. package/dist/commands/app-lifecycle.js.map +1 -0
  52. package/dist/commands/ci.d.ts +45 -0
  53. package/dist/commands/ci.d.ts.map +1 -0
  54. package/dist/commands/ci.js +174 -0
  55. package/dist/commands/ci.js.map +1 -0
  56. package/dist/commands/deploy-manifest.d.ts +11 -0
  57. package/dist/commands/deploy-manifest.d.ts.map +1 -0
  58. package/dist/commands/deploy-manifest.js +17 -0
  59. package/dist/commands/deploy-manifest.js.map +1 -0
  60. package/dist/commands/deploy.d.ts +70 -11
  61. package/dist/commands/deploy.d.ts.map +1 -1
  62. package/dist/commands/deploy.js +273 -150
  63. package/dist/commands/deploy.js.map +1 -1
  64. package/dist/commands/downgrade.js +1 -1
  65. package/dist/commands/downgrade.js.map +1 -1
  66. package/dist/commands/faucet.d.ts +78 -0
  67. package/dist/commands/faucet.d.ts.map +1 -0
  68. package/dist/commands/faucet.js +184 -0
  69. package/dist/commands/faucet.js.map +1 -0
  70. package/dist/commands/governance.js +1 -1
  71. package/dist/commands/governance.js.map +1 -1
  72. package/dist/commands/hist-balance.d.ts +1 -1
  73. package/dist/commands/hist-balance.js +1 -1
  74. package/dist/commands/init.js +1 -1
  75. package/dist/commands/list.d.ts +22 -0
  76. package/dist/commands/list.d.ts.map +1 -0
  77. package/dist/commands/list.js +81 -0
  78. package/dist/commands/list.js.map +1 -0
  79. package/dist/commands/personhood.js +2 -2
  80. package/dist/commands/personhood.js.map +1 -1
  81. package/dist/commands/redeploy.d.ts +62 -0
  82. package/dist/commands/redeploy.d.ts.map +1 -0
  83. package/dist/commands/redeploy.js +322 -0
  84. package/dist/commands/redeploy.js.map +1 -0
  85. package/dist/commands/status.d.ts +51 -0
  86. package/dist/commands/status.d.ts.map +1 -0
  87. package/dist/commands/status.js +138 -0
  88. package/dist/commands/status.js.map +1 -0
  89. package/dist/commands/subscribe.d.ts +94 -17
  90. package/dist/commands/subscribe.d.ts.map +1 -1
  91. package/dist/commands/subscribe.js +487 -81
  92. package/dist/commands/subscribe.js.map +1 -1
  93. package/dist/commands/transactions.d.ts +60 -0
  94. package/dist/commands/transactions.d.ts.map +1 -0
  95. package/dist/commands/transactions.js +101 -0
  96. package/dist/commands/transactions.js.map +1 -0
  97. package/dist/commands/update.d.ts +40 -0
  98. package/dist/commands/update.d.ts.map +1 -0
  99. package/dist/commands/update.js +114 -0
  100. package/dist/commands/update.js.map +1 -0
  101. package/dist/commands/verify.d.ts +10 -19
  102. package/dist/commands/verify.d.ts.map +1 -1
  103. package/dist/commands/verify.js +14 -23
  104. package/dist/commands/verify.js.map +1 -1
  105. package/dist/index.d.ts +12 -3
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +32 -3
  108. package/dist/index.js.map +1 -1
  109. package/package.json +11 -4
@@ -1,38 +1,113 @@
1
1
  /**
2
- * `hsuite subscribe` — Mint a subscription NFT against the validator's
3
- * `/api/v3/subscription/*` surface.
2
+ * `hsuite subscribe` — Onboard a smart-app the CANONICAL, MINT-FIRST way:
3
+ * create the smart-app's DKG ENTITY first, mint the builder subscription NFT
4
+ * ON THAT ENTITY's id, and land it on the dev wallet — so `1 smart-app =
5
+ * 1 DKG entity = 1 NFT`, ACTIVE from mint.
4
6
  *
5
- * Flow (per docs/superpowers/specs/2026-05-27-developer-subscription-gating.md §3.5):
6
- * 1. Read XRPL_ADDRESS + XRPL_SEED from env (written by `hsuite init`).
7
- * 2. POST /api/v3/subscription/request server creates subscription doc.
8
- * - `free_testnet`: server auto-activates + mints. CLI polls /status
9
- * until NFT serial is set.
10
- * - paid tier: server returns depositInstructions. CLI displays them,
11
- * polls /status every 5s until status: 'PENDING_MINT' (deposit
12
- * confirmed), then POSTs /mint to flip ACTIVE.
13
- * 3. Verify NFT serial lands on the wallet via GET /status.
14
- * 4. Write SUBSCRIPTION_APP_ID + SUBSCRIPTION_NFT_SERIAL to .env.
7
+ * ## Why this creates the entity (the mint-first re-architecture)
8
+ *
9
+ * `subscribe` used to mint the subscription NFT on a throwaway random
10
+ * `app-${uuid}` that was NEVER a DKG entity, while `hsuite deploy` separately
11
+ * minted a FRESH entity (+ a SECOND subscription) at `init` time. Paid id ≠
12
+ * deployed id the deployed app stayed PENDING, redeploys forked, and two
13
+ * NFTs were minted. Now `subscribe` creates the durable DKG entity up front and
14
+ * uses its `entityId` as the subscription appId end-to-end; `deploy` reuses
15
+ * that same id (it no longer creates anything). Output:
16
+ * `SUBSCRIPTION_APP_ID == DEPLOYED_APP_ID == DKG entityId`, ACTIVE, ONE NFT.
17
+ *
18
+ * Full flow:
19
+ * 1. Read XRPL_ADDRESS + XRPL_SEED from env (written by `hsuite init`) and the
20
+ * validator URL.
21
+ * 2. Web3-auth against the validator (challenge → sign → bearer). The
22
+ * subscription + create routes are session-guarded. (Auth routes have NO
23
+ * /api prefix.)
24
+ * 3. POST /api/v3/smart-apps (createApp) — run the per-entity DKG ceremony
25
+ * to derive the canonical `entityId` AND create the (paid, pending-deposit)
26
+ * subscription in the same in-process flow. The response carries
27
+ * `{ appId: entityId, depositInstructions, subscriptionId }`. THIS replaces
28
+ * the old random-id + standalone `subscription/request`. From here the
29
+ * `entityId` is THE appId for everything downstream.
30
+ * 4. Ensure deposit instructions: the createApp response normally carries them.
31
+ * If a node deferred deposit-account creation, fall back to the idempotent
32
+ * POST /api/v3/subscription/request { appId: entityId, … } (same retry/503
33
+ * semantics, returns the SAME subscription's deposit instructions — no
34
+ * second subscription, no second deposit wallet).
35
+ * 5. Render the deposit instructions.
36
+ * 6. AUTO-PAY the deposit from the dev wallet over the XRPL testnet (HST
37
+ * Payment with a SendMax covering the 0.25% transfer fee). `--no-autopay`
38
+ * skips this and prints instructions for manual (XUMM) payment.
39
+ * 7. Poll GET /api/v3/subscription/status/:entityId until the deposit is
40
+ * confirmed and ready to mint (status in { deposit_confirmed, pending_mint,
41
+ * minting, active }; the real confirmed status is `deposit_confirmed`).
42
+ * 8. POST /api/v3/subscription/mint/:entityId — activates the subscription +
43
+ * flips the SmartApp doc PENDING_SUBSCRIPTION → ACTIVE (via `activateApp`,
44
+ * gated on the deposit-backed NFT mint) and kicks off the async NFT mint.
45
+ * 9. Poll /status until `subscriptionNftSerial` is set OR `chainNfts.xrpl.nftId`
46
+ * is present (the NFT mints asynchronously via the mint subscriber).
47
+ * 10. Accept the brokered NFT sell offer so it lands on the dev wallet.
48
+ * 11. Verify account_nfts, then write SUBSCRIPTION_APP_ID + APP_ID +
49
+ * SUBSCRIPTION_NFT_SERIAL (= entityId) to the env file.
15
50
  */
16
51
  import { Command } from 'commander';
17
52
  import { SubscriptionClient } from '../_lib/subscription-client';
53
+ /**
54
+ * Minimal structural shape of the bits of the `xrpl` Client we use for the
55
+ * deposit payment + NFT offer acceptance. Lets unit tests inject a fake without
56
+ * a real websocket.
57
+ */
58
+ export type XrplNftClientLike = {
59
+ connect(): Promise<unknown>;
60
+ disconnect(): Promise<unknown>;
61
+ request(req: Record<string, unknown>): Promise<{
62
+ result: any;
63
+ }>;
64
+ autofill(tx: Record<string, unknown>): Promise<Record<string, unknown>>;
65
+ submitAndWait(blob: string): Promise<{
66
+ result: {
67
+ meta?: any;
68
+ };
69
+ }>;
70
+ };
18
71
  type SubscribeOpts = {
19
72
  env: string;
20
73
  gateway?: string;
21
74
  tier: string;
22
- networks: string;
23
- appName?: string;
75
+ /** Explicit appId. Defaults to SUBSCRIPTION_APP_ID env, then a random id. */
24
76
  appId?: string;
77
+ appName?: string;
78
+ /** XRPL account that issues the subscription NFT. Optional override for the
79
+ * sell-offer discovery (the /status response now exposes it). */
80
+ nftIssuer?: string;
81
+ /** Skip the auto-pay step — print instructions and exit (manual XUMM pay). */
82
+ noAutopay?: boolean;
25
83
  pollIntervalMs?: number;
26
84
  pollTimeoutMs?: number;
85
+ /**
86
+ * Max status polls while waiting for the NFT to mint (default 24 × pollIntervalMs
87
+ * ≈ 120s). The 2-of-3 issuer MPC mint + sell-offer creation take ~15-25s, so the
88
+ * default gives ample headroom. Exposed for tests (kept fast via `sleep`).
89
+ */
90
+ nftPollAttempts?: number;
91
+ /**
92
+ * Max NFTokenAcceptOffer retries while the issuer's sell offer becomes
93
+ * queryable on-ledger (default 10 × acceptRetryMs). Exposed for tests.
94
+ */
95
+ acceptAttempts?: number;
96
+ /** Delay between accept retries (default pollIntervalMs, then 5000). */
97
+ acceptRetryMs?: number;
27
98
  clientFactory?: (baseUrl: string) => SubscriptionClient;
28
99
  sleep?: (ms: number) => Promise<void>;
100
+ /** Builds an XRPL client for deposit pay + NFT accept. Defaults to real `xrpl`. */
101
+ xrplClientFactory?: (wss: string) => XrplNftClientLike;
102
+ /** Signs a prepared XRPL tx with the dev seed → tx_blob. Defaults to `xrpl`. */
103
+ walletSignFactory?: (seed: string) => (tx: Record<string, unknown>) => string;
29
104
  };
30
105
  /**
31
106
  * Pure orchestration body — exported for unit tests.
32
107
  *
33
- * Returns the appId + NFT serial (when minted) so callers can persist them.
34
- * Throws on every error path; the command-level action wraps this and
35
- * exits the process.
108
+ * Returns the appId + NFT serial (once minted + accepted) so callers can
109
+ * persist them. Throws on every hard-error path; the command-level action wraps
110
+ * this and exits the process.
36
111
  */
37
112
  export declare function runSubscribe(opts: SubscribeOpts): Promise<{
38
113
  appId: string;
@@ -40,6 +115,8 @@ export declare function runSubscribe(opts: SubscribeOpts): Promise<{
40
115
  nftSerial?: number | string;
41
116
  tier: string;
42
117
  status?: string;
118
+ depositPaid: boolean;
119
+ nftAccepted: boolean;
43
120
  }>;
44
121
  export declare const subscribeCommand: Command;
45
122
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,OAAO,EACL,kBAAkB,EAInB,MAAM,6BAA6B,CAAC;AAGrC,KAAK,aAAa,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,kBAAkB,CAAC;IACxD,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AAQF;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAkFD;AA0DD,eAAO,MAAM,gBAAgB,SA4CzB,CAAC"}
1
+ {"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/commands/subscribe.ts"],"names":[],"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