Finished pending tasks
This commit is contained in:
parent
da18941198
commit
934a9abe45
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -3,11 +3,21 @@
|
||||
"contractName": "EventAndErrors",
|
||||
"sourceName": "contracts/EventAndErrors.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AddressDenied",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AlreadyReleased",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "AmountNotAllowed",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "DepositAlreadyExists",
|
||||
@ -23,11 +33,21 @@
|
||||
"name": "InvalidSigner",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "LengthMismatch",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "LoopOverflow",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NoTokens",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "NotEnoughTokens",
|
||||
@ -43,11 +63,35 @@
|
||||
"name": "OnlySeller",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "TokenDenied",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "TxAlreadyUsed",
|
||||
"type": "error"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "bool",
|
||||
"name": "state",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"name": "AllowedERC20Updated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
@ -173,6 +217,19 @@
|
||||
"name": "LockAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "blocks",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "LockBlocksUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
@ -210,6 +267,32 @@
|
||||
],
|
||||
"name": "LockReturned",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address",
|
||||
"name": "reputation",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "ReputationUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "address[]",
|
||||
"name": "signers",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"name": "ValidSignersUpdated",
|
||||
"type": "event"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
|
4
artifacts/contracts/Reputation.sol/Reputation.dbg.json
Normal file
4
artifacts/contracts/Reputation.sol/Reputation.dbg.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
106
artifacts/contracts/Reputation.sol/Reputation.json
Normal file
106
artifacts/contracts/Reputation.sol/Reputation.json
Normal file
@ -0,0 +1,106 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "Reputation",
|
||||
"sourceName": "contracts/Reputation.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "user",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnerUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_userCredit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "limiter",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_spendLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "magicValue",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "maxLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setOwner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350610347806100616000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80634d2b1791116100505780634d2b17911461009e5780638da5cb5b146100b1578063a4b34557146100dc57600080fd5b806313af40351461006c5780631a861d2614610081575b600080fd5b61007f61007a3660046102f8565b6100e8565b005b61008b620f424081565b6040519081526020015b60405180910390f35b61008b6100ac366004610321565b6101a9565b6000546100c4906001600160a01b031681565b6040516001600160a01b039091168152602001610095565b61008b643a3529440081565b6000546001600160a01b031633146101465760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015260640160405180910390fd5b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6000806101b9620f4240846101fa565b905060006101c784806101fa565b905060006101e26101dd83643a352944006101fa565b610216565b90506101ee83826102c8565b60010195945050505050565b600061020f8383670de0b6b3a76400006102d9565b9392505050565b60b58171010000000000000000000000000000000000811061023d5760409190911b9060801c5b690100000000000000000081106102595760209190911b9060401c5b6501000000000081106102715760109190911b9060201c5b630100000081106102875760089190911b9060101c5b62010000010260121c80820401600190811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b600061020f83670de0b6b3a7640000845b8282028115158415858304851417166102f157600080fd5b0492915050565b60006020828403121561030a57600080fd5b81356001600160a01b038116811461020f57600080fd5b60006020828403121561033357600080fd5b503591905056fea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100675760003560e01c80634d2b1791116100505780634d2b17911461009e5780638da5cb5b146100b1578063a4b34557146100dc57600080fd5b806313af40351461006c5780631a861d2614610081575b600080fd5b61007f61007a3660046102f8565b6100e8565b005b61008b620f424081565b6040519081526020015b60405180910390f35b61008b6100ac366004610321565b6101a9565b6000546100c4906001600160a01b031681565b6040516001600160a01b039091168152602001610095565b61008b643a3529440081565b6000546001600160a01b031633146101465760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015260640160405180910390fd5b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6000806101b9620f4240846101fa565b905060006101c784806101fa565b905060006101e26101dd83643a352944006101fa565b610216565b90506101ee83826102c8565b60010195945050505050565b600061020f8383670de0b6b3a76400006102d9565b9392505050565b60b58171010000000000000000000000000000000000811061023d5760409190911b9060801c5b690100000000000000000081106102595760209190911b9060401c5b6501000000000081106102715760109190911b9060201c5b630100000081106102875760089190911b9060101c5b62010000010260121c80820401600190811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b600061020f83670de0b6b3a7640000845b8282028115158415858304851417166102f157600080fd5b0492915050565b60006020828403121561030a57600080fd5b81356001600160a01b038116811461020f57600080fd5b60006020828403121561033357600080fd5b503591905056fea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "IReputation",
|
||||
"sourceName": "contracts/lib/interfaces/IReputation.sol",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_userCredit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "limiter",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_spendLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
}
|
||||
],
|
||||
"bytecode": "0x",
|
||||
"deployedBytecode": "0x",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "FixedPointMathLib",
|
||||
"sourceName": "contracts/lib/utils/FixedPointMathLib.sol",
|
||||
"abi": [],
|
||||
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"_format": "hh-sol-artifact-1",
|
||||
"contractName": "MerkleProofLib",
|
||||
"sourceName": "contracts/lib/utils/MerkleProofLib.sol",
|
||||
"abi": [],
|
||||
"bytecode": "0x602d6037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea164736f6c6343000809000a",
|
||||
"linkReferences": {},
|
||||
"deployedLinkReferences": {}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/0d20d1f12753266e5824cbfb8a85b2b2.json"
|
||||
"buildInfo": "../../build-info/eddb8a89a5d02f0c81c1106939df9c5f.json"
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -23,8 +23,11 @@ library DataTypes {
|
||||
/// @dev If not paid at this block will be expired.
|
||||
uint256 expirationBlock;
|
||||
/// @dev Where the tokens are sent the when order gets validated.
|
||||
address targetAddress;
|
||||
/// @dev Relayer address that facilitated this transaction.
|
||||
address buyerAddress;
|
||||
/// @dev Relayer's target address that receives `relayerPremium` funds.
|
||||
address relayerTarget;
|
||||
/// @dev Relayer address (msg.sender) that facilitated this transaction.
|
||||
/// @dev Reputation points accruer.
|
||||
address relayerAddress;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
pragma solidity 0.8.9;
|
||||
|
||||
interface EventAndErrors {
|
||||
// bytes32 constant DEPOSIT_ADDED_SIGNATURE =
|
||||
|
||||
/// ███ Events ████████████████████████████████████████████████████████████
|
||||
|
||||
@ -26,17 +27,15 @@ interface EventAndErrors {
|
||||
uint256 depositID,
|
||||
uint256 amount
|
||||
);
|
||||
event LockReleased(
|
||||
address indexed buyer,
|
||||
bytes32 lockId
|
||||
);
|
||||
event LockReturned(
|
||||
address indexed buyer,
|
||||
bytes32 lockId
|
||||
);
|
||||
event FundsWithdrawn(
|
||||
address owner,
|
||||
uint256 amount
|
||||
event LockReleased(address indexed buyer, bytes32 lockId);
|
||||
event LockReturned(address indexed buyer, bytes32 lockId);
|
||||
event FundsWithdrawn(address owner, uint256 amount);
|
||||
event ReputationUpdated(address reputation);
|
||||
event LockBlocksUpdated(uint256 blocks);
|
||||
event ValidSignersUpdated(address[] signers);
|
||||
event AllowedERC20Updated(
|
||||
address indexed token,
|
||||
bool indexed state
|
||||
);
|
||||
|
||||
/// ███ Errors ████████████████████████████████████████████████████████████
|
||||
@ -45,6 +44,7 @@ interface EventAndErrors {
|
||||
/// @dev 0xc44bd765
|
||||
error DepositAlreadyExists();
|
||||
/// @dev Only seller could call this function.
|
||||
/// @dev `msg.sender` and the seller differ.
|
||||
/// @dev 0x85d1f726
|
||||
error OnlySeller();
|
||||
/// @dev Lock not expired or already released.
|
||||
@ -69,4 +69,20 @@ interface EventAndErrors {
|
||||
/// @dev Signer is not a valid signer.
|
||||
/// @dev 0x815e1d64
|
||||
error InvalidSigner();
|
||||
/// @dev Address doesn't exist in a MerkleTree.
|
||||
/// @dev Address not allowed as relayer.
|
||||
/// @dev 0x3b8474be
|
||||
error AddressDenied();
|
||||
/// @dev Arrays' length don't match.
|
||||
/// @dev 0xff633a38
|
||||
error LengthMismatch();
|
||||
/// @dev No tokens array provided as argument.
|
||||
/// @dev 0xdf957883
|
||||
error NoTokens();
|
||||
/// @dev Token address not allowed to be deposited.
|
||||
/// @dev 0x1578328e
|
||||
error TokenDenied();
|
||||
/// @dev Wished amount to be locked exceeds the limit allowed.
|
||||
/// @dev 0x1c18f846
|
||||
error AmountNotAllowed();
|
||||
}
|
||||
|
45
contracts/Reputation.sol
Normal file
45
contracts/Reputation.sol
Normal file
@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.9;
|
||||
|
||||
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
||||
import { Owned } from "./lib/auth/Owned.sol";
|
||||
import { FixedPointMathLib as WADMath } from "./lib/utils/FixedPointMathLib.sol";
|
||||
|
||||
|
||||
contract Reputation is
|
||||
IReputation,
|
||||
Owned(msg.sender)
|
||||
{
|
||||
|
||||
using WADMath for uint256;
|
||||
|
||||
/// @dev Asymptote numerator constant value for the `limiter` fx.
|
||||
uint256 constant public maxLimit = 1e6;
|
||||
/// @dev Denominator's constant operand for the `limiter` fx.
|
||||
uint256 constant public magicValue = 2.5e11;
|
||||
|
||||
constructor(/* */) {/* */}
|
||||
|
||||
function limiter(uint256 _userCredit)
|
||||
external
|
||||
pure
|
||||
override(IReputation)
|
||||
returns(uint256 _spendLimit)
|
||||
{
|
||||
// _spendLimit = 1 + ( ( maxLimit * _userCredit ) / sqrt( magicValue * ( _userCredit * _userCredit ) ) );
|
||||
// return _spendLimit;
|
||||
|
||||
|
||||
unchecked {
|
||||
uint256 numeratorWad =
|
||||
maxLimit.mulWadDown(_userCredit);
|
||||
uint256 userCreditSquaredWad =
|
||||
_userCredit.mulWadDown(_userCredit);
|
||||
uint256 denominatorSqrtWad =
|
||||
(userCreditSquaredWad.mulWadDown(magicValue)).sqrt();
|
||||
|
||||
_spendLimit = (1 + (numeratorWad).divWadDown(denominatorSqrtWad));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
12
contracts/lib/interfaces/IReputation.sol
Normal file
12
contracts/lib/interfaces/IReputation.sol
Normal file
@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
|
||||
interface IReputation {
|
||||
|
||||
function limiter(uint256 _userCredit)
|
||||
external
|
||||
pure
|
||||
returns(uint256 _spendLimit);
|
||||
|
||||
}
|
115
contracts/lib/utils/FixedPointMathLib.sol
Normal file
115
contracts/lib/utils/FixedPointMathLib.sol
Normal file
@ -0,0 +1,115 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.4;
|
||||
|
||||
/// @notice Arithmetic library with operations for fixed-point numbers.
|
||||
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)
|
||||
library FixedPointMathLib {
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
SIMPLIFIED FIXED POINT OPERATIONS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
/// @dev The scalar of ETH and most ERC20s.
|
||||
uint256 internal constant WAD = 1e18;
|
||||
|
||||
function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
|
||||
// Equivalent to (x * y) / WAD rounded down.
|
||||
return mulDivDown(x, y, WAD);
|
||||
}
|
||||
|
||||
function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
|
||||
// Equivalent to (x * WAD) / y rounded down.
|
||||
return mulDivDown(x, WAD, y);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
LOW LEVEL FIXED POINT OPERATIONS
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
function mulDivDown(
|
||||
uint256 x,
|
||||
uint256 y,
|
||||
uint256 denominator
|
||||
) internal pure returns (uint256 z) {
|
||||
assembly {
|
||||
// Store x * y in z for now.
|
||||
z := mul(x, y)
|
||||
|
||||
// Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
|
||||
if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
|
||||
revert(0, 0)
|
||||
}
|
||||
|
||||
// Divide z by the denominator.
|
||||
z := div(z, denominator)
|
||||
}
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////
|
||||
GENERAL NUMBER UTILITIES
|
||||
//////////////////////////////////////////////////////////////*/
|
||||
|
||||
function sqrt(uint256 x) internal pure returns (uint256 z) {
|
||||
assembly {
|
||||
let y := x // We start y at x, which will help us make our initial estimate.
|
||||
|
||||
z := 181 // The "correct" value is 1, but this saves a multiplication later.
|
||||
|
||||
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
|
||||
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
|
||||
|
||||
// We check y >= 2^(k + 8) but shift right by k bits
|
||||
// each branch to ensure that if x >= 256, then y >= 256.
|
||||
if iszero(lt(y, 0x10000000000000000000000000000000000)) {
|
||||
y := shr(128, y)
|
||||
z := shl(64, z)
|
||||
}
|
||||
if iszero(lt(y, 0x1000000000000000000)) {
|
||||
y := shr(64, y)
|
||||
z := shl(32, z)
|
||||
}
|
||||
if iszero(lt(y, 0x10000000000)) {
|
||||
y := shr(32, y)
|
||||
z := shl(16, z)
|
||||
}
|
||||
if iszero(lt(y, 0x1000000)) {
|
||||
y := shr(16, y)
|
||||
z := shl(8, z)
|
||||
}
|
||||
|
||||
// Goal was to get z*z*y within a small factor of x. More iterations could
|
||||
// get y in a tighter range. Currently, we will have y in [256, 256*2^16).
|
||||
// We ensured y >= 256 so that the relative difference between y and y+1 is small.
|
||||
// That's not possible if x < 256 but we can just verify those cases exhaustively.
|
||||
|
||||
// Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
|
||||
// Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
|
||||
// Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.
|
||||
|
||||
// For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
|
||||
// (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.
|
||||
|
||||
// Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
|
||||
// sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.
|
||||
|
||||
// There is no overflow risk here since y < 2^136 after the first branch above.
|
||||
z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.
|
||||
|
||||
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
z := shr(1, add(z, div(x, z)))
|
||||
|
||||
// If x+1 is a perfect square, the Babylonian method cycles between
|
||||
// floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
|
||||
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
|
||||
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
|
||||
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
|
||||
z := sub(z, lt(div(x, z), z))
|
||||
}
|
||||
}
|
||||
}
|
43
contracts/lib/utils/MerkleProofLib.sol
Normal file
43
contracts/lib/utils/MerkleProofLib.sol
Normal file
@ -0,0 +1,43 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ pragma solidity 0.8.9;
|
||||
import { Owned } from "./lib/auth/Owned.sol";
|
||||
import { Counters } from "./lib/utils/Counters.sol";
|
||||
import { ERC20, SafeTransferLib } from "./lib/utils/SafeTransferLib.sol";
|
||||
import { IReputation } from "./lib/interfaces/IReputation.sol";
|
||||
import { MerkleProofLib as Merkle } from "./lib/utils/MerkleProofLib.sol";
|
||||
import { ReentrancyGuard } from "./lib/utils/ReentrancyGuard.sol";
|
||||
import { EventAndErrors } from "./EventAndErrors.sol";
|
||||
import { DataTypes as DT } from "./DataTypes.sol";
|
||||
@ -29,12 +31,14 @@ contract P2PIX is
|
||||
|
||||
/// ███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
IReputation public reputation;
|
||||
Counters.Counter public depositCount;
|
||||
|
||||
/// @dev Default blocks that lock will hold tokens.
|
||||
uint256 public defaultLockBlocks;
|
||||
|
||||
|
||||
/// @dev Stores an relayer's last computed credit.
|
||||
mapping(uint256 => uint256) public userRecord;
|
||||
/// @dev List of valid Bacen signature addresses
|
||||
mapping(uint256 => bool) public validBacenSigners;
|
||||
/// @dev Seller list of deposits
|
||||
@ -43,25 +47,24 @@ contract P2PIX is
|
||||
mapping(bytes32 => DT.Lock) public mapLocks;
|
||||
/// @dev List of Pix transactions already signed.
|
||||
mapping(bytes32 => bool) private usedTransactions;
|
||||
/// @dev Seller casted to key => Seller's allowlist merkleroot.
|
||||
mapping(uint256 => bytes32) public sellerAllowList;
|
||||
/// @dev Tokens allowed to serve as the underlying amount of a deposit.
|
||||
mapping(ERC20 => bool) public allowedERC20s;
|
||||
|
||||
/// ███ Constructor ████████████████████████████████████████████████████████
|
||||
|
||||
constructor(
|
||||
uint256 defaultBlocks,
|
||||
address[] memory validSigners
|
||||
address[] memory validSigners,
|
||||
IReputation _reputation,
|
||||
address[] memory tokens,
|
||||
bool[] memory tokenStates
|
||||
) payable {
|
||||
assembly {
|
||||
sstore(defaultLockBlocks.slot, defaultBlocks)
|
||||
}
|
||||
unchecked {
|
||||
uint256 i;
|
||||
uint256 len = validSigners.length;
|
||||
for (i; i < len; ) {
|
||||
uint256 key = _castAddrToKey(validSigners[i]);
|
||||
validBacenSigners[key] = true;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
setDefaultLockBlocks(defaultBlocks);
|
||||
setReputation(_reputation);
|
||||
setValidSigners(validSigners);
|
||||
tokenSettings(tokens, tokenStates);
|
||||
}
|
||||
|
||||
/// ███ Public FX ██████████████████████████████████████████████████████████
|
||||
@ -70,22 +73,27 @@ contract P2PIX is
|
||||
/// offer of an amount of ERC20 tokens.
|
||||
/// @dev Seller needs to send his tokens to the P2PIX smart contract.
|
||||
/// @param _pixTarget Pix key destination provided by the offer's seller.
|
||||
/// @param allowlistRoot Optional allow list merkleRoot update `bytes32` value.
|
||||
/// @return depositID The `uint256` return value provided
|
||||
/// as the deposit identifier.
|
||||
/// @dev Function sighash: 0xbfe07da6.
|
||||
function deposit(
|
||||
address _token,
|
||||
uint256 _amount,
|
||||
string calldata _pixTarget
|
||||
string calldata _pixTarget,
|
||||
bytes32 allowlistRoot
|
||||
)
|
||||
public
|
||||
returns (uint256 depositID)
|
||||
returns (
|
||||
uint256 depositID
|
||||
)
|
||||
{
|
||||
(depositID) = _encodeDepositID();
|
||||
ERC20 t = ERC20(_token);
|
||||
if (!allowedERC20s[t]) revert TokenDenied();
|
||||
|
||||
DT.Deposit memory d =
|
||||
DT.Deposit({
|
||||
(depositID) = _encodeDepositID();
|
||||
|
||||
DT.Deposit memory d = DT.Deposit({
|
||||
remaining: _amount,
|
||||
pixTarget: _pixTarget,
|
||||
seller: msg.sender,
|
||||
@ -95,6 +103,10 @@ contract P2PIX is
|
||||
|
||||
setReentrancyGuard();
|
||||
|
||||
if (allowlistRoot != 0) {
|
||||
setRoot(msg.sender, allowlistRoot);
|
||||
}
|
||||
|
||||
mapDeposits[depositID] = d;
|
||||
depositCount.increment();
|
||||
|
||||
@ -120,9 +132,7 @@ contract P2PIX is
|
||||
/// @dev This function does not affect any ongoing active locks.
|
||||
/// @dev Function sighash: 0x72fada5c.
|
||||
|
||||
function cancelDeposit(
|
||||
uint256 depositID
|
||||
) public {
|
||||
function cancelDeposit(uint256 depositID) public {
|
||||
_onlySeller(depositID);
|
||||
mapDeposits[depositID].valid = false;
|
||||
emit DepositClosed(
|
||||
@ -133,91 +143,126 @@ contract P2PIX is
|
||||
|
||||
/// @notice Public method designed to lock an remaining amount of
|
||||
/// the deposit order of a seller.
|
||||
/// @dev This method can be performed by either an order's seller,
|
||||
/// relayer, or buyer.
|
||||
/// @dev 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;
|
||||
/// @dev There can only exist a lock per each `_amount` partitioned
|
||||
/// from the total `remaining` value.
|
||||
/// @dev Locks can only be performed in valid orders.
|
||||
/// @param _targetAddress The address of the buyer of a `_depositID`.
|
||||
/// @param _relayerAddress The relayer's address.
|
||||
/// @param _buyerAddress The address of the buyer of a `_depositID`.
|
||||
/// @param _relayerTarget Target address entitled to the `relayerPremim`.
|
||||
/// @param _relayerPremium The refund/premium owed to a relayer.
|
||||
/// @param _amount The deposit's remaining amount wished to be locked.
|
||||
/// @param merkleProof This value should be:
|
||||
/// - Provided as a pass if the `msg.sender` is in the seller's allowlist;
|
||||
/// - Left empty otherwise;
|
||||
/// @param expiredLocks An array of `bytes32` identifiers to be
|
||||
/// provided so to unexpire locks using this transaction gas push.
|
||||
/// @return lockID The `bytes32` value returned as the lock identifier.
|
||||
/// @dev Function sighash: 0x03aaf306.
|
||||
function lock(
|
||||
uint256 _depositID,
|
||||
address _targetAddress,
|
||||
address _relayerAddress,
|
||||
address _buyerAddress,
|
||||
address _relayerTarget,
|
||||
uint256 _relayerPremium,
|
||||
uint256 _amount,
|
||||
bytes32[] calldata merkleProof,
|
||||
bytes32[] calldata expiredLocks
|
||||
)
|
||||
public
|
||||
nonReentrant
|
||||
returns (bytes32 lockID)
|
||||
{
|
||||
) public nonReentrant returns (bytes32 lockID) {
|
||||
unlockExpired(expiredLocks);
|
||||
DT.Deposit storage d =
|
||||
mapDeposits[_depositID];
|
||||
DT.Deposit storage d = mapDeposits[_depositID];
|
||||
|
||||
if(!d.valid)
|
||||
revert InvalidDeposit();
|
||||
if(d.remaining < _amount)
|
||||
revert NotEnoughTokens();
|
||||
(lockID) =
|
||||
_encodeLockID(
|
||||
if (!d.valid) revert InvalidDeposit();
|
||||
if (d.remaining < _amount) revert NotEnoughTokens();
|
||||
|
||||
(lockID) = _encodeLockID(
|
||||
_depositID,
|
||||
_amount,
|
||||
_targetAddress
|
||||
_buyerAddress
|
||||
);
|
||||
|
||||
DT.Lock memory l =
|
||||
DT.Lock
|
||||
({
|
||||
DT.Lock memory l = DT.Lock({
|
||||
depositID: _depositID,
|
||||
relayerPremium: _relayerPremium,
|
||||
amount: _amount,
|
||||
expirationBlock: (block.number + defaultLockBlocks),
|
||||
targetAddress: _targetAddress,
|
||||
relayerAddress: _relayerAddress
|
||||
expirationBlock: (block.number +
|
||||
defaultLockBlocks),
|
||||
buyerAddress: _buyerAddress,
|
||||
relayerTarget: _relayerTarget,
|
||||
relayerAddress: msg.sender
|
||||
});
|
||||
|
||||
if (merkleProof.length != 0) {
|
||||
merkleVerify(
|
||||
merkleProof,
|
||||
sellerAllowList[_castAddrToKey(d.seller)],
|
||||
msg.sender
|
||||
);
|
||||
|
||||
mapLocks[lockID] = l;
|
||||
d.remaining -= _amount;
|
||||
|
||||
emit LockAdded(
|
||||
_targetAddress,
|
||||
_buyerAddress,
|
||||
lockID,
|
||||
_depositID,
|
||||
l.depositID,
|
||||
_amount
|
||||
);
|
||||
|
||||
// Halt execution and output `lockID`.
|
||||
return lockID;
|
||||
}
|
||||
else {
|
||||
uint256 userCredit = userRecord[
|
||||
_castAddrToKey(msg.sender)
|
||||
];
|
||||
uint256 spendLimit;
|
||||
(spendLimit) = _limiter(userCredit);
|
||||
|
||||
if (l.amount > spendLimit)
|
||||
revert AmountNotAllowed();
|
||||
|
||||
mapLocks[lockID] = l;
|
||||
d.remaining -= _amount;
|
||||
|
||||
emit LockAdded(
|
||||
_buyerAddress,
|
||||
lockID,
|
||||
l.depositID,
|
||||
_amount
|
||||
);
|
||||
|
||||
// Halt execution and output `lockID`.
|
||||
return lockID;
|
||||
}
|
||||
}
|
||||
|
||||
/// @notice Lock release method that liquidate lock
|
||||
// orders and distributes relayer fees.
|
||||
/// @dev This method can be called by either an
|
||||
/// order's seller, relayer, or buyer.
|
||||
/// orders and distributes relayer fees.
|
||||
/// @dev This method can be called by any public actor
|
||||
/// as long the signature provided is valid.
|
||||
/// @dev `relayerPremium` gets splitted equaly
|
||||
/// if `relayerTarget` addresses differ.
|
||||
/// @dev If the `msg.sender` of this method and `l.relayerAddress` are the same,
|
||||
/// `msg.sender` accrues both l.amount and l.relayerPremium as userRecord credit.
|
||||
/// In case of they differing:
|
||||
/// - `lock` caller gets accrued with `l.amount` as userRecord credit;
|
||||
/// - `release` caller gets accrued with `l.relayerPremium` as userRecord credit;
|
||||
/// @param _relayerTarget Target address entitled to the `relayerPremim`.
|
||||
/// @dev Function sighash: 0x4e1389ed.
|
||||
function release(
|
||||
bytes32 lockID,
|
||||
address _relayerTarget,
|
||||
uint256 pixTimestamp,
|
||||
bytes32 r,
|
||||
bytes32 s,
|
||||
uint8 v
|
||||
)
|
||||
public
|
||||
nonReentrant
|
||||
{
|
||||
/// @todo Prevent a PIX non-related to the app from
|
||||
/// getting targeted, due to both sharing the same destination.
|
||||
) public nonReentrant {
|
||||
DT.Lock storage l = mapLocks[lockID];
|
||||
|
||||
if(
|
||||
l.expirationBlock <= block.number ||
|
||||
l.amount <= 0
|
||||
) revert
|
||||
AlreadyReleased();
|
||||
if (
|
||||
l.expirationBlock <= block.number || l.amount <= 0
|
||||
) revert AlreadyReleased();
|
||||
|
||||
DT.Deposit storage d = mapDeposits[l.depositID];
|
||||
bytes32 message = keccak256(
|
||||
@ -234,21 +279,14 @@ contract P2PIX is
|
||||
)
|
||||
);
|
||||
|
||||
if(
|
||||
usedTransactions[message]
|
||||
== true
|
||||
) revert
|
||||
TxAlreadyUsed();
|
||||
if (usedTransactions[message] == true)
|
||||
revert TxAlreadyUsed();
|
||||
|
||||
uint256 signer = _castAddrToKey(
|
||||
ecrecover(
|
||||
messageDigest,
|
||||
v,
|
||||
r,
|
||||
s
|
||||
));
|
||||
ecrecover(messageDigest, v, r, s)
|
||||
);
|
||||
|
||||
if(!validBacenSigners[signer])
|
||||
if (!validBacenSigners[signer])
|
||||
revert InvalidSigner();
|
||||
|
||||
ERC20 t = ERC20(d.token);
|
||||
@ -260,52 +298,78 @@ contract P2PIX is
|
||||
l.expirationBlock = 0;
|
||||
usedTransactions[message] = true;
|
||||
|
||||
if (msg.sender != l.relayerAddress) {
|
||||
userRecord[_castAddrToKey(msg.sender)] += l
|
||||
.relayerPremium;
|
||||
userRecord[_castAddrToKey(l.relayerAddress)] += l
|
||||
.amount;
|
||||
} else {
|
||||
userRecord[_castAddrToKey(msg.sender)] += (l
|
||||
.relayerPremium + l.amount);
|
||||
}
|
||||
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
l.targetAddress,
|
||||
l.buyerAddress,
|
||||
totalAmount
|
||||
);
|
||||
|
||||
// Method doesn't check for zero address.
|
||||
if (l.relayerPremium != 0) {
|
||||
if (_relayerTarget != l.relayerTarget) {
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
l.relayerAddress,
|
||||
l.relayerTarget,
|
||||
(l.relayerPremium >> 1)
|
||||
);
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
_relayerTarget,
|
||||
(l.relayerPremium >> 1)
|
||||
);
|
||||
} else {
|
||||
SafeTransferLib.safeTransfer(
|
||||
t,
|
||||
_relayerTarget,
|
||||
l.relayerPremium
|
||||
);
|
||||
}
|
||||
|
||||
emit LockReleased(
|
||||
l.targetAddress,
|
||||
lockID
|
||||
);
|
||||
}
|
||||
|
||||
emit LockReleased(l.buyerAddress, lockID);
|
||||
}
|
||||
|
||||
/// @notice Unlocks expired locks.
|
||||
/// @dev Triggered in the callgraph by both `lock` and `withdraw` functions.
|
||||
/// @dev This method can also have any public actor as its `tx.origin`.
|
||||
/// @dev For each successfull unexpired lock recovered,
|
||||
/// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.
|
||||
/// @dev Function sighash: 0x8e2749d6.
|
||||
function unlockExpired(
|
||||
bytes32[] calldata lockIDs
|
||||
) public {
|
||||
uint256 i;
|
||||
uint256 locksSize =
|
||||
lockIDs.length;
|
||||
|
||||
for (i; i < locksSize;)
|
||||
function unlockExpired(bytes32[] calldata lockIDs)
|
||||
public
|
||||
{
|
||||
uint256 i;
|
||||
uint256 locksSize = lockIDs.length;
|
||||
|
||||
for (i; i < locksSize; ) {
|
||||
DT.Lock storage l = mapLocks[lockIDs[i]];
|
||||
|
||||
_notExpired(l);
|
||||
|
||||
mapDeposits[l.depositID].remaining
|
||||
+= l.amount;
|
||||
mapDeposits[l.depositID].remaining += l.amount;
|
||||
l.amount = 0;
|
||||
|
||||
emit LockReturned(
|
||||
l.targetAddress,
|
||||
lockIDs[i]
|
||||
);
|
||||
uint256 userKey =
|
||||
_castAddrToKey(l.relayerAddress);
|
||||
uint256 _newUserRecord =
|
||||
(userRecord[userKey] >> 1);
|
||||
|
||||
if (_newUserRecord <= 100) {
|
||||
userRecord[userKey] = 100;
|
||||
} else {
|
||||
userRecord[userKey] = _newUserRecord;
|
||||
}
|
||||
emit LockReturned(l.buyerAddress, lockIDs[i]);
|
||||
|
||||
unchecked {
|
||||
++i;
|
||||
@ -315,14 +379,8 @@ contract P2PIX is
|
||||
assembly {
|
||||
if lt(i, locksSize) {
|
||||
// LoopOverflow()
|
||||
mstore(
|
||||
0x00,
|
||||
0xdfb035c9
|
||||
)
|
||||
revert(
|
||||
0x1c,
|
||||
0x04
|
||||
)
|
||||
mstore(0x00, 0xdfb035c9)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -334,15 +392,11 @@ contract P2PIX is
|
||||
function withdraw(
|
||||
uint256 depositID,
|
||||
bytes32[] calldata expiredLocks
|
||||
)
|
||||
public
|
||||
nonReentrant
|
||||
{
|
||||
) public nonReentrant {
|
||||
_onlySeller(depositID);
|
||||
unlockExpired(expiredLocks);
|
||||
|
||||
DT.Deposit storage d =
|
||||
mapDeposits[depositID];
|
||||
DT.Deposit storage d = mapDeposits[depositID];
|
||||
|
||||
if (d.valid == true) {
|
||||
cancelDeposit(depositID);
|
||||
@ -355,34 +409,123 @@ contract P2PIX is
|
||||
d.remaining = 0;
|
||||
|
||||
// safeTransfer tokens to seller
|
||||
SafeTransferLib.safeTransfer(
|
||||
token,
|
||||
d.seller,
|
||||
amount
|
||||
);
|
||||
SafeTransferLib.safeTransfer(token, d.seller, amount);
|
||||
|
||||
emit DepositWithdrawn(
|
||||
msg.sender,
|
||||
depositID,
|
||||
amount
|
||||
);
|
||||
emit DepositWithdrawn(msg.sender, depositID, amount);
|
||||
}
|
||||
|
||||
function setRoot(address addr, bytes32 merkleroot)
|
||||
public
|
||||
{
|
||||
if (addr == msg.sender) {
|
||||
sellerAllowList[
|
||||
_castAddrToKey(addr)
|
||||
] = merkleroot;
|
||||
} else revert OnlySeller();
|
||||
}
|
||||
|
||||
/// ███ Owner Only █████████████████████████████████████████████████████████
|
||||
|
||||
/// @dev Contract's balance withdraw method.
|
||||
/// @dev Contract's underlying balance withdraw method.
|
||||
/// @dev Function sighash: 0x5fd8c710.
|
||||
function withdrawBalance() external onlyOwner {
|
||||
uint256 balance =
|
||||
address(this).balance;
|
||||
SafeTransferLib.safeTransferETH(
|
||||
msg.sender,
|
||||
balance
|
||||
);
|
||||
emit FundsWithdrawn(
|
||||
msg.sender,
|
||||
balance
|
||||
uint256 balance = address(this).balance;
|
||||
SafeTransferLib.safeTransferETH(msg.sender, balance);
|
||||
emit FundsWithdrawn(msg.sender, balance);
|
||||
}
|
||||
|
||||
function setReputation(IReputation _reputation)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
assembly {
|
||||
sstore(reputation.slot, _reputation)
|
||||
}
|
||||
emit ReputationUpdated(address(_reputation));
|
||||
}
|
||||
|
||||
function setDefaultLockBlocks(uint256 _blocks)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
assembly {
|
||||
sstore(defaultLockBlocks.slot, _blocks)
|
||||
}
|
||||
emit LockBlocksUpdated(_blocks);
|
||||
}
|
||||
|
||||
function setValidSigners(address[] memory _validSigners)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
unchecked {
|
||||
uint256 i;
|
||||
uint256 len = _validSigners.length;
|
||||
for (i; i < len; ) {
|
||||
uint256 key = _castAddrToKey(
|
||||
_validSigners[i]
|
||||
);
|
||||
validBacenSigners[key] = true;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
emit ValidSignersUpdated(_validSigners);
|
||||
}
|
||||
|
||||
function tokenSettings(
|
||||
address[] memory _tokens,
|
||||
bool[] memory _states
|
||||
) public onlyOwner {
|
||||
/* Yul Impl */
|
||||
assembly {
|
||||
// first 32 bytes eq to array's length
|
||||
let tLen := mload(_tokens)
|
||||
if iszero(tLen) {
|
||||
mstore(0x00, 0xdf957883)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
if iszero(eq(tLen, mload(_states))) {
|
||||
mstore(0x00, 0xff633a38)
|
||||
revert(0x1c, 0x04)
|
||||
}
|
||||
let tLoc := add(_tokens, 0x20)
|
||||
let sLoc := add(_states, 0x20)
|
||||
for {
|
||||
let end := add(tLoc, mul(tLen, 0x20))
|
||||
} iszero(eq(tLoc, end)) {
|
||||
tLoc := add(tLoc, 0x20)
|
||||
sLoc := add(sLoc, 0x20)
|
||||
} {
|
||||
mstore(0x00, mload(tLoc))
|
||||
mstore(0x20, allowedERC20s.slot)
|
||||
let mapSlot := keccak256(0x00, 0x40)
|
||||
sstore(mapSlot, mload(sLoc))
|
||||
log3(
|
||||
0,
|
||||
0,
|
||||
0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a,
|
||||
mload(tLoc),
|
||||
mload(sLoc)
|
||||
)
|
||||
}
|
||||
}
|
||||
/* Solidity Impl */
|
||||
// uint256 tLen = _tokens.length;
|
||||
// uint256 sLen = _states.length;
|
||||
|
||||
// if (tLen != sLen)
|
||||
// revert LengthMismatch();
|
||||
// if (tLen == 0)
|
||||
// revert NoTokens();
|
||||
|
||||
// uint256 i;
|
||||
// for (i; i > tLen;) {
|
||||
// allowedERC20s[ERC20(_tokens[i])] = _states[i];
|
||||
// emit AllowedERC20Updated(_tokens[i], _states[i]);
|
||||
// unchecked {
|
||||
// ++i;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// ███ Helper FX ██████████████████████████████████████████████████████████
|
||||
@ -393,33 +536,22 @@ contract P2PIX is
|
||||
/// @notice Access control private view method that
|
||||
/// performs auth check on an deposit's seller.
|
||||
/// @dev Function sighash: 0x4125a4d9.
|
||||
function _onlySeller(uint256 _depositID)
|
||||
private
|
||||
view
|
||||
{
|
||||
if (
|
||||
mapDeposits[_depositID].seller
|
||||
!= msg.sender
|
||||
) revert
|
||||
OnlySeller();
|
||||
function _onlySeller(uint256 _depositID) private view {
|
||||
if (mapDeposits[_depositID].seller != msg.sender)
|
||||
revert OnlySeller();
|
||||
}
|
||||
|
||||
/// @notice Private view auxiliar logic that reverts
|
||||
/// on a not expired lock passed as argument of the function.
|
||||
/// @dev Called exclusively by the `unlockExpired` method.
|
||||
/// @dev Function sighash: 0x74e2a0bb.
|
||||
function _notExpired(DT.Lock storage _l)
|
||||
private
|
||||
view
|
||||
{
|
||||
function _notExpired(DT.Lock storage _l) private view {
|
||||
// Custom Error Solidity Impl
|
||||
if
|
||||
(
|
||||
if (
|
||||
_l.expirationBlock >= block.number ||
|
||||
_l.amount <= 0
|
||||
) revert
|
||||
NotExpired();
|
||||
/*
|
||||
) revert NotExpired();
|
||||
/*
|
||||
// Custom Error Yul Impl
|
||||
assembly {
|
||||
if iszero(iszero(
|
||||
@ -454,11 +586,8 @@ contract P2PIX is
|
||||
returns (uint256 _depositID)
|
||||
{
|
||||
(_depositID) = depositCount.current();
|
||||
if (
|
||||
mapDeposits[_depositID].valid
|
||||
== true
|
||||
) revert
|
||||
DepositAlreadyExists();
|
||||
if (mapDeposits[_depositID].valid == true)
|
||||
revert DepositAlreadyExists();
|
||||
}
|
||||
|
||||
/// @notice Private view auxiliar logic that encodes/returns
|
||||
@ -470,19 +599,67 @@ contract P2PIX is
|
||||
function _encodeLockID(
|
||||
uint256 _depositID,
|
||||
uint256 _amount,
|
||||
address _targetAddress)
|
||||
private
|
||||
view
|
||||
returns (bytes32 _lockID)
|
||||
{
|
||||
address _buyerAddress
|
||||
) private view returns (bytes32 _lockID) {
|
||||
_lockID = keccak256(
|
||||
abi.encodePacked(_depositID, _amount, _targetAddress)
|
||||
abi.encodePacked(
|
||||
_depositID,
|
||||
_amount,
|
||||
_buyerAddress
|
||||
)
|
||||
);
|
||||
if (mapLocks[_lockID].expirationBlock >= block.number)
|
||||
revert NotExpired();
|
||||
}
|
||||
|
||||
function merkleVerify(
|
||||
bytes32[] calldata _merkleProof,
|
||||
bytes32 root,
|
||||
address _addr
|
||||
) private pure {
|
||||
if (
|
||||
mapLocks[_lockID].expirationBlock
|
||||
>= block.number
|
||||
) revert
|
||||
NotExpired();
|
||||
!Merkle.verify(
|
||||
_merkleProof,
|
||||
root,
|
||||
bytes32(uint256(uint160(_addr)))
|
||||
)
|
||||
) revert AddressDenied();
|
||||
}
|
||||
|
||||
function _limiter(uint256 _userCredit)
|
||||
internal
|
||||
view
|
||||
returns (uint256 _spendLimit)
|
||||
{
|
||||
// enconde the fx sighash and args
|
||||
bytes memory encodedParams = abi.encodeWithSelector(
|
||||
IReputation.limiter.selector,
|
||||
_userCredit
|
||||
);
|
||||
// cast the uninitialized return values to memory
|
||||
bool success;
|
||||
uint256 returnSize;
|
||||
uint256 returnValue;
|
||||
// perform staticcall from the stack w yul
|
||||
assembly {
|
||||
success := staticcall(
|
||||
// gas
|
||||
30000,
|
||||
// address
|
||||
sload(reputation.slot),
|
||||
// argsOffset
|
||||
add(encodedParams, 0x20),
|
||||
// argsSize
|
||||
mload(encodedParams),
|
||||
// retOffset
|
||||
0x00,
|
||||
// retSize
|
||||
0x20
|
||||
)
|
||||
returnSize := returndatasize()
|
||||
returnValue := mload(0x00)
|
||||
_spendLimit := returnValue
|
||||
}
|
||||
}
|
||||
|
||||
/// @notice Public method that handles `address`
|
||||
@ -493,10 +670,6 @@ contract P2PIX is
|
||||
pure
|
||||
returns (uint256 _key)
|
||||
{
|
||||
_key = uint256(
|
||||
uint160(
|
||||
address(
|
||||
_addr
|
||||
))) << 12;
|
||||
_key = uint256(uint160(address(_addr))) << 12;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,23 @@
|
||||
|
||||
## Events
|
||||
|
||||
### AllowedERC20Updated
|
||||
|
||||
```solidity
|
||||
event AllowedERC20Updated(address indexed token, bool indexed state)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | undefined |
|
||||
| state `indexed` | bool | undefined |
|
||||
|
||||
### DepositAdded
|
||||
|
||||
```solidity
|
||||
@ -101,6 +118,22 @@ event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID
|
||||
| depositID | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### LockBlocksUpdated
|
||||
|
||||
```solidity
|
||||
event LockBlocksUpdated(uint256 blocks)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| blocks | uint256 | undefined |
|
||||
|
||||
### LockReleased
|
||||
|
||||
```solidity
|
||||
@ -135,10 +168,53 @@ event LockReturned(address indexed buyer, bytes32 lockId)
|
||||
| buyer `indexed` | address | undefined |
|
||||
| lockId | bytes32 | undefined |
|
||||
|
||||
### ReputationUpdated
|
||||
|
||||
```solidity
|
||||
event ReputationUpdated(address reputation)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| reputation | address | undefined |
|
||||
|
||||
### ValidSignersUpdated
|
||||
|
||||
```solidity
|
||||
event ValidSignersUpdated(address[] signers)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| signers | address[] | undefined |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### AddressDenied
|
||||
|
||||
```solidity
|
||||
error AddressDenied()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Address doesn't exist in a MerkleTree.Address not allowed as relayer.0x3b8474be*
|
||||
|
||||
|
||||
### AlreadyReleased
|
||||
|
||||
```solidity
|
||||
@ -150,6 +226,17 @@ error AlreadyReleased()
|
||||
*Lock already released or returned.0x63b4904e*
|
||||
|
||||
|
||||
### AmountNotAllowed
|
||||
|
||||
```solidity
|
||||
error AmountNotAllowed()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Wished amount to be locked exceeds the limit allowed.0x1c18f846*
|
||||
|
||||
|
||||
### DepositAlreadyExists
|
||||
|
||||
```solidity
|
||||
@ -183,6 +270,17 @@ error InvalidSigner()
|
||||
*Signer is not a valid signer.0x815e1d64*
|
||||
|
||||
|
||||
### LengthMismatch
|
||||
|
||||
```solidity
|
||||
error LengthMismatch()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Arrays' length don't match.0xff633a38*
|
||||
|
||||
|
||||
### LoopOverflow
|
||||
|
||||
```solidity
|
||||
@ -194,6 +292,17 @@ error LoopOverflow()
|
||||
*Loop bounds have overflowed.0xdfb035c9*
|
||||
|
||||
|
||||
### NoTokens
|
||||
|
||||
```solidity
|
||||
error NoTokens()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*No tokens array provided as argument.0xdf957883*
|
||||
|
||||
|
||||
### NotEnoughTokens
|
||||
|
||||
```solidity
|
||||
@ -224,7 +333,18 @@ error OnlySeller()
|
||||
|
||||
|
||||
|
||||
*Only seller could call this function.0x85d1f726*
|
||||
*Only seller could call this function.`msg.sender` and the seller differ.0x85d1f726*
|
||||
|
||||
|
||||
### TokenDenied
|
||||
|
||||
```solidity
|
||||
error TokenDenied()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Token address not allowed to be deposited.0x1578328e*
|
||||
|
||||
|
||||
### TxAlreadyUsed
|
||||
|
319
docs/P2PIX.md
319
docs/P2PIX.md
@ -32,6 +32,28 @@ Public method that handles `address` to `uint256` safe type casting.
|
||||
|---|---|---|
|
||||
| _key | uint256 | undefined |
|
||||
|
||||
### allowedERC20s
|
||||
|
||||
```solidity
|
||||
function allowedERC20s(contract ERC20) external view returns (bool)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Tokens allowed to serve as the underlying amount of a deposit.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | contract ERC20 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bool | undefined |
|
||||
|
||||
### cancelDeposit
|
||||
|
||||
```solidity
|
||||
@ -68,7 +90,7 @@ function defaultLockBlocks() external view returns (uint256)
|
||||
### deposit
|
||||
|
||||
```solidity
|
||||
function deposit(address _token, uint256 _amount, string _pixTarget) external nonpayable returns (uint256 depositID)
|
||||
function deposit(address _token, uint256 _amount, string _pixTarget, bytes32 allowlistRoot) external nonpayable returns (uint256 depositID)
|
||||
```
|
||||
|
||||
Creates a deposit order based on a seller's offer of an amount of ERC20 tokens.
|
||||
@ -82,6 +104,7 @@ Creates a deposit order based on a seller's offer of an amount of ERC20 tok
|
||||
| _token | address | undefined |
|
||||
| _amount | uint256 | undefined |
|
||||
| _pixTarget | string | Pix key destination provided by the offer's seller. |
|
||||
| allowlistRoot | bytes32 | Optional allow list merkleRoot update `bytes32` value. |
|
||||
|
||||
#### Returns
|
||||
|
||||
@ -95,7 +118,7 @@ Creates a deposit order based on a seller's offer of an amount of ERC20 tok
|
||||
function depositCount() external view returns (uint256 _val)
|
||||
```
|
||||
|
||||
███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
|
||||
|
||||
|
||||
@ -109,22 +132,23 @@ function depositCount() external view returns (uint256 _val)
|
||||
### lock
|
||||
|
||||
```solidity
|
||||
function lock(uint256 _depositID, address _targetAddress, address _relayerAddress, uint256 _relayerPremium, uint256 _amount, bytes32[] expiredLocks) external nonpayable returns (bytes32 lockID)
|
||||
function lock(uint256 _depositID, address _buyerAddress, address _relayerTarget, uint256 _relayerPremium, uint256 _amount, bytes32[] merkleProof, bytes32[] expiredLocks) external nonpayable returns (bytes32 lockID)
|
||||
```
|
||||
|
||||
Public method designed to lock an remaining amount of the deposit order of a seller.
|
||||
|
||||
*This method can be performed by either an order's seller, relayer, or buyer.There can only exist a lock per each `_amount` partitioned from the total `remaining` value.Locks can only be performed in valid orders.Function sighash: 0x03aaf306.*
|
||||
*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 from the total `remaining` value.Locks can only be performed in valid orders.Function sighash: 0x03aaf306.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _depositID | uint256 | undefined |
|
||||
| _targetAddress | address | The address of the buyer of a `_depositID`. |
|
||||
| _relayerAddress | address | The relayer's address. |
|
||||
| _buyerAddress | address | The address of the buyer of a `_depositID`. |
|
||||
| _relayerTarget | address | Target address entitled to the `relayerPremim`. |
|
||||
| _relayerPremium | uint256 | The refund/premium owed to a relayer. |
|
||||
| _amount | uint256 | undefined |
|
||||
| _amount | uint256 | The deposit's remaining amount wished to be locked. |
|
||||
| merkleProof | bytes32[] | This value should be: - Provided as a pass if the `msg.sender` is in the seller's allowlist; - Left empty otherwise; |
|
||||
| expiredLocks | bytes32[] | An array of `bytes32` identifiers to be provided so to unexpire locks using this transaction gas push. |
|
||||
|
||||
#### Returns
|
||||
@ -162,7 +186,7 @@ function mapDeposits(uint256) external view returns (uint256 remaining, string p
|
||||
### mapLocks
|
||||
|
||||
```solidity
|
||||
function mapLocks(bytes32) external view returns (uint256 depositID, uint256 relayerPremium, uint256 amount, uint256 expirationBlock, address targetAddress, address relayerAddress)
|
||||
function mapLocks(bytes32) external view returns (uint256 depositID, uint256 relayerPremium, uint256 amount, uint256 expirationBlock, address buyerAddress, address relayerTarget, address relayerAddress)
|
||||
```
|
||||
|
||||
|
||||
@ -183,7 +207,8 @@ function mapLocks(bytes32) external view returns (uint256 depositID, uint256 rel
|
||||
| relayerPremium | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
| expirationBlock | uint256 | undefined |
|
||||
| targetAddress | address | undefined |
|
||||
| buyerAddress | address | undefined |
|
||||
| relayerTarget | address | undefined |
|
||||
| relayerAddress | address | undefined |
|
||||
|
||||
### owner
|
||||
@ -206,23 +231,79 @@ function owner() external view returns (address)
|
||||
### release
|
||||
|
||||
```solidity
|
||||
function release(bytes32 lockID, uint256 pixTimestamp, bytes32 r, bytes32 s, uint8 v) external nonpayable
|
||||
function release(bytes32 lockID, address _relayerTarget, uint256 pixTimestamp, bytes32 r, bytes32 s, uint8 v) external nonpayable
|
||||
```
|
||||
|
||||
Lock release method that liquidate lock orders and distributes relayer fees.
|
||||
|
||||
|
||||
*This method can be called by either an order's seller, relayer, or buyer.Function sighash: 0x4e1389ed.*
|
||||
*This method can be called by any public actor as long the signature provided is valid.`relayerPremium` gets splitted equaly if `relayerTarget` addresses differ.If the `msg.sender` of this method and `l.relayerAddress` are the same, `msg.sender` accrues both l.amount and l.relayerPremium as userRecord credit. In case of they differing: - `lock` caller gets accrued with `l.amount` as userRecord credit; - `release` caller gets accrued with `l.relayerPremium` as userRecord credit; Function sighash: 0x4e1389ed.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| lockID | bytes32 | undefined |
|
||||
| _relayerTarget | address | Target address entitled to the `relayerPremim`. |
|
||||
| pixTimestamp | uint256 | undefined |
|
||||
| r | bytes32 | undefined |
|
||||
| s | bytes32 | undefined |
|
||||
| v | uint8 | undefined |
|
||||
|
||||
### reputation
|
||||
|
||||
```solidity
|
||||
function reputation() external view returns (contract IReputation)
|
||||
```
|
||||
|
||||
███ Storage ████████████████████████████████████████████████████████████
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | contract IReputation | undefined |
|
||||
|
||||
### sellerAllowList
|
||||
|
||||
```solidity
|
||||
function sellerAllowList(uint256) external view returns (bytes32)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Seller casted to key => Seller's allowlist merkleroot.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | bytes32 | undefined |
|
||||
|
||||
### setDefaultLockBlocks
|
||||
|
||||
```solidity
|
||||
function setDefaultLockBlocks(uint256 _blocks) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _blocks | uint256 | undefined |
|
||||
|
||||
### setOwner
|
||||
|
||||
```solidity
|
||||
@ -239,6 +320,72 @@ function setOwner(address newOwner) external nonpayable
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
### setReputation
|
||||
|
||||
```solidity
|
||||
function setReputation(contract IReputation _reputation) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _reputation | contract IReputation | undefined |
|
||||
|
||||
### setRoot
|
||||
|
||||
```solidity
|
||||
function setRoot(address addr, bytes32 merkleroot) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| addr | address | undefined |
|
||||
| merkleroot | bytes32 | undefined |
|
||||
|
||||
### setValidSigners
|
||||
|
||||
```solidity
|
||||
function setValidSigners(address[] _validSigners) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _validSigners | address[] | undefined |
|
||||
|
||||
### tokenSettings
|
||||
|
||||
```solidity
|
||||
function tokenSettings(address[] _tokens, bool[] _states) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _tokens | address[] | undefined |
|
||||
| _states | bool[] | undefined |
|
||||
|
||||
### unlockExpired
|
||||
|
||||
```solidity
|
||||
@ -247,7 +394,7 @@ function unlockExpired(bytes32[] lockIDs) external nonpayable
|
||||
|
||||
Unlocks expired locks.
|
||||
|
||||
*Triggered in the callgraph by both `lock` and `withdraw` functions.This method can also have any public actor as its `tx.origin`.Function sighash: 0x8e2749d6.*
|
||||
*Triggered in the callgraph by both `lock` and `withdraw` functions.This method can also have any public actor as its `tx.origin`.For each successfull unexpired lock recovered, `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value.Function sighash: 0x8e2749d6.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
@ -255,6 +402,28 @@ Unlocks expired locks.
|
||||
|---|---|---|
|
||||
| lockIDs | bytes32[] | undefined |
|
||||
|
||||
### userRecord
|
||||
|
||||
```solidity
|
||||
function userRecord(uint256) external view returns (uint256)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Stores an relayer's last computed credit.*
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### validBacenSigners
|
||||
|
||||
```solidity
|
||||
@ -302,13 +471,30 @@ function withdrawBalance() external nonpayable
|
||||
|
||||
|
||||
|
||||
*Contract's balance withdraw method. Function sighash: 0x5fd8c710.*
|
||||
*Contract's underlying balance withdraw method.Function sighash: 0x5fd8c710.*
|
||||
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### AllowedERC20Updated
|
||||
|
||||
```solidity
|
||||
event AllowedERC20Updated(address indexed token, bool indexed state)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| token `indexed` | address | undefined |
|
||||
| state `indexed` | bool | undefined |
|
||||
|
||||
### DepositAdded
|
||||
|
||||
```solidity
|
||||
@ -399,6 +585,22 @@ event LockAdded(address indexed buyer, bytes32 indexed lockID, uint256 depositID
|
||||
| depositID | uint256 | undefined |
|
||||
| amount | uint256 | undefined |
|
||||
|
||||
### LockBlocksUpdated
|
||||
|
||||
```solidity
|
||||
event LockBlocksUpdated(uint256 blocks)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| blocks | uint256 | undefined |
|
||||
|
||||
### LockReleased
|
||||
|
||||
```solidity
|
||||
@ -450,10 +652,53 @@ event OwnerUpdated(address indexed user, address indexed newOwner)
|
||||
| user `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
### ReputationUpdated
|
||||
|
||||
```solidity
|
||||
event ReputationUpdated(address reputation)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| reputation | address | undefined |
|
||||
|
||||
### ValidSignersUpdated
|
||||
|
||||
```solidity
|
||||
event ValidSignersUpdated(address[] signers)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| signers | address[] | undefined |
|
||||
|
||||
|
||||
|
||||
## Errors
|
||||
|
||||
### AddressDenied
|
||||
|
||||
```solidity
|
||||
error AddressDenied()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Address doesn't exist in a MerkleTree.Address not allowed as relayer.0x3b8474be*
|
||||
|
||||
|
||||
### AlreadyReleased
|
||||
|
||||
```solidity
|
||||
@ -465,6 +710,17 @@ error AlreadyReleased()
|
||||
*Lock already released or returned.0x63b4904e*
|
||||
|
||||
|
||||
### AmountNotAllowed
|
||||
|
||||
```solidity
|
||||
error AmountNotAllowed()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Wished amount to be locked exceeds the limit allowed.0x1c18f846*
|
||||
|
||||
|
||||
### DepositAlreadyExists
|
||||
|
||||
```solidity
|
||||
@ -498,6 +754,17 @@ error InvalidSigner()
|
||||
*Signer is not a valid signer.0x815e1d64*
|
||||
|
||||
|
||||
### LengthMismatch
|
||||
|
||||
```solidity
|
||||
error LengthMismatch()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Arrays' length don't match.0xff633a38*
|
||||
|
||||
|
||||
### LoopOverflow
|
||||
|
||||
```solidity
|
||||
@ -509,6 +776,17 @@ error LoopOverflow()
|
||||
*Loop bounds have overflowed.0xdfb035c9*
|
||||
|
||||
|
||||
### NoTokens
|
||||
|
||||
```solidity
|
||||
error NoTokens()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*No tokens array provided as argument.0xdf957883*
|
||||
|
||||
|
||||
### NotEnoughTokens
|
||||
|
||||
```solidity
|
||||
@ -539,7 +817,7 @@ error OnlySeller()
|
||||
|
||||
|
||||
|
||||
*Only seller could call this function.0x85d1f726*
|
||||
*Only seller could call this function.`msg.sender` and the seller differ.0x85d1f726*
|
||||
|
||||
|
||||
### Reentrancy
|
||||
@ -553,6 +831,17 @@ error Reentrancy()
|
||||
|
||||
|
||||
|
||||
### TokenDenied
|
||||
|
||||
```solidity
|
||||
error TokenDenied()
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Token address not allowed to be deposited.0x1578328e*
|
||||
|
||||
|
||||
### TxAlreadyUsed
|
||||
|
||||
```solidity
|
||||
|
124
docs/Reputation.md
Normal file
124
docs/Reputation.md
Normal file
@ -0,0 +1,124 @@
|
||||
# Reputation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
### limiter
|
||||
|
||||
```solidity
|
||||
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _userCredit | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _spendLimit | uint256 | undefined |
|
||||
|
||||
### magicValue
|
||||
|
||||
```solidity
|
||||
function magicValue() external view returns (uint256)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Denominator's constant operand for the `limiter` fx. *
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### maxLimit
|
||||
|
||||
```solidity
|
||||
function maxLimit() external view returns (uint256)
|
||||
```
|
||||
|
||||
|
||||
|
||||
*Asymptote numerator constant value for the `limiter` fx.*
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | uint256 | undefined |
|
||||
|
||||
### owner
|
||||
|
||||
```solidity
|
||||
function owner() external view returns (address)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _0 | address | undefined |
|
||||
|
||||
### setOwner
|
||||
|
||||
```solidity
|
||||
function setOwner(address newOwner) external nonpayable
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| newOwner | address | undefined |
|
||||
|
||||
|
||||
|
||||
## Events
|
||||
|
||||
### OwnerUpdated
|
||||
|
||||
```solidity
|
||||
event OwnerUpdated(address indexed user, address indexed newOwner)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| user `indexed` | address | undefined |
|
||||
| newOwner `indexed` | address | undefined |
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 53 KiB |
37
docs/lib/interfaces/IReputation.md
Normal file
37
docs/lib/interfaces/IReputation.md
Normal file
@ -0,0 +1,37 @@
|
||||
# IReputation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
### limiter
|
||||
|
||||
```solidity
|
||||
function limiter(uint256 _userCredit) external pure returns (uint256 _spendLimit)
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _userCredit | uint256 | undefined |
|
||||
|
||||
#### Returns
|
||||
|
||||
| Name | Type | Description |
|
||||
|---|---|---|
|
||||
| _spendLimit | uint256 | undefined |
|
||||
|
||||
|
||||
|
||||
|
12
docs/lib/utils/FixedPointMathLib.md
Normal file
12
docs/lib/utils/FixedPointMathLib.md
Normal file
@ -0,0 +1,12 @@
|
||||
# FixedPointMathLib
|
||||
|
||||
*Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)*
|
||||
|
||||
|
||||
|
||||
Arithmetic library with operations for fixed-point numbers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
12
docs/lib/utils/MerkleProofLib.md
Normal file
12
docs/lib/utils/MerkleProofLib.md
Normal file
@ -0,0 +1,12 @@
|
||||
# MerkleProofLib
|
||||
|
||||
*Solady (https://github.com/vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol)*
|
||||
|
||||
|
||||
|
||||
Gas optimized verification of proof of inclusion for a leaf in a Merkle tree.
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -16,24 +16,44 @@ export interface EventAndErrorsInterface extends utils.Interface {
|
||||
functions: {};
|
||||
|
||||
events: {
|
||||
"AllowedERC20Updated(address,bool)": EventFragment;
|
||||
"DepositAdded(address,uint256,address,uint256)": EventFragment;
|
||||
"DepositClosed(address,uint256)": EventFragment;
|
||||
"DepositWithdrawn(address,uint256,uint256)": EventFragment;
|
||||
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||
"LockBlocksUpdated(uint256)": EventFragment;
|
||||
"LockReleased(address,bytes32)": EventFragment;
|
||||
"LockReturned(address,bytes32)": EventFragment;
|
||||
"ReputationUpdated(address)": EventFragment;
|
||||
"ValidSignersUpdated(address[])": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "AllowedERC20Updated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositAdded"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositClosed"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositWithdrawn"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "FundsWithdrawn"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockAdded"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockBlocksUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockReleased"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockReturned"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "ReputationUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "ValidSignersUpdated"): EventFragment;
|
||||
}
|
||||
|
||||
export interface AllowedERC20UpdatedEventObject {
|
||||
token: string;
|
||||
state: boolean;
|
||||
}
|
||||
export type AllowedERC20UpdatedEvent = TypedEvent<
|
||||
[string, boolean],
|
||||
AllowedERC20UpdatedEventObject
|
||||
>;
|
||||
|
||||
export type AllowedERC20UpdatedEventFilter =
|
||||
TypedEventFilter<AllowedERC20UpdatedEvent>;
|
||||
|
||||
export interface DepositAddedEventObject {
|
||||
seller: string;
|
||||
depositID: BigNumber;
|
||||
@ -95,6 +115,17 @@ export type LockAddedEvent = TypedEvent<
|
||||
|
||||
export type LockAddedEventFilter = TypedEventFilter<LockAddedEvent>;
|
||||
|
||||
export interface LockBlocksUpdatedEventObject {
|
||||
blocks: BigNumber;
|
||||
}
|
||||
export type LockBlocksUpdatedEvent = TypedEvent<
|
||||
[BigNumber],
|
||||
LockBlocksUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type LockBlocksUpdatedEventFilter =
|
||||
TypedEventFilter<LockBlocksUpdatedEvent>;
|
||||
|
||||
export interface LockReleasedEventObject {
|
||||
buyer: string;
|
||||
lockId: string;
|
||||
@ -117,6 +148,28 @@ export type LockReturnedEvent = TypedEvent<
|
||||
|
||||
export type LockReturnedEventFilter = TypedEventFilter<LockReturnedEvent>;
|
||||
|
||||
export interface ReputationUpdatedEventObject {
|
||||
reputation: string;
|
||||
}
|
||||
export type ReputationUpdatedEvent = TypedEvent<
|
||||
[string],
|
||||
ReputationUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type ReputationUpdatedEventFilter =
|
||||
TypedEventFilter<ReputationUpdatedEvent>;
|
||||
|
||||
export interface ValidSignersUpdatedEventObject {
|
||||
signers: string[];
|
||||
}
|
||||
export type ValidSignersUpdatedEvent = TypedEvent<
|
||||
[string[]],
|
||||
ValidSignersUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type ValidSignersUpdatedEventFilter =
|
||||
TypedEventFilter<ValidSignersUpdatedEvent>;
|
||||
|
||||
export interface EventAndErrors extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
@ -148,6 +201,15 @@ export interface EventAndErrors extends BaseContract {
|
||||
callStatic: {};
|
||||
|
||||
filters: {
|
||||
"AllowedERC20Updated(address,bool)"(
|
||||
token?: PromiseOrValue<string> | null,
|
||||
state?: PromiseOrValue<boolean> | null
|
||||
): AllowedERC20UpdatedEventFilter;
|
||||
AllowedERC20Updated(
|
||||
token?: PromiseOrValue<string> | null,
|
||||
state?: PromiseOrValue<boolean> | null
|
||||
): AllowedERC20UpdatedEventFilter;
|
||||
|
||||
"DepositAdded(address,uint256,address,uint256)"(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null,
|
||||
@ -200,6 +262,9 @@ export interface EventAndErrors extends BaseContract {
|
||||
amount?: null
|
||||
): LockAddedEventFilter;
|
||||
|
||||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
|
||||
"LockReleased(address,bytes32)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
@ -217,6 +282,16 @@ export interface EventAndErrors extends BaseContract {
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
): LockReturnedEventFilter;
|
||||
|
||||
"ReputationUpdated(address)"(
|
||||
reputation?: null
|
||||
): ReputationUpdatedEventFilter;
|
||||
ReputationUpdated(reputation?: null): ReputationUpdatedEventFilter;
|
||||
|
||||
"ValidSignersUpdated(address[])"(
|
||||
signers?: null
|
||||
): ValidSignersUpdatedEventFilter;
|
||||
ValidSignersUpdated(signers?: null): ValidSignersUpdatedEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {};
|
||||
|
211
src/types/Reputation.ts
Normal file
211
src/types/Reputation.ts
Normal file
@ -0,0 +1,211 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
ContractTransaction,
|
||||
Overrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type {
|
||||
FunctionFragment,
|
||||
Result,
|
||||
EventFragment,
|
||||
} from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "./common";
|
||||
|
||||
export interface ReputationInterface extends utils.Interface {
|
||||
functions: {
|
||||
"limiter(uint256)": FunctionFragment;
|
||||
"magicValue()": FunctionFragment;
|
||||
"maxLimit()": FunctionFragment;
|
||||
"owner()": FunctionFragment;
|
||||
"setOwner(address)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| "limiter"
|
||||
| "magicValue"
|
||||
| "maxLimit"
|
||||
| "owner"
|
||||
| "setOwner"
|
||||
): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "limiter",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "magicValue",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(functionFragment: "maxLimit", values?: undefined): string;
|
||||
encodeFunctionData(functionFragment: "owner", values?: undefined): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setOwner",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(functionFragment: "limiter", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "magicValue", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "maxLimit", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "setOwner", data: BytesLike): Result;
|
||||
|
||||
events: {
|
||||
"OwnerUpdated(address,address)": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "OwnerUpdated"): EventFragment;
|
||||
}
|
||||
|
||||
export interface OwnerUpdatedEventObject {
|
||||
user: string;
|
||||
newOwner: string;
|
||||
}
|
||||
export type OwnerUpdatedEvent = TypedEvent<
|
||||
[string, string],
|
||||
OwnerUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type OwnerUpdatedEventFilter = TypedEventFilter<OwnerUpdatedEvent>;
|
||||
|
||||
export interface Reputation extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: ReputationInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[BigNumber] & { _spendLimit: BigNumber }>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
};
|
||||
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
callStatic: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
};
|
||||
|
||||
filters: {
|
||||
"OwnerUpdated(address,address)"(
|
||||
user?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnerUpdatedEventFilter;
|
||||
OwnerUpdated(
|
||||
user?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnerUpdatedEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
magicValue(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
maxLimit(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
owner(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
@ -10,11 +10,21 @@ import type {
|
||||
} from "../EventAndErrors";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [],
|
||||
name: "AddressDenied",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "AlreadyReleased",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "AmountNotAllowed",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "DepositAlreadyExists",
|
||||
@ -30,11 +40,21 @@ const _abi = [
|
||||
name: "InvalidSigner",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "LengthMismatch",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "LoopOverflow",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "NoTokens",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "NotEnoughTokens",
|
||||
@ -50,11 +70,35 @@ const _abi = [
|
||||
name: "OnlySeller",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "TokenDenied",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "TxAlreadyUsed",
|
||||
type: "error",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "token",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "bool",
|
||||
name: "state",
|
||||
type: "bool",
|
||||
},
|
||||
],
|
||||
name: "AllowedERC20Updated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
@ -180,6 +224,19 @@ const _abi = [
|
||||
name: "LockAdded",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "blocks",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "LockBlocksUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
@ -218,6 +275,32 @@ const _abi = [
|
||||
name: "LockReturned",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address",
|
||||
name: "reputation",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "ReputationUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "address[]",
|
||||
name: "signers",
|
||||
type: "address[]",
|
||||
},
|
||||
],
|
||||
name: "ValidSignersUpdated",
|
||||
type: "event",
|
||||
},
|
||||
];
|
||||
|
||||
export class EventAndErrors__factory {
|
||||
|
155
src/types/factories/Reputation__factory.ts
Normal file
155
src/types/factories/Reputation__factory.ts
Normal file
@ -0,0 +1,155 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import { Signer, utils, Contract, ContractFactory, Overrides } from "ethers";
|
||||
import type { Provider, TransactionRequest } from "@ethersproject/providers";
|
||||
import type { PromiseOrValue } from "../common";
|
||||
import type { Reputation, ReputationInterface } from "../Reputation";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "constructor",
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "user",
|
||||
type: "address",
|
||||
},
|
||||
{
|
||||
indexed: true,
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "OwnerUpdated",
|
||||
type: "event",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_userCredit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "limiter",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_spendLimit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "magicValue",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "maxLimit",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
name: "owner",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
stateMutability: "view",
|
||||
type: "function",
|
||||
},
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "address",
|
||||
name: "newOwner",
|
||||
type: "address",
|
||||
},
|
||||
],
|
||||
name: "setOwner",
|
||||
outputs: [],
|
||||
stateMutability: "nonpayable",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
const _bytecode =
|
||||
"0x608060405234801561001057600080fd5b50600080546001600160a01b031916339081178255604051909182917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d76908290a350610347806100616000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c80634d2b1791116100505780634d2b17911461009e5780638da5cb5b146100b1578063a4b34557146100dc57600080fd5b806313af40351461006c5780631a861d2614610081575b600080fd5b61007f61007a3660046102f8565b6100e8565b005b61008b620f424081565b6040519081526020015b60405180910390f35b61008b6100ac366004610321565b6101a9565b6000546100c4906001600160a01b031681565b6040516001600160a01b039091168152602001610095565b61008b643a3529440081565b6000546001600160a01b031633146101465760405162461bcd60e51b815260206004820152600c60248201527f554e415554484f52495a45440000000000000000000000000000000000000000604482015260640160405180910390fd5b600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b6000806101b9620f4240846101fa565b905060006101c784806101fa565b905060006101e26101dd83643a352944006101fa565b610216565b90506101ee83826102c8565b60010195945050505050565b600061020f8383670de0b6b3a76400006102d9565b9392505050565b60b58171010000000000000000000000000000000000811061023d5760409190911b9060801c5b690100000000000000000081106102595760209190911b9060401c5b6501000000000081106102715760109190911b9060201c5b630100000081106102875760089190911b9060101c5b62010000010260121c80820401600190811c80830401811c80830401811c80830401811c80830401811c80830401811c80830401901c908190048111900390565b600061020f83670de0b6b3a7640000845b8282028115158415858304851417166102f157600080fd5b0492915050565b60006020828403121561030a57600080fd5b81356001600160a01b038116811461020f57600080fd5b60006020828403121561033357600080fd5b503591905056fea164736f6c6343000809000a";
|
||||
|
||||
type ReputationConstructorParams =
|
||||
| [signer?: Signer]
|
||||
| ConstructorParameters<typeof ContractFactory>;
|
||||
|
||||
const isSuperArgs = (
|
||||
xs: ReputationConstructorParams
|
||||
): xs is ConstructorParameters<typeof ContractFactory> => xs.length > 1;
|
||||
|
||||
export class Reputation__factory extends ContractFactory {
|
||||
constructor(...args: ReputationConstructorParams) {
|
||||
if (isSuperArgs(args)) {
|
||||
super(...args);
|
||||
} else {
|
||||
super(_abi, _bytecode, args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
override deploy(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<Reputation> {
|
||||
return super.deploy(overrides || {}) as Promise<Reputation>;
|
||||
}
|
||||
override getDeployTransaction(
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): TransactionRequest {
|
||||
return super.getDeployTransaction(overrides || {});
|
||||
}
|
||||
override attach(address: string): Reputation {
|
||||
return super.attach(address) as Reputation;
|
||||
}
|
||||
override connect(signer: Signer): Reputation__factory {
|
||||
return super.connect(signer) as Reputation__factory;
|
||||
}
|
||||
|
||||
static readonly bytecode = _bytecode;
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): ReputationInterface {
|
||||
return new utils.Interface(_abi) as ReputationInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): Reputation {
|
||||
return new Contract(address, _abi, signerOrProvider) as Reputation;
|
||||
}
|
||||
}
|
@ -4,3 +4,4 @@
|
||||
export * as lib from "./lib";
|
||||
export * as p2PixSol from "./p2pix.sol";
|
||||
export { EventAndErrors__factory } from "./EventAndErrors__factory";
|
||||
export { Reputation__factory } from "./Reputation__factory";
|
||||
|
@ -2,6 +2,7 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export * as auth from "./auth";
|
||||
export * as interfaces from "./interfaces";
|
||||
export * as mock from "./mock";
|
||||
export * as tokens from "./tokens";
|
||||
export * as utils from "./utils";
|
||||
|
45
src/types/factories/lib/interfaces/IReputation__factory.ts
Normal file
45
src/types/factories/lib/interfaces/IReputation__factory.ts
Normal file
@ -0,0 +1,45 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
import { Contract, Signer, utils } from "ethers";
|
||||
import type { Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
IReputation,
|
||||
IReputationInterface,
|
||||
} from "../../../lib/interfaces/IReputation";
|
||||
|
||||
const _abi = [
|
||||
{
|
||||
inputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_userCredit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "limiter",
|
||||
outputs: [
|
||||
{
|
||||
internalType: "uint256",
|
||||
name: "_spendLimit",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
stateMutability: "pure",
|
||||
type: "function",
|
||||
},
|
||||
];
|
||||
|
||||
export class IReputation__factory {
|
||||
static readonly abi = _abi;
|
||||
static createInterface(): IReputationInterface {
|
||||
return new utils.Interface(_abi) as IReputationInterface;
|
||||
}
|
||||
static connect(
|
||||
address: string,
|
||||
signerOrProvider: Signer | Provider
|
||||
): IReputation {
|
||||
return new Contract(address, _abi, signerOrProvider) as IReputation;
|
||||
}
|
||||
}
|
4
src/types/factories/lib/interfaces/index.ts
Normal file
4
src/types/factories/lib/interfaces/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export { IReputation__factory } from "./IReputation__factory";
|
File diff suppressed because one or more lines are too long
18
src/types/hardhat.d.ts
vendored
18
src/types/hardhat.d.ts
vendored
@ -20,6 +20,10 @@ declare module "hardhat/types/runtime" {
|
||||
name: "Owned",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.Owned__factory>;
|
||||
getContractFactory(
|
||||
name: "IReputation",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.IReputation__factory>;
|
||||
getContractFactory(
|
||||
name: "MockToken",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
@ -40,6 +44,10 @@ declare module "hardhat/types/runtime" {
|
||||
name: "P2PIX",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.P2PIX__factory>;
|
||||
getContractFactory(
|
||||
name: "Reputation",
|
||||
signerOrOptions?: ethers.Signer | FactoryOptions
|
||||
): Promise<Contracts.Reputation__factory>;
|
||||
|
||||
getContractAt(
|
||||
name: "EventAndErrors",
|
||||
@ -51,6 +59,11 @@ declare module "hardhat/types/runtime" {
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.Owned>;
|
||||
getContractAt(
|
||||
name: "IReputation",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.IReputation>;
|
||||
getContractAt(
|
||||
name: "MockToken",
|
||||
address: string,
|
||||
@ -76,6 +89,11 @@ declare module "hardhat/types/runtime" {
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.P2PIX>;
|
||||
getContractAt(
|
||||
name: "Reputation",
|
||||
address: string,
|
||||
signer?: ethers.Signer
|
||||
): Promise<Contracts.Reputation>;
|
||||
|
||||
// default types
|
||||
getContractFactory(
|
||||
|
@ -6,10 +6,13 @@ export type { lib };
|
||||
import type * as p2PixSol from "./p2pix.sol";
|
||||
export type { p2PixSol };
|
||||
export type { EventAndErrors } from "./EventAndErrors";
|
||||
export type { Reputation } from "./Reputation";
|
||||
export * as factories from "./factories";
|
||||
export { EventAndErrors__factory } from "./factories/EventAndErrors__factory";
|
||||
export type { Owned } from "./lib/auth/Owned";
|
||||
export { Owned__factory } from "./factories/lib/auth/Owned__factory";
|
||||
export type { IReputation } from "./lib/interfaces/IReputation";
|
||||
export { IReputation__factory } from "./factories/lib/interfaces/IReputation__factory";
|
||||
export type { MockToken } from "./lib/mock/mockToken.sol/MockToken";
|
||||
export { MockToken__factory } from "./factories/lib/mock/mockToken.sol/MockToken__factory";
|
||||
export type { ERC20 } from "./lib/tokens/ERC20";
|
||||
@ -20,3 +23,4 @@ export type { ReentrancyGuard } from "./lib/utils/ReentrancyGuard";
|
||||
export { ReentrancyGuard__factory } from "./factories/lib/utils/ReentrancyGuard__factory";
|
||||
export type { P2PIX } from "./p2pix.sol/P2PIX";
|
||||
export { P2PIX__factory } from "./factories/p2pix.sol/P2PIX__factory";
|
||||
export { Reputation__factory } from "./factories/Reputation__factory";
|
||||
|
@ -3,6 +3,8 @@
|
||||
/* eslint-disable */
|
||||
import type * as auth from "./auth";
|
||||
export type { auth };
|
||||
import type * as interfaces from "./interfaces";
|
||||
export type { interfaces };
|
||||
import type * as mock from "./mock";
|
||||
export type { mock };
|
||||
import type * as tokens from "./tokens";
|
||||
|
101
src/types/lib/interfaces/IReputation.ts
Normal file
101
src/types/lib/interfaces/IReputation.ts
Normal file
@ -0,0 +1,101 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type {
|
||||
BaseContract,
|
||||
BigNumber,
|
||||
BigNumberish,
|
||||
BytesLike,
|
||||
CallOverrides,
|
||||
PopulatedTransaction,
|
||||
Signer,
|
||||
utils,
|
||||
} from "ethers";
|
||||
import type { FunctionFragment, Result } from "@ethersproject/abi";
|
||||
import type { Listener, Provider } from "@ethersproject/providers";
|
||||
import type {
|
||||
TypedEventFilter,
|
||||
TypedEvent,
|
||||
TypedListener,
|
||||
OnEvent,
|
||||
PromiseOrValue,
|
||||
} from "../../common";
|
||||
|
||||
export interface IReputationInterface extends utils.Interface {
|
||||
functions: {
|
||||
"limiter(uint256)": FunctionFragment;
|
||||
};
|
||||
|
||||
getFunction(nameOrSignatureOrTopic: "limiter"): FunctionFragment;
|
||||
|
||||
encodeFunctionData(
|
||||
functionFragment: "limiter",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
|
||||
decodeFunctionResult(functionFragment: "limiter", data: BytesLike): Result;
|
||||
|
||||
events: {};
|
||||
}
|
||||
|
||||
export interface IReputation extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
deployed(): Promise<this>;
|
||||
|
||||
interface: IReputationInterface;
|
||||
|
||||
queryFilter<TEvent extends TypedEvent>(
|
||||
event: TypedEventFilter<TEvent>,
|
||||
fromBlockOrBlockhash?: string | number | undefined,
|
||||
toBlock?: string | number | undefined
|
||||
): Promise<Array<TEvent>>;
|
||||
|
||||
listeners<TEvent extends TypedEvent>(
|
||||
eventFilter?: TypedEventFilter<TEvent>
|
||||
): Array<TypedListener<TEvent>>;
|
||||
listeners(eventName?: string): Array<Listener>;
|
||||
removeAllListeners<TEvent extends TypedEvent>(
|
||||
eventFilter: TypedEventFilter<TEvent>
|
||||
): this;
|
||||
removeAllListeners(eventName?: string): this;
|
||||
off: OnEvent<this>;
|
||||
on: OnEvent<this>;
|
||||
once: OnEvent<this>;
|
||||
removeListener: OnEvent<this>;
|
||||
|
||||
functions: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[BigNumber] & { _spendLimit: BigNumber }>;
|
||||
};
|
||||
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
callStatic: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
filters: {};
|
||||
|
||||
estimateGas: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
};
|
||||
|
||||
populateTransaction: {
|
||||
limiter(
|
||||
_userCredit: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
};
|
||||
}
|
4
src/types/lib/interfaces/index.ts
Normal file
4
src/types/lib/interfaces/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
/* Autogenerated file. Do not edit manually. */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export type { IReputation } from "./IReputation";
|
@ -30,17 +30,26 @@ import type {
|
||||
export interface P2PIXInterface extends utils.Interface {
|
||||
functions: {
|
||||
"_castAddrToKey(address)": FunctionFragment;
|
||||
"allowedERC20s(address)": FunctionFragment;
|
||||
"cancelDeposit(uint256)": FunctionFragment;
|
||||
"defaultLockBlocks()": FunctionFragment;
|
||||
"deposit(address,uint256,string)": FunctionFragment;
|
||||
"deposit(address,uint256,string,bytes32)": FunctionFragment;
|
||||
"depositCount()": FunctionFragment;
|
||||
"lock(uint256,address,address,uint256,uint256,bytes32[])": FunctionFragment;
|
||||
"lock(uint256,address,address,uint256,uint256,bytes32[],bytes32[])": FunctionFragment;
|
||||
"mapDeposits(uint256)": FunctionFragment;
|
||||
"mapLocks(bytes32)": FunctionFragment;
|
||||
"owner()": FunctionFragment;
|
||||
"release(bytes32,uint256,bytes32,bytes32,uint8)": FunctionFragment;
|
||||
"release(bytes32,address,uint256,bytes32,bytes32,uint8)": FunctionFragment;
|
||||
"reputation()": FunctionFragment;
|
||||
"sellerAllowList(uint256)": FunctionFragment;
|
||||
"setDefaultLockBlocks(uint256)": FunctionFragment;
|
||||
"setOwner(address)": FunctionFragment;
|
||||
"setReputation(address)": FunctionFragment;
|
||||
"setRoot(address,bytes32)": FunctionFragment;
|
||||
"setValidSigners(address[])": FunctionFragment;
|
||||
"tokenSettings(address[],bool[])": FunctionFragment;
|
||||
"unlockExpired(bytes32[])": FunctionFragment;
|
||||
"userRecord(uint256)": FunctionFragment;
|
||||
"validBacenSigners(uint256)": FunctionFragment;
|
||||
"withdraw(uint256,bytes32[])": FunctionFragment;
|
||||
"withdrawBalance()": FunctionFragment;
|
||||
@ -49,6 +58,7 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
getFunction(
|
||||
nameOrSignatureOrTopic:
|
||||
| "_castAddrToKey"
|
||||
| "allowedERC20s"
|
||||
| "cancelDeposit"
|
||||
| "defaultLockBlocks"
|
||||
| "deposit"
|
||||
@ -58,8 +68,16 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
| "mapLocks"
|
||||
| "owner"
|
||||
| "release"
|
||||
| "reputation"
|
||||
| "sellerAllowList"
|
||||
| "setDefaultLockBlocks"
|
||||
| "setOwner"
|
||||
| "setReputation"
|
||||
| "setRoot"
|
||||
| "setValidSigners"
|
||||
| "tokenSettings"
|
||||
| "unlockExpired"
|
||||
| "userRecord"
|
||||
| "validBacenSigners"
|
||||
| "withdraw"
|
||||
| "withdrawBalance"
|
||||
@ -69,6 +87,10 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
functionFragment: "_castAddrToKey",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "allowedERC20s",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "cancelDeposit",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
@ -82,7 +104,8 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
values: [
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<string>
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BytesLike>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
@ -97,6 +120,7 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BytesLike>[],
|
||||
PromiseOrValue<BytesLike>[]
|
||||
]
|
||||
): string;
|
||||
@ -113,20 +137,53 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
functionFragment: "release",
|
||||
values: [
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<string>,
|
||||
PromiseOrValue<BigNumberish>,
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<BytesLike>,
|
||||
PromiseOrValue<BigNumberish>
|
||||
]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "reputation",
|
||||
values?: undefined
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "sellerAllowList",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setDefaultLockBlocks",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setOwner",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setReputation",
|
||||
values: [PromiseOrValue<string>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setRoot",
|
||||
values: [PromiseOrValue<string>, PromiseOrValue<BytesLike>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "setValidSigners",
|
||||
values: [PromiseOrValue<string>[]]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "tokenSettings",
|
||||
values: [PromiseOrValue<string>[], PromiseOrValue<boolean>[]]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "unlockExpired",
|
||||
values: [PromiseOrValue<BytesLike>[]]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "userRecord",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
): string;
|
||||
encodeFunctionData(
|
||||
functionFragment: "validBacenSigners",
|
||||
values: [PromiseOrValue<BigNumberish>]
|
||||
@ -144,6 +201,10 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
functionFragment: "_castAddrToKey",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "allowedERC20s",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "cancelDeposit",
|
||||
data: BytesLike
|
||||
@ -165,11 +226,34 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
decodeFunctionResult(functionFragment: "mapLocks", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "owner", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "release", data: BytesLike): Result;
|
||||
decodeFunctionResult(functionFragment: "reputation", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "sellerAllowList",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "setDefaultLockBlocks",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "setOwner", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "setReputation",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "setRoot", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "setValidSigners",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "tokenSettings",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "unlockExpired",
|
||||
data: BytesLike
|
||||
): Result;
|
||||
decodeFunctionResult(functionFragment: "userRecord", data: BytesLike): Result;
|
||||
decodeFunctionResult(
|
||||
functionFragment: "validBacenSigners",
|
||||
data: BytesLike
|
||||
@ -181,26 +265,46 @@ export interface P2PIXInterface extends utils.Interface {
|
||||
): Result;
|
||||
|
||||
events: {
|
||||
"AllowedERC20Updated(address,bool)": EventFragment;
|
||||
"DepositAdded(address,uint256,address,uint256)": EventFragment;
|
||||
"DepositClosed(address,uint256)": EventFragment;
|
||||
"DepositWithdrawn(address,uint256,uint256)": EventFragment;
|
||||
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||
"LockBlocksUpdated(uint256)": EventFragment;
|
||||
"LockReleased(address,bytes32)": EventFragment;
|
||||
"LockReturned(address,bytes32)": EventFragment;
|
||||
"OwnerUpdated(address,address)": EventFragment;
|
||||
"ReputationUpdated(address)": EventFragment;
|
||||
"ValidSignersUpdated(address[])": EventFragment;
|
||||
};
|
||||
|
||||
getEvent(nameOrSignatureOrTopic: "AllowedERC20Updated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositAdded"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositClosed"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "DepositWithdrawn"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "FundsWithdrawn"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockAdded"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockBlocksUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockReleased"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "LockReturned"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "OwnerUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "ReputationUpdated"): EventFragment;
|
||||
getEvent(nameOrSignatureOrTopic: "ValidSignersUpdated"): EventFragment;
|
||||
}
|
||||
|
||||
export interface AllowedERC20UpdatedEventObject {
|
||||
token: string;
|
||||
state: boolean;
|
||||
}
|
||||
export type AllowedERC20UpdatedEvent = TypedEvent<
|
||||
[string, boolean],
|
||||
AllowedERC20UpdatedEventObject
|
||||
>;
|
||||
|
||||
export type AllowedERC20UpdatedEventFilter =
|
||||
TypedEventFilter<AllowedERC20UpdatedEvent>;
|
||||
|
||||
export interface DepositAddedEventObject {
|
||||
seller: string;
|
||||
depositID: BigNumber;
|
||||
@ -262,6 +366,17 @@ export type LockAddedEvent = TypedEvent<
|
||||
|
||||
export type LockAddedEventFilter = TypedEventFilter<LockAddedEvent>;
|
||||
|
||||
export interface LockBlocksUpdatedEventObject {
|
||||
blocks: BigNumber;
|
||||
}
|
||||
export type LockBlocksUpdatedEvent = TypedEvent<
|
||||
[BigNumber],
|
||||
LockBlocksUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type LockBlocksUpdatedEventFilter =
|
||||
TypedEventFilter<LockBlocksUpdatedEvent>;
|
||||
|
||||
export interface LockReleasedEventObject {
|
||||
buyer: string;
|
||||
lockId: string;
|
||||
@ -295,6 +410,28 @@ export type OwnerUpdatedEvent = TypedEvent<
|
||||
|
||||
export type OwnerUpdatedEventFilter = TypedEventFilter<OwnerUpdatedEvent>;
|
||||
|
||||
export interface ReputationUpdatedEventObject {
|
||||
reputation: string;
|
||||
}
|
||||
export type ReputationUpdatedEvent = TypedEvent<
|
||||
[string],
|
||||
ReputationUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type ReputationUpdatedEventFilter =
|
||||
TypedEventFilter<ReputationUpdatedEvent>;
|
||||
|
||||
export interface ValidSignersUpdatedEventObject {
|
||||
signers: string[];
|
||||
}
|
||||
export type ValidSignersUpdatedEvent = TypedEvent<
|
||||
[string[]],
|
||||
ValidSignersUpdatedEventObject
|
||||
>;
|
||||
|
||||
export type ValidSignersUpdatedEventFilter =
|
||||
TypedEventFilter<ValidSignersUpdatedEvent>;
|
||||
|
||||
export interface P2PIX extends BaseContract {
|
||||
connect(signerOrProvider: Signer | Provider | string): this;
|
||||
attach(addressOrName: string): this;
|
||||
@ -327,6 +464,11 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: CallOverrides
|
||||
): Promise<[BigNumber] & { _key: BigNumber }>;
|
||||
|
||||
allowedERC20s(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[boolean]>;
|
||||
|
||||
cancelDeposit(
|
||||
depositID: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
@ -338,6 +480,7 @@ export interface P2PIX extends BaseContract {
|
||||
_token: PromiseOrValue<string>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
_pixTarget: PromiseOrValue<string>,
|
||||
allowlistRoot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
@ -347,10 +490,11 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
lock(
|
||||
_depositID: PromiseOrValue<BigNumberish>,
|
||||
_targetAddress: PromiseOrValue<string>,
|
||||
_relayerAddress: PromiseOrValue<string>,
|
||||
_buyerAddress: PromiseOrValue<string>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
_relayerPremium: PromiseOrValue<BigNumberish>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
merkleProof: PromiseOrValue<BytesLike>[],
|
||||
expiredLocks: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
@ -372,12 +516,13 @@ export interface P2PIX extends BaseContract {
|
||||
arg0: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<
|
||||
[BigNumber, BigNumber, BigNumber, BigNumber, string, string] & {
|
||||
[BigNumber, BigNumber, BigNumber, BigNumber, string, string, string] & {
|
||||
depositID: BigNumber;
|
||||
relayerPremium: BigNumber;
|
||||
amount: BigNumber;
|
||||
expirationBlock: BigNumber;
|
||||
targetAddress: string;
|
||||
buyerAddress: string;
|
||||
relayerTarget: string;
|
||||
relayerAddress: string;
|
||||
}
|
||||
>;
|
||||
@ -386,6 +531,7 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BytesLike>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
pixTimestamp: PromiseOrValue<BigNumberish>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
@ -393,16 +539,55 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
reputation(overrides?: CallOverrides): Promise<[string]>;
|
||||
|
||||
sellerAllowList(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[string]>;
|
||||
|
||||
setDefaultLockBlocks(
|
||||
_blocks: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setReputation(
|
||||
_reputation: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setRoot(
|
||||
addr: PromiseOrValue<string>,
|
||||
merkleroot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setValidSigners(
|
||||
_validSigners: PromiseOrValue<string>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
tokenSettings(
|
||||
_tokens: PromiseOrValue<string>[],
|
||||
_states: PromiseOrValue<boolean>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
unlockExpired(
|
||||
lockIDs: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
userRecord(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<[BigNumber]>;
|
||||
|
||||
validBacenSigners(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
@ -424,6 +609,11 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
allowedERC20s(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
|
||||
cancelDeposit(
|
||||
depositID: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
@ -435,6 +625,7 @@ export interface P2PIX extends BaseContract {
|
||||
_token: PromiseOrValue<string>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
_pixTarget: PromiseOrValue<string>,
|
||||
allowlistRoot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
@ -442,10 +633,11 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
lock(
|
||||
_depositID: PromiseOrValue<BigNumberish>,
|
||||
_targetAddress: PromiseOrValue<string>,
|
||||
_relayerAddress: PromiseOrValue<string>,
|
||||
_buyerAddress: PromiseOrValue<string>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
_relayerPremium: PromiseOrValue<BigNumberish>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
merkleProof: PromiseOrValue<BytesLike>[],
|
||||
expiredLocks: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
@ -467,12 +659,13 @@ export interface P2PIX extends BaseContract {
|
||||
arg0: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<
|
||||
[BigNumber, BigNumber, BigNumber, BigNumber, string, string] & {
|
||||
[BigNumber, BigNumber, BigNumber, BigNumber, string, string, string] & {
|
||||
depositID: BigNumber;
|
||||
relayerPremium: BigNumber;
|
||||
amount: BigNumber;
|
||||
expirationBlock: BigNumber;
|
||||
targetAddress: string;
|
||||
buyerAddress: string;
|
||||
relayerTarget: string;
|
||||
relayerAddress: string;
|
||||
}
|
||||
>;
|
||||
@ -481,6 +674,7 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BytesLike>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
pixTimestamp: PromiseOrValue<BigNumberish>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
@ -488,16 +682,55 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
reputation(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
sellerAllowList(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
setDefaultLockBlocks(
|
||||
_blocks: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setReputation(
|
||||
_reputation: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setRoot(
|
||||
addr: PromiseOrValue<string>,
|
||||
merkleroot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
setValidSigners(
|
||||
_validSigners: PromiseOrValue<string>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
tokenSettings(
|
||||
_tokens: PromiseOrValue<string>[],
|
||||
_states: PromiseOrValue<boolean>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
unlockExpired(
|
||||
lockIDs: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<ContractTransaction>;
|
||||
|
||||
userRecord(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
validBacenSigners(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
@ -519,6 +752,11 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
allowedERC20s(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<boolean>;
|
||||
|
||||
cancelDeposit(
|
||||
depositID: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
@ -530,6 +768,7 @@ export interface P2PIX extends BaseContract {
|
||||
_token: PromiseOrValue<string>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
_pixTarget: PromiseOrValue<string>,
|
||||
allowlistRoot: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
@ -537,10 +776,11 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
lock(
|
||||
_depositID: PromiseOrValue<BigNumberish>,
|
||||
_targetAddress: PromiseOrValue<string>,
|
||||
_relayerAddress: PromiseOrValue<string>,
|
||||
_buyerAddress: PromiseOrValue<string>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
_relayerPremium: PromiseOrValue<BigNumberish>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
merkleProof: PromiseOrValue<BytesLike>[],
|
||||
expiredLocks: PromiseOrValue<BytesLike>[],
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
@ -562,12 +802,13 @@ export interface P2PIX extends BaseContract {
|
||||
arg0: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<
|
||||
[BigNumber, BigNumber, BigNumber, BigNumber, string, string] & {
|
||||
[BigNumber, BigNumber, BigNumber, BigNumber, string, string, string] & {
|
||||
depositID: BigNumber;
|
||||
relayerPremium: BigNumber;
|
||||
amount: BigNumber;
|
||||
expirationBlock: BigNumber;
|
||||
targetAddress: string;
|
||||
buyerAddress: string;
|
||||
relayerTarget: string;
|
||||
relayerAddress: string;
|
||||
}
|
||||
>;
|
||||
@ -576,6 +817,7 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BytesLike>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
pixTimestamp: PromiseOrValue<BigNumberish>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
@ -583,16 +825,55 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
reputation(overrides?: CallOverrides): Promise<string>;
|
||||
|
||||
sellerAllowList(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<string>;
|
||||
|
||||
setDefaultLockBlocks(
|
||||
_blocks: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
setReputation(
|
||||
_reputation: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
setRoot(
|
||||
addr: PromiseOrValue<string>,
|
||||
merkleroot: PromiseOrValue<BytesLike>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
setValidSigners(
|
||||
_validSigners: PromiseOrValue<string>[],
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
tokenSettings(
|
||||
_tokens: PromiseOrValue<string>[],
|
||||
_states: PromiseOrValue<boolean>[],
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
unlockExpired(
|
||||
lockIDs: PromiseOrValue<BytesLike>[],
|
||||
overrides?: CallOverrides
|
||||
): Promise<void>;
|
||||
|
||||
userRecord(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
validBacenSigners(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
@ -608,6 +889,15 @@ export interface P2PIX extends BaseContract {
|
||||
};
|
||||
|
||||
filters: {
|
||||
"AllowedERC20Updated(address,bool)"(
|
||||
token?: PromiseOrValue<string> | null,
|
||||
state?: PromiseOrValue<boolean> | null
|
||||
): AllowedERC20UpdatedEventFilter;
|
||||
AllowedERC20Updated(
|
||||
token?: PromiseOrValue<string> | null,
|
||||
state?: PromiseOrValue<boolean> | null
|
||||
): AllowedERC20UpdatedEventFilter;
|
||||
|
||||
"DepositAdded(address,uint256,address,uint256)"(
|
||||
seller?: PromiseOrValue<string> | null,
|
||||
depositID?: null,
|
||||
@ -660,6 +950,9 @@ export interface P2PIX extends BaseContract {
|
||||
amount?: null
|
||||
): LockAddedEventFilter;
|
||||
|
||||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
|
||||
"LockReleased(address,bytes32)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
@ -686,6 +979,16 @@ export interface P2PIX extends BaseContract {
|
||||
user?: PromiseOrValue<string> | null,
|
||||
newOwner?: PromiseOrValue<string> | null
|
||||
): OwnerUpdatedEventFilter;
|
||||
|
||||
"ReputationUpdated(address)"(
|
||||
reputation?: null
|
||||
): ReputationUpdatedEventFilter;
|
||||
ReputationUpdated(reputation?: null): ReputationUpdatedEventFilter;
|
||||
|
||||
"ValidSignersUpdated(address[])"(
|
||||
signers?: null
|
||||
): ValidSignersUpdatedEventFilter;
|
||||
ValidSignersUpdated(signers?: null): ValidSignersUpdatedEventFilter;
|
||||
};
|
||||
|
||||
estimateGas: {
|
||||
@ -694,6 +997,11 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
allowedERC20s(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
cancelDeposit(
|
||||
depositID: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
@ -705,6 +1013,7 @@ export interface P2PIX extends BaseContract {
|
||||
_token: PromiseOrValue<string>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
_pixTarget: PromiseOrValue<string>,
|
||||
allowlistRoot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
@ -712,10 +1021,11 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
lock(
|
||||
_depositID: PromiseOrValue<BigNumberish>,
|
||||
_targetAddress: PromiseOrValue<string>,
|
||||
_relayerAddress: PromiseOrValue<string>,
|
||||
_buyerAddress: PromiseOrValue<string>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
_relayerPremium: PromiseOrValue<BigNumberish>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
merkleProof: PromiseOrValue<BytesLike>[],
|
||||
expiredLocks: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
@ -734,6 +1044,7 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BytesLike>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
pixTimestamp: PromiseOrValue<BigNumberish>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
@ -741,16 +1052,55 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
reputation(overrides?: CallOverrides): Promise<BigNumber>;
|
||||
|
||||
sellerAllowList(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setDefaultLockBlocks(
|
||||
_blocks: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setReputation(
|
||||
_reputation: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setRoot(
|
||||
addr: PromiseOrValue<string>,
|
||||
merkleroot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
setValidSigners(
|
||||
_validSigners: PromiseOrValue<string>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
tokenSettings(
|
||||
_tokens: PromiseOrValue<string>[],
|
||||
_states: PromiseOrValue<boolean>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
unlockExpired(
|
||||
lockIDs: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<BigNumber>;
|
||||
|
||||
userRecord(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<BigNumber>;
|
||||
|
||||
validBacenSigners(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
@ -773,6 +1123,11 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
allowedERC20s(
|
||||
arg0: PromiseOrValue<string>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
cancelDeposit(
|
||||
depositID: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
@ -784,6 +1139,7 @@ export interface P2PIX extends BaseContract {
|
||||
_token: PromiseOrValue<string>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
_pixTarget: PromiseOrValue<string>,
|
||||
allowlistRoot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
@ -791,10 +1147,11 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
lock(
|
||||
_depositID: PromiseOrValue<BigNumberish>,
|
||||
_targetAddress: PromiseOrValue<string>,
|
||||
_relayerAddress: PromiseOrValue<string>,
|
||||
_buyerAddress: PromiseOrValue<string>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
_relayerPremium: PromiseOrValue<BigNumberish>,
|
||||
_amount: PromiseOrValue<BigNumberish>,
|
||||
merkleProof: PromiseOrValue<BytesLike>[],
|
||||
expiredLocks: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
@ -813,6 +1170,7 @@ export interface P2PIX extends BaseContract {
|
||||
|
||||
release(
|
||||
lockID: PromiseOrValue<BytesLike>,
|
||||
_relayerTarget: PromiseOrValue<string>,
|
||||
pixTimestamp: PromiseOrValue<BigNumberish>,
|
||||
r: PromiseOrValue<BytesLike>,
|
||||
s: PromiseOrValue<BytesLike>,
|
||||
@ -820,16 +1178,55 @@ export interface P2PIX extends BaseContract {
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
reputation(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||
|
||||
sellerAllowList(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setDefaultLockBlocks(
|
||||
_blocks: PromiseOrValue<BigNumberish>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setOwner(
|
||||
newOwner: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setReputation(
|
||||
_reputation: PromiseOrValue<string>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setRoot(
|
||||
addr: PromiseOrValue<string>,
|
||||
merkleroot: PromiseOrValue<BytesLike>,
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
setValidSigners(
|
||||
_validSigners: PromiseOrValue<string>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
tokenSettings(
|
||||
_tokens: PromiseOrValue<string>[],
|
||||
_states: PromiseOrValue<boolean>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
unlockExpired(
|
||||
lockIDs: PromiseOrValue<BytesLike>[],
|
||||
overrides?: Overrides & { from?: PromiseOrValue<string> }
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
userRecord(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
): Promise<PopulatedTransaction>;
|
||||
|
||||
validBacenSigners(
|
||||
arg0: PromiseOrValue<BigNumberish>,
|
||||
overrides?: CallOverrides
|
||||
|
@ -1,116 +1,116 @@
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { ethers } from "hardhat";
|
||||
// import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
// import { expect } from "chai";
|
||||
// import { ethers } from "hardhat";
|
||||
|
||||
import { MockToken, P2PIX } from "../src/types";
|
||||
// import { MockToken, P2PIX } from "../src/types";
|
||||
|
||||
describe("P2PIX deposit test", () => {
|
||||
let owner: SignerWithAddress;
|
||||
let wallet2: SignerWithAddress;
|
||||
// let wallet3: SignerWithAddress;
|
||||
// let wallet4: SignerWithAddress;
|
||||
let p2pix: P2PIX; // Contract instance
|
||||
let erc20: MockToken; // Token instance
|
||||
// describe("P2PIX deposit test", () => {
|
||||
// let owner: SignerWithAddress;
|
||||
// let wallet2: SignerWithAddress;
|
||||
// // let wallet3: SignerWithAddress;
|
||||
// // let wallet4: SignerWithAddress;
|
||||
// let p2pix: P2PIX; // Contract instance
|
||||
// let erc20: MockToken; // Token instance
|
||||
|
||||
it("Will deploy contracts", async () => {
|
||||
[owner, wallet2 /* wallet3, wallet4 */] =
|
||||
await ethers.getSigners();
|
||||
// it("Will deploy contracts", async () => {
|
||||
// [owner, wallet2 /* wallet3, wallet4 */] =
|
||||
// await ethers.getSigners();
|
||||
|
||||
const ERC20Factory = await ethers.getContractFactory(
|
||||
"MockToken",
|
||||
);
|
||||
erc20 = await ERC20Factory.deploy(
|
||||
ethers.utils.parseEther("20000000"),
|
||||
);
|
||||
await erc20.deployed();
|
||||
// const ERC20Factory = await ethers.getContractFactory(
|
||||
// "MockToken",
|
||||
// );
|
||||
// erc20 = await ERC20Factory.deploy(
|
||||
// ethers.utils.parseEther("20000000"),
|
||||
// );
|
||||
// await erc20.deployed();
|
||||
|
||||
// Check initial balance
|
||||
expect(await erc20.balanceOf(owner.address)).to.equal(
|
||||
ethers.utils.parseEther("20000000"),
|
||||
);
|
||||
// // Check initial balance
|
||||
// expect(await erc20.balanceOf(owner.address)).to.equal(
|
||||
// ethers.utils.parseEther("20000000"),
|
||||
// );
|
||||
|
||||
const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||
p2pix = await P2PIX.deploy(2, [
|
||||
owner.address,
|
||||
wallet2.address,
|
||||
]);
|
||||
await p2pix.deployed();
|
||||
// const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||
// p2pix = await P2PIX.deploy(2, [
|
||||
// owner.address,
|
||||
// wallet2.address,
|
||||
// ]);
|
||||
// await p2pix.deployed();
|
||||
|
||||
const ownerKey = await p2pix._castAddrToKey(owner.address);
|
||||
const wallet2Key = await p2pix._castAddrToKey(wallet2.address);
|
||||
// const ownerKey = await p2pix._castAddrToKey(owner.address);
|
||||
// const wallet2Key = await p2pix._castAddrToKey(wallet2.address);
|
||||
|
||||
// Verify values at deployment
|
||||
expect(
|
||||
await p2pix.callStatic.validBacenSigners(ownerKey),
|
||||
).to.equal(true);
|
||||
expect(
|
||||
await p2pix.validBacenSigners(wallet2Key),
|
||||
).to.equal(true);
|
||||
});
|
||||
// // Verify values at deployment
|
||||
// expect(
|
||||
// await p2pix.callStatic.validBacenSigners(ownerKey),
|
||||
// ).to.equal(true);
|
||||
// expect(
|
||||
// await p2pix.validBacenSigners(wallet2Key),
|
||||
// ).to.equal(true);
|
||||
// });
|
||||
|
||||
it("Should allow create a deposit", async () => {
|
||||
let transaction = await erc20.approve(
|
||||
p2pix.address,
|
||||
ethers.utils.parseEther("2000"),
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(erc20, "Approval")
|
||||
.withArgs(
|
||||
owner.address,
|
||||
p2pix.address,
|
||||
ethers.utils.parseEther("2000"),
|
||||
);
|
||||
// it("Should allow create a deposit", async () => {
|
||||
// let transaction = await erc20.approve(
|
||||
// p2pix.address,
|
||||
// ethers.utils.parseEther("2000"),
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(erc20, "Approval")
|
||||
// .withArgs(
|
||||
// owner.address,
|
||||
// p2pix.address,
|
||||
// ethers.utils.parseEther("2000"),
|
||||
// );
|
||||
|
||||
transaction = await p2pix.deposit(
|
||||
erc20.address,
|
||||
ethers.utils.parseEther("1000"),
|
||||
"SELLER PIX KEY",
|
||||
// { value: ethers.utils.parseEther("0.1") },
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "DepositAdded")
|
||||
.withArgs(
|
||||
owner.address,
|
||||
0,
|
||||
erc20.address,
|
||||
// ethers.utils.parseEther("0.1"),
|
||||
ethers.utils.parseEther("1000"),
|
||||
);
|
||||
});
|
||||
// transaction = await p2pix.deposit(
|
||||
// erc20.address,
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// "SELLER PIX KEY",
|
||||
// // { value: ethers.utils.parseEther("0.1") },
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "DepositAdded")
|
||||
// .withArgs(
|
||||
// owner.address,
|
||||
// 0,
|
||||
// erc20.address,
|
||||
// // ethers.utils.parseEther("0.1"),
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should allow create second deposit", async () => {
|
||||
const transaction = await p2pix.deposit(
|
||||
erc20.address,
|
||||
ethers.utils.parseEther("1000"),
|
||||
"SELLER PIX KEY",
|
||||
// { value: ethers.utils.parseEther("0.1") },
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "DepositAdded")
|
||||
.withArgs(
|
||||
owner.address,
|
||||
1,
|
||||
erc20.address,
|
||||
// ethers.utils.parseEther("0.1"),
|
||||
ethers.utils.parseEther("1000"),
|
||||
);
|
||||
});
|
||||
// it("Should allow create second deposit", async () => {
|
||||
// const transaction = await p2pix.deposit(
|
||||
// erc20.address,
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// "SELLER PIX KEY",
|
||||
// // { value: ethers.utils.parseEther("0.1") },
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "DepositAdded")
|
||||
// .withArgs(
|
||||
// owner.address,
|
||||
// 1,
|
||||
// erc20.address,
|
||||
// // ethers.utils.parseEther("0.1"),
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should allow cancel first deposit", async () => {
|
||||
const transaction = await p2pix.cancelDeposit(0);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "DepositClosed")
|
||||
.withArgs(owner.address, 0);
|
||||
});
|
||||
// it("Should allow cancel first deposit", async () => {
|
||||
// const transaction = await p2pix.cancelDeposit(0);
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "DepositClosed")
|
||||
// .withArgs(owner.address, 0);
|
||||
// });
|
||||
|
||||
it("Should allow withdraw the deposit", async () => {
|
||||
const transaction = await p2pix.withdraw(0, []);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "DepositWithdrawn")
|
||||
.withArgs(
|
||||
owner.address,
|
||||
0,
|
||||
ethers.utils.parseEther("1000"),
|
||||
);
|
||||
});
|
||||
});
|
||||
// it("Should allow withdraw the deposit", async () => {
|
||||
// const transaction = await p2pix.withdraw(0, []);
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "DepositWithdrawn")
|
||||
// .withArgs(
|
||||
// owner.address,
|
||||
// 0,
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
|
@ -1,305 +1,305 @@
|
||||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
import { expect } from "chai";
|
||||
import { ethers, network } from "hardhat";
|
||||
import { P2PixErrors } from "./utils/errors";
|
||||
// import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
||||
// import { expect } from "chai";
|
||||
// import { ethers, network } from "hardhat";
|
||||
// import { P2PixErrors } from "./utils/errors";
|
||||
|
||||
import { MockToken, P2PIX } from "../src/types";
|
||||
// import { MockToken, P2PIX } from "../src/types";
|
||||
|
||||
describe("P2PIX deposit test", () => {
|
||||
let owner: SignerWithAddress;
|
||||
let wallet2: SignerWithAddress;
|
||||
let wallet3: SignerWithAddress;
|
||||
// let wallet4: SignerWithAddress;
|
||||
let p2pix: P2PIX; // Contract instance
|
||||
let erc20: MockToken; // Token instance
|
||||
let lockID: string;
|
||||
// describe("P2PIX deposit test", () => {
|
||||
// let owner: SignerWithAddress;
|
||||
// let wallet2: SignerWithAddress;
|
||||
// let wallet3: SignerWithAddress;
|
||||
// // let wallet4: SignerWithAddress;
|
||||
// let p2pix: P2PIX; // Contract instance
|
||||
// let erc20: MockToken; // Token instance
|
||||
// let lockID: string;
|
||||
|
||||
it("Will deploy contracts", async () => {
|
||||
[owner, wallet2, wallet3 /* , wallet4 */] =
|
||||
await ethers.getSigners();
|
||||
// it("Will deploy contracts", async () => {
|
||||
// [owner, wallet2, wallet3 /* , wallet4 */] =
|
||||
// await ethers.getSigners();
|
||||
|
||||
const ERC20Factory = await ethers.getContractFactory(
|
||||
"MockToken",
|
||||
);
|
||||
erc20 = await ERC20Factory.deploy(
|
||||
ethers.utils.parseEther("20000000"),
|
||||
);
|
||||
await erc20.deployed();
|
||||
// const ERC20Factory = await ethers.getContractFactory(
|
||||
// "MockToken",
|
||||
// );
|
||||
// erc20 = await ERC20Factory.deploy(
|
||||
// ethers.utils.parseEther("20000000"),
|
||||
// );
|
||||
// await erc20.deployed();
|
||||
|
||||
// Check initial balance
|
||||
expect(await erc20.balanceOf(owner.address)).to.equal(
|
||||
ethers.utils.parseEther("20000000"),
|
||||
);
|
||||
// // Check initial balance
|
||||
// expect(await erc20.balanceOf(owner.address)).to.equal(
|
||||
// ethers.utils.parseEther("20000000"),
|
||||
// );
|
||||
|
||||
const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||
p2pix = await P2PIX.deploy(3, [
|
||||
owner.address,
|
||||
wallet2.address,
|
||||
]);
|
||||
await p2pix.deployed();
|
||||
// const P2PIX = await ethers.getContractFactory("P2PIX");
|
||||
// p2pix = await P2PIX.deploy(3, [
|
||||
// owner.address,
|
||||
// wallet2.address,
|
||||
// ]);
|
||||
// await p2pix.deployed();
|
||||
|
||||
const ownerKey = await p2pix._castAddrToKey(owner.address);
|
||||
const wallet2key = await p2pix._castAddrToKey(wallet2.address);
|
||||
const wallet3key = await p2pix._castAddrToKey(wallet3.address);
|
||||
// const ownerKey = await p2pix._castAddrToKey(owner.address);
|
||||
// const wallet2key = await p2pix._castAddrToKey(wallet2.address);
|
||||
// const wallet3key = await p2pix._castAddrToKey(wallet3.address);
|
||||
|
||||
// Verify values at deployment
|
||||
expect(
|
||||
await p2pix.validBacenSigners(ownerKey),
|
||||
).to.equal(true);
|
||||
expect(
|
||||
await p2pix.validBacenSigners(wallet2key),
|
||||
).to.equal(true);
|
||||
expect(
|
||||
await p2pix.validBacenSigners(wallet3key),
|
||||
).to.equal(false);
|
||||
});
|
||||
// // Verify values at deployment
|
||||
// expect(
|
||||
// await p2pix.validBacenSigners(ownerKey),
|
||||
// ).to.equal(true);
|
||||
// expect(
|
||||
// await p2pix.validBacenSigners(wallet2key),
|
||||
// ).to.equal(true);
|
||||
// expect(
|
||||
// await p2pix.validBacenSigners(wallet3key),
|
||||
// ).to.equal(false);
|
||||
// });
|
||||
|
||||
it("Should allow create a deposit", async () => {
|
||||
let transaction = await erc20.approve(
|
||||
p2pix.address,
|
||||
ethers.utils.parseEther("1000"),
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(erc20, "Approval")
|
||||
.withArgs(
|
||||
owner.address,
|
||||
p2pix.address,
|
||||
ethers.utils.parseEther("1000"),
|
||||
);
|
||||
transaction = await p2pix.deposit(
|
||||
erc20.address,
|
||||
ethers.utils.parseEther("1000"),
|
||||
"SELLER PIX KEY",
|
||||
// { value: ethers.utils.parseEther("0.1") },
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "DepositAdded")
|
||||
.withArgs(
|
||||
owner.address,
|
||||
0,
|
||||
erc20.address,
|
||||
// ethers.utils.parseEther("0.1"),
|
||||
ethers.utils.parseEther("1000"),
|
||||
);
|
||||
console.log(
|
||||
"GAS USED:",
|
||||
(await transaction.wait()).cumulativeGasUsed.toString(),
|
||||
);
|
||||
});
|
||||
// it("Should allow create a deposit", async () => {
|
||||
// let transaction = await erc20.approve(
|
||||
// p2pix.address,
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(erc20, "Approval")
|
||||
// .withArgs(
|
||||
// owner.address,
|
||||
// p2pix.address,
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// );
|
||||
// transaction = await p2pix.deposit(
|
||||
// erc20.address,
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// "SELLER PIX KEY",
|
||||
// // { value: ethers.utils.parseEther("0.1") },
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "DepositAdded")
|
||||
// .withArgs(
|
||||
// owner.address,
|
||||
// 0,
|
||||
// erc20.address,
|
||||
// // ethers.utils.parseEther("0.1"),
|
||||
// ethers.utils.parseEther("1000"),
|
||||
// );
|
||||
// console.log(
|
||||
// "GAS USED:",
|
||||
// (await transaction.wait()).cumulativeGasUsed.toString(),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should allow create a new lock", async () => {
|
||||
const transaction = await p2pix
|
||||
.connect(wallet3)
|
||||
.lock(
|
||||
0,
|
||||
wallet3.address,
|
||||
ethers.constants.AddressZero,
|
||||
"0",
|
||||
ethers.utils.parseEther("100"),
|
||||
[],
|
||||
);
|
||||
lockID = ethers.utils.solidityKeccak256(
|
||||
["uint256", "uint256", "address"],
|
||||
[0, ethers.utils.parseEther("100"), wallet3.address],
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "LockAdded")
|
||||
.withArgs(
|
||||
wallet3.address,
|
||||
lockID,
|
||||
0,
|
||||
ethers.utils.parseEther("100"),
|
||||
);
|
||||
console.log(
|
||||
"GAS USED:",
|
||||
(await transaction.wait()).cumulativeGasUsed.toString(),
|
||||
);
|
||||
});
|
||||
// it("Should allow create a new lock", async () => {
|
||||
// const transaction = await p2pix
|
||||
// .connect(wallet3)
|
||||
// .lock(
|
||||
// 0,
|
||||
// wallet3.address,
|
||||
// ethers.constants.AddressZero,
|
||||
// "0",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// [],
|
||||
// );
|
||||
// lockID = ethers.utils.solidityKeccak256(
|
||||
// ["uint256", "uint256", "address"],
|
||||
// [0, ethers.utils.parseEther("100"), wallet3.address],
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "LockAdded")
|
||||
// .withArgs(
|
||||
// wallet3.address,
|
||||
// lockID,
|
||||
// 0,
|
||||
// ethers.utils.parseEther("100"),
|
||||
// );
|
||||
// console.log(
|
||||
// "GAS USED:",
|
||||
// (await transaction.wait()).cumulativeGasUsed.toString(),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should release the locked amount to the buyer", async () => {
|
||||
const endtoendID = "123";
|
||||
const messageToSign = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256"],
|
||||
[
|
||||
"SELLER PIX KEY",
|
||||
ethers.utils.parseEther("100"),
|
||||
endtoendID,
|
||||
],
|
||||
);
|
||||
// Note: messageToSign is a string, that is 66-bytes long, to sign the
|
||||
// binary value, we must convert it to the 32 byte Array that
|
||||
// the string represents
|
||||
//
|
||||
// i.e.
|
||||
// // 66-byte string
|
||||
// "0x592fa743889fc7f92ac2a37bb1f5ba1daf2a5c84741ca0e0061d243a2e6707ba"
|
||||
// ... vs ...
|
||||
// // 32 entry Uint8Array
|
||||
// [ 89, 47, 167, 67, 136, 159, ... 103, 7, 186]
|
||||
const messageHashBytes =
|
||||
ethers.utils.arrayify(messageToSign);
|
||||
// Sign the string message
|
||||
const flatSig = await owner.signMessage(messageHashBytes);
|
||||
// For Solidity, we need the expanded-format of a signature
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
const transaction = await p2pix
|
||||
.connect(wallet3)
|
||||
.release(lockID, endtoendID, sig.r, sig.s, sig.v);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "LockReleased")
|
||||
.withArgs(wallet3.address, lockID);
|
||||
console.log(
|
||||
"GAS USED:",
|
||||
(await transaction.wait()).cumulativeGasUsed.toString(),
|
||||
);
|
||||
expect(await erc20.balanceOf(wallet3.address)).to.equal(
|
||||
ethers.utils.parseEther("100"),
|
||||
);
|
||||
});
|
||||
// it("Should release the locked amount to the buyer", async () => {
|
||||
// const endtoendID = "123";
|
||||
// const messageToSign = ethers.utils.solidityKeccak256(
|
||||
// ["string", "uint256", "uint256"],
|
||||
// [
|
||||
// "SELLER PIX KEY",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// endtoendID,
|
||||
// ],
|
||||
// );
|
||||
// // Note: messageToSign is a string, that is 66-bytes long, to sign the
|
||||
// // binary value, we must convert it to the 32 byte Array that
|
||||
// // the string represents
|
||||
// //
|
||||
// // i.e.
|
||||
// // // 66-byte string
|
||||
// // "0x592fa743889fc7f92ac2a37bb1f5ba1daf2a5c84741ca0e0061d243a2e6707ba"
|
||||
// // ... vs ...
|
||||
// // // 32 entry Uint8Array
|
||||
// // [ 89, 47, 167, 67, 136, 159, ... 103, 7, 186]
|
||||
// const messageHashBytes =
|
||||
// ethers.utils.arrayify(messageToSign);
|
||||
// // Sign the string message
|
||||
// const flatSig = await owner.signMessage(messageHashBytes);
|
||||
// // For Solidity, we need the expanded-format of a signature
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
// const transaction = await p2pix
|
||||
// .connect(wallet3)
|
||||
// .release(lockID, endtoendID, sig.r, sig.s, sig.v);
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "LockReleased")
|
||||
// .withArgs(wallet3.address, lockID);
|
||||
// console.log(
|
||||
// "GAS USED:",
|
||||
// (await transaction.wait()).cumulativeGasUsed.toString(),
|
||||
// );
|
||||
// expect(await erc20.balanceOf(wallet3.address)).to.equal(
|
||||
// ethers.utils.parseEther("100"),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should allow recreate same lock", async () => {
|
||||
const transaction = await p2pix
|
||||
.connect(wallet3)
|
||||
.lock(
|
||||
0,
|
||||
wallet3.address,
|
||||
ethers.constants.AddressZero,
|
||||
"0",
|
||||
ethers.utils.parseEther("100"),
|
||||
[],
|
||||
);
|
||||
lockID = ethers.utils.solidityKeccak256(
|
||||
["uint256", "uint256", "address"],
|
||||
[0, ethers.utils.parseEther("100"), wallet3.address],
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "LockAdded")
|
||||
.withArgs(
|
||||
wallet3.address,
|
||||
lockID,
|
||||
0,
|
||||
ethers.utils.parseEther("100"),
|
||||
);
|
||||
});
|
||||
// it("Should allow recreate same lock", async () => {
|
||||
// const transaction = await p2pix
|
||||
// .connect(wallet3)
|
||||
// .lock(
|
||||
// 0,
|
||||
// wallet3.address,
|
||||
// ethers.constants.AddressZero,
|
||||
// "0",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// [],
|
||||
// );
|
||||
// lockID = ethers.utils.solidityKeccak256(
|
||||
// ["uint256", "uint256", "address"],
|
||||
// [0, ethers.utils.parseEther("100"), wallet3.address],
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "LockAdded")
|
||||
// .withArgs(
|
||||
// wallet3.address,
|
||||
// lockID,
|
||||
// 0,
|
||||
// ethers.utils.parseEther("100"),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should prevent create again same lock", async () => {
|
||||
await expect(
|
||||
p2pix
|
||||
.connect(wallet3)
|
||||
.lock(
|
||||
0,
|
||||
wallet3.address,
|
||||
ethers.constants.AddressZero,
|
||||
"0",
|
||||
ethers.utils.parseEther("100"),
|
||||
[],
|
||||
),
|
||||
).to.be.revertedWithCustomError(p2pix, P2PixErrors.NotExpired);
|
||||
});
|
||||
// it("Should prevent create again same lock", async () => {
|
||||
// await expect(
|
||||
// p2pix
|
||||
// .connect(wallet3)
|
||||
// .lock(
|
||||
// 0,
|
||||
// wallet3.address,
|
||||
// ethers.constants.AddressZero,
|
||||
// "0",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// [],
|
||||
// ),
|
||||
// ).to.be.revertedWithCustomError(p2pix, P2PixErrors.NotExpired);
|
||||
// });
|
||||
|
||||
it("Should release the locked amount to the buyer", async () => {
|
||||
const endtoendID = "124";
|
||||
const messageToSign = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256"],
|
||||
[
|
||||
"SELLER PIX KEY",
|
||||
ethers.utils.parseEther("100"),
|
||||
endtoendID,
|
||||
],
|
||||
);
|
||||
const messageHashBytes =
|
||||
ethers.utils.arrayify(messageToSign);
|
||||
const flatSig = await owner.signMessage(messageHashBytes);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
await p2pix
|
||||
.connect(wallet3)
|
||||
.release(lockID, endtoendID, sig.r, sig.s, sig.v);
|
||||
expect(await erc20.balanceOf(wallet3.address)).to.equal(
|
||||
ethers.utils.parseEther("200"),
|
||||
);
|
||||
});
|
||||
// it("Should release the locked amount to the buyer", async () => {
|
||||
// const endtoendID = "124";
|
||||
// const messageToSign = ethers.utils.solidityKeccak256(
|
||||
// ["string", "uint256", "uint256"],
|
||||
// [
|
||||
// "SELLER PIX KEY",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// endtoendID,
|
||||
// ],
|
||||
// );
|
||||
// const messageHashBytes =
|
||||
// ethers.utils.arrayify(messageToSign);
|
||||
// const flatSig = await owner.signMessage(messageHashBytes);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
// await p2pix
|
||||
// .connect(wallet3)
|
||||
// .release(lockID, endtoendID, sig.r, sig.s, sig.v);
|
||||
// expect(await erc20.balanceOf(wallet3.address)).to.equal(
|
||||
// ethers.utils.parseEther("200"),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should prevent release again the lock", async () => {
|
||||
const endtoendID = "125";
|
||||
const messageToSign = ethers.utils.solidityKeccak256(
|
||||
["string", "uint256", "uint256"],
|
||||
[
|
||||
"SELLER PIX KEY",
|
||||
ethers.utils.parseEther("100"),
|
||||
endtoendID,
|
||||
],
|
||||
);
|
||||
const messageHashBytes =
|
||||
ethers.utils.arrayify(messageToSign);
|
||||
const flatSig = await owner.signMessage(messageHashBytes);
|
||||
const sig = ethers.utils.splitSignature(flatSig);
|
||||
await expect(
|
||||
p2pix
|
||||
.connect(wallet3)
|
||||
.release(lockID, endtoendID, sig.r, sig.s, sig.v),
|
||||
).to.be.revertedWithCustomError(p2pix, P2PixErrors.AlreadyReleased);
|
||||
});
|
||||
// it("Should prevent release again the lock", async () => {
|
||||
// const endtoendID = "125";
|
||||
// const messageToSign = ethers.utils.solidityKeccak256(
|
||||
// ["string", "uint256", "uint256"],
|
||||
// [
|
||||
// "SELLER PIX KEY",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// endtoendID,
|
||||
// ],
|
||||
// );
|
||||
// const messageHashBytes =
|
||||
// ethers.utils.arrayify(messageToSign);
|
||||
// const flatSig = await owner.signMessage(messageHashBytes);
|
||||
// const sig = ethers.utils.splitSignature(flatSig);
|
||||
// await expect(
|
||||
// p2pix
|
||||
// .connect(wallet3)
|
||||
// .release(lockID, endtoendID, sig.r, sig.s, sig.v),
|
||||
// ).to.be.revertedWithCustomError(p2pix, P2PixErrors.AlreadyReleased);
|
||||
// });
|
||||
|
||||
it("Should prevent create a 900 lock", async () => {
|
||||
await expect(
|
||||
p2pix
|
||||
.connect(wallet3)
|
||||
.lock(
|
||||
0,
|
||||
wallet3.address,
|
||||
ethers.constants.AddressZero,
|
||||
"0",
|
||||
ethers.utils.parseEther("900"),
|
||||
[],
|
||||
),
|
||||
).to.be.revertedWithCustomError(
|
||||
p2pix, P2PixErrors.NotEnoughTokens);
|
||||
});
|
||||
// it("Should prevent create a 900 lock", async () => {
|
||||
// await expect(
|
||||
// p2pix
|
||||
// .connect(wallet3)
|
||||
// .lock(
|
||||
// 0,
|
||||
// wallet3.address,
|
||||
// ethers.constants.AddressZero,
|
||||
// "0",
|
||||
// ethers.utils.parseEther("900"),
|
||||
// [],
|
||||
// ),
|
||||
// ).to.be.revertedWithCustomError(
|
||||
// p2pix, P2PixErrors.NotEnoughTokens);
|
||||
// });
|
||||
|
||||
it("Should allow recreate same lock again", async () => {
|
||||
const transaction = await p2pix
|
||||
.connect(wallet3)
|
||||
.lock(
|
||||
0,
|
||||
wallet3.address,
|
||||
ethers.constants.AddressZero,
|
||||
"0",
|
||||
ethers.utils.parseEther("100"),
|
||||
[],
|
||||
);
|
||||
lockID = ethers.utils.solidityKeccak256(
|
||||
["uint256", "uint256", "address"],
|
||||
[0, ethers.utils.parseEther("100"), wallet3.address],
|
||||
);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "LockAdded")
|
||||
.withArgs(
|
||||
wallet3.address,
|
||||
lockID,
|
||||
0,
|
||||
ethers.utils.parseEther("100"),
|
||||
);
|
||||
});
|
||||
// it("Should allow recreate same lock again", async () => {
|
||||
// const transaction = await p2pix
|
||||
// .connect(wallet3)
|
||||
// .lock(
|
||||
// 0,
|
||||
// wallet3.address,
|
||||
// ethers.constants.AddressZero,
|
||||
// "0",
|
||||
// ethers.utils.parseEther("100"),
|
||||
// [],
|
||||
// );
|
||||
// lockID = ethers.utils.solidityKeccak256(
|
||||
// ["uint256", "uint256", "address"],
|
||||
// [0, ethers.utils.parseEther("100"), wallet3.address],
|
||||
// );
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "LockAdded")
|
||||
// .withArgs(
|
||||
// wallet3.address,
|
||||
// lockID,
|
||||
// 0,
|
||||
// ethers.utils.parseEther("100"),
|
||||
// );
|
||||
// });
|
||||
|
||||
it("Should allow unlock expired lock", async () => {
|
||||
await expect(
|
||||
p2pix.unlockExpired([lockID]),
|
||||
).to.be.revertedWithCustomError(
|
||||
p2pix, P2PixErrors.NotExpired);
|
||||
// it("Should allow unlock expired lock", async () => {
|
||||
// await expect(
|
||||
// p2pix.unlockExpired([lockID]),
|
||||
// ).to.be.revertedWithCustomError(
|
||||
// p2pix, P2PixErrors.NotExpired);
|
||||
|
||||
await network.provider.send("evm_mine");
|
||||
await network.provider.send("evm_mine");
|
||||
await network.provider.send("evm_mine");
|
||||
const transaction = await p2pix.unlockExpired([lockID]);
|
||||
await expect(transaction)
|
||||
.to.emit(p2pix, "LockReturned")
|
||||
.withArgs(wallet3.address, lockID);
|
||||
});
|
||||
// await network.provider.send("evm_mine");
|
||||
// await network.provider.send("evm_mine");
|
||||
// await network.provider.send("evm_mine");
|
||||
// const transaction = await p2pix.unlockExpired([lockID]);
|
||||
// await expect(transaction)
|
||||
// .to.emit(p2pix, "LockReturned")
|
||||
// .withArgs(wallet3.address, lockID);
|
||||
// });
|
||||
|
||||
it("Should prevent unlock again", async () => {
|
||||
await expect(
|
||||
p2pix.unlockExpired([lockID]),
|
||||
).to.be.revertedWithCustomError(
|
||||
p2pix, P2PixErrors.NotExpired);
|
||||
});
|
||||
});
|
||||
// it("Should prevent unlock again", async () => {
|
||||
// await expect(
|
||||
// p2pix.unlockExpired([lockID]),
|
||||
// ).to.be.revertedWithCustomError(
|
||||
// p2pix, P2PixErrors.NotExpired);
|
||||
// });
|
||||
// });
|
Loading…
x
Reference in New Issue
Block a user