hashgraph / hedera-hardhat-hethers Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED Hardhat plugin for integration with hethers.js.
License: Apache License 2.0
DEPRECATED Hardhat plugin for integration with hethers.js.
License: Apache License 2.0
As a user I want to be able to assert that certain events have been emitted in a certain transaction I am making.
await expect(smartContract.method(arg1, arg2, arg3)).to.emit(contract, "SomeEvent").withArgs(arg1, arg2, arg3);
Currently the snippet above does not work.
@hashgraph/[email protected]
has dependency @hashgraph/[email protected]
which in turn has dependency @hashgraph/[email protected]
, this causes a few issues which would be resolved with a new @hashgraph/hethers
release(X) that points to the latest SDK and then also another release for @hashgraph/hardhat-hethers
which points to the (X)
No response
Did not see this error until switching to hethers.
Can't seem to figure out what it's complaining about.
You will see this when running any command npx hardhat run ...
npx hardhat run ...
No response
testnet
Latest
macOS
The only allowed return type of the deployed contract is Contract
, however, the type of the deployed contract should also be allowed.
const ERC20Factory = await hre.hethers.getContractFactory("ERC20", accounts[0]);
// works fine
const erc20contract1: Contract = await ERC20Factory.deploy(`Token A`, `TOKENA`, 1_000_000);
// type error:
// Type 'Contract' is missing the following properties from type 'ERC20': DOMAIN_SEPARATOR, allowance, approve, balanceOf, and 11 more.
const erc20contract2: ERC20 = await ERC20Factory.deploy(`Token A`, `TOKENA`, 1_000_000);
hethers.ContractFactory.deploy
should allow for both hethers.Contract or type of Contract which is identical to the contract name.No response
previewnet
, testnet
, local
f.e). Example config:previewnet: {
accounts: [ ACCS_HERE ]
},
testnet: {
accounts: [ACCS_HERE ]
},
local: {
name: 'local',
consensusNodes: [
{
url: '127.0.0.1:50211',
nodeId: '0.0.3'
}
],
mirrorNodeUrl: '127.0.0.1:5551',
chainId: 0,
accounts: [
{
account: '0.0.1001',
privateKey: "0x7f109a9e3b0d8ecfba9cc23a3614433ce0fa7ddcc80f2a8f10b222179a5a80d6",
},
{
account: '0.0.1002',
privateKey: "0x6ec1f2e7d126a74a1d2ff9e1c5d90b92378c725e506651ff8bb8616a5c724628",
},
{
account: '0.0.1003',
privateKey: "0xb4d7f7e82f61d81c95985771b8abf518f9328d019c36849d4214b5f995d13814",
}
]
}
--network
tag is ignored and the network being used is always the one defined as defaultNetwork
in the hardhat.config
file.If defaultNetwork: 'previewnet',
is set in the hardhat.config
file, the scripts are always using the previewnet
network.
Excpectation
When running the script:
npx hardhat deploy --network local
I would expect that the used network is local
and not previewnet
In hardhat.config.ts
:
const config: HardhatUserConfig = {
defaultNetwork: "localHederaNetwork",
...,
namedAccounts: {
deployer: {
default: 0, // maps to account 0.0.1002
},
dev: {
default: 1, // maps to account 0.0.1003
},
},
hedera: {
...,
localHederaNetwork: {
...,
accounts: [
{
account: "0.0.1002",
privateKey: "0x7f109a9e3b0d8ecfba9cc23a3614433ce0fa7ddcc80f2a8f10b222179a5a80d6",
},
{
account: "0.0.1003",
privateKey: "0x6ec1f2e7d126a74a1d2ff9e1c5d90b92378c725e506651ff8bb8616a5c724628",
}
]
},
}
}
In script:
import {getNamedAccounts } from "hardhat";
const { deployer, dev } = await getNamedAccounts();
On getNamedAccounts()
fails with the following error stack trace:
TypeError: this.network.provider.send is not a function
at DeploymentsManager.getChainId (node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:51)
at DeploymentsManager.setupAccounts (node_modules/hardhat-deploy/src/DeploymentsManager.ts:1505:34)
at DeploymentsManager.getNamedAccounts (node_modules/hardhat-deploy/src/DeploymentsManager.ts:574:16)
at initialize (test/harness/ConstantProduct.ts:60:36)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Context.<anonymous> (test/Test.test.ts:10:5)
No response
BigNumber
variables cannot be passed to constructor params(and though untested possibly function params as well). number
variables work fine. The error that is thrown is:
Error: missing argument: in Contract constructor (count=2, expectedCount=3, code=MISSING_ARGUMENT, version=contracts/1.2.0)
const ERC20 = await hre.hethers.getContractFactory("ERC20Mock", accounts[0]);
// number works:
await ERC20.deploy(`Token A`, `TOKENA`, 1_000_000))
// BigNumber fails:
const supply = BigNumber.from(1_000_000).mul(BigNumber.from(10).pow(0));
await ERC20.deploy(`Token A`, `TOKENA`, supply))
// Using BigNumber.toString() works:
const supply = BigNumber.from(1_000_000).mul(BigNumber.from(10).pow(0)).toString();
await ERC20.deploy(`Token A`, `TOKENA`, supply))
No response
other
1.0.2
macOS
Upon running something like this errors in: TypeError: collectionImpl.waitForDeployment is not a function
import { hethers } from 'hardhat'
const main = async () => {
const CollectionImplV1 = await hethers.getContractFactory('CollectionImplV1')
const collectionImpl = await CollectionImplV1.deploy()
await collectionImpl.waitForDeployment()
console.log(`Collection Implementation: ${collectionImpl.target}`)
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})
npx hardhat run script/ScriptName.s.ts --network testnet
No response
testnet
Latest
macOS
We need to update the .github/workflows/nodejs.yml
workflow to use the ephemeral self-hosted runners which are now configured on this repository. Additionally, we should add a workflow dispatch trigger to improve ease of testing.
runs-on
specification to the following stanza:
runs-on: [self-hosted, hardhat, hethers, standard, ephemeral]
workflow_dispatch
trigger to the on
declarationv3
version:
actions/setup-node
actions/checkout
hardhat-deploy doesn't work with @hashgraph/hardhat-hethers
.
Attempting await deployments.fixtures()
results in the following error stack trace:
TypeError: this.network.provider.send is not a function
at DeploymentsManager.getChainId (node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:51)
at DeploymentsManager.loadDeployments (node_modules/hardhat-deploy/src/DeploymentsManager.ts:619:28)
at DeploymentsManager.runDeploy (node_modules/hardhat-deploy/src/DeploymentsManager.ts:998:16)
at Object.fixture (node_modules/hardhat-deploy/src/DeploymentsManager.ts:315:20)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async initialize (test/helpers.ts:40:3)
at async Context.<anonymous> (test/_/Contract.test.ts:10:5)
network
is set to env.network i.e. hre.network
. Potentially have hedera-hardhat-hethers
plugin load network: Network
into hre
with a compatible Provider
No response
The error with which a contract call reverts can be tested positively as follows:
import { expect } from "chai";
await expect(
contract.foo(-1)
).to.be.revertedWith("OUT_OF_RANGE");
If the contract reverts with another error an AssertionError
like the following is normally in hardhat:
AssertionError: Expected transaction to be reverted with OUT_OF_RANGE, but other exception was thrown: Error: VM Exception while processing transaction: reverted with custom error 'OutOfRange()'
The response from a contract call that reverted using @hashgraph/hardhat-hethers
does not have parity with the default hardhat functionality and instead throws the follows AssertionError:
AssertionError: Expected transaction to be reverted with OUT_OF_RANGE, but other exception was thrown: Error: receipt for transaction [email protected] contained error status CONTRACT_REVERT_EXECUTED (code=CONTRACT_REVERT_EXECUTED, version=providers/1.2.0)
hedera-hardhat-ethers
decode and handle CONTRACT_REVERT_EXECUTED
calls identically to hardhat-ethers
No response
deployed()
- it often hangsWhen defining value
as part of a contract call, the amount is denominated in hbars
however it should be in tinybars
Example code:
const depositTx = await WHBAR.deposit({value: hbarAmount, gasLimit: 150_000});
In this case hbarAmount
is in hbars
and not tinybars
There are errors when the plugin is installed in a typescript project: Property 'hethers' does not exist on type 'HardhatRuntimeEnvironment'.
Add the following license headers to all source files (example).
/*-
*
* Hedera Hardhat Hethers
*
* Copyright (C) 2022 - 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
The solidity-coverage plugin cannot be used simultaneously with @hashgraph/hardhat-hethers
.
Attempting to analyse code coverage with command npx hardhat coverage
throws the following error:
Error in plugin solidity-coverage: HardhatError: HH10: Error while loading Hardhat's configuration.
You or one of your plugins is trying to modify the userConfig.hedera.networks.localHederaNetwork.allowUnlimitedContractSize value from a config extender
HederaConfig
type to include all properties present in HardhatUserConfig
including the allowUnlimitedContractSize
property with identical defaults.No response
As a user I'd like to be able to set the property for max automatic token associations somewhere within the deploy() method of a contract.
Reference for max_automatic_token_associations:
This property is supported both for accounts and contracts, but the documentation is not yet updated so I am linking the cryptocreate page for reference instead.
This is where the property should be populated. I am referencing it as a starting point.
A hedera network configured in HardhatUserConfig.networks isn't functional presumably due to the lack of parity in the hedera-json-rpc-relay
with the standard ethereum json rpc.
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
const config: HardhatUserConfig = {
...,
defaultNetwork: "hedera",
networks: {
hedera: {
url: "http://127.0.0.1:7546",
chainId: 298,
accounts: [
// Alias ECDSA keys private keys
"0x105d050185ccb907fba04dd92d8de9e32c18305e097ab41dadda21489a211524",
"0x2e1d968b041d84dd120a5860cee60cd83f9374ef527ca86996317ada3d0d03e7",
"0x45a5a7108a18dd5013cf2d5857a28144beadc9c70b3bdbd914e38df4e804b8d8",
"0x6e9d61a325be3f6675cf8b7676c70e4a004d2308e3e182370a41f5653d52c6bd",
"0x0b58b1bd44469ac9f813b5aeaf6213ddaea26720f0b2f133d08b6f234130a64f",
"0x95eac372e0f0df3b43740fa780e62458b2d2cc32d6a440877f1cc2a9ad0c35cc",
"0x6c6e6727b40c8d4b616ab0d26af357af09337299f09c66704146e14236972106",
"0x5072e7aa1b03f531b4731a32a021f6a5d20d5ddc4e55acbb71ae202fc6f3a26d",
"0x60fe891f13824a2c1da20fb6a14e28fa353421191069ba6b6d09dd6c29b90eff",
"0xeae4e00ece872dd14fb6dc7a04f390563c7d69d16326f2a703ec8e0934060cc7",
],
},
}
...,
};
export default config;
Attempting to run a simple test fails on the first call to the json rpc relay i.e. deploy
:
import { expect } from "chai";
import { ethers } from 'hardhat';
describe("Greeter", function () {
it("Should return the new greeting once it's changed", async function () {
const signers = await ethers.getSigners();
const signer = signers[0];
const Greeter = await ethers.getContractFactory("Greeter", signer);
// fails here
const greeter = await Greeter.deploy("Hello, world!");
await greeter.deployed();
expect(await greeter.greet()).to.equal("Hello, world!");
const setGreetingTx = await greeter.setGreeting("Hola, mundo!");
// wait until the transaction is mined
await setGreetingTx.wait();
expect(await greeter.greet()).to.equal("Hola, mundo!");
});
});
Hardhat error stack trace:
ProviderError: Internal error
at HttpProvider.request (node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
at LocalAccountsProvider.request (node_modules/hardhat/src/internal/core/providers/accounts.ts:188:34)
at async EthersProviderWrapper.send (node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)
Greeter.sol:
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.9;
contract Greeter {
string private greeting;
constructor(string memory _greeting) {
greeting = _greeting;
}
function greet() public view returns (string memory) {
return greeting;
}
function setGreeting(string memory _greeting) public {
greeting = _greeting;
}
}
json-rpc-relay docker container logs:
[2022-08-29 08:42:13.714 +0000] INFO (rpc-server/50 on baafe97141e2): [GET]: /health/liveness 1 ms
[2022-08-29 08:42:13.958 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:13.958 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:13.960 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 1 ms
[2022-08-29 08:42:13.964 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:13.964 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:13.964 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 0 ms
[2022-08-29 08:42:13.971 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:13.971 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:13.971 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 0 ms
[2022-08-29 08:42:13.997 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_blockNumber
[2022-08-29 08:42:13.998 +0000] TRACE (relay-eth/50 on baafe97141e2): blockNumber()
[2022-08-29 08:42:14.024 +0000] DEBUG (rpc-server/50 on baafe97141e2): eth_chainId
[2022-08-29 08:42:14.024 +0000] TRACE (relay-eth/50 on baafe97141e2): chainId()
[2022-08-29 08:42:14.024 +0000] INFO (rpc-server/50 on baafe97141e2): [POST] eth_chainId: 200 0 ms
[2022-08-29 08:42:14.037 +0000] ERROR (mirror-node/50 on baafe97141e2): [GET] blocks?limit=1&order=desc 567 status
err: {
"type": "Error",
"message": "connect ECONNREFUSED 127.0.0.1:5551",
"stack":
Error: connect ECONNREFUSED 127.0.0.1:5551
at MirrorNodeClient.handleError (/home/node/app/packages/relay/dist/lib/clients/mirrorNodeClient.js:107:27)
at MirrorNodeClient.<anonymous> (/home/node/app/packages/relay/dist/lib/clients/mirrorNodeClient.js:95:22)
at Generator.throw (<anonymous>)
at rejected (/home/node/app/packages/relay/dist/lib/clients/mirrorNodeClient.js:25:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
}
[2022-08-29 08:42:14.042 +0000] ERROR (Internal error/50 on baafe97141e2): [POST] eth_blockNumber: -32603 45 ms
code: -32603
message: "Unknown error invoking RPC"
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.