Skip to content

Commit

Permalink
only apply mptamount for payment and claw
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Apr 22, 2024
1 parent a9d5a9b commit 3093e38
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/xrpl/src/client/partialPayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import { isFlagEnabled } from '../models/utils'

const WARN_PARTIAL_PAYMENT_CODE = 2001

function amountsEqual(amt1: Amount, amt2: Amount): boolean {
function amountsEqual(
amt1: Amount | MPTAmount,
amt2: Amount | MPTAmount,
): boolean {
if (typeof amt1 === 'string' && typeof amt2 === 'string') {
return amt1 === amt2
}
Expand Down
2 changes: 1 addition & 1 deletion packages/xrpl/src/models/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface MPTAmount {
value: string
}

export type Amount = IssuedCurrencyAmount | MPTAmount | string
export type Amount = IssuedCurrencyAmount | string

export interface Balance {
currency: string
Expand Down
6 changes: 3 additions & 3 deletions packages/xrpl/src/models/transactions/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Amount } from '../common'
import { Amount, MPTAmount } from '../common'

import { BaseTransaction } from './common'
import {
Expand Down Expand Up @@ -82,9 +82,9 @@ export function isDeletedNode(node: Node): node is DeletedNode {

export interface TransactionMetadataBase {
AffectedNodes: Node[]
DeliveredAmount?: Amount
DeliveredAmount?: Amount | MPTAmount
// "unavailable" possible for transactions before 2014-01-20
delivered_amount?: Amount | 'unavailable'
delivered_amount?: Amount | MPTAmount | 'unavailable'
TransactionIndex: number
TransactionResult: string
}
Expand Down
8 changes: 4 additions & 4 deletions packages/xrpl/src/models/transactions/payment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ValidationError } from '../../errors'
import { Amount, Path } from '../common'
import { Amount, Path, MPTAmount } from '../common'
import { isFlagEnabled } from '../utils'

import {
Expand Down Expand Up @@ -116,7 +116,7 @@ export interface Payment extends BaseTransaction {
* names MUST be lower-case. If the tfPartialPayment flag is set, deliver up
* to this amount instead.
*/
Amount: Amount
Amount: Amount | MPTAmount
/** The unique address of the account receiving the payment. */
Destination: Account
/**
Expand Down Expand Up @@ -153,8 +153,8 @@ export interface Payment extends BaseTransaction {
}

export interface PaymentMetadata extends TransactionMetadataBase {
DeliveredAmount?: Amount
delivered_amount?: Amount | 'unavailable'
DeliveredAmount?: Amount | MPTAmount
delivered_amount?: Amount | MPTAmount | 'unavailable'
}

/**
Expand Down

0 comments on commit 3093e38

Please sign in to comment.