Test for existing stateless contract works

This commit is contained in:
evgeniy-scherbina 2024-01-02 15:44:17 -05:00
parent e43272c054
commit 1381099eaf
19 changed files with 14017 additions and 0 deletions

4
.gitignore vendored
View file

@ -50,3 +50,7 @@ profile.cov
logs/ logs/
tests/spec-tests/ tests/spec-tests/
contracts/node_modules
contracts/cache
contracts/artifacts

13
contracts/README.md Normal file
View file

@ -0,0 +1,13 @@
# Sample Hardhat Project
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.
Try running some of the following tasks:
```shell
npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts
```

View file

@ -0,0 +1,9 @@
pragma solidity ^0.8.0;
contract ExampleSHA256 {
function hashSha256(uint256 numberToHash) public view returns (bytes32 h) {
(bool ok, bytes memory out) = address(2).staticcall(abi.encode(numberToHash));
require(ok, "precompile call failed");
h = abi.decode(out, (bytes32));
}
}

View file

@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
// 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);
}
}

View file

@ -0,0 +1,8 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
const config: HardhatUserConfig = {
solidity: "0.8.19",
};
export default config;

13088
contracts/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

7
contracts/package.json Normal file
View file

@ -0,0 +1,7 @@
{
"name": "hardhat-project",
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
"hardhat": "^2.19.4"
}
}

View file

@ -0,0 +1,27 @@
import { ethers } from "hardhat";
async function main() {
const currentTimestampInSeconds = Math.round(Date.now() / 1000);
const unlockTime = currentTimestampInSeconds + 60;
const lockedAmount = ethers.parseEther("0.001");
const lock = await ethers.deployContract("Lock", [unlockTime], {
value: lockedAmount,
});
await lock.waitForDeployment();
console.log(
`Lock with ${ethers.formatEther(
lockedAmount
)}ETH and unlock timestamp ${unlockTime} deployed to ${lock.target}`
);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

127
contracts/test/Lock.ts Normal file
View 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 { ethers } 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 ethers.getSigners();
const Lock = await 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 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 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]
);
});
});
});
});

16
contracts/test/sha256.ts Normal file
View file

@ -0,0 +1,16 @@
import {
time,
loadFixture,
} from "@nomicfoundation/hardhat-toolbox/network-helpers";
import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs";
import { expect } from "chai";
import { ethers } from "hardhat";
describe("SHA256", function() {
it("Should properly calculate hash", async function () {
const ExampleSHA256 = await ethers.getContractFactory("ExampleSHA256")
const exampleSHA256 = await ExampleSHA256.deploy();
expect(await exampleSHA256.hashSha256(42)).to.equal("0x0a28e9ffef0073f9a6a674cf57ee77307f38f0f1bebb087888d9011ed0eeefdf");
})
})

11
contracts/tsconfig.json Normal file
View file

@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"resolveJsonModule": true
}
}

View file

@ -0,0 +1,92 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type {
BaseContract,
BigNumberish,
BytesLike,
FunctionFragment,
Result,
Interface,
ContractRunner,
ContractMethod,
Listener,
} from "ethers";
import type {
TypedContractEvent,
TypedDeferredTopicFilter,
TypedEventLog,
TypedListener,
TypedContractMethod,
} from "./common";
export interface ExampleSHA256Interface extends Interface {
getFunction(nameOrSignature: "hashSha256"): FunctionFragment;
encodeFunctionData(
functionFragment: "hashSha256",
values: [BigNumberish]
): string;
decodeFunctionResult(functionFragment: "hashSha256", data: BytesLike): Result;
}
export interface ExampleSHA256 extends BaseContract {
connect(runner?: ContractRunner | null): ExampleSHA256;
waitForDeployment(): Promise<this>;
interface: ExampleSHA256Interface;
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>;
hashSha256: TypedContractMethod<
[numberToHash: BigNumberish],
[string],
"view"
>;
getFunction<T extends ContractMethod = ContractMethod>(
key: string | FunctionFragment
): T;
getFunction(
nameOrSignature: "hashSha256"
): TypedContractMethod<[numberToHash: BigNumberish], [string], "view">;
filters: {};
}

