Skip to content

Conversation

@stalniy
Copy link
Contributor

@stalniy stalniy commented Jan 3, 2026

📝 Description

adds example of how to create a deployment

🔧 Purpose of the Change

  • New feature implementation
  • Bug fix
  • Documentation update
  • Code refactoring
  • Dependency upgrade
  • Other: [specify]

📌 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 January 3, 2026 06:52
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

Adds a new TypeScript example that uses a MNEMONIC-derived wallet to create an SDL deployment, polls for provider bids with capped retries, creates a lease from a selected bid, and verifies the lease. Also updates README to reference the examples folder. (46 words)

Changes

Cohort / File(s) Summary
New Deployment Example
ts/examples/create-deployment.ts
New end-to-end TypeScript example: reads MNEMONIC (errors if missing), derives wallet/address, initializes Chain Node SDK with signer, builds SDL manifest, broadcasts MsgCreateDeployment (with deposit), polls for provider bids (capped retries, 10s interval), selects first bid and broadcasts MsgCreateLease, then queries/verifies the lease.
Docs / Usage Note
ts/README.md
Documentation: adds a Usage line pointing to the examples folder.

Sequence Diagram(s)

sequenceDiagram
    participant Script as Script
    participant Wallet as Wallet
    participant SDK as "Chain Node SDK"
    participant Chain as Blockchain
    participant Provider as Provider

    Script->>Wallet: Load MNEMONIC → derive account (error if missing)
    Wallet-->>Script: Account / address
    Script->>SDK: Init SDK with signer
    SDK-->>Script: Ready

    Script->>Script: Build SDL → compute groups & manifest_version
    Script->>Chain: Broadcast MsgCreateDeployment (with deposit)
    Chain-->>Script: Tx result (dseq)

    rect `#E8F3FF`
    Note over Script,Chain: Polling for bids (max 18 attempts, 10s interval)
    loop until bids or max attempts
        Script->>Chain: Query getBids(dseq)
        Chain-->>Script: Bids (maybe empty)
    end
    end

    alt Bids found
        Script->>Provider: Select first bid
        Script->>Chain: Broadcast MsgCreateLease (from bid)
        Chain-->>Script: Lease created (lease id)
    else No bids (timeout)
        Script-->>Script: Throw error / abort
    end

    Script->>Chain: Query leases (filter owner/dseq/gseq/oseq/provider)
    Chain-->>Script: Lease details (state, price)
    Script-->>Script: Log lease info
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I found a mnemonic tucked away,
I sowed an SDL and signed away,
I waited for bids beneath the log,
Picked one, made a lease — hooray, a cog!
Carrots deployed, I hop and sway 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description follows the template structure but is incomplete: the short explanation is vague, related issues section uses placeholder text, and notes for reviewers section is empty. Replace placeholder text with actual issue references and provide concrete details about the example in the description and reviewer notes sections.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding an example demonstrating deployment creation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/ts-example

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efd2df5 and d84a779.

📒 Files selected for processing (2)
  • ts/README.md
  • ts/examples/create-deployment.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • ts/README.md
  • ts/examples/create-deployment.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test
  • GitHub Check: coverage
  • GitHub Check: go

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

@github-actions github-actions bot added the C:ts label Jan 3, 2026
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: 4

🧹 Nitpick comments (1)
ts/examples/create-deployment.ts (1)

133-135: Move the whitelist reminder outside the polling loop.

The message is logged on every polling attempt, which adds noise. Consider logging it once before entering the loop.

