Skip to content

[PROTOTYPE - Invoke Contract] enable token units AND base units - #2164

Open
jeesunikim wants to merge 1 commit into
mainfrom
prototype-unit-convert
Open

[PROTOTYPE - Invoke Contract] enable token units AND base units#2164
jeesunikim wants to merge 1 commit into
mainfrom
prototype-unit-convert

Conversation

@jeesunikim

@jeesunikim jeesunikim commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

There are cases where SEP41 contracts' assets are hard to move because they often use a different set of decimal architectures. This PR is to alleviate the UX experience by querying the contract and adapt the 'amount' field to the specific asset architecture by using decimals() beforehand.

The pain points: To move SolvBTC and deJAAA in CC64WBDGS6QQP22QTTIACYIXT3WF7BBQEYOQPLTP7GTKYY7PZ74QYGSL,

  • To move 5 SolvBTC, users have to put 500000000
  • To move 5 deJAAA, users have to put 5000000000000000000
Screenshot 2026-07-23 at 10 10 31 AM

Copilot AI review requested due to automatic review settings July 23, 2026 17:29
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX Jul 23, 2026
@stellar-jenkins-ci

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds decimals-aware SEP-41 token amount entry while preserving raw base-unit submission.

Changes:

  • Queries token metadata through RPC simulation.
  • Adds token/raw amount modes with validation and conversion.
  • Propagates token metadata through schema rendering and adds unit tests.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/unit/tokenAmount.test.ts Tests amount conversion helpers.
tests/unit/getTokenAmountError.test.ts Tests token amount validation.
src/validate/methods/getTokenAmountError.ts Validates scaled token amounts.
src/validate/index.ts Exports the new validator.
src/types/types.ts Defines and propagates token metadata.
src/query/useGetTokenInfoFromRpc.ts Fetches decimals and symbol through simulation.
src/helpers/tokenAmount.ts Converts token and base units precisely.
src/constants/sep41AmountArgs.ts Identifies SEP-41 amount arguments.
src/components/SmartContractJsonSchema/TokenAmountInput.tsx Implements token/raw input modes.
src/components/SmartContractJsonSchema/renderTupleType.tsx Propagates token metadata through tuples.
src/components/SmartContractJsonSchema/renderPrimitivesType.tsx Renders decimals-aware integer inputs.
src/components/SmartContractJsonSchema/renderOneOf.tsx Propagates metadata through unions.
src/components/SmartContractJsonSchema/renderArrayType.tsx Propagates metadata through arrays.
src/components/SmartContractJsonSchema/JsonSchemaRenderer.tsx Routes metadata through schema rendering.
src/app/(sidebar)/smart-contracts/contract-explorer/components/InvokeContractForm.tsx Supplies metadata to invocation fields.
src/app/(sidebar)/smart-contracts/contract-explorer/components/InvokeContract.tsx Detects token contracts and requests metadata.
Comments suppressed due to low confidence (1)

src/components/SmartContractJsonSchema/TokenAmountInput.tsx:125

  • Every function card passes a path-only ID such as amount, while InvokeContract mounts all function cards together. This gives the new radios duplicate IDs and the same name, so the browser treats transfer/approve/burn controls as one radio group; selecting one card can uncheck another, and labels may target the wrong control. Include the function name or another per-instance identifier in both the IDs and group name.
          id={`${id}-mode-tokens`}
          name={`${id}-amount-mode`}

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

Comment on lines +99 to +101
// Clear stale errors from the previous mode; the counterpart value is a
// valid representation of the same stored raw integer.
onError(false);
* integer string, so simulation/submission paths are untouched. The
* human-units string is local component state only.
*/
export const TokenAmountInput = ({
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

2 participants