@@ -25,7 +25,7 @@ import {
2525 UnexpectedAddressError ,
2626 VerifyTransactionOptions ,
2727} from '@bitgo/sdk-core' ;
28- import { coins , BaseCoin as StaticsBaseCoin , XrpCoin } from '@bitgo/statics' ;
28+ import { coins , BaseCoin as StaticsBaseCoin , XrpCoin , XrpMptCoin } from '@bitgo/statics' ;
2929import * as rippleKeypairs from 'ripple-keypairs' ;
3030import * as xrpl from 'xrpl' ;
3131
@@ -132,6 +132,8 @@ export class Xrp extends BaseCoin {
132132 return {
133133 requiresTokenEnablement : true ,
134134 supportsMultipleTokenEnablements : false ,
135+ getEnableTokenType : ( tokenName : string ) =>
136+ coins . has ( tokenName ) && coins . get ( tokenName ) instanceof XrpMptCoin ? 'enableMpt' : 'enabletoken' ,
135137 } ;
136138 }
137139
@@ -219,7 +221,7 @@ export class Xrp extends BaseCoin {
219221 try {
220222 transaction = JSON . parse ( txHex ) ;
221223 txHex = rippleBinaryCodec . encode ( transaction ) ;
222- } catch ( e ) {
224+ } catch ( e2 ) {
223225 throw new Error ( 'txHex needs to be either hex or JSON string for XRP' ) ;
224226 }
225227 }
@@ -329,18 +331,25 @@ export class Xrp extends BaseCoin {
329331 } catch ( e ) {
330332 try {
331333 transaction = JSON . parse ( txHex ) ;
332- } catch ( e ) {
334+ } catch ( e2 ) {
333335 throw new Error ( 'txHex needs to be either hex or JSON string for XRP' ) ;
334336 }
335337 }
336338
337339 return transaction . TransactionType ;
338340 }
339341
340- verifyTxType ( txPrebuildDecoded : TransactionExplanation , txHexPrebuild : string | undefined ) : void {
342+ verifyTxType ( txPrebuildDecoded : TransactionExplanation , txHexPrebuild : string | undefined , isMpt = false ) : void {
341343 if ( ! txHexPrebuild ) throw new Error ( 'Missing txHexPrebuild to verify token type for enabletoken tx' ) ;
342344 const transactionType = this . getTransactionTypeRawTxHex ( txHexPrebuild ) ;
343345 if ( transactionType === undefined ) throw new Error ( 'Missing TransactionType on token enablement tx' ) ;
346+
347+ if ( isMpt ) {
348+ if ( transactionType !== XrpTransactionType . MPTokenAuthorize )
349+ throw new Error ( `tx type ${ transactionType } does not match expected type MPTokenAuthorize` ) ;
350+ return ;
351+ }
352+
344353 if ( transactionType !== XrpTransactionType . TrustSet )
345354 throw new Error ( `tx type ${ transactionType } does not match expected type TrustSet` ) ;
346355 // decoded payload type could come as undefined or any of the enabletoken like types but never as something else like Send, etc
@@ -438,6 +447,13 @@ export class Xrp extends BaseCoin {
438447
439448 // Explaining a tx strips out certain data, for extra measurement we're checking vs the explained tx
440449 // but also vs the tx pre explained.
450+ if ( txParams . type === 'enableMpt' ) {
451+ if ( verification ?. verifyTokenEnablement ) {
452+ this . verifyTxType ( explanation , txPrebuild . txHex , true ) ;
453+ }
454+ return true ;
455+ }
456+
441457 if ( txParams . type === 'enabletoken' && verification ?. verifyTokenEnablement ) {
442458 this . verifyTxType ( explanation , txPrebuild . txHex ) ;
443459 this . verifyActivationAddress ( txParams , explanation ) ;
0 commit comments