Skip to content

Commit 96c57ef

Browse files
committed
chore: 🤖 Multiple linter fixes
1 parent 823156e commit 96c57ef

36 files changed

+503
-315
lines changed

‎docs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "WindingTree market protocol docs",
55
"scripts": {
66
"lint:local": "npx markdownlint src/**/*.md",
7-
"build": "./scripts/build.sh",
87
"serve": "npx docsify serve ./"
98
},
109
"repository": "git@github.com:kostysh/wtmp-sdk.git",

‎examples/client/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

‎examples/client/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@windingtree/client-example",
2+
"name": "wtmp-client-example",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
@@ -14,7 +14,7 @@
1414
"@windingtree/sdk-storage": "workspace:*",
1515
"@windingtree/sdk-messages": "workspace:*",
1616
"@windingtree/sdk-utils": "workspace:*",
17-
"wtmp-protocol-examples-shared-files": "workspace:*",
17+
"wtmp-examples-shared-files": "workspace:*",
1818
"eslint": "^8.45.0",
1919
"eslint-config-react-app": "^7.0.1",
2020
"eslint-plugin-react-refresh": "^0.4.3",
@@ -54,6 +54,7 @@
5454
"scripts": {
5555
"start": "vite --force --port 5173",
5656
"build": "tsc && vite build",
57-
"lint": "eslint . --ext .ts"
57+
"lint": "eslint . --ext .ts --ignore-path ../../.lintignore",
58+
"lint:fix": "eslint . --ext .ts --ignore-path ../../.lintignore --fix && prettier --ignore-path ../../.lintignore --write ."
5859
}
5960
}

‎examples/client/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
OfferOptions,
1616
contractsConfig,
1717
serverAddress,
18-
} from 'wtmp-protocol-examples-shared-files';
18+
} from 'wtmp-examples-shared-files';
1919
import { OfferData, RequestData } from '@windingtree/sdk-types';
2020
import { useWallet, AccountWidget } from '@windingtree/sdk-react/providers';
2121
import { FormValues, RequestForm } from './components/RequestForm.js';

