Imports for "#chainlink" and "#openzeppelinn" are broken - solidity

Whenever I try to do an import like the two demonstrated below, they are not recognized. I am using VSCode. Yes I have tried installing and uninstalling many times. If anybody knows why that would be EPIC. Thanks.
import "#chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "#openzeppelin/contracts/token/ERC721/ERC721Full.sol";

VSC Solidity extension can't read Brownie's remappings. I'm assuming that you're getting this error:
Source
"#chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"
not found: File import callback not supported
Source "#openzeppelin/contracts/token/ERC721/ERC721Full.sol" not
found: File import callback not supported
Make sure you set dependencies and remappings correctly in brownie-config.yaml:
dependencies:
- smartcontractkit/chainlink-brownie-contracts#0.2.1
- OpenZeppelin/openzeppelin-contracts#3.4.0
compiler:
solc:
remappings:
- '#chainlink=smartcontractkit/chainlink-brownie-contracts#0.2.1'
- '#openzeppelin=OpenZeppelin/openzeppelin-contracts#3.4.0'
Compile your contracts:
brownie compile
If compiled successfully, Brownie should have downloaded packages, you can confirm it by running
brownie pm list
Set remappings for VSCode Solidity extension (for example in ./vscode/settings.json).
"solidity.remappings": [
"#chainlink/=<PATH_TO_BROWNIE_STUFF>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#0.2.1",
"#openzeppelin/=<PATH_TO_BROWNIE_STUFF>/.brownie/packages/OpenZeppelin/openzeppelin-contracts#3.4.0",
]
Make sure that you got the versions (#x.x.x) right across all the config files.
If you're on Linux, <PATH_TO_BROWNIE_STUFF> would probably be your home directory (/home/jjreedv)

As of Feb 2022, the remappings code settings for VS Code have been updated to be OS specific.
Here's an example:
{
"solidity.remappingsUnix": [
"#chainlink-brownie-contracts/=/home/<USERNAME>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#0.4.1",
"#openzeppelin/=/home/<USERNAME>/.brownie/packages/OpenZeppelin/openzeppelin-contracts#4.6.0",
],
"solidity.remappingsWindows": [
"#openzeppelin/=C:/Users/<USERNAME>/.brownie/packages/OpenZeppelin/openzeppelin-contracts#4.6.0",
"#chainlink-brownie-contracts/=C:/Users/<USERNAME>/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#0.4.1",
],
Official README of project:
https://github.com/juanfranblanco/vscode-solidity#platform-specific-remappings

Related

Solidity, compiler version error incompatible

I know is a typical error but I don't know how to solve it. I have tried to add the compile version in the hardhat config file but it doesn't work.
Error HH606: The project cannot be compiled, see reasons below.
These files import other files that use a different and incompatible version of Solidity:
contracts/MarketOrder.sol (^0.8.8) imports #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
To learn more, run the command again with --verbose
Read about compiler configuration at https://hardhat.org/config
Without adding the 0.7.0:
Error HH606: The project cannot be compiled, see reasons below.
The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. Change the pragma or configure additional compiler versions in your hardhat config.
* #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
* #openzeppelin/contracts/math/SafeMath.sol (^0.7.0)
* #openzeppelin/contracts/token/ERC20/IERC20.sol (^0.7.0)
These files import other files that use a different and incompatible version of Solidity:
* contracts/MarketOrder.sol (^0.8.8) imports #openzeppelin/contracts/token/ERC20/ERC20.sol (^0.7.0)
These files and its dependencies cannot be compiled with your config. This can happen because they have incompatible Solidity pragmas, or don't match any of your configured Solidity compilers.
* #uniswap/v3-periphery/contracts/libraries/TransferHelper.sol
To learn more, run the command again with --verbose
Read about compiler configuration at https://hardhat.org/config
Inside the hardhat.config file you can add multiple compiler versions, find the snippet similar to and add the compiler version which is required.
solidity: {
compilers: [
{
version: "0.8.8",
},
{
version: "0.7.0",
},
],
}

trying to use tipsi-twitter in snack.expo.io?

I'm trying to use tipsi-twitter in snack.expo.io but I'm running into issues. I added the following item into package.json dependencies:
"tipsi-twitter": "*"
Expo then appeared to successfully install this package. In my App.js I included the following import:
import TwitterAuth from 'tipsi-twitter';
The import compiles successfully but when I put the following code after the imports:
TwitterAuth.init({
twitter_key: '<TWITTER_KEY>',
twitter_secret: '<TWITTER_SECRET>',
})
This returns an error of:
"Cannot read property 'init' of undefined"
But this appears to be the exact implementation in the Usage section of the tipsi-twitter github page:
https://github.com/tipsi/tipsi-twitter#usage
Any idea what the issue might be or how to debug? Am I possibly missing some type of configuration step or is it possible that expo.io doesn't support this package/scenario?

PixiJS for Haxe won't import - Type Not Found error in IntelliJ

I'm trying to run the most basic PixiJS for Haxe sample program, but IntelliJ gives a Type Not Found error.
The failing code:
package ;
import pixi.core.Application;
The error message:
Main.hx:3: characters 7-28 : Type not found : pixi.core.Application
I think the issue is PixiJS-specific, as when I follow the same install-and-import steps for other Haxe modules (eg flambe, flixel) they behave as expected. I've tried with both 4.7.1 and 4.5.5, and as both global and project-specific libraries (separately).
(I hybridized several screenshots to save space)
When running from the console, using:
> haxe -main Main -lib pixijs -js output.js
Everything seems to compile (running the compiled code results in a PIXI is not defined error which is a seperate issue).
UPDATE 1, how I'm adding the dependency:
After executing haxelib install pixijs, I follow these steps:
UDPATE 2, the config being run:
If you can't get it working in the dependencies section you could try adding the haxelibs pixijs externs src/ folder as an additional sources root in Project Structure -> Modules -> (module name) -> Sources. That's how it worked for me:

Elm "cannot find module"

I'm fairly new in Elm. It's interesting to see a functional language which allows you to develop front-end stuff. Now even if I am following the steps described here nicely, I still have problems with modules.
The code is
module Main where
import Html exposing ( Html )
import Signal
main : Signal Html.Html
main = Html.text "This should work."
|> Signal.constant
I have used elm-reactor -a='localhost' to be able to view my output. But I am getting an error, that module 'HTML' cannot be found:
I cannot find find module 'Html'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json
(note the double "find" hehe)
The fix suggestion didn't help me. Or it could be that I'm not understanding the use of the .json file correctly.
elm-package.json:
{
"version": "1.0.0",
"summary": "testing elm",
"license": "BSD3",
"source-directories": [
".",
"./bin/"
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "3.0.0 <= v < 4.0.0"
},
"elm-version": "0.16.0 <= v < 0.17.0"
}
Here is a screenshot of my file tree.
Maybe it behaves differently than how Haskell is threatening the modules.
How can I solve this - eh simple? - problem.
Or is my elm-package.json just configured incorrectly?
Update for Elm 0.17
In 0.17, the Html package has been moved to elm-lang/html. Run the following command from the terminal to install it:
elm package install elm-lang/html
You should also remove the evancz/elm-html package from elm-package.json because it no longer exists as of 0.17.
For more information about the upgrading from 0.16 to 0.17, please see the 0.17 announcement.
Original Answer for Elm 0.16
Your elm-package.json configuration is missing the evancz/elm-html package, which exposes Html. You can use elm's package manager to install dependencies rather than editing elm-package.json directly.
From the terminal, type the following:
elm package install evancz/elm-html
You will also be prompted to install a few other missing dependencies required by evancz/elm-html. Running this command will update your elm-package.json file as well as pull down the missing packages from the internet and install them in the standard elm-stuff/packages directory.
More info on the elm-package tool can be found here.
You can browse elm packages online at package.elm-lang.org. The sidebar has a Popular Packages section which contains the evancz/elm-html package mentioned here.

Py2Exe and MatPlotLib: Plot won't Appear

I have a working Python 2.6 code using matplotlib, and would like to get a working exe out of it. I am having problems getting this accomplished:
Initially I got an error for missing MSCVP90.dll, but I downloaded that and extracted the .dll to the working directory and that error went away.
I had some errors regarding a missing tkagg module, but I added that to the exceptions and edited the matplotlibrc file to default to WXAgg instead and that went away.
The exe runs normally, but at the end of the code it is supposed to display a plot, and it doesn't. The plot is the main goal of this program, so it would be good to have this.
Just running the python code brings the plot up just fine.
Can anyone offer any suggestions or insights?
Here's my setup.py:
from distutils.core import setup
import py2exe
import matplotlib
matplotlib.use('wxagg') # overrule configuration
import pylab
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['_gtkagg', '_tkagg', 'backend_tkagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Thanks in advance!
Alright, I used pyinstaller and reverted the matplotlibrc file back to its original state where TkAgg was the default and everything works on my computer, but when I try to run it on another computer the plot still does not appear...
I can use pyinstaller to compile an exe out of a very simple matplotlib code, like:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
show()
But when I take that exe to another computer, it does not work.
Has anyone else had a similar issue? Any ideas?
Thanks
If the executable runs in your computer but doesn't work in another computer, the most likely problem is the lack of one or more of the required dlls that py2exe doesn't pack because license problems.
Very often these dlls are
gdiplus.dll
msvcp90.dll
Look for them in the computer where the exe works and copy them to the failing computer.
If the exe still doesn't work, check for other dll's. Py2exe gives the list of binary dependencies:
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
OLEAUT32.dll - C:\Windows\system32\OLEAUT32.dll
USER32.dll - C:\Windows\system32\USER32.dll
gdiplus.dll - gdiplus.dll
SHELL32.dll - C:\Windows\system32\SHELL32.dll
ole32.dll - C:\Windows\system32\ole32.dll
RPCRT4.dll - C:\Windows\system32\RPCRT4.dll
WSOCK32.dll - C:\Windows\system32\WSOCK32.dll
WINMM.dll - C:\Windows\system32\WINMM.dll
ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
msvcrt.dll - C:\Windows\system32\msvcrt.dll
WS2_32.dll - C:\Windows\system32\WS2_32.dll
WINSPOOL.DRV - C:\Windows\system32\WINSPOOL.DRV
GDI32.dll - C:\Windows\system32\GDI32.dll
IMM32.dll - C:\Windows\system32\IMM32.dll
MSVCP90.dll - C:\Python26\programas\test\MSVCP90.dll
KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
ntdll.dll - C:\Windows\system32\ntdll.dll
COMCTL32.dll - C:\Windows\system32\COMCTL32.dll
COMDLG32.dll - C:\Windows\system32\COMDLG32.dll
VERSION.dll - C:\Windows\system32\VERSION.dll
C:\Python26\programas\test>
Finally, I succesfully got a functional matplotlib program executable with py2exe. I only needed to add an 'includes' to setup.py and set WXAgg as the backend in matplotlib.rc (with Tk I got the same problem you described...). For it to work, I had to set WXAgg in the original matplotlib.rc (in the matplotlib/mpl-data folder). This is the one py2exe imports (not the one in the user's matplotlib configuration directory). To be sure check the .rc file in your dist folder.
from distutils.core import setup
import py2exe
import matplotlib
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['Tkconstants','Tkinter', 'tcl'],
'includes': ['matplotlib.backends.backend_wxagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Today I lost one day of work with this, so...
The solution is to include "FileDialog" module explicity, because the "six" module uses it. Specifically, I solved my problem by including six, dateutil, FileDialog, matplotlib, pylab, matplotlib.backends.backend_tkagg and others.
Good Luck!