diff --git a/contracts/TestCondition.sol b/contracts/TestCondition.sol new file mode 100644 index 0000000..59ec3bd --- /dev/null +++ b/contracts/TestCondition.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface StubIERC20 { + function transfer(address to, uint256 amount) external returns (bool); +} + +contract TestCondition { + + event Transfer(TransferInfo transferInfo, bytes data); + + struct TransferInfo { + StubIERC20 token; + address receiver; + uint256 amount; + } + + function transfer(TransferInfo calldata transferInfo, bytes calldata data) external { + emit Transfer(transferInfo, data); + } +} diff --git a/hardhat.config.ts b/hardhat.config.ts index 1823e77..f8dc7c8 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -32,7 +32,7 @@ module.exports = { settings: { optimizer: { enabled: true, - runs: 1000, + runs: 200, }, }, }, diff --git a/scripts/deploy/TestCondition.ts b/scripts/deploy/TestCondition.ts new file mode 100644 index 0000000..5412289 --- /dev/null +++ b/scripts/deploy/TestCondition.ts @@ -0,0 +1,21 @@ +import { ethers } from "hardhat" +import { getDeployer } from "../utils" + +async function main() { + const deployer = getDeployer() + + // Deploying TestCondition + console.log("Deploying TestCondition...") + const TestCondition = await ( + await ethers.getContractFactory("TestCondition", deployer) + ).deploy() + await TestCondition.deployTransaction.wait() + console.log(`TestCondition contract address: ${TestCondition.address}`) +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error) + process.exit(1) + }) diff --git a/scripts/testCondition/transfer.ts b/scripts/testCondition/transfer.ts new file mode 100644 index 0000000..b227d46 --- /dev/null +++ b/scripts/testCondition/transfer.ts @@ -0,0 +1,42 @@ +import { ethers } from "hardhat" +import { default as prompts } from "prompts" +import { getDeployer, testConditionAddr } from "../utils" + +async function main() { + const deployer = await getDeployer() + const TestCondition = await ethers.getContractAt("TestCondition", testConditionAddr) + + // const promptErrandParamResult = await prompts( + // { + // type: "number", + // name: "errandParam", + // message: "important param", + // }, + // { + // onCancel: async function () { + // console.log("Exit process") + // process.exit(0) + // }, + // }, + // ) + // const newErrandParam = promptErrandParamResult.errandParam + + const tx = await TestCondition.connect(deployer).transfer( + ["0x000000000000000000000000000000000000beef", "0x000000000000000000000000000000000000abcd", 10], + "0x1234" + ) + console.log(`transfer tx sent: ${tx.hash}`) + await tx.wait() + + // const paramStored = await TestCondition.callStatic.errandParam() + // if (paramStored != newErrandParam) { + // throw new Error(`Wrong errandParam: ${paramStored}`) + // } +} + +main() + .then(() => process.exit(0)) + .catch(error => { + console.error(error) + process.exit(1) + }) diff --git a/scripts/utils.ts b/scripts/utils.ts index a005c32..1112c28 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -108,4 +108,6 @@ export const upgradeProxyImplementationAddr = "0x1E0D76E9556a8089cdb382243610437 export const oneRoleAccessControlAddr = "0x4Ed59b1E11E1460f4Ff5c5ae2895d7bd7c93E713" -export const oneRoleAccessControlWithTimeLockAddr = "0x0d975AEB0ee9EFd0682A303987aF2018e2917189" \ No newline at end of file +export const oneRoleAccessControlWithTimeLockAddr = "0x0d975AEB0ee9EFd0682A303987aF2018e2917189" + +export const testConditionAddr = "0xddD10b48CE74a0640725b24775a3CE4EC7549A62" \ No newline at end of file