@black-market/sdk 0.12.0 → 0.14.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.
Files changed (57) hide show
  1. package/README.md +96 -96
  2. package/dist/lifecycle/index.d.ts +3 -1
  3. package/dist/lifecycle/index.d.ts.map +1 -1
  4. package/dist/lifecycle/index.js +3 -1
  5. package/dist/lifecycle/index.js.map +1 -1
  6. package/dist/lifecycle/lens.d.ts +409 -0
  7. package/dist/lifecycle/lens.d.ts.map +1 -0
  8. package/dist/lifecycle/lens.js +30 -0
  9. package/dist/lifecycle/lens.js.map +1 -0
  10. package/dist/lifecycle/mining.d.ts +47 -0
  11. package/dist/lifecycle/mining.d.ts.map +1 -0
  12. package/dist/lifecycle/mining.js +89 -0
  13. package/dist/lifecycle/mining.js.map +1 -0
  14. package/dist/lifecycle/planner.d.ts.map +1 -1
  15. package/dist/lifecycle/planner.js +121 -78
  16. package/dist/lifecycle/planner.js.map +1 -1
  17. package/dist/lifecycle/presets.d.ts +3 -0
  18. package/dist/lifecycle/presets.d.ts.map +1 -1
  19. package/dist/lifecycle/presets.js +1 -0
  20. package/dist/lifecycle/presets.js.map +1 -1
  21. package/dist/lifecycle/progress.d.ts +51 -1
  22. package/dist/lifecycle/progress.d.ts.map +1 -1
  23. package/dist/lifecycle/progress.js +149 -73
  24. package/dist/lifecycle/progress.js.map +1 -1
  25. package/dist/lifecycle/rpc.d.ts +14 -4
  26. package/dist/lifecycle/rpc.d.ts.map +1 -1
  27. package/dist/lifecycle/rpc.js +171 -12
  28. package/dist/lifecycle/rpc.js.map +1 -1
  29. package/dist/lifecycle/simulation.d.ts +5 -3
  30. package/dist/lifecycle/simulation.d.ts.map +1 -1
  31. package/dist/lifecycle/simulation.js +137 -115
  32. package/dist/lifecycle/simulation.js.map +1 -1
  33. package/dist/lifecycle/snapshot.d.ts +8 -0
  34. package/dist/lifecycle/snapshot.d.ts.map +1 -0
  35. package/dist/lifecycle/snapshot.js +79 -0
  36. package/dist/lifecycle/snapshot.js.map +1 -0
  37. package/dist/lifecycle/types.d.ts +27 -5
  38. package/dist/lifecycle/types.d.ts.map +1 -1
  39. package/dist/lifecycle/types.js.map +1 -1
  40. package/docs/launch-lifecycle.md +627 -1495
  41. package/docs/reference.md +365 -0
  42. package/examples/.env.example +3 -2
  43. package/examples/README.md +171 -552
  44. package/examples/launch-example-support.ts +11 -3
  45. package/examples/launch-example.ts +1 -1
  46. package/examples/launch-lifecycle-smoke.ts +1 -1
  47. package/package.json +1 -1
  48. package/src/lifecycle/index.ts +5 -1
  49. package/src/lifecycle/lens.ts +42 -0
  50. package/src/lifecycle/mining.ts +80 -0
  51. package/src/lifecycle/planner.ts +122 -73
  52. package/src/lifecycle/presets.ts +4 -0
  53. package/src/lifecycle/progress.ts +132 -59
  54. package/src/lifecycle/rpc.ts +163 -13
  55. package/src/lifecycle/simulation.ts +134 -106
  56. package/src/lifecycle/snapshot.ts +72 -0
  57. package/src/lifecycle/types.ts +24 -6
@@ -5,11 +5,13 @@ import type {
5
5
  MarketLiveStateV1, PreparedMarketV1, ProfileRegistrationV1, ProfileTopologyV1, LaunchEnvelopeV2, LifecycleDeveloperTerms,
6
6
  } from "./schema.js";
7
7
 
8
- /** Local opt-in timing only: never contains request arguments, addresses, results or errors. */
8
+ /** Local opt-in timing only: never contains request arguments, addresses, results or errors.
9
+ * Since 0.14.0, removed replay/envelope stages are represented by simulation.measure,
10
+ * which includes the final validated execution at the returned gas envelope. */
9
11
  export type LifecycleDiagnosticStage =
10
12
  | "plan" | "plan.context" | "plan.domain" | "plan.progress" | "plan.inputs" | "rpc"
11
13
  | "profile.certification" | "simulation.context" | "simulation.nitro"
