Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from LionelB5/add-tests
Test contract & mock LINK dependencies
- Loading branch information
Showing
15 changed files
with
33,637 additions
and
18,376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ typechain | |
typechain-types | ||
|
||
#Hardhat files | ||
cache | ||
artifacts | ||
cache | ||
deployments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.4.24; | ||
|
||
import "@chainlink/token/contracts/v0.4/LinkToken.sol"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.6.0; | ||
|
||
import "@chainlink/contracts/src/v0.6/tests/VRFCoordinatorMock.sol"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
|
||
const deployMocks: DeployFunction = async function ( | ||
hre: HardhatRuntimeEnvironment | ||
) { | ||
const { deployments, getNamedAccounts, getChainId } = hre; | ||
const { deploy, log } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const chainId = await getChainId(); | ||
|
||
// If this is to the local chain | ||
if (chainId === "31337") { | ||
log("Local network detected - Deploying mocks"); | ||
|
||
// Deploy LINK token to our local network | ||
const LinkToken = await deploy("LinkToken", { | ||
from: deployer, | ||
log: true, | ||
}); | ||
|
||
// Deploy a mock VRF Coordinator to our local network | ||
await deploy("VRFCoordinatorMock", { | ||
from: deployer, | ||
log: true, | ||
args: [LinkToken.address], | ||
}); | ||
|
||
log("Mocks deployed"); | ||
} | ||
}; | ||
export default deployMocks; | ||
deployMocks.tags = ["all", "mocks"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { Deployment } from "hardhat-deploy/dist/types"; | ||
import { networkConfig } from "../helper-hardhat-config"; | ||
|
||
const deployCryptoBooks: DeployFunction = async function ( | ||
hre: HardhatRuntimeEnvironment | ||
) { | ||
const { deployments, getNamedAccounts, getChainId } = hre; | ||
const { deploy, get } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
const chainId = await getChainId(); | ||
|
||
let linkTokenAddress: string | undefined; | ||
let vrfCoordinatorAddress: string | undefined; | ||
let LinkToken: Deployment; | ||
let VRFCoordinatorMock: Deployment; | ||
|
||
if (chainId === "31337") { | ||
LinkToken = await get("LinkToken"); | ||
VRFCoordinatorMock = await get("VRFCoordinatorMock"); | ||
linkTokenAddress = LinkToken.address; | ||
vrfCoordinatorAddress = VRFCoordinatorMock.address; | ||
} else { | ||
linkTokenAddress = networkConfig[chainId].linkToken; | ||
vrfCoordinatorAddress = networkConfig[chainId].vrfCoordinator; | ||
} | ||
|
||
const keyHash: string = networkConfig[chainId].keyHash; | ||
const chainlinkFee: string = networkConfig[chainId].chainlinkFee; | ||
await deploy("CryptoBooks", { | ||
from: deployer, | ||
args: [vrfCoordinatorAddress, linkTokenAddress, keyHash, chainlinkFee], | ||
log: true, | ||
}); | ||
}; | ||
export default deployCryptoBooks; | ||
deployCryptoBooks.tags = ["all", "books"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export interface networkConfigItem { | ||
name: string; | ||
chainlinkFee: string; | ||
keyHash: string; | ||
linkToken?: string; | ||
vrfCoordinator?: string; | ||
} | ||
|
||
export interface networkConfigInfo { | ||
[key: string]: networkConfigItem; | ||
} | ||
|
||
export const networkConfig: networkConfigInfo = { | ||
default: { | ||
name: "hardhat", | ||
chainlinkFee: "100000000000000000", | ||
keyHash: | ||
"0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4", | ||
}, | ||
31337: { | ||
name: "localhost", | ||
chainlinkFee: "100000000000000000", | ||
keyHash: | ||
"0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4", | ||
}, | ||
80001: { | ||
name: "polygon_testnet", | ||
linkToken: "0x326C977E6efc84E512bB9C30f76E30c160eD06FB", | ||
keyHash: | ||
"0x6e75b569a01ef56d18cab6a8e71e6600d6ce853834d4a5748b720d06f878b3a4", | ||
vrfCoordinator: "0x8C7382F9D8f56b33781fE506E897a4F1e2d17255", | ||
chainlinkFee: "100000000000000000", | ||
}, | ||
}; | ||
|
||
export const developmentChains = ["hardhat", "localhost"]; |
Oops, something went wrong.