TypeError: Invalid URL : while deploying smart contract i am getting this error - typeerror

C:\Users\hp\twitter_clone\server>npx hardhat run scripts/deploy.js --network rinkeby
npm WARN config global --global, --local are deprecated. Use --location=global instead.
TypeError: Invalid URL
at new NodeError (node:internal/errors:372:5)
at URL.onParseError (node:internal/url:553:9)
at new URL (node:internal/url:629:5)
at new HttpProvider (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\core\providers\http.ts:51:17)
at createProvider (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\core\providers\construction.ts:118:23)
at C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\core\runtime-environment.ts:82:28
at getRealTarget (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\util\lazy.ts:112:22)
at Object.get (C:\Users\hp\twitter_clone\server\node_modules\hardhat\src\internal\util\lazy.ts:185:26)
at createProviderProxy (C:\Users\hp\twitter_clone\server\node_modules#nomiclabs\hardhat-ethers\src\internal\provider-proxy.ts:25:19)
at C:\Users\hp\twitter_clone\server\node_modules#nomiclabs\hardhat-ethers\src\internal\index.ts:35:27 {
input: 'gGu01voSv52VJ6Ps9hYdffxEdgmCh-_BB',
code: 'ERR_INVALID_URL'
}

I encountered the same issue and after googling around, this post combined with yours gave me some hint that the createProvider is trying to get all of the necessary information to interact with the chain. Then I checked all of the variables defined in .env and see if any of them are missing. For me, the private key was missing. For yours, it might be caused by the API key invalid. You need the following info to make it work.
URL: from alchemy or whatever service you are using
API_KEY: same as above
PRIVATE_KEY: your wallet private key

Related

Deploy warning calling external JS function in `serverless.yml`

So, in my serverless.yml file I have this:
custom:
my_attr: ${file(./serverless/get-custom-value.js):my_attr}
And in that file (located in ./serverless/get-custom-value.js) is this JavaScript code:
module.exports.my_attr = async function(slsArg) {
const stage = slsArg.providers.aws.getStage()
console.debug(`### stage: "${stage}".`)
return stage
}
When doing a sls package -s {stage} or sls deploy -s {stage} (which are both successful), I see this warning:
Serverless: Deprecation warning: Variables resolver reports following resolution errors:
- Cannot resolve variable at "custom.my_attr": Cannot resolve "my_attr" out of "get-custom-value.js": Resolved a JS function not confirmed to work with a new parser, falling back to old resolver
Yet, despite the warning it works exactly as expected…
It's a deprecation warning, which serves to inform you that in the next version of the Serverless Framework, this specific resolver syntax is deprecated (and will error) as internally the process for resolving variables has changed.
You can adopt the new custom resolver very simply by changing the declaration in the serverless.yml and modifying the function arguments in get-custom-value.js, then you can set
variablesResolutionMode: 20210326
in your serverless.yml to indicate you have migrated. That will instruct the Serverless Framework to use the new resolver, as indicated by the warning message.
The full overview is in the documentation

Error Connecting to Substrate: Unable to initialize the API: createType(StorageKey):: Derived

I've got a Substrate node running locally on my PC, following this tutorial. https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/interact. It can be viewed on two ports:
Local: http://localhost:8000/substrate-front-end-template
On Your Network: http://192.168.56.1:8000/substrate-front-end-template
So I don't think connectivity is the issue.
Anyway, I bound the #polkadot/api to my node via the command:
yarn add #polkadot/api.
I'm now getting an error, in the browser, whenever I run my node:
Error Connecting to Substrate
Error: FATAL: Unable to initialize the API: createType(StorageKey):: Derived TypedArray constructor created an array which was too small
Can anyone help?
Upgrading to the latest Substrate Sidecar API resolved these issues for me.

Verdaccio No Package Published Yet

