mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
refactor isIssue to isCurrency
This commit is contained in:
@@ -5,7 +5,7 @@ import { Amount, Currency } from '../common'
|
||||
import {
|
||||
BaseTransaction,
|
||||
isAmount,
|
||||
isIssue,
|
||||
isCurrency,
|
||||
validateBaseTransaction,
|
||||
} from './common'
|
||||
|
||||
@@ -71,7 +71,7 @@ export function validateAMMBid(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMBid: missing field Asset')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset)) {
|
||||
if (!isCurrency(tx.Asset)) {
|
||||
throw new ValidationError('AMMBid: Asset must be an Issue')
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ export function validateAMMBid(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMBid: missing field Asset2')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset2)) {
|
||||
if (!isCurrency(tx.Asset2)) {
|
||||
throw new ValidationError('AMMBid: Asset2 must be an Issue')
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
BaseTransaction,
|
||||
GlobalFlags,
|
||||
isAmount,
|
||||
isIssue,
|
||||
isCurrency,
|
||||
isIssuedCurrency,
|
||||
validateBaseTransaction,
|
||||
} from './common'
|
||||
@@ -93,7 +93,7 @@ export function validateAMMDeposit(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMDeposit: missing field Asset')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset)) {
|
||||
if (!isCurrency(tx.Asset)) {
|
||||
throw new ValidationError('AMMDeposit: Asset must be an Issue')
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ export function validateAMMDeposit(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMDeposit: missing field Asset2')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset2)) {
|
||||
if (!isCurrency(tx.Asset2)) {
|
||||
throw new ValidationError('AMMDeposit: Asset2 must be an Issue')
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ValidationError } from '../../errors'
|
||||
import { Currency } from '../common'
|
||||
|
||||
import { AMM_MAX_TRADING_FEE } from './AMMCreate'
|
||||
import { BaseTransaction, isIssue, validateBaseTransaction } from './common'
|
||||
import { BaseTransaction, isCurrency, validateBaseTransaction } from './common'
|
||||
|
||||
/**
|
||||
* AMMVote is used for submitting a vote for the trading fee of an AMM Instance.
|
||||
@@ -45,7 +45,7 @@ export function validateAMMVote(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMVote: missing field Asset')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset)) {
|
||||
if (!isCurrency(tx.Asset)) {
|
||||
throw new ValidationError('AMMVote: Asset must be an Issue')
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export function validateAMMVote(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMVote: missing field Asset2')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset2)) {
|
||||
if (!isCurrency(tx.Asset2)) {
|
||||
throw new ValidationError('AMMVote: Asset2 must be an Issue')
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
BaseTransaction,
|
||||
GlobalFlags,
|
||||
isAmount,
|
||||
isIssue,
|
||||
isCurrency,
|
||||
isIssuedCurrency,
|
||||
validateBaseTransaction,
|
||||
} from './common'
|
||||
@@ -99,7 +99,7 @@ export function validateAMMWithdraw(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMWithdraw: missing field Asset')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset)) {
|
||||
if (!isCurrency(tx.Asset)) {
|
||||
throw new ValidationError('AMMWithdraw: Asset must be an Issue')
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ export function validateAMMWithdraw(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMWithdraw: missing field Asset2')
|
||||
}
|
||||
|
||||
if (!isIssue(tx.Asset2)) {
|
||||
if (!isCurrency(tx.Asset2)) {
|
||||
throw new ValidationError('AMMWithdraw: Asset2 must be an Issue')
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
* @param input - The input to check the form and type of.
|
||||
* @returns Whether the IssuedCurrency is properly formed.
|
||||
*/
|
||||
export function isIssue(input: unknown): input is Currency {
|
||||
export function isCurrency(input: unknown): input is Currency {
|
||||
return (
|
||||
isRecord(input) &&
|
||||
((Object.keys(input).length === ISSUE_SIZE &&
|
||||
|
||||
Reference in New Issue
Block a user