diff --git a/.changeset/verify-status-apikey-quote.md b/.changeset/verify-status-apikey-quote.md new file mode 100644 index 00000000000..6e1644e90f7 --- /dev/null +++ b/.changeset/verify-status-apikey-quote.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +checkVerificationStatus sends the explorer API key without a trailing double quote diff --git a/packages/thirdweb/src/contract/verification/index.test.ts b/packages/thirdweb/src/contract/verification/index.test.ts new file mode 100644 index 00000000000..4a92bd366a1 --- /dev/null +++ b/packages/thirdweb/src/contract/verification/index.test.ts @@ -0,0 +1,39 @@ +import { HttpResponse, http } from "msw"; +import { setupServer } from "msw/node"; +import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest"; +import { checkVerificationStatus } from "./index.js"; + +const server = setupServer(); + +describe("checkVerificationStatus", () => { + beforeAll(() => server.listen({ onUnhandledRequest: "error" })); + afterAll(() => server.close()); + afterEach(() => server.resetHandlers()); + + it("sends the API key unchanged", async () => { + let apikey: string | null = null; + server.use( + http.get("https://api.etherscan.test/api", ({ request }) => { + apikey = new URL(request.url).searchParams.get("apikey"); + return HttpResponse.json({ + message: "OK", + result: "Pass - Verified", + status: "1", + }); + }), + ); + + const result = await checkVerificationStatus({ + explorerApiKey: "TEST_API_KEY", + explorerApiUrl: "https://api.etherscan.test/api", + guid: "test-guid", + }); + + expect(apikey).toBe("TEST_API_KEY"); + expect(result).toEqual({ + message: "OK", + result: "Pass - Verified", + status: "1", + }); + }, 10_000); +}); diff --git a/packages/thirdweb/src/contract/verification/index.ts b/packages/thirdweb/src/contract/verification/index.ts index d6ae811eca6..b41d8c42dcf 100644 --- a/packages/thirdweb/src/contract/verification/index.ts +++ b/packages/thirdweb/src/contract/verification/index.ts @@ -209,7 +209,7 @@ type CheckVerificationStatusOptions = { export async function checkVerificationStatus( options: CheckVerificationStatusOptions, ): Promise { - const endpoint = `${options.explorerApiUrl}?module=contract&action=checkverifystatus&guid=${options.guid}&apikey=${options.explorerApiKey}"`; + const endpoint = `${options.explorerApiUrl}?module=contract&action=checkverifystatus&guid=${options.guid}&apikey=${options.explorerApiKey}`; return new Promise((resolve, reject) => { const intervalId = setInterval(async () => { try {