I'm having trouble using the openseas.js library. I'm trying to do a getAsset call on a random asset on openseas I found, but I keep getting
Error: DEPRECATED: Please use providerUtils.standardizeOrThrow() instead supportedProvider.send.toString(...).replaceAll is not a function
Full Error:
I'm currently on node v16.14.2.
How can I resolve this issue? I appreciate the help!
const Web3 = require("web3");
import { OpenSeaPort, Network } from "opensea-js";
import { OpenSeaAsset } from "opensea-js/lib/types";
// This example provider won't let you make transactions, only read-only calls:
const provider = new Web3.providers.HttpProvider("https://mainnet.infura.io");
const seaport = new OpenSeaPort(provider, {
networkName: Network.Main,
});
(async function main() {
try {
//random asset I found on OpenSea
const asset: OpenSeaAsset = await seaport.api.getAsset({
tokenAddress: "0x20ed6cdf9344b3a187063a3ff4d883b6b1947b81", // string
tokenId: 220, // string | number | null
});
console.log("Asset", asset);
} catch (e) {
console.log("ERROR", e);
}
});
"dependencies": {
"opensea-js": "^3.0.2",
"typescript": "^4.6.3",
"web3": "^1.7.3",
"web3-provider-engine": "^16.0.3"
}
First, check the obvious things—since I know these bite me from time to time—clear your node_modules and reinstall, make sure your package-lock.json matches the versions you expect from package.json, make sure you're not running from a previous build, etc...
My guess is that something in your project is importing/using old versions of some of the 0xProject libs. Run npm list --all and see which ones are imported.
Worst case: that error is coming from the isWeb3Provider function in the 0xProject/assert project -- grep -r in your node_modules for something calling isWeb3Provider. Hopefully that'll give a clue.
Related
When I run this command yarn hardhat deploy --tags fundme I'm getting this MockV3Aggregator error.
Error: ERROR processing /Users/mohameduzair/blockChain/JSweb3_2/fundMe_hardhat/deploy/01-deploy-fundMe.js:
Error: No deployment found for: MockV3Aggregator at Object.get (/Users/mohameduzair/blockChain/JSweb3_2/fundMe_hardhat/node_modules/hardhat-deploy/src/DeploymentsManager.ts:162:17)
01-deploy-fundMe.js deploy script
```module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
let ethUsdPriceFeedAddress
if (developmentChains.includes(network.name)) {
// if (chainId === 31337) {
const ethUsdAggregator = await deployments.get("MockV3Aggregator")
ethUsdPriceFeedAddress = ethUsdAggregator.address
} else {
ethUsdPriceFeedAddress = networkConfig[chainId]["ethUsdPriceFeed"]
}
const fundMe = await deploy("FundMe", {
from: deployer,
args: [ethUsdPriceFeedAddress],
log: true,
})
log(`FundMe deployed at ${fundMe.address}`)
log(`-------------------------!!!--------------------------`)
}
module.exports.tags = ["all", "fundme"]
```
MockV3Aggregator.sol contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
// pragma solidity >=0.6.6 <0.8.7;
import "#chainlink/contracts/src/v0.6/tests/MockV3Aggregator.sol";
I', new to the Blockchain technologies. I'm following a tutorial on Youtube. I've tried my best. still can not fix this.
What should I do now?
Thank you
This is Patrick's tutorial, and you need to first deploy the mock.
Please see here.
After spending 5 hours, I fixed the bug. It was an extra {curly brace} in my code and a deployment error.
If you are following Patrick's tutorial and getting this error then you are probably missing network.name in either of deploy files.
Instead of network.name you have typed only network
Instead of
module.exports.tags = ["all", "fundme"]
in 01-deploy-fundMe.js, use
module.exports.tags = ["all", "mocks"]
and then use command
yarn hardhat deploy --tags mocks
;)
TypeScript 2.4 added support for dynamic import() expressions, which allow us to asynchronously load and execute ECMAScript modules on demand.
Trying to dynamically import the localize but facing the issue with export
Module not found: Error: Package path ./locales is not exported from package ....\node_modules\#angular\common (see exports field in .....\node_modules\#angular\common\package.json)
I have the below code
let angularLocale = convertAbpLocaleToAngularLocale(abp.localization.currentLanguage.name);
import(`#angular/common/locales/${angularLocale}.js`)
.then(module => {
registerLocaleData(module.default);
NgxBootstrapDatePickerConfigService.registerNgxBootstrapDatePickerLocales().then(_ => {
resolve(true);
abp.ui.clearBusy();
});
}, reject);
Quite not sure how can I export this, it was working fine with angular 12.
I had the same problem that I fixed by modifying the import path adding 'node_modules/...'
original code:
import(`#angular/common/locales/${angularLocale}.js`)
fixed code
import(`/node_modules/#angular/common/locales/${angularLocale}.js`)
Adding a system didn't work
let angularLocale = convertAbpLocaleToAngularLocale(abp.localization.currentLanguage.name);
System.import(`#angular/common/locales/${angularLocale}.js`)
.then(module => {
registerLocaleData(module.default);
NgxBootstrapDatePickerConfigService.registerNgxBootstrapDatePickerLocales().then(_ => {
resolve(true);
abp.ui.clearBusy();
});
}, reject);
Reference - https://github.com/angular/angular/issues/20487
Update
We don't need to use System.import these days... I think that a dynamic ES import expression might be enough...
let angularLocale = convertAbpLocaleToAngularLocale(abp.localization.currentLanguage.name);
import(`#angular/common/locales/${angularLocale}.js`).then(module => registerLocaleData(module.default));
With the above code, I still face the exception. In that case, I was hitting angular/angular-cli#22154 - this is a webpack bug. https://github.com/angular/angular/issues/20487
https://github.com/angular/angular-cli/issues/22154
import(
/* webpackExclude: /\.d\.ts$/ */
/* webpackMode: "lazy-once" */
/* webpackChunkName: "i18n-extra" */
`#/../node_modules/#angular/common/locales/${angularLocale}.mjs`)
As mentioned in the https://github.com/angular/angular-cli/issues/22154 issue, you need to update the import path with /node_modules/#angular/common/locales/${locale}.mjs.
The below code works for me in my AspNetZero project after upgrading to angular version 13.
NOTE: Make sure to restart "ng serve" command after these changes for webpack to do its magic.
async function registerLocales(resolve: (value?: boolean | Promise<boolean>) => void, reject: any, spinnerService: NgxSpinnerService) {
if (shouldLoadLocale()) {
let angularLocale = convertAbpLocaleToAngularLocale(abp.localization.currentLanguage.name);
await import(`/node_modules/#angular/common/locales/${ angularLocale }.mjs`)
.then(module => {
registerLocaleData(module.default);
NgxBootstrapDatePickerConfigService.registerNgxBootstrapDatePickerLocales().then(_ => {
resolve(true);
spinnerService.hide();
});
}, reject);
} else {
NgxBootstrapDatePickerConfigService.registerNgxBootstrapDatePickerLocales().then(_ => {
resolve(true);
spinnerService.hide();
});
}
}
I need a little help to solve a problem in my project.
Scenario:
First: I have a SPA web site that is being developed in Vue.js.
Second: I also have a Web API spec in Swagger that I want to use to generate my client code in Javascript.
Lastly: I'm using swagger-codegen-cli.jar for that.
What I've done until now
1 - Download the last swagger-codegen-cli.jar stable version with javascript support:
curl http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.7/swagger-codegen-cli-2.4.7.jar -o swagger-codegen-cli.jar
2 - Generate the client code using:
java -jar swagger-codegen-cli.jar generate -i http://192.168.0.85:32839/api/swagger/v1/swagger.json -l javascript -o ./web_api_client/
3 - Add the generated module to my project:
"dependencies": {
// ...
"vue": "^2.6.10",
"vue-router": "^3.0.3",
"web_api_client": "file:./web_api_client"
},
4 - Execute npm install. Apparently, it's working fine.
5 - At this moment I faced the problem. For some reason, the module generated isn't loaded completely.
export default {
name: 'home',
components: {
HelloWorld
},
mounted() {
var WebApiClient = require("web_api_client");
var defaultClient = WebApiClient.ApiClient.instance;
var oauth2 = defaultClient.authentications["oauth2"];
oauth2.accessToken = "YOUR ACCESS TOKEN";
var apiInstance = new WebApiClient.VersaoApi();
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.apiVersaoGet(callback);
}
}
6 - The line var WebApiClient = require("web_api_client"); is working without any error, however, not working 100%. The instance of the module has been created but empty. For instance, WebApiClient.ApiClient is always undefined.
7 - I took a look at the generated code and I think the problem is related with the way the module is being loaded.
(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['ApiClient', 'api/VersaoApi'], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('./ApiClient'), require('./api/VersaoApi'));
}
}(function(ApiClient, VersaoApi) {
'use strict';
// ...
In this code, neither of ifs blocks are executed.
Has someone faced a problem like that?
Some advice?
Many thanks, folks.
Solution
After a while trying to fix the problem with require("web_api_client"); I decided to use ES6 instead ES5.
I found an option in swagger-codegen-cli.jar to generate the client code using ES6 as shown below:
java -jar swagger-codegen-cli.jar generate -i http://192.168.0.85:32839/api/swagger/v1/swagger.json -l javascript --additional-properties useES6=true -o ./web_api_client/
Using ES6 I was able to import the javascript module direct from the generated source as shown in the code below.
import WebApiClient from "./web_api_client/src/index";
let defaultClient = WebApiClient.ApiClient.instance;
defaultClient.basePath = 'http://192.168.0.85:32839';
// Configure OAuth2 access token for authorization: oauth2
let oauth2 = defaultClient.authentications["oauth2"];
oauth2.accessToken = "YOUR ACCESS TOKEN";
let apiInstance = new WebApiClient.VersaoApi();
apiInstance.apiVersaoGet((error, data, response) => {
if (error) {
console.error(error);
} else {
console.log("API called successfully. Returned data: " + data + response);
}
});
When I first ran the code I got an error because the module WebApiClient generated didn't have the keyword default in the export block.
Original generated code
export {
/**
* The ApiClient constructor.
* #property {module:ApiClient}
*/
ApiClient,
// ...
Alter changed
export default {
/**
* The ApiClient constructor.
* #property {module:ApiClient}
*/
ApiClient,
// ...
Now everything is working fine.
I am using the following minimal probot app and try to write Mocha unit tests for it.
Unfortunately, it results in the error below, which indicates that some of my setup for the private key or security tokens is not picked up.
I assume that the configuration with my .env file is correct since I do not get the same error when I start the probot via probot-run.js.
Are there any extra steps needed to configure probot when used with Mocha?
Any suggestions on why the use of the scheduler extension may result in such issue would be great.
Code and error below:
app.ts
import createScheduler from "probot-scheduler";
import { Application } from "probot";
export = (app: Application) => {
createScheduler(app, {
delay: !!process.env.DISABLE_DELAY, // delay is enabled on first run
interval: 24 * 60 * 60 * 1000 // 1 day
});
app.on("schedule.repository", async function (context) {
app.log.info("schedule.repository");
const result = await context.github.pullRequests.list({owner: "owner", repo: "test"});
app.log.info(result);
});
};
test.ts
import createApp from "../src/app";
import nock from "nock";
import { Probot } from "probot";
nock.disableNetConnect();
describe("my scenario", function() {
let probot: Probot;
beforeEach(function() {
probot = new Probot({});
const app = probot.load(createApp);
});
it("basic feature", async function() {
await probot.receive({name: "schedule.repository", payload: {action: "foo"}});
});
});
This unfortunately results in the following error:
Error: secretOrPrivateKey must have a value
at Object.module.exports [as sign] (node_modules/jsonwebtoken/sign.js:101:20)
at Application.app (node_modules/probot/lib/github-app.js:15:39)
at Application.<anonymous> (node_modules/probot/lib/application.js:260:72)
at step (node_modules/probot/lib/application.js:40:23)
at Object.next (node_modules/probot/lib/application.js:21:53)
Turns out that new Probot({}); as suggested in the documentation initializes the Probot object without any parameters (the given options object {} is empty after all).
To avoid the error, one can provide the information manually:
new Probot({
cert: "...",
secret: "...",
id: 12345
});
I'm trying to use sailsjs as a library for a project with specific node files that use models.
# /testfile.js
process.chdir(__dirname);
// Ensure a "sails" can be located:
(function() {
var sails;
try {
sails = require('sails');
} catch (e) {
console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
console.error('To do that, run `npm install sails`');
console.error('');
console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
console.error('but if it doesn\'t, the app will run with the global sails instead!');
return;
}
// Try to get `rc` dependency
var rc;
try {
rc = require('rc');
} catch (e0) {
try {
rc = require('sails/node_modules/rc');
} catch (e1) {
console.error('Could not find dependency: `rc`.');
console.error('Your `.sailsrc` file(s) will be ignored.');
console.error('To resolve this, run:');
console.error('npm install rc --save');
rc = function () { return {}; };
}
}
// Start server
sails.lift(rc('sails'));
var req = require('sails/lib/router/req');
var res = require('sails/lib/router/res');
while(!sails.isLifted)
{
}
console.log(sails);
sails.models.user.find({where: {email: 'test#test.com'}}, function (err, result) {
if(err) return res().send('Not found');
return res().send('Found')
});
})();
I don't want a server running but I want all the configuration options to be used. I've edited the globals.js file to expose models.
models: true
After a bit of wrestling, found that sails takes a bit to 'lift'. I'm using a timeout at the moment but will probably clean that bit up after I get more working.