mirror of
https://github.com/emo2007/block-accounting.git
synced 2025-02-22 21:26:27 +00:00
init hardhat
This commit is contained in:
parent
10537008b9
commit
2fefe16f61
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
12
.idea/block-accounting.iml
Normal file
12
.idea/block-accounting.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/block-accounting.iml" filepath="$PROJECT_DIR$/.idea/block-accounting.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
File diff suppressed because one or more lines are too long
4
artifacts/contracts/Lock.sol/Lock.dbg.json
Normal file
4
artifacts/contracts/Lock.sol/Lock.dbg.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/22662767f8b1a09e64d324318d70c2ac.json"
|
||||
}
|
74
artifacts/contracts/Lock.sol/Lock.json
Normal file
74
artifacts/contracts/Lock.sol/Lock.json
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Lock",
|
||||
"sourceName": "contracts/Lock.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_unlockTime",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "payable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "when",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Withdrawal",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address payable",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "unlockTime",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "withdraw",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x60806040526040516105d83803806105d8833981810160405281019061002591906100f0565b804210610067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161005e906101a0565b60405180910390fd5b8060008190555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101c0565b600080fd5b6000819050919050565b6100cd816100ba565b81146100d857600080fd5b50565b6000815190506100ea816100c4565b92915050565b600060208284031215610106576101056100b5565b5b6000610114848285016100db565b91505092915050565b600082825260208201905092915050565b7f556e6c6f636b2074696d652073686f756c6420626520696e207468652066757460008201527f7572650000000000000000000000000000000000000000000000000000000000602082015250565b600061018a60238361011d565b91506101958261012e565b604082019050919050565b600060208201905081810360008301526101b98161017d565b9050919050565b610409806101cf6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063251c1aa3146100465780633ccfd60b146100645780638da5cb5b1461006e575b600080fd5b61004e61008c565b60405161005b919061024a565b60405180910390f35b61006c610092565b005b61007661020b565b60405161008391906102a6565b60405180910390f35b60005481565b6000544210156100d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ce9061031e565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161015e9061038a565b60405180910390fd5b7fbf2ed60bd5b5965d685680c01195c9514e4382e28e3a5a2d2d5244bf59411b9347426040516101989291906103aa565b60405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610208573d6000803e3d6000fd5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000819050919050565b61024481610231565b82525050565b600060208201905061025f600083018461023b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061029082610265565b9050919050565b6102a081610285565b82525050565b60006020820190506102bb6000830184610297565b92915050565b600082825260208201905092915050565b7f596f752063616e27742077697468647261772079657400000000000000000000600082015250565b60006103086016836102c1565b9150610313826102d2565b602082019050919050565b60006020820190508181036000830152610337816102fb565b9050919050565b7f596f75206172656e277420746865206f776e6572000000000000000000000000600082015250565b60006103746014836102c1565b915061037f8261033e565b602082019050919050565b600060208201905081810360008301526103a381610367565b9050919050565b60006040820190506103bf600083018561023b565b6103cc602083018461023b565b939250505056fea264697066735822122022a2b65355af697b0725f7bcddf1c94be908ee67893e84bd3442d61fdc82585064736f6c63430008180033",
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063251c1aa3146100465780633ccfd60b146100645780638da5cb5b1461006e575b600080fd5b61004e61008c565b60405161005b919061024a565b60405180910390f35b61006c610092565b005b61007661020b565b60405161008391906102a6565b60405180910390f35b60005481565b6000544210156100d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ce9061031e565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161015e9061038a565b60405180910390fd5b7fbf2ed60bd5b5965d685680c01195c9514e4382e28e3a5a2d2d5244bf59411b9347426040516101989291906103aa565b60405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610208573d6000803e3d6000fd5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000819050919050565b61024481610231565b82525050565b600060208201905061025f600083018461023b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061029082610265565b9050919050565b6102a081610285565b82525050565b60006020820190506102bb6000830184610297565b92915050565b600082825260208201905092915050565b7f596f752063616e27742077697468647261772079657400000000000000000000600082015250565b60006103086016836102c1565b9150610313826102d2565b602082019050919050565b60006020820190508181036000830152610337816102fb565b9050919050565b7f596f75206172656e277420746865206f776e6572000000000000000000000000600082015250565b60006103746014836102c1565b915061037f8261033e565b602082019050919050565b600060208201905081810360008301526103a381610367565b9050919050565b60006040820190506103bf600083018561023b565b6103cc602083018461023b565b939250505056fea264697066735822122022a2b65355af697b0725f7bcddf1c94be908ee67893e84bd3442d61fdc82585064736f6c63430008180033",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
41
cache/solidity-files-cache.json
vendored
Normal file
41
cache/solidity-files-cache.json
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"_format": "hh-sol-cache-2",
|
||||
"files": {
|
||||
"/Users/nikitapoznyakov/Desktop/work/block-accounting/contracts/Lock.sol": {
|
||||
"lastModificationDate": 1714595956954,
|
||||
"contentHash": "dacf0d5cb5b45dc83086de5bc1c26c2c",
|
||||
"sourceName": "contracts/Lock.sol",
|
||||
"solcConfig": {
|
||||
"version": "0.8.24",
|
||||
"settings": {
|
||||
"evmVersion": "paris",
|
||||
"optimizer": {
|
||||
"enabled": false,
|
||||
"runs": 200
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": [
|
||||
"abi",
|
||||
"evm.bytecode",
|
||||
"evm.deployedBytecode",
|
||||
"evm.methodIdentifiers",
|
||||
"metadata"
|
||||
],
|
||||
"": [
|
||||
"ast"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"imports": [],
|
||||
"versionPragmas": [
|
||||
"^0.8.24"
|
||||
],
|
||||
"artifacts": [
|
||||
"Lock"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
17
contract/.gitignore
vendored
Normal file
17
contract/.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
node_modules
|
||||
.env
|
||||
|
||||
# Hardhat files
|
||||
/cache
|
||||
/artifacts
|
||||
|
||||
# TypeChain files
|
||||
/typechain
|
||||
/typechain-types
|
||||
|
||||
# solidity-coverage files
|
||||
/coverage
|
||||
/coverage.json
|
||||
|
||||
# Hardhat Ignition default folder for deployments against a local node
|
||||
ignition/deployments/chain-31337
|
34
contract/contracts/Lock.sol
Normal file
34
contract/contracts/Lock.sol
Normal file
@ -0,0 +1,34 @@
|
||||
// SPDX-License-Identifier: UNLICENSED
|
||||
pragma solidity ^0.8.24;
|
||||
|
||||
// Uncomment this line to use console.log
|
||||
// import "hardhat/console.sol";
|
||||
|
||||
contract Lock {
|
||||
uint public unlockTime;
|
||||
address payable public owner;
|
||||
|
||||
event Withdrawal(uint amount, uint when);
|
||||
|
||||
constructor(uint _unlockTime) payable {
|
||||
require(
|
||||
block.timestamp < _unlockTime,
|
||||
"Unlock time should be in the future"
|
||||
);
|
||||
|
||||
unlockTime = _unlockTime;
|
||||
owner = payable(msg.sender);
|
||||
}
|
||||
|
||||
function withdraw() public {
|
||||
// Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal
|
||||
// console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp);
|
||||
|
||||
require(block.timestamp >= unlockTime, "You can't withdraw yet");
|
||||
require(msg.sender == owner, "You aren't the owner");
|
||||
|
||||
emit Withdrawal(address(this).balance, block.timestamp);
|
||||
|
||||
owner.transfer(address(this).balance);
|
||||
}
|
||||
}
|
14
contract/hardhat.config.ts
Normal file
14
contract/hardhat.config.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {HardhatUserConfig, vars} from "hardhat/config";
|
||||
import "@nomicfoundation/hardhat-toolbox";
|
||||
const INFURA_API_KEY = vars.get("INFURA_API_KEY");
|
||||
|
||||
const config: HardhatUserConfig = {
|
||||
solidity: "0.8.24",
|
||||
networks: {
|
||||
sepolia: {
|
||||
url: `https://sepolia.infura.io/v3/${INFURA_API_KEY}`,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
17
contract/ignition/modules/Lock.ts
Normal file
17
contract/ignition/modules/Lock.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
|
||||
|
||||
const JAN_1ST_2030 = 1893456000;
|
||||
const ONE_GWEI: bigint = 1_000_000_000n;
|
||||
|
||||
const LockModule = buildModule("LockModule", (m) => {
|
||||
const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
|
||||
const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);
|
||||
|
||||
const lock = m.contract("Lock", [unlockTime], {
|
||||
value: lockedAmount,
|
||||
});
|
||||
|
||||
return { lock };
|
||||
});
|
||||
|
||||
export default LockModule;
|
7346
contract/package-lock.json
generated
Normal file
7346
contract/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
contract/package.json
Normal file
12
contract/package.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"devDependencies": {
|
||||
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
||||
"@types/chai": "^4.3.14",
|
||||
"@types/mocha": "^10.0.6",
|
||||
"@types/node": "^20.12.8",
|
||||
"chai": "^4.4.1",
|
||||
"hardhat": "^2.22.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.4.5"
|
||||
}
|
||||
}
|
127
contract/test/Lock.ts
Normal file
127
contract/test/Lock.ts
Normal file
@ -0,0 +1,127 @@
|
||||
import {
|
||||
time,
|
||||
loadFixture,
|
||||
} from "@nomicfoundation/hardhat-toolbox/network-helpers";
|
||||
import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs";
|
||||
import { expect } from "chai";
|
||||
import hre from "hardhat";
|
||||
|
||||
describe("Lock", function () {
|
||||
// We define a fixture to reuse the same setup in every test.
|
||||
// We use loadFixture to run this setup once, snapshot that state,
|
||||
// and reset Hardhat Network to that snapshot in every test.
|
||||
async function deployOneYearLockFixture() {
|
||||
const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60;
|
||||
const ONE_GWEI = 1_000_000_000;
|
||||
|
||||
const lockedAmount = ONE_GWEI;
|
||||
const unlockTime = (await time.latest()) + ONE_YEAR_IN_SECS;
|
||||
|
||||
// Contracts are deployed using the first signer/account by default
|
||||
const [owner, otherAccount] = await hre.ethers.getSigners();
|
||||
|
||||
const Lock = await hre.ethers.getContractFactory("Lock");
|
||||
const lock = await Lock.deploy(unlockTime, { value: lockedAmount });
|
||||
|
||||
return { lock, unlockTime, lockedAmount, owner, otherAccount };
|
||||
}
|
||||
|
||||
describe("Deployment", function () {
|
||||
it("Should set the right unlockTime", async function () {
|
||||
const { lock, unlockTime } = await loadFixture(deployOneYearLockFixture);
|
||||
|
||||
expect(await lock.unlockTime()).to.equal(unlockTime);
|
||||
});
|
||||
|
||||
it("Should set the right owner", async function () {
|
||||
const { lock, owner } = await loadFixture(deployOneYearLockFixture);
|
||||
|
||||
expect(await lock.owner()).to.equal(owner.address);
|
||||
});
|
||||
|
||||
it("Should receive and store the funds to lock", async function () {
|
||||
const { lock, lockedAmount } = await loadFixture(
|
||||
deployOneYearLockFixture
|
||||
);
|
||||
|
||||
expect(await hre.ethers.provider.getBalance(lock.target)).to.equal(
|
||||
lockedAmount
|
||||
);
|
||||
});
|
||||
|
||||
it("Should fail if the unlockTime is not in the future", async function () {
|
||||
// We don't use the fixture here because we want a different deployment
|
||||
const latestTime = await time.latest();
|
||||
const Lock = await hre.ethers.getContractFactory("Lock");
|
||||
await expect(Lock.deploy(latestTime, { value: 1 })).to.be.revertedWith(
|
||||
"Unlock time should be in the future"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Withdrawals", function () {
|
||||
describe("Validations", function () {
|
||||
it("Should revert with the right error if called too soon", async function () {
|
||||
const { lock } = await loadFixture(deployOneYearLockFixture);
|
||||
|
||||
await expect(lock.withdraw()).to.be.revertedWith(
|
||||
"You can't withdraw yet"
|
||||
);
|
||||
});
|
||||
|
||||
it("Should revert with the right error if called from another account", async function () {
|
||||
const { lock, unlockTime, otherAccount } = await loadFixture(
|
||||
deployOneYearLockFixture
|
||||
);
|
||||
|
||||
// We can increase the time in Hardhat Network
|
||||
await time.increaseTo(unlockTime);
|
||||
|
||||
// We use lock.connect() to send a transaction from another account
|
||||
await expect(lock.connect(otherAccount).withdraw()).to.be.revertedWith(
|
||||
"You aren't the owner"
|
||||
);
|
||||
});
|
||||
|
||||
it("Shouldn't fail if the unlockTime has arrived and the owner calls it", async function () {
|
||||
const { lock, unlockTime } = await loadFixture(
|
||||
deployOneYearLockFixture
|
||||
);
|
||||
|
||||
// Transactions are sent using the first signer by default
|
||||
await time.increaseTo(unlockTime);
|
||||
|
||||
await expect(lock.withdraw()).not.to.be.reverted;
|
||||
});
|
||||
});
|
||||
|
||||
describe("Events", function () {
|
||||
it("Should emit an event on withdrawals", async function () {
|
||||
const { lock, unlockTime, lockedAmount } = await loadFixture(
|
||||
deployOneYearLockFixture
|
||||
);
|
||||
|
||||
await time.increaseTo(unlockTime);
|
||||
|
||||
await expect(lock.withdraw())
|
||||
.to.emit(lock, "Withdrawal")
|
||||
.withArgs(lockedAmount, anyValue); // We accept any value as `when` arg
|
||||
});
|
||||
});
|
||||
|
||||
describe("Transfers", function () {
|
||||
it("Should transfer the funds to the owner", async function () {
|
||||
const { lock, unlockTime, lockedAmount, owner } = await loadFixture(
|
||||
deployOneYearLockFixture
|
||||
);
|
||||
|
||||
await time.increaseTo(unlockTime);
|
||||
|
||||
await expect(lock.withdraw()).to.changeEtherBalances(
|
||||
[owner, lock],
|
||||
[lockedAmount, -lockedAmount]
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
11
contract/tsconfig.json
Normal file
11
contract/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
140
typechain-types/Lock.ts
Normal file
140
typechain-types/Lock.ts
Normal file
@ -0,0 +1,140 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
FunctionFragment,
|
||||
Result,
|
||||
Interface,
|
||||
EventFragment,
|
||||
ContractRunner,
|
||||
ContractMethod,
|
||||
Listener,
|
||||
} from "ethers";
|
||||
import type {
|
||||
TypedContractEvent,
|
||||
TypedDeferredTopicFilter,
|
||||
TypedEventLog,
|
||||
TypedLogDescription,
|
||||
TypedListener,
|
||||
TypedContractMethod,
|
||||
} from "./common";
|
||||
|
||||
export interface LockInterface extends Interface {
|
||||
getFunction(
|
||||
nameOrSignature: "owner" | "unlockTime" | "withdraw"
|
||||
): FunctionFragment;
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "Withdrawal"): EventFragment;
|
||||
|
||||
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "unlockTime",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(functionFragment: "withdraw", values?: undefined): string;
|
||||
|
||||
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "unlockTime", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "withdraw", data: BytesLike): Result;
|
||||
}
|
||||
|
||||
export namespace WithdrawalEvent {
|
||||
export type InputTuple = [amount: BigNumberish, when: BigNumberish];
|
||||
export type OutputTuple = [amount: bigint, when: bigint];
|
||||
export interface OutputObject {
|
||||
amount: bigint;
|
||||
when: bigint;
|
||||
}
|
||||
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
|
||||
export type Filter = TypedDeferredTopicFilter<Event>;
|
||||
export type Log = TypedEventLog<Event>;
|
||||
export type LogDescription = TypedLogDescription<Event>;
|
||||
}
|
||||
|
||||
export interface Lock extends BaseContract {
|
||||
connect(runner?: ContractRunner | null): Lock;
|
||||
waitForDeployment(): Promise<this>;
|
||||
|
||||
interface: LockInterface;
|
||||
|
||||
queryFilter<TCEvent extends TypedContractEvent>(
|
||||
event: TCEvent,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TypedEventLog<TCEvent>>>;
|
||||
queryFilter<TCEvent extends TypedContractEvent>(
|
||||
filter: TypedDeferredTopicFilter<TCEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TypedEventLog<TCEvent>>>;
|
||||
|
||||
on<TCEvent extends TypedContractEvent>(
|
||||
event: TCEvent,
|
||||
listener: TypedListener<TCEvent>
|
||||
): Promise<this>;
|
||||
on<TCEvent extends TypedContractEvent>(
|
||||
filter: TypedDeferredTopicFilter<TCEvent>,
|
||||
listener: TypedListener<TCEvent>
|
||||
): Promise<this>;
|
||||
|
||||
once<TCEvent extends TypedContractEvent>(
|
||||
event: TCEvent,
|
||||
listener: TypedListener<TCEvent>
|
||||
): Promise<this>;
|
||||
once<TCEvent extends TypedContractEvent>(
|
||||
filter: TypedDeferredTopicFilter<TCEvent>,
|
||||
listener: TypedListener<TCEvent>
|
||||
): Promise<this>;
|
||||
|
||||
listeners<TCEvent extends TypedContractEvent>(
|
||||
event: TCEvent
|
||||
): Promise<Array<TypedListener<TCEvent>>>;
|
||||
listeners(eventName?: string): Promise<Array<Listener>>;
|
||||
removeAllListeners<TCEvent extends TypedContractEvent>(
|
||||
event?: TCEvent
|
||||
): Promise<this>;
|
||||
|
||||
owner: TypedContractMethod<[], [string], "view">;
|
||||
|
||||
unlockTime: TypedContractMethod<[], [bigint], "view">;
|
||||
|
||||
withdraw: TypedContractMethod<[], [void], "nonpayable">;
|
||||
|
||||
getFunction<T extends ContractMethod = ContractMethod>(
|
||||
key: string | FunctionFragment
|
||||
): T;
|
||||
|
||||
getFunction(
|
||||
nameOrSignature: "owner"
|
||||
): TypedContractMethod<[], [string], "view">;
|
||||
getFunction(
|
||||
nameOrSignature: "unlockTime"
|
||||
): TypedContractMethod<[], [bigint], "view">;
|
||||
getFunction(
|
||||
nameOrSignature: "withdraw"
|
||||
): TypedContractMethod<[], [void], "nonpayable">;
|
||||
|
||||
getEvent(
|
||||
key: "Withdrawal"
|
||||
): TypedContractEvent<
|
||||
WithdrawalEvent.InputTuple,
|
||||
WithdrawalEvent.OutputTuple,
|
||||
WithdrawalEvent.OutputObject
|
||||
>;
|
||||
|
||||
filters: {
|
||||
"Withdrawal(uint256,uint256)": TypedContractEvent<
|
||||
WithdrawalEvent.InputTuple,
|
||||
WithdrawalEvent.OutputTuple,
|
||||
WithdrawalEvent.OutputObject
|
||||
>;
|
||||
Withdrawal: TypedContractEvent<
|
||||
WithdrawalEvent.InputTuple,
|
||||
WithdrawalEvent.OutputTuple,
|
||||
WithdrawalEvent.OutputObject
|
||||
>;
|
||||
};
|
||||
}
|
131
typechain-types/common.ts
Normal file
131
typechain-types/common.ts
Normal file
@ -0,0 +1,131 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
FunctionFragment,
|
||||
Typed,
|
||||
EventFragment,
|
||||
ContractTransaction,
|
||||
ContractTransactionResponse,
|
||||
DeferredTopicFilter,
|
||||
EventLog,
|
||||
TransactionRequest,
|
||||
LogDescription,
|
||||
} from "ethers";
|
||||
|
||||
export interface TypedDeferredTopicFilter<_TCEvent extends TypedContractEvent>
|
||||
extends DeferredTopicFilter {}
|
||||
|
||||
export interface TypedContractEvent<
|
||||
InputTuple extends Array<any> = any,
|
||||
OutputTuple extends Array<any> = any,
|
||||
OutputObject = any
|
||||
> {
|
||||
(...args: Partial<InputTuple>): TypedDeferredTopicFilter<
|
||||
TypedContractEvent<InputTuple, OutputTuple, OutputObject>
|
||||
>;
|
||||
name: string;
|
||||
fragment: EventFragment;
|
||||
getFragment(...args: Partial<InputTuple>): EventFragment;
|
||||
}
|
||||
|
||||
type __TypechainAOutputTuple<T> = T extends TypedContractEvent<
|
||||
infer _U,
|
||||
infer W
|
||||
>
|
||||
? W
|
||||
: never;
|
||||
type __TypechainOutputObject<T> = T extends TypedContractEvent<
|
||||
infer _U,
|
||||
infer _W,
|
||||
infer V
|
||||
>
|
||||
? V
|
||||
: never;
|
||||
|
||||
export interface TypedEventLog<TCEvent extends TypedContractEvent>
|
||||
extends Omit<EventLog, "args"> {
|
||||
args: __TypechainAOutputTuple<TCEvent> & __TypechainOutputObject<TCEvent>;
|
||||
}
|
||||
|
||||
export interface TypedLogDescription<TCEvent extends TypedContractEvent>
|
||||
extends Omit<LogDescription, "args"> {
|
||||
args: __TypechainAOutputTuple<TCEvent> & __TypechainOutputObject<TCEvent>;
|
||||
}
|
||||
|
||||
export type TypedListener<TCEvent extends TypedContractEvent> = (
|
||||
...listenerArg: [
|
||||
...__TypechainAOutputTuple<TCEvent>,
|
||||
TypedEventLog<TCEvent>,
|
||||
...undefined[]
|
||||
]
|
||||
) => void;
|
||||
|
||||
export type MinEthersFactory<C, ARGS> = {
|
||||
deploy(...a: ARGS[]): Promise<C>;
|
||||
};
|
||||
|
||||
export type GetContractTypeFromFactory<F> = F extends MinEthersFactory<
|
||||
infer C,
|
||||
any
|
||||
>
|
||||
? C
|
||||
: never;
|
||||
export type GetARGsTypeFromFactory<F> = F extends MinEthersFactory<any, any>
|
||||
? Parameters<F["deploy"]>
|
||||
: never;
|
||||
|
||||
export type StateMutability = "nonpayable" | "payable" | "view";
|
||||
|
||||
export type BaseOverrides = Omit<TransactionRequest, "to" | "data">;
|
||||
export type NonPayableOverrides = Omit<
|
||||
BaseOverrides,
|
||||
"value" | "blockTag" | "enableCcipRead"
|
||||
>;
|
||||
export type PayableOverrides = Omit<
|
||||
BaseOverrides,
|
||||
"blockTag" | "enableCcipRead"
|
||||
>;
|
||||
export type ViewOverrides = Omit<TransactionRequest, "to" | "data">;
|
||||
export type Overrides<S extends StateMutability> = S extends "nonpayable"
|
||||
? NonPayableOverrides
|
||||
: S extends "payable"
|
||||
? PayableOverrides
|
||||
: ViewOverrides;
|
||||
|
||||
export type PostfixOverrides<A extends Array<any>, S extends StateMutability> =
|
||||
| A
|
||||
| [...A, Overrides<S>];
|
||||
export type ContractMethodArgs<
|
||||
A extends Array<any>,
|
||||
S extends StateMutability
|
||||
> = PostfixOverrides<{ [I in keyof A]-?: A[I] | Typed }, S>;
|
||||
|
||||
export type DefaultReturnType<R> = R extends Array<any> ? R[0] : R;
|
||||
|
||||
// export interface ContractMethod<A extends Array<any> = Array<any>, R = any, D extends R | ContractTransactionResponse = R | ContractTransactionResponse> {
|
||||
export interface TypedContractMethod<
|
||||
A extends Array<any> = Array<any>,
|
||||
R = any,
|
||||
S extends StateMutability = "payable"
|
||||
> {
|
||||
(...args: ContractMethodArgs<A, S>): S extends "view"
|
||||
? Promise<DefaultReturnType<R>>
|
||||
: Promise<ContractTransactionResponse>;
|
||||
|
||||
name: string;
|
||||
|
||||
fragment: FunctionFragment;
|
||||
|
||||
getFragment(...args: ContractMethodArgs<A, S>): FunctionFragment;
|
||||
|
||||
populateTransaction(
|
||||
...args: ContractMethodArgs<A, S>
|
||||
): Promise<ContractTransaction>;
|
||||
staticCall(
|
||||
...args: ContractMethodArgs<A, "view">
|
||||
): Promise<DefaultReturnType<R>>;
|
||||
send(...args: ContractMethodArgs<A, S>): Promise<ContractTransactionResponse>;
|
||||
estimateGas(...args: ContractMethodArgs<A, S>): Promise<bigint>;
|
||||
staticCallResult(...args: ContractMethodArgs<A, "view">): Promise<R>;
|
||||
}
|
133
typechain-types/factories/Lock__factory.ts
Normal file
133
typechain-types/factories/Lock__factory.ts
Normal file
@ -0,0 +1,133 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import {
|
||||
Contract,
|
||||
ContractFactory,
|
||||
ContractTransactionResponse,
|
||||
Interface,
|
||||
} from "ethers";
|
||||
import type {
|
||||
Signer,
|
||||
BigNumberish,
|
||||
ContractDeployTransaction,
|
||||
ContractRunner,
|
||||
} from "ethers";
|
||||
import type { PayableOverrides } from "../common";
|
||||
import type { Lock, LockInterface } from "../Lock";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_unlockTime",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "payable",
|
||||
type: "constructor",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "when",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "Withdrawal",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "owner",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address payable",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "unlockTime",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "withdraw",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
] as const;
|
||||
|
||||
const _bytecode =
|
||||
"0x60806040526040516105d83803806105d8833981810160405281019061002591906100f0565b804210610067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161005e906101a0565b60405180910390fd5b8060008190555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101c0565b600080fd5b6000819050919050565b6100cd816100ba565b81146100d857600080fd5b50565b6000815190506100ea816100c4565b92915050565b600060208284031215610106576101056100b5565b5b6000610114848285016100db565b91505092915050565b600082825260208201905092915050565b7f556e6c6f636b2074696d652073686f756c6420626520696e207468652066757460008201527f7572650000000000000000000000000000000000000000000000000000000000602082015250565b600061018a60238361011d565b91506101958261012e565b604082019050919050565b600060208201905081810360008301526101b98161017d565b9050919050565b610409806101cf6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063251c1aa3146100465780633ccfd60b146100645780638da5cb5b1461006e575b600080fd5b61004e61008c565b60405161005b919061024a565b60405180910390f35b61006c610092565b005b61007661020b565b60405161008391906102a6565b60405180910390f35b60005481565b6000544210156100d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ce9061031e565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161015e9061038a565b60405180910390fd5b7fbf2ed60bd5b5965d685680c01195c9514e4382e28e3a5a2d2d5244bf59411b9347426040516101989291906103aa565b60405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610208573d6000803e3d6000fd5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000819050919050565b61024481610231565b82525050565b600060208201905061025f600083018461023b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061029082610265565b9050919050565b6102a081610285565b82525050565b60006020820190506102bb6000830184610297565b92915050565b600082825260208201905092915050565b7f596f752063616e27742077697468647261772079657400000000000000000000600082015250565b60006103086016836102c1565b9150610313826102d2565b602082019050919050565b60006020820190508181036000830152610337816102fb565b9050919050565b7f596f75206172656e277420746865206f776e6572000000000000000000000000600082015250565b60006103746014836102c1565b915061037f8261033e565b602082019050919050565b600060208201905081810360008301526103a381610367565b9050919050565b60006040820190506103bf600083018561023b565b6103cc602083018461023b565b939250505056fea264697066735822122022a2b65355af697b0725f7bcddf1c94be908ee67893e84bd3442d61fdc82585064736f6c63430008180033";
|
||||
|
||||
type LockConstructorParams =
|
||||
| [signer?: Signer]
|
||||
| ConstructorParameters<typeof ContractFactory>;
|
||||
|
||||
const isSuperArgs = (
|
||||
xs: LockConstructorParams
|
||||
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;
|
||||
|
||||
export class Lock__factory extends ContractFactory {
|
||||
constructor(...args: LockConstructorParams) {
|
||||
if (isSuperArgs(args)) {
|
||||
super(...args);
|
||||
} else {
|
||||
super(_abi, _bytecode, args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
override getDeployTransaction(
|
||||
_unlockTime: BigNumberish,
|
||||
overrides?: PayableOverrides & { from?: string }
|
||||
): Promise<ContractDeployTransaction> {
|
||||
return super.getDeployTransaction(_unlockTime, overrides || {});
|
||||
}
|
||||
override deploy(
|
||||
_unlockTime: BigNumberish,
|
||||
overrides?: PayableOverrides & { from?: string }
|
||||
) {
|
||||
return super.deploy(_unlockTime, overrides || {}) as Promise<
|
||||
Lock & {
|
||||
deploymentTransaction(): ContractTransactionResponse;
|
||||
}
|
||||
>;
|
||||
}
|
||||
override connect(runner: ContractRunner | null): Lock__factory {
|
||||
return super.connect(runner) as Lock__factory;
|
||||
}
|
||||
|
||||
static readonly bytecode = _bytecode;
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): LockInterface {
|
||||
return new Interface(_abi) as LockInterface;
|
||||
}
|
||||
static connect(address: string, runner?: ContractRunner | null): Lock {
|
||||
return new Contract(address, _abi, runner) as unknown as Lock;
|
||||
}
|
||||
}
|
4
typechain-types/factories/index.ts
Normal file
4
typechain-types/factories/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { Lock__factory } from "./Lock__factory";
|
63
typechain-types/hardhat.d.ts
vendored
Normal file
63
typechain-types/hardhat.d.ts
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { ethers } from "ethers";
|
||||
import {
|
||||
DeployContractOptions,
|
||||
FactoryOptions,
|
||||
HardhatEthersHelpers as HardhatEthersHelpersBase,
|
||||
} from "@nomicfoundation/hardhat-ethers/types";
|
||||
|
||||
import * as Contracts from ".";
|
||||
|
||||
declare module "hardhat/types/runtime" {
|
||||
interface HardhatEthersHelpers extends HardhatEthersHelpersBase {
|
||||
getContractFactory(
|
||||
name: "Lock",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.Lock__factory>;
|
||||
|
||||
getContractAt(
|
||||
name: "Lock",
|
||||
address: string | ethers.Addressable,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.Lock>;
|
||||
|
||||
deployContract(
|
||||
name: "Lock",
|
||||
signerOrOptions?: ethers.Signer | DeployContractOptions
|
||||
): Promise<Contracts.Lock>;
|
||||
|
||||
deployContract(
|
||||
name: "Lock",
|
||||
args: any[],
|
||||
signerOrOptions?: ethers.Signer | DeployContractOptions
|
||||
): Promise<Contracts.Lock>;
|
||||
|
||||
// default types
|
||||
getContractFactory(
|
||||
name: string,
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<ethers.ContractFactory>;
|
||||
getContractFactory(
|
||||
abi: any[],
|
||||
bytecode: ethers.BytesLike,
|
||||
signer?: ethers.Signer
|
||||
): Promise<ethers.ContractFactory>;
|
||||
getContractAt(
|
||||
nameOrAbi: string | any[],
|
||||
address: string | ethers.Addressable,
|
||||
signer?: ethers.Signer
|
||||
): Promise<ethers.Contract>;
|
||||
deployContract(
|
||||
name: string,
|
||||
signerOrOptions?: ethers.Signer | DeployContractOptions
|
||||
): Promise<ethers.Contract>;
|
||||
deployContract(
|
||||
name: string,
|
||||
args: any[],
|
||||
signerOrOptions?: ethers.Signer | DeployContractOptions
|
||||
): Promise<ethers.Contract>;
|
||||
}
|
||||
}
|
6
typechain-types/index.ts
Normal file
6
typechain-types/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type { Lock } from "./Lock";
|
||||
export * as factories from "./factories";
|
||||
export { Lock__factory } from "./factories/Lock__factory";
|
Loading…
Reference in New Issue
Block a user