Skip to content

Commit

Permalink
Production Deploy (#13446)
Browse files Browse the repository at this point in the history
Manual deploy as of commit:db666a62334d0272531b4da720c874cd17043c40
  • Loading branch information
julien51 committed Mar 12, 2024
1 parent 5bae935 commit d039b7c
Show file tree
Hide file tree
Showing 182 changed files with 14,317 additions and 14,933 deletions.
5 changes: 4 additions & 1 deletion .clabot
Expand Up @@ -57,7 +57,10 @@
"teawaterwire",
"sudheerDev",
"SVell",
"JoaoCampos89"
"JoaoCampos89",
"jchanolm",
"0xTxbi",
"FedericoCaruso"
],
"message": "Thank you for your pull request and welcome to Unlock! We require contributors to sign our [Contributor License Agreement](https://github.com/unlock-protocol/unlock/blob/master/CLA.txt), and we don't seem to have the users {{usersWithoutCLA}} on file. \nIn order for us to review and merge your code, please open _another_ pull request with a single modification: your github username added to the file `.clabot`.\nThank you! "
}
672 changes: 336 additions & 336 deletions .yarn/releases/yarn-4.0.2.cjs → .yarn/releases/yarn-4.1.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Expand Up @@ -28,4 +28,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"

yarnPath: .yarn/releases/yarn-4.0.2.cjs
yarnPath: .yarn/releases/yarn-4.1.1.cjs
2 changes: 1 addition & 1 deletion docker/docker-compose.ci.yml
Expand Up @@ -253,7 +253,7 @@ services:

ipfs:
# Required for subgraph
image: ipfs/go-ipfs:v0.25.0
image: ipfs/go-ipfs:v0.27.0
ports:
- '5001:5001'

Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Expand Up @@ -8,7 +8,7 @@ services:
- '8020:8020'

ipfs:
image: ipfs/kubo:v0.25.0
image: ipfs/kubo:v0.27.0
ports:
- '5001:5001'

Expand Down
2 changes: 1 addition & 1 deletion governance/package.json
Expand Up @@ -15,7 +15,7 @@
"@openzeppelin/upgrades-core": "1.32.5",
"@safe-global/api-kit": "2.0.0",
"@safe-global/protocol-kit": "2.0.0",
"@tenderly/hardhat-tenderly": "2.1.1",
"@tenderly/hardhat-tenderly": "2.2.2",
"@unlock-protocol/contracts": "workspace:./packages/contracts",
"@unlock-protocol/eslint-config": "workspace:./packages/eslint-config",
"@unlock-protocol/hardhat-helpers": "workspace:^",
Expand Down
23 changes: 23 additions & 0 deletions locksmith/__tests__/controllers/v2/verifierController.test.ts
Expand Up @@ -59,6 +59,29 @@ describe('Verifier v2 endpoints for locksmith', () => {
expect(deleteVerifierResponse.status).toBe(200)
})

it('Add verifier with name and delete correctly', async () => {
expect.assertions(4)
const verifierName = 'randomUser'

const { loginResponse } = await loginRandomUser(app)
const randomWallet = await ethers.Wallet.createRandom().getAddress()
expect(loginResponse.status).toBe(200)

const addVerifierResponse = await request(app)
.put(`/v2/api/verifier/${network}/${lockAddress}/${randomWallet}`)
.set('authorization', `Bearer ${loginResponse.body.accessToken}`)
.send({ verifierName: verifierName })

expect(addVerifierResponse.status).toBe(201)
expect(addVerifierResponse.body.name).toBe(verifierName)

const deleteVerifierResponse = await request(app)
.delete(`/v2/api/verifier/${network}/${lockAddress}/${randomWallet}`)
.set('authorization', `Bearer ${loginResponse.body.accessToken}`)

expect(deleteVerifierResponse.status).toBe(200)
})

it('Get verifiers list', async () => {
expect.assertions(3)

Expand Down
32 changes: 0 additions & 32 deletions locksmith/__tests__/utils/decoyUser.test.ts

This file was deleted.

15 changes: 15 additions & 0 deletions locksmith/migrations/20240208193316-add-name-verifier.js
@@ -0,0 +1,15 @@
'use strict'
const table = 'Verifiers'
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn(table, 'name', {
type: Sequelize.STRING,
allowNull: true,
})
},

async down(queryInterface, Sequelize) {
await queryInterface.removeColumn(table, 'name')
},
}
1 change: 0 additions & 1 deletion locksmith/package.json
Expand Up @@ -74,7 +74,6 @@
"p-retry": "6.0.0",
"path-to-regexp": "6.2.1",
"pg": "8.11.3",
"random-words": "2.0.0",
"rate-limiter-flexible": "4.0.1",
"react": "18.2.0",
"remark-html": "15.0.2",
Expand Down
10 changes: 7 additions & 3 deletions locksmith/src/controllers/userController.ts
@@ -1,9 +1,9 @@
import { Request, Response } from 'express'
import { DecoyUser } from '../utils/decoyUser'
import StripeOperations from '../operations/stripeOperations'
import * as Normalizer from '../utils/normalizer'
import UserOperations from '../operations/userOperations'
import logger from '../logger'
import { ethers } from 'ethers'