🔎 Proposed fix
+console.log("Make sure your address is whitelisted on this network.");
+
 do {
   await wait(10000);
   attempts++;

   console.log(`Checking for bids (attempt ${attempts}/${maxAttempts})...`);
-  console.log("Make sure your address is whitelisted on this network.");

   bidsResponse = await sdk.akash.market.v1beta5.getBids({
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 02bd13b and d20500a.

📒 Files selected for processing (1)
  • ts/examples/create-deployment.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: proto
  • GitHub Check: go
  • GitHub Check: test
  • GitHub Check: coverage

console.log("Step 1: Creating deployment...");
const sdl = SDL.fromString(`
# Welcome to the Akash Network! 🚀☁
# This file is called a Stack Definition Laguage (SDL)
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

Typo in SDL comment.

"Laguage" should be "Language".

🔎 Proposed fix
-# This file is called a Stack Definition Laguage (SDL)
+# This file is called a Stack Definition Language (SDL)
📝 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
# This file is called a Stack Definition Laguage (SDL)
# This file is called a Stack Definition Language (SDL)
🤖 Prompt for AI Agents
In ts/examples/create-deployment.ts around line 37, the inline comment contains
a typo: "Laguage" should be corrected to "Language"; update the comment text to
read "# This file is called a Stack Definition Language (SDL)".

throw new Error(`No bids found after ${maxAttempts} attempts. Check deployment resources and pricing.`);
}

console.log("Step 4: Selecting the first bid...");
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

Step numbering is inconsistent.

The steps jump from "Step 2" (line 123) directly to "Step 4". Step 3 appears to be missing.

🔎 Proposed fix
-console.log("Step 4: Selecting the first bid...");
+console.log("Step 3: Selecting the first bid...");

And update subsequent steps accordingly (Step 5 → Step 4, Step 6 → Step 5).

📝 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
console.log("Step 4: Selecting the first bid...");
console.log("Step 3: Selecting the first bid...");
🤖 Prompt for AI Agents
In ts/examples/create-deployment.ts around line 158 the step labels are
inconsistent: the log shows "Step 4" while the prior step is "Step 2", meaning
"Step 3" is missing; update this and all subsequent step labels so numbering is
sequential (change the "Step 4" at line 158 to "Step 3", then decrement
subsequent step numbers: Step 5→Step 4, Step 6→Step 5), and scan the file for
every "Step X:" string to adjust any other mismatched step numbers accordingly.

Comment on lines +179 to +201
console.log("Step 6: Verifying lease creation...");
console.log("Lease created successfully!");

const leaseQuery = await sdk.akash.market.v1beta5.getLeases({
filters: {
owner: deploymentId.owner,
dseq: deploymentId.dseq,
gseq: 1,
oseq: 1,
provider: firstBid.id!.provider,
state: "",
bseq: 0,
},
});

const createdLease = leaseQuery!.leases![0]!.lease!;
console.log("Lease verification completed successfully!");
console.log(`Lease ID: ${createdLease.id?.owner}/${createdLease.id?.dseq}/${createdLease.id?.gseq}/${createdLease.id?.oseq}/${createdLease.id?.provider}`);
console.log(`Lease State: ${createdLease.state}`);
console.log(`Lease Price: ${createdLease.price?.amount}${createdLease.price?.denom}`);
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

Success message logged before verification; no error handling for empty lease query.

Line 180 logs "Lease created successfully!" before the verification query runs. Additionally, line 194 uses non-null assertions that will throw an unclear TypeError if the lease query returns no results.

🔎 Proposed fix
 console.log("Step 6: Verifying lease creation...");
-console.log("Lease created successfully!");

 const leaseQuery = await sdk.akash.market.v1beta5.getLeases({
   filters: {
     owner: deploymentId.owner,
     dseq: deploymentId.dseq,
     gseq: 1,
     oseq: 1,
     provider: firstBid.id!.provider,
     state: "",
     bseq: 0,
   },
 });

-const createdLease = leaseQuery!.leases![0]!.lease!;
+if (!leaseQuery?.leases?.length) {
+  throw new Error("Lease verification failed: no leases found");
+}
+
+const createdLease = leaseQuery.leases[0].lease!;
+console.log("Lease created successfully!");
 console.log("Lease verification completed successfully!");
📝 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
console.log("Step 6: Verifying lease creation...");
console.log("Lease created successfully!");
const leaseQuery = await sdk.akash.market.v1beta5.getLeases({
filters: {
owner: deploymentId.owner,
dseq: deploymentId.dseq,
gseq: 1,
oseq: 1,
provider: firstBid.id!.provider,
state: "",
bseq: 0,
},
});
const createdLease = leaseQuery!.leases![0]!.lease!;
console.log("Lease verification completed successfully!");
console.log(`Lease ID: ${createdLease.id?.owner}/${createdLease.id?.dseq}/${createdLease.id?.gseq}/${createdLease.id?.oseq}/${createdLease.id?.provider}`);
console.log(`Lease State: ${createdLease.state}`);
console.log(`Lease Price: ${createdLease.price?.amount}${createdLease.price?.denom}`);
console.log("Step 6: Verifying lease creation...");
const leaseQuery = await sdk.akash.market.v1beta5.getLeases({
filters: {
owner: deploymentId.owner,
dseq: deploymentId.dseq,
gseq: 1,
oseq: 1,
provider: firstBid.id!.provider,
state: "",
bseq: 0,
},
});
if (!leaseQuery?.leases?.length) {
throw new Error("Lease verification failed: no leases found");
}
const createdLease = leaseQuery.leases[0].lease!;
console.log("Lease created successfully!");
console.log("Lease verification completed successfully!");
console.log(`Lease ID: ${createdLease.id?.owner}/${createdLease.id?.dseq}/${createdLease.id?.gseq}/${createdLease.id?.oseq}/${createdLease.id?.provider}`);
console.log(`Lease State: ${createdLease.state}`);
console.log(`Lease Price: ${createdLease.price?.amount}${createdLease.price?.denom}`);
🤖 Prompt for AI Agents
In ts/examples/create-deployment.ts around lines 179-198, the code logs "Lease
created successfully!" before actually querying for the lease and then uses
non-null assertions that will throw if the query returns no results; remove or
move the premature success log so it occurs only after verification, then check
that leaseQuery and leaseQuery.leases exist and have at least one item (if not,
log a clear error and exit/throw), avoid non-null assertions when accessing
createdLease fields (use guarded access or defaults) and only print the lease
details after the existence check succeeds.

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: 0

♻️ Duplicate comments (3)
ts/examples/create-deployment.ts (3)

38-38: Typo in SDL comment.

"Laguage" should be "Language".

🔎 Proposed fix
-# This file is called a Stack Definition Laguage (SDL)
+# This file is called a Stack Definition Language (SDL)

159-159: Step numbering is inconsistent.

The steps jump from "Step 2" (line 124) directly to "Step 4". Step 3 appears to be missing.

🔎 Proposed fix
-console.log("Step 4: Selecting the first bid...");
+console.log("Step 3: Selecting the first bid...");

And update subsequent steps accordingly (Step 5 → Step 4, Step 6 → Step 5).


180-199: Success message logged before verification; no error handling for empty lease query.

Line 181 logs "Lease created successfully!" before the verification query runs. Additionally, line 195 uses chained non-null assertions that will throw an unclear TypeError if the lease query returns no results.

🔎 Proposed fix
 console.log("Step 6: Verifying lease creation...");
-console.log("Lease created successfully!");

 const leaseQuery = await sdk.akash.market.v1beta5.getLeases({
   filters: {
     owner: deploymentId.owner,
     dseq: deploymentId.dseq,
     gseq: 1,
     oseq: 1,
     provider: firstBid.id!.provider,
     state: "",
     bseq: 0,
   },
 });

-const createdLease = leaseQuery!.leases![0]!.lease!;
+if (!leaseQuery?.leases?.length) {
+  throw new Error("Lease verification failed: no leases found");
+}
+
+const createdLease = leaseQuery.leases[0].lease!;
+console.log("Lease created successfully!");
 console.log("Lease verification completed successfully!");
🧹 Nitpick comments (1)
ts/examples/create-deployment.ts (1)

130-147: Consider moving the whitelist reminder outside the loop.

The message "Make sure your address is whitelisted on this network." is logged on every polling attempt. Consider logging it once before the loop starts for cleaner output.

🔎 Proposed fix
 console.log("Step 2: Waiting for providers to create bids...");
 console.log(`Deployment ID: ${deploymentId.owner}/${deploymentId.dseq}`);
+console.log("Make sure your address is whitelisted on this network.");
 let bidsResponse;
 let attempts = 0;
 const maxAttempts = 18;

 do {
   await wait(10000);
   attempts++;

   console.log(`Checking for bids (attempt ${attempts}/${maxAttempts})...`);
-  console.log("Make sure your address is whitelisted on this network.");
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d20500a and 8856b83.

📒 Files selected for processing (2)
  • ts/README.md
  • ts/examples/create-deployment.ts
✅ Files skipped from review due to trivial changes (1)
  • ts/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test
  • GitHub Check: coverage
  • GitHub Check: proto
  • GitHub Check: go
🔇 Additional comments (6)
ts/examples/create-deployment.ts (6)

1-6: LGTM!

Imports are well-organized with appropriate use of type-only imports for message types.


9-12: LGTM!

Environment variable handling is now consistent with MNEMONIC used both in the code and error message.


14-33: LGTM!

Wallet initialization and SDK configuration are properly set up with sensible defaults for the sandbox network.


97-111: LGTM!

Deployment message structure is correctly formed with appropriate deposit configuration and unique dseq generation.


113-122: LGTM!

Deployment creation flow is clear and the deployment ID is properly captured for subsequent queries.


164-178: LGTM!

Lease message is correctly constructed from the selected bid's ID fields.

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: 2

♻️ Duplicate comments (3)
ts/examples/create-deployment.ts (3)

38-38: Typo in SDL comment remains unfixed.

"Laguage" should be "Language" in the Stack Definition Language comment.

🔎 Proposed fix
-# This file is called a Stack Definition Laguage (SDL)
+# This file is called a Stack Definition Language (SDL)

161-161: Inconsistent step numbering remains unfixed.

The steps jump from "Step 2" (line 126) directly to "Step 4" (line 161). Step 3 is missing. Subsequent steps (lines 166, 182) should also be renumbered.

🔎 Proposed fix
-console.log("Step 4: Selecting the first bid...");
+console.log("Step 3: Selecting the first bid...");

And update subsequent steps:

-console.log("Step 5: Creating lease from selected bid...");
+console.log("Step 4: Creating lease from selected bid...");
-console.log("Step 6: Verifying lease creation...");
+console.log("Step 5: Verifying lease creation...");

182-201: Premature success message and unsafe non-null assertions remain unfixed.

Line 183 logs "Lease created successfully!" before the verification query runs (line 185). Additionally, line 197 uses multiple non-null assertions that will throw unclear TypeError messages if the lease query returns no results.

🔎 Proposed fix
 console.log("Step 6: Verifying lease creation...");
-console.log("Lease created successfully!");

 const leaseQuery = await sdk.akash.market.v1beta5.getLeases({
   filters: {
     owner: deploymentId.owner,
     dseq: deploymentId.dseq,
     gseq: 1,
     oseq: 1,
     provider: firstBid.id!.provider,
     state: "",
     bseq: 0,
   },
 });

-const createdLease = leaseQuery!.leases![0]!.lease!;
+if (!leaseQuery?.leases?.length) {
+  throw new Error("Lease verification failed: no leases found");
+}
+
+const createdLease = leaseQuery.leases[0].lease!;
+console.log("Lease created successfully!");
 console.log("Lease verification completed successfully!");
 console.log(`Lease ID: ${createdLease.id?.owner}/${createdLease.id?.dseq}/${createdLease.id?.gseq}/${createdLease.id?.oseq}/${createdLease.id?.provider}`);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8856b83 and 9fabb69.

📒 Files selected for processing (2)
  • ts/README.md
  • ts/examples/create-deployment.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ts/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test
  • GitHub Check: coverage
  • GitHub Check: go
  • GitHub Check: proto
🔇 Additional comments (2)
ts/examples/create-deployment.ts (2)

132-149: Well-structured bid polling with clear feedback.

The retry loop provides good visibility into the polling process with attempt counters and helpful guidance about whitelisting. The 3-minute timeout (18 attempts × 10 seconds) is reasonable for an example.


151-159: Clear error handling for the no-bids case.

The code provides helpful error messaging when no bids are found, suggesting users check deployment resources and pricing. The bid enumeration loop gives good visibility into available options.

Comment on lines +97 to +112
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(),
deposit: {
amount: {
denom: "uakt",
amount: "500000",
},
sources: [Source.balance],
},
};
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 | 🟠 Major

Validate block response before using non-null assertion.

Line 101 uses optional chaining followed by a non-null assertion on latestBlockResponse.block?.header?.height!. If block or header is undefined, this will silently pass undefined to the deployment message, causing issues downstream. Validate the response first.

🔎 Proposed fix
 const latestBlockResponse = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock();
+if (!latestBlockResponse.block?.header?.height) {
+  throw new Error("Failed to retrieve latest block height");
+}
+
 const deploymentMessage: TxInput<MsgCreateDeployment> = {
   id: {
     owner: account.address,
-    dseq: latestBlockResponse.block?.header?.height!,
+    dseq: latestBlockResponse.block.header.height,
   },
   groups: sdl.groups(),
   hash: await sdl.manifestVersion(),
📝 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(),
deposit: {
amount: {
denom: "uakt",
amount: "500000",
},
sources: [Source.balance],
},
};
const latestBlockResponse = await sdk.cosmos.base.tendermint.v1beta1.getLatestBlock();
if (!latestBlockResponse.block?.header?.height) {
throw new Error("Failed to retrieve latest block height");
}
const deploymentMessage: TxInput<MsgCreateDeployment> = {
id: {
owner: account.address,
dseq: latestBlockResponse.block.header.height,
},
groups: sdl.groups(),
hash: await sdl.manifestVersion(),
deposit: {
amount: {
denom: "uakt",
amount: "500000",
},
sources: [Source.balance],
},
};

ygrishajev
ygrishajev previously approved these changes Jan 3, 2026
@stalniy stalniy force-pushed the chore/ts-example branch 3 times, most recently from 4c4f256 to efd2df5 Compare January 5, 2026 07:35
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

♻️ Duplicate comments (4)
ts/examples/create-deployment.ts (4)

38-38: Typo: "Laguage" should be "Language".


97-112: Validate block response before using non-null assertion.

The combination of optional chaining (?.) followed by non-null assertion (!) on line 101 can silently pass undefined if block or header is undefined.


161-161: Step numbering is inconsistent: jumps from Step 2 to Step 4.


182-201: Success message logged before verification; no error handling for empty lease query.

Line 183 logs success before the verification query runs, and line 197 uses chained non-null assertions that will throw an unclear error if the query returns no results.

🧹 Nitpick comments (1)
ts/examples/create-deployment.ts (1)

132-149: Consider moving the whitelist message outside the loop.

The "Make sure your address is whitelisted" message is logged on every polling attempt (up to 18 times). Consider logging it once before the loop starts to reduce noise.

🔎 Proposed fix
 console.log("Step 2: Waiting for providers to create bids...");
 console.log(`Deployment ID: ${deploymentId.owner}/${deploymentId.dseq}`);
+console.log("Make sure your address is whitelisted on this network.");
 let bidsResponse;
 let attempts = 0;
 const maxAttempts = 18;

 do {
   await wait(10000);
   attempts++;

   console.log(`Checking for bids (attempt ${attempts}/${maxAttempts})...`);
-  console.log("Make sure your address is whitelisted on this network.");
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c4f256 and efd2df5.

📒 Files selected for processing (2)
  • ts/README.md
  • ts/examples/create-deployment.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ts/README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test
  • GitHub Check: coverage
  • GitHub Check: go
  • GitHub Check: proto
🔇 Additional comments (4)
ts/examples/create-deployment.ts (4)

1-17: LGTM!

The imports are well-organized, and the environment variable handling now correctly requires MNEMONIC without a fallback, addressing the previous concern about unreachable code.


19-33: LGTM!

The SDK configuration follows a good pattern with sensible sandbox defaults and environment variable overrides for flexibility.


114-124: LGTM!

The deployment creation flow is straightforward. The non-null assertion on deploymentMessage.id!.dseq (line 123) is safe since the id was just constructed in the same scope.


151-164: LGTM with minor style observation.

The bid validation logic is correct. After the length check on line 151, the non-null assertions are safe. The code correctly throws an error if no bids are found after max attempts.

Comment on lines +162 to +176
const firstBid = bidsResponse!.bids![0]!.bid!;

console.log(`Selected bid from provider: ${firstBid.id!.provider}`);

console.log("Step 5: Creating lease from selected bid...");
const leaseMessage: TxInput<MsgCreateLease> = {
bidId: {
owner: firstBid.id!.owner,
dseq: firstBid.id!.dseq,
gseq: firstBid.id!.gseq,
oseq: firstBid.id!.oseq,
provider: firstBid.id!.provider,
bseq: firstBid.id!.bseq,
},
};
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

Validate firstBid.id before accessing its properties.

Multiple non-null assertions on firstBid.id!.owner, firstBid.id!.dseq, etc. assume the bid has a valid id object. If the provider returns a malformed bid without an id, this will throw an unclear TypeError.

🔎 Proposed fix
 console.log("Step 4: Selecting the first bid...");
 const firstBid = bidsResponse!.bids![0]!.bid!;
+if (!firstBid.id) {
+  throw new Error("Selected bid is missing an ID");
+}

-console.log(`Selected bid from provider: ${firstBid.id!.provider}`);
+console.log(`Selected bid from provider: ${firstBid.id.provider}`);

 console.log("Step 5: Creating lease from selected bid...");
 const leaseMessage: TxInput<MsgCreateLease> = {
   bidId: {
-    owner: firstBid.id!.owner,
-    dseq: firstBid.id!.dseq,
-    gseq: firstBid.id!.gseq,
-    oseq: firstBid.id!.oseq,
-    provider: firstBid.id!.provider,
-    bseq: firstBid.id!.bseq,
+    owner: firstBid.id.owner,
+    dseq: firstBid.id.dseq,
+    gseq: firstBid.id.gseq,
+    oseq: firstBid.id.oseq,
+    provider: firstBid.id.provider,
+    bseq: firstBid.id.bseq,
   },
 };

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.

3 participants