-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Truffle migrations verbosity and fixed invalid JSON rpc #416
Changes from 10 commits
48cc092
c67c6b2
a93b130
2474063
4c95899
748876c
061ef54
02b26b2
e0ff48d
b026df1
db5bfa7
fbf3c40
5968337
8d6c529
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ require('dotenv').config(); // auto parse env variables from '.env' file | |
|
||
const HDWalletProvider = require('@truffle/hdwallet-provider'); | ||
|
||
const infuraUrl = `${process.env.INFURA_URL || 'https://infura.io/v3/'}/${process.env.INFURA_API_KEY}`; | ||
const cleanInfuraUrl = infuraUrl.replace(/([^:])(\/\/+)/g, '$1/'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to keep the previous comment of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes actually keep the comment, it's definitely not obvious There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reminder: the comment is not added yet |
||
|
||
module.exports = { | ||
networks: { | ||
local: { | ||
|
@@ -31,22 +34,19 @@ module.exports = { | |
}, | ||
infura: { | ||
skipDryRun: true, | ||
provider: () => { | ||
const infuraUrl = `${process.env.INFURA_URL}/${process.env.INFURA_API_KEY}`; | ||
|
||
// Replace double '//' | ||
const cleanInfuraUrl = infuraUrl.replace(/([^:])(\/\/+)/g, '$1/'); | ||
|
||
return new HDWalletProvider( | ||
[ | ||
process.env.DEPLOYER_PRIVATEKEY, | ||
process.env.MAINTAINER_PRIVATEKEY, | ||
process.env.AUTHORITY_PRIVATEKEY, | ||
], | ||
cleanInfuraUrl, | ||
0, 3, | ||
); | ||
}, | ||
// Can't be a function otherwise it'll throw a JSON RPC error for some reason | ||
// https://github.com/trufflesuite/truffle/issues/852#issuecomment-522367001 | ||
// Using 0's as private key because it'll throw an error if the private keys | ||
// are undefined as this is instanciating a class.... | ||
provider: new HDWalletProvider( | ||
[ | ||
process.env.DEPLOYER_PRIVATEKEY || '0'.repeat(64), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really understand, why we would need empty 0s here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It fails on tests if the private keys are undefined since infuras wallet provider is not a function, but rather instanciates a class on runtime. This instantiation reads the keys and trys to derive it but immediately throws an error because the keys are undefined. To circumvent this I've made the default keys to be zeros |
||
process.env.MAINTAINER_PRIVATEKEY || '0'.repeat(64), | ||
process.env.AUTHORITY_PRIVATEKEY || '0'.repeat(64), | ||
], | ||
cleanInfuraUrl, | ||
0, 3, | ||
), | ||
network_id: '*', | ||
}, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, so you can deploy same contract multiple times by
deployer.deply()
just when you try to get it back bydeployed()
you will get the latest one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap you can, you save the instance in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also
<>.new()
deploys the contracts silently whereasdeployer.deploy(<>)
does it verbosely for some reason.....