[PROTOTYPE - Invoke Contract] enable token units AND base units - #2164
Open
jeesunikim wants to merge 1 commit into
Open
[PROTOTYPE - Invoke Contract] enable token units AND base units#2164jeesunikim wants to merge 1 commit into
jeesunikim wants to merge 1 commit into
Conversation
|
Preview is available here: |
Contributor
There was a problem hiding this comment.
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, whileInvokeContractmounts all function cards together. This gives the new radios duplicate IDs and the samename, 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 = ({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,SolvBTC, users have to put500000000deJAAA, users have to put5000000000000000000