From da8f8b3cc58cbfac9d6d1d82c4cb76532a98594e Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Thu, 17 Oct 2024 23:35:42 +0200 Subject: [PATCH 1/9] feat: used ubiquity-os-logger for logging --- package.json | 1 + src/adapters/supabase/helpers/wallet.ts | 2 +- src/handlers/command-parser.ts | 2 +- src/handlers/query-wallet.ts | 18 +++++-- src/plugin.ts | 68 ++++--------------------- src/types/context.ts | 18 ++++--- src/utils.ts | 20 ++++++++ tests/main.test.ts | 3 +- yarn.lock | 5 ++ 9 files changed, 65 insertions(+), 72 deletions(-) create mode 100644 src/utils.ts diff --git a/package.json b/package.json index c46e221..281079f 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@sinclair/typebox": "0.32.33", "@supabase/supabase-js": "2.43.5", "@ubiquity-dao/rpc-handler": "1.3.0", + "@ubiquity-os/ubiquity-os-logger": "^1.3.2", "commander": "12.1.0", "dotenv": "16.4.5", "ethers": "6.13.1", diff --git a/src/adapters/supabase/helpers/wallet.ts b/src/adapters/supabase/helpers/wallet.ts index 161b0ea..56915ad 100644 --- a/src/adapters/supabase/helpers/wallet.ts +++ b/src/adapters/supabase/helpers/wallet.ts @@ -169,7 +169,7 @@ export class Wallet extends Super { if (walletData.location_id === null) { throw new Error("Location ID is null"); } - logger.debug("Enriching wallet location metadata", locationMetaData); + logger.debug("Enriching wallet location metadata", { locationMetaData }); return this.supabase.from("locations").update(locationMetaData).eq("id", walletData.location_id); } } diff --git a/src/handlers/command-parser.ts b/src/handlers/command-parser.ts index 574d92e..caa9633 100644 --- a/src/handlers/command-parser.ts +++ b/src/handlers/command-parser.ts @@ -21,7 +21,7 @@ export class CommandParser { context.logger.debug(str); }, async writeErr(str: string) { - context.logger.warn(str); + context.logger.error(str); }, getErrHelpWidth(): number { return 0; diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index c03b706..12cda00 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -1,6 +1,7 @@ import { ethers } from "ethers"; import { Context } from "../types"; import { RPCHandler } from "@ubiquity-dao/rpc-handler"; +import { addCommentToIssue } from "../utils"; function extractEnsName(text: string) { const ensRegex = /^(?=.{3,40}$)([a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/gm; @@ -30,7 +31,10 @@ export async function registerWallet(context: Context, body: string) { } if (!address) { - return context.logger.info("Skipping to register a wallet address because both address/ens doesn't exist"); + const message = "Skipping to register a wallet address because both address/ens doesn't exist"; + await addCommentToIssue(context, `\`\`\`diff\n# ${message}`); + context.logger.info(message); + return; } if (config.registerWalletWithVerification) { @@ -38,7 +42,10 @@ export async function registerWallet(context: Context, body: string) { } if (address == ethers.ZeroAddress) { - return logger.error("Skipping to register a wallet address because user is trying to set their address to null address"); + const message = "Skipping to register a wallet address because user is trying to set their address to null address"; + await addCommentToIssue(context, `\`\`\`diff\n! ${message}`); + logger.error(message); + return; } // Makes sure that the address is check-summed @@ -47,7 +54,10 @@ export async function registerWallet(context: Context, body: string) { if (payload.comment) { const { wallet } = adapters.supabase; await wallet.upsertWalletAddress(context, address); - return context.logger.ok("Successfully registered wallet address", { sender, address }); + + const message = "Successfully registered wallet address"; + await addCommentToIssue(context, `\`\`\`diff\n# ${message}`); + context.logger.ok(message, { sender, address }); } else { throw new Error("Payload comment is undefined"); } @@ -67,7 +77,7 @@ function registerWalletWithVerification(context: Context, body: string, address: throw new Error(failedSigLogMsg); } } catch (e) { - context.logger.fatal("Exception thrown by verifyMessage for /wallet: ", e, failedSigLogMsg); + context.logger.fatal("Exception thrown by verifyMessage for /wallet: ", { e, failedSigLogMsg }); throw new Error(failedSigLogMsg); } } diff --git a/src/plugin.ts b/src/plugin.ts index 25d3aac..89be315 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,10 +1,12 @@ import { Octokit } from "@octokit/rest"; import { createClient } from "@supabase/supabase-js"; +import { Logs } from "@ubiquity-os/ubiquity-os-logger"; import { CommanderError } from "commander"; import { createAdapters } from "./adapters"; import { CommandParser } from "./handlers/command-parser"; import { Env, PluginInputs } from "./types"; import { Context } from "./types"; +import { addCommentToIssue } from "./utils"; /** * How a worker executes the plugin. @@ -19,56 +21,7 @@ export async function plugin(inputs: PluginInputs, env: Env) { config: inputs.settings, octokit, env, - logger: { - debug(message: unknown, ...optionalParams: unknown[]) { - console.debug(message, ...optionalParams); - }, - async ok(message: unknown, ...optionalParams: unknown[]) { - console.log(message, ...optionalParams); - try { - await octokit.issues.createComment({ - owner: context.payload.repository.owner.login, - issue_number: context.payload.issue.number, - repo: context.payload.repository.name, - body: `\`\`\`diff\n+ ${message}`, - }); - } catch (e) { - console.error("Failed to post ok comment", e); - } - }, - async info(message: unknown, ...optionalParams: unknown[]) { - console.log(message, ...optionalParams); - try { - await octokit.issues.createComment({ - owner: context.payload.repository.owner.login, - issue_number: context.payload.issue.number, - repo: context.payload.repository.name, - body: `\`\`\`diff\n# ${message}`, - }); - } catch (e) { - console.error("Failed to post info comment", e); - } - }, - warn(message: unknown, ...optionalParams: unknown[]) { - console.warn(message, ...optionalParams); - }, - async error(message: unknown, ...optionalParams: unknown[]) { - console.error(message, ...optionalParams); - try { - await octokit.issues.createComment({ - owner: context.payload.repository.owner.login, - issue_number: context.payload.issue.number, - repo: context.payload.repository.name, - body: `\`\`\`diff\n- ${message} ${optionalParams}`, - }); - } catch (e) { - console.error("Failed to post error comment", e); - } - }, - fatal(message: unknown, ...optionalParams: unknown[]) { - console.error(message, ...optionalParams); - }, - }, + logger: new Logs("info"), adapters: {} as ReturnType, }; @@ -79,17 +32,18 @@ export async function plugin(inputs: PluginInputs, env: Env) { try { const args = inputs.eventPayload.comment.body.trim().split(/\s+/); await commandParser.parse(args); - } catch (e) { - if (e instanceof CommanderError) { - if (e.code !== "commander.unknownCommand") { - await context.logger.error(e.message); + } catch (err) { + if (err instanceof CommanderError) { + if (err.code !== "commander.unknownCommand") { + await addCommentToIssue(context, `\`\`\`diff\n- ${err.message}`); + context.logger.error(err.message); } } else { - await context.logger.error(e); - throw e; + context.logger.error("An error occurred", { err }); + throw err; } } } else { - context.logger.warn(`Unsupported event: ${context.eventName}`); + context.logger.error(`Unsupported event: ${context.eventName}`); } } diff --git a/src/types/context.ts b/src/types/context.ts index 4d5bfb8..5af6dc1 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -1,5 +1,6 @@ import { Octokit } from "@octokit/rest"; import { EmitterWebhookEvent as WebhookEvent, EmitterWebhookEventName as WebhookEventName } from "@octokit/webhooks"; +import { Logs } from "@ubiquity-os/ubiquity-os-logger"; import { createAdapters } from "../adapters"; import { Env } from "./env"; import { PluginSettings } from "./plugin-inputs"; @@ -17,12 +18,13 @@ export interface Context; config: PluginSettings; env: Env; - logger: { - fatal: (message: unknown, ...optionalParams: unknown[]) => void; - error: (message: unknown, ...optionalParams: unknown[]) => Promise; - warn: (message: unknown, ...optionalParams: unknown[]) => void; - info: (message: unknown, ...optionalParams: unknown[]) => Promise; - ok: (message: unknown, ...optionalParams: unknown[]) => Promise; - debug: (message: unknown, ...optionalParams: unknown[]) => void; - }; + logger: Logs; + // { + // fatal: (message: unknown, ...optionalParams: unknown[]) => void; + // error: (message: unknown, ...optionalParams: unknown[]) => Promise; + // warn: (message: unknown, ...optionalParams: unknown[]) => void; + // info: (message: unknown, ...optionalParams: unknown[]) => Promise; + // ok: (message: unknown, ...optionalParams: unknown[]) => Promise; + // debug: (message: unknown, ...optionalParams: unknown[]) => void; + // }; } diff --git a/src/utils.ts b/src/utils.ts new file mode 100644 index 0000000..98e54d8 --- /dev/null +++ b/src/utils.ts @@ -0,0 +1,20 @@ +import { Context } from "./types"; + +export async function addCommentToIssue(context: Context, message: string | null) { + if (!message) { + context.logger.error("Message is not defined"); + return; + } + + const { payload } = context; + try { + await context.octokit.rest.issues.createComment({ + owner: payload.repository.owner.login, + issue_number: payload.issue.number, + repo: payload.repository.name, + body: message, + }); + } catch (err: unknown) { + throw new Error(context.logger.error("Failed to post comment", { error: err as Error }).logMessage.raw); + } +} diff --git a/tests/main.test.ts b/tests/main.test.ts index d0870df..69ff652 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -6,6 +6,7 @@ import { db } from "./__mocks__/db"; import { server } from "./__mocks__/node"; import commentCreatedPayload from "./__mocks__/payloads/comment-created.json"; import dbSeed from "./__mocks__/db-seed.json"; +import { Logs } from "@ubiquity-os/ubiquity-os-logger"; beforeAll(() => server.listen()); afterEach(() => server.resetHandlers()); @@ -31,7 +32,7 @@ describe("Wallet command tests", () => { }); it("Should link a wallet", async () => { - const spy = jest.spyOn(console, "log"); + const spy = jest.spyOn(Logs.prototype, "ok"); await plugin( { eventName: "issue_comment.created", diff --git a/yarn.lock b/yarn.lock index 30ef574..c0e175d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2407,6 +2407,11 @@ axios "^1.7.1" node-fetch "^3.3.2" +"@ubiquity-os/ubiquity-os-logger@^1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@ubiquity-os/ubiquity-os-logger/-/ubiquity-os-logger-1.3.2.tgz#4423bc0baeac5c2f73123d15fd961310521163cd" + integrity sha512-oTIzR8z4jAQmaeJp98t1bZUKE3Ws9pas0sbxt58fC37MwXclPMWrLO+a0JlhPkdJYsvpv/q/79wC2MKVhOIVXQ== + JSONStream@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" From ad58dcbe03814ac9dc7f40b67c9dd97d4770ae28 Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Fri, 18 Oct 2024 00:02:22 +0200 Subject: [PATCH 2/9] fix: fixed unittest --- tests/main.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/main.test.ts b/tests/main.test.ts index 69ff652..808f827 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -51,9 +51,12 @@ describe("Wallet command tests", () => { { SUPABASE_URL: process.env.SUPABASE_URL, SUPABASE_KEY: process.env.SUPABASE_KEY } ); expect(spy).toHaveBeenCalledTimes(1); - expect(spy).toHaveBeenLastCalledWith("Successfully registered wallet address", { - address: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd", - sender: "ubiquibot", - }); + expect(spy).toHaveBeenLastCalledWith( + "Successfully registered wallet address", + expect.objectContaining({ + address: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd", + sender: "ubiquibot", + }) + ); }, 10000); }); From 80443f049c5106b2c3c25c155f3e70d1cd700ea4 Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Mon, 21 Oct 2024 21:53:19 +0200 Subject: [PATCH 3/9] fix: process review comments --- src/handlers/query-wallet.ts | 20 +++++++++----------- src/types/context.ts | 8 -------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 12cda00..2220129 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -22,18 +22,17 @@ export async function registerWallet(context: Context, body: string) { const ensName = extractEnsName(body.replace("/wallet", "").trim()); if (!address && ensName) { - context.logger.debug("Trying to resolve address from ENS name", { ensName }); + logger.debug("Trying to resolve address from ENS name", { ensName }); address = await resolveAddress(ensName); if (!address) { throw new Error(`Resolving address from ENS name failed: ${ensName}`); } - context.logger.debug("Resolved address from ENS name", { ensName, address }); + logger.debug("Resolved address from ENS name", { ensName, address }); } if (!address) { - const message = "Skipping to register a wallet address because both address/ens doesn't exist"; - await addCommentToIssue(context, `\`\`\`diff\n# ${message}`); - context.logger.info(message); + const logMessage = logger.info("Skipping to register a wallet address because both address/ens doesn't exist"); + await addCommentToIssue(context, logMessage.logMessage.diff); return; } @@ -42,9 +41,9 @@ export async function registerWallet(context: Context, body: string) { } if (address == ethers.ZeroAddress) { - const message = "Skipping to register a wallet address because user is trying to set their address to null address"; - await addCommentToIssue(context, `\`\`\`diff\n! ${message}`); - logger.error(message); + const logMessage = logger.error("Skipping to register a wallet address because user is trying to set their address to null address"); + await addCommentToIssue(context, logMessage.logMessage.diff); + return; } @@ -55,9 +54,8 @@ export async function registerWallet(context: Context, body: string) { const { wallet } = adapters.supabase; await wallet.upsertWalletAddress(context, address); - const message = "Successfully registered wallet address"; - await addCommentToIssue(context, `\`\`\`diff\n# ${message}`); - context.logger.ok(message, { sender, address }); + const message = logger.ok("Successfully registered wallet address", { sender, address }); + await addCommentToIssue(context, message.logMessage.diff); } else { throw new Error("Payload comment is undefined"); } diff --git a/src/types/context.ts b/src/types/context.ts index 5af6dc1..661406d 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -19,12 +19,4 @@ export interface Context void; - // error: (message: unknown, ...optionalParams: unknown[]) => Promise; - // warn: (message: unknown, ...optionalParams: unknown[]) => void; - // info: (message: unknown, ...optionalParams: unknown[]) => Promise; - // ok: (message: unknown, ...optionalParams: unknown[]) => Promise; - // debug: (message: unknown, ...optionalParams: unknown[]) => void; - // }; } From b82b4d36ed0083e51b064872f6be6683d0625a6f Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Tue, 22 Oct 2024 08:30:38 +0200 Subject: [PATCH 4/9] fix: inline logging message --- src/handlers/query-wallet.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 2220129..982946a 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -31,8 +31,7 @@ export async function registerWallet(context: Context, body: string) { } if (!address) { - const logMessage = logger.info("Skipping to register a wallet address because both address/ens doesn't exist"); - await addCommentToIssue(context, logMessage.logMessage.diff); + await addCommentToIssue(context, logger.info("Skipping to register a wallet address because both address/ens doesn't exist").logMessage.diff); return; } @@ -41,8 +40,10 @@ export async function registerWallet(context: Context, body: string) { } if (address == ethers.ZeroAddress) { - const logMessage = logger.error("Skipping to register a wallet address because user is trying to set their address to null address"); - await addCommentToIssue(context, logMessage.logMessage.diff); + await addCommentToIssue( + context, + logger.error("Skipping to register a wallet address because user is trying to set their address to null address").logMessage.diff + ); return; } @@ -54,8 +55,7 @@ export async function registerWallet(context: Context, body: string) { const { wallet } = adapters.supabase; await wallet.upsertWalletAddress(context, address); - const message = logger.ok("Successfully registered wallet address", { sender, address }); - await addCommentToIssue(context, message.logMessage.diff); + await addCommentToIssue(context, logger.ok("Successfully registered wallet address", { sender, address }).logMessage.diff); } else { throw new Error("Payload comment is undefined"); } From f576c0561892780027d498541d98d095798e9345 Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Tue, 22 Oct 2024 19:02:31 +0200 Subject: [PATCH 5/9] fix: fixed failing unittest --- tests/main.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/main.test.ts b/tests/main.test.ts index 808f827..eb71b0e 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -1,5 +1,6 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, jest } from "@jest/globals"; import { ethers } from "ethers"; +import { JsonRpcProvider } from "@ethersproject/providers"; import { plugin } from "../src/plugin"; import { PluginInputs } from "../src/types"; import { db } from "./__mocks__/db"; @@ -7,6 +8,7 @@ import { server } from "./__mocks__/node"; import commentCreatedPayload from "./__mocks__/payloads/comment-created.json"; import dbSeed from "./__mocks__/db-seed.json"; import { Logs } from "@ubiquity-os/ubiquity-os-logger"; +import { RPCHandler } from "@ubiquity-dao/rpc-handler"; beforeAll(() => server.listen()); afterEach(() => server.resetHandlers()); @@ -32,6 +34,11 @@ describe("Wallet command tests", () => { }); it("Should link a wallet", async () => { + jest + .spyOn(RPCHandler.prototype, "getFirstAvailableRpcProvider") + .mockResolvedValue(new JsonRpcProvider({ url: "https://fastethrpc.com", skipFetchSetup: true }, Number(1))); + jest.spyOn(JsonRpcProvider.prototype, "resolveName").mockResolvedValue("0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd"); + const spy = jest.spyOn(Logs.prototype, "ok"); await plugin( { From 9619a97c40f70a5dcb14f709a75d15e151a0c018 Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Tue, 22 Oct 2024 19:06:20 +0200 Subject: [PATCH 6/9] fix: added @ethersproject/providers --- package.json | 4 +++- yarn.lock | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 281079f..7d35144 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "@cspell/dict-software-terms": "3.4.6", "@cspell/dict-typescript": "3.1.5", "@eslint/js": "9.5.0", + "@ethersproject/providers": "^5.7.2", "@jest/globals": "29.7.0", "@mswjs/data": "0.16.1", "@types/node": "20.14.5", @@ -90,5 +91,6 @@ "extends": [ "@commitlint/config-conventional" ] - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/yarn.lock b/yarn.lock index c0e175d..84cf006 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1357,7 +1357,7 @@ dependencies: "@ethersproject/logger" "^5.7.0" -"@ethersproject/providers@5.7.2": +"@ethersproject/providers@5.7.2", "@ethersproject/providers@^5.7.2": version "5.7.2" resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg== From f2dc71af5ff661212c2184f215372dd9d6d4e7f1 Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Thu, 24 Oct 2024 08:19:34 +0200 Subject: [PATCH 7/9] fix: update package.json Co-authored-by: Mentlegen <9807008+gentlementlegen@users.noreply.github.com> --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 7d35144..7414243 100644 --- a/package.json +++ b/package.json @@ -92,5 +92,4 @@ "@commitlint/config-conventional" ] }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } From de783d3a51193baecae332291e79dd19b6ecb5cc Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Thu, 24 Oct 2024 08:59:39 +0200 Subject: [PATCH 8/9] fix: removed comma in the package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7414243..2a1ba9c 100644 --- a/package.json +++ b/package.json @@ -91,5 +91,5 @@ "extends": [ "@commitlint/config-conventional" ] - }, + } } From 13253ac45ade2b87681180b7084b44cabdad64e3 Mon Sep 17 00:00:00 2001 From: Aries Gunawan Date: Thu, 24 Oct 2024 18:47:39 +0200 Subject: [PATCH 9/9] fix: revert changes in test --- package.json | 1 - src/handlers/query-wallet.ts | 1 - tests/main.test.ts | 7 ------- yarn.lock | 2 +- 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/package.json b/package.json index 2a1ba9c..281079f 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "@cspell/dict-software-terms": "3.4.6", "@cspell/dict-typescript": "3.1.5", "@eslint/js": "9.5.0", - "@ethersproject/providers": "^5.7.2", "@jest/globals": "29.7.0", "@mswjs/data": "0.16.1", "@types/node": "20.14.5", diff --git a/src/handlers/query-wallet.ts b/src/handlers/query-wallet.ts index 982946a..c80b127 100644 --- a/src/handlers/query-wallet.ts +++ b/src/handlers/query-wallet.ts @@ -50,7 +50,6 @@ export async function registerWallet(context: Context, body: string) { // Makes sure that the address is check-summed address = ethers.getAddress(address); - if (payload.comment) { const { wallet } = adapters.supabase; await wallet.upsertWalletAddress(context, address); diff --git a/tests/main.test.ts b/tests/main.test.ts index eb71b0e..808f827 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -1,6 +1,5 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, jest } from "@jest/globals"; import { ethers } from "ethers"; -import { JsonRpcProvider } from "@ethersproject/providers"; import { plugin } from "../src/plugin"; import { PluginInputs } from "../src/types"; import { db } from "./__mocks__/db"; @@ -8,7 +7,6 @@ import { server } from "./__mocks__/node"; import commentCreatedPayload from "./__mocks__/payloads/comment-created.json"; import dbSeed from "./__mocks__/db-seed.json"; import { Logs } from "@ubiquity-os/ubiquity-os-logger"; -import { RPCHandler } from "@ubiquity-dao/rpc-handler"; beforeAll(() => server.listen()); afterEach(() => server.resetHandlers()); @@ -34,11 +32,6 @@ describe("Wallet command tests", () => { }); it("Should link a wallet", async () => { - jest - .spyOn(RPCHandler.prototype, "getFirstAvailableRpcProvider") - .mockResolvedValue(new JsonRpcProvider({ url: "https://fastethrpc.com", skipFetchSetup: true }, Number(1))); - jest.spyOn(JsonRpcProvider.prototype, "resolveName").mockResolvedValue("0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd"); - const spy = jest.spyOn(Logs.prototype, "ok"); await plugin( { diff --git a/yarn.lock b/yarn.lock index 84cf006..c0e175d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1357,7 +1357,7 @@ dependencies: "@ethersproject/logger" "^5.7.0" -"@ethersproject/providers@5.7.2", "@ethersproject/providers@^5.7.2": +"@ethersproject/providers@5.7.2": version "5.7.2" resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.7.2.tgz#f8b1a4f275d7ce58cf0a2eec222269a08beb18cb" integrity sha512-g34EWZ1WWAVgr4aptGlVBF8mhl3VWjv+8hoAnzStu8Ah22VHBsuGzP17eb6xDVRzw895G4W7vvx60lFFur/1Rg==