Skip to content

Commit

Permalink
feat(fiatExchanges): support url params on external quotes (#6195)
Browse files Browse the repository at this point in the history
### Description

Relates to this change
valora-inc/cloud-functions@fa45ba6

### Test plan

unit tests updated
  • Loading branch information
jh2oman authored Oct 28, 2024
1 parent 1dcd25f commit 811e881
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/fiatExchanges/quotes/ExternalQuote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,20 @@ describe('ExternalQuote', () => {
tokenId: mockCusdTokenId,
})
quote.navigate()
expect(navigateToURI).toHaveBeenCalled()
expect(navigateToURI).toHaveBeenCalledWith('https://www.moonpay.com/')
})
it('calls navigateToURI with quote specific url', () => {
const quote = new ExternalQuote({
quote: {
...(mockProviders[1].quote as RawProviderQuote[])[0],
url: 'https://example.com',
},
provider: mockProviders[1],
flow: CICOFlow.CashIn,
tokenId: mockCusdTokenId,
})
quote.navigate()
expect(navigateToURI).toHaveBeenCalledWith('https://example.com')
})
})

Expand Down
3 changes: 2 additions & 1 deletion src/fiatExchanges/quotes/ExternalQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export default class ExternalQuote extends NormalizedQuote {
tokenId: this.tokenId,
})
} else {
navigateToURI(this.provider.url!)
const url = this.quote.url ?? this.provider.url
navigateToURI(url!)
}
}

Expand Down
1 change: 1 addition & 0 deletions src/fiatExchanges/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export interface RawProviderQuote {
returnedAmount?: number
fiatFee?: number
extraReqs?: { mobileCarrier: 'Safaricom' | 'MTN' }
url?: string
}

export interface LegacyMobileMoneyProvider {
Expand Down

0 comments on commit 811e881

Please sign in to comment.