Skip to content

Conversation

nguyen-zung
Copy link
Collaborator

@nguyen-zung nguyen-zung commented Jul 22, 2025

Thank you!

Summary by CodeRabbit

  • New Features
    • Introduced methods for building EVM unsigned transactions and messages.
  • Chores
    • Updated package version and entry points to use compiled distribution files.
    • Improved TypeScript configuration for better output management and type declarations.

Copy link

coderabbitai bot commented Jul 22, 2025

Walkthrough

The changes update the package configuration to reference compiled output files, adjust TypeScript compiler settings for output and type declarations, and remove trailing blank lines in a method within the main wrapper class without altering functionality.

Changes

File(s) Change Summary
wasmjs/package.json Updated version, changed main entry to compiled JS, added types field pointing to declaration file.
wasmjs/tsconfig.json Changed module resolution to "node", added outDir and declaration options, adjusted included files.
wasmjs/src/index.ts Removed trailing blank lines after marshalInput method inside WalletCoreWrapper class.

Estimated code review effort

2 (~15 minutes)

Poem

🐇 Through code fields fresh and bright,
A rabbit hops with pure delight.
From source to dist, the path is clear,
Types and builds now appear near.
Lines trimmed neat, the code’s in flight,
A small change, but feels just right! 🌿✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d44b445 and b1f5584.

📒 Files selected for processing (1)
  • wasmjs/src/index.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • wasmjs/src/index.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). (6)
  • GitHub Check: build
  • GitHub Check: test-wasm
  • GitHub Check: build-and-test
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: test
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07d3ec8 and d44b445.

⛔ Files ignored due to path filters (3)
  • wasmjs/dist/index.d.ts is excluded by !**/dist/**
  • wasmjs/dist/index.js is excluded by !**/dist/**
  • wasmjs/dist/test/tw.test.js is excluded by !**/dist/**
📒 Files selected for processing (3)
  • wasmjs/package.json (1 hunks)
  • wasmjs/src/index.ts (1 hunks)
  • wasmjs/tsconfig.json (1 hunks)
⏰ 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). (6)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: test-wasm
  • GitHub Check: build-and-test
  • GitHub Check: test
🔇 Additional comments (5)
wasmjs/package.json (2)

3-3: Version bump looks appropriate for structural changes.

The version increment from 1.0.0 to 1.0.4 reflects the structural changes to the build output and new methods being added.


5-6: Good shift to compiled distribution files.

The change from referencing source files directly (src/index.ts) to compiled output (dist/index.js and dist/index.d.ts) is the correct approach for npm package distribution. This ensures consumers get optimized JavaScript and proper TypeScript support.

wasmjs/tsconfig.json (3)

6-7: Build output configuration aligns with package.json.

The outDir: "dist" and declaration: true settings properly support the package.json changes that reference dist/index.js and dist/index.d.ts.


12-12: Include scope appropriately narrowed for build.

Focusing the compilation on src/**/* is correct for the build process, removing test files from the compilation scope.


5-5: Confirm moduleResolution compatibility with imports

I scanned wasmjs/src/index.ts and found only these external imports:

  • "craminiumlab-wallet-core"
  • "long"

Switching from "bundler" to "node" defers resolution to TypeScript’s Node-style algorithm. Please verify that both packages expose entrypoints compatible with Node resolution (via main/module or an exports field). If either relies on bundler-specific mappings, you may need to switch to "node16"/"nodenext" or add explicit paths in your tsconfig.

