Skip to content

Commit

Permalink
:sparkless: Adding api key in GaslessOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-bellotti committed Jul 15, 2024
1 parent f2ebb85 commit 1172263
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ import {
const baseUrl = (options?: GaslessOptions): string => options?.baseUrl ?? BASE_URL;
const getRequest = (options?: GaslessOptions): RequestInit => ({
signal: options?.abortSignal,
headers: { ...(options?.apiPublicKey !== undefined && { 'ask-signature': 'true' }) },
headers: {
...(options?.apiPublicKey !== undefined && { 'ask-signature': 'true' }),
...(options?.apiKey && { 'api-key': options.apiKey }),
},
});
const postRequest = (body: unknown, options?: GaslessOptions): RequestInit => ({
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
...(options?.apiKey && { 'api-key': options.apiKey }),
...(options?.apiPublicKey && { 'ask-signature': 'true' }),
},
body: JSON.stringify(body),
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export interface ExecuteCallsOptions {

export interface GaslessOptions {
baseUrl?: string;
// The api key allows you to sponsor the gas fees for your users
apiKey?: string;
abortSignal?: AbortSignal;
apiPublicKey?: string;
}
Expand Down

0 comments on commit 1172263

Please sign in to comment.