Skip to content

Commit 2f80cea

Browse files
committed
refactor: rename EVM signatures to disambiguate auth
1 parent c72b903 commit 2f80cea

8 files changed

Lines changed: 23 additions & 23 deletions

File tree

packages/client/src/actions/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
BuilderApiKeyCredsSchema,
99
BuilderApiKeysResponseSchema,
1010
} from '@polymarket/bindings/clob';
11-
import { type EvmAddress, type Signature, unwrap } from '@polymarket/types';
11+
import { type EvmAddress, type EvmSignature, unwrap } from '@polymarket/types';
1212
import { z } from 'zod';
1313
import type { Client, SecureClient } from '../clients';
1414
import {
@@ -23,7 +23,7 @@ import { validateWith } from '../response';
2323
export type ApiKeyAuthRequest = {
2424
address: EvmAddress;
2525
nonce: number;
26-
signature: Signature;
26+
signature: EvmSignature;
2727
timestamp: number;
2828
};
2929

packages/client/src/actions/orders/prepare.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectSignature, never } from '@polymarket/types';
1+
import { expectEvmSignature, never } from '@polymarket/types';
22
import type { SecureClient } from '../../clients';
33
import type {
44
InsufficientLiquidityError,
@@ -61,7 +61,7 @@ export async function prepareMarketOrder(
6161

6262
const unsignedOrder = createUnsignedOrder(draft, client.account);
6363

64-
const signature = expectSignature(
64+
const signature = expectEvmSignature(
6565
yield {
6666
kind: 'signOrder',
6767
payload: createOrderTypedDataPayload(unsignedOrder),
@@ -108,7 +108,7 @@ export async function prepareLimitOrder(
108108

109109
const unsignedOrder = createUnsignedOrder(draft, client.account);
110110

111-
const signature = expectSignature(
111+
const signature = expectEvmSignature(
112112
yield {
113113
kind: 'signOrder',
114114
payload: createOrderTypedDataPayload(unsignedOrder),

packages/client/src/actions/orders/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type {
55
} from '@polymarket/bindings/clob';
66
import type {
77
EvmAddress,
8+
EvmSignature,
89
HexString,
9-
Signature,
1010
TxHash,
1111
} from '@polymarket/types';
1212
import type { TypedDataPayload } from '../../types';
@@ -116,7 +116,7 @@ export type SignedOrder = {
116116
taker: EvmAddress;
117117
takerAmount: string;
118118
tokenId: string;
119-
signature: Signature;
119+
signature: EvmSignature;
120120
};
121121

122122
export type OrderWorkflowRequest =
@@ -136,5 +136,5 @@ export type OrderWorkflowRequest =
136136
export type OrderWorkflow = AsyncGenerator<
137137
OrderWorkflowRequest,
138138
SignedOrder,
139-
Signature | TxHash
139+
EvmSignature | TxHash
140140
>;

packages/client/src/authentication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EvmAddress, Signature } from '@polymarket/types';
1+
import type { EvmAddress, EvmSignature } from '@polymarket/types';
22
import type { SecureClient } from './clients';
33
import type { TypedDataPayload } from './types';
44

@@ -12,7 +12,7 @@ export type AuthenticationWorkflowRequest =
1212
export type AuthenticationWorkflow = AsyncGenerator<
1313
AuthenticationWorkflowRequest,
1414
SecureClient,
15-
EvmAddress | Signature
15+
EvmAddress | EvmSignature
1616
>;
1717

1818
export type CreateApiKeyAuthTypedDataPayloadRequest = {

packages/client/src/clients.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { ApiKeyCreds } from '@polymarket/bindings/clob';
22
import type { EvmAddress } from '@polymarket/types';
33
import {
44
expectEvmAddress,
5-
expectSignature,
5+
expectEvmSignature,
66
invariant,
77
} from '@polymarket/types';
88
import type { AccountIdentity } from './account';
@@ -147,7 +147,7 @@ export class PublicClient extends AbstractClient<PublicContext> {
147147
const credentials = await createOrDeriveApiKey(this, {
148148
address: signer,
149149
nonce,
150-
signature: expectSignature(signature),
150+
signature: expectEvmSignature(signature),
151151
timestamp,
152152
});
153153

packages/client/src/viem/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
22
expectEvmAddress,
3-
expectSignature,
3+
expectEvmSignature,
44
invariant,
55
type TxHash,
66
} from '@polymarket/types';
@@ -41,7 +41,7 @@ export function authenticateWith(walletClient: WalletClient) {
4141
break;
4242
case 'signAuthMessage':
4343
result = await workflow.next(
44-
expectSignature(
44+
expectEvmSignature(
4545
await walletClient.signTypedData({
4646
account,
4747
...result.value.payload,
@@ -75,7 +75,7 @@ export function executeWith(walletClient: WalletClient) {
7575
switch (result.value.kind) {
7676
case 'signOrder':
7777
result = await workflow.next(
78-
expectSignature(
78+
expectEvmSignature(
7979
await walletClient.signTypedData({
8080
account,
8181
...result.value.payload,

packages/types/src/hex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export type PrivateKey = Tagged<HexString, 'PrivateKey'>;
1616
export type EvmAddress = Tagged<HexString, 'EvmAddress'>;
1717

1818
/**
19-
* A hex-encoded cryptographic signature.
19+
* A hex-encoded EVM signature.
2020
*/
21-
export type Signature = Tagged<HexString, 'Signature'>;
21+
export type EvmSignature = Tagged<HexString, 'EvmSignature'>;
2222

2323
/**
2424
* A transaction hash returned by an EVM-compatible network.

packages/types/src/refinements.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { InvariantError } from './errors';
22
import {
33
type EvmAddress,
4+
type EvmSignature,
45
isHexString,
5-
type Signature,
66
type TxHash,
77
} from './hex';
88

@@ -51,17 +51,17 @@ export function expectEvmAddress(
5151
}
5252

5353
/**
54-
* Refines a string to a signature or throws when the value is invalid.
54+
* Refines a string to an EVM signature or throws when the value is invalid.
5555
*/
56-
export function expectSignature(
56+
export function expectEvmSignature(
5757
value: string,
58-
message = 'Expected a signature',
59-
): Signature {
58+
message = 'Expected an EVM signature',
59+
): EvmSignature {
6060
if (!isHexString(value) || value.length !== 132) {
6161
throw new InvariantError(message);
6262
}
6363

64-
return value as Signature;
64+
return value as EvmSignature;
6565
}
6666

6767
/**

0 commit comments

Comments
 (0)