From today verdaccio (v3.8.3) stopped showing packages in local registry.
Opening on browser this message is shown: No Package Published Yet
The storage folder specified in configuration (~/.local/share/verdaccio/storage) contains all my packages.
But database file is empty ~/.local/share/verdaccio/storage/.sinopia-db.json.
Indeed running verdaccio from terminal I get this:
warn --- config file - /home/bssadmin/.config/verdaccio/config.yaml
error--- Package database file corrupted (invalid JSON), please check the error printed below.
File Path: /home/bssadmin/.local/share/verdaccio/storage/.sinopia-db.json SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at LocalDatabase._parseDatabase (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/node_modules/#verdaccio/local-storage/lib/local-database.js:298:19)
at LocalDatabase._fetchLocalPackages (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/node_modules/#verdaccio/local-storage/lib/local-database.js:272:23)
at new LocalDatabase (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/node_modules/#verdaccio/local-storage/lib/local-database.js:49:22)
at LocalStorage._loadStorage (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/lib/local-storage.js:809:14)
at new LocalStorage (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/lib/local-storage.js:54:27)
at Storage.init (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/lib/storage.js:64:25)
at /home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/api/index.js:145:19
at Generator.next (<anonymous>)
at step (/home/bssadmin/.npm-packages/lib/node_modules/verdaccio/build/api/index.js:53:191)
error--- Database is locked, please check error message printed during startup to prevent data loss.
(node:9242) ExperimentalWarning: The fs.promises API is experimental
error--- Database is locked, please check error message printed during startup to prevent data loss.
warn --- Plugin successfully loaded: htpasswd
warn --- Plugin successfully loaded: audit
warn --- http address - http://0.0.0.0:4873/ - verdaccio/3.8.3
What's happened? How can I resolve?
I should tag this question with 'verdaccio' tag but is not available and I can't create it.
If the .sinopia-db.json. is empty, pretty likely was corrupted. If there were any private packages you might need to fix it manually.
The format is pretty simple
{"list":["#test/test_1","#test/test_2","#test/test_3","test_4"],"secret":"secretKEYLongString"}
This file must be a valid JSON format.
If in the other had, the database was empty, just let the list array empty, or remove the whole file, restart the server and Verdaccio will generate a new one.

Error while upgrading sensu puppet module: Invalid parameter prefetch on sensu_rabbitmq_config

I'm trying to upgrade the sensu-puppet module and im getting an error when i run puppet now: the error is:
Error: Could not retrieve catalog from remote server: Error 400 on
SERVER: Invalid parameter prefetch on Sensurabbitmqconfig[<(hostname
is here, removed for this post on ask puppet)>] at
/etc/puppet/environments/staging/modules/sensu/manifests/rabbitmq/config.pp:123
Warning: Not using cache on failed catalog Error: Could not retrieve
catalog; skipping run
I have no idea what's going wrong or how to fix it. I looked in the pathway at the rabbitmq config and found this:
prefetch => $sensu::rabbitmq_prefetch
But I'm not sure what the issue is. Anyone know what might be causing this?
Where did you get the puppet module and what way?
Did you use puppet module install or a git pull?
Make sure sure that the parameter you want to use is in
modules/sensu/lib/puppet/provider/sensu_rabbitmq_config/json.rb
and also
modules/sensu/lib/puppet/type/sensu_rabbitmq_config.rb

Express.js using passport-facebook - TypeError: Object 302 has no method 'indexOf'

I've got an express project already running, I'm just trying to hook it up using passport to authenticate through facebook, I've basically copied the example from the github page here:
https://github.com/jaredhanson/passport-facebook
But I'm getting the following error whenever I try to go to the '/auth/facebook' URL in my app:
TypeError: Object 302 has no method 'indexOf'
at ServerResponse.res.redirect (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/response.js:546:13)
at Strategy.strategy.redirect (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:294:15)
at Strategy.OAuth2Strategy.authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport-facebook/node_modules/passport-oauth2/lib/strategy.js:227:10)
at Strategy.authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport-facebook/lib/strategy.js:84:41)
at attempt (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:337:16)
at authenticate (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/passport/lib/middleware/authenticate.js:338:7)
at callbacks (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:171:11)
at param (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:145:11)
at pass (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:152:5)
at Router._dispatch (/Users/jlawrence/Documents/Websites/Node/Gigster/node_modules/express/lib/router/index.js:179:5)
It could be an incompatibility with older versions of express; you might try updating to express#3.5.x; 3.6 and above deprecated some methods and the refactor might not be worth it.
Try npm install express#3.5.x, or npm install express#3.5.x -g if it's a global package. Make sure to update the package.json file too.