diff --git a/src/transaction/payment.ts b/src/transaction/payment.ts index 37051d5b..e3a7582d 100644 --- a/src/transaction/payment.ts +++ b/src/transaction/payment.ts @@ -10,8 +10,8 @@ import {Amount, Adjustment, MaxAdjustment, export type Payment = { - source: Adjustment & MaxAdjustment, - destination: Adjustment & MinAdjustment, + source: Adjustment | MaxAdjustment, + destination: Adjustment | MinAdjustment, paths?: string, memos?: Array, // A 256-bit hash that can be used to identify a particular payment @@ -74,8 +74,8 @@ function createPaymentTransaction(address: string, paymentArgument: Payment throw new ValidationError('address must match payment.source.address') } - if ((payment.source.maxAmount && payment.destination.minAmount) || - (payment.source.amount && payment.destination.amount)) { + if (((payment.source).maxAmount && (payment.destination).minAmount) || + ((payment.source).amount && (payment.destination).amount)) { throw new ValidationError('payment must specify either (source.maxAmount ' + 'and destination.amount) or (source.amount and destination.minAmount)') } @@ -86,9 +86,9 @@ function createPaymentTransaction(address: string, paymentArgument: Payment // send the whole source amount, so we set the destination amount to the // maximum possible amount. otherwise it's possible that the destination // cap could be hit before the source cap. - const amount = payment.destination.minAmount && !isXRPToXRPPayment(payment) ? - createMaximalAmount(payment.destination.minAmount) : - (payment.destination.amount || payment.destination.minAmount) + const amount = (payment.destination).minAmount && !isXRPToXRPPayment(payment) ? + createMaximalAmount((payment.destination).minAmount) : + ((payment.destination).amount || (payment.destination).minAmount) const txJSON: any = { TransactionType: 'Payment', @@ -122,15 +122,15 @@ function createPaymentTransaction(address: string, paymentArgument: Payment // https://github.com/ripple/rippled/commit/ // c522ffa6db2648f1d8a987843e7feabf1a0b7de8/ if (payment.allowPartialPayment === true - || payment.destination.minAmount !== undefined) { + || (payment.destination).minAmount !== undefined) { txJSON.Flags |= paymentFlags.PartialPayment } txJSON.SendMax = toRippledAmount( - payment.source.maxAmount || payment.source.amount) + (payment.source).maxAmount || (payment.source).amount) - if (payment.destination.minAmount !== undefined) { - txJSON.DeliverMin = toRippledAmount(payment.destination.minAmount) + if ((payment.destination).minAmount !== undefined) { + txJSON.DeliverMin = toRippledAmount((payment.destination).minAmount) } if (payment.paths !== undefined) {