Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
4476d9c
chore: 🤖 move tests from mocha to vitest
Galeaf11 Jun 21, 2023
5705da5
chore: 🤖 move tests from mocha to vitest
Galeaf11 Jun 21, 2023
4e1c1c9
Merge pull request #29 from Galeaf11/chore/vitest_migration
kostysh Jun 22, 2023
519819a
chore: 🤖 tRPC deps are added to package
kostysh Jun 19, 2023
c7a32e1
feat: 🎸 Added users database abstraction
kostysh Jun 19, 2023
2e3914f
feat: 🎸 Added a prtotype of the NodeApiServer class
kostysh Jun 19, 2023
6bf227e
chore: 🤖 Updated dependencies versions
kostysh Jun 22, 2023
86e0552
chore: 🤖 Tests cleanup
kostysh Jun 22, 2023
8eafa93
chore: 🤖 Updated the repository scripts
kostysh Jun 23, 2023
3e4af25
feat: 🎸 Added final UserdDB implementation
kostysh Jun 23, 2023
f6676c0
feat: 🎸 Added NodeAPIServer implementation
kostysh Jun 23, 2023
61ef9ab
test: 💍 Added tests for the UserDB module
kostysh Jun 23, 2023
b33e186
test: 💍 Added tests for the NodeApiServer module
kostysh Jun 23, 2023
6377646
chore: 🤖 Updated viem dependency version
kostysh Jun 26, 2023
4a4e00a
chore: 🤖 Updated yarn.lock
kostysh Jun 26, 2023
6c18948
feat: 🎸 User type of admin added to the UsersDb
kostysh Jun 26, 2023
66bb09a
refactor: 💡 NodeApiServer extracted into separate module
kostysh Jun 26, 2023
1c1223d
refactor: 💡 Users routes are extracted into separate module
kostysh Jun 26, 2023
558b7c4
feat: 🎸 Added admin routes
kostysh Jun 26, 2023
fb12a4e
refactor: 💡 Root NodeApiServer module now re-exports only
kostysh Jun 26, 2023
8f0beca
test: 💍 Added tests for admin API routes
kostysh Jun 26, 2023
ad04611
refactor: 💡 Added passwords hashing using bcrypt
kostysh Jun 29, 2023
e03b19c
fix: 🐛 Fixed api.db.spec test
kostysh Jun 29, 2023
8e6cea9
Merge pull request #30 from windingtree/feat/node-trpc-auth
kostysh Jun 29, 2023
f4a2b0b
refactor: 💡 UsersDb class moved to the ./node/db directory
kostysh Jun 29, 2023
71d531a
chore: 🤖 Old queue removed from sources
kostysh Jun 29, 2023
e8a2af6
chore: 🤖 Updated the repository configuration
kostysh Jun 29, 2023
2a06610
feat: 🎸 Added `scope` to the storage interface
kostysh Jun 29, 2023
f568f73
refactor: 💡 DealsRecord type is moved to the shared types
kostysh Jun 29, 2023
6b6ec20
chore: 🤖 Minor cleanup
kostysh Jun 29, 2023
d22ee74
refactor: 💡 Server API tests minor refactoring
kostysh Jun 29, 2023
7a45a74
feat: 🎸 Added DealsDb class
kostysh Jun 29, 2023
7a739dc
test: 💍 Added tests for DealsDb class
kostysh Jun 29, 2023
9ad483c
Merge pull request #31 from windingtree/feat/deals-db
kostysh Jun 29, 2023
ef383ac
fix: 🐛 Added mised typing to the StorageInitializerFunction
kostysh Jun 30, 2023
67d2633
refactor: 💡 Added typing to the local storage initializer
kostysh Jun 30, 2023
dfacb59
fix: 🐛 Fixed scoped behaviour in the MemoryStorage
kostysh Jun 30, 2023
fcaf781
test: 💍 Added tests for the MemoryStorage
kostysh Jun 30, 2023
63d1d46
Merge pull request #32 from windingtree/test/memory-storage
kostysh Jun 30, 2023
8d50cd7
chore: 🤖 Linter fixes
kostysh Jun 30, 2023
98b1ec0
refactor: 💡 Optional props in PaginationOptions
kostysh Jun 30, 2023
6dc9528
refactor: 💡 Optional props in PaginationOptions
kostysh Jun 30, 2023
d7f2aab
refactor: 💡 Chenged code structure in users router
kostysh Jun 30, 2023
0566989
refactor: 💡 Using of middleware with type overrides
kostysh Jun 30, 2023
f9d4392
feat: 🎸 superjson adde to trpc lient initialization
kostysh Jun 30, 2023
e243227
feat: 🎸 Added deals router
kostysh Jun 30, 2023
c3650ec
feat: 🎸 Added set of middlewares int the API server
kostysh Jun 30, 2023
40ba7d1
chore: 🤖 Deals router added to API server module exports
kostysh Jun 30, 2023
4895dbd
chore: 🤖 Updated the repository configuration
kostysh Jul 3, 2023
e72ad8a
refactor: 💡 Reconfigured exports from the node module
kostysh Jul 3, 2023
c47bd83
feat: 🎸 Added the Node API initialization logic to the example
kostysh Jul 3, 2023
b9b0a49
chore: 🤖 Updated repository configuration
kostysh Jul 4, 2023
119154e
refactor: 💡 Wallet provider extracted into separate example
kostysh Jul 4, 2023
80da4d7
feat: 🎸 Added example of a mode-manager's web-app
kostysh Jul 4, 2023
795794a
refactor: 💡 The client example app uses shared wallet provider
kostysh Jul 4, 2023
c8a2b75
refactor: 💡 Updated storage initializer typing
kostysh Jul 4, 2023
8a2bb5c
refactor: 💡 The Node API exports are refactored
kostysh Jul 4, 2023
d4e1de6
chore: 🤖 Minor server example update
kostysh Jul 4, 2023
723a597
feat: 🎸 The Node API server integrated into the Node example
kostysh Jul 4, 2023
08df3a2
test: 💍 Tests are updated to use the latest refactored code
kostysh Jul 4, 2023
84751f2
fix: 🐛 Fix for test workflow script
kostysh Jul 4, 2023
a3fb725
fix: 🐛 Fix for release workflow script
kostysh Jul 4, 2023
0bb1595
feat: 🎸 Added UNAUTHORIZED errors watcher link for tRPC client
kostysh Jul 5, 2023
94f3073
feat: 🎸 Added cookies-based authorization
kostysh Jul 5, 2023
1206742
feat: 🎸 Implemented login/logout in the manager app example
kostysh Jul 5, 2023
7edf172
feat: 🎸 Added user delete feature to the manager app example
kostysh Jul 5, 2023
e03383a
feat: 🎸 Password update feature added to the UsersDb.set
kostysh Jul 6, 2023
21e1086
refactor: 💡 PaginationInputSchema extracted in to separate util
kostysh Jul 6, 2023
488e766
feat: 🎸 Added user.update API route
kostysh Jul 6, 2023
c4abb4c
refactor: 💡 DealsGetAllInput... renamed into PaginationInput
kostysh Jul 6, 2023
92fc95e
feat: 🎸 Added UserRegister component of the node manager app
kostysh Jul 6, 2023
4b6c216
feat: 🎸 Added UserUpdate component of the node manager app
kostysh Jul 6, 2023
7fb937f
feat: 🎸 UserRegister/Update added to the LoginWidget component
kostysh Jul 6, 2023
4a1992d
chore: 🤖 Until monorepo; Added several nested lint commands
kostysh Jul 6, 2023
f9a8cbf
chore: 🤖 Updated test workflow
kostysh Jul 6, 2023
6d1f0af
fix: 🐛 Fixed filed Admin route > admin.login test
kostysh Jul 6, 2023
273eb3c
feat: 🎸 createCheckInOutSignature can be used in browser
kostysh Jul 6, 2023
fc2db46
refactor: 💡 Refactored deals API routes
kostysh Jul 6, 2023
546054e
refactor: 💡 Added feature to getDeal using offerId
kostysh Jul 6, 2023
2077c92
chore: 🤖 Minor cleanup of unauthorizedLink
kostysh Jul 6, 2023
e539bc4
feat: 🎸 Added checkInOutSignature helper to the dealsManager
kostysh Jul 6, 2023
00e1624
feat: 🎸 Added claimed deal saving step to the node example
kostysh Jul 6, 2023
361554c
chore: 🤖 Minot cleanup of the LoginWidger
kostysh Jul 6, 2023
a241bd6
feat: 🎸 Added DealSeek component to the node manager app exampl
kostysh Jul 6, 2023
8f253cc
feat: 🎸 Added deals table component to the node manager app
kostysh Jul 6, 2023
3c81d3b
feat: 🎸 Added DealCheckInOut component to the node manager app
kostysh Jul 6, 2023
f64cade
chore: 🤖 Enable deals related components in the node manager
kostysh Jul 6, 2023
46c3492
fix: 🐛 Fixed wrong types imports
kostysh Jul 6, 2023
7d49d6e
feat: 🎸 Added check out action to the client example app
kostysh Jul 6, 2023
c243646
Merge pull request #33 from windingtree/feat/deals-api
kostysh Jul 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
EXAMPLE_ENTITY_SIGNER_MNEMONIC=
# EXAMPLE_ENTITY_SIGNER_PK=
EXAMPLE_ENTITY_ID=
EXAMPLE_ENTITY_OWNER_ADDRESS=
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
node-version: "lts/*"
- name: Install dependencies
run: yarn install --frozen-lockfile && yarn --cwd ./examples/client install --frozen-lockfile
run: yarn install --frozen-lockfile && yarn --cwd ./examples/client install --frozen-lockfile && yarn --cwd ./examples/manager install --frozen-lockfile
- name: Lint
run: yarn lint
- name: Test
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
with:
node-version: "lts/*"
- name: Install dependencies
run: yarn install --frozen-lockfile && yarn --cwd ./examples/client install --frozen-lockfile
run: |
yarn install --frozen-lockfile && \
yarn --cwd ./examples/client install --frozen-lockfile && \
yarn --cwd ./examples/manager install --frozen-lockfile && \
yarn --cwd ./examples/react-libs install --frozen-lockfile
- name: Lint
run: yarn lint
- name: Test
Expand Down
14 changes: 8 additions & 6 deletions examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"version": "0.0.0",
"type": "module",
"devDependencies": {
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react": "^4.0.0",
"eslint": "^8.44.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "^5.0.4",
"viem": "^0.3.43",
"typescript": "^5.1.6",
"viem": "^1.2.9",
"vite": "^4.3.9"
},
"eslintConfig": {
Expand All @@ -39,8 +40,9 @@
]
},
"scripts": {
"dev": "vite --force",
"dev": "vite --force --port 5173",
"build": "tsc && vite build",
"preview": "vite preview"
"preview": "vite preview",
"lint": "eslint . --ext .ts"
}
}
10 changes: 4 additions & 6 deletions examples/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ import { hardhat, polygonZkEvmTestnet } from 'viem/chains';
import { EventHandler } from '@libp2p/interfaces/events';
import {
Client,
ClientOptions,
createClient,
storage,
ClientRequestsManager,
buildRequest,
ClientDealsManager,
ClientRequestRecord,
} from '../../../src/index.js'; // @windingtree/sdk
} from '../../../src/client/index.js'; // @windingtree/sdk
import { storage, buildRequest } from '../../../src/index.js'; // @windingtree/sdk
import {
RequestQuery,
OfferOptions,
contractsConfig,
serverAddress,
} from '../../shared/index.js';
import { OfferData, RequestData } from '../../../src/shared/types.js';
import { useWallet } from './providers/WalletProvider/WalletProviderContext.js';
import { AccountWidget } from './providers/WalletProvider/AccountWidget.js';
import { useWallet } from '../../react-libs/src/providers/WalletProvider/WalletProviderContext.js';
import { AccountWidget } from '../../react-libs/src/providers/WalletProvider/AccountWidget.js';
import { FormValues, RequestForm } from './components/RequestForm.js';
import { Tabs, TabPanel } from './components/Tabs.js';
import { Requests, RequestsRegistryRecord } from './components/Requests.js';
Expand Down
55 changes: 48 additions & 7 deletions examples/client/src/components/Deals.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { useState, useCallback, useEffect } from 'react';
import { DateTime } from 'luxon';
import { Address } from 'viem';
import { Address, Hash } from 'viem';
import {
ClientDealsManager,
DealRecord,
DealStatus,
} from '../../../../src/index.js'; // @windingtree/sdk
import { ClientDealsManager } from '../../../../src/client/dealsManager.js';
import { RequestQuery, OfferOptions } from '../../../shared/index.js';
import { centerEllipsis, formatBalance, parseWalletError } from '../utils.js';
import { useWallet } from '../providers/WalletProvider/WalletProviderContext.js';
import {
centerEllipsis,
formatBalance,
parseWalletError,
} from '../../../react-libs/src/utils/index.js';
import { useWallet } from '../../../react-libs/src/providers/WalletProvider/WalletProviderContext.js';

