How can I import AggregatorV3Interface - import

I'm trying to import AggregatorV3 but the file is nowhere to be found here is my code;
I'm sorry in advance i'm still a beginner programmer.
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
import "#chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract Lottery {
address payable[] public players; //to keep track of all players, payable array
uint256 public usdEntryFee;
AggregatorV3Intefrace internal ethUsdPriceFeed;
constructor(address _priceFeedAddress) public {
usdEntryFree = 50 * (10**18);
ethUsdPriceFeed = AggregatorV3Interface(_priceFeedAddress); //we need to pass the address of aggv3 in constructor
}
function enter() public payable {
//payable since we want them to pay in eth
//50 $ minimum
players.push(msg.sender);
}
function getEntranceFee() public view returns (uint256) {}
function startLottery() public {}
function endLottery() public {}
}
here is my Yaml file:
dependencies:
- smartcontractkit/chainlink-brownie-contracts#1.1.1
compiler:
solc:
remappings:
- '#chainlink=smartcontractkit/chainlink-brownie-contracts#1.1.1'
here is the error:
(base) marc#Marcs-MacBook-Pro smartcontract-lottery % brownie compile
Brownie v1.17.2 - Python development framework for Ethereum
Compiling contracts...
Solc version: 0.8.11
Optimizer: Enabled Runs: 200
EVM Version: Istanbul
CompilerError: solc returned the following errors:
ParserError: Source "/Users/marc/.brownie/packages/smartcontractkit/chainlink-brownie-contracts#1.1.1/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol" not found: File not found.
--> contracts/Lottery.sol:4:1:
|
4 | import "#chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I tried changing
compiler:
solc:
remappings:
- '#chainlink=smartcontractkit/chainlink-brownie-contracts#1.1.1'
to #0.2.1
I also tried changing solidity version to a newer version and it's not working
Thanks in advance!

I solved it by doing:
npm install #chainlink/contracts --save
and in the yaml file doing:

I solved it by replacing
import "#chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
with
import "#chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
My mistake, cheers!

import "#chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
use v0.6 instead of v0.8

Hi I was also stuck in a similar problem. Make sure that the brownie-config.yaml file is not inside the test folder and is kept seperately. Hope this helps.
check the below image to see how I saved my brownie-config.yaml file

Related

Jest stranspiles code differently then ts-node

