Overview
The Sui helper utilities provide functions for currency conversion, transaction building, and validation. These utilities simplify interaction with the Sui blockchain and the TUNA smart contract.Currency Conversion
suiToMist
Convert SUI to MIST (1 SUI = 1,000,000,000 MIST).Amount in SUI to convert
number - Amount in MIST (floored to integer)
Example:
mistToSui
Convert MIST to SUI.Amount in MIST to convert
number - Amount in SUI
Example:
formatSui
Format MIST amount for user-friendly display.Amount in MIST to format
string - Formatted string with “SUI” suffix
Formatting Rules:
- < 0.001 SUI: displays ”< 0.001 SUI”
- < 1 SUI: displays with 3 decimal places
- ≥ 1 SUI: displays with 2 decimal places
Validation
isValidTipAmount
Validate that a tip amount meets the minimum requirement.Tip amount in MIST to validate
boolean - true if amount is valid, false otherwise
The minimum tip amount is defined in
CONSTANTS.MIN_TIP_AMOUNT from the config.Transaction Builders
createTipArticleTransaction
Create a transaction to tip an article author.The Walrus blob ID of the article
Tip amount in MIST
Transaction - Sui transaction object ready to be signed
Implementation Details:
- Splits coins from gas for the tip
- Calls
tip_articleon the TUNA smart contract - Passes registry object, blob ID, and tip coin
createPostCommentTransaction
Create a transaction to post a short comment (≤280 characters).The article blob ID to comment on
Comment text (maximum 280 characters)
Transaction - Sui transaction object
For comments longer than 280 characters, use
createPostCommentWithBlobTransaction instead.createPostCommentWithBlobTransaction
Create a transaction to post a long comment or comment with media.The article blob ID to comment on
Preview text (maximum 280 characters) displayed in feeds
Walrus blob ID containing the full comment content
Type of comment: ‘text_long’ for long text, ‘media’ for comments with images
Transaction - Sui transaction object
createTipCommentTransaction
Create a transaction to tip a comment.The Sui object ID of the comment
Tip amount in MIST
Transaction - Sui transaction object
createWithdrawCommentTipsTransaction
Create a transaction to withdraw accumulated tips from a comment.The Sui object ID of the comment to withdraw tips from
Transaction - Sui transaction object
Only the comment author can withdraw tips from their comments.
Source Reference
All Sui helper functions are implemented in:CONTRACT_CONFIG- Package ID, module name, registry IDCONSTANTS- Minimum tip amount and other constants
