Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const smockit = async (
spec: SmockSpec,
opts: SmockOptions = {}
): Promise => {
// Only support native hardhat runtime, haven't bothered to figure it out for anything else.
if (hre.network.name !== 'hardhat') {
throw new Error(
`[smock]: smock is only compatible with the "hardhat" network, got: ${hre.network.name}`
)
}
// Find the provider object. See comments for `findBaseHardhatProvider`
const provider = findBaseHardhatProvider(hre)
// Sometimes the VM hasn't been initialized by the time we get here, depending on what the user
// is doing with hardhat (e.g., sending a transaction before calling this function will
// initialize the vm). Initialize it here if it hasn't been already.
if ((provider as any)._node === undefined) {
await (provider as any)._init()
}
// Generate the contract object that we're going to attach our fancy functions to. Doing it this
// way is nice because it "feels" more like a contract (as long as you're using ethers).
const contract = new ethers.Contract(
export const smockit = async (
spec: SmockSpec,
opts: SmockOptions = {}
): Promise => {
// Only support native hardhat runtime, haven't bothered to figure it out for anything else.
if (hre.network.name !== 'hardhat') {
throw new Error(
`[smock]: smock is only compatible with the "hardhat" network, got: ${hre.network.name}`
)
}
// Find the provider object. See comments for `findBaseHardhatProvider`
const provider = findBaseHardhatProvider(hre)
// Sometimes the VM hasn't been initialized by the time we get here, depending on what the user
// is doing with hardhat (e.g., sending a transaction before calling this function will
// initialize the vm). Initialize it here if it hasn't been already.
if ((provider as any)._node === undefined) {
await (provider as any)._init()
}
// Generate the contract object that we're going to attach our fancy functions to. Doing it this