@@ -137,6 +137,12 @@ export interface XrpCoinConstructorOptions extends AccountConstructorOptions {
137137 contractAddress : string ;
138138}
139139
140+ export interface XrpMptCoinConstructorOptions extends AccountConstructorOptions {
141+ mptIssuanceId : string ; // 48-char hex MPTokenIssuanceID — stored as contractAddress
142+ canTransfer : boolean ; // immutable lsfMPTCanTransfer (0x0008) flag
143+ assetScale : number ; // immutable AssetScale from MPTokenIssuanceCreate
144+ }
145+
140146export interface SuiCoinConstructorOptions extends AccountConstructorOptions {
141147 packageId : string ;
142148 module : string ;
@@ -607,6 +613,34 @@ export class XrpCoin extends AccountCoinToken {
607613 }
608614}
609615
616+ /**
617+ * XRP Ledger Multi-Purpose Token (MPT) — MPTokensV1 amendment.
618+ * Identified by a 48-char hex MPTokenIssuanceID stored as contractAddress.
619+ * Uses account_objects (not account_lines). No issuer::currency pattern.
620+ * Named xrp:<token_name> — same pattern as trust-line tokens.
621+ */
622+ export class XrpMptCoin extends AccountCoinToken {
623+ public readonly contractAddress : string ; // MPTokenIssuanceID
624+ public readonly canTransfer : boolean ; // immutable — set at MPTokenIssuanceCreate
625+
626+ constructor ( options : XrpMptCoinConstructorOptions ) {
627+ super ( { ...options } ) ;
628+
629+ if ( ! / ^ [ 0 - 9 a - f A - F ] { 48 } $ / . test ( options . mptIssuanceId ) ) {
630+ throw new InvalidContractAddressError ( options . name , options . mptIssuanceId ) ;
631+ }
632+
633+ if ( ! Number . isInteger ( options . assetScale ) || options . assetScale < 0 || options . assetScale > 255 ) {
634+ throw new Error (
635+ `invalid assetScale '${ options . assetScale } ' for coin '${ options . name } ': must be an integer between 0 and 255 (uint8)`
636+ ) ;
637+ }
638+
639+ this . contractAddress = options . mptIssuanceId ;
640+ this . canTransfer = options . canTransfer ;
641+ }
642+ }
643+
610644export class SuiCoin extends AccountCoinToken {
611645 public packageId : string ;
612646 public module : string ;
@@ -3313,6 +3347,85 @@ export function txrpToken(
33133347 ) ;
33143348}
33153349
3350+ /**
3351+ * Factory function for mainnet XRP MPT token instances.
3352+ *
3353+ * @param id uuid v4
3354+ * @param name unique identifier of the token, e.g. "xrp:my_mpt"
3355+ * @param fullName Complete human-readable name of the token
3356+ * @param mptIssuanceId 48-char hex MPTokenIssuanceID
3357+ * @param canTransfer immutable lsfMPTCanTransfer flag from MPTokenIssuanceCreate
3358+ * @param assetScale immutable display decimal places from MPTokenIssuanceCreate (also used as decimalPlaces)
3359+ * @param asset UnderlyingAsset enum value
3360+ * @param features Optional coin features
3361+ * @param network Optional network override (defaults to mainnet XRP)
3362+ */
3363+ export function xrpMptToken (
3364+ id : string ,
3365+ name : string ,
3366+ fullName : string ,
3367+ mptIssuanceId : string ,
3368+ canTransfer : boolean ,
3369+ assetScale : number ,
3370+ asset : UnderlyingAsset ,
3371+ features : CoinFeature [ ] = AccountCoin . DEFAULT_FEATURES ,
3372+ prefix = '' ,
3373+ suffix : string = name . toUpperCase ( ) ,
3374+ network : AccountNetwork = Networks . main . xrp ,
3375+ primaryKeyCurve : KeyCurve = KeyCurve . Secp256k1
3376+ ) {
3377+ return Object . freeze (
3378+ new XrpMptCoin ( {
3379+ id,
3380+ name,
3381+ fullName,
3382+ network,
3383+ mptIssuanceId,
3384+ canTransfer,
3385+ assetScale,
3386+ prefix,
3387+ suffix,
3388+ features,
3389+ decimalPlaces : assetScale , // assetScale IS the display decimal places — same concept as decimalPlaces elsewhere
3390+ asset,
3391+ isToken : true ,
3392+ primaryKeyCurve,
3393+ baseUnit : BaseUnit . XRP ,
3394+ } )
3395+ ) ;
3396+ }
3397+
3398+ /**
3399+ * Factory function for testnet XRP MPT token instances.
3400+ */
3401+ export function txrpMptToken (
3402+ id : string ,
3403+ name : string ,
3404+ fullName : string ,
3405+ mptIssuanceId : string ,
3406+ canTransfer : boolean ,
3407+ assetScale : number ,
3408+ asset : UnderlyingAsset ,
3409+ features : CoinFeature [ ] = AccountCoin . DEFAULT_FEATURES ,
3410+ prefix = '' ,
3411+ suffix : string = name . toUpperCase ( ) ,
3412+ network : AccountNetwork = Networks . test . xrp
3413+ ) {
3414+ return xrpMptToken (
3415+ id ,
3416+ name ,
3417+ fullName ,
3418+ mptIssuanceId ,
3419+ canTransfer ,
3420+ assetScale ,
3421+ asset ,
3422+ features ,
3423+ prefix ,
3424+ suffix ,
3425+ network
3426+ ) ;
3427+ }
3428+
33163429/**
33173430 * Factory function for sui token instances.
33183431 *
0 commit comments