From 7704f354003a575b883090fba12b67cf3135c58a Mon Sep 17 00:00:00 2001 From: mattcasey Date: Sat, 22 Feb 2025 10:44:14 -0700 Subject: [PATCH] fix things --- .../lib/session/loginWithWalletAction.ts | 1 - lib/blockchain/signAndVerify.ts | 5 +---- lib/blockchain/walletClient.ts | 3 +-- lib/charms/generateCharmWallet.ts | 3 +-- lib/middleware/requireWalletSignature.ts | 3 +-- lib/rewards/listAvailableRewards.ts | 2 +- lib/roles/__tests__/assignRole.spec.ts | 9 ++------- lib/utils/__tests__/blockchain.spec.ts | 3 +-- lib/utils/__tests__/paginatedPrismaTask.spec.ts | 2 +- lib/utils/paginatedPrismaTask.ts | 3 +-- package-lock.json | 15 +++++++++++++++ .../users/src/__tests__/getUserProfile.spec.ts | 3 +-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/sunnyawards/lib/session/loginWithWalletAction.ts b/apps/sunnyawards/lib/session/loginWithWalletAction.ts index 0638708de3..602eae31ae 100644 --- a/apps/sunnyawards/lib/session/loginWithWalletAction.ts +++ b/apps/sunnyawards/lib/session/loginWithWalletAction.ts @@ -26,7 +26,6 @@ export const loginWithWalletAction = actionClient const { user: loggedInUser } = await createOrGetUserFromWallet({ address: parsedInput.address }); - ctx.session.anonymousUserId = undefined; ctx.session.user = { id: loggedInUser.id }; await ctx.session.save(); diff --git a/lib/blockchain/signAndVerify.ts b/lib/blockchain/signAndVerify.ts index 406198a524..8b02150c26 100644 --- a/lib/blockchain/signAndVerify.ts +++ b/lib/blockchain/signAndVerify.ts @@ -1,9 +1,8 @@ import { log } from '@charmverse/core/log'; +import { InvalidInputError } from '@packages/utils/errors'; import { SiweMessage } from 'siwe'; import { hashMessage, parseAbi } from 'viem'; -import { InvalidInputError } from '../../packages/utils/src/errors'; - import { getPublicClient } from './publicClient'; /** @@ -69,9 +68,7 @@ export async function verifyEIP1271Signature({ }: SignatureVerificationPayloadWithAddress): Promise { const chainId = message.chainId; const parsedMessage = new SiweMessage(message).toMessage(); - const messageHash = hashMessage(parsedMessage); - const client = getPublicClient(chainId); const data = await client diff --git a/lib/blockchain/walletClient.ts b/lib/blockchain/walletClient.ts index 5a9660ef6f..d05b6300bd 100644 --- a/lib/blockchain/walletClient.ts +++ b/lib/blockchain/walletClient.ts @@ -1,10 +1,9 @@ import { getChainById } from '@packages/blockchain/connectors/chains'; +import { InvalidInputError } from '@packages/utils/errors'; import { createWalletClient, http, publicActions } from 'viem'; import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'; import { optimismSepolia } from 'viem/chains'; -import { InvalidInputError } from '../../packages/utils/src/errors'; - export function getWalletClient({ chainId, privateKey, diff --git a/lib/charms/generateCharmWallet.ts b/lib/charms/generateCharmWallet.ts index 8591340e23..108bd1e60f 100644 --- a/lib/charms/generateCharmWallet.ts +++ b/lib/charms/generateCharmWallet.ts @@ -1,6 +1,5 @@ import { prisma } from '@charmverse/core/prisma-client'; - -import { isUniqueConstraintError } from '../../packages/utils/src/errors/prisma'; +import { isUniqueConstraintError } from '@packages/utils/errors/prisma'; type Params = { userId: string } | { spaceId: string }; diff --git a/lib/middleware/requireWalletSignature.ts b/lib/middleware/requireWalletSignature.ts index f9adfa99f8..66e1a689d8 100644 --- a/lib/middleware/requireWalletSignature.ts +++ b/lib/middleware/requireWalletSignature.ts @@ -1,3 +1,4 @@ +import { MissingDataError } from '@packages/utils/errors'; import type { SignatureVerificationPayloadWithAddress } from '@root/lib/blockchain/signAndVerify'; import { isValidWalletSignature, @@ -7,8 +8,6 @@ import { import type { NextApiRequest, NextApiResponse } from 'next'; import type { NextHandler } from 'next-connect'; -import { MissingDataError } from '../../packages/utils/src/errors'; - export async function requireWalletSignature(req: NextApiRequest, res: NextApiResponse, next: NextHandler) { const domain = req.headers.host as string; const { message, signature, address } = req.body as SignatureVerificationPayloadWithAddress; diff --git a/lib/rewards/listAvailableRewards.ts b/lib/rewards/listAvailableRewards.ts index 52cd1818bb..9b01289936 100644 --- a/lib/rewards/listAvailableRewards.ts +++ b/lib/rewards/listAvailableRewards.ts @@ -1,6 +1,6 @@ import { prisma } from '@charmverse/core/prisma-client'; +import { DataNotFoundError } from '@packages/utils/errors'; -import { DataNotFoundError } from '../../packages/utils/src/errors'; import type { AvailableResourcesRequest } from '../permissions/interfaces'; import { rewardWithUsersInclude } from './getReward'; diff --git a/lib/roles/__tests__/assignRole.spec.ts b/lib/roles/__tests__/assignRole.spec.ts index 37c668514e..b5447037fa 100644 --- a/lib/roles/__tests__/assignRole.spec.ts +++ b/lib/roles/__tests__/assignRole.spec.ts @@ -1,21 +1,16 @@ import type { Space, User } from '@charmverse/core/prisma'; import { InvalidStateError } from '@packages/nextjs/errors'; +import { ExpectedAnError } from '@packages/testing/errors'; import { generateRole, generateSpaceUser, generateUserAndSpace, generateUserAndSpaceWithApiToken } from '@packages/testing/setupDatabase'; +import { DataNotFoundError, InsecureOperationError, UndesirableOperationError } from '@packages/utils/errors'; import { assignRole, listRoleMembers } from '@root/lib/roles'; import { v4 } from 'uuid'; -import { ExpectedAnError } from '../../../packages/testing/src/errors'; -import { - DataNotFoundError, - InsecureOperationError, - UndesirableOperationError -} from '../../../packages/utils/src/errors'; - let user: User; let space: Space; diff --git a/lib/utils/__tests__/blockchain.spec.ts b/lib/utils/__tests__/blockchain.spec.ts index 17fb8509f3..1b373c9037 100644 --- a/lib/utils/__tests__/blockchain.spec.ts +++ b/lib/utils/__tests__/blockchain.spec.ts @@ -1,9 +1,8 @@ import type { UserWallet } from '@charmverse/core/prisma'; import { randomETHWalletAddress } from '@packages/testing/generateStubs'; +import { matchWalletAddress, shortenHex, shortWalletAddress } from '@packages/utils/blockchain'; import { getAddress } from 'viem'; -import { matchWalletAddress, shortenHex, shortWalletAddress } from '../../../packages/utils/src/blockchain'; - describe('shortWalletAddress()', () => { it('should shorten valid wallet addresses', () => { const address = randomETHWalletAddress(); diff --git a/lib/utils/__tests__/paginatedPrismaTask.spec.ts b/lib/utils/__tests__/paginatedPrismaTask.spec.ts index 0d68c92613..126f12bcdb 100644 --- a/lib/utils/__tests__/paginatedPrismaTask.spec.ts +++ b/lib/utils/__tests__/paginatedPrismaTask.spec.ts @@ -3,8 +3,8 @@ import type { Post } from '@charmverse/core/prisma-client'; import { prisma } from '@charmverse/core/prisma-client'; import { testUtilsForum, testUtilsUser } from '@charmverse/core/test'; import { arrayUtils } from '@charmverse/core/utilities'; +import { randomIntFromInterval } from '@packages/utils/random'; -import { randomIntFromInterval } from '../../../packages/utils/src/random'; import { paginatedPrismaTask } from '../paginatedPrismaTask'; describe('paginatedPrismaTask', () => { diff --git a/lib/utils/paginatedPrismaTask.ts b/lib/utils/paginatedPrismaTask.ts index eacdf4fd94..c9cd582d35 100644 --- a/lib/utils/paginatedPrismaTask.ts +++ b/lib/utils/paginatedPrismaTask.ts @@ -1,7 +1,6 @@ import type { Prisma } from '@charmverse/core/prisma-client'; import { prisma } from '@charmverse/core/prisma-client'; - -import { InvalidInputError } from '../../packages/utils/src/errors'; +import { InvalidInputError } from '@packages/utils/errors'; type PrismaModel = Extract< Uncapitalize, diff --git a/package-lock.json b/package-lock.json index 22b9a88c13..c459fa2f01 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63880,6 +63880,21 @@ "dependencies": { "@paralleldrive/cuid2": "^2.2.2" } + }, + "node_modules/react-email/node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.2.23", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.23.tgz", + "integrity": "sha512-zfHZOGguFCqAJ7zldTKg4tJHPJyJCOFhpoJcVxKL9BSUHScVDnMdDuOU1zPPGdOzr/GWxbhYTjyiEgLEpAoFPA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } } }, "dependencies": { diff --git a/packages/users/src/__tests__/getUserProfile.spec.ts b/packages/users/src/__tests__/getUserProfile.spec.ts index 102101d1d7..81e0608c1d 100644 --- a/packages/users/src/__tests__/getUserProfile.spec.ts +++ b/packages/users/src/__tests__/getUserProfile.spec.ts @@ -1,12 +1,11 @@ import { prisma } from '@charmverse/core/prisma-client'; import { sessionUserRelations } from '@packages/profile/constants'; import type { LoggedInUser } from '@packages/profile/getUser'; +import { getUserProfile } from '@packages/profile/getUser'; import { InvalidInputError, MissingDataError } from '@packages/utils/errors'; import { uid } from '@packages/utils/strings'; import { v4 } from 'uuid'; -import { getUserProfile } from '../@packages/profile/getUser'; - let user: LoggedInUser; const walletAddress = `0x${v4()}`;