Skip to content

feat: add token-id related queries for stellar its#1346

Open
rista404 wants to merge 2 commits into
mainfrom
stellar-its-canonical-token-id-query
Open

feat: add token-id related queries for stellar its#1346
rista404 wants to merge 2 commits into
mainfrom
stellar-its-canonical-token-id-query

Conversation

@rista404

@rista404 rista404 commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

why

For easier inspection.

# Get the canonical interchain token id for a token address
node stellar/its.js canonical-interchain-token-id <TOKEN_ADDRESS> -p <PRIVATE_KEY> --env testnet

# Get the interchain token id for a deployer and salt
node stellar/its.js interchain-token-id <DEPLOYER_ADDRESS> <SALT> -p <PRIVATE_KEY> --env testnet

# Get the linked token id for a deployer and salt
node stellar/its.js linked-token-id <DEPLOYER_ADDRESS> <SALT> -p <PRIVATE_KEY> --env testnet

how


Note

Low Risk
Low risk: adds read-only CLI queries that call existing contract methods and print results, without changing stateful operations or core transaction flow.

Overview
Adds three new read-only commands to stellar/its.js for easier token inspection: canonical-interchain-token-id, interchain-token-id, and linked-token-id.

Each command validates inputs, computes/prints the derived salt bytes where relevant, calls the corresponding ITS contract method, and prints/returns the serialized token ID.

Reviewed by Cursor Bugbot for commit 7707838. Bugbot is set up for automated code reviews on this repo. Configure here.

@rista404 rista404 requested a review from a team as a code owner February 11, 2026 20:50
Copilot AI review requested due to automatic review settings February 11, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds new Stellar ITS CLI queries to retrieve different token-id derivations, making it easier to inspect/derive token IDs from on-chain data.

Changes:

  • Add contract query handlers for canonical_interchain_token_id, interchain_token_id, and linked_token_id.
  • Wire the new handlers into the stellar/its.js Commander CLI as canonical-interchain-token-id, interchain-token-id, and linked-token-id.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread stellar/its.js
Comment on lines +332 to +337
const operation = contract.call('interchain_token_id', addressToScVal(deployer), hexToScVal(saltBytes32));
const returnValue = await broadcast(operation, wallet, chain, 'Get interchain token id', options);
const tokenId = serializeValue(returnValue.value());

printInfo('Interchain Token ID', tokenId);

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

serializeValue produces a non-0x-prefixed hex string for the token id. Since other commands consume token ids via hexToScVal (which relies on ethers.utils.arrayify), the printed/returned value here may not be directly reusable. Consider prefixing with 0x (or standardizing token id formatting in one place).

Copilot uses AI. Check for mistakes.
Comment thread stellar/its.js
Comment on lines +353 to +358
const operation = contract.call('linked_token_id', addressToScVal(deployer), hexToScVal(saltBytes32));
const returnValue = await broadcast(operation, wallet, chain, 'Get linked token id', options);
const tokenId = serializeValue(returnValue.value());

printInfo('Linked Token ID', tokenId);

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

Same formatting concern as above: the linked token id is serialized as bare hex without 0x, which may not be directly accepted by other commands expecting a hex string parsable by ethers.utils.arrayify. Consider printing/returning 0x-prefixed hex for easier copy/paste.

Copilot uses AI. Check for mistakes.
Comment thread stellar/its.js
Comment on lines +321 to +327
const [deployer, salt] = args;
const saltBytes32 = saltToBytes32(salt);

validateParameters({
isValidStellarAddress: { deployer },
isNonEmptyString: { salt },
});

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

saltToBytes32(salt) is computed before validating salt. If salt is empty or not a valid hex string/bytes-like input, saltToBytes32 can throw (via keccak256) with a less actionable error. Validate salt (and ideally its expected format) before converting it, then derive saltBytes32.

Copilot uses AI. Check for mistakes.
Comment thread stellar/its.js
Comment on lines +342 to +348
const [deployer, salt] = args;
const saltBytes32 = saltToBytes32(salt);

validateParameters({
isValidStellarAddress: { deployer },
isNonEmptyString: { salt },
});

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

Same issue as interchainTokenId: saltToBytes32(salt) runs before salt is validated, so invalid/empty salts can throw from inside saltToBytes32 instead of producing a clean parameter validation error. Move validation ahead of the conversion.

Copilot uses AI. Check for mistakes.
Comment thread stellar/its.js
Comment on lines +311 to +316
const operation = contract.call('canonical_interchain_token_id', nativeToScVal(tokenAddress, { type: 'address' }));
const returnValue = await broadcast(operation, wallet, chain, 'Get canonical interchain token id', options);
const tokenId = serializeValue(returnValue.value());

printInfo('Canonical Interchain Token ID', tokenId);

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

serializeValue returns raw hex for Uint8Array without a 0x prefix, but downstream helpers like hexToScVal use ethers.utils.arrayify, which expects 0x-prefixed hex. Consider returning/printing the token id in 0x... form here so the output can be copy-pasted into other commands that accept <tokenId> without manual editing.

Copilot uses AI. Check for mistakes.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7707838. Configure here.

Comment thread stellar/its.js
.command('canonical-interchain-token-id <tokenAddress>')
.description('Get the canonical interchain token id for a token address')
.action((tokenAddress, options) => {
mainProcessor(canonicalInterchainTokenId, [tokenAddress], options);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Queries exit before completion

High Severity

The new command actions start mainProcessor without returning its promise. Since program.parseAsync() exits after the action returns, these queries can terminate before canonicalInterchainTokenId, interchainTokenId, or linkedTokenId finishes, producing no result and hiding failures.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7707838. Configure here.

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.

3 participants