export const createUser = async (req: Request, res: Response): Promise<any> => {
try {
Expand Down Expand Up @@ -60,7 +60,10 @@ export const retrieveEncryptedPrivatekey = async (
if (result) {
return res.json({ passwordEncryptedPrivateKey: result })
} else {
const result = await new DecoyUser().encryptedPrivateKey()
const result = await ethers.Wallet.createRandom().encrypt(
(Math.random() + 1).toString(36)
)
console.log(result)

return res.json({
passwordEncryptedPrivateKey: result,
Expand All @@ -85,7 +88,8 @@ export const retrieveRecoveryPhrase = async (
if (result) {
return res.json({ recoveryPhrase: result })
}
const recoveryPhrase = new DecoyUser().recoveryPhrase()
// Create a fake recoveryPhrase
const recoveryPhrase = (Math.random() + 1).toString(36)
return res.json({ recoveryPhrase })
}

Expand Down
29 changes: 27 additions & 2 deletions locksmith/src/controllers/v2/ticketsController.tsx
Expand Up @@ -10,6 +10,7 @@ import { createTicket } from '../../utils/ticket'
import { generateKeyMetadata } from '../../operations/metadataOperations'
import config from '../../config/config'
import { getVerifiersList } from '../../operations/verifierOperations'
import { Verifier } from '../../models/verifier'

export class TicketsController {
public web3Service: Web3Service
Expand Down Expand Up @@ -48,6 +49,14 @@ export class TicketsController {
const lockAddress = Normalizer.ethereumAddress(request.params.lockAddress)
const network = Number(request.params.network)
const id = request.params.keyId.toLowerCase()
const address = Normalizer.ethereumAddress(request.user!.walletAddress!)
const verifier = await Verifier.findOne({
where: {
lockAddress,
address,
network,
},
})

const keyMetadata = await KeyMetadata.findOne({
where: {
Expand All @@ -57,7 +66,9 @@ export class TicketsController {
})

const data = keyMetadata?.data as unknown as {
metadata: { checkedInAt: number | number[] }
metadata: {
checkedInAt: number | number[] | { at: number; verifierName: string }
}
}

const checkedInAt = []
Expand All @@ -66,7 +77,14 @@ export class TicketsController {
} else if (typeof data?.metadata?.checkedInAt === 'number') {
checkedInAt.push(data?.metadata?.checkedInAt, new Date().getTime())
} else if (Array.isArray(data?.metadata?.checkedInAt)) {
checkedInAt.push(...data.metadata.checkedInAt, new Date().getTime())
if (verifier?.name) {
checkedInAt.push(...data.metadata.checkedInAt, {
at: new Date().getTime(),
verifierName: verifier.name,
})
} else {
checkedInAt.push(...data.metadata.checkedInAt, new Date().getTime())
}
}

await KeyMetadata.upsert(
Expand Down Expand Up @@ -319,6 +337,12 @@ export const getTicket: RequestHandler = async (request, response) => {
.map((item: string) => Normalizer.ethereumAddress(item))
.includes(Normalizer.ethereumAddress(userAddress))

const verifier = verifiers.find(
(item) =>
Normalizer.ethereumAddress(item.address) ===
Normalizer.ethereumAddress(userAddress)
)

const isVerifier = verifiers
?.map((item) => Normalizer.ethereumAddress(item.address))
.includes(Normalizer.ethereumAddress(userAddress))
Expand Down Expand Up @@ -353,5 +377,6 @@ export const getTicket: RequestHandler = async (request, response) => {
protected: keyData?.userMetadata?.protected || {},
},
isVerifier: isVerifier || isManager,
verifierName: isVerifier ? verifier?.name : null,
})
}
15 changes: 14 additions & 1 deletion locksmith/src/controllers/v2/verifierController.ts
Expand Up @@ -3,6 +3,13 @@ import Normalizer from '../../utils/normalizer'
import logger from '../../logger'

import VerifierOperations from '../../operations/verifierOperations'
import { z } from 'zod'

const AddVerifierBody = z
.object({
verifierName: z.string().optional(),
})
.optional()

export default class VerifierController {
// for a lock manager to list all verifiers for a specicifc lock address
Expand Down Expand Up @@ -37,6 +44,11 @@ export default class VerifierController {
const lockAddress = Normalizer.ethereumAddress(request.params.lockAddress)
const address = Normalizer.ethereumAddress(request.params.verifierAddress)
const network = Number(request.params.network)
const addVerifierBody = await AddVerifierBody.parseAsync(request.body)

const name = addVerifierBody?.verifierName
? addVerifierBody?.verifierName
: null

const loggedUserAddress = Normalizer.ethereumAddress(
request.user!.walletAddress!
Expand All @@ -57,7 +69,8 @@ export default class VerifierController {
lockAddress,
address,
loggedUserAddress,
network
network,
name
)
return response.status(201).send(createdVerifier)
}
Expand Down
6 changes: 6 additions & 0 deletions locksmith/src/models/verifier.ts
Expand Up @@ -15,6 +15,7 @@ export class Verifier extends Model<
declare lockAddress: string
declare lockManager: string
declare network: number
declare name: string | null
declare createdAt: CreationOptional<Date>
declare updatedAt: CreationOptional<Date>
}
Expand All @@ -35,6 +36,11 @@ Verifier.init(
type: DataTypes.STRING,
allowNull: false,
},
name: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
},
network: {
type: DataTypes.INTEGER,
allowNull: false,
Expand Down
4 changes: 3 additions & 1 deletion locksmith/src/operations/verifierOperations.ts
Expand Up @@ -58,13 +58,15 @@ export const createVerifier = async (
lockAddress: string,
address: string,
lockManager: string,
network: number
network: number,
name: string | null
) => {
const newVerifier = new Verifier({
lockAddress,
address,
lockManager,
network,
name,
})
return newVerifier.save()
}
Expand Down
1 change: 1 addition & 0 deletions locksmith/src/routes/v2/images.ts
Expand Up @@ -31,6 +31,7 @@ export const upload = multer({
}
},
storage: multerS3({
// @ts-expect-error Type 'import("/Users/julien/repos/unlock/node_modules/@aws-sdk/client-s3/dist-types/S3Client").S3Client' is not assignable to type 'import("/Users/julien/repos/unlock/node_modules/@types/multer-s3/node_modules/@aws-sdk/client-s3/dist-types/S3Client").S3Client'. Types of property 'config' are incompatible.
s3: storageClient,
// Cloudflare R2 does not support other ACLs schemes. See: https://developers.cloudflare.com/r2/data-access/s3-api/api/
// That said, we only require public-read.
Expand Down
14 changes: 0 additions & 14 deletions locksmith/src/utils/decoyUser.ts

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -21,7 +21,7 @@
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-sort-keys-fix": "1.1.2",
"eslint-plugin-vitest": "0.3.0",
"husky": "8.0.3",
"husky": "9.0.11",
"lint-staged": "15.1.0",
"prettier": "3.0.0"
},
Expand Down Expand Up @@ -80,7 +80,7 @@
},
"engineStrict": true,
"homepage": "https://github.com/unlock-protocol/unlock#readme",
"packageManager": "yarn@4.0.2",
"packageManager": "yarn@4.1.1",
"lint-staged": {
"*.{js,ts,tsx}": "yarn run lint --fix",
"*.{js,ts,tsx,sol,css,md}": "prettier --write --plugin=prettier-plugin-solidity",
Expand Down
7 changes: 1 addition & 6 deletions packages/contracts/src/index.ts
Expand Up @@ -77,9 +77,4 @@ export { UnlockDiscountTokenV2 }
export { UnlockDiscountTokenV3 }
export { GovernorUnlockProtocol }
export { GovernorUnlockProtocolTimelock }
export {
LockSerializer,
UnlockSwapPurchaser,
UnlockSwapBurner,
UniswapOracleV3,
}
export { LockSerializer,UnlockSwapPurchaser,UnlockSwapBurner,UniswapOracleV3 }
2 changes: 1 addition & 1 deletion packages/ui/package.json
Expand Up @@ -74,7 +74,7 @@
"@unlock-protocol/unlock-js": "workspace:./packages/unlock-js",
"@vitejs/plugin-react": "4.2.1",
"autoprefixer": "10.4.18",
"postcss": "8.4.32",
"postcss": "8.4.35",
"react": "18.2.0",
"react-dom": "18.2.0",
"storybook": "7.6.3",
Expand Down
4 changes: 4 additions & 0 deletions packages/unlock-js/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changes

# 0.43.2

- using `totalKeys` when possible (lock v11 and further)

# 0.43.1

- adding the ability to add a filter for approval when listing keys.
Expand Down

0 comments on commit d039b7c

Please sign in to comment.