I can't make my code work when running the project normally and running in Jest.
Running the project requires this kind of imports for dayjs:
import * as dayjs from 'dayjs';
import * as utc from 'dayjs/plugin/utc';
import * as customParseFormat from 'dayjs/plugin/customParseFormat';
npm run dev (nodemon --exec ./node_modules/.bin/ts-node ./src/app.ts): No issues
Jest: TypeError: t is not a function
Running the Jest tests requires this kind of imports for dayjs:
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import customParseFormat from 'dayjs/plugin/customParseFormat';
npm run dev (nodemon --exec ./node_modules/.bin/ts-node ./src/app.ts):
dayjs.extend(utc);
^
TypeError: Cannot read property 'extend' of undefined`
Jest: Success!
So now it is impossible for me to write Tests. Why is it transpiled differntly?
In my case,
tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true
}
}
solved it.
I switched to ts-jest and it solved my problem. I was assuming that I could write JS tests to test the TS code but I suppose that is not possible.

how to use email logger packer in laravel?

I am using
juniorb2ss/laravel-email-logger
package in
Laravel 5.2
For email logging, i have read its documentation but there is not much about implementation.
I have install it but need suggestion to use. should i explicitly put message into db or this package will do on it self?
Package link is
https://github.com/juniorb2ss/laravel-email-logger
Thanks in advance
You should use
https://github.com/shvetsgroup/laravel-email-database-log
and for laravel 5.2 after installing please change in file:
Path :
vendor\shvetsgroup\laravel-email-database-log\src\ShvetsGroup\LaravelEmailDatabaseLog\LaravelEmailDatabaseLogServiceProvider.php
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
Replace public function boot() with public function boot(DispatcherContract $events)
Replace parent::boot(); with parent::boot($events);
and if don't want to use migrations please comment following line:
$this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');

How to use this module on my Ionic project?

I am just starting using Ionic framework recently. I have been trying to import this vcard module.
https://github.com/Heymdall/vcard
I am able to use it in normal javascript environment, but so far I am not able to use it in my .ts file.
What I have done are:
Adding the module using
npm install vcard-parser --save
npm install ajv#>=5.0.0 --save
Import it inside .ts file
import * as v from 'vcard-parser'
Then this is the result from console.log(v)
Object {}
proto
:
Object
constructor
:
function Object()
hasOwnProperty
:
function hasOwnProperty()
isPrototypeOf
:
function isPrototypeOf()
propertyIsEnumerable
:
function propertyIsEnumerable()
toLocaleString
:
function toLocaleString()
toString
:
function ()
valueOf
:
function valueOf()
defineGetter
:
function defineGetter()
defineSetter
:
function defineSetter()
lookupGetter
:
function lookupGetter()
lookupSetter
:
function lookupSetter()
get proto
:
function proto()
set proto
:
function proto()
I don't know how to use the module, such as calling function "parse" or "generate".
Could anybody please help me with an example please?
So their documentation on the install is not quite correct.
npm install vcard-parser
should change to
npm install vcard-parser --save
To save it to your package.json
I not 100% but it does not look like the code conforms to the component -> module pattern ( might be wrong here, just looks a bit different )
For most ionic/angular extentions/components you want to import it in your app.module.ts using the name declared in the package.json.
for example ionic-network would be
import { Network } from '#ionic-native/network';
Because in the package.json it is declared as a dependency as
"#ionic-native/network": "^4.1.0",
You can also import for a specific page and add it to the constructor.
Here is a post from the official documentation on installing 3rd party libraries
Based on how is vcard-parser tested, it should be like this:
declare var require: any;
var vCard = require('vcard-parser').vCard;
vCard.parse(raw);

Postgres PL/JAVA: java.lang.ClassNotFoundException error after loading JAR file in database

I am getting the java.lang.ClassNotFoundException: error inside Postgres when running a function that calls a JAR file I have loaded. I have installed and configured PL/JAVA (including the delivered examples) in my database and can run the examples to success. I am not attempting to load/install my first JAR, but I am doing something wrong.
My host controls the OS version: CentOS 6.8. Postgres is version 8.4.
I am attempting to install my own very simple java class, which is a derivative of the delivered example Parameters.addOne class. All my code is in /tmp. Here are the steps I've followed:
Doug.java:
package com.msmetric;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import java.util.logging.Logger;
public class Doug {
public static int addOne(int value) {
return value + 1;
}
}
Compile Doug.java using 'javac Doug.java' succeeds.
Create JAR file with Doug.class file in it using 'jar -cvf Doug.jar Doug.class. This works fine.
Now I load the JAR file into Postgres (public schema), change the classpath, create the function that calls the JAR, then attempt to run at psql prompt.
Run sqlj.install_jar from psql:
select sqlj.install_jar('file:/tmp/Doug.jar','Doug',false);
Set the classpath inside Postgres (from psql prompt postgres=#):
select sqlj.set_classpath('public','Doug');
Create the function that calls the JAR. This create function code is taken directly from the examples.ddr file that came with PL/JAVA. I simply changed org.postgres to com.msmetric.
create or replace function addone(int) returns int as 'com.msmetric.Doug.addOne(java.lang.Integer)' language java;
Now with the JAR loaded and function created, I attempt to run it. This function should simply add 1 to the number provided.
select addone(3);
Results:
ERROR: java.lang.ClassNotFoundException: com.msmetric.Doug
Thoughts?
I'm very sorry I didn't see your question sooner. Underneath all the exotic details (PostgreSQL, PL/Java, schemas, classpaths...), there's just a bit of basic Java going on here: if a jar file contains a class Doug.class in package com.msmetric, its path within the jar has to reflect that: it has to be com/msmetric/Doug.class. Otherwise, it won't be found.
You can set up that whole structure step by step:
javac Doug.java
mkdir com
mkdir com/msmetric
mv Doug.class com/msmetric/
jar -cvf Doug.jar com/msmetric/Doug.class
Or, you can let javac do more of the work for you:
mkdir classes
javac -d classes Doug.java
jar -cvf Doug.jar -C classes .
When you give javac a -ddirectory option, instead of just writing class files next to their .java sources, it will put them all in their proper places under the directory you named, and then you can just tell jar to change into that directory and slurp them all up (don't overlook the . at the end of that jar command).
Once you fix that, if you retry your original steps, you'll see that you now get a different error:
ERROR: Unable to find static method com.msmetric.Doug.addOne with signature (Ljava/lang/Integer;)I
That happens because you declared the function in Doug.java with int addOne(int value) (that is, taking a primitive int argument), but you declared it in SQL with returns int as 'com.msmetric.Doug.addOne(java.lang.Integer)' taking an Integer object.
Once you correct that:
create or replace function addone(int) returns int as 'com.msmetric.Doug.addOne(int)' language java;
you'll be able to see:
# select addone(3);
addone
--------
4
(1 row)
If you happen to see this belated answer, may I ask what version of PL/Java you are using? That's one detail you didn't mention. If it is older than 1.5.0, there are newer features that can help you out. For one, you can just annotate that function:
#Function
public static int addOne(int value) {
return value + 1;
}
and have javac spit out not only the Doug.class file but also a pljava.ddr file with your SQL function declaration already written correctly (no mixing up argument types!). There is a way to include that .ddr file into the jar you create so that you can just call sqlj.install_jar with the last parameter true so it runs the commands in the .ddr and your functions are ready to use. There's a Hello, world example in the docs that shows more of how it's done.
Cheers,
-Chap

Groovy Grape imports aren't resolved by Eclipse

groovy eclipse plugin version: 1.7.5.xx-20101020-1000-e36-release.
import com.jidesoft.swing.JideSplitButton
#Grab(group='com.jidesoft', module='jide-oss', version='[2.2.1,2.3.0)')
public class TestClassAnnotation {
public static String testMethod () {
return JideSplitButton.class.name
}
}
new TestClassAnnotation().testMethod()
the first line error: Groovy:unable to resolve class com.jidesoft.swing.JideSplitButton
it can run as groovy shell, but the error warning is bore
When I compile this in the editor, I get the same error as I do when I compile or run from the command line:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: com.jidesoft#jide-oss;[2.2.1,2.3.0): not found]
(and then a very long stack trace)
Is this what you are seeing?
I'm rather late to this question, but I wonder if
#Grab(group='com.jidesoft', module='jide-oss', version='[2.2.1,2.3.0)')
shouldn't be
#Grab(group='com.jidesoft', module='jide-oss', version='[2.2.1,2.3.0]')
It looks to me like a syntax error where groovy expects to be passed a list.
Try placing #Grab right above the import statement. Just like that:
#Grab(group='com.jidesoft', module='jide-oss',version='[2.2.1,2.3.0]')
import com.jidesoft.swing.JideSplitButton
... your code continues here