Merge branch 'hotfix-1.0.2' into main
This commit is contained in:
commit
1a9353575c
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -254,6 +254,12 @@
|
|||
"internalType": "bytes32",
|
||||
"name": "lockId",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "uint256",
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "LockReleased",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/916d546d680bb337e1c490eb628d93df.json"
|
||||
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||
"buildInfo": "../../../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"_format": "hh-sol-dbg-1",
|
||||
"buildInfo": "../../build-info/948b888bf726ea051449ea823f31e46a.json"
|
||||
"buildInfo": "../../build-info/35b01c3398ab10e738bc36ca68343c23.json"
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -28,7 +28,8 @@ interface EventAndErrors {
|
|||
);
|
||||
event LockReleased(
|
||||
address indexed buyer,
|
||||
bytes32 lockId
|
||||
bytes32 lockId,
|
||||
uint256 amount
|
||||
);
|
||||
event LockReturned(
|
||||
address indexed buyer,
|
||||
|
|
|
@ -34,11 +34,10 @@ contract P2PIX is
|
|||
IReputation public reputation;
|
||||
Counters.Counter public depositCount;
|
||||
|
||||
|
||||
/// @dev Default blocks that lock will hold tokens.
|
||||
uint256 public defaultLockBlocks;
|
||||
/// @dev The scalar of BRZ token.
|
||||
uint256 constant public WAD = 1e18;
|
||||
uint256 public constant WAD = 1e18;
|
||||
|
||||
/// @dev Stores an relayer's last computed credit.
|
||||
mapping(uint256 => uint256) public userRecord;
|
||||
|
@ -213,8 +212,10 @@ contract P2PIX is
|
|||
uint256 spendLimit;
|
||||
(spendLimit) = _limiter(userCredit / WAD);
|
||||
|
||||
if (l.amount > (spendLimit * WAD) || l.amount > 1e6 ether)
|
||||
revert AmountNotAllowed();
|
||||
if (
|
||||
l.amount > (spendLimit * WAD) ||
|
||||
l.amount > 1e6 ether
|
||||
) revert AmountNotAllowed();
|
||||
|
||||
_addLock(lockID, l, d);
|
||||
// Halt execution and output `lockID`.
|
||||
|
@ -324,7 +325,7 @@ contract P2PIX is
|
|||
}
|
||||
}
|
||||
|
||||
emit LockReleased(l.buyerAddress, lockID);
|
||||
emit LockReleased(l.buyerAddress, lockID, lockAmount);
|
||||
}
|
||||
|
||||
/// @notice Unlocks expired locks.
|
||||
|
@ -333,9 +334,9 @@ contract P2PIX is
|
|||
/// @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 {
|
||||
function unlockExpired(bytes32[] calldata lockIDs)
|
||||
public
|
||||
{
|
||||
uint256 i;
|
||||
uint256 locksSize = lockIDs.length;
|
||||
|
||||
|
@ -403,10 +404,9 @@ contract P2PIX is
|
|||
emit DepositWithdrawn(msg.sender, depositID, amount);
|
||||
}
|
||||
|
||||
function setRoot(
|
||||
address addr,
|
||||
bytes32 merkleroot
|
||||
) public {
|
||||
function setRoot(address addr, bytes32 merkleroot)
|
||||
public
|
||||
{
|
||||
if (addr == msg.sender) {
|
||||
sellerAllowList[
|
||||
_castAddrToKey(addr)
|
||||
|
@ -425,27 +425,30 @@ contract P2PIX is
|
|||
emit FundsWithdrawn(msg.sender, balance);
|
||||
}
|
||||
|
||||
function setReputation(
|
||||
IReputation _reputation
|
||||
) public onlyOwner {
|
||||
function setReputation(IReputation _reputation)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
assembly {
|
||||
sstore(reputation.slot, _reputation)
|
||||
}
|
||||
emit ReputationUpdated(address(_reputation));
|
||||
}
|
||||
|
||||
function setDefaultLockBlocks(
|
||||
uint256 _blocks
|
||||
) public onlyOwner {
|
||||
function setDefaultLockBlocks(uint256 _blocks)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
assembly {
|
||||
sstore(defaultLockBlocks.slot, _blocks)
|
||||
}
|
||||
emit LockBlocksUpdated(_blocks);
|
||||
}
|
||||
|
||||
function setValidSigners(
|
||||
address[] memory _validSigners
|
||||
) public onlyOwner {
|
||||
function setValidSigners(address[] memory _validSigners)
|
||||
public
|
||||
onlyOwner
|
||||
{
|
||||
unchecked {
|
||||
uint256 i;
|
||||
uint256 len = _validSigners.length;
|
||||
|
@ -589,9 +592,11 @@ contract P2PIX is
|
|||
) revert AddressDenied();
|
||||
}
|
||||
|
||||
function _limiter(
|
||||
uint256 _userCredit
|
||||
) internal view returns (uint256 _spendLimit) {
|
||||
function _limiter(uint256 _userCredit)
|
||||
internal
|
||||
view
|
||||
returns (uint256 _spendLimit)
|
||||
{
|
||||
// enconde the fx sighash and args
|
||||
bytes memory encodedParams = abi.encodeWithSelector(
|
||||
IReputation.limiter.selector,
|
||||
|
@ -631,9 +636,11 @@ contract P2PIX is
|
|||
/// @notice Public method that handles `address`
|
||||
/// to `uint256` safe type casting.
|
||||
/// @dev Function sighash: 0x4b2ae980.
|
||||
function _castAddrToKey(
|
||||
address _addr
|
||||
) public pure returns (uint256 _key) {
|
||||
function _castAddrToKey(address _addr)
|
||||
public
|
||||
pure
|
||||
returns (uint256 _key)
|
||||
{
|
||||
_key = uint256(uint160(address(_addr))) << 12;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export interface EventAndErrorsInterface extends utils.Interface {
|
|||
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||
"LockBlocksUpdated(uint256)": EventFragment;
|
||||
"LockReleased(address,bytes32)": EventFragment;
|
||||
"LockReleased(address,bytes32,uint256)": EventFragment;
|
||||
"LockReturned(address,bytes32)": EventFragment;
|
||||
"ReputationUpdated(address)": EventFragment;
|
||||
"RootUpdated(address,bytes32)": EventFragment;
|
||||
|
@ -131,9 +131,10 @@ export type LockBlocksUpdatedEventFilter =
|
|||
export interface LockReleasedEventObject {
|
||||
buyer: string;
|
||||
lockId: string;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type LockReleasedEvent = TypedEvent<
|
||||
[string, string],
|
||||
[string, string, BigNumber],
|
||||
LockReleasedEventObject
|
||||
>;
|
||||
|
||||
|
@ -278,13 +279,15 @@ export interface EventAndErrors extends BaseContract {
|
|||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
|
||||
"LockReleased(address,bytes32)"(
|
||||
"LockReleased(address,bytes32,uint256)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
lockId?: null,
|
||||
amount?: null
|
||||
): LockReleasedEventFilter;
|
||||
LockReleased(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
lockId?: null,
|
||||
amount?: null
|
||||
): LockReleasedEventFilter;
|
||||
|
||||
"LockReturned(address,bytes32)"(
|
||||
|
|
|
@ -262,6 +262,12 @@ const _abi = [
|
|||
name: "lockId",
|
||||
type: "bytes32",
|
||||
},
|
||||
{
|
||||
indexed: false,
|
||||
internalType: "uint256",
|
||||
name: "amount",
|
||||
type: "uint256",
|
||||
},
|
||||
],
|
||||
name: "LockReleased",
|
||||
type: "event",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -286,7 +286,7 @@ export interface P2PIXInterface extends utils.Interface {
|
|||
"FundsWithdrawn(address,uint256)": EventFragment;
|
||||
"LockAdded(address,bytes32,uint256,uint256)": EventFragment;
|
||||
"LockBlocksUpdated(uint256)": EventFragment;
|
||||
"LockReleased(address,bytes32)": EventFragment;
|
||||
"LockReleased(address,bytes32,uint256)": EventFragment;
|
||||
"LockReturned(address,bytes32)": EventFragment;
|
||||
"OwnerUpdated(address,address)": EventFragment;
|
||||
"ReputationUpdated(address)": EventFragment;
|
||||
|
@ -396,9 +396,10 @@ export type LockBlocksUpdatedEventFilter =
|
|||
export interface LockReleasedEventObject {
|
||||
buyer: string;
|
||||
lockId: string;
|
||||
amount: BigNumber;
|
||||
}
|
||||
export type LockReleasedEvent = TypedEvent<
|
||||
[string, string],
|
||||
[string, string, BigNumber],
|
||||
LockReleasedEventObject
|
||||
>;
|
||||
|
||||
|
@ -1001,13 +1002,15 @@ export interface P2PIX extends BaseContract {
|
|||
"LockBlocksUpdated(uint256)"(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
LockBlocksUpdated(blocks?: null): LockBlocksUpdatedEventFilter;
|
||||
|
||||
"LockReleased(address,bytes32)"(
|
||||
"LockReleased(address,bytes32,uint256)"(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
lockId?: null,
|
||||
amount?: null
|
||||
): LockReleasedEventFilter;
|
||||
LockReleased(
|
||||
buyer?: PromiseOrValue<string> | null,
|
||||
lockId?: null
|
||||
lockId?: null,
|
||||
amount?: null
|
||||
): LockReleasedEventFilter;
|
||||
|
||||
"LockReturned(address,bytes32)"(
|
||||
|
|
|
@ -1251,7 +1251,7 @@ describe("P2PIX", () => {
|
|||
expect(tx).to.be.ok;
|
||||
await expect(tx)
|
||||
.to.emit(p2pix, "LockReleased")
|
||||
.withArgs(acc02.address, lockID);
|
||||
.withArgs(acc02.address, lockID, storage1.amount);
|
||||
expect(storage1.expirationBlock).to.eq(
|
||||
ethers.BigNumber.from(16),
|
||||
);
|
||||
|
@ -1358,6 +1358,11 @@ describe("P2PIX", () => {
|
|||
["uint256", "uint256", "address"],
|
||||
[0, 25, acc02.address],
|
||||
);
|
||||
|
||||
const storage1: Lock = await p2pix.callStatic.mapLocks(lockID);
|
||||
const storage2: Lock = await p2pix.callStatic.mapLocks(lockID2);
|
||||
const storage3: Lock = await p2pix.callStatic.mapLocks(lockID3);
|
||||
|
||||
// relayerPremium == 0
|
||||
const tx = await p2pix
|
||||
.connect(acc01)
|
||||
|
@ -1412,13 +1417,13 @@ describe("P2PIX", () => {
|
|||
expect(tx2).to.be.ok;
|
||||
await expect(tx)
|
||||
.to.emit(p2pix, "LockReleased")
|
||||
.withArgs(acc02.address, lockID);
|
||||
.withArgs(acc02.address, lockID, storage1.amount);
|
||||
await expect(tx1)
|
||||
.to.emit(p2pix, "LockReleased")
|
||||
.withArgs(acc02.address, lockID2);
|
||||
.withArgs(acc02.address, lockID2, storage2.amount);
|
||||
await expect(tx2)
|
||||
.to.emit(p2pix, "LockReleased")
|
||||
.withArgs(acc02.address, lockID3);
|
||||
.withArgs(acc02.address, lockID3, storage3.amount);
|
||||
expect(used1).to.eq(true);
|
||||
expect(used2).to.eq(true);
|
||||
expect(used3).to.eq(true);
|
||||
|
|
Loading…
Reference in New Issue