You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
Contracts using the @chainlink dependency are failing to compile using the ZKsync plugin on Remix.
Steps to reproduce:
Paste the following code into a Receiver.sol file:
// SPDX-License-Identifier: MITpragma solidity0.8.26;
import {Client} from"@chainlink/[email protected]/src/v0.8/ccip/libraries/Client.sol";
import {CCIPReceiver} from"@chainlink/[email protected]/src/v0.8/ccip/applications/CCIPReceiver.sol";
/** * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY. * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. * DO NOT USE THIS CODE IN PRODUCTION. *//// @title - A simple contract for receiving string data across chains.contractReceiverisCCIPReceiver {
// Event emitted when a message is received from another chain.event MessageReceived(
bytes32indexedmessageId, // The unique ID of the message.uint64indexedsourceChainSelector, // The chain selector of the source chain.addresssender, // The address of the sender from the source chain.string text // The text that was received.
);
bytes32private s_lastReceivedMessageId; // Store the last received messageId.stringprivate s_lastReceivedText; // Store the last received text./// @notice Constructor initializes the contract with the router address./// @param router The address of the router contract.constructor(addressrouter) CCIPReceiver(router) {}
/// handle a received messagefunction _ccipReceive(
Client.Any2EVMMessage memoryany2EvmMessage
) internaloverride {
s_lastReceivedMessageId = any2EvmMessage.messageId; // fetch the messageId
s_lastReceivedText =abi.decode(any2EvmMessage.data, (string)); // abi-decoding of the sent textemitMessageReceived(
any2EvmMessage.messageId,
any2EvmMessage.sourceChainSelector, // fetch the source chain identifier (aka selector)abi.decode(any2EvmMessage.sender, (address)), // abi-decoding of the sender address,abi.decode(any2EvmMessage.data, (string))
);
}
/// @notice Fetches the details of the last received message./// @return messageId The ID of the last received message./// @return text The last received text.function getLastReceivedMessageDetails()
externalviewreturns (bytes32messageId, stringmemorytext)
{
return (s_lastReceivedMessageId, s_lastReceivedText);
}
}
Head to the ZKsync plugin tab and hit 'Compile Receiver.sol' or 'Compile project' (both fail for me).
This produces the following error:
Failed to compile:
Error HH411: The library @chainlink/[email protected], imported from docs.chain.link/contracts/CCIP/Receiver.sol, is not installed. Try installing it using npm.
HardhatError: HH411: The library @chainlink/[email protected], imported from docs.chain.link/contracts/CCIP/Receiver.sol, is not installed. Try installing it using npm.
at Resolver.resolveImport (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:254:15)
at async /opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:188:28
at async Promise.all (index 0)
at async DependencyGraph._addDependenciesFrom (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:186:5)
at async Promise.all (index 0)
at async Function.createFromResolvedFiles (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:15:5)
at async Environment._runTaskDefinition (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
at async Environment.run (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
at async SimpleTaskDefinition.action (/opt/app/api/hardhat_env/node_modules/hardhat/src/builtin-tasks/compile.ts:1389:58)
at async Environment._runTaskDefinition (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
Caused by: HardhatError: HH401: Library @chainlink/[email protected] is not installed.
at Resolver._resolveLibrarySourceName (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:322:15)
at Resolver.resolveSourceName (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:103:33)
at async Resolver.resolveImport (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:194:24)
at async /opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:188:28
at async Promise.all (index 0)
at async DependencyGraph._addDependenciesFrom (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:186:5)
at async Promise.all (index 0)
at async Function.createFromResolvedFiles (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:15:5)
at async Environment._runTaskDefinition (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/core/runtime-environment.ts:359:14)
at async Environment.run (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/core/runtime-environment.ts:192:14)
Caused by: Error: Cannot find module '@chainlink/[email protected]/package.json' from '/opt/app/api/hardhat_env/workspaces/b8b63a98-9fe3-4351-a9fe-6c1e727b508d'
at Function.resolveSync [as sync] (/opt/app/api/hardhat_env/node_modules/resolve/lib/sync.js:89:15)
at Resolver._resolveNodeModulesFileFromProjectRoot (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:457:20)
at Resolver._resolveLibrarySourceName (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:311:30)
at Resolver.resolveSourceName (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:103:33)
at async Resolver.resolveImport (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/resolver.ts:194:24)
at async /opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:188:28
at async Promise.all (index 0)
at async DependencyGraph._addDependenciesFrom (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:186:5)
at async Promise.all (index 0)
at async Function.createFromResolvedFiles (/opt/app/api/hardhat_env/node_modules/hardhat/src/internal/solidity/dependencyGraph.ts:15:5)
Additional Information
This issue does not seem to be isolated as Updraft users are getting the same error. See this issue for more details.
Additionally, I attempted to make a simple ERC20 contract using OpenZeppelin and this compiled fine.
The text was updated successfully, but these errors were encountered:
tl;dr is that currently plugin supports a limited set of dependencies (you can see them here). Given that plugin doesn't currently have a sandboxed environment, supporting any possible dependency is troublesome, as we cannot just allow to blindly install any npm package on the backend. However, what we can do short-term is to support a fixed set of popular libraries, if that works.
Thanks for the prompt response @popzxc
I have updated my code to use @chainlink/contracts however I need to use release v1.3.0 (the most recent release as v1.0.0 does not have CCIP)
Does the plugin use the exact version specified in the package.json file you shared? By semantic versioning, I assumed minor versions were also compatible. However, this still seemed to cause an issue for me and the user who posted an issue on the Cyfrin GitHub
@ciaranightingale Well, the npm workspace is built inside the dockerfile so the versions on the backend are static (e.g. they are not updated during compilation). So, yes, the plugin does use the exact version from package.json.
What we can do is to at least bump the version of @chainlink/contracts. However, right now we're transitioning the plugin from Nethermind to Matter Labs (here's the corresponding issue), so the update can only happen after the migration.
Contracts using the @chainlink dependency are failing to compile using the ZKsync plugin on Remix.
Steps to reproduce:
Receiver.sol
file:This produces the following error:
Additional Information
This issue does not seem to be isolated as Updraft users are getting the same error. See this issue for more details.
Additionally, I attempted to make a simple ERC20 contract using OpenZeppelin and this compiled fine.
The text was updated successfully, but these errors were encountered: