From 4c921ccc200521411841469066e31cbb60203bd3 Mon Sep 17 00:00:00 2001 From: Julien Genestoux Date: Wed, 11 Sep 2024 16:43:29 -0400 Subject: [PATCH] fix(locksmit): fixed relayer API --- locksmith/__tests__/fulfillment/dispatcher.test.ts | 1 - locksmith/config/config.js | 4 ++-- locksmith/src/config/config.ts | 8 ++++---- locksmith/src/controllers/hookController.ts | 3 +-- locksmith/src/controllers/metadataController.ts | 3 --- locksmith/src/controllers/userController.ts | 2 +- locksmith/src/fulfillment/dispatcher.ts | 10 ++++++++-- locksmith/src/payment/paymentProcessor.ts | 1 - locksmith/src/utils/envLoader.ts | 1 - 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/locksmith/__tests__/fulfillment/dispatcher.test.ts b/locksmith/__tests__/fulfillment/dispatcher.test.ts index 5a6953db73d..50dba9b4ce2 100644 --- a/locksmith/__tests__/fulfillment/dispatcher.test.ts +++ b/locksmith/__tests__/fulfillment/dispatcher.test.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line max-classes-per-file import { EventEmitter } from 'events' import { BigNumber, Wallet } from 'ethers' import Dispatcher from '../../src/fulfillment/dispatcher' diff --git a/locksmith/config/config.js b/locksmith/config/config.js index 43e9f3306d6..1037c072314 100644 --- a/locksmith/config/config.js +++ b/locksmith/config/config.js @@ -4,8 +4,8 @@ const networks = require('@unlock-protocol/networks') const defenderRelayCredentials = {} Object.values(networks).forEach((network) => { defenderRelayCredentials[network.id] = { - apiKey: process.env[`DEFENDER_RELAY_KEY_${network.id}`] || '', - apiSecret: process.env[`DEFENDER_RELAY_SECRET_${network.id}`] || '', + relayerApiKey: process.env[`DEFENDER_RELAY_KEY_${network.id}`] || '', + relayerApiSecret: process.env[`DEFENDER_RELAY_SECRET_${network.id}`] || '', } }) diff --git a/locksmith/src/config/config.ts b/locksmith/src/config/config.ts index ad8bbb7ff8b..54c78ae0692 100644 --- a/locksmith/src/config/config.ts +++ b/locksmith/src/config/config.ts @@ -37,8 +37,8 @@ const defaultConfig = isProduction ? prodConfig : stagingConfig interface DefenderRelayCredentials { [network: number]: { - apiKey: string - apiSecret: string + relayerApiKey: string + relayerApiSecret: string } } @@ -51,8 +51,8 @@ interface GoogleWalletCredentials { const defenderRelayCredentials: DefenderRelayCredentials = {} Object.values(networks).forEach((network) => { defenderRelayCredentials[network.id] = { - apiKey: process.env[`DEFENDER_RELAY_KEY_${network.id}`] || '', - apiSecret: process.env[`DEFENDER_RELAY_SECRET_${network.id}`] || '', + relayerApiKey: process.env[`DEFENDER_RELAY_KEY_${network.id}`] || '', + relayerApiSecret: process.env[`DEFENDER_RELAY_SECRET_${network.id}`] || '', } }) diff --git a/locksmith/src/controllers/hookController.ts b/locksmith/src/controllers/hookController.ts index 83997d26ed7..d9850e79bd5 100644 --- a/locksmith/src/controllers/hookController.ts +++ b/locksmith/src/controllers/hookController.ts @@ -22,7 +22,6 @@ interface HookControllerOptions { } } export class HookController { - // eslint-disable-next-line constructor(public options: HookControllerOptions) {} async handle(request: SubscribeRequest, response: Response) { @@ -61,7 +60,7 @@ export class HookController { return } catch (error) { logger.error(error.message) - // eslint-disable-next-line + return } } diff --git a/locksmith/src/controllers/metadataController.ts b/locksmith/src/controllers/metadataController.ts index 9e69e72eb4e..594b15336e8 100644 --- a/locksmith/src/controllers/metadataController.ts +++ b/locksmith/src/controllers/metadataController.ts @@ -1,6 +1,3 @@ -/* eslint-disable no-shadow */ -/* eslint-disable no-use-before-define */ - import { Web3Service } from '@unlock-protocol/unlock-js' import networks from '@unlock-protocol/networks' import { Response } from 'express' diff --git a/locksmith/src/controllers/userController.ts b/locksmith/src/controllers/userController.ts index e476afc927c..dc42af810d8 100644 --- a/locksmith/src/controllers/userController.ts +++ b/locksmith/src/controllers/userController.ts @@ -117,7 +117,7 @@ export const retrieveEncryptedPrivatekey = async ( { scrypt: { // web3 used 1 << 5, ethers default is 1 << 18. We want speedy encryption here since this is not a real account anyway. - // eslint-disable-next-line no-bitwise + N: 1 << 5, }, } diff --git a/locksmith/src/fulfillment/dispatcher.ts b/locksmith/src/fulfillment/dispatcher.ts index 3f2047dc3d5..dd580df4153 100644 --- a/locksmith/src/fulfillment/dispatcher.ts +++ b/locksmith/src/fulfillment/dispatcher.ts @@ -62,7 +62,10 @@ export const getPurchaser = async function ({ }: PurchaserArgs): Promise { // If we have a provider, we need to fetch that one... or yield an error! const defenderRelayCredential = config.defenderRelayCredentials[network] - if (defenderRelayCredential?.apiKey && defenderRelayCredential?.apiSecret) { + if ( + defenderRelayCredential?.relayerApiKey && + defenderRelayCredential?.relayerApiSecret + ) { const defender = new Defender(defenderRelayCredential) const provider = defender.relaySigner.getProvider() const wallet = await defender.relaySigner.getSigner(provider, { @@ -97,7 +100,10 @@ export const getAllPurchasers = async function ({ }: PurchaserArgs) { const purchasers = [] const defenderRelayCredential = config.defenderRelayCredentials[network] - if (defenderRelayCredential?.apiKey && defenderRelayCredential?.apiSecret) { + if ( + defenderRelayCredential?.relayerApiKey && + defenderRelayCredential?.relayerApiSecret + ) { const defender = new Defender(defenderRelayCredential) const provider = defender.relaySigner.getProvider() const wallet = await defender.relaySigner.getSigner(provider, { diff --git a/locksmith/src/payment/paymentProcessor.ts b/locksmith/src/payment/paymentProcessor.ts index ed6d6eef368..c404afd794b 100644 --- a/locksmith/src/payment/paymentProcessor.ts +++ b/locksmith/src/payment/paymentProcessor.ts @@ -23,7 +23,6 @@ export class PaymentProcessor { this.keyPricer = new KeyPricer() } - // eslint-disable-next-line class-methods-use-this async findUserByPublicKey(publicKey: ethereumAddress) { const normalizedEthereumAddress = Normalizer.ethereumAddress(publicKey) diff --git a/locksmith/src/utils/envLoader.ts b/locksmith/src/utils/envLoader.ts index aaaa2757ef6..cf882d00e73 100644 --- a/locksmith/src/utils/envLoader.ts +++ b/locksmith/src/utils/envLoader.ts @@ -12,7 +12,6 @@ const configPath = path.resolve( ) if (process.env.NODE_ENV !== 'test') { - // eslint-disable-next-line no-console console.log(`Loading config from ${configPath}`) }