12
- | "simulation.poster" | "simulation.measure" | "simulation.replay" | "simulation.envelope" | "session-cache";
14
+ | "simulation.poster" | "simulation.measure" | "session-cache";
13
15
  export type LifecycleDiagnosticEvent = {
14
16
  stage: LifecycleDiagnosticStage;
15
17
  phase: "queued" | "start" | "success" | "failure" | "reuse";
@@ -35,7 +37,7 @@ export type LifecycleRpcClient = {
35
37
  sessionCache?: LifecycleSessionCache;
36
38
  };
37
39
  export type LifecycleBlock = { number: bigint; hash: Hash; timestamp: bigint; gasLimit: bigint; baseFeePerGas?: bigint };
38
- /** A session retains only static reads at one canonical block, never execution proof. */
40
+ /** A session retains pinned static reads and deployment/backend capability observations. */
39
41
  export type LifecycleSessionCache = {
40
42
  readonly block: Readonly<Pick<LifecycleBlock, "number" | "hash">> | undefined;
41
43
  /** Call on wallet/chain changes and after every confirmed transaction. */
@@ -76,10 +78,11 @@ export type LifecyclePostcondition =
76
78
  export type LifecycleTransaction = {
77
79
  id: string; kind: LifecycleTransactionKind; chainId: number; from: Address; to: Address; data: Hex; value: bigint;
78
80
  dependencies: readonly string[]; postconditions: readonly LifecyclePostcondition[];
79
- marketStart?: number; marketCount?: number; gas?: bigint; gasPrice?: bigint;
81
+ marketStart?: number; marketCount?: number; gas?: bigint; gasPrice?: bigint; nonce?: bigint;
80
82
  /** Exact encoded byte count; populated on SDK-built commands, including approvals. */
81
83
  calldataBytes?: number;
82
- /** Exact current-state execution admission, not a wallet batch or future guarantee. */
84
+ /** Only the immediate command receives exact gas/price/estimate/admission.
85
+ * Future commands must be re-sized and proved by buildNextTransaction. */
83
86
  admission?: LifecycleAdmission;
84
87
  estimate?: LifecycleTransactionEstimate;
85
88
  };
@@ -104,7 +107,12 @@ export type LifecycleFailureCategory = "semantic" | "capacity" | "opaque" | "sou
104
107
  export type LifecycleCapacityConstraint = "compute" | "gas-envelope" | "calldata" | "simulation-gas";
105
108
  export type LifecycleSimulationStep = {
106
109
  transactionId: string; success: boolean; gasUsed?: bigint; gasLimit?: bigint; gasRequired?: bigint;
110
+ /** Compute-only sizing observation, excluding Nitro poster gas; not admission. */
111
+ computeGasRequired?: bigint;
107
112
  returnData?: Hex; error?: string; estimate?: LifecycleTransactionEstimate;
113
+ /** Suffix feasibility budget only, not a transaction estimate or execution admission.
114
+ * buildNextTransaction obtains a fresh poster quote and exact envelope at its turn. */
115
+ provisional?: boolean;
108
116
  failureCategory?: LifecycleFailureCategory; decodedError?: string;
109
117
  /** Safe failed-call facts only; native messages and error-data bytes are never copied here. */
110
118
  nativeErrorCode?: number;
@@ -115,13 +123,15 @@ export type LifecycleSimulationStep = {
115
123
  };
116
124
  export type LifecycleSimulation = LifecycleProofOutcomes & {
117
125
  backend: "eth_simulateV1" | "controlled-fork" | "unavailable";
118
- /** Admission/proved outcomes cover the successful prefix, not the deferred suffix. */
126
+ /** Full successful prefix feasibility; only its immediate envelope is final. */
119
127
  confidence: "stateful" | "provisional"; admitted: boolean;
120
128
  blockNumber: bigint; blockHash: Hash; account: Address; chainId: bigint;
121
129
  steps: readonly LifecycleSimulationStep[]; limits: ResolvedLifecycleLimits;
122
130
  /** Unproved suffix. These transactions receive no gas, price, estimate or admission. */
123
131
  deferredTransactionIds: readonly string[];
124
132
  reason?: string; failedTransactionId?: string;
133
+ /** Affordability can mean insufficient sizing margin, even if smaller exact
134
+ * envelopes could fit. A refused RPC exposes no prefix results to refine them. */
125
135
  failureCategory?: LifecycleFailureCategory; capacityConstraint?: LifecycleCapacityConstraint;
126
136
  };
127
137
  export type LifecycleFundingPrerequisite = {
@@ -164,6 +174,8 @@ export type PlannedLaunch = {
164
174
  account: Address; chainId: bigint; mode: LaunchExecutionMode; confirmations: number;
165
175
  /** Opt-in proxy routing; the committed creator remains the proxy, account is its principal. */
166
176
  ufg?: { config: UfgLaunchConfig; configHash: Hash };
177
+ /** With admitted exact proof, transactions[0] is the immediate reviewed envelope,
178
+ * including nonce, gas and gasPrice. Deferred commands have no execution admission. */
167
179
  transactions: readonly LifecycleTransaction[]; prerequisites: readonly LifecycleFundingPrerequisite[];
168
180
  /** Sum of exact calldata bytes across the returned remaining commands, including approvals. */
169
181
  totalCalldataBytes: number;
@@ -186,11 +198,17 @@ export type PlanLaunchOptions = {
186
198
  /** Unstarted only: waive the funded boundary tail; all other topology checks remain required. */
187
199
  allowMissingPermanentTail?: boolean;
188
200
  };
201
+ /** Explicit atomic final gas. Omitted price freezes this invocation's recommendation;
202
+ * a supplied price is replayed exactly, never refreshed or silently increased. */
203
+ export type LifecycleFinalEnvelope = Readonly<{ gas: bigint; gasPrice?: bigint }>;
189
204
  export type PrepareAndPlanLifecycleLaunchOptions = PlanLaunchOptions & {
190
205
  onProgress?: (progress: PoolBoundLifecyclePreparationProgress) => void;
191
206
  /** Protect every ordered buy from its actual diagnostic receipt output, rounded down.
192
207
  * Omitted preserves the caller's committed minima. Only an unstarted launch may be protected. */
193
208
  buySlippageBps?: number;
209
+ /** Atomic only, with no preceding approvals. Final calldata receives one exact
210
+ * validated replay, not a new gas recommendation or a larger rescue envelope. */
211
+ fixedFinalEnvelope?: LifecycleFinalEnvelope;
194
212
  };
195
213
  export type BuildLaunchTransactionsOptions = {
196
214
  plan: LaunchPlanV1; mode: LaunchExecutionMode;