View 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
>;
};
}

View 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>;
}

View file

@ -0,0 +1,83 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import {
Contract,
ContractFactory,
ContractTransactionResponse,
Interface,
} from "ethers";
import type { Signer, ContractDeployTransaction, ContractRunner } from "ethers";
import type { NonPayableOverrides } from "../common";
import type { ExampleSHA256, ExampleSHA256Interface } from "../ExampleSHA256";
const _abi = [
{
inputs: [
{
internalType: "uint256",
name: "numberToHash",
type: "uint256",
},
],
name: "hashSha256",
outputs: [
{
internalType: "bytes32",
name: "h",
type: "bytes32",
},
],
stateMutability: "view",
type: "function",
},
] as const;
const _bytecode =
"0x608060405234801561001057600080fd5b506103a6806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d121893114610030575b600080fd5b61004a60048036038101906100459190610187565b610060565b60405161005791906101cd565b60405180910390f35b6000806000600273ffffffffffffffffffffffffffffffffffffffff168460405160200161008e91906101f7565b6040516020818303038152906040526040516100aa9190610283565b600060405180830381855afa9150503d80600081146100e5576040519150601f19603f3d011682016040523d82523d6000602084013e6100ea565b606091505b50915091508161012f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610126906102f7565b60405180910390fd5b808060200190518101906101439190610343565b92505050919050565b600080fd5b6000819050919050565b61016481610151565b811461016f57600080fd5b50565b6000813590506101818161015b565b92915050565b60006020828403121561019d5761019c61014c565b5b60006101ab84828501610172565b91505092915050565b6000819050919050565b6101c7816101b4565b82525050565b60006020820190506101e260008301846101be565b92915050565b6101f181610151565b82525050565b600060208201905061020c60008301846101e8565b92915050565b600081519050919050565b600081905092915050565b60005b8381101561024657808201518184015260208101905061022b565b60008484015250505050565b600061025d82610212565b610267818561021d565b9350610277818560208601610228565b80840191505092915050565b600061028f8284610252565b915081905092915050565b600082825260208201905092915050565b7f707265636f6d70696c652063616c6c206661696c656400000000000000000000600082015250565b60006102e160168361029a565b91506102ec826102ab565b602082019050919050565b60006020820190508181036000830152610310816102d4565b9050919050565b610320816101b4565b811461032b57600080fd5b50565b60008151905061033d81610317565b92915050565b6000602082840312156103595761035861014c565b5b60006103678482850161032e565b9150509291505056fea2646970667358221220ddec545ddbc7f2919666033e50c25e284ec8fc46aa071d2478abce59dfdddcbb64736f6c63430008130033";
type ExampleSHA256ConstructorParams =
| [signer?: Signer]
| ConstructorParameters<typeof ContractFactory>;
const isSuperArgs = (
xs: ExampleSHA256ConstructorParams
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;
export class ExampleSHA256__factory extends ContractFactory {
constructor(...args: ExampleSHA256ConstructorParams) {
if (isSuperArgs(args)) {
super(...args);
} else {
super(_abi, _bytecode, args[0]);
}
}
override getDeployTransaction(
overrides?: NonPayableOverrides & { from?: string }
): Promise<ContractDeployTransaction> {
return super.getDeployTransaction(overrides || {});
}
override deploy(overrides?: NonPayableOverrides & { from?: string }) {
return super.deploy(overrides || {}) as Promise<
ExampleSHA256 & {
deploymentTransaction(): ContractTransactionResponse;
}
>;
}
override connect(runner: ContractRunner | null): ExampleSHA256__factory {
return super.connect(runner) as ExampleSHA256__factory;
}
static readonly bytecode = _bytecode;
static readonly abi = _abi;
static createInterface(): ExampleSHA256Interface {
return new Interface(_abi) as ExampleSHA256Interface;
}
static connect(
address: string,
runner?: ContractRunner | null
): ExampleSHA256 {
return new Contract(address, _abi, runner) as unknown as ExampleSHA256;
}
}

View 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 =
"0x60806040526040516105d83803806105d8833981810160405281019061002591906100f0565b804210610067576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161005e906101a0565b60405180910390fd5b8060008190555033600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101c0565b600080fd5b6000819050919050565b6100cd816100ba565b81146100d857600080fd5b50565b6000815190506100ea816100c4565b92915050565b600060208284031215610106576101056100b5565b5b6000610114848285016100db565b91505092915050565b600082825260208201905092915050565b7f556e6c6f636b2074696d652073686f756c6420626520696e207468652066757460008201527f7572650000000000000000000000000000000000000000000000000000000000602082015250565b600061018a60238361011d565b91506101958261012e565b604082019050919050565b600060208201905081810360008301526101b98161017d565b9050919050565b610409806101cf6000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063251c1aa3146100465780633ccfd60b146100645780638da5cb5b1461006e575b600080fd5b61004e61008c565b60405161005b919061024a565b60405180910390f35b61006c610092565b005b61007661020b565b60405161008391906102a6565b60405180910390f35b60005481565b6000544210156100d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100ce9061031e565b60405180910390fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610167576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161015e9061038a565b60405180910390fd5b7fbf2ed60bd5b5965d685680c01195c9514e4382e28e3a5a2d2d5244bf59411b9347426040516101989291906103aa565b60405180910390a1600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610208573d6000803e3d6000fd5b50565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000819050919050565b61024481610231565b82525050565b600060208201905061025f600083018461023b565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061029082610265565b9050919050565b6102a081610285565b82525050565b60006020820190506102bb6000830184610297565b92915050565b600082825260208201905092915050565b7f596f752063616e27742077697468647261772079657400000000000000000000600082015250565b60006103086016836102c1565b9150610313826102d2565b602082019050919050565b60006020820190508181036000830152610337816102fb565b9050919050565b7f596f75206172656e277420746865206f776e6572000000000000000000000000600082015250565b60006103746014836102c1565b915061037f8261033e565b602082019050919050565b600060208201905081810360008301526103a381610367565b9050919050565b60006040820190506103bf600083018561023b565b6103cc602083018461023b565b939250505056fea264697066735822122037d72a62344bd1b2480de1f3f4d6ffe4a35d6a5337d4c346f069eed9df11cad164736f6c63430008130033";
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;
}
}

