From 0e53f043b53992714d3bf3217c50e8c39cea7c03 Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Thu, 10 Aug 2023 15:03:32 +0100 Subject: [PATCH] Revert "Delete hand-made auth, not needed anymore" This reverts commit a6a8f4e251c2e59e5060ef1e39b994572c82e58b. --- actions/utils.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/actions/utils.ts b/actions/utils.ts index 6a6fd4d..506732c 100644 --- a/actions/utils.ts +++ b/actions/utils.ts @@ -26,11 +26,25 @@ export async function getProvider( () => undefined ); const providerConfig: ConnectionInfo = - user && password ? { url, user, password } : { url }; + user && password + ? { + url, + // TODO: This is a hack to make it work for HTTP endpoints (while we don't have a HTTPS one for Gnosis Chain), however I will delete once we have it + headers: { + Authorization: getAuthHeader({ user, password }), + }, + // user: await getSecret(`NODE_USER_${network}`, context), + // password: await getSecret(`NODE_PASSWORD_${network}`, context), + } + : { url }; return new ethers.providers.JsonRpcProvider(providerConfig); } +function getAuthHeader({ user, password }: { user: string; password: string }) { + return "Basic " + Buffer.from(`${user}:${password}`).toString("base64"); +} + export function apiUrl(network: string): string { switch (network) { case "1":