From 70d180c68b04ab012a48bb4df779d83683c462cf Mon Sep 17 00:00:00 2001 From: Omar Khan Date: Thu, 27 Jul 2023 18:58:43 -0400 Subject: [PATCH] refactor and export interfaces --- packages/xrpl/src/models/common/index.ts | 6 ++++++ packages/xrpl/src/models/ledger/AMM.ts | 10 ++-------- packages/xrpl/src/models/methods/ammInfo.ts | 20 ++++++++----------- .../xrpl/src/models/transactions/AMMBid.ts | 8 +------- 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/packages/xrpl/src/models/common/index.ts b/packages/xrpl/src/models/common/index.ts index f64ae22f8a..8a4e06b655 100644 --- a/packages/xrpl/src/models/common/index.ts +++ b/packages/xrpl/src/models/common/index.ts @@ -141,3 +141,9 @@ export interface NFToken { nft_serial: number uri: string } + +export interface AuthAccount { + AuthAccount: { + account: string + } +} diff --git a/packages/xrpl/src/models/ledger/AMM.ts b/packages/xrpl/src/models/ledger/AMM.ts index 1e501c8245..01f3fd1392 100644 --- a/packages/xrpl/src/models/ledger/AMM.ts +++ b/packages/xrpl/src/models/ledger/AMM.ts @@ -1,14 +1,8 @@ -import { Currency } from '../common' +import { AuthAccount, Currency } from '../common' import BaseLedgerEntry from './BaseLedgerEntry' -interface AuthAccount { - AuthAccount: { - account: string - } -} - -interface VoteSlot { +export interface VoteSlot { VoteEntry: { Account: string TradingFee: number diff --git a/packages/xrpl/src/models/methods/ammInfo.ts b/packages/xrpl/src/models/methods/ammInfo.ts index c451c3f4ba..d7e819cf2d 100644 --- a/packages/xrpl/src/models/methods/ammInfo.ts +++ b/packages/xrpl/src/models/methods/ammInfo.ts @@ -22,16 +22,6 @@ export interface AMMInfoRequest extends BaseRequest { asset2: Currency } -interface AuthAccount { - account: string -} - -interface VoteSlot { - account: string - trading_fee: number - vote_weight: number -} - /** * Response expected from an {@link AMMInfoRequest}. * @@ -81,7 +71,9 @@ export interface AMMInfoResponse extends BaseResponse { * of the discounted trading fee. * Each member of this array is an object with one field, account, containing the address of the designated account. */ - auth_accounts: AuthAccount[] + auth_accounts: Array<{ + account: string + }> /** * The discounted trading fee that applies to the auction slot holder, and any eligible accounts @@ -124,7 +116,11 @@ export interface AMMInfoResponse extends BaseResponse { /** * (May be omitted) The current votes for the AMM's trading fee, as Vote Slot Objects. */ - vote_slots?: VoteSlot[] + vote_slots?: Array<{ + account: string + trading_fee: number + vote_weight: number + }> } /** diff --git a/packages/xrpl/src/models/transactions/AMMBid.ts b/packages/xrpl/src/models/transactions/AMMBid.ts index 76a5eb9435..ad60a7dc10 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, Currency } from '../common' +import { Amount, AuthAccount, Currency } from '../common' import { BaseTransaction, @@ -11,12 +11,6 @@ import { const MAX_AUTH_ACCOUNTS = 4 -interface AuthAccount { - AuthAccount: { - Account: string - } -} - /** * Bid on an Automated Market Maker's (AMM's) auction slot. *