chore(ts): updates example to use new manifest generation functions#235
chore(ts): updates example to use new manifest generation functions#235
Conversation
WalkthroughThe 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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.
| 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), |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
find . -name "create-deployment.ts" -type fRepository: 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 -20Repository: akash-network/chain-sdk
Length of output: 108
🏁 Script executed:
cat ./ts/eslint.config.mjsRepository: akash-network/chain-sdk
Length of output: 1739
🏁 Script executed:
cat ./ts/tsconfig.jsonRepository: akash-network/chain-sdk
Length of output: 776
🏁 Script executed:
rg "getLatestBlock" ./ts --type ts -A 5 | head -50Repository: akash-network/chain-sdk
Length of output: 2265
🏁 Script executed:
rg "GetLatestBlockResponse" ./ts/src/generated --type ts -A 10 | head -40Repository: akash-network/chain-sdk
Length of output: 6873
🏁 Script executed:
rg "export interface GetLatestBlockResponse" ./ts/src/generated --type ts -A 15Repository: 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 -50Repository: 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.
| 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.
📝 Description
updates example to use new manifest generation functions
🔧 Purpose of the Change
📌 Related Issues
✅ Checklist
📎 Notes for Reviewers
[Include any additional context, architectural decisions, or specific areas to focus on]