Skip to content

Commit 4d3998c

Browse files
committed
refactor: clarify api key auth naming
1 parent 025576f commit 4d3998c

3 files changed

Lines changed: 10 additions & 15 deletions

File tree

packages/client/src/actions/auth.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ import {
1616
} from '../errors';
1717
import { validateWith } from '../response';
1818

19-
export type CreateL2AuthRequest = {
20-
chainId: number;
21-
nonce?: number;
22-
};
23-
24-
export type L2AuthRequest = {
19+
export type ApiKeyAuthRequest = {
2520
address: EvmAddress;
2621
nonce: number;
2722
signature: Signature;
@@ -50,7 +45,7 @@ export type CreateApiKeyError =
5045
*/
5146
export async function createApiKey(
5247
client: Client,
53-
request: L2AuthRequest,
48+
request: ApiKeyAuthRequest,
5449
): Promise<ApiKeyCreds> {
5550
return unwrap(
5651
client.clob
@@ -83,7 +78,7 @@ export type DeriveApiKeyError =
8378
*/
8479
export async function deriveApiKey(
8580
client: Client,
86-
request: L2AuthRequest,
81+
request: ApiKeyAuthRequest,
8782
): Promise<ApiKeyCreds> {
8883
return unwrap(
8984
client.clob
@@ -116,7 +111,7 @@ export type CreateOrDeriveApiKeyError =
116111
*/
117112
export async function createOrDeriveApiKey(
118113
client: Client,
119-
request: L2AuthRequest,
114+
request: ApiKeyAuthRequest,
120115
): Promise<ApiKeyCreds> {
121116
try {
122117
return await createApiKey(client, request);
@@ -169,7 +164,7 @@ export async function fetchApiKeys(
169164
return response.apiKeys;
170165
}
171166

172-
function toL1Headers(auth: L2AuthRequest): HeadersInit {
167+
function toL1Headers(auth: ApiKeyAuthRequest): HeadersInit {
173168
return {
174169
POLY_ADDRESS: auth.address,
175170
POLY_NONCE: `${auth.nonce}`,

packages/client/src/authentication.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ export type AuthenticationWorkflow = AsyncGenerator<
1515
EvmAddress | Signature
1616
>;
1717

18-
export type CreateL2AuthTypedDataPayloadRequest = {
18+
export type CreateApiKeyAuthTypedDataPayloadRequest = {
1919
address: EvmAddress;
2020
chainId: number;
2121
nonce?: number;
2222
timestamp: number;
2323
};
2424

2525
/** @internal */
26-
export function createL2AuthTypedDataPayload(
27-
request: CreateL2AuthTypedDataPayloadRequest,
26+
export function createApiKeyAuthTypedDataPayload(
27+
request: CreateApiKeyAuthTypedDataPayloadRequest,
2828
): TypedDataPayload {
2929
return {
3030
domain: {

packages/client/src/clients.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { fetchPublicProfile } from './actions/profiles';
88
import { fetchWalletType } from './actions/wallets';
99
import {
1010
type AuthenticationWorkflow,
11-
createL2AuthTypedDataPayload,
11+
createApiKeyAuthTypedDataPayload,
1212
} from './authentication';
1313
import { type EnvironmentConfig, production } from './environments';
1414
import { RequestRejectedError } from './errors';
@@ -117,7 +117,7 @@ class PublicClient extends AbstractClient<Context> {
117117

118118
const signature = yield {
119119
kind: 'signAuthMessage',
120-
payload: createL2AuthTypedDataPayload({
120+
payload: createApiKeyAuthTypedDataPayload({
121121
address,
122122
chainId: this.environment.chainId,
123123
nonce,

0 commit comments

Comments
 (0)