export type DealsRegistryRecord = Required<
DealRecord<RequestQuery, OfferOptions>
Expand Down Expand Up @@ -219,13 +223,31 @@ export const Cancel = ({ deal, manager, onClose }: CancelProps) => {
* Created deals table
*/
export const Deals = ({ deals, manager }: DealsProps) => {
const { walletClient } = useWallet();
const [dealStates, setDealStates] = useState<Record<string, DealStatus>>({});
const [transferDeal, setTransferDeal] = useState<
DealsRegistryRecord | undefined
>();
const [cancelDeal, setCancelDeal] = useState<
DealsRegistryRecord | undefined
>();
const [userSign, setUserSign] = useState<Hash | undefined>();
const [error, setError] = useState<string | undefined>();

const handleCheckInOut = useCallback(async (deal: DealsRegistryRecord) => {
try {
if (!manager || !walletClient) {
throw new Error('Wallet not connected yet');
}
setUserSign(await manager.checkInOutSignature(
deal.offer.id,
walletClient,
));
} catch (error) {
console.log(error);
setError((error as Error).message || 'Unknown check in signature error');
}
}, [manager, walletClient]);

useEffect(() => {
if (deals && deals.length > 0) {
Expand Down Expand Up @@ -271,8 +293,8 @@ export const Deals = ({ deals, manager }: DealsProps) => {
{DealStatus[dealStates[d.offer.id]]}
</td>
<td>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ marginBottom: 5 }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
<div>
<button
onClick={() => setCancelDeal(d)}
disabled={
Expand Down Expand Up @@ -302,13 +324,22 @@ export const Deals = ({ deals, manager }: DealsProps) => {
Transfer
</button>
</div>
{d.status === DealStatus.Claimed &&
<div>
<button
onClick={() => handleCheckInOut(d)}
>
Check In
</button>
</div>
}
</div>
</td>
</tr>
))}
</tbody>
</table>
<div style={{ marginTop: 20 }}>
<div>
<TransferForm
deal={transferDeal}
manager={manager}
Expand All @@ -319,7 +350,17 @@ export const Deals = ({ deals, manager }: DealsProps) => {
manager={manager}
onClose={() => setCancelDeal(undefined)}
/>
{userSign &&
<div style={{ marginTop: 20 }}>
<h2>Provide this signature to the reception manager:</h2>
<input style={{ width: '100%' }} onFocus={(event) => {
event.target.select();
}} value={userSign} onChange={() => {}} />
</div>
}
</div>

{error && <div style={{ marginTop: 20 }}>🚨 {error}</div>}
</div>
);
};
8 changes: 4 additions & 4 deletions examples/client/src/components/MakeDeal.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { useState, useCallback, useEffect } from 'react';
import { Hash, stringify } from 'viem';
import { ClientDealsManager } from '../../../../src/index.js'; // @windingtree/sdk
import { ClientDealsManager } from '../../../../src/client/dealsManager.js';
import { OfferData } from '../../../../src/shared/types.js';
import { RequestQuery, OfferOptions } from '../../../shared/index.js';
import {
ZeroHash,
centerEllipsis,
formatBalance,
parseWalletError,
} from '../utils.js';
import { useWallet } from '../providers/WalletProvider/WalletProviderContext.js';
import { ConnectButton } from '../providers/WalletProvider/ConnectButton.js';
} from '../../../react-libs/src/utils/index.js';
import { useWallet } from '../../../react-libs/src/providers/WalletProvider/WalletProviderContext.js';
import { ConnectButton } from '../../../react-libs/src/providers/WalletProvider/ConnectButton.js';

interface MakeDealProps {
offer?: OfferData<RequestQuery, OfferOptions>;
Expand Down
2 changes: 1 addition & 1 deletion examples/client/src/components/Offers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { stringify } from 'viem';
import { utils } from '../../../../src/index.js'; // @windingtree/sdk
import { OfferData } from '../../../../src/shared/types.js';
import { RequestQuery, OfferOptions } from '../../../shared/index.js';
import { centerEllipsis } from '../utils.js';
import { centerEllipsis } from '../../../react-libs/src/utils/index.js';

interface OffersProps {
offers?: OfferData<RequestQuery, OfferOptions>[];
Expand Down
5 changes: 3 additions & 2 deletions examples/client/src/components/Requests.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ClientRequestRecord, utils } from '../../../../src/index.js'; // @windingtree/sdk
import { utils } from '../../../../src/index.js'; // @windingtree/sdk
import { ClientRequestRecord } from '../../../../src/client/requestsManager.js';
import { OfferData } from '../../../../src/shared/types.js';
import { RequestQuery, OfferOptions } from '../../../shared/index.js';
import { centerEllipsis } from '../utils.js';
import { centerEllipsis } from '../../../react-libs/src/utils/index.js';

export type RequestsRegistryRecord = Required<
ClientRequestRecord<RequestQuery, OfferOptions>
Expand Down
2 changes: 1 addition & 1 deletion examples/client/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createRoot } from 'react-dom/client';
import { WalletProvider } from './providers/WalletProvider';
import { WalletProvider } from '../../react-libs/src/providers/WalletProvider/index.js';
import { App } from './App';

window.addEventListener('unhandledrejection', (event) => {
Expand Down
Loading