Skip to content

Commit

Permalink
Add solidity location for downstream test consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr committed Aug 8, 2024
1 parent 94d7c5b commit 6a705db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 68 deletions.
3 changes: 3 additions & 0 deletions integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,13 @@ pub async fn deploy_contracts() -> Address {

let location_a = "/althea_rs/solidity/contract-deployer.ts";
let location_b = "solidity/contract-deployer.ts";
let location_c = "/tmp/althea_rs/solidity/contract-deployer.ts";
let location = if std::path::Path::new(location_a).exists() {
location_a
} else if std::path::Path::new(location_b).exists() {
location_b
} else if std::path::Path::new(location_c).exists() {
location_c
} else {
panic!("Could not find contract deployer file!")
};
Expand Down
73 changes: 5 additions & 68 deletions solidity/contract-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,92 +46,29 @@ async function deploy() {
await sleep(1000);
}

console.log("Test mode, deploying ERC20 contracts");

// this handles several possible locations for the ERC20 artifacts
// var erc20_a_path: string
// var erc20_b_path: string
// var erc20_c_path: string
// var erc721_a_path: string
var althea_db_path: string
// const main_location_a = "/althea_rs/solidity/artifacts/contracts/TestERC20A.sol/TestERC20A.json"
// const main_location_b = "/althea_rs/solidity/artifacts/contracts/TestERC20B.sol/TestERC20B.json"
// const main_location_c = "/althea_rs/solidity/artifacts/contracts/TestERC20C.sol/TestERC20C.json"
// const main_location_721_a = "/althea_rs/solidity/artifacts/contracts/TestERC721A.sol/TestERC721A.json"
const main_location_altheadb = "/althea_rs/solidity/artifacts/contracts/AltheaDB.sol/AltheaDB.json"

const alt_location_1_altheadb = "solidity/artifacts/contracts/AltheaDB.sol/AltheaDB.json"

// const alt_location_2_a = "TestERC20A.json"
// const alt_location_2_b = "TestERC20B.json"
// const alt_location_2_c = "TestERC20C.json"
// const alt_location_2_721a = "TestERC721A.json"
const alt_location_2_altheadb = "AltheaDB.json"

const alt_location_3_altheadb = "/tmp/althea_rs/solidity/artifacts/contracts/AltheaDB.sol/AltheaDB.json"


if (fs.existsSync(main_location_altheadb)) {
// erc20_a_path = main_location_a
// erc20_b_path = main_location_b
// erc20_c_path = main_location_c
// erc721_a_path = main_location_721_a
althea_db_path = main_location_altheadb
} else if (fs.existsSync(alt_location_1_altheadb)) {
// erc20_a_path = alt_location_1_a
// erc20_b_path = alt_location_1_b
// erc20_c_path = alt_location_1_c
// erc721_a_path = alt_location_1_721a
althea_db_path = alt_location_1_altheadb
} else if (fs.existsSync(alt_location_2_altheadb)) {
// erc20_a_path = alt_location_2_a
// erc20_b_path = alt_location_2_b
// erc20_c_path = alt_location_2_c
// erc721_a_path = alt_location_2_721a
althea_db_path = alt_location_2_altheadb
} else if (fs.existsSync(alt_location_3_altheadb)) {
althea_db_path = alt_location_3_altheadb
} else {
console.log("Test mode was enabled but the ERC20 contracts can't be found!")
console.log("contracts can't be found!")
exit(1)
}

// Finally the source for each contract is known
// The bytecode can be deployed to the chain via ContractFactory and
// with the contract ABI JavaScript functions can be generated to interact with the contracts

// To deploy a new contract here first run `npm run typechain` and then locate the
// TypeScript type declaration file in typechain/ for your contract, the goal being to deploy the contract
// and cast it to the generated Class in that <contract>.d.ts file

// Read ABI (blockchain API) and bytecode from disk
// const { abi, bytecode } = getContractArtifacts(erc20_a_path);
// // Create a contract deployer factory
// const erc20Factory = new ethers.ContractFactory(abi, bytecode, wallet);
// // Deploy the contract and cast to the typechain generated class
// const testERC20 = (await erc20Factory.deploy(overrides)) as TestERC20A;
// await testERC20.deployed(); // Wait
// const erc20TestAddress = testERC20.address;
// console.log("ERC20 deployed at Address - ", erc20TestAddress);
// Now testERC20 is ready to use, e.g.testERC20.transfer(from, to, amount)

// const { abi: abi1, bytecode: bytecode1 } = getContractArtifacts(erc20_b_path);
// const erc20Factory1 = new ethers.ContractFactory(abi1, bytecode1, wallet);
// const testERC201 = (await erc20Factory1.deploy(overrides)) as TestERC20B;
// await testERC201.deployed();
// const erc20TestAddress1 = testERC201.address;
// console.log("ERC20 deployed at Address - ", erc20TestAddress1);

// const { abi: abi2, bytecode: bytecode2 } = getContractArtifacts(erc20_c_path);
// const erc20Factory2 = new ethers.ContractFactory(abi2, bytecode2, wallet);
// const testERC202 = (await erc20Factory2.deploy(overrides)) as TestERC20C;
// await testERC202.deployed();
// const erc20TestAddress2 = testERC202.address;
// console.log("ERC20 deployed at Address - ", erc20TestAddress2);

// const { abi: abi3, bytecode: bytecode3 } = getContractArtifacts(erc721_a_path);
// const erc721Factory1 = new ethers.ContractFactory(abi3, bytecode3, wallet);
// const testERC721 = (await erc721Factory1.deploy(overrides)) as TestERC721A;
// await testERC721.deployed();
// const erc721TestAddress = testERC721.address;
// console.log("ERC721 deployed at Address - ", erc721TestAddress);

const { abi: abi4, bytecode: bytecode4 } = getContractArtifacts(althea_db_path);
const altheadbFactory1 = new ethers.ContractFactory(abi4, bytecode4, wallet);
const testAltheaDB = (await altheadbFactory1.deploy(overrides)) as AltheaDB;
Expand Down

0 comments on commit 6a705db

Please sign in to comment.