View file

@ -0,0 +1,5 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export { ExampleSHA256__factory } from "./ExampleSHA256__factory";
export { Lock__factory } from "./Lock__factory";

81
contracts/typechain-types/hardhat.d.ts vendored Normal file
View file

@ -0,0 +1,81 @@
/* 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: "ExampleSHA256",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.ExampleSHA256__factory>;
getContractFactory(
name: "Lock",
signerOrOptions?: ethers.Signer | FactoryOptions
): Promise<Contracts.Lock__factory>;
getContractAt(
name: "ExampleSHA256",
address: string | ethers.Addressable,
signer?: ethers.Signer
): Promise<Contracts.ExampleSHA256>;
getContractAt(
name: "Lock",
address: string | ethers.Addressable,
signer?: ethers.Signer
): Promise<Contracts.Lock>;
deployContract(
name: "ExampleSHA256",
signerOrOptions?: ethers.Signer | DeployContractOptions
): Promise<Contracts.ExampleSHA256>;
deployContract(
name: "Lock",
signerOrOptions?: ethers.Signer | DeployContractOptions
): Promise<Contracts.Lock>;
deployContract(
name: "ExampleSHA256",
args: any[],
signerOrOptions?: ethers.Signer | DeployContractOptions
): Promise<Contracts.ExampleSHA256>;
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>;
}
}

View file

@ -0,0 +1,8 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export type { ExampleSHA256 } from "./ExampleSHA256";
export type { Lock } from "./Lock";
export * as factories from "./factories";
export { ExampleSHA256__factory } from "./factories/ExampleSHA256__factory";
export { Lock__factory } from "./factories/Lock__factory";