Comment on lines 239 to 258
buildEVMUnsignedTx(jsonStr: string): Uint8Array {
const req = JSON.parse(jsonStr);

const opPayment = TW.Stellar.Proto.OperationPayment.create({
destination: req.destination,
amount: Long.fromString(String(req.amount)),
})
const memoText = this.TW.Stellar.Proto.MemoText.create({
text: req.memoText
})
const input = {
fee : req.fee,
account: req.account,
passphrase: 'Public Global Stellar Network ; September 2015',
sequence: Long.fromString(String(req.sequence)),
opPayment: opPayment,
memoText: memoText
};
return this.TW.Stellar.Proto.SigningInput.encode(input).finish();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: EVM method incorrectly implements Stellar logic.

The buildEVMUnsignedTx method is misleadingly named as it actually builds Stellar transactions using TW.Stellar.Proto types. This will cause confusion and runtime errors when used for EVM transactions.

Either:

  1. Rename the method to buildStellarUnsignedTx2 if this is intentional duplication, or
  2. Implement proper EVM transaction building using Ethereum protobuf types:
-  buildEVMUnsignedTx(jsonStr: string): Uint8Array {
-    const req = JSON.parse(jsonStr);
-
-    const opPayment = TW.Stellar.Proto.OperationPayment.create({
-      destination: req.destination,
-      amount: Long.fromString(String(req.amount)),
-    })
-    const memoText = this.TW.Stellar.Proto.MemoText.create({
-      text: req.memoText
-    })
-    const input = {
-      fee : req.fee,
-      account: req.account,
-      passphrase: 'Public Global Stellar Network ; September 2015',
-      sequence: Long.fromString(String(req.sequence)),
-      opPayment: opPayment,
-      memoText: memoText
-    };
-    return this.TW.Stellar.Proto.SigningInput.encode(input).finish();
+  buildEVMUnsignedTx(jsonStr: string): Uint8Array {
+    const req = JSON.parse(jsonStr);
+    const input = {
+      chainId: this.HexCoding.decode(req.chainId),
+      nonce: this.HexCoding.decode(req.nonce),
+      gasPrice: this.HexCoding.decode(req.gasPrice),
+      gasLimit: this.HexCoding.decode(req.gasLimit),
+      toAddress: req.toAddress,
+      transaction: {
+        transfer: this.TW.Ethereum.Proto.Transaction.Transfer.create({
+          amount: this.HexCoding.decode(req.amount)
+        })
+      }
+    };
+    return this.TW.Ethereum.Proto.SigningInput.encode(input).finish();
📝 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
buildEVMUnsignedTx(jsonStr: string): Uint8Array {
const req = JSON.parse(jsonStr);
const opPayment = TW.Stellar.Proto.OperationPayment.create({
destination: req.destination,
amount: Long.fromString(String(req.amount)),
})
const memoText = this.TW.Stellar.Proto.MemoText.create({
text: req.memoText
})
const input = {
fee : req.fee,
account: req.account,
passphrase: 'Public Global Stellar Network ; September 2015',
sequence: Long.fromString(String(req.sequence)),
opPayment: opPayment,
memoText: memoText
};
return this.TW.Stellar.Proto.SigningInput.encode(input).finish();
}
buildEVMUnsignedTx(jsonStr: string): Uint8Array {
const req = JSON.parse(jsonStr);
const input = {
chainId: this.HexCoding.decode(req.chainId),
nonce: this.HexCoding.decode(req.nonce),
gasPrice: this.HexCoding.decode(req.gasPrice),
gasLimit: this.HexCoding.decode(req.gasLimit),
toAddress: req.toAddress,
transaction: {
transfer: this.TW.Ethereum.Proto.Transaction.Transfer.create({
amount: this.HexCoding.decode(req.amount)
})
}
};
return this.TW.Ethereum.Proto.SigningInput.encode(input).finish();
}
🤖 Prompt for AI Agents
In wasmjs/src/index.ts lines 239 to 258, the method named buildEVMUnsignedTx is
incorrectly building Stellar transactions instead of EVM transactions, causing
confusion and potential runtime errors. To fix this, either rename the method to
buildStellarUnsignedTx2 to reflect its actual purpose or rewrite the method to
construct unsigned EVM transactions using the appropriate Ethereum protobuf
types instead of Stellar types.

Comment on lines 260 to 264
buildEVMUnsignedMessage(txInput: Uint8Array): Uint8Array {
const preimage = this.preImageHashes(this.CoinType.stellar, txInput);
const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage)
return out.dataHash
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: EVM method uses wrong coin type.

The buildEVMUnsignedMessage method uses CoinType.stellar instead of an appropriate EVM coin type, which will produce incorrect results for EVM transactions.

-  buildEVMUnsignedMessage(txInput: Uint8Array): Uint8Array  {
-    const preimage = this.preImageHashes(this.CoinType.stellar, txInput);
-    const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage)
-    return out.dataHash
-  }
+  buildEVMUnsignedMessage(txInput: Uint8Array): Uint8Array  {
+    const preimage = this.preImageHashes(this.CoinType.ethereum, txInput);
+    const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage)
+    return out.data
+  }
📝 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
buildEVMUnsignedMessage(txInput: Uint8Array): Uint8Array {
const preimage = this.preImageHashes(this.CoinType.stellar, txInput);
const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage)
return out.dataHash
}
buildEVMUnsignedMessage(txInput: Uint8Array): Uint8Array {
const preimage = this.preImageHashes(this.CoinType.ethereum, txInput);
const out = this.TW.TxCompiler.Proto.PreSigningOutput.decode(preimage)
return out.data
}
🤖 Prompt for AI Agents
In wasmjs/src/index.ts around lines 260 to 264, the buildEVMUnsignedMessage
method incorrectly uses CoinType.stellar when calling preImageHashes, which is
wrong for EVM transactions. Replace CoinType.stellar with the correct EVM coin
type constant to ensure the method processes EVM transactions properly and
produces correct results.

Comment on lines 266 to 268
marshalInput(input: protobuf.Writer): Uint8Array {
return input.finish();
}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify protobuf import for marshalInput method.

The marshalInput method references protobuf.Writer but there's no protobuf import visible in this file. This will cause a TypeScript compilation error.


🏁 Script executed:

#!/bin/bash
# Check if protobuf is imported in the file
rg "import.*protobuf" wasmjs/src/index.ts

Length of output: 43


🏁 Script executed:

#!/bin/bash
# Display the top of the file to inspect imports
sed -n '1,200p' wasmjs/src/index.ts

# Search for any protobuf references in the file
rg "protobuf" -n wasmjs/src/index.ts

Length of output: 6196


Import missing protobuf in wasmjs/src/index.ts

The marshalInput method refers to protobuf.Writer but there’s no protobuf import in this file, which will trigger a TypeScript compilation error.

• File: wasmjs/src/index.ts
• Around line 266

Add at the top of the file:

 import Long from "long";
+import * as protobuf from "protobufjs/minimal";

If you’d rather import just the Writer type, you can instead do:

-import * as protobuf from "protobufjs/minimal";
+import { Writer } from "protobufjs/minimal";

and update the signature to:

marshalInput(input: Writer): Uint8Array {  }
🤖 Prompt for AI Agents
In wasmjs/src/index.ts around lines 266 to 268, the marshalInput method uses
protobuf.Writer but protobuf is not imported, causing a TypeScript error. Fix
this by adding an import statement for protobuf or just the Writer type at the
top of the file. Then update the marshalInput method signature accordingly to
use the imported Writer type if you choose the latter approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant