์ฌ๋ณด์ธ์! ์ฐ๋ฆฌ๋ hardhat-deploy
๋ฅผ https://github.com/ethereum-optimism/contracts ์ ํตํฉํ๊ธฐ๋ฅผ ํฌ๋งํฉ๋๋ค hardhat-deploy
์ฌ์ฉ์ ๋ํ ์ฐจ๋จ์ ์๋์ง๋ง ์ฅ๊ธฐ์ ์ผ๋ก ํ์คํ ๋์์ด ๋ ๊ฒ์
๋๋ค. ์ด๊ฒ์ด ์ง๊ธ ๊ฐ๋ฅํ๊ฐ์? ๊ทธ๋ ์ง ์๋ค๋ฉด ์ด๊ฒ์ด ๋๊ด์ฃผ์ ํ์ด ๋์ธ ์ ์๋ ์ผ์
๋๊น?
์๋ ํ์ธ์ @smartcontracts์ ๋๋ค. ์ด๊ฒ์ ์ ๊ฐ ๊ผญ ๊ฐ๊ณ ์ถ์ ๊ธฐ๋ฅ์ ๋๋ค.
3๊ฐ์ง ์ต์ ์ ๋ณผ ์ ์์ต๋๋ค.
ํ ๊ฐ์ง ๊ฐ๋ฅ์ฑ์ hardhat-deploy-ethers
deployContract ๋ฉ์๋๋ฅผ ์ถ๊ฐํ์ฌ ethers ์๋ช
์๋ฅผ ์ ๋ฌํ ์ ์๋๋ก ํ๋ ๊ฒ์
๋๋ค(hardhat-deploy ์์ฒด์์ ์ด๋ฅผ ๋ชฉํ๋ก ํ๋ ์ด PR ์ฐธ์กฐ: https://github.com/wighawag/hardhat- ๋ฐฐํฌ/๋น๊ธฐ๊ธฐ/62). ๊ทธ๋ฌ๋ hardhat-deploy ์ฌ์ฉ์๋ก์ ์ด๊ฒ์ ์๋ช
์ ๋ฑ์ ์ธ์คํด์คํํด์ผ ํ๊ธฐ ๋๋ฌธ์ ๊ฐ์ฅ ์ฐ์ํ์ง ์์ต๋๋ค...
๋๋ ์ด๊ฒ์ด ์์ ๋ชจ ์์ค์์ ์ํ๋ ์ ์๊ณ ์์ ๋ชจ ๊ณต๊ธ์๋ฅผ ์ฌ์ ์ํ์ฌ ๊ฐ๋ฅํ ์๋ ์๊ธฐ๋ฅผ ๋ฐ๋์ต๋๋ค.
์ด๋ ๊ฒ ํ๋ฉด hardhat-deploy๋ฟ๋ง ์๋๋ผ ๋ค๋ฅธ ๋ชจ๋ ํ๋ฌ๊ทธ์ธ ๋ฐ ์ฌ์ฉ ์ฌ๋ก๋ ์ด์ ์ ์ป์ ์ ์์ต๋๋ค.
๊ทธ๋ ์ง ์์ผ๋ฉด hardhat-deploy์ ์ผ๋ถ๋ก ๋ง๋ค ์ ์์ต๋๋ค. ๋๋ ์ด๊ฒ์ด ์ด๋ป๊ฒ ๊ตฌ์ฑ๋๋์ง ์์๋ด์ผ๋ง ํ๋ค.
ํ์ฌ hardhat-deploy๋ฅผ ์ฌ์ฉํ๋ฉด ๊ณ์ ์ด๋ฆ์ ์ง์ ํ ์ ์์ผ๋ฉฐ ์ด๋ฌํ ๊ณ์ ์ ๋จ์ํ ๋ฌธ์์ด๋ก ๋ ์ฃผ์์
๋๋ค.
from
ํ๋์ ์๋ ๊ทธ๋๋ก ํด๋น ๋ฌธ์์ด์ ์ ๋ฌํฉ๋๋ค.
์ด๋ฅผ ์ผ๋์ ๋๊ณ from
ํ๋๋ฅผ ๋ฌธ์์ด์ด๋ ๊ฐ์ฒด๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ด ๊ฐ์ฅ ๊ฐ๋จํ ์ ์์ต๋๋ค. ๊ฐ์ฒด๋ ํ๋์จ์ด ์ง๊ฐ์ธ์ง ์ฌ๋ถ์ ๊ด๊ณ์์ด ์ต์
์ ์ง์ ํ ์ ์์ต๋๋ค.
๊ทธ๋ฌ๋ ์ด์์ ์ผ๋ก๋ ๋ช
๋ช
๋ ๊ณ์ ์ ํตํด ์ด๋ฅผ ๊ตฌ์ฑํ ์ ์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค. ๋ถํํ๋ ํ์ฌ์ ๋ช
๋ช
๊ณ์ ๊ตฌ์กฐ๋ ์ฝ์ง ์์ต๋๋ค. ํ ๊ฐ์ง ์์ด๋์ด๋ ์ฃผ์ ๋ฌธ์์ด ์์ " ledger://0x34fe4ff... "์ ๊ฐ์ ํ๋กํ ์ฝ ๋ฌธ์์ด์ ์ถ๊ฐํ๋ ๊ฒ์ด์์ต๋๋ค
๋งค์ฐ ํฅ๋ฏธ๋ก์ด. ๋์ ์ด๊ธฐ ๋ฐ์์ (์ด์์ ์ผ๋ก) ํ๋ฌ๊ทธ์ธ์ ์๋ช
์๊ฐ ์ผ๋ฐ ํ
์คํธ ๊ฐ์ธ ํค์ธ์ง ์๋๋ฉด ํ๋์จ์ด ์ง๊ฐ์ธ์ง ์ ๊ฒฝ ์ธ ํ์๊ฐ ์๋ค๋ ๊ฒ์
๋๋ค. ์๋ง๋ ์ฐ๋ฆฌ๋ hardhat ๋คํธ์ํฌ ๊ตฌ์ฑ์ accounts
ํ๋์ ํ๋์จ์ด ์ง๊ฐ ์ฐ๊ฒฐ์ ์ง์ ํ ์ ์๋ ๋ณ๋์ ํ๋ฌ๊ทธ์ธ์ ๋ง๋ค ์ ์์ต๋๋ค. ๊ทธ๋ฐ ๋ค์ LedgerSigner ๋ก ๋ณํํ ์ ์์ต๋๋ค(
const config = {
networks: {
goerli: {
accounts: [
{
platform: "ledger",
type: "hid",
path: "m/44'/60'/0'/0/0"
}
],
}
}
}
๋ค, ๊ทธ๊ฒ ์ ๊ฐ ์๊ฐํ๋ ์ต์ ์ ๋ฐฉ๋ฒ์ผ ๊ฒ์ ๋๋ค. ์ต๋ํ ๋ฎ์ ์์ค์ผ๋ก
๋ด๊ฐ ๋ณผ ์์๋ ํ ๊ฐ์ง ๋ฌธ์ ๋ ํ๋์จ์ด ์ง๊ฐ์ด ํ์ธ ์์ด ์ฃผ์๋ฅผ ๋ ธ์ถํ์ง ์์ผ๋ฏ๋ก ๊ณ์ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค๋ ๋ชจ๋ ํ๋ฌ๊ทธ์ธ, ๋๊ตฌ๊ฐ ์ง๊ฐ์์ ์ฌ์ฉ์ ์ ๋ ฅ์ ์์ฒญํ์ง๋ง ์ด์์ ์ด์ง ์๋ค๋ ๊ฒ์ ๋๋ค.
๋ฐ๋ผ์ ๊ณ์ ๊ฐ์ฒด๋ ์ฃผ์๋ฅผ ์ง์ ํด์ผ ํ๊ณ ์ค์ ๋ก ์ผ์นํ์ง ์์ผ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ฑฐ๋ ๋ญ๊ฐ
๋ฐ๋ผ์ ๊ณ์ ๊ฐ์ฒด๋ ์ฃผ์๋ฅผ ์ง์ ํด์ผ ํ๊ณ ์ค์ ๋ก ์ผ์นํ์ง ์์ผ๋ฉด ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ฑฐ๋ ๋ญ๊ฐ
์ ๋ ์ด๊ฒ์ด ์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค. ๋ด์ผ ์คํํด๋ณด๊ณ ์๋์ ์ผ๋ก ์ ๋ขฐํ ์ ์๋์ง ํ์ธํ๊ฒ ์ต๋๋ค.
๋ค๋ฅธ ๋ฌธ์ ์ ๋ํ ๋์์ ์ฐพ๊ณ ๊ณ์ญ๋๊น? ์ ๊ฐ ํ ์ ์๋ ๊ณณ์์ ๊ธฐ๊บผ์ด ๋์๋๋ฆฌ๊ฒ ์ต๋๋ค.
์ง๊ธ ๋น์ฅ์ ์๋์ง๋ง ๋๋ฝ๋ ๊ธฐ๋ฅ์ ๋ํด ๋ฃ๊ณ ์ถ์ต๋๋ค. ์์ผ๋ก ์ต์ ์ ๋ฐฉ๋ฒ์ ์ํด ์ด์ ๊ฐ์ด ๋ ผ์ํ ์ ์์ต๋๋ค. :)
๋๋ ์ง๊ธ ์ด๊ฒ์ ์คํํ๊ณ ์๋ค. ๋ถํํ๋ hardhat์ ๋ฎ์ ์์ค์์ ์ด๊ฒ์ ํ๋ ๊ฒ์ ๊ฝค ๋ง์ ์์
์
๋๋ค. ์ฌ์ด ์์ ํด๊ฒฐ์ฑ
์ hardhat-deploy
๊ฐ ์ฃผ์๊ฐ ์๋ deploy
์๋ช
์๋ฅผ ์ ๋ฌํ ์ ์๋๋ก ํ๋ ๊ฒ์
๋๋ค. ๊ทธ๊ฒ์ ๋ํด ์ด๋ป๊ฒ ์๊ฐํ์ธ์? ๊ทธ๊ฒ์ ์ฐ๋ฆฌ๊ฐ ๋ค์๊ณผ ๊ฐ์ ๋ผ์ธ์ ๋ฐ๋ผ ๋ฌด์ธ๊ฐ๋ฅผ ํ ์ ์๊ฒ ํด์ค ๊ฒ์
๋๋ค:
const signer = new LedgerSigner(hre.network.provider, 'default', hre.ethers.utils.defaultPath)
const result = await deploy('MyContract', {
from: signer,
args: [],
log: true,
})
์๋
ํ์ธ์ @smartcontracts , ์ฌ๊ธฐ์์ ๋ด ๋๋ต์ ํ์ธํ์ญ์์ค : https://github.com/wighawag/hardhat-deploy/pull/62
๊ธฐ๋ณธ์ ์ผ๋ก ๋๋ ethers ๋๋ API ์ธก์ ๋ค๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋
๋ฆฝ์ ์ผ๋ก hardhat-deploy๋ฅผ ์ ์งํ๊ณ ์ถ์ต๋๋ค.
ํ์ง๋ง ๋ด ๋ต์ฅ์์ ์ธ๊ธํ๋ฏ์ด hardhat-deploy-ethers
ํตํด ์ถ๊ฐํ ์ ์์ต๋๋ค. https://github.com/wighawag/hardhat-deploy-ethers
์ด๋ฐ ๊ฒ์ด ์ผ๋ง๋ ์๊ธํ๊ฐ์?
์๋ ํ์ธ์ @smartcontracts ์ต์ ๋ฒ์ (0.7.0-beta.51)์ ์์ฅ ์ง์์ ์ถ๊ฐํ์ต๋๋ค.
์์ฅ ์ง์์ด ๋ฒ๊ทธ๊ฐ ๋ง์ ๊ฒ ๊ฐ์์ ํ ์คํธํ ์ ์์ต๋๋ค(์ด์ ๊ด๋ จ์ด ์์ ์ ์์: https://github.com/ethers-io/ethers.js/issues/1203). ํ์ง๋ง ์๋ง๋ ๋น์ ์ ๋๋ณด๋ค ๋ ๋์ ๊ธฐํ๋ฅผ ๊ฐ์ง ๊ฒ์ ๋๋ค.
๋๋ ์ถ๊ฐํ๊ธฐ ๋งค์ฐ ์ฌ์ด ์ต์
3์ ์ฌ์ฉํ์ต๋๋ค. ๋น์ ์ ๊ธฐ๋ณธ์ ์ผ๋ก ๊ฐ์ ๊ฐ์ผ๋ก ๋ช
๋ช
๋ ๊ณ์ ์ ์ถ๊ฐ ledger://<address>
์ฌ๊ธฐ ์๋ฅผ ๋ค์ด, ์ฐธ์กฐ : https://github.com/wighawag/template-ethereum-contracts/blob/d7eee3fc00b7e6a347a5ef2cd7718998254f2401/hardhat.config.ts#L15
hardhat-deploy๋ ์ด๋ฅผ ์ฃผ์๋ก ๋ณํํ์ฌ ์ด ๋ช ๋ช ๋ ๊ณ์ ์ ์ฌ์ ํ ์ฃผ์๋ก ์ฐธ์กฐํ ์ ์์ง๋ง ๋ฐฐํ์์๋ ํด๋น ๊ณ์ ์ LedgerSigner์ ์ฐ๊ฒฐํฉ๋๋ค. ํ๋์จ์ด ์ง๊ฐ์ด ๊ฐ์ง๋๋ฉด ๋ก๊ทธ๋ ์ถ๊ฐํ์ต๋๋ค/.
hardhat์ฉ ํ๋ฌ๊ทธ์ธ์ด ๋ฎ์ ์์ค์์ ์ฒ๋ฆฌํ ์ ์์ ๋๊น์ง๋ ๋๋ถ๋ถ์ ์ฌ์ฉ ์ฌ๋ก์ ์ถฉ๋ถํฉ๋๋ค. ๋น์ ์ด ๋ฌด์จ ์๊ฐ์ํ๋์ง ์ ๊ฒ ์๋ ค์ฃผ์ธ์
์ด๊ฑด ๋๋ด์ค. ์ง๊ธ ํ ์คํธ ์ค์ ๋๋ค!
ํ๋์ ํธ๋์ญ์ ์์ ์๋ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์์ง๋ง ์ผ์ข ์ ์ถฉ๋์ด ๋ฐ์ํ์ต๋๋ค. ethers ์์ฅ ํจํค์ง๊ฐ ์ฝ๊ฐ ์์๋ ๊ฒ ๊ฐ์ต๋๋ค.
@wighawag ์์ฅ ์ง์์ด ๊ณง ์ ๊ณต๋๋ ๊ฒ์
diff --git a/node_modules/hardhat-deploy/dist/src/helpers.js b/node_modules/hardhat-deploy/dist/src/helpers.js
index 3b588fa..67dce8f 100644
--- a/node_modules/hardhat-deploy/dist/src/helpers.js
+++ b/node_modules/hardhat-deploy/dist/src/helpers.js
@@ -290,6 +290,10 @@ function addHelpers(deploymentManager, partialExtension, network, getArtifact, s
if (options.log || hardwareWallet) {
print(`: deployed at ${deployment.address} with ${receipt === null || receipt === void 0 ? void 0 : receipt.gasUsed} gas\n`);
}
+ if(hardwareWallet){
+ const __eth = await ethersSigner._eth
+ await __eth.transport.device.close()
+ }
return Object.assign(Object.assign({}, deployment), { address, newlyDeployed: true });
}
async function deterministic(name, options) {
@@ -396,7 +400,7 @@ function addHelpers(deploymentManager, partialExtension, network, getArtifact, s
transaction = await provider.getTransaction(deployment.transactionHash);
}
if (transaction) {
- const { ethersSigner } = await getOptionalFrom(options.from);
+ const { ethersSigner, hardwareWallet } = await getOptionalFrom(options.from);
const { artifact } = await getArtifactFromOptions(name, options);
const abi = artifact.abi;
const byteCode = linkLibraries(artifact, options.libraries);
@@ -421,9 +425,17 @@ function addHelpers(deploymentManager, partialExtension, network, getArtifact, s
' not specified in new transaction, cant compare');
}
if (transaction[field] !== newTransaction[field]) {
+ if(hardwareWallet){
+ const __eth = await ethersSigner._eth
+ await __eth.transport.device.close()
+ }
return { differences: true, address: deployment.address };
}
}
+ if(hardwareWallet){
+ const __eth = await ethersSigner._eth
+ await __eth.transport.device.close()
+ }
return { differences: false, address: deployment.address };
}
}
@wighawag ์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ์ผ๋ก ์์ ํ๋๋ก ์ฌ๋ฐ๋ฅธ ๋ฐฉํฅ์ผ๋ก ์๋ดํด ์ฃผ์๋ฉด PR์ ๋ณด๋ผ ์ ์์ต๋๋ค. ๋ด ์์ ์ฌํญ์ PR์ ํฌํจ๋์ง ์์ต๋๋ค.
@rokso ๊ฐ์ฌํฉ๋๋ค
ethers.js hardhware-wallet ํจํค์ง์ ํ๊ธฐ ๋ฒ์ ์ ์ด์จ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค.
@wighawag ๋ช
์์ ์ผ๋ก close
๋ฅผ ํธ์ถํด์ผ ํ๋ฏ๋ก ethers.js๊ฐ ์ด ๋ฌธ์ ๋ฅผ ์ด๋ป๊ฒ ๊ณ ์น ์ง ํ์คํ์ง ์์ต๋๋ค. ethers.js๋ close
๋ฉ์๋๋ฅผ ๋
ธ์ถํ์ฌ ๋์์ ์ค ์ ์์ต๋๋ค.
@rokso ๋ diff๋ฅผ๋ณด๊ณ ๋ชจ๋ ๋ฐฐํฌ ํ์ ๋ซ์ต๋๋ค.
ethers.js๋ tx ์์ค์์ ๋์ผํ ์์
์ ์ํํ ์ ์์ต๋๋ค.
@wighawag ์, ์๋ํ์ง๋ง ์ฌ์ฉ์๋ ๋ชจ๋ ํธ๋์ญ์ ์ ๋ํด ์ ์ฐ๊ฒฐ์ ์ด์ด์ผ ํฉ๋๋ค. ์ด ์๋ฃจ์ ์ ์ฐ๋ฆฌ๊ฐ ์๋ก์ด ์ฐ๊ฒฐ์ ์ด ๋ ์ฐ๋ฆฌ์ ๊ฒฝ์ฐ์ ํจ๊ณผ๊ฐ ์์ ๊ฒ์ ๋๋ค.
@smartcontracts ๊ฐ ์ ์ํ ์ด๊ธฐ ์๋ฃจ์ ์ด ๊ฐ์ฅ ์ฐ์ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
const config = {
networks: {
goerli: {
accounts: [
{
platform: "ledger",
type: "hid",
path: "m/44'/60'/0'/0/0"
}
],
}
}
}
hardhat์ ๋ฏธํด๊ฒฐ ๋ฌธ์ ๊ฐ ์์ต๋๊น? ์ด ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ์ดํด๋ณด๊ณ ์ถ์ต๋๋ค.
์ฌ๋ฌ๋ถ, ๊ทธ๋ฅ ์ด ์ํ๋ฅผ ํ์ธํ๊ณ ์ถ์์ต๋๋ค. ํด๊ฒฐ๋์๋์? ๊ตฌ์ฑ์ namedAccounts
๋ด์์ ' ledger://0x00000000000000addr00000 '์(๋ฅผ) ์ฌ์ฉํ๋ ์ค์ ์ ์๋ํ๋ ๋์ ๋ก์ปฌ์์ ์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: /bindings.js:126
err = new Error(
^
Error: Could not locate the bindings file. Tried:
.
ethers ํ๋์จ์ด ์ง๊ฐ ํจํค์ง๊ฐ ์์ง ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค๊ณ ์๊ฐํ์ง ์์ต๋๋ค. https://github.com/ethers-io/ethers.js/issues/1440#issuecomment -816554584
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@smartcontracts ๊ฐ ์ ์ํ ์ด๊ธฐ ์๋ฃจ์ ์ด ๊ฐ์ฅ ์ฐ์ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
hardhat์ ๋ฏธํด๊ฒฐ ๋ฌธ์ ๊ฐ ์์ต๋๊น? ์ด ๊ธฐ๋ฅ์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ์ดํด๋ณด๊ณ ์ถ์ต๋๋ค.