diff --git a/packages/api/Dockerfile b/packages/api/Dockerfile index 2dc91c236d..55c750f00a 100644 --- a/packages/api/Dockerfile +++ b/packages/api/Dockerfile @@ -38,5 +38,6 @@ ENV METRICS_PORT $METRICS_PORT EXPOSE $PORT $METRICS_PORT 9229 9230 USER node +WORKDIR /usr/src/app/packages/api -CMD [ "node", "packages/api/dist/main.js" ] +CMD [ "node", "dist/main.js" ] diff --git a/packages/app/src/components/contract/ContractInfoTab.vue b/packages/app/src/components/contract/ContractInfoTab.vue index 80a5a0eccc..fdf7c21a86 100644 --- a/packages/app/src/components/contract/ContractInfoTab.vue +++ b/packages/app/src/components/contract/ContractInfoTab.vue @@ -11,7 +11,10 @@
- {{ t("contract.abiInteraction.method.read.name") }} +
+ {{ t("contract.abiInteraction.method.read.name") }} + +
{ isRequestFailed.value = false; response.value = undefined; errorMessage.value = null; - const signer = new zkSyncSdk.Provider(context.currentNetwork.value.rpcUrl); + let signer: zkSyncSdk.Provider | zkSyncSdk.Signer = new zkSyncSdk.Provider(context.currentNetwork.value.rpcUrl); + if (walletAddress.value !== null) { + // If connected to a wallet, use the signer so 'msg.sender' is correctly populated downstream + signer = await getL2Signer(); + } const contract = new ethers.Contract(address, [abiFragment], signer!); const res = ( await contract[abiFragment.name](...Object.entries(params).map(([, inputValue]) => inputValue)).catch( diff --git a/packages/app/tests/composables/useContractInteraction.spec.ts b/packages/app/tests/composables/useContractInteraction.spec.ts index dcadd83679..d5449d5b4b 100644 --- a/packages/app/tests/composables/useContractInteraction.spec.ts +++ b/packages/app/tests/composables/useContractInteraction.spec.ts @@ -67,6 +67,27 @@ describe("useContractInteraction:", () => { expect(errorMessage.value).toEqual("An error occurred"); mock.mockRestore(); }); + it("uses Signer when wallet address is not null", async () => { + const mockGetL2Signer = vi.fn(async () => undefined); + const walletMock = useWalletMock({ + getL2Signer: mockGetL2Signer, + address: { value: "0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b" }, + }); + const { readFunction } = useContractInteraction(); + await readFunction("0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b", abiFragment, {}); + expect(mockGetL2Signer).toHaveBeenCalled(); + mockGetL2Signer.mockRestore(); + walletMock.mockRestore(); + }); + it("uses Provider when wallet address is null", async () => { + const mockGetL2Signer = vi.fn(async () => undefined); + const walletMock = useWalletMock({ getL2Signer: mockGetL2Signer }); + const { readFunction } = useContractInteraction(); + await readFunction("0x0cc725e6ba24e7db79f62f22a7994a8ee33adc1b", abiFragment, {}); + expect(mockGetL2Signer).not.toHaveBeenCalled(); + mockGetL2Signer.mockRestore(); + walletMock.mockRestore(); + }); }); describe("writeFunction:", () => { beforeEach(() => { diff --git a/packages/worker/Dockerfile b/packages/worker/Dockerfile index a519806e86..7f2e8b502e 100644 --- a/packages/worker/Dockerfile +++ b/packages/worker/Dockerfile @@ -38,5 +38,6 @@ ENV PORT $PORT EXPOSE $PORT 9229 9230 USER node +WORKDIR /usr/src/app/packages/worker -CMD [ "node", "packages/worker/dist/main.js" ] +CMD [ "node", "dist/main.js" ] diff --git a/scripts/setup-hyperchain-config.ts b/scripts/setup-hyperchain-config.ts index 6b5870a5da..45eccb8ef1 100644 --- a/scripts/setup-hyperchain-config.ts +++ b/scripts/setup-hyperchain-config.ts @@ -5,7 +5,7 @@ import * as dotenv from "dotenv"; import { parse as parseConnectionString } from "pg-connection-string"; const buildAppConfig = (zkSyncEnvs: { [key: string]: string }) => ({ - networks: { + networks: [{ apiUrl: "http://localhost:3020", verificationApiUrl: zkSyncEnvs.API_CONTRACT_VERIFICATION_URL || "", hostnames: ["localhost"], @@ -18,7 +18,7 @@ const buildAppConfig = (zkSyncEnvs: { [key: string]: string }) => ({ name: zkSyncEnvs.CHAIN_ETH_ZKSYNC_NETWORK || "", published: true, rpcUrl: zkSyncEnvs.API_WEB3_JSON_RPC_HTTP_URL || "", - } + }] }); const buildWorkerConfig = (zkSyncEnvs: { [key: string]: string }) => {