From f6f5f6b09a1b3757fdc472c2d3a30e8a3d864e86 Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Mon, 11 Sep 2023 17:18:03 -0400 Subject: [PATCH] fix: request model fields related to AMM (#2473) * fix AuthAccount model * fix AuctionSlot.Price field to be IssuedCurrencyAmount * fix AMMBid BidMin & BidMan to IssuedCurrencyAmount * update HISTORY --- packages/xrpl/HISTORY.md | 3 +++ packages/xrpl/src/models/common/index.ts | 2 +- packages/xrpl/src/models/ledger/AMM.ts | 4 ++-- packages/xrpl/src/models/methods/ammInfo.ts | 2 +- packages/xrpl/src/models/transactions/AMMBid.ts | 10 +++++----- packages/xrpl/test/models/AMMBid.test.ts | 12 ++++++++++-- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/packages/xrpl/HISTORY.md b/packages/xrpl/HISTORY.md index 27105364..e0e291d1 100644 --- a/packages/xrpl/HISTORY.md +++ b/packages/xrpl/HISTORY.md @@ -3,6 +3,9 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release. ## Unreleased +## Fixed +* Fix request model fields related to AMM + ## 2.11.0 (2023-08-24) ### Added diff --git a/packages/xrpl/src/models/common/index.ts b/packages/xrpl/src/models/common/index.ts index a7eaf7e7..e9cbdac3 100644 --- a/packages/xrpl/src/models/common/index.ts +++ b/packages/xrpl/src/models/common/index.ts @@ -145,6 +145,6 @@ export interface NFToken { export interface AuthAccount { AuthAccount: { - account: string + Account: string } } diff --git a/packages/xrpl/src/models/ledger/AMM.ts b/packages/xrpl/src/models/ledger/AMM.ts index 5297370c..ddfee5d3 100644 --- a/packages/xrpl/src/models/ledger/AMM.ts +++ b/packages/xrpl/src/models/ledger/AMM.ts @@ -1,4 +1,4 @@ -import { AuthAccount, Currency } from '../common' +import { AuthAccount, Currency, IssuedCurrencyAmount } from '../common' import BaseLedgerEntry from './BaseLedgerEntry' @@ -53,7 +53,7 @@ export default interface AMM extends BaseLedgerEntry { /** * The amount the auction owner paid to win this slot, in LP Tokens. */ - Price: Currency + Price: IssuedCurrencyAmount } /** * The total outstanding balance of liquidity provider tokens from this AMM instance. diff --git a/packages/xrpl/src/models/methods/ammInfo.ts b/packages/xrpl/src/models/methods/ammInfo.ts index 8e59405e..3f503e6e 100644 --- a/packages/xrpl/src/models/methods/ammInfo.ts +++ b/packages/xrpl/src/models/methods/ammInfo.ts @@ -98,7 +98,7 @@ export interface AMMInfoResponse extends BaseResponse { * The amount, in LP Tokens, that the auction slot holder paid to win the auction slot. * This affects the price to outbid the current slot holder. */ - price: Amount + price: IssuedCurrencyAmount /** * The current 72-minute time interval this auction slot is in, from 0 to 19. diff --git a/packages/xrpl/src/models/transactions/AMMBid.ts b/packages/xrpl/src/models/transactions/AMMBid.ts index b7634ba5..48965d7d 100644 --- a/packages/xrpl/src/models/transactions/AMMBid.ts +++ b/packages/xrpl/src/models/transactions/AMMBid.ts @@ -1,6 +1,6 @@ /* eslint-disable complexity -- required for validateAMMBid */ import { ValidationError } from '../../errors' -import { Amount, AuthAccount, Currency } from '../common' +import { AuthAccount, Currency, IssuedCurrencyAmount } from '../common' import { BaseTransaction, @@ -33,18 +33,18 @@ export interface AMMBid extends BaseTransaction { Asset2: Currency /** - * Pay at least this amount for the slot. + * Pay at least this LPToken amount for the slot. * Setting this value higher makes it harder for others to outbid you. * If omitted, pay the minimum necessary to win the bid. */ - BidMin?: Amount + BidMin?: IssuedCurrencyAmount /** - * Pay at most this amount for the slot. + * Pay at most this LPToken amount for the slot. * If the cost to win the bid is higher than this amount, the transaction fails. * If omitted, pay as much as necessary to win the bid. */ - BidMax?: Amount + BidMax?: IssuedCurrencyAmount /** * A list of up to 4 additional accounts that you allow to trade at the discounted fee. diff --git a/packages/xrpl/test/models/AMMBid.test.ts b/packages/xrpl/test/models/AMMBid.test.ts index c958804a..d7f0ea73 100644 --- a/packages/xrpl/test/models/AMMBid.test.ts +++ b/packages/xrpl/test/models/AMMBid.test.ts @@ -22,8 +22,16 @@ describe('AMMBid', function () { currency: 'ETH', issuer: 'rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd', }, - BidMin: '5', - BidMax: '10', + BidMin: { + currency: '039C99CD9AB0B70B32ECDA51EAAE471625608EA2', + issuer: 'rE54zDvgnghAoPopCgvtiqWNq3dU5y836S', + value: '50', + }, + BidMax: { + currency: '039C99CD9AB0B70B32ECDA51EAAE471625608EA2', + issuer: 'rE54zDvgnghAoPopCgvtiqWNq3dU5y836S', + value: '100', + }, AuthAccounts: [ { AuthAccount: {