soroban-cli icon indicating copy to clipboard operation
soroban-cli copied to clipboard

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

Open wu-benjamin opened this issue 1 month ago • 6 comments
trafficstars

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]};

wu-benjamin avatar Oct 15 '25 13:10 wu-benjamin