diff --git a/src/bindings/config.ts b/src/bindings/config.ts index 5a2c0841d..4599436ef 100644 --- a/src/bindings/config.ts +++ b/src/bindings/config.ts @@ -60,7 +60,7 @@ export const loadConfig = async (context: Context): Promise => { payout: { networkId: networkId, rpc: rpc, - privateKeyEncrypted: privateKeyEncrypted || "", + privateKeyEncrypted: privateKeyEncrypted || null, paymentToken: paymentToken, permitBaseUrl: process.env.PERMIT_BASE_URL || permitBaseUrl, }, @@ -113,7 +113,7 @@ export const loadConfig = async (context: Context): Promise => { newContributorGreeting: newContributorGreeting, }; - if (botConfig.payout.privateKeyEncrypted == "") { + if (!botConfig.payout.privateKeyEncrypted) { botConfig.mode.paymentPermitMaxPrice = 0; } diff --git a/src/handlers/payout/action.ts b/src/handlers/payout/action.ts index 924bcc724..9f996de40 100644 --- a/src/handlers/payout/action.ts +++ b/src/handlers/payout/action.ts @@ -27,7 +27,7 @@ export interface IncentivesCalculationResult { paymentToken: string; rpc: string; networkId: number; - privateKeyEncrypted: string; + privateKeyEncrypted: string | null; paymentPermitMaxPrice: number; baseMultiplier: number; incentives: Incentives; @@ -147,7 +147,7 @@ export const incentivesCalculation = async (): Promise; export const PayoutConfigSchema = Type.Object({ networkId: Type.Number(), rpc: Type.String(), - privateKeyEncrypted: Type.String(), + privateKeyEncrypted: Type.Union([Type.Null(), Type.String()]), paymentToken: Type.String(), permitBaseUrl: Type.String(), }); diff --git a/src/utils/private.ts b/src/utils/private.ts index 423ce7ea3..57db827db 100644 --- a/src/utils/private.ts +++ b/src/utils/private.ts @@ -64,8 +64,10 @@ export const getOrgAndRepoFromPath = (path: string) => { return { org, repo }; }; -export const getPrivateKey = async (cipherText: string): Promise => { +export const getPrivateKey = async (cipherText: string | null): Promise => { try { + if (!cipherText) throw new Error("Cipher text is empty"); + await _sodium.ready; const sodium = _sodium;