Skip to content

Comments

chore(ts): updates example to use new manifest generation functions#235

Open
stalniy wants to merge 1 commit intomainfrom
chore/example
Open

chore(ts): updates example to use new manifest generation functions#235
stalniy wants to merge 1 commit intomainfrom
chore/example

Conversation

@stalniy
Copy link
Contributor

@stalniy stalniy commented Feb 17, 2026

📝 Description

updates example to use new manifest generation functions

🔧 Purpose of the Change

  • New feature implementation
  • Bug fix
  • Documentation update
  • Code refactoring
  • Dependency upgrade
  • Other: chore

📌 Related Issues

  • Closes #ISSUE_NUMBER
  • References #ISSUE_NUMBER

✅ Checklist

  • I've updated relevant documentation
  • Code follows Akash Network's style guide
  • I've added/updated relevant unit tests
  • Dependencies have been properly updated
  • I agree and adhered to the Contribution Guidelines

📎 Notes for Reviewers

[Include any additional context, architectural decisions, or specific areas to focus on]

@stalniy stalniy requested a review from a team as a code owner February 17, 2026 03:52
@github-actions github-actions bot added the C:ts label Feb 17, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

Walkthrough

The pull request replaces SDL-based deployment creation with a manifest-based approach. Imports are updated to include manifest generation and yaml utilities while removing SDL. The deployment message construction now derives groups from manifest data and uses a manifest version hash instead of SDL-derived methods, with added error handling for manifest generation validation.

Changes

Cohort / File(s) Summary
Manifest-based Deployment
ts/examples/create-deployment.ts
Replaced SDL import with generateManifest, generateManifestVersion, and yaml. Introduced runtime manifest generation and validation. Updated deployment construction to consume manifest.value.groupSpecs for groups and use generateManifestVersion() for hash computation. Added error handling for manifest generation failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰✨ From SDL to manifest, a shift so fine,
Our examples now generate with yaml's design,
Groups and hashes flow from one source true,
Error checks keep deployments shiny and new!
hops contentedly with a carrot twirl 🥕

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: updating an example to use new manifest generation functions instead of SDL-based approach.
Description check ✅ Passed The description follows the template structure with all required sections, though the description content is minimal and some placeholder issue numbers remain unfilled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/example

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ts/examples/create-deployment.ts`:
- Around line 100-107: latestBlockResponse.block?.header?.height is being
force-unwrapped which can still be undefined; instead call
sdk.cosmos.base.tendermint.v1beta1.getLatestBlock(), extract and store the
block.header.height into a local variable (e.g., latestHeight), explicitly check
that latestHeight is defined (throw or return an error if not), then use that
local latestHeight when building the TxInput<MsgCreateDeployment>
deploymentMessage and when calling generateManifestVersion/other logic; this
ensures you don't rely on optional chaining + non-null assertion and reuses the
retrieved value.

Comment on lines 100 to +107
const latestBlockResponse = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock();
const deploymentMessage: TxInput<MsgCreateDeployment> = {
id: {
owner: account.address,
dseq: latestBlockResponse.block?.header?.height!,
},
groups: sdl.groups(),
hash: await sdl.manifestVersion(),
groups: manifest.value.groupSpecs,
hash: await generateManifestVersion(manifest.value.groups),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "create-deployment.ts" -type f

Repository: akash-network/chain-sdk

Length of output: 101


🏁 Script executed:

cat -n ./ts/examples/create-deployment.ts | sed -n '95,115p'

Repository: akash-network/chain-sdk

Length of output: 777


🏁 Script executed:

find . -name "tsconfig.json" -o -name ".eslintrc*" -o -name "eslint.config.*" | head -20

Repository: akash-network/chain-sdk

Length of output: 108


🏁 Script executed:

cat ./ts/eslint.config.mjs

Repository: akash-network/chain-sdk

Length of output: 1739


🏁 Script executed:

cat ./ts/tsconfig.json

Repository: akash-network/chain-sdk

Length of output: 776


🏁 Script executed:

rg "getLatestBlock" ./ts --type ts -A 5 | head -50

Repository: akash-network/chain-sdk

Length of output: 2265


🏁 Script executed:

rg "GetLatestBlockResponse" ./ts/src/generated --type ts -A 10 | head -40

Repository: akash-network/chain-sdk

Length of output: 6873


🏁 Script executed:

rg "export interface GetLatestBlockResponse" ./ts/src/generated --type ts -A 15

Repository: akash-network/chain-sdk

Length of output: 1585


🏁 Script executed:

rg "export interface Block " ./ts/src/generated/protos/cosmos/base/tendermint/v1beta1 --type ts -A 15 | head -50

Repository: akash-network/chain-sdk

Length of output: 1501


Guard against optional-chain + non-null assertion at line 104.

latestBlockResponse.block?.header?.height! can still be undefined at runtime; the optional chaining operator makes the entire expression potentially undefined, and the non-null assertion doesn't prevent this. Use an explicit guard and reuse the value.

🔧 Proposed fix
-const deploymentMessage: TxInput<MsgCreateDeployment> = {
+const height = latestBlockResponse.block?.header?.height;
+if (!height) {
+  throw new Error("Latest block height is unavailable");
+}
+
+const deploymentMessage: TxInput<MsgCreateDeployment> = {
   id: {
     owner: account.address,
-    dseq: latestBlockResponse.block?.header?.height!,
+    dseq: height,
   },
   groups: manifest.value.groupSpecs,
   hash: await generateManifestVersion(manifest.value.groups),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const latestBlockResponse = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock();
const deploymentMessage: TxInput<MsgCreateDeployment> = {
id: {
owner: account.address,
dseq: latestBlockResponse.block?.header?.height!,
},
groups: sdl.groups(),
hash: await sdl.manifestVersion(),
groups: manifest.value.groupSpecs,
hash: await generateManifestVersion(manifest.value.groups),
const latestBlockResponse = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock();
const height = latestBlockResponse.block?.header?.height;
if (!height) {
throw new Error("Latest block height is unavailable");
}
const deploymentMessage: TxInput<MsgCreateDeployment> = {
id: {
owner: account.address,
dseq: height,
},
groups: manifest.value.groupSpecs,
hash: await generateManifestVersion(manifest.value.groups),
🧰 Tools
🪛 Biome (2.3.14)

[error] 104-105: Forbidden non-null assertion after optional chaining.

Optional chaining already handles nullish values. Using non-null assertion defeats its purpose and may cause runtime errors.
Consider using the nullish coalescing operator ?? or optional chaining throughout the chain instead.

(lint/suspicious/noNonNullAssertedOptionalChain)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ts/examples/create-deployment.ts` around lines 100 - 107,
latestBlockResponse.block?.header?.height is being force-unwrapped which can
still be undefined; instead call
sdk.cosmos.base.tendermint.v1beta1.getLatestBlock(), extract and store the
block.header.height into a local variable (e.g., latestHeight), explicitly check
that latestHeight is defined (throw or return an error if not), then use that
local latestHeight when building the TxInput<MsgCreateDeployment>
deploymentMessage and when calling generateManifestVersion/other logic; this
ensures you don't rely on optional chaining + non-null assertion and reuses the
retrieved value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants