Skip to content

Commit

Permalink
feat: export Balance type (#2374)
Browse files Browse the repository at this point in the history
Closes #1823
  • Loading branch information
ckniffen authored Jul 10, 2023
1 parent 8243691 commit f07e2c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
6 changes: 6 additions & 0 deletions packages/xrpl/src/models/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export interface IssuedCurrencyAmount extends IssuedCurrency {

export type Amount = IssuedCurrencyAmount | string

export interface Balance {
currency: string
issuer?: string
value: string
}

export interface Signer {
Signer: {
Account: string
Expand Down
8 changes: 1 addition & 7 deletions packages/xrpl/src/sugar/balances.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import flatMap from 'lodash/flatMap'

import type { Client } from '..'
import type { Balance, Client } from '..'
import {
AccountLinesRequest,
AccountLinesTrustline,
Expand All @@ -9,12 +9,6 @@ import {
} from '../models'
import { dropsToXrp } from '../utils'

interface Balance {
value: string
currency: string
issuer?: string
}

function formatBalances(trustlines: AccountLinesTrustline[]): Balance[] {
return trustlines.map((trustline) => ({
value: trustline.balance,
Expand Down
21 changes: 8 additions & 13 deletions packages/xrpl/src/utils/getBalanceChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ import BigNumber from 'bignumber.js'
import flatten from 'lodash/flatten'
import groupBy from 'lodash/groupBy'

import { Amount, IssuedCurrencyAmount } from '../models/common'
import { TransactionMetadata, Node } from '../models/transactions/metadata'
import {
Amount,
Balance,
IssuedCurrencyAmount,
TransactionMetadata,
Node,
} from '../models'

import { dropsToXrp } from './xrpConversion'

interface Balance {
currency: string
issuer?: string
value: string
}

interface BalanceChange {
account: string
balance: Balance
Expand Down Expand Up @@ -164,11 +163,7 @@ export default function getBalanceChanges(
metadata: TransactionMetadata,
): Array<{
account: string
balances: Array<{
currency: string
issuer?: string
value: string
}>
balances: Balance[]
}> {
const quantities = normalizeNodes(metadata).map((node) => {
if (node.LedgerEntryType === 'AccountRoot') {
Expand Down

0 comments on commit f07e2c7

Please sign in to comment.