Skip to content

Commit

Permalink
fix(locksmit): fixed relayer API
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Sep 11, 2024
1 parent 11ca921 commit 4c921cc
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 17 deletions.
1 change: 0 additions & 1 deletion locksmith/__tests__/fulfillment/dispatcher.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions locksmith/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`] || '',
}
})

Expand Down
8 changes: 4 additions & 4 deletions locksmith/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const defaultConfig = isProduction ? prodConfig : stagingConfig

interface DefenderRelayCredentials {
[network: number]: {
apiKey: string
apiSecret: string
relayerApiKey: string
relayerApiSecret: string
}
}

Expand All @@ -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}`] || '',
}
})

Expand Down
3 changes: 1 addition & 2 deletions locksmith/src/controllers/hookController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ interface HookControllerOptions {
}
}
export class HookController {
// eslint-disable-next-line
constructor(public options: HookControllerOptions) {}

async handle(request: SubscribeRequest, response: Response) {
Expand Down Expand Up @@ -61,7 +60,7 @@ export class HookController {
return
} catch (error) {
logger.error(error.message)
// eslint-disable-next-line

return
}
}
Expand Down
3 changes: 0 additions & 3 deletions locksmith/src/controllers/metadataController.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion locksmith/src/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand Down
10 changes: 8 additions & 2 deletions locksmith/src/fulfillment/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export const getPurchaser = async function ({
}: PurchaserArgs): Promise<ethers.Signer> {
// 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, {
Expand Down Expand Up @@ -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, {
Expand Down
1 change: 0 additions & 1 deletion locksmith/src/payment/paymentProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion locksmith/src/utils/envLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}

Expand Down

0 comments on commit 4c921cc

Please sign in to comment.