typescript contract binding code-gen type definitions are duplicated/missing

Open
#2,259 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust, typescript
Domain
cli, tooling

Research direction

Start by running the three stellar contract bindings typescript commands and inspecting the generated src/index.ts files. Trace the contract binding TypeScript code-generation entry point to determine why shared types are duplicated or omitted, then verify that each generated output builds without duplicate definitions or unresolved types.

Written by the indexing model from the issue text.

Description

bug

The exact issues here are distinct but possibly related to https://github.com/stellar/stellar-cli/issues/732.

What version are you using?
stellar version
stellar 23.1.4 ()
stellar-xdr 23.0.0 (e83a6337204ecfdb0ac0d44ffb857130c1249b1b)
xdr curr (4b7a2ef7931ab2ca2499be68d849f38190b443ca)
What did you do?
Example 1:
stellar contract bindings typescript \
  --rpc-url https://soroban-testnet.stellar.org/ \
  --network-passphrase "Test SDF Network ; September 2015" \
  --contract-id CBZHXZBNABBQRFBNQXYXMJ3NKETUKDIBSILNQUWHVV3RXMRP3AZYLK66 \
  --output-dir ./factory \
  --overwrite
Example 2:
stellar contract bindings typescript \
  --rpc-url https://soroban-testnet.stellar.org/ \
  --network-passphrase "Test SDF Network ; September 2015" \
  --contract-id CCYJJ2A2BAQHKKSNJ3NHRV66GA6XCHHBLROFBBR7J33YIYMWDL57XOUL \
  --output-dir ./pool \
  --overwrite
Example 3:
stellar contract bindings typescript \
  --rpc-url https://soroban-testnet.stellar.org/ \
  --network-passphrase "Test SDF Network ; September 2015" \
  --contract-id CAVSGXMRXOCASPTKMLCFCPEKOLNMSQRFTLTLHYIBXBP22K2GUEIN5IN7 \
  --output-dir ./router \
  --overwrite
What did you expect to see?

Generated buildable src/index.ts.

What did you see instead?

Build errors as follows.

Example 1:

Duplicate definition of the StorageKey type

export type StorageKey = {tag: "Owner", values: void} | {tag: "FeeAmtTickSpacing", values: readonly [u32]} | {tag: "GetPool", values: readonly [string, string, u32]} | {tag: "WasmHash", values: void};
export type StorageKey = {tag: "Owner", values: void} | {tag: "FeeAmtTickSpacing", values: readonly [u32]} | {tag: "GetPool", values: readonly [string, string, u32]} | {tag: "WasmHash", values: void} | {tag: "DefaultRouter", values: void};
Example 2:

The SqrtPriceX96 type is not defined (this is defined as u256 in the contract source code)

export interface SwapStepResult {
  amount_in: u256;
  amount_out: u256;
  fee_amount: u256;
  sqrt_ratio_next: SqrtPriceX96;
}
Example 3:

The SqrtPriceX96 type is not defined (this is defined as u256 in the contract source code)

export interface SwapStepResult {
  amount_in: u256;
  amount_out: u256;
  fee_amount: u256;
  sqrt_ratio_next: SqrtPriceX96;
}

The CountryCode type is not defined

/**
 * Represents different types of country relationships for individuals
 */
export type IndividualCountryRelation = {tag: "Residence", values: readonly [CountryCode]} | {tag: "Citizenship", values: readonly [CountryCode]} | {tag: "SourceOfFunds", values: readonly [CountryCode]} | {tag: "TaxResidency", values: readonly [CountryCode]} | {tag: "Custom", values: readonly [string, CountryCode]};

/**
 * Represents different types of country relationships for organizations
 */
export type OrganizationCountryRelation = {tag: "Incorporation", values: readonly [CountryCode]} | {tag: "OperatingJurisdiction", values: readonly [CountryCode]} | {tag: "TaxJurisdiction", values: readonly [CountryCode]} | {tag: "SourceOfFunds", values: readonly [CountryCode]} | {tag: "Custom", values: readonly [string, CountryCode]};

Duplicate definition of the DataKey type

/**
 * Keys under which we'll store the immutable fields
 */
export type DataKey = {tag: "Factory", values: void} | {tag: "XlmAddress", values: void};

// ...

/**
 * Storage keys for the modular compliance contract.
 */
export type DataKey = {tag: "HookModules", values: readonly [ComplianceHook]} | {tag: "ModuleRegistered", values: readonly [ComplianceHook, string]};
Dominant language
Rust
Stars
123
Forks
141
Avg merge
2d 21h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-cli

All issues in stellar/stellar-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.