Skip to content

Commit

Permalink
fix bad comment and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Aug 21, 2024
1 parent 7d43a14 commit e885c3a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export interface MPTokenIssuanceCreate extends BaseTransaction {
* Specifies the hex-encoded maximum asset amount of this token that should ever be issued.
* It is a non-negative integer that can store a range of up to 63 bits. If not set, the max
* amount will default to the largest unsigned 63-bit integer (0x7FFFFFFFFFFFFFFF)
*
* Helper function `mptUint64ToHex` can be used to help converting from base 10 or 16 string
* to a valid value.
*
* Example:
* ```
* MaximumAmount: '3e8' // 0x3E8 in hex or 1000 in decimal
* MaximumAmount: mptUint64ToHex('1000') // 1000 in decimal using helper function
* ```
*/
MaximumAmount?: string
/**
Expand Down
6 changes: 2 additions & 4 deletions packages/xrpl/src/models/transactions/MPTokenIssuanceSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import { ValidationError } from '../../errors'
*/
export enum MPTokenIssuanceSetFlags {
/**
* If set, indicates that the MPT can be locked both individually and globally.
* If not set, the MPT cannot be locked in any way.
* If set, indicates that issuer locks the MPT
*/
tfMPTLock = 0x00000001,
/**
* If set, indicates that the MPT can be locked both individually and globally.
* If not set, the MPT cannot be locked in any way.
* If set, indicates that issuer unlocks the MPT
*/
tfMPTUnlock = 0x00000002,
}
Expand Down
11 changes: 10 additions & 1 deletion packages/xrpl/src/utils/mptConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ import { ValidationError } from '../errors'
const SANITY_CHECK = /^[0-9]+$/u

/**
* Convert an unsigned 64-bit integer string to hex string. Mostly used for the MaximumAmount field
* Convert an unsigned 64-bit decimal string to hex string. Mostly used for the MaximumAmount field
* in MPTokenIssuanceCreate.
*
* @param numberToConvert - Non-negative number string.
* @returns Amount in hex string.
* @throws When amount is invalid.
* @category Utilities
*
* @example
* ```typescript
* const decimalString = mptUint64ToHex("1000");
* console.log(decimalString); // Output: "3e8"
*
* const hexString = mptUint64ToHex("0x3e8");
* console.log(hexString); // Output: "3e8"
* ```
*/
export function mptUint64ToHex(numberToConvert: string): string {
// convert to base 10 string first for inputs like scientific notation
Expand Down

0 comments on commit e885c3a

Please sign in to comment.