Skip to content

Commit 22fe51b

Browse files
authored
Upgrade to quote V2 (#888)
* Upgrade to quote v2 api * Upgrade to quote v2 api for token widget renderer * Upgrade hook to use quote/v2 * Sync api types * Fix explicit deposit not being sent
1 parent 3d22972 commit 22fe51b

File tree

14 files changed

+1139
-297
lines changed

14 files changed

+1139
-297
lines changed

demo/pages/api/secure/[...path].ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { paths } from '@relayprotocol/relay-sdk'
22
import type { NextApiRequest, NextApiResponse } from 'next'
33

44
type QuoteResponse =
5-
paths['/quote']['post']['responses']['200']['content']['application/json']
5+
paths['/quote/v2']['post']['responses']['200']['content']['application/json']
66

77
const sponsoredTokens = [
88
'792703809:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
@@ -21,7 +21,7 @@ export default async function handler(
2121
) {
2222
const { query } = req
2323

24-
const url = new URL('https://api.relay.link/quote')
24+
const url = new URL('https://api.relay.link/quote/v2')
2525

2626
for (const [key, value] of Object.entries(query)) {
2727
url.searchParams.set(key, value as string)

packages/hooks/src/hooks/useQuote.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import type { WalletClient } from 'viem'
1717
import type { AxiosRequestConfig } from 'axios'
1818

1919
type QuoteBody =
20-
paths['/quote']['post']['requestBody']['content']['application/json']
20+
paths['/quote/v2']['post']['requestBody']['content']['application/json']
2121

2222
export type QuoteResponse =
23-
paths['/quote']['post']['responses']['200']['content']['application/json']
23+
paths['/quote/v2']['post']['responses']['200']['content']['application/json']
2424

2525
type QueryType = typeof useQuery<
2626
QuoteResponse,
@@ -36,7 +36,7 @@ export const queryQuote = function (
3636
config?: AxiosRequestConfig
3737
): Promise<QuoteResponse> {
3838
return new Promise((resolve, reject) => {
39-
const href = `${baseApiUrl}/quote`
39+
const href = `${baseApiUrl}/quote/v2`
4040
axiosPostFetcher(href, options, config)
4141
.then((response) => {
4242
const request: AxiosRequestConfig = {

packages/sdk/src/actions/apiKey.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('API Key Header Tests', () => {
5959

6060
expect(axiosRequestSpy).toHaveBeenCalledWith(
6161
expect.objectContaining({
62-
url: expect.stringContaining('/quote'),
62+
url: expect.stringContaining('/quote/v2'),
6363
headers: expect.objectContaining({
6464
'x-api-key': 'test-api-key'
6565
})

packages/sdk/src/actions/getQuote.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { AdaptedWallet, Execute, paths } from '../types/index.js'
1515
import { getDeadAddress } from '../constants/address.js'
1616

1717
export type QuoteBody = NonNullable<
18-
paths['/quote']['post']['requestBody']['content']['application/json']
18+
paths['/quote/v2']['post']['requestBody']['content']['application/json']
1919
>
2020
export type QuoteBodyOptions = Omit<
2121
QuoteBody,
@@ -158,7 +158,7 @@ export async function getQuote(
158158
}
159159

160160
const request: AxiosRequestConfig = {
161-
url: `${client.baseApiUrl}/quote`,
161+
url: `${client.baseApiUrl}/quote/v2`,
162162
method: 'post',
163163
data: query,
164164
headers: {

packages/sdk/src/routes/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@ export const routes = [
1313
"/execute/swap/multi-input",
1414
"/execute/permits",
1515
"/quote",
16+
"/quote/v2",
1617
"/price",
1718
"/execute",
1819
"/fast-fill",
1920
"/lives",
2021
"/intents/status",
2122
"/intents/status/v2",
2223
"/intents/status/v3",
23-
"/intents/quote",
24-
"/intents/quote/v2",
2524
"/requests/{requestId}/signature",
2625
"/requests/{requestId}/signature/v2",
2726
"/requests",
2827
"/requests/v2",
2928
"/requests/metadata",
3029
"/transactions/index",
3130
"/transactions/single",
32-
"/transactions/status",
31+
"/swap-sources",
3332
"/loadforge.txt",
3433
"/conduit/install",
3534
"/prices/rates",
@@ -40,5 +39,6 @@ export const routes = [
4039
"/chains/{chainId}/currencies/{address}",
4140
"/chains/{chainId}/currencies/{address}/chart",
4241
"/provision/chain",
43-
"/sanctioned/{address}"
42+
"/sanctioned/{address}",
43+
"/wallets/screen"
4444
];

packages/sdk/src/types/Execute.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ export type CallBreakdown =
99
paths['/execute/call/v2']['post']['responses']['200']['content']['application/json']['breakdown']
1010
export type CheckApi = NonNullable<
1111
NonNullable<
12-
paths['/execute/call/v2']['post']['responses']['200']['content']['application/json']['steps']
12+
paths['/quote/v2']['post']['responses']['200']['content']['application/json']['steps']
1313
>['0']['items']
1414
>[0]['check']
1515
export type QuoteDetails = NonNullable<
16-
paths['/quote']['post']['responses']['200']['content']['application/json']['details']
16+
paths['/quote/v2']['post']['responses']['200']['content']['application/json']['details']
1717
>
1818
export type QuoteStepId = NonNullable<
19-
paths['/quote']['post']['responses']['200']['content']['application/json']['steps']
19+
paths['/quote/v2']['post']['responses']['200']['content']['application/json']['steps']
2020
>['0']['id']
2121

2222
export type TransactionStepState = 'confirming' | 'validating' | 'complete'

packages/sdk/src/types/RelayChain.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ type RelayAPIChain = NonNullable<
55
paths['/chains']['get']['responses']['200']['content']['application/json']['chains']
66
>['0']
77

8-
export type ChainVM = 'evm' | 'svm' | 'bvm' | 'tvm' | 'suivm' | 'hypevm' | 'lvm'
8+
export type ChainVM =
9+
| 'evm'
10+
| 'svm'
11+
| 'bvm'
12+
| 'tvm'
13+
| 'suivm'
14+
| 'hypevm'
15+
| 'lvm'
16+
| 'tonvm'
917

1018
export type RelayChain = {
1119
id: number

0 commit comments

Comments
 (0)