‎examples/client/src/components/Deals.tsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DateTime } from 'luxon';
33
import { Address, Hash } from 'viem';
44
import { DealRecord, DealStatus } from '@windingtree/sdk-types';
55
import { ClientDealsManager } from '@windingtree/sdk-client';
6-
import { RequestQuery, OfferOptions } from 'wtmp-protocol-examples-shared-files';
6+
import { RequestQuery, OfferOptions } from 'wtmp-examples-shared-files';
77
import {
88
centerEllipsis,
99
formatBalance,
@@ -231,20 +231,24 @@ export const Deals = ({ deals, manager }: DealsProps) => {
231231
const [userSign, setUserSign] = useState<Hash | undefined>();
232232
const [error, setError] = useState<string | undefined>();
233233

234-
const handleCheckInOut = useCallback(async (deal: DealsRegistryRecord) => {
235-
try {
236-
if (!manager || !walletClient) {
237-
throw new Error('Wallet not connected yet');
234+
const handleCheckInOut = useCallback(
235+
async (deal: DealsRegistryRecord) => {
236+
try {
237+
if (!manager || !walletClient) {
238+
throw new Error('Wallet not connected yet');
239+
}
240+
setUserSign(
241+
await manager.checkInOutSignature(deal.offer.id, walletClient),
242+
);
243+
} catch (error) {
244+
console.log(error);
245+
setError(
246+
(error as Error).message || 'Unknown check in signature error',
247+
);
238248
}
239-
setUserSign(await manager.checkInOutSignature(
240-
deal.offer.id,
241-
walletClient,
242-
));
243-
} catch (error) {
244-
console.log(error);
245-
setError((error as Error).message || 'Unknown check in signature error');
246-
}
247-
}, [manager, walletClient]);
249+
},
250+
[manager, walletClient],
251+
);
248252

249253
useEffect(() => {
250254
if (deals && deals.length > 0) {
@@ -290,7 +294,9 @@ export const Deals = ({ deals, manager }: DealsProps) => {
290294
{DealStatus[dealStates[d.offer.id]]}
291295
</td>
292296
<td>
293-
<div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
297+
<div
298+
style={{ display: 'flex', flexDirection: 'column', gap: 5 }}
299+
>
294300
<div>
295301
<button
296302
onClick={() => setCancelDeal(d)}
@@ -321,15 +327,13 @@ export const Deals = ({ deals, manager }: DealsProps) => {
321327
Transfer
322328
</button>
323329
</div>
324-
{d.status === DealStatus.Claimed &&
330+
{d.status === DealStatus.Claimed && (
325331
<div>
326-
<button
327-
onClick={() => handleCheckInOut(d)}
328-
>
332+
<button onClick={() => handleCheckInOut(d)}>
329333
Check In
330334
</button>
331335
</div>
332-
}
336+
)}
333337
</div>
334338
</td>
335339
</tr>
@@ -347,14 +351,19 @@ export const Deals = ({ deals, manager }: DealsProps) => {
347351
manager={manager}
348352
onClose={() => setCancelDeal(undefined)}
349353
/>
350-
{userSign &&
354+
{userSign && (
351355
<div style={{ marginTop: 20 }}>
352356
<h2>Provide this signature to the reception manager:</h2>
353-
<input style={{ width: '100%' }} onFocus={(event) => {
354-
event.target.select();
355-
}} value={userSign} onChange={() => {}} />
357+
<input
358+
style={{ width: '100%' }}
359+
onFocus={(event) => {
360+
event.target.select();
361+
}}
362+
value={userSign}
363+
onChange={() => {}}
364+
/>
356365
</div>
357-
}
366+
)}
358367
</div>
359368

360369
{error && <div style={{ marginTop: 20 }}>🚨 {error}</div>}

‎examples/client/src/components/MakeDeal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Hash } from 'viem';
33
import { stringify } from 'superjson';
44
import { ClientDealsManager } from '@windingtree/sdk-client';
55
import { OfferData } from '@windingtree/sdk-types';
6-
import { RequestQuery, OfferOptions } from 'wtmp-protocol-examples-shared-files';
6+
import { RequestQuery, OfferOptions } from 'wtmp-examples-shared-files';
77
import {
88
ZeroHash,
99
centerEllipsis,

‎examples/client/src/components/Offers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
22
import { stringify } from 'superjson';
33
import { isExpired } from '@windingtree/sdk-utils';
44
import { OfferData } from '@windingtree/sdk-types';
5-
import { RequestQuery, OfferOptions } from 'wtmp-protocol-examples-shared-files';
5+
import { RequestQuery, OfferOptions } from 'wtmp-examples-shared-files';
66
import { centerEllipsis } from '@windingtree/sdk-react/utils';
77

88
interface OffersProps {

‎examples/client/src/components/Requests.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { isExpired } from '@windingtree/sdk-utils';
22
import { ClientRequestRecord } from '@windingtree/sdk-client';
33
import { OfferData } from '@windingtree/sdk-types';
4-
import { RequestQuery, OfferOptions } from 'wtmp-protocol-examples-shared-files';
4+
import { RequestQuery, OfferOptions } from 'wtmp-examples-shared-files';
55
import { centerEllipsis } from '@windingtree/sdk-react/utils';
66
import { stringify } from 'superjson';
77

‎examples/client/src/main.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { WalletProvider } from '@windingtree/sdk-react/providers';
33
import { polygonZkEvmTestnet, hardhat } from 'viem/chains';
44
import { App } from './App.js';
55

6-
const targetChain = import.meta.env.VITE_LOCAL_NODE === 'hardhat'
7-
? hardhat
8-
: polygonZkEvmTestnet;
6+
const targetChain =
7+
import.meta.env.VITE_LOCAL_NODE === 'hardhat' ? hardhat : polygonZkEvmTestnet;
98

109
window.addEventListener('unhandledrejection', (event) => {
1110
event.preventDefault();

‎examples/e2e-tests/package.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
2-
"name": "e2e-tests",
2+
"name": "wtmp-e2e-tests",
33
"version": "0.0.0",
44
"description": "The WindingTree market protocol examples end to end tests",
55
"private": true,
66
"type": "module",
7-
"main": "./dist/index.js",
8-
"types": "./dist/index.d.ts",
97
"keywords": [
108
"test"
119
],
@@ -14,17 +12,11 @@
1412
"Kostiantyn Smyrnov <kostysh@gmail.com>"
1513
],
1614
"license": "ISC",
17-
"scripts": {
18-
"build": "tsc -p ./tsconfig.json",
19-
"test": "echo \"Error: no test specified\" && exit 1"
20-
},
21-
"dependencies": {
22-
"viem": "^1.3.0",
23-
"@windingtree/sdk-types": "workspace:*",
24-
"@windingtree/sdk-utils": "workspace:*"
25-
},
2615
"devDependencies": {
16+
"@types/luxon": "3.3.1",
2717
"@windingtree/contracts": "1.0.0-beta.12",
18+
"@windingtree/sdk-types": "workspace:*",
19+
"@windingtree/sdk-utils": "workspace:*",
2820
"@windingtree/sdk-client": "workspace:*",
2921
"@windingtree/sdk-constants": "workspace:*",
3022
"@windingtree/sdk-contracts-manager": "workspace:*",
@@ -35,15 +27,20 @@
3527
"@windingtree/sdk-queue": "workspace:*",
3628
"@windingtree/sdk-server": "workspace:*",
3729
"@windingtree/sdk-storage": "workspace:*",
38-
"vitest": "^0.33.0",
39-
"wtmp-protocol-examples-shared-files": "workspace:*",
30+
"wtmp-examples-shared-files": "workspace:*",
4031
"@libp2p/interface-connection": "^5.1.1",
4132
"@libp2p/interface-peer-id": "^2.0.2",
4233
"@libp2p/interfaces": "^3.3.2",
4334
"@libp2p/peer-id": "^2.0.4",
4435
"@multiformats/multiaddr": "^12.1.3",
4536
"luxon": "^3.3.0",
46-
"ts-luxon": "^4.3.2",
4737
"viem": "^1.3.0"
38+
},
39+
"scripts": {
40+
"build": "echo \"no build specified\" && exit 0",
41+
"test": "vitest --run",
42+
"test:rel": "vitest related --run",
43+
"lint": "eslint . --ext .ts --ignore-path ../../.lintignore",
44+
"lint:fix": "eslint . --ext .ts --ignore-path ../../.lintignore --fix && prettier --ignore-path ../../.lintignore --write ."
4845
}
4946
}

‎examples/e2e-tests/test/examples/client.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ import {
22
OfferOptions,
33
RequestQuery,
44
serverAddress,
5-
} from 'wtmp-protocol-examples-shared-files';
5+
} from 'wtmp-examples-shared-files';
66
import { EventHandler } from '@libp2p/interfaces/events';
77
import { buildRequest } from '@windingtree/sdk-messages';
88
import { memoryStorage } from '@windingtree/sdk-storage';
9-
import { GenericOfferOptions, GenericQuery, OfferData, RequestData } from '@windingtree/sdk-types';
10-
import { ClientRequestsManager, Client, createClient, ClientRequestRecord } from '@windingtree/sdk-client';
9+
import {
10+
GenericOfferOptions,
11+
GenericQuery,
12+
OfferData,
13+
RequestData,
14+
} from '@windingtree/sdk-types';
15+
import {
16+
ClientRequestsManager,
17+
Client,
18+
createClient,
19+
ClientRequestRecord,
20+
} from '@windingtree/sdk-client';
1121

1222
const defaultExpire = '30s';
1323

‎examples/e2e-tests/test/examples/node.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,32 @@ import {
88
RequestQuery,
99
serverAddress,
1010
stableCoins,
11-
} from 'wtmp-protocol-examples-shared-files';
11+
} from 'wtmp-examples-shared-files';
1212
import { OPEN } from '@libp2p/interface-connection/status';
1313
import { multiaddr } from '@multiformats/multiaddr';
1414
import { peerIdFromString } from '@libp2p/peer-id';
1515
import { PeerId } from '@libp2p/interface-peer-id';
1616
import { mnemonicToAccount } from 'viem/accounts';
1717
import { ProtocolContracts } from '@windingtree/sdk-contracts-manager';
1818
import { createLogger } from '@windingtree/sdk-logger';
19-
import { generateMnemonic, nowSec, parseSeconds, supplierId as spId } from '@windingtree/sdk-utils';
20-
import { NodeOptions, Node, createNode, RequestEvent, NodeRequestManager } from '@windingtree/sdk-node';
19+
import {
20+
generateMnemonic,
21+
nowSec,
22+
parseSeconds,
23+
supplierId as spId,
24+
} from '@windingtree/sdk-utils';
25+
import {
26+
NodeOptions,
27+
Node,
28+
createNode,
29+
RequestEvent,
30+
NodeRequestManager,
31+
} from '@windingtree/sdk-node';
2132
import { JobHandler } from '@windingtree/sdk-queue';
2233
import { DealStatus, OfferData } from '@windingtree/sdk-types';
2334
import { noncePeriod } from '@windingtree/sdk-constants';
2435
import { CenterSub } from '@windingtree/sdk-pubsub';
25-
import { DateTime } from 'ts-luxon';
36+
import { DateTime } from 'luxon';
2637

2738
const logger = createLogger('NodeMain');
2839

@@ -116,7 +127,7 @@ export class NodeExample {
116127
const [, , , buyer, , , status] = await contracts.getDeal(offer);
117128

118129
// Deal must be exists and not cancelled
119-
if (buyer !== zeroAddress && status === DealStatus.Created) {
130+
if (buyer !== zeroAddress && status === Number(DealStatus.Created)) {
120131
// check for double booking in the availability system
121132
// If double booking detected - rejects (and refunds) the deal
122133

‎examples/e2e-tests/test/examples/server.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import peerKey from './peerKey.json';
22
import { createLogger } from '@windingtree/sdk-logger';
33
import { memoryStorage } from '@windingtree/sdk-storage';
4-
import { CoordinationServer, createServer, ServerOptions } from '@windingtree/sdk-server';
5-
4+
import {
5+
CoordinationServer,
6+
createServer,
7+
ServerOptions,
8+
} from '@windingtree/sdk-server';
69

710
const logger = createLogger('ServerExample');
811

‎examples/e2e-tests/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"compilerOptions": {
4-
"outDir": "./dist"
5-
}
3+
"include": ["./test"]
64
}

‎examples/manager/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

‎examples/manager/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@windingtree/manager-example",
2+
"name": "wtmp-manager-example",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",
@@ -13,7 +13,7 @@
1313
"@windingtree/sdk-storage": "workspace:*",
1414
"@windingtree/sdk-messages": "workspace:*",
1515
"@windingtree/sdk-node-api": "workspace:*",
16-
"wtmp-protocol-examples-shared-files": "workspace:*",
16+
"wtmp-examples-shared-files": "workspace:*",
1717
"eslint": "^8.45.0",
1818
"eslint-config-react-app": "^7.0.1",
1919
"eslint-plugin-react-refresh": "^0.4.3",
@@ -56,6 +56,7 @@
5656
"scripts": {
5757
"start": "vite --force --port 5173",
5858
"build": "tsc && vite build",
59-
"lint": "eslint . --ext .ts"
59+
"lint": "eslint . --ext .ts --ignore-path ../../.lintignore",
60+
"lint:fix": "eslint . --ext .ts --ignore-path ../../.lintignore --fix && prettier --ignore-path ../../.lintignore --write ."
6061
}
6162
}

‎examples/manager/src/components/ConfigForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const ConfigForm = () => {
2121
type: ConfigActions.SET_CONFIG,
2222
payload: {
2323
nodeHost: e.target.value,
24-
}
24+
},
2525
})
2626
}
2727
/>

0 commit comments

Comments
 (0)