Skip to content

Commit a7b9f07

Browse files
authored
Merge pull request #839 from relayprotocol/feature/api-key-configuration
Api key configuration
2 parents 18b4e96 + 028701b commit a7b9f07

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

.changeset/eight-laws-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@relayprotocol/relay-sdk': patch
3+
---
4+
5+
Allow getQuote to pass in headers

demo/pages/sdk/actions/swap.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const SwapActionPage: NextPage = () => {
2323

2424
const { primaryWallet: primaryWallet } = useDynamicContext()
2525
const [jsonPayload, setJsonPayload] = useState<any>()
26+
const [headersPayload, setHeadersPayload] = useState<any>()
2627
const [error, setError] = useState<string | undefined>()
2728
const [logs, setLogs] = useState<{ message: string[]; level: LogLevel }[]>([])
2829
const [quote, setQuote] = useState<Execute | undefined>()
@@ -167,6 +168,12 @@ const SwapActionPage: NextPage = () => {
167168
value={jsonPayload}
168169
onChange={(e) => setJsonPayload(e.target.value)}
169170
/>
171+
<div>Paste in headers JSON parameters below (optional):</div>
172+
<textarea
173+
style={{ minHeight: 200, minWidth: 500 }}
174+
value={headersPayload}
175+
onChange={(e) => setHeadersPayload(e.target.value)}
176+
/>
170177
<button
171178
style={{
172179
marginTop: 50,
@@ -300,7 +307,8 @@ const SwapActionPage: NextPage = () => {
300307
tradeType,
301308
options
302309
},
303-
true
310+
true,
311+
headersPayload ? JSON.parse(headersPayload) : undefined
304312
)
305313

306314
setQuote(quote)

packages/sdk/src/actions/getQuote.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ const getDefaultQuoteParameters = async (
7676
*/
7777
export async function getQuote(
7878
parameters: GetQuoteParameters,
79-
includeDefaultParameters?: boolean
79+
includeDefaultParameters?: boolean,
80+
headers?: Record<string, string>
8081
): Promise<Execute> {
8182
const {
8283
toChainId,
@@ -137,7 +138,6 @@ export async function getQuote(
137138
throw new Error('Recipient is required')
138139
}
139140

140-
141141
const query: QuoteBody = {
142142
user: includeDefaultParameters
143143
? (defaultParameters?.user as string)
@@ -159,7 +159,8 @@ export async function getQuote(
159159
const request: AxiosRequestConfig = {
160160
url: `${client.baseApiUrl}/quote`,
161161
method: 'post',
162-
data: query
162+
data: query,
163+
headers
163164
}
164165

165166
const res = await axios.request(request)

0 commit comments

Comments
 (0)