2 Commits

Author SHA1 Message Date
hueso
91ab0fae80 expired bond goes to seller 2025-08-02 21:35:22 -03:00
hueso
b2198306e6 bond to override lock limit 2025-08-02 21:35:22 -03:00
19 changed files with 618 additions and 36 deletions

View File

@@ -3,10 +3,9 @@ pragma solidity ^0.8.19;
import { ERC20, OwnerSettings } from "contracts/core/OwnerSettings.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import { MerkleProof as Merkle } from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { ECDSA } from "contracts/lib/utils/ECDSA.sol";
import { MerkleProofLib as Merkle } from "contracts/lib/utils/MerkleProofLib.sol";
import { ReentrancyGuard } from "contracts/lib/utils/ReentrancyGuard.sol";
abstract contract BaseUtils is
OwnerSettings,
@@ -44,8 +43,8 @@ abstract contract BaseUtils is
if (
!validBacenSigners(
_castAddrToKey(
ECDSA.recover(
MessageHashUtils.toEthSignedMessageHash(
ECDSA.recoverCalldata(
ECDSA.toEthSignedMessageHash(
_message
),
_signature

View File

@@ -44,4 +44,5 @@ abstract contract Constants {
uint256 constant MAXBALANCE_UPPERBOUND = 1e8 ether;
uint256 constant REPUTATION_LOWERBOUND = 1e2 ether;
uint256 constant LOCKAMOUNT_UPPERBOUND = 1e6 ether;
uint256 constant BOND_DIVISOR = 4; // 6,25%
}

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
library DataTypes {
@@ -13,6 +13,7 @@ library DataTypes {
ERC20 token;
address buyerAddress;
address seller;
bool bond;
}
// prettier-ignore

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "contracts/lib/tokens/ERC20.sol";
// prettier-ignore
interface EventAndErrors {

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ERC2771 } from "contracts/lib/metatx/ERC2771Context.sol";
import { ERC2771Context as ERC2771 } from "contracts/lib/metatx/ERC2771Context.sol";
import { ERC20, SafeTransferLib } from "contracts/lib/utils/SafeTransferLib.sol";
import { IReputation } from "contracts/lib/interfaces/IReputation.sol";
import { EventAndErrors } from "contracts/core/EventAndErrors.sol";

View File

@@ -1,14 +1,87 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
pragma solidity >=0.8.4;
import { ERC2771Context } from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
/// @author OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
/// (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Context.sol)
abstract contract ERC2771 is ERC2771Context(address(0)) {
/// @dev Provides information about the current execution context, including the
/// sender of the transaction and its data. While these are generally available
/// via msg.sender and msg.data, they should not be accessed in such a direct
/// manner, since when dealing with meta-transactions the account sending and
/// paying for execution may not be the actual sender (as far as an application
/// is concerned).
///
/// This contract is only required for intermediate, library-like contracts.
abstract contract Context {
function _msgSender()
internal
view
virtual
returns (address)
{
return msg.sender;
}
function _msgData()
internal
view
virtual
returns (bytes calldata)
{
return msg.data;
}
}
/// @author Modified from OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol)
/// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/metatx/ERC2771Context.sol
/// @dev Context variant with ERC2771 support.
abstract contract ERC2771Context is Context {
// address private immutable _trustedForwarder;
mapping(address => bool) public trustedForwarders;
function isTrustedForwarder(address forwarder) public view override returns (bool) {
/// @custom:oz-upgrades-unsafe-allow constructor
// constructor(address trustedForwarder) {
// _trustedForwarder = trustedForwarder;
// }
function _msgSender()
internal
view
virtual
override
returns (address sender)
{
if (trustedForwarders[msg.sender]) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
/// @solidity memory-safe-assembly
assembly {
sender := shr(
96,
calldataload(sub(calldatasize(), 20))
)
}
} else {
return super._msgSender();
}
}
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
return trustedForwarders[forwarder];
}
function _msgData()
internal
view
virtual
override
returns (bytes calldata)
{
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return super._msgData();
}
}
}

View File

@@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "../tokens/ERC20.sol";
contract MockToken is ERC20 {
constructor(uint256 supply) ERC20("MockBRL", "MBRL") {
constructor(uint256 supply) ERC20("MockBRL", "MBRL", 18) {
_mint(msg.sender, supply);
}

View File

@@ -0,0 +1,250 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event Transfer(
address indexed from,
address indexed to,
uint256 amount
);
event Approval(
address indexed owner,
address indexed spender,
uint256 amount
);
/*//////////////////////////////////////////////////////////////
METADATA STORAGE
//////////////////////////////////////////////////////////////*/
string public name;
string public symbol;
uint8 public immutable decimals;
/*//////////////////////////////////////////////////////////////
ERC20 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
mapping(address => mapping(address => uint256))
public allowance;
/*//////////////////////////////////////////////////////////////
EIP-2612 STORAGE
//////////////////////////////////////////////////////////////*/
uint256 internal immutable INITIAL_CHAIN_ID;
bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;
mapping(address => uint256) public nonces;
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals
) {
name = _name;
symbol = _symbol;
decimals = _decimals;
INITIAL_CHAIN_ID = block.chainid;
INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
}
/*//////////////////////////////////////////////////////////////
ERC20 LOGIC
//////////////////////////////////////////////////////////////*/
function approve(
address spender,
uint256 amount
) public virtual returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
function transfer(
address to,
uint256 amount
) public virtual returns (bool) {
balanceOf[msg.sender] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(msg.sender, to, amount);
return true;
}
function transferFrom(
address from,
address to,
uint256 amount
) public virtual returns (bool) {
uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.
if (allowed != type(uint256).max)
allowance[from][msg.sender] = allowed - amount;
balanceOf[from] -= amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(from, to, amount);
return true;
}
/*//////////////////////////////////////////////////////////////
EIP-2612 LOGIC
//////////////////////////////////////////////////////////////*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
require(
deadline >= block.timestamp,
"PERMIT_DEADLINE_EXPIRED"
);
// Unchecked because the only math done is incrementing
// the owner's nonce which cannot realistically overflow.
unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
),
owner,
spender,
value,
nonces[owner]++,
deadline
)
)
)
),
v,
r,
s
);
require(
recoveredAddress != address(0) &&
recoveredAddress == owner,
"INVALID_SIGNER"
);
allowance[recoveredAddress][spender] = value;
}
emit Approval(owner, spender, value);
}
function DOMAIN_SEPARATOR()
public
view
virtual
returns (bytes32)
{
return
block.chainid == INITIAL_CHAIN_ID
? INITIAL_DOMAIN_SEPARATOR
: computeDomainSeparator();
}
function computeDomainSeparator()
internal
view
virtual
returns (bytes32)
{
return
keccak256(
abi.encode(
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256(bytes(name)),
keccak256("1"),
block.chainid,
address(this)
)
);
}
/*//////////////////////////////////////////////////////////////
INTERNAL MINT/BURN LOGIC
//////////////////////////////////////////////////////////////*/
function _mint(
address to,
uint256 amount
) internal virtual {
totalSupply += amount;
// Cannot overflow because the sum of all user
// balances can't exceed the max uint256 value.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
function _burn(
address from,
uint256 amount
) internal virtual {
balanceOf[from] -= amount;
// Cannot underflow because a user's balance
// will never be larger than the total supply.
unchecked {
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}

View File

@@ -0,0 +1,95 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// @notice Gas optimized ECDSA wrapper.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol)
library ECDSA {
/// @dev The signature is invalid.
error InvalidSignature();
/// @dev The number which `s` must not exceed in order for
/// the signature to be non-malleable.
bytes32 private constant _MALLEABILITY_THRESHOLD =
0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0;
/// @dev Recovers the signer's address from a message digest `hash`,
/// and the `signature`.
///
/// This function does NOT accept EIP-2098 short form signatures.
/// Use `recover(bytes32 hash, bytes32 r, bytes32 vs)` for EIP-2098
/// short form signatures instead.
function recoverCalldata(
bytes32 hash,
bytes calldata signature
) internal view returns (address result) {
/// @solidity memory-safe-assembly
assembly {
// Copy the free memory pointer so that we can restore it later.
let m := mload(0x40)
// Directly copy `r` and `s` from the calldata.
calldatacopy(0x40, signature.offset, 0x40)
// Store the `hash` in the scratch space.
mstore(0x00, hash)
// Compute `v` and store it in the scratch space.
mstore(
0x20,
byte(
0,
calldataload(add(signature.offset, 0x40))
)
)
pop(
staticcall(
gas(), // Amount of gas left for the transaction.
and(
// If the signature is exactly 65 bytes in length.
eq(signature.length, 65),
// If `s` in lower half order, such that the signature is not malleable.
lt(
mload(0x60),
add(_MALLEABILITY_THRESHOLD, 1)
)
), // Address of `ecrecover`.
0x00, // Start of input.
0x80, // Size of input.
0x00, // Start of output.
0x20 // Size of output.
)
)
result := mload(0x00)
// `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
if iszero(returndatasize()) {
// Store the function selector of `InvalidSignature()`.
mstore(0x00, 0x8baa579f)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
// Restore the zero slot.
mstore(0x60, 0)
// Restore the free memory pointer.
mstore(0x40, m)
}
}
/// @dev Returns an Ethereum Signed Message, created from a `hash`.
/// This produces a hash corresponding to the one signed with the
/// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
/// JSON-RPC method as part of EIP-191.
function toEthSignedMessageHash(
bytes32 hash
) internal pure returns (bytes32 result) {
/// @solidity memory-safe-assembly
assembly {
// Store into scratch space for keccak256.
mstore(0x20, hash)
mstore(
0x00,
"\x00\x00\x00\x00\x19Ethereum Signed Message:\n32"
)
// 0x40 - 0x04 = 0x3c
result := keccak256(0x04, 0x3c)
}
}
}

View File

@@ -0,0 +1,58 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// @notice Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.
/// @author Solady
/// (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)
/// @author Modified from Solmate
/// (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)
/// @author Modified from OpenZeppelin
/// (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)
library MerkleProofLib {
/// @dev Returns whether `leaf` exists in the Merkle tree with `root`, given `proof`.
function verify(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool isValid) {
/// @solidity memory-safe-assembly
assembly {
if proof.length {
// Left shift by 5 is equivalent to multiplying by 0x20.
let end := add(
proof.offset,
shl(5, proof.length)
)
// Initialize `offset` to the offset of `proof` in the calldata.
let offset := proof.offset
// Iterate over proof elements to compute root hash.
for {
} 1 {
} {
// Slot of `leaf` in scratch space.
// If the condition is true: 0x20, otherwise: 0x00.
let scratch := shl(
5,
gt(leaf, calldataload(offset))
)
// Store elements to hash contiguously in scratch space.
// Scratch space is 64 bytes (0x00 - 0x3f) and both elements are 32 bytes.
mstore(scratch, leaf)
mstore(
xor(scratch, 0x20),
calldataload(offset)
)
// Reuse `leaf` to store the hash to reduce stack operations.
leaf := keccak256(0x00, 0x40)
offset := add(offset, 0x20)
if iszero(lt(offset, end)) {
break
}
}
}
isValid := eq(leaf, root)
}
}
}

View File

@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
/// @notice Reentrancy protection for smart contracts.
/// @author z0r0z.eth
/// @author Modified from Seaport
/// (https://github.com/ProjectOpenSea/seaport/blob/main/contracts/lib/ReentrancyGuard.sol)
/// @author Modified from Solmate
/// (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
error Reentrancy();
uint256 private guard = 1;
modifier nonReentrant() virtual {
setReentrancyGuard();
_;
clearReentrancyGuard();
}
/// @dev Check guard sentinel value and set it.
function setReentrancyGuard() internal virtual {
if (guard == 2) revert Reentrancy();
guard = 2;
}
/// @dev Unset sentinel value.
function clearReentrancyGuard() internal virtual {
guard = 1;
}
}

View File

@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20 } from "../tokens/ERC20.sol";
/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SafeTransferLib.sol)

View File

@@ -135,7 +135,8 @@ contract P2PIX is BaseUtils {
ERC20 token,
uint80 amount,
bytes32[] calldata merkleProof,
uint256[] calldata expiredLocks
uint256[] calldata expiredLocks,
bool bond
) public nonReentrant returns (uint256 lockID) {
unlockExpired(expiredLocks);
@@ -154,10 +155,17 @@ contract P2PIX is BaseUtils {
bytes32 _pixTarget = getPixTarget(seller, token);
// transaction forwarding must leave `merkleProof` empty;
// otherwise, the trustedForwarder must be previously added
// to a seller whitelist.
if (merkleProof.length != 0) {
if (bond){
SafeTransferLib.safeTransferFrom(
token,
_msgSender(),
address(this),
amount >> BOND_DIVISOR
);
} else if (merkleProof.length != 0) {
// transaction forwarding must leave `merkleProof` empty;
// otherwise, the trustedForwarder must be previously added
// to a seller whitelist.
_merkleVerify( merkleProof, sellerAllowList(seller), _msgSender());
} else if ( amount > REPUTATION_LOWERBOUND && msg.sender == _msgSender() ) {
@@ -178,7 +186,8 @@ contract P2PIX is BaseUtils {
amount,
token,
_msgSender(),
seller
seller,
bond
);
_addLock(bal, l);
@@ -237,7 +246,7 @@ contract P2PIX is BaseUtils {
SafeTransferLib.safeTransfer(
t,
l.buyerAddress,
lockAmount
l.bond ? lockAmount + lockAmount >> BOND_DIVISOR : lockAmount
);
emit LockReleased(l.buyerAddress, lockID, lockAmount);
@@ -266,7 +275,7 @@ contract P2PIX is BaseUtils {
if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND)
revert MaxBalExceeded();
_addSellerBalance(l.seller, l.token, l.amount);
_addSellerBalance(l.seller, l.token, l.bond ? l.amount + l.amount >> BOND_DIVISOR : l.amount);
l.amount = 0;

View File

@@ -94,3 +94,9 @@ uint256 REPUTATION_LOWERBOUND
uint256 LOCKAMOUNT_UPPERBOUND
```
### BOND_DIVISOR
```solidity
uint256 BOND_DIVISOR
```

View File

@@ -13,6 +13,7 @@ struct Lock {
contract ERC20 token;
address buyerAddress;
address seller;
bool bond;
}
```

View File

@@ -67,7 +67,7 @@ _Function sighash: 0x6d82d9e0_
### lock
```solidity
function lock(address seller, contract ERC20 token, uint80 amount, bytes32[] merkleProof, uint256[] expiredLocks) public returns (uint256 lockID)
function lock(address seller, contract ERC20 token, uint80 amount, bytes32[] merkleProof, uint256[] expiredLocks, bool bond) public returns (uint256 lockID)
```
Public method designed to lock an remaining amount of
@@ -78,7 +78,7 @@ to a seller whitelist.
This method can be performed either by:
- An user allowed via the seller's allowlist;
- An user with enough userRecord to lock the wished amount;
There can only exist a lock per each `_amount` partitioned
There can only exist a lock per each `amount` partitioned
from the total `remaining` value.
Locks can only be performed in valid orders.
@@ -93,6 +93,7 @@ _Function sighash: 0xdc43221c_
| amount | uint80 | The deposit's remaining amount wished to be locked. |
| merkleProof | bytes32[] | Provided as a pass if the `msg.sender` is in the seller's allowlist; Left empty otherwise; |
| expiredLocks | uint256[] | An array of identifiers to be provided so to unexpire locks using this transaction gas push. |
| bond | bool | |
#### Return Values

View File

@@ -38,7 +38,6 @@
"@nomicfoundation/hardhat-verify": "^2.1.0",
"@nomicfoundation/hardhat-viem": "^2.1.0",
"@nomicfoundation/ignition-core": "^0.15.13",
"@openzeppelin/contracts": "5.5.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/chai": "^4.3.20",

View File

@@ -615,6 +615,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
const fail2 = p2pix.lock(
zero,
@@ -622,6 +623,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
expect(fail).to.be.revertedWithCustomError(
@@ -651,6 +653,7 @@ describe("P2PIX", () => {
price * 2n,
[],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -676,6 +679,7 @@ describe("P2PIX", () => {
1000n,
[ethers.keccak256(ethers.toUtf8Bytes("wrong"))],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -703,6 +707,7 @@ describe("P2PIX", () => {
price * 2n,
[],
[],
false,
);
await expect(fail).to.be.revertedWithCustomError(
@@ -710,6 +715,42 @@ describe("P2PIX", () => {
P2PixErrors.AmountNotAllowed,
);
});
it("should override spend limit if buyer pays the bond", async () => {
await erc20.approve(
p2pix.address,
price.mul(3),
);
await p2pix.deposit(
"1",
merkleRoot,
erc20.address,
price.mul(3),
true,
);
await erc20
.transfer(
acc02.address,
price,
);
await erc20
.connect(acc02)
.approve(
p2pix.address,
price.mul(30000),
);
const bond = p2pix
.connect(acc02)
.lock(
owner.address,
erc20.address,
price.mul(2),
[],
[],
true,
);
await expect(bond).to.be.ok;
});
it("should create a lock, update storage and emit events via the allowlist path", async () => {
const target = "333";
await erc20.approve(p2pix.target, price);
@@ -728,6 +769,7 @@ describe("P2PIX", () => {
price,
proof,
[],
false,
);
const storage: Lock = await p2pix.mapLocks.staticCall(
1,
@@ -772,6 +814,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
const storage: Lock = await p2pix.mapLocks.staticCall(
1,
@@ -831,6 +874,7 @@ describe("P2PIX", () => {
price,
[],
[],
false,
);
await p2pix
.connect(acc01)
@@ -847,6 +891,7 @@ describe("P2PIX", () => {
price + 1n,
[],
[],
false,
);
const storage: Lock = await p2pix.mapLocks.staticCall(
2,
@@ -897,6 +942,7 @@ describe("P2PIX", () => {
newPrice,
proof,
[],
false,
);
const storage1: Lock = await p2pix.mapLocks.staticCall(
1,
@@ -913,6 +959,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const storage2: Lock = await p2pix.mapLocks.staticCall(
2,
@@ -929,6 +976,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const storage3: Lock = await p2pix.mapLocks.staticCall(
3,
@@ -1205,6 +1253,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const lockID = BigInt(1);
await mine(13);
@@ -1246,6 +1295,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const lockID = BigInt(1);
await p2pix.release(
@@ -1290,6 +1340,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
await p2pix
@@ -1307,6 +1358,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const fail = p2pix
.connect(acc01)
@@ -1348,6 +1400,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const fail = p2pix
.connect(acc01)
@@ -1404,6 +1457,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
const acc01Key = await p2pix._castAddrToKey.staticCall(
acc01.address,
@@ -1568,6 +1622,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[],
false,
);
await p2pix
.connect(acc03)
@@ -1577,6 +1632,7 @@ describe("P2PIX", () => {
BigInt(50),
[],
[],
false,
);
await p2pix
.connect(acc03)
@@ -1586,6 +1642,7 @@ describe("P2PIX", () => {
BigInt(25),
[],
[],
false,
);
const lockStatus1 =
@@ -1755,6 +1812,7 @@ describe("P2PIX", () => {
BigInt(1),
[],
[],
false,
);
const lockID = BigInt(1);
const fail = p2pix.unlockExpired([lockID]);
@@ -1793,6 +1851,7 @@ describe("P2PIX", () => {
BigInt(1),
[],
[],
false,
);
const lockID = BigInt(1);
// await mine(10);
@@ -1826,6 +1885,7 @@ describe("P2PIX", () => {
BigInt(1),
[],
[],
false,
);
const lockID = BigInt(1);
await mine(11);
@@ -1889,6 +1949,7 @@ describe("P2PIX", () => {
price,
proof,
[],
false,
);
// as return values of non view functions can't be accessed
// outside the evm, we fetch the lockID from the emitted event.
@@ -1928,6 +1989,7 @@ describe("P2PIX", () => {
BigInt(100),
[],
[lockID],
false
);
const remaining = await p2pix.getBalance.staticCall(
owner.address,
@@ -1961,6 +2023,7 @@ describe("P2PIX", () => {
price,
proof,
[],
false,
);
const lockID = BigInt(1);
// mine blocks to expire lock

View File

@@ -988,13 +988,6 @@ __metadata:
languageName: node
linkType: hard
"@openzeppelin/contracts@npm:5.5.0":
version: 5.5.0
resolution: "@openzeppelin/contracts@npm:5.5.0"
checksum: 10/5eb1a201e2e324280292077f68c8a4a2e450762798d3c990741b540b1b218c4fed143901647f8519e9abe239017bd29a455cb7e43aff25918ef110e4cdea7013
languageName: node
linkType: hard
"@pkgjs/parseargs@npm:^0.11.0":
version: 0.11.0
resolution: "@pkgjs/parseargs@npm:0.11.0"
@@ -4570,7 +4563,6 @@ __metadata:
"@nomicfoundation/hardhat-verify": "npm:^2.1.0"
"@nomicfoundation/hardhat-viem": "npm:^2.1.0"
"@nomicfoundation/ignition-core": "npm:^0.15.13"
"@openzeppelin/contracts": "npm:5.5.0"
"@typechain/ethers-v6": "npm:^0.5.1"
"@typechain/hardhat": "npm:^9.1.0"
"@types/chai": "npm:^4.3.20"