Description:
The contract exposes get_token_decimals(token: Address) (at lib.rs:430-434) that returns the decimal precision for a registered token (e.g., 6 for USDC, 7 for XLM). This is critical for correctly formatting token amounts in UI displays.
The contract implementation:
pub fn get_token_decimals(env: Env, token: Address) -> Option<u32> {
env.storage()
.persistent()
.get(&crate::storage::DataKey::TokenDecimals(token))
}
The SDK method should:
- Accept a token address parameter
- Call the contract's
get_token_decimals view
- Return
number | null (null if token is not registered)
- Handle the Stellar address type conversion
Why it matters: Displaying token amounts correctly requires knowing the decimal precision. Without this, 1 USDC (10,000,000 stroops) could be displayed as 10000000 instead of 1.00.
Acceptance Criteria:
Relevant Files: contracts/invoice_liquidity/src/lib.rs:430-434, sdk/src/index.ts
Description:
The contract exposes
get_token_decimals(token: Address)(atlib.rs:430-434) that returns the decimal precision for a registered token (e.g., 6 for USDC, 7 for XLM). This is critical for correctly formatting token amounts in UI displays.The contract implementation:
The SDK method should:
get_token_decimalsviewnumber | null(null if token is not registered)Why it matters: Displaying token amounts correctly requires knowing the decimal precision. Without this, 1 USDC (10,000,000 stroops) could be displayed as 10000000 instead of 1.00.
Acceptance Criteria:
sdk/src/methods/that callsget_token_decimalsPromise<number | null>sdk/src/index.tsRelevant Files:
contracts/invoice_liquidity/src/lib.rs:430-434,sdk/src/index.ts