Skip to content

Commit 228e120

Browse files
committed
Fix linting
1 parent d2b2575 commit 228e120

8 files changed

Lines changed: 86 additions & 16 deletions

File tree

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
11
// eslint-disable-next-line
2-
export { default } from '../../shared/config/base.eslint.mjs';
2+
import baseConfig from '../../shared/config/base.eslint.mjs';
3+
4+
const withX402NamingExceptions = baseConfig.map((entry) => {
5+
const namingConventionRule =
6+
entry.rules?.['@typescript-eslint/naming-convention'];
7+
8+
if (!Array.isArray(namingConventionRule)) {
9+
return entry;
10+
}
11+
12+
const [level, ...conventions] = namingConventionRule;
13+
14+
return {
15+
...entry,
16+
rules: {
17+
...entry.rules,
18+
'@typescript-eslint/naming-convention': [
19+
level,
20+
{
21+
selector: ['class', 'typeAlias'],
22+
filter: {
23+
regex: '^x402[A-Z].*$',
24+
match: true,
25+
},
26+
format: null,
27+
},
28+
...conventions,
29+
],
30+
},
31+
};
32+
});
33+
34+
const config = [
35+
...withX402NamingExceptions,
36+
{
37+
files: ['**/*.ts', '**/*.tsx'],
38+
rules: {
39+
'new-cap': [
40+
'error',
41+
{
42+
newIsCap: true,
43+
newIsCapExceptionPattern: '^x402[A-Z]',
44+
capIsNew: true,
45+
properties: true,
46+
},
47+
],
48+
},
49+
},
50+
];
51+
52+
export default config;

packages/smart-accounts-kit-x402/src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ export {
77
type x402SchemeNetworkClientLike,
88
type x402Erc7710ClientConfig,
99
} from './x402Client';
10-
export {
11-
x402Erc7710Server,
12-
type x402Erc7710ServerConfig,
13-
} from './x402Server';
10+
export { x402Erc7710Server, type x402Erc7710ServerConfig } from './x402Server';
1411
export { x402ExactEvmErc7710ServerScheme } from './x402ExactEvmErc7710ServerScheme';

packages/smart-accounts-kit-x402/src/x402Client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ export type x402Erc7710ClientConfig = {
4040
fallbackClient?: x402SchemeNetworkClientLike;
4141
};
4242

43+
/**
44+
* Normalize and validate a delegation payload before publishing it.
45+
*
46+
* @param payload - Delegation payload returned by the configured provider.
47+
* @returns The normalized payload with checksum addresses.
48+
*/
4349
function normalizeDelegationPayload(
4450
payload: x402DelegationPaymentPayload,
4551
): x402DelegationPaymentPayload {

packages/smart-accounts-kit-x402/src/x402ExactEvmErc7710ServerScheme.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export class x402ExactEvmErc7710ServerScheme extends ExactEvmScheme {
2929
return baseRequirements;
3030
}
3131

32-
const enhancedRequirements = await this.#erc7710Server.enhancePaymentRequirements(
33-
baseRequirements,
34-
supportedKind,
35-
);
32+
const enhancedRequirements =
33+
await this.#erc7710Server.enhancePaymentRequirements(
34+
baseRequirements,
35+
supportedKind,
36+
);
3637

3738
return enhancedRequirements as PaymentRequirements;
3839
}

packages/smart-accounts-kit-x402/src/x402Server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ export type x402Erc7710ServerConfig = {
66
allowAssetTransferMethodOverride?: boolean;
77
};
88

9+
/**
10+
* Validate and normalize optional facilitator address metadata.
11+
*
12+
* @param publishedAddresses - Optional facilitator address list from `supportedKind.extra`.
13+
* @returns A normalized checksum address list, or `undefined` when no list is provided.
14+
*/
915
function validateFacilitatorAddresses(
1016
publishedAddresses: unknown,
1117
): string[] | undefined {

packages/smart-accounts-kit-x402/test/x402Client.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ describe('x402Erc7710Client', () => {
5454
}),
5555
});
5656

57-
await expect(client.createPaymentPayload(2, baseRequirements)).rejects.toThrow(
57+
await expect(
58+
client.createPaymentPayload(2, baseRequirements),
59+
).rejects.toThrow(
5860
'Invalid delegation payload: permissionContext must be non-empty hex data',
5961
);
6062
});
@@ -68,7 +70,9 @@ describe('x402Erc7710Client', () => {
6870
}),
6971
});
7072

71-
await expect(client.createPaymentPayload(2, baseRequirements)).rejects.toThrow(
73+
await expect(
74+
client.createPaymentPayload(2, baseRequirements),
75+
).rejects.toThrow(
7276
'Invalid delegation payload: permissionContext must be non-empty hex data',
7377
);
7478
});

packages/smart-accounts-kit-x402/test/x402ExactEvmErc7710ServerScheme.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ describe('x402ExactEvmErc7710ServerScheme', () => {
6767
facilitatorAddresses: ['0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa'],
6868
},
6969
} as unknown as PaymentRequirements;
70-
vi.spyOn(ExactEvmScheme.prototype, 'enhancePaymentRequirements').mockResolvedValue(
71-
baseRequirements,
72-
);
70+
vi.spyOn(
71+
ExactEvmScheme.prototype,
72+
'enhancePaymentRequirements',
73+
).mockResolvedValue(baseRequirements);
7374
const erc7710Spy = vi
7475
.spyOn(x402Erc7710Server.prototype, 'enhancePaymentRequirements')
7576
.mockResolvedValue(enhancedRequirements);

packages/smart-accounts-kit-x402/test/x402Server.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ describe('x402Erc7710Server', () => {
2323
it('sets assetTransferMethod to erc7710', async () => {
2424
const server = new x402Erc7710Server();
2525

26-
const result = await server.enhancePaymentRequirements(baseRequirements, {});
26+
const result = await server.enhancePaymentRequirements(
27+
baseRequirements,
28+
{},
29+
);
2730

2831
expect(result.extra?.assetTransferMethod).toBe('erc7710');
2932
});
@@ -67,7 +70,9 @@ describe('x402Erc7710Server', () => {
6770
extra: { assetTransferMethod: 'eip3009' },
6871
};
6972

70-
await expect(server.enhancePaymentRequirements(requirements, {})).rejects.toThrow(
73+
await expect(
74+
server.enhancePaymentRequirements(requirements, {}),
75+
).rejects.toThrow(
7176
'Cannot overwrite existing assetTransferMethod "eip3009" with "erc7710"',
7277
);
7378
});

0 commit comments

Comments
 (0)