Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/haystack/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,10 @@ export class RouterClient {
)
}

// Conditionally include deprecated protocols in disabled list
// If _allowNonComposableSwaps is true, only exclude Tinyman v1 from auto-disabled list
// Otherwise, always include all deprecated protocols (Tinyman v1, Humble)
// Always disable the deprecated protocols (Tinyman v1), unless
// _allowNonComposableSwaps opts into Tinyman v1
const allDisabledProtocols = _allowNonComposableSwaps
? [...new Set(['Humble', ...disabledProtocols])]
? [...new Set(disabledProtocols)]
: [...new Set([...DEPRECATED_PROTOCOLS, ...disabledProtocols])]

let includeOptIn = optIn
Expand Down
3 changes: 2 additions & 1 deletion packages/haystack/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
export enum Protocol {
TinymanV2 = 'TinymanV2',
Humble = 'Humble',
Algofi = 'Algofi',
Algomint = 'Algomint',
Pact = 'Pact',
Expand All @@ -15,7 +16,7 @@ export enum Protocol {
*
* @internal
*/
export const DEPRECATED_PROTOCOLS = ['Humble', 'Tinyman'] as const
export const DEPRECATED_PROTOCOLS = ['Tinyman'] as const

/** Default Algod node URI for mainnet */
export const DEFAULT_ALGOD_URI = 'https://mainnet-api.4160.nodely.dev/'
Expand Down
13 changes: 5 additions & 8 deletions packages/haystack/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ describe('RouterClient', () => {
expect(callUrl).toContain('toASAID=31566704')
expect(callUrl).toContain('amount=1000000')
expect(callUrl).toContain('type=fixed-output')
expect(callUrl).toContain(
'disabledProtocols=Humble%2CTinyman%2CTinymanV2',
)
expect(callUrl).toContain('disabledProtocols=Tinyman%2CTinymanV2')
expect(callUrl).toContain('maxGroupSize=12')
expect(callUrl).toContain('maxDepth=3')
expect(callUrl).toContain('optIn=true')
Expand All @@ -190,8 +188,8 @@ describe('RouterClient', () => {
})

const callUrl = mockRequest.mock.calls?.[0]?.[0] as string
expect(callUrl).toContain('Humble')
expect(callUrl).toContain('Tinyman')
expect(callUrl).toContain('disabledProtocols=Tinyman&')
expect(callUrl).not.toContain('Humble')
})

it('should use custom apiBaseUrl when provided', async () => {
Expand Down Expand Up @@ -540,8 +538,7 @@ describe('RouterClient', () => {
const callUrl = mockRequest.mock.calls?.[0]?.[0] as string
// Should NOT include Tinyman when _allowNonComposableSwaps is true
expect(callUrl).not.toContain('Tinyman')
// Should still include Humble
expect(callUrl).toContain('Humble')
expect(callUrl).not.toContain('Humble')
})

it('should include deprecated protocols by default when _allowNonComposableSwaps is false', async () => {
Expand All @@ -566,7 +563,7 @@ describe('RouterClient', () => {
const callUrl = mockRequest.mock.calls?.[0]?.[0] as string
// Should include deprecated protocols
expect(callUrl).toContain('Tinyman')
expect(callUrl).toContain('Humble')
expect(callUrl).not.toContain('Humble')
})

it('should throw error when _allowNonComposableSwaps is used with optIn: true', async () => {
Expand Down
13 changes: 7 additions & 6 deletions packages/haystack/tests/constants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,28 @@ describe('constants', () => {
describe('Protocol enum', () => {
it('should have expected protocol values', () => {
expect(Protocol.TinymanV2).toBe('TinymanV2')
expect(Protocol.Humble).toBe('Humble')
expect(Protocol.Algofi).toBe('Algofi')
expect(Protocol.Algomint).toBe('Algomint')
expect(Protocol.Pact).toBe('Pact')
expect(Protocol.Folks).toBe('Folks')
expect(Protocol.TAlgo).toBe('TAlgo')
})

it('should have exactly 6 protocols', () => {
it('should have exactly 7 protocols', () => {
const protocols = Object.values(Protocol)
expect(protocols).toHaveLength(6)
expect(protocols).toHaveLength(7)
})
})

describe('DEPRECATED_PROTOCOLS', () => {
it('should include Humble and Tinyman', () => {
expect(DEPRECATED_PROTOCOLS).toContain('Humble')
it('should include Tinyman but not Humble', () => {
expect(DEPRECATED_PROTOCOLS).toContain('Tinyman')
expect(DEPRECATED_PROTOCOLS).not.toContain('Humble')
})

it('should have exactly 2 deprecated protocols', () => {
expect(DEPRECATED_PROTOCOLS).toHaveLength(2)
it('should have exactly 1 deprecated protocol', () => {
expect(DEPRECATED_PROTOCOLS).toHaveLength(1)
})

it('should be a readonly array', () => {
Expand Down
Loading