File tree Expand file tree Collapse file tree 5 files changed +19
-23
lines changed
Expand file tree Collapse file tree 5 files changed +19
-23
lines changed Original file line number Diff line number Diff line change 11/* eslint-disable no-inline-comments -- Necessary for important note */
22/* eslint-disable max-lines -- There is a lot to export */
3- /* eslint-disable prettier/prettier -- Required here to keep formatting in line */
43import type { APIVersion , DEFAULT_API_VERSION } from '../common'
54
65import {
@@ -37,17 +36,17 @@ import {
3736 AccountObjectsResponse ,
3837 AccountObjectType ,
3938} from './accountObjects'
39+ import {
40+ AccountOffer ,
41+ AccountOffersRequest ,
42+ AccountOffersResponse ,
43+ } from './accountOffers'
4044import {
4145 AccountSponsoringObjectType ,
4246 AccountSponsoringRequest ,
4347 AccountSponsoringResponse ,
4448 SponsoredObject ,
4549} from './accountSponsoring'
46- import {
47- AccountOffer ,
48- AccountOffersRequest ,
49- AccountOffersResponse ,
50- } from './accountOffers'
5150import {
5251 AccountTxRequest ,
5352 AccountTxResponse ,
Original file line number Diff line number Diff line change @@ -721,9 +721,12 @@ export function validateBaseTransaction(
721721
722722 // Validate SponsorFlags has valid values
723723 if ( hasSponsorFlags ) {
724- const validFlags = SponsorFlags . tfSponsorFee | SponsorFlags . tfSponsorReserve
725- const flags = common . SponsorFlags as number
726- if ( ( flags & ~ validFlags ) !== 0 || flags === 0 ) {
724+ const flags = Number ( common . SponsorFlags )
725+ const isValidFlag =
726+ flags === SponsorFlags . tfSponsorFee ||
727+ flags === SponsorFlags . tfSponsorReserve ||
728+ flags === SponsorFlags . tfSponsorFee + SponsorFlags . tfSponsorReserve
729+ if ( ! isValidFlag ) {
727730 throw new ValidationError (
728731 'BaseTransaction: invalid SponsorFlags - must include tfSponsorFee and/or tfSponsorReserve' ,
729732 )
Original file line number Diff line number Diff line change @@ -148,12 +148,10 @@ export function validateSponsorshipSet(tx: Record<string, unknown>): void {
148148 validateOptionalField ( tx , 'ReserveCount' , isNumber )
149149
150150 // Validate flag combinations with tfDeleteObject
151- const flags =
152- typeof tx . Flags === 'number' ? tx . Flags : 0
153-
151+ const flags = typeof tx . Flags === 'number' ? tx . Flags : 0
154152 const tfDeleteObject = SponsorshipSetFlags . tfDeleteObject
155153
156- if ( ( flags & tfDeleteObject ) !== 0 ) {
154+ if ( flags === tfDeleteObject ) {
157155 // When deleting, cannot specify FeeAmount, MaxFee, or ReserveCount
158156 if ( tx . FeeAmount !== undefined ) {
159157 throw new ValidationError (
@@ -172,4 +170,3 @@ export function validateSponsorshipSet(tx: Record<string, unknown>): void {
172170 }
173171 }
174172}
175-
Original file line number Diff line number Diff line change @@ -57,13 +57,10 @@ export interface SponsorshipTransfer extends BaseTransaction {
5757 * @param tx - A SponsorshipTransfer Transaction.
5858 * @throws When the SponsorshipTransfer is malformed.
5959 */
60- export function validateSponsorshipTransfer (
61- tx : Record < string , unknown > ,
62- ) : void {
60+ export function validateSponsorshipTransfer ( tx : Record < string , unknown > ) : void {
6361 validateBaseTransaction ( tx )
6462
6563 validateOptionalField ( tx , 'ObjectID' , isString )
6664 validateOptionalField ( tx , 'Sponsor' , isAccount )
6765 validateOptionalField ( tx , 'SponsorFlags' , isNumber )
6866}
69-
Original file line number Diff line number Diff line change 11import { assert } from 'chai'
22
3+ import AccountRoot from '../../src/models/ledger/AccountRoot'
4+ import { BaseLedgerEntry } from '../../src/models/ledger/BaseLedgerEntry'
5+ import Check from '../../src/models/ledger/Check'
6+ import Escrow from '../../src/models/ledger/Escrow'
7+ import Offer from '../../src/models/ledger/Offer'
38import {
49 AccountObjectsRequest ,
510 AccountSponsoringRequest ,
611 AccountSponsoringResponse ,
712} from '../../src/models/methods'
8- import Check from '../../src/models/ledger/Check'
9- import Escrow from '../../src/models/ledger/Escrow'
10- import Offer from '../../src/models/ledger/Offer'
11- import AccountRoot from '../../src/models/ledger/AccountRoot'
12- import { BaseLedgerEntry } from '../../src/models/ledger/BaseLedgerEntry'
1313
1414/**
1515 * Tests for XLS-0068 Sponsorship Feature Changes.
You can’t perform that action at this